Commit 4e8fb33f authored by Benjamin Otte's avatar Benjamin Otte

pixelcache: Don't have a style context argument

That would imply the pixelcache monitors the style context for changes
and it doesn't do that.

Its only use case was opacity checks, so add
gtk_pixel_cache_se_is_opaque() instead.
parent 71a9fd9d
......@@ -47,15 +47,13 @@ struct _GtkPixelCache {
/* may be null if not dirty */
cairo_region_t *surface_dirty;
/* background tracking for rgb/rgba */
GtkStyleContext *style_context;
guint timeout_tag;
guint extra_width;
guint extra_height;
guint always_cache : 1;
guint is_opaque : 1;
};
GtkPixelCache *
......@@ -93,8 +91,6 @@ _gtk_pixel_cache_free (GtkPixelCache *cache)
if (cache->surface_dirty != NULL)
cairo_region_destroy (cache->surface_dirty);
g_clear_object (&cache->style_context);
g_free (cache);
}
......@@ -197,10 +193,10 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
content = cache->content;
if (!content)
{
content = CAIRO_CONTENT_COLOR_ALPHA;
if (cache->style_context &&
gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (cache->style_context)))
if (cache->is_opaque)
content = CAIRO_CONTENT_COLOR;
else
content = CAIRO_CONTENT_COLOR_ALPHA;
}
surface_w = view_rect->width;
......@@ -504,9 +500,12 @@ _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
}
void
_gtk_pixel_cache_set_style_context (GtkPixelCache *cache,
GtkStyleContext *style_context)
gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
gboolean is_opaque)
{
if (g_set_object (&cache->style_context, style_context))
_gtk_pixel_cache_invalidate (cache, NULL);
if (cache->is_opaque == is_opaque)
return;
cache->is_opaque = is_opaque;
_gtk_pixel_cache_invalidate (cache, NULL);
}
......@@ -54,8 +54,8 @@ void _gtk_pixel_cache_set_content (GtkPixelCache *cache,
gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache);
void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
gboolean always_cache);
void _gtk_pixel_cache_set_style_context(GtkPixelCache *cache,
GtkStyleContext *style_context);
void gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
gboolean is_opaque);
G_END_DECLS
......
......@@ -37,6 +37,7 @@
#include "gtkmarshalers.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtkrenderbackgroundprivate.h"
#include "gtkseparatormenuitem.h"
#include "gtksettings.h"
#include "gtkselectionprivate.h"
......@@ -51,7 +52,6 @@
#include "gtkscrollable.h"
#include "gtktypebuiltins.h"
#include "gtktexthandleprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkpopover.h"
#include "gtktoolbar.h"
......@@ -1685,7 +1685,6 @@ gtk_text_view_init (GtkTextView *text_view)
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
_gtk_pixel_cache_set_style_context (priv->pixel_cache, context);
/* Set up default style */
priv->wrap_mode = GTK_WRAP_NONE;
......@@ -9775,10 +9774,18 @@ node_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkWidget *widget)
{
GtkTextViewPrivate *priv = GTK_TEXT_VIEW (widget)->priv;
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
if (node == priv->text_window->css_node)
{
GtkCssStyle *style = gtk_css_style_change_get_new_style (change);
gtk_pixel_cache_set_is_opaque (priv->pixel_cache, gtk_css_style_render_background_is_opaque (style));
}
}
static void
......
......@@ -33,7 +33,8 @@
#include "gtkpixelcacheprivate.h"
#include "gtkprivate.h"
#include "gtkscrollable.h"
#include "gtkrender.h"
#include "gtkrenderbackgroundprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
......@@ -937,6 +938,18 @@ gtk_viewport_draw (GtkWidget *widget,
return FALSE;
}
static void
gtk_viewport_update_pixelcache_opacity (GtkWidget *child,
GtkViewport *viewport)
{
GtkViewportPrivate *priv = viewport->priv;
gtk_pixel_cache_set_is_opaque (priv->pixel_cache,
gtk_css_style_render_background_is_opaque (
gtk_style_context_lookup_style (
gtk_widget_get_style_context (child))));
}
static void
gtk_viewport_remove (GtkContainer *container,
GtkWidget *child)
......@@ -944,10 +957,14 @@ gtk_viewport_remove (GtkContainer *container,
GtkViewport *viewport = GTK_VIEWPORT (container);
GtkViewportPrivate *priv = viewport->priv;
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
if (g_signal_handlers_disconnect_by_func (child, gtk_viewport_update_pixelcache_opacity, viewport) != 1)
{
g_assert_not_reached ();
}
_gtk_pixel_cache_set_style_context (priv->pixel_cache, NULL);
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
gtk_pixel_cache_set_is_opaque (priv->pixel_cache, FALSE);
}
static void
......@@ -961,11 +978,11 @@ gtk_viewport_add (GtkContainer *container,
g_return_if_fail (gtk_bin_get_child (bin) == NULL);
gtk_widget_set_parent_window (child, priv->bin_window);
_gtk_pixel_cache_set_style_context (priv->pixel_cache,
gtk_widget_get_style_context (child));
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->add (container, child);
g_signal_connect (child, "style-updated", G_CALLBACK (gtk_viewport_update_pixelcache_opacity), viewport);
gtk_viewport_update_pixelcache_opacity (child, viewport);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment