[gtk/wip/baedert/css-values: 75/102] csscolorvalue: Don't copy rgbas when applying function
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 75/102] csscolorvalue: Don't copy rgbas when applying function
- Date: Sat, 18 Jan 2020 07:51:44 +0000 (UTC)
commit 7d1f915a612db3c8da6a31c87f8cf83a70971c00
Author: Timm Bäder <mail baedert org>
Date: Sat Jan 11 11:54:39 2020 +0100
csscolorvalue: Don't copy rgbas when applying function
We get const pointers to the colors, so just use those and unref the
values later.
gtk/gtkcsscolorvalue.c | 62 ++++++++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkcsscolorvalue.c b/gtk/gtkcsscolorvalue.c
index 28154002a5..8c496886d4 100644
--- a/gtk/gtkcsscolorvalue.c
+++ b/gtk/gtkcsscolorvalue.c
@@ -381,59 +381,61 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
break;
case COLOR_TYPE_SHADE:
{
- GtkCssValue *val;
- GdkRGBA shade;
+ const GdkRGBA *c;
+ GtkCssValue *val;
+ GdkRGBA shade;
- val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
- if (val == NULL)
- return NULL;
-
- apply_shade (gtk_css_color_value_get_rgba (val), &shade, color->sym_col.shade.factor);
+ val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
+ if (val == NULL)
+ return NULL;
+ c = gtk_css_color_value_get_rgba (val);
- _gtk_css_value_unref (val);
+ apply_shade (c, &shade, color->sym_col.shade.factor);
value = _gtk_css_color_value_new_literal (&shade);
+ _gtk_css_value_unref (val);
}
break;
case COLOR_TYPE_ALPHA:
{
- GtkCssValue *val;
- GdkRGBA alpha;
-
- val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
- if (val == NULL)
- return NULL;
+ const GdkRGBA *c;
+ GtkCssValue *val;
+ GdkRGBA alpha;
- alpha = *gtk_css_color_value_get_rgba (val);
- apply_alpha (&alpha, &alpha, color->sym_col.alpha.factor);
+ val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
+ if (val == NULL)
+ return NULL;
+ c = gtk_css_color_value_get_rgba (val);
- _gtk_css_value_unref (val);
+ apply_alpha (c, &alpha, color->sym_col.alpha.factor);
value = _gtk_css_color_value_new_literal (&alpha);
+ _gtk_css_value_unref (val);
}
break;
case COLOR_TYPE_MIX:
{
- GtkCssValue *val;
- GdkRGBA color1, color2, res;
+ const GdkRGBA *color1, *color2;
+ GtkCssValue *val1, *val2;
+ GdkRGBA res;
- val = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
- if (val == NULL)
- return NULL;
- color1 = *gtk_css_color_value_get_rgba (val);
- _gtk_css_value_unref (val);
+ val1 = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
+ if (val1 == NULL)
+ return NULL;
+ color1 = gtk_css_color_value_get_rgba (val1);
- val = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
- if (val == NULL)
- return NULL;
- color2 = *gtk_css_color_value_get_rgba (val);
- _gtk_css_value_unref (val);
+ val2 = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
+ if (val2 == NULL)
+ return NULL;
+ color2 = gtk_css_color_value_get_rgba (val2);
- apply_mix (&color1, &color2, &res, color->sym_col.mix.factor);
+ apply_mix (color1, color2, &res, color->sym_col.mix.factor);
value = _gtk_css_color_value_new_literal (&res);
+ _gtk_css_value_unref (val1);
+ _gtk_css_value_unref (val2);
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]