[mutter/wip/shape: 3/4] shaped-texture: Use non-deprecated cogl APIs



commit 50e9edcb76ed14fba3a3809cb7f61f8557a3f929
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Aug 27 16:25:40 2013 -0400

    shaped-texture: Use non-deprecated cogl APIs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706930

 src/compositor/meta-shaped-texture.c |   44 ++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 83c227c..0e3ce86 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -155,6 +155,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
   ClutterActorBox alloc;
   CoglContext *ctx;
   CoglPipeline *pipeline;
+  CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
 
   if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
     return;
@@ -208,12 +209,10 @@ meta_shaped_texture_paint (ClutterActor *actor)
   {
     CoglColor color;
     guchar opacity = clutter_actor_get_paint_opacity (actor);
-    cogl_color_set_from_4ub (&color, opacity, opacity, opacity, opacity);
+    cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity);
     cogl_pipeline_set_color (pipeline, &color);
   }
 
-  cogl_set_source (pipeline);
-
   clutter_actor_get_allocation_box (actor, &alloc);
 
   if (priv->clip_region)
@@ -256,17 +255,19 @@ meta_shaped_texture_paint (ClutterActor *actor)
               coords[6] = coords[2];
               coords[7] = coords[3];
 
-              cogl_rectangle_with_multitexture_coords (x1, y1, x2, y2,
-                                                       &coords[0], 8);
+              cogl_framebuffer_draw_multitextured_rectangle (fb, pipeline,
+                                                             x1, y1, x2, y2,
+                                                             &coords[0], 8);
             }
 
           goto out;
        }
     }
 
-  cogl_rectangle (0, 0,
-                 alloc.x2 - alloc.x1,
-                 alloc.y2 - alloc.y1);
+  cogl_framebuffer_draw_rectangle (fb, pipeline,
+                                   0, 0,
+                                   alloc.x2 - alloc.x1,
+                                   alloc.y2 - alloc.y1);
 
  out:
   cogl_object_unref (pipeline);
@@ -281,13 +282,16 @@ meta_shaped_texture_pick (ClutterActor       *actor,
 
   /* If there is no region then use the regular pick */
   if (priv->mask_texture == NULL)
-    CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class)
-      ->pick (actor, color);
+    CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class)->pick (actor, color);
   else if (clutter_actor_should_pick_paint (actor))
     {
       CoglTexture *paint_tex;
       ClutterActorBox alloc;
       guint tex_width, tex_height;
+      CoglPipeline *pipeline;
+      CoglContext *ctx;
+      CoglFramebuffer *fb;
+      CoglColor cogl_color;
 
       paint_tex = COGL_TEXTURE (priv->texture);
 
@@ -300,17 +304,21 @@ meta_shaped_texture_pick (ClutterActor       *actor,
       if (tex_width == 0 || tex_height == 0) /* no contents yet */
         return;
 
-      cogl_set_source_color4ub (color->red, color->green, color->blue,
-                                 color->alpha);
+      ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
+      fb = cogl_get_draw_framebuffer ();
+
+      cogl_color_init_from_4ub (&cogl_color, color->red, color->green, color->blue, color->alpha);
+
+      pipeline = cogl_pipeline_new (ctx);
+      cogl_pipeline_set_layer_texture (pipeline, 0, priv->mask_texture);
+      cogl_pipeline_set_color (pipeline, &cogl_color);
 
       clutter_actor_get_allocation_box (actor, &alloc);
 
-      /* Paint the mask rectangle in the given color */
-      cogl_set_source_texture (priv->mask_texture);
-      cogl_rectangle_with_texture_coords (0, 0,
-                                          alloc.x2 - alloc.x1,
-                                          alloc.y2 - alloc.y1,
-                                          0, 0, 1, 1);
+      cogl_framebuffer_draw_rectangle (fb, pipeline,
+                                       0, 0,
+                                       alloc.x2 - alloc.x1,
+                                       alloc.y2 - alloc.y1);
     }
 }
 


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