[maemo-commits] [maemo-commits] r19144 - projects/haf/branches/gtk+/temp-rgba/gdk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Aug 18 17:13:03 EEST 2009
Author: herzi
Date: 2009-08-18 17:13:01 +0300 (Tue, 18 Aug 2009)
New Revision: 19144

Modified:
   projects/haf/branches/gtk+/temp-rgba/gdk/gdkwindow.c
Log:
from gordon


Modified: projects/haf/branches/gtk+/temp-rgba/gdk/gdkwindow.c
===================================================================
--- projects/haf/branches/gtk+/temp-rgba/gdk/gdkwindow.c	2009-08-18 14:08:30 UTC (rev 19143)
+++ projects/haf/branches/gtk+/temp-rgba/gdk/gdkwindow.c	2009-08-18 14:13:01 UTC (rev 19144)
@@ -388,7 +388,7 @@
       attributes->wclass != GDK_INPUT_ONLY &&
       gdk_drawable_get_depth (window) == 32)
     {
-      gdk_window_set_composited (window, TRUE);
+      //gdk_window_set_composited (window, TRUE);
       gdk_window_set_auto_composite (window, TRUE);
     }
 #endif
@@ -1065,6 +1065,38 @@
 #include "x11/gdkx.h"
 #endif
 
+
+static void
+dump_changes (GdkWindow *window)
+{
+  int width, height;
+  gdk_drawable_get_size (GDK_DRAWABLE (window),
+                         &width, &height);
+  if (width<200 | height<60)
+    return;
+
+  cairo_t* cr = gdk_cairo_create (window);
+  gint counter = 0;
+  for (counter = 0; counter < 1000; counter++)
+    {
+      gchar* png_name = g_strdup_printf ("/home/user/%d.png", counter);
+
+      if (g_file_test (png_name, G_FILE_TEST_IS_REGULAR))
+        {
+          g_free (png_name);
+          continue;
+        }
+
+      g_message ("saving to %s\n", png_name);
+      cairo_surface_write_to_png (cairo_get_target (cr),
+                                  png_name);
+      g_free (png_name);
+      break;
+    }
+  cairo_destroy (cr);
+}
+
+
 /**
  * gdk_window_begin_paint_region:
  * @window: a #GdkWindow
@@ -1126,6 +1158,8 @@
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
+  dump_changes(window);
+
   if (GDK_IS_PAINTABLE (private->impl)) 
     {
       GdkPaintableIface *iface = GDK_PAINTABLE_GET_IFACE (private->impl);
@@ -1147,21 +1181,13 @@
 		    MAX (clip_box.width, 1), MAX (clip_box.height, 1), -1);
 
   paint->surface = _gdk_drawable_ref_cairo_surface (paint->pixmap);
-#ifdef MAEMO_CHANGES
-  if (gdk_drawable_get_depth (paint->pixmap) == 32)
-    {
-      cairo_t* cr = gdk_cairo_create (paint->pixmap);
-      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-      cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
-      gdk_cairo_region (cr, paint->region);
-      cairo_clip (cr);
-      cairo_paint (cr);
-      cairo_destroy (cr);
-    }
-#endif
   cairo_surface_set_device_offset (paint->surface,
 				   - paint->x_offset, - paint->y_offset);
   
+  /* TODO: Maybe we also subtract areas for non-composited windows from
+   * paint->region? */
+
+
   for (list = private->paint_stack; list != NULL; list = list->next)
     {
       GdkWindowPaint *tmp_paint = list->data;
@@ -1179,20 +1205,32 @@
     }
 
 #ifdef MAEMO_CHANGES
+  /* If we are 32 bit, set the area that we are *not* rendering to
+   * to be transparent. This means when we blit it back, it won't
+   * overwrite what is already there. */
   if (gdk_drawable_get_depth (window) == 32)
     {
+      GdkRegion *inverse = gdk_region_rectangle(&clip_box);
+      gdk_region_subtract(inverse, region);
+
+      if (!gdk_region_empty(inverse))
+        {
       cairo_t* cr = gdk_cairo_create (window);
       cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
       cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
-      gdk_cairo_region (cr, region);
+          gdk_cairo_region (cr, inverse);
       cairo_clip (cr);
       cairo_paint (cr);
       cairo_destroy (cr);
     }
+
+      gdk_region_destroy(inverse);
+    }
 #endif
 #endif /* USE_BACKING_STORE */
 }
 
+
 /**
  * gdk_window_end_paint:
  * @window: a #GdkWindow
@@ -1255,49 +1293,16 @@
   gdk_gc_set_clip_region (tmp_gc, paint->region);
   gdk_gc_set_clip_origin (tmp_gc, - x_offset, - y_offset);
 
-  gdk_draw_drawable (private->impl, tmp_gc, paint->pixmap,
-                     clip_box.x - paint->x_offset,
-                     clip_box.y - paint->y_offset,
-                     clip_box.x - x_offset, clip_box.y - y_offset,
-                     clip_box.width, clip_box.height);
-
-  if (private->redirect)
-    {
-      GdkWindowClipData data;
-      
-      setup_redirect_clip (window, tmp_gc, &data);
-#ifndef MAEMO_CHANGES
-      gdk_draw_drawable (private->redirect->pixmap, tmp_gc, paint->pixmap,
-			 clip_box.x - paint->x_offset,
-			 clip_box.y - paint->y_offset,
-			 clip_box.x + data.x_offset,
-			 clip_box.y + data.y_offset,
-			 clip_box.width, clip_box.height);
-#else
-      cairo_t* cr = gdk_cairo_create (private->redirect->pixmap);
-      cairo_rectangle (cr,
-                       clip_box.x + data.x_offset,
-                       clip_box.y + data.y_offset,
-                       clip_box.width, clip_box.height);
-      gdk_cairo_set_source_pixmap (cr, paint->pixmap,
-                                   clip_box.x - paint->x_offset,
-                                   clip_box.y - paint->y_offset);
-      cairo_fill (cr);
-      cairo_destroy (cr);
-#endif
-      reset_redirect_clip (window, tmp_gc, &data);
-    }
-
 #ifdef MAEMO_CHANGES
-#if 1
-  /* this is the code that works */
-  cr = gdk_cairo_create (window);
+  /* compose subwindows onto this pixmap */
+  cr = gdk_cairo_create (paint->pixmap);
   for (subwindow = gdk_window_peek_children (window);
        subwindow;
        subwindow = subwindow->next)
     {
       int x, y, w, h;
 
+      /* We should maybe ignore this here, or stuff probably won't appear? */
       if (!gdk_window_get_auto_composite (subwindow->data))
         continue;
 
@@ -1312,22 +1317,30 @@
       cairo_restore (cr);
     }
   cairo_destroy (cr);
-#else
-  /* and this is the code that should be working according to timj */
-  if (gdk_window_get_auto_composite (window))
+
+  /* finally paint the pixmap onto the window */
+  gdk_draw_drawable (private->impl, tmp_gc, paint->pixmap,
+                     clip_box.x - paint->x_offset,
+                     clip_box.y - paint->y_offset,
+                     clip_box.x, clip_box.y,
+                     clip_box.width, clip_box.height);
+#endif
+
+  if (private->redirect)
     {
-      int x, y, w, h;
+      GdkWindowClipData data;
 
-      cr = gdk_cairo_create (gdk_window_get_parent (window));
-      gdk_window_get_position (window, &x, &y);
-      gdk_window_get_size     (window, &w, &h);
-      gdk_cairo_set_source_pixmap (cr, window, x, y);
-      cairo_rectangle (cr, x, y, w, h);
-      cairo_fill (cr);
-      cairo_destroy (cr);
+      setup_redirect_clip (window, tmp_gc, &data);
+
+      gdk_draw_drawable (private->redirect->pixmap, tmp_gc, paint->pixmap,
+                         clip_box.x - paint->x_offset,
+                         clip_box.y - paint->y_offset,
+                         clip_box.x + data.x_offset,
+                         clip_box.y + data.y_offset,
+                         clip_box.width, clip_box.height);
+
+      reset_redirect_clip (window, tmp_gc, &data);
     }
-#endif
-#endif
 
   /* Reset clip region of the cached GdkGC */
   gdk_gc_set_clip_region (tmp_gc, NULL);
@@ -1367,6 +1380,8 @@
     }
 #endif
 #endif /* USE_BACKING_STORE */
+
+  dump_changes(window);
 }
 
 static void
@@ -4345,12 +4360,12 @@
   if (private->auto_composite == auto_composite)
     return;
 
-  if (!private->composited && auto_composite)
+ /* if (!private->composited && auto_composite)
     {
       g_warning ("gdk_window_set_auto_composite called but "
                  "window is not composited");
       return;
-    }
+    }*/
 
   private->auto_composite = auto_composite;
 }

More information about the maemo-commits mailing list