diff options
author | Benjamin Otte <otte@redhat.com> | 2016-02-25 15:40:04 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-02-25 16:52:58 +0100 |
commit | 71a9fd9d83f118abc2ed087792459f3e47a555dd (patch) | |
tree | 83fd1955a507bf77a204733eac57d8e398dfdaf7 /gtk | |
parent | 374494b9285c88a5a16366a573eedc5e9537837f (diff) | |
download | gtk+-71a9fd9d83f118abc2ed087792459f3e47a555dd.tar.gz |
stylecontext: Move background_is_opaque() function
The new way, it no longer depends on the style context, but on the
CssStyle. This will become relevant in the next commit.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkpixelcache.c | 3 | ||||
-rw-r--r-- | gtk/gtkrenderbackground.c | 22 | ||||
-rw-r--r-- | gtk/gtkrenderbackgroundprivate.h | 16 | ||||
-rw-r--r-- | gtk/gtkstylecontext.c | 35 | ||||
-rw-r--r-- | gtk/gtkstylecontextprivate.h | 2 |
5 files changed, 39 insertions, 39 deletions
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c index dae40447a8..34a710b6ce 100644 --- a/gtk/gtkpixelcache.c +++ b/gtk/gtkpixelcache.c @@ -19,6 +19,7 @@ #include "gtkdebug.h" #include "gtkpixelcacheprivate.h" +#include "gtkrenderbackgroundprivate.h" #include "gtkstylecontextprivate.h" #define BLOW_CACHE_TIMEOUT_SEC 20 @@ -198,7 +199,7 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache, { content = CAIRO_CONTENT_COLOR_ALPHA; if (cache->style_context && - _gtk_style_context_is_background_opaque (cache->style_context)) + gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (cache->style_context))) content = CAIRO_CONTENT_COLOR; } diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c index 5b3591d298..a9a80f1636 100644 --- a/gtk/gtkrenderbackground.c +++ b/gtk/gtkrenderbackground.c @@ -25,6 +25,7 @@ #include "gtkcssarrayvalueprivate.h" #include "gtkcssbgsizevalueprivate.h" +#include "gtkcsscornervalueprivate.h" #include "gtkcssenumvalueprivate.h" #include "gtkcssimagevalueprivate.h" #include "gtkcssnumbervalueprivate.h" @@ -344,3 +345,24 @@ gtk_css_style_render_background (GtkCssStyle *style, cairo_restore (cr); } + +static gboolean +corner_value_is_right_angle (GtkCssValue *value) +{ + return _gtk_css_corner_value_get_x (value, 100) <= 0.0 && + _gtk_css_corner_value_get_y (value, 100) <= 0.0; +} + +gboolean +gtk_css_style_render_background_is_opaque (GtkCssStyle *style) +{ + const GdkRGBA *color; + + color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); + + return color->alpha >= 1.0 + && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS)) + && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS)) + && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS)) + && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS)); +} diff --git a/gtk/gtkrenderbackgroundprivate.h b/gtk/gtkrenderbackgroundprivate.h index b893b69397..52a6ffd687 100644 --- a/gtk/gtkrenderbackgroundprivate.h +++ b/gtk/gtkrenderbackgroundprivate.h @@ -28,13 +28,15 @@ G_BEGIN_DECLS -void gtk_css_style_render_background (GtkCssStyle *style, - cairo_t *cr, - gdouble x, - gdouble y, - gdouble width, - gdouble height, - GtkJunctionSides junction); +void gtk_css_style_render_background (GtkCssStyle *style, + cairo_t *cr, + gdouble x, + gdouble y, + gdouble width, + gdouble height, + GtkJunctionSides junction); +gboolean gtk_css_style_render_background_is_opaque (GtkCssStyle *style); + G_END_DECLS diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index bfb094838b..ed1ad917bb 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -27,7 +27,6 @@ #include "gtkcontainerprivate.h" #include "gtkcssanimatedstyleprivate.h" #include "gtkcsscolorvalueprivate.h" -#include "gtkcsscornervalueprivate.h" #include "gtkcssenumvalueprivate.h" #include "gtkcssimagevalueprivate.h" #include "gtkcssnodedeclarationprivate.h" @@ -45,6 +44,7 @@ #include "gtkdebug.h" #include "gtkintl.h" #include "gtkprivate.h" +#include "gtkrenderbackgroundprivate.h" #include "gtkrendericonprivate.h" #include "gtksettings.h" #include "gtksettingsprivate.h" @@ -2435,13 +2435,6 @@ gtk_style_context_invalidate (GtkStyleContext *context) gtk_style_context_validate (context, NULL); } -static gboolean -corner_value_is_right_angle (GtkCssValue *value) -{ - return _gtk_css_corner_value_get_x (value, 100) <= 0.0 && - _gtk_css_corner_value_get_y (value, 100) <= 0.0; -} - /** * gtk_style_context_set_background: * @context: a #GtkStyleContext @@ -2460,8 +2453,6 @@ void gtk_style_context_set_background (GtkStyleContext *context, GdkWindow *window) { - const GdkRGBA *color; - g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -2473,10 +2464,12 @@ gtk_style_context_set_background (GtkStyleContext *context, * * We could indeed just set black instead of the color we have. */ - color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); - - if (_gtk_style_context_is_background_opaque (context)) + if (gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (context))) { + const GdkRGBA *color; + + color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); + gdk_window_set_background_rgba (window, color); } else @@ -3188,22 +3181,6 @@ gtk_gradient_resolve_for_context (GtkGradient *gradient, priv->parent ? gtk_style_context_lookup_style (priv->parent) : NULL); } -gboolean -_gtk_style_context_is_background_opaque (GtkStyleContext *context) -{ - const GdkRGBA *color; - - g_return_val_if_fail (context != NULL, FALSE); - - color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); - - return (color->alpha >= 1.0 && - corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS)) && - corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS)) && - corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS)) && - corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS))); -} - /** * GtkStyleContextPrintFlags: * @GTK_STYLE_CONTEXT_PRINT_RECURSE: Print the entire tree of diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h index 91ce297cd4..421e5263fc 100644 --- a/gtk/gtkstylecontextprivate.h +++ b/gtk/gtkstylecontextprivate.h @@ -70,8 +70,6 @@ void _gtk_style_context_get_icon_extents (GtkStyleContext gint width, gint height); -gboolean _gtk_style_context_is_background_opaque (GtkStyleContext *context); - PangoAttrList *_gtk_style_context_get_pango_attributes (GtkStyleContext *context); /* Accessibility support */ |