Revert "[rectangle] Avoid modifying materials mid scene"
This reverts commit 8cf42ea8ac5c05f6b443c453f9c6c2a3cd75acfa. Since the journal puts material colors in the vertex array accumulated for drawing we don't need to flush the journal simply due to color changes which means using cogl_set_source_color4ub is no longer a concern.
This commit is contained in:
parent
5ffbe05248
commit
6ee8e15654
@ -60,10 +60,8 @@ enum
|
|||||||
|
|
||||||
struct _ClutterRectanglePrivate
|
struct _ClutterRectanglePrivate
|
||||||
{
|
{
|
||||||
ClutterColor primary_color;
|
ClutterColor color;
|
||||||
CoglHandle primary_material;
|
ClutterColor border_color;
|
||||||
ClutterColor border_color;
|
|
||||||
CoglHandle border_material;
|
|
||||||
|
|
||||||
guint border_width;
|
guint border_width;
|
||||||
|
|
||||||
@ -80,7 +78,6 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
ClutterRectanglePrivate *priv;
|
ClutterRectanglePrivate *priv;
|
||||||
ClutterGeometry geom;
|
ClutterGeometry geom;
|
||||||
guint8 tmp_alpha;
|
guint8 tmp_alpha;
|
||||||
guint8 opacity;
|
|
||||||
|
|
||||||
rectangle = CLUTTER_RECTANGLE(self);
|
rectangle = CLUTTER_RECTANGLE(self);
|
||||||
priv = rectangle->priv;
|
priv = rectangle->priv;
|
||||||
@ -91,8 +88,6 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
: "unknown");
|
: "unknown");
|
||||||
clutter_actor_get_allocation_geometry (self, &geom);
|
clutter_actor_get_allocation_geometry (self, &geom);
|
||||||
|
|
||||||
opacity = clutter_actor_get_paint_opacity (self);
|
|
||||||
|
|
||||||
/* parent paint call will have translated us into position so
|
/* parent paint call will have translated us into position so
|
||||||
* paint from 0, 0
|
* paint from 0, 0
|
||||||
*/
|
*/
|
||||||
@ -101,26 +96,15 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
/* compute the composited opacity of the actor taking into
|
/* compute the composited opacity of the actor taking into
|
||||||
* account the opacity of the color set by the user
|
* account the opacity of the color set by the user
|
||||||
*/
|
*/
|
||||||
tmp_alpha = opacity * priv->border_color.alpha / 255;
|
tmp_alpha = clutter_actor_get_paint_opacity (self)
|
||||||
|
* priv->border_color.alpha
|
||||||
|
/ 255;
|
||||||
|
|
||||||
/* paint the border */
|
/* paint the border */
|
||||||
|
cogl_set_source_color4ub (priv->border_color.red,
|
||||||
/* We are assuming this is a NOP when the color doesn't change.
|
priv->border_color.green,
|
||||||
* This is important since we should aim to never modify
|
priv->border_color.blue,
|
||||||
* materials mid-scene. */
|
tmp_alpha);
|
||||||
cogl_material_set_color4ub (priv->border_material,
|
|
||||||
priv->border_color.red,
|
|
||||||
priv->border_color.green,
|
|
||||||
priv->border_color.blue,
|
|
||||||
tmp_alpha);
|
|
||||||
|
|
||||||
cogl_set_source (priv->border_material);
|
|
||||||
|
|
||||||
cogl_material_set_color4ub (priv->border_material,
|
|
||||||
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 */
|
/* this sucks, but it's the only way to make a border */
|
||||||
cogl_rectangle (priv->border_width, 0,
|
cogl_rectangle (priv->border_width, 0,
|
||||||
@ -140,16 +124,15 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
priv->border_width,
|
priv->border_width,
|
||||||
geom.height - priv->border_width);
|
geom.height - priv->border_width);
|
||||||
|
|
||||||
tmp_alpha = opacity * priv->primary_color.alpha / 255;
|
tmp_alpha = clutter_actor_get_paint_opacity (self)
|
||||||
|
* priv->color.alpha
|
||||||
|
/ 255;
|
||||||
|
|
||||||
/* now paint the rectangle */
|
/* now paint the rectangle */
|
||||||
cogl_set_source (priv->primary_material);
|
cogl_set_source_color4ub (priv->color.red,
|
||||||
|
priv->color.green,
|
||||||
cogl_material_set_color4ub (priv->primary_material,
|
priv->color.blue,
|
||||||
priv->primary_color.red,
|
tmp_alpha);
|
||||||
priv->primary_color.green,
|
|
||||||
priv->primary_color.blue,
|
|
||||||
tmp_alpha);
|
|
||||||
|
|
||||||
cogl_rectangle (priv->border_width, priv->border_width,
|
cogl_rectangle (priv->border_width, priv->border_width,
|
||||||
geom.width - priv->border_width,
|
geom.width - priv->border_width,
|
||||||
@ -160,16 +143,14 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
/* compute the composited opacity of the actor taking into
|
/* compute the composited opacity of the actor taking into
|
||||||
* account the opacity of the color set by the user
|
* account the opacity of the color set by the user
|
||||||
*/
|
*/
|
||||||
tmp_alpha = opacity * priv->primary_color.alpha / 255;
|
tmp_alpha = clutter_actor_get_paint_opacity (self)
|
||||||
|
* priv->color.alpha
|
||||||
|
/ 255;
|
||||||
|
|
||||||
/* now paint the rectangle */
|
cogl_set_source_color4ub (priv->color.red,
|
||||||
cogl_set_source (priv->primary_material);
|
priv->color.green,
|
||||||
|
priv->color.blue,
|
||||||
cogl_material_set_color4ub (priv->primary_material,
|
tmp_alpha);
|
||||||
priv->primary_color.red,
|
|
||||||
priv->primary_color.green,
|
|
||||||
priv->primary_color.blue,
|
|
||||||
tmp_alpha);
|
|
||||||
|
|
||||||
cogl_rectangle (0, 0, geom.width, geom.height);
|
cogl_rectangle (0, 0, geom.width, geom.height);
|
||||||
}
|
}
|
||||||
@ -216,7 +197,7 @@ clutter_rectangle_get_property (GObject *object,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_COLOR:
|
case PROP_COLOR:
|
||||||
clutter_value_set_color (value, &priv->primary_color);
|
clutter_value_set_color (value, &priv->color);
|
||||||
break;
|
break;
|
||||||
case PROP_BORDER_COLOR:
|
case PROP_BORDER_COLOR:
|
||||||
clutter_value_set_color (value, &priv->border_color);
|
clutter_value_set_color (value, &priv->border_color);
|
||||||
@ -327,10 +308,8 @@ clutter_rectangle_init (ClutterRectangle *self)
|
|||||||
|
|
||||||
self->priv = priv = CLUTTER_RECTANGLE_GET_PRIVATE (self);
|
self->priv = priv = CLUTTER_RECTANGLE_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->primary_color = default_color;
|
priv->color = default_color;
|
||||||
priv->border_color = default_border_color;
|
priv->border_color = default_border_color;
|
||||||
priv->primary_material = cogl_material_new ();
|
|
||||||
priv->border_material = cogl_material_new ();
|
|
||||||
|
|
||||||
priv->border_width = 0;
|
priv->border_width = 0;
|
||||||
|
|
||||||
@ -385,10 +364,10 @@ clutter_rectangle_get_color (ClutterRectangle *rectangle,
|
|||||||
|
|
||||||
priv = rectangle->priv;
|
priv = rectangle->priv;
|
||||||
|
|
||||||
color->red = priv->primary_color.red;
|
color->red = priv->color.red;
|
||||||
color->green = priv->primary_color.green;
|
color->green = priv->color.green;
|
||||||
color->blue = priv->primary_color.blue;
|
color->blue = priv->color.blue;
|
||||||
color->alpha = priv->primary_color.alpha;
|
color->alpha = priv->color.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,10 +390,10 @@ clutter_rectangle_set_color (ClutterRectangle *rectangle,
|
|||||||
|
|
||||||
priv = rectangle->priv;
|
priv = rectangle->priv;
|
||||||
|
|
||||||
priv->primary_color.red = color->red;
|
priv->color.red = color->red;
|
||||||
priv->primary_color.green = color->green;
|
priv->color.green = color->green;
|
||||||
priv->primary_color.blue = color->blue;
|
priv->color.blue = color->blue;
|
||||||
priv->primary_color.alpha = color->alpha;
|
priv->color.alpha = color->alpha;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME - appears to be causing border to always get drawn */
|
/* FIXME - appears to be causing border to always get drawn */
|
||||||
@ -546,7 +525,7 @@ clutter_rectangle_set_border_color (ClutterRectangle *rectangle,
|
|||||||
priv->border_color.blue = color->blue;
|
priv->border_color.blue = color->blue;
|
||||||
priv->border_color.alpha = color->alpha;
|
priv->border_color.alpha = color->alpha;
|
||||||
|
|
||||||
if (clutter_color_equal (&priv->primary_color, &priv->border_color))
|
if (clutter_color_equal (&priv->color, &priv->border_color))
|
||||||
priv->has_border = FALSE;
|
priv->has_border = FALSE;
|
||||||
else
|
else
|
||||||
priv->has_border = TRUE;
|
priv->has_border = TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user