]> Pileus Git - ~andy/gtk/commitdiff
Instead of drawing a background pixmap in with gdk_draw_pixmap(), set it
authorOwen Taylor <otaylor@redhat.com>
Wed, 20 Jan 1999 18:06:31 +0000 (18:06 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 20 Jan 1999 18:06:31 +0000 (18:06 +0000)
Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>

* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
a background pixmap in with gdk_draw_pixmap(), set
it as a tile pixmap for a GC. This should speed
up things considerably and also will hide a bug
where text->first_onscreen_ver_pixel is being
corrupted, causing the bg pixmap drawing code to generate
graphics exposes.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktext.c
gtk/gtktext.h

index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 12c08f78393e5be98d5fa2de6a80ae98317bb35d..08a543ffc79875e6e224dfb0bd6bda5ec86c91ab 100644 (file)
@@ -1,3 +1,13 @@
+Wed Jan 20 13:06:51 1999  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
+       a background pixmap in with gdk_draw_pixmap(), set
+       it as a tile pixmap for a GC. This should speed
+       up things considerably and also will hide a bug
+       where text->first_onscreen_ver_pixel is being
+       corrupted, causing the bg pixmap drawing code to generate
+       graphics exposes.
+
 Tue Jan 19 22:15:10 1999  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtklist.c
index 8ef9b1aea80fd02aa9aa2f2bd733b6ad24b9375c..b28a4405cc7e6d5adfbfdc121ef21fad186ffdee 100644 (file)
@@ -296,6 +296,7 @@ static void delete_expose (GtkText* text,
                           guint nchars,
                           guint old_lines, 
                           guint old_pixels);
+static GdkGC *create_bg_gc (GtkText *text);
 static void clear_area (GtkText *text, GdkRectangle *area);
 static void draw_line (GtkText* text,
                       gint pixel_height,
@@ -669,6 +670,7 @@ gtk_text_init (GtkText *text)
   text->hadj = NULL;
   text->vadj = NULL;
   text->gc = NULL;
+  text->bg_gc = NULL;
   text->line_wrap_bitmap = NULL;
   text->line_arrow_bitmap = NULL;
   
@@ -1302,6 +1304,9 @@ gtk_text_realize (GtkWidget *widget)
   /* Can't call gtk_style_set_background here because it's handled specially */
   gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
   gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
+
+  if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
+    text->bg_gc = create_bg_gc (text);
   
   text->line_wrap_bitmap = gdk_bitmap_create_from_data (text->text_area,
                                                        (gchar*) line_wrap_bits,
@@ -1407,6 +1412,15 @@ gtk_text_style_set       (GtkWidget      *widget,
       gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
       gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
       
+      if (text->bg_gc)
+       {
+         gdk_gc_destroy (text->bg_gc);
+         text->bg_gc = NULL;
+       }
+
+      if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
+       text->bg_gc = create_bg_gc (text);
+
       recompute_geometry (text);
     }
 
@@ -1447,6 +1461,12 @@ gtk_text_unrealize (GtkWidget *widget)
   
   gdk_gc_destroy (text->gc);
   text->gc = NULL;
+
+  if (text->bg_gc)
+    {
+      gdk_gc_destroy (text->bg_gc);
+      text->bg_gc = NULL;
+    }
   
   gdk_pixmap_unref (text->line_wrap_bitmap);
   gdk_pixmap_unref (text->line_arrow_bitmap);
@@ -1466,47 +1486,16 @@ clear_focus_area (GtkText *text, gint area_x, gint area_y, gint area_width, gint
   gint xthick = TEXT_BORDER_ROOM + widget->style->klass->xthickness;
   
   gint width, height;
-  gint xorig, yorig;
-  gint x, y;
   
   gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
   
-  yorig = - text->first_onscreen_ver_pixel + ythick;
-  xorig = - text->first_onscreen_hor_pixel + xthick;
-  
-  while (yorig > 0)
-    yorig -= height;
-  
-  while (xorig > 0)
-    xorig -= width;
-  
-  for (y = area_y; y < area_y + area_height; )
-    {
-      gint yoff = (y - yorig) % height;
-      gint yw = MIN(height - yoff, (area_y + area_height) - y);
-      
-      for (x = area_x; x < area_x + area_width; )
-       {
-         gint xoff = (x - xorig) % width;
-         gint xw = MIN(width - xoff, (area_x + area_width) - x);
-         
-         gdk_draw_pixmap (widget->window,
-                          text->gc,
-                          widget->style->bg_pixmap[GTK_STATE_NORMAL],
-                          xoff,
-                          yoff,
-                          x,
-                          y,
-                          xw,
-                          yw);
-         
-         x += width - xoff;
-       }
-      y += height - yoff;
-    }
-}
-
+  gdk_gc_set_ts_origin (text->bg_gc,
+                       (- text->first_onscreen_hor_pixel + xthick) % width,
+                       (- text->first_onscreen_ver_pixel + ythick) % height);
 
+  gdk_draw_rectangle (GTK_WIDGET (text)->window, text->bg_gc, TRUE,
+                     area_x, area_y, area_width, area_height);
+}
 
 static void
 gtk_text_draw_focus (GtkWidget *widget)
@@ -5231,46 +5220,35 @@ draw_cursor (GtkText* text, gint absolute)
     }
 }
 
+static GdkGC *
+create_bg_gc (GtkText *text)
+{
+  GdkGCValues values;
+  
+  values.tile = GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL];
+  values.fill = GDK_TILED;
+
+  return gdk_gc_new_with_values (text->text_area, &values,
+                                GDK_GC_FILL | GDK_GC_TILE);
+}
+
 static void
 clear_area (GtkText *text, GdkRectangle *area)
 {
   GtkWidget *widget = GTK_WIDGET (text);
   
-  if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
+  if (text->bg_gc)
     {
       gint width, height;
-      gint x = area->x, y = area->y;
-      gint xorig, yorig;
       
       gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
       
-      yorig = - text->first_onscreen_ver_pixel;
-      xorig = - text->first_onscreen_hor_pixel;
-      
-      for (y = area->y; y < area->y + area->height; )
-       {
-         gint yoff = (y - yorig) % height;
-         gint yw = MIN(height - yoff, (area->y + area->height) - y);
-         
-         for (x = area->x; x < area->x + area->width; )
-           {
-             gint xoff = (x - xorig) % width;
-             gint xw = MIN(width - xoff, (area->x + area->width) - x);
-             
-             gdk_draw_pixmap (text->text_area,
-                              text->gc,
-                              widget->style->bg_pixmap[GTK_STATE_NORMAL],
-                              xoff,
-                              yoff,
-                              x,
-                              y,
-                              xw,
-                              yw);
-             
-             x += width - xoff;
-           }
-         y += height - yoff;
-       }
+      gdk_gc_set_ts_origin (text->bg_gc,
+                           (- text->first_onscreen_hor_pixel) % width,
+                           (- text->first_onscreen_ver_pixel) % height);
+
+      gdk_draw_rectangle (text->text_area, text->bg_gc, TRUE,
+                         area->x, area->y, area->width, area->height);
     }
   else
     gdk_window_clear_area (text->text_area, area->x, area->y, area->width, area->height);
index f8f35af6c71bbcdabcf7059f657ab0290023581e..8ccdb493ce4fbb834cb0fd5e4fae51ee07725f1a 100644 (file)
@@ -154,6 +154,7 @@ struct _GtkText
   gint timer;
   
   guint button;                        /* currently pressed mouse button */
+  GdkGC *bg_gc;                        /* gc for drawing background pixmap */
 };
 
 struct _GtkTextClass