[mutter/gbsneto/explicit-framebuffer-preparations: 10/10] clutter-rectangle: Remove cogl_rectangle()
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/explicit-framebuffer-preparations: 10/10] clutter-rectangle: Remove cogl_rectangle()
- Date: Thu, 8 Nov 2018 23:33:46 +0000 (UTC)
commit 2542dadae68196d610450d29eabbfd97df280fc9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Nov 8 21:21:16 2018 -0200
clutter-rectangle: Remove cogl_rectangle()
clutter/clutter/deprecated/clutter-rectangle.c | 108 ++++++++++++++++---------
1 file changed, 70 insertions(+), 38 deletions(-)
---
diff --git a/clutter/clutter/deprecated/clutter-rectangle.c b/clutter/clutter/deprecated/clutter-rectangle.c
index 205ee3b29..1b48bc191 100644
--- a/clutter/clutter/deprecated/clutter-rectangle.c
+++ b/clutter/clutter/deprecated/clutter-rectangle.c
@@ -52,6 +52,8 @@
struct _ClutterRectanglePrivate
{
+ CoglPipeline *pipeline;
+
ClutterColor color;
ClutterColor border_color;
@@ -81,6 +83,7 @@ static void
clutter_rectangle_paint (ClutterActor *self)
{
ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
+ CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
ClutterGeometry geom;
guint8 tmp_alpha;
@@ -90,6 +93,13 @@ clutter_rectangle_paint (ClutterActor *self)
: "unknown");
clutter_actor_get_allocation_geometry (self, &geom);
+ if (G_UNLIKELY (priv->pipeline == NULL))
+ {
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ priv->pipeline = cogl_pipeline_new (ctx);
+ }
+
if (priv->has_border)
{
/* We paint the border and the content only if the rectangle
@@ -106,42 +116,53 @@ clutter_rectangle_paint (ClutterActor *self)
/ 255;
/* paint the border */
- cogl_set_source_color4ub (priv->border_color.red,
- priv->border_color.green,
- priv->border_color.blue,
- tmp_alpha);
+ cogl_pipeline_set_color4ub (priv->pipeline,
+ priv->border_color.red,
+ priv->border_color.green,
+ priv->border_color.blue,
+ tmp_alpha);
/* this sucks, but it's the only way to make a border */
- cogl_rectangle (priv->border_width, 0,
- geom.width,
- priv->border_width);
-
- cogl_rectangle (geom.width - priv->border_width,
- priv->border_width,
- geom.width,
- geom.height);
-
- cogl_rectangle (0, geom.height - priv->border_width,
- geom.width - priv->border_width,
- geom.height);
-
- cogl_rectangle (0, 0,
- priv->border_width,
- geom.height - priv->border_width);
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ priv->border_width, 0,
+ geom.width,
+ priv->border_width);
+
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ geom.width - priv->border_width,
+ priv->border_width,
+ geom.width, geom.height);
+
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ 0, geom.height - priv->border_width,
+ geom.width - priv->border_width,
+ geom.height);
+
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ 0, 0,
+ priv->border_width,
+ geom.height - priv->border_width);
tmp_alpha = clutter_actor_get_paint_opacity (self)
* priv->color.alpha
/ 255;
/* now paint the rectangle */
- cogl_set_source_color4ub (priv->color.red,
- priv->color.green,
- priv->color.blue,
- tmp_alpha);
-
- cogl_rectangle (priv->border_width, priv->border_width,
- geom.width - priv->border_width,
- geom.height - priv->border_width);
+ cogl_pipeline_set_color4ub (priv->pipeline,
+ priv->color.red,
+ priv->color.green,
+ priv->color.blue,
+ tmp_alpha);
+
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ priv->border_width, priv->border_width,
+ geom.width - priv->border_width,
+ geom.height - priv->border_width);
}
else
{
@@ -153,12 +174,15 @@ clutter_rectangle_paint (ClutterActor *self)
* priv->border_color.alpha
/ 255;
- cogl_set_source_color4ub (priv->border_color.red,
- priv->border_color.green,
- priv->border_color.blue,
- tmp_alpha);
+ cogl_pipeline_set_color4ub (priv->pipeline,
+ priv->border_color.red,
+ priv->border_color.green,
+ priv->border_color.blue,
+ tmp_alpha);
- cogl_rectangle (0, 0, geom.width, geom.height);
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ 0, 0, geom.width, geom.height);
}
}
else
@@ -170,12 +194,15 @@ clutter_rectangle_paint (ClutterActor *self)
* priv->color.alpha
/ 255;
- cogl_set_source_color4ub (priv->color.red,
- priv->color.green,
- priv->color.blue,
- tmp_alpha);
+ cogl_pipeline_set_color4ub (priv->pipeline,
+ priv->color.red,
+ priv->color.green,
+ priv->color.blue,
+ tmp_alpha);
- cogl_rectangle (0, 0, geom.width, geom.height);
+ cogl_framebuffer_draw_rectangle (framebuffer,
+ priv->pipeline,
+ 0, 0, geom.width, geom.height);
}
}
@@ -258,6 +285,11 @@ clutter_rectangle_get_property (GObject *object,
static void
clutter_rectangle_finalize (GObject *object)
{
+ ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE(object)->priv;
+
+ if (priv->pipeline)
+ cogl_object_unref (priv->pipeline);
+
G_OBJECT_CLASS (clutter_rectangle_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]