summaryrefslogtreecommitdiff
path: root/gtk/gtkcssenumvalue.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-12-04 16:35:58 +0100
committerBenjamin Otte <otte@redhat.com>2015-12-04 17:44:51 +0100
commita37220109fa0952e4f3c7e188ccd574cdac6a660 (patch)
tree052aa683adc526d77b863fe0e9c731f0db55f068 /gtk/gtkcssenumvalue.c
parentcefba86fb366adc3584ad59607e1a8864d1bd9f8 (diff)
downloadgtk+-a37220109fa0952e4f3c7e188ccd574cdac6a660.tar.gz
render: Split out icon-effect apply function
Diffstat (limited to 'gtk/gtkcssenumvalue.c')
-rw-r--r--gtk/gtkcssenumvalue.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 39c14e7345..1f356a30ad 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -923,6 +923,39 @@ _gtk_css_icon_effect_value_get (const GtkCssValue *value)
return value->value;
}
+void
+gtk_css_icon_effect_apply (GtkCssIconEffect icon_effect,
+ cairo_surface_t *surface)
+{
+ cairo_t *cr;
+
+ switch (icon_effect)
+ {
+ case GTK_CSS_ICON_EFFECT_DIM:
+ cr = cairo_create (surface);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0); /* transparent */
+ cairo_paint_with_alpha (cr, 0.5);
+ cairo_destroy (cr);
+ break;
+
+ case GTK_CSS_ICON_EFFECT_HIGHLIGHT:
+ cr = cairo_create (surface);
+ cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
+ cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
+ /* DANGER: We mask with ourself - that works for images, but... */
+ cairo_mask_surface (cr, surface, 0, 0);
+ cairo_destroy (cr);
+ break;
+
+ default:
+ g_warn_if_reached ();
+ /* fall through */
+ case GTK_CSS_ICON_EFFECT_NONE:
+ break;
+ }
+}
+
/* GtkCssIconStyle */
static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {