[mutter/wip/cairo: 6/11] theme: Use cairo for TINT operations with alpha



commit 90887d6e7f2df437f6ff96e322dab748fd6d0657
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Feb 29 23:20:44 2012 -0500

    theme: Use cairo for TINT operations with alpha
    
    https://bugzilla.gnome.org/show_bug.cgi?id=662962

 src/ui/theme.c |   73 +++++++------------------------------------------------
 1 files changed, 10 insertions(+), 63 deletions(-)
---
diff --git a/src/ui/theme.c b/src/ui/theme.c
index e9ae3fb..2221894 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3405,42 +3405,6 @@ draw_op_as_pixbuf (const MetaDrawOp    *op,
 
   switch (op->type)
     {
-    case META_DRAW_TINT:
-      {
-        GdkRGBA color;
-        guint32 rgba;
-        gboolean has_alpha;
-
-        meta_color_spec_render (op->data.rectangle.color_spec,
-                                context,
-                                &color);
-
-        has_alpha =
-          op->data.tint.alpha_spec &&
-          (op->data.tint.alpha_spec->n_alphas > 1 ||
-           op->data.tint.alpha_spec->alphas[0] != 0xff);
-        
-        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
-                                 has_alpha,
-                                 8, width, height);
-
-        if (!has_alpha)
-          {
-            rgba = GDK_COLOR_RGBA (color);
-            
-            gdk_pixbuf_fill (pixbuf, rgba);
-          }
-        else if (op->data.tint.alpha_spec->n_alphas == 1)
-          {
-            rgba = GDK_COLOR_RGBA (color);
-            rgba &= ~0xff;
-            rgba |= op->data.tint.alpha_spec->alphas[0];
-            
-            gdk_pixbuf_fill (pixbuf, rgba);
-          }
-      }
-      break;
-
     case META_DRAW_IMAGE:
       {
         if (op->data.image.colorize_spec)
@@ -3483,6 +3447,7 @@ draw_op_as_pixbuf (const MetaDrawOp    *op,
           }
         break;
       }
+    case META_DRAW_TINT:
     case META_DRAW_ICON:
     case META_DRAW_LINE:
     case META_DRAW_RECTANGLE:
@@ -3761,41 +3726,23 @@ meta_draw_op_draw_with_env (const MetaDrawOp    *op,
     case META_DRAW_TINT:
       {
         int rx, ry, rwidth, rheight;
-        gboolean needs_alpha;
-        
-        needs_alpha = op->data.tint.alpha_spec &&
-          (op->data.tint.alpha_spec->n_alphas > 1 ||
-           op->data.tint.alpha_spec->alphas[0] != 0xff);
-        
+
         rx = parse_x_position_unchecked (op->data.tint.x, env);
         ry = parse_y_position_unchecked (op->data.tint.y, env);
         rwidth = parse_size_unchecked (op->data.tint.width, env);
         rheight = parse_size_unchecked (op->data.tint.height, env);
 
-        if (!needs_alpha)
-          {
-            meta_color_spec_render (op->data.tint.color_spec,
-                                    style_gtk, &color);
-            gdk_cairo_set_source_rgba (cr, &color);
-
-            cairo_rectangle (cr, rx, ry, rwidth, rheight);
-            cairo_fill (cr);
-          }
-        else
-          {
-            GdkPixbuf *pixbuf;
+        meta_color_spec_render (op->data.tint.color_spec,
+                                style_gtk, &color);
 
-            pixbuf = draw_op_as_pixbuf (op, style_gtk, info,
-                                        rwidth, rheight);
+        if (op->data.tint.alpha_spec &&
+            op->data.tint.alpha_spec->n_alphas == 1)
+          color.alpha = op->data.tint.alpha_spec->alphas[0];
 
-            if (pixbuf)
-              {
-                gdk_cairo_set_source_pixbuf (cr, pixbuf, rx, ry);
-                cairo_paint (cr);
+        gdk_cairo_set_source_rgba (cr, &color);
 
-                g_object_unref (G_OBJECT (pixbuf));
-              }
-          }
+        cairo_rectangle (cr, rx, ry, rwidth, rheight);
+        cairo_fill (cr);
       }
       break;
 



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