]> Pileus Git - ~andy/gtk/commitdiff
Use a scratch GC in the case where the background is a solid color.
authorSoeren Sandmann <sandmann@daimi.au.dk>
Wed, 18 Feb 2004 17:03:46 +0000 (17:03 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Wed, 18 Feb 2004 17:03:46 +0000 (17:03 +0000)
Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

* gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
case where the background is a solid color.
(gdk_window_clear_backing_rect): Reset the clip region after use.

* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
back to using a scratch GC. Pointed out by Owen Taylor

* gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
scratch GC if the passed-in one is NULL

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkdraw.c
gdk/gdkpixbuf-render.c
gdk/gdkwindow.c

index 9020a70b2a043e9dc9b04dcf60730de6a646e84d..ba8da9872e50a5abd1e0b6af8099fac840589b53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
+       case where the background is a solid color.
+       (gdk_window_clear_backing_rect): Reset the clip region after use.
+
+       * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
+       back to using a scratch GC. Pointed out by Owen Taylor
+       
+       * gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
+       scratch GC if the passed-in one is NULL
+
 Wed Feb 18 14:27:08 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gdk/gdkwindow.c (gdk_window_get_composite_drawable): Reset clip
index 9020a70b2a043e9dc9b04dcf60730de6a646e84d..ba8da9872e50a5abd1e0b6af8099fac840589b53 100644 (file)
@@ -1,3 +1,15 @@
+Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
+       case where the background is a solid color.
+       (gdk_window_clear_backing_rect): Reset the clip region after use.
+
+       * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
+       back to using a scratch GC. Pointed out by Owen Taylor
+       
+       * gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
+       scratch GC if the passed-in one is NULL
+
 Wed Feb 18 14:27:08 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gdk/gdkwindow.c (gdk_window_get_composite_drawable): Reset clip
index 9020a70b2a043e9dc9b04dcf60730de6a646e84d..ba8da9872e50a5abd1e0b6af8099fac840589b53 100644 (file)
@@ -1,3 +1,15 @@
+Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
+       case where the background is a solid color.
+       (gdk_window_clear_backing_rect): Reset the clip region after use.
+
+       * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
+       back to using a scratch GC. Pointed out by Owen Taylor
+       
+       * gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
+       scratch GC if the passed-in one is NULL
+
 Wed Feb 18 14:27:08 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gdk/gdkwindow.c (gdk_window_get_composite_drawable): Reset clip
index 9020a70b2a043e9dc9b04dcf60730de6a646e84d..ba8da9872e50a5abd1e0b6af8099fac840589b53 100644 (file)
@@ -1,3 +1,15 @@
+Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
+       case where the background is a solid color.
+       (gdk_window_clear_backing_rect): Reset the clip region after use.
+
+       * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
+       back to using a scratch GC. Pointed out by Owen Taylor
+       
+       * gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
+       scratch GC if the passed-in one is NULL
+
 Wed Feb 18 14:27:08 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gdk/gdkwindow.c (gdk_window_get_composite_drawable): Reset clip
index 9020a70b2a043e9dc9b04dcf60730de6a646e84d..ba8da9872e50a5abd1e0b6af8099fac840589b53 100644 (file)
@@ -1,3 +1,15 @@
+Wed Feb 18 17:53:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gdk/gdkwindow.c (gdk_window_get_bg_gc): Use a scratch GC in the
+       case where the background is a solid color.
+       (gdk_window_clear_backing_rect): Reset the clip region after use.
+
+       * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Go
+       back to using a scratch GC. Pointed out by Owen Taylor
+       
+       * gdk/gdkdraw.c (gdk_drawable_real_draw_pixbuf): Only use a
+       scratch GC if the passed-in one is NULL
+
 Wed Feb 18 14:27:08 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gdk/gdkwindow.c (gdk_window_get_composite_drawable): Reset clip
index 79fa0966586a50c0e4509218b26d628537c96ddf..da845032e54dc5fb61adbb67871c4f6df90d8233 100644 (file)
@@ -1404,7 +1404,8 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable  *drawable,
     return;
   
   /* Actually draw */
-  gc = _gdk_drawable_get_scratch_gc (drawable, FALSE);
+  if (!gc)
+    gc = _gdk_drawable_get_scratch_gc (drawable, FALSE);
   
   if (pixbuf->has_alpha)
     {
@@ -1540,8 +1541,8 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable  *drawable,
  * the standard values for @drawable, except for the graphics_exposures
  * field which is determined by the @graphics_exposures parameter.
  *
- * The returned #GdkGC must not be altered in any way and must not
- * be freed.
+ * The foreground color of the returned #GdkGC is undefined. The #GdkGC
+ * must not be altered in any way, except to change its foreground color.
  * 
  * Return value: A #GdkGC suitable for drawing on @drawable
  * 
@@ -1561,7 +1562,7 @@ _gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
   g_return_val_if_fail (!screen->closed, NULL);
 
   depth = gdk_drawable_get_depth (drawable);
-  
+
   if (graphics_exposures)
     {
       if (!screen->exposure_gcs[depth])
index 0065ed13f814147fcbb8a0339caefa68f9a002a9..2675c399511cf5d0b57fba7104ea5e88419e13fd 100644 (file)
@@ -82,14 +82,13 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
   if (width == 0 || height == 0)
     return;
 
-  gc = gdk_gc_new (bitmap);
+  gc = _gdk_drawable_get_scratch_gc (bitmap, FALSE);
 
   if (!pixbuf->has_alpha)
     {
       color.pixel = (alpha_threshold == 255) ? 0 : 1;
       gdk_gc_set_foreground (gc, &color);
       gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
-      g_object_unref (gc);
       return;
     }
 
@@ -131,8 +130,6 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
                       start + dest_x, y + dest_y,
                       x - 1 + dest_x, y + dest_y);
     }
-
-  g_object_unref (gc);
 }
 
 \f
index a1fc8294bd4f584c5fe77e0b21d7fedb0df9dc88..7ad957d59f105213c8e5b6a4db1c0643d1087e29 100644 (file)
@@ -851,41 +851,6 @@ gdk_window_begin_paint_rect (GdkWindow    *window,
   gdk_region_destroy (region);
 }
 
-static GdkGC *
-gdk_window_get_bg_gc (GdkWindow      *window,
-                     GdkWindowPaint *paint)
-{
-  GdkWindowObject *private = (GdkWindowObject *)window;
-
-  guint gc_mask = 0;
-  GdkGCValues gc_values;
-
-  if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG && private->parent)
-    {
-      GdkWindowPaint tmp_paint = *paint;
-      tmp_paint.x_offset += private->x;
-      tmp_paint.y_offset += private->y;
-      
-      return gdk_window_get_bg_gc (GDK_WINDOW (private->parent), &tmp_paint);
-    }
-  else if (private->bg_pixmap && 
-           private->bg_pixmap != GDK_PARENT_RELATIVE_BG && 
-           private->bg_pixmap != GDK_NO_BG)
-    {
-      gc_values.fill = GDK_TILED;
-      gc_values.tile = private->bg_pixmap;
-      
-      gc_mask = GDK_GC_FILL | GDK_GC_TILE;
-    }
-  else
-    {
-      gc_values.foreground = private->bg_color;
-      gc_mask = GDK_GC_FOREGROUND;
-    }
-
-  return gdk_gc_new_with_values (paint->pixmap, &gc_values, gc_mask);
-}
-
 #ifdef GDK_WINDOWING_X11
 #include "x11/gdkx.h"
 #endif
@@ -1663,6 +1628,44 @@ gdk_window_draw_glyphs (GdkDrawable      *drawable,
   RESTORE_GC (gc);
 }
 
+static GdkGC *
+gdk_window_get_bg_gc (GdkWindow      *window,
+                     GdkWindowPaint *paint)
+{
+  GdkWindowObject *private = (GdkWindowObject *)window;
+
+  guint gc_mask = 0;
+  GdkGCValues gc_values;
+
+  if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG && private->parent)
+    {
+      GdkWindowPaint tmp_paint = *paint;
+      tmp_paint.x_offset += private->x;
+      tmp_paint.y_offset += private->y;
+      
+      return gdk_window_get_bg_gc (GDK_WINDOW (private->parent), &tmp_paint);
+    }
+  else if (private->bg_pixmap && 
+           private->bg_pixmap != GDK_PARENT_RELATIVE_BG && 
+           private->bg_pixmap != GDK_NO_BG)
+    {
+      gc_values.fill = GDK_TILED;
+      gc_values.tile = private->bg_pixmap;
+      
+      gc_mask = GDK_GC_FILL | GDK_GC_TILE;
+
+      return gdk_gc_new_with_values (paint->pixmap, &gc_values, gc_mask);
+    }
+  else
+    {
+      GdkGC *gc = _gdk_drawable_get_scratch_gc (paint->pixmap, FALSE);
+
+      gdk_gc_set_foreground (gc, &(private->bg_color));
+
+      return g_object_ref (gc);
+    }
+}
+
 static void
 gdk_window_clear_backing_rect (GdkWindow *window,
                               gint       x,
@@ -1683,6 +1686,8 @@ gdk_window_clear_backing_rect (GdkWindow *window,
   gdk_draw_rectangle (window, tmp_gc, TRUE,
                      x, y, width, height);
 
+  gdk_gc_set_clip_region (tmp_gc, NULL);
+  
   g_object_unref (tmp_gc);
 }