shaped-texture: Use non-deprecated cogl APIs

https://bugzilla.gnome.org/show_bug.cgi?id=707019
This commit is contained in:
Jasper St. Pierre 2013-08-27 16:25:40 -04:00
parent 69f038f7c7
commit 452be05ea0

View File

@ -221,11 +221,12 @@ meta_shaped_texture_paint (ClutterActor *actor)
{ {
MetaShapedTexture *stex = (MetaShapedTexture *) actor; MetaShapedTexture *stex = (MetaShapedTexture *) actor;
MetaShapedTexturePrivate *priv = stex->priv; MetaShapedTexturePrivate *priv = stex->priv;
CoglTexture *paint_tex;
guint tex_width, tex_height; guint tex_width, tex_height;
ClutterActorBox alloc;
CoglContext *ctx; CoglContext *ctx;
CoglPipeline *pipeline; CoglFramebuffer *fb;
CoglPipeline *pipeline = NULL;
CoglTexture *paint_tex;
ClutterActorBox alloc;
if (priv->clip_region && cairo_region_is_empty (priv->clip_region)) if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
return; return;
@ -263,6 +264,7 @@ meta_shaped_texture_paint (ClutterActor *actor)
return; return;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
fb = cogl_get_draw_framebuffer ();
if (priv->mask_texture == NULL) if (priv->mask_texture == NULL)
{ {
@ -279,12 +281,10 @@ meta_shaped_texture_paint (ClutterActor *actor)
{ {
CoglColor color; CoglColor color;
guchar opacity = clutter_actor_get_paint_opacity (actor); 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_pipeline_set_color (pipeline, &color);
} }
cogl_set_source (pipeline);
clutter_actor_get_allocation_box (actor, &alloc); clutter_actor_get_allocation_box (actor, &alloc);
if (priv->clip_region) if (priv->clip_region)
@ -327,20 +327,23 @@ meta_shaped_texture_paint (ClutterActor *actor)
coords[6] = coords[2]; coords[6] = coords[2];
coords[7] = coords[3]; coords[7] = coords[3];
cogl_rectangle_with_multitexture_coords (x1, y1, x2, y2, cogl_framebuffer_draw_multitextured_rectangle (fb, pipeline,
&coords[0], 8); x1, y1, x2, y2,
&coords[0], 8);
} }
goto out; goto out;
} }
} }
cogl_rectangle (0, 0, cogl_framebuffer_draw_rectangle (fb, pipeline,
alloc.x2 - alloc.x1, 0, 0,
alloc.y2 - alloc.y1); alloc.x2 - alloc.x1,
alloc.y2 - alloc.y1);
out: out:
cogl_object_unref (pipeline); if (pipeline != NULL)
cogl_object_unref (pipeline);
} }
static void static void
@ -356,13 +359,16 @@ meta_shaped_texture_pick (ClutterActor *actor,
/* If there is no region then use the regular pick */ /* If there is no region then use the regular pick */
if (priv->input_shape_region == NULL) if (priv->input_shape_region == NULL)
CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class) CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class)->pick (actor, color);
->pick (actor, color);
else else
{ {
int n_rects; int n_rects;
float *rectangles; float *rectangles;
int i; int i;
CoglPipeline *pipeline;
CoglContext *ctx;
CoglFramebuffer *fb;
CoglColor cogl_color;
/* Note: We don't bother trying to intersect the pick and clip regions /* Note: We don't bother trying to intersect the pick and clip regions
* since needing to copy the region, do the intersection, and probably * since needing to copy the region, do the intersection, and probably
@ -391,12 +397,17 @@ meta_shaped_texture_pick (ClutterActor *actor,
rectangles[pos + 3] = rect.y + rect.height; rectangles[pos + 3] = rect.y + rect.height;
} }
cogl_set_source_color4ub (color->red, ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
color->green, fb = cogl_get_draw_framebuffer ();
color->blue,
color->alpha);
cogl_rectangles (rectangles, n_rects); cogl_color_init_from_4ub (&cogl_color, color->red, color->green, color->blue, color->alpha);
pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color (pipeline, &cogl_color);
cogl_framebuffer_draw_rectangles (fb, pipeline,
rectangles, n_rects);
cogl_object_unref (pipeline);
} }
} }