[gtk+] themingengine: Do pattern merging smarter



commit 48814c8d1e9788afe87d3e29a33d17610d632850
Author: Benjamin Otte <otte redhat com>
Date:   Sat Jun 11 04:06:22 2011 +0200

    themingengine: Do pattern merging smarter
    
    Create an intermdiate surface and fill() with it later. Instead of doing
    clip + paint twice.

 gtk/gtkthemingengine.c |   38 ++++++++++++++------------------------
 1 files changed, 14 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 51c80b4..863ea8c 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -1510,7 +1510,7 @@ render_background_internal (GtkThemingEngine *engine,
   cairo_pattern_t *pattern;
   GtkStateFlags flags;
   gboolean running;
-  gdouble progress, alpha = 1;
+  gdouble progress;
   GtkCssBorderCornerRadius *top_left_radius, *top_right_radius;
   GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius;
   GtkCssBorderRadius border_radius = { { 0, },  };
@@ -1641,22 +1641,22 @@ render_background_internal (GtkThemingEngine *engine,
             }
           else
             {
-              /* Different pattern types, or different color
-               * stop counts, alpha blend both patterns.
-               */
-              _cairo_round_rectangle_sides (cr, &border_radius,
-                                            0, 0, width, height,
-                                            SIDE_ALL);
+              cairo_save (cr);
+
+              cairo_rectangle (cr, 0, 0, width, height);
+              cairo_clip (cr);
+
+              cairo_push_group (cr);
 
               cairo_scale (cr, width, height);
               cairo_set_source (cr, other_pattern);
-              cairo_scale (cr, 1.0 / width, 1.0 / height);
-              cairo_fill_preserve (cr);
+              cairo_paint_with_alpha (cr, progress);
+              cairo_set_source (cr, pattern);
+              cairo_paint_with_alpha (cr, 1.0 - progress);
+
+              new_pattern = cairo_pop_group (cr);
 
-              /* Set alpha for posterior drawing
-               * of the target pattern
-               */
-              alpha = 1 - progress;
+              cairo_restore (cr);
             }
         }
       else if (pattern || other_pattern)
@@ -1740,17 +1740,7 @@ render_background_internal (GtkThemingEngine *engine,
   else
     gdk_cairo_set_source_rgba (cr, &bg_color);
 
-  if (alpha == 1)
-    {
-      cairo_fill (cr);
-    }
-  else
-    {
-      cairo_save (cr);
-      cairo_clip (cr);
-      cairo_paint_with_alpha (cr, alpha);
-      cairo_restore (cr);
-    }
+  cairo_fill (cr);
 
   if (pattern)
     cairo_pattern_destroy (pattern);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]