diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2016-08-13 08:34:22 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2016-10-18 11:49:14 +0100 |
commit | 387ed37f743c3fccd18638deca86e252a191660c (patch) | |
tree | c33021229a4ff3bf4fea57739ed8c34d04a9adfd /gsk | |
parent | 3bdd9c270afd15e7a983b8a5d703dbc7404dd9fb (diff) | |
download | gtk+-387ed37f743c3fccd18638deca86e252a191660c.tar.gz |
gsk: Move scaling filters to GskRenderNode
The renderer will always use nearest-neighbor filters because it renders
at 1:1 pixel to texel ratio.
On the other hand, render nodes may be scaled, so we need to offer a way
to control the minification and magnification filters.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gskglrenderer.c | 27 | ||||
-rw-r--r-- | gsk/gskrenderer.c | 125 | ||||
-rw-r--r-- | gsk/gskrenderer.h | 8 | ||||
-rw-r--r-- | gsk/gskrendernode.c | 16 | ||||
-rw-r--r-- | gsk/gskrendernode.h | 5 | ||||
-rw-r--r-- | gsk/gskrendernodeprivate.h | 4 |
6 files changed, 35 insertions, 150 deletions
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c index 4d5c4f3698..f9218eae0e 100644 --- a/gsk/gskglrenderer.c +++ b/gsk/gskglrenderer.c @@ -107,9 +107,6 @@ struct _GskGLRenderer GskGLProfiler *gl_profiler; GskShaderBuilder *shader_builder; - int gl_min_filter; - int gl_mag_filter; - int blend_program_id; int blit_program_id; @@ -515,15 +512,11 @@ render_item (GskGLRenderer *self, } static void -get_gl_scaling_filters (GskRenderer *renderer, - int *min_filter_r, - int *mag_filter_r) +get_gl_scaling_filters (GskRenderNode *node, + int *min_filter_r, + int *mag_filter_r) { - GskScalingFilter min_filter, mag_filter; - - gsk_renderer_get_scaling_filters (renderer, &min_filter, &mag_filter); - - switch (min_filter) + switch (node->min_filter) { case GSK_SCALING_FILTER_NEAREST: *min_filter_r = GL_NEAREST; @@ -538,7 +531,7 @@ get_gl_scaling_filters (GskRenderer *renderer, break; } - switch (mag_filter) + switch (node->mag_filter) { case GSK_SCALING_FILTER_NEAREST: *mag_filter_r = GL_NEAREST; @@ -711,6 +704,9 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, else if (gsk_render_node_has_surface (node)) { cairo_surface_t *surface = gsk_render_node_get_surface (node); + int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST; + + get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter); /* Upload the Cairo surface to a GL texture */ item.render_data.texture_id = gsk_gl_driver_create_texture (self->gl_driver, @@ -720,8 +716,8 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, gsk_gl_driver_init_texture_with_surface (self->gl_driver, item.render_data.texture_id, surface, - self->gl_min_filter, - self->gl_mag_filter); + gl_min_filter, + gl_mag_filter); } else { @@ -869,9 +865,6 @@ gsk_gl_renderer_render (GskRenderer *renderer, gsk_gl_renderer_update_frustum (self, &modelview, &projection); - get_gl_scaling_filters (GSK_RENDERER (self), - &self->gl_min_filter, - &self->gl_mag_filter); if (!gsk_gl_renderer_validate_tree (self, root, &projection)) goto out; diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index 5d97d85467..b81c9dff9d 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -82,8 +82,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GskRenderer, gsk_renderer, G_TYPE_OBJECT) enum { PROP_VIEWPORT = 1, - PROP_MINIFICATION_FILTER, - PROP_MAGNIFICATION_FILTER, PROP_AUTO_CLEAR, PROP_USE_ALPHA, PROP_SCALE_FACTOR, @@ -149,14 +147,6 @@ gsk_renderer_set_property (GObject *gobject, gsk_renderer_set_viewport (self, g_value_get_boxed (value)); break; - case PROP_MINIFICATION_FILTER: - gsk_renderer_set_scaling_filters (self, g_value_get_enum (value), priv->mag_filter); - break; - - case PROP_MAGNIFICATION_FILTER: - gsk_renderer_set_scaling_filters (self, priv->min_filter, g_value_get_enum (value)); - break; - case PROP_AUTO_CLEAR: gsk_renderer_set_auto_clear (self, g_value_get_boolean (value)); break; @@ -195,14 +185,6 @@ gsk_renderer_get_property (GObject *gobject, g_value_set_boxed (value, &priv->viewport); break; - case PROP_MINIFICATION_FILTER: - g_value_set_enum (value, priv->min_filter); - break; - - case PROP_MAGNIFICATION_FILTER: - g_value_set_enum (value, priv->mag_filter); - break; - case PROP_AUTO_CLEAR: g_value_set_boolean (value, priv->auto_clear); break; @@ -277,44 +259,6 @@ gsk_renderer_class_init (GskRendererClass *klass) G_PARAM_EXPLICIT_NOTIFY); /** - * GskRenderer:minification-filter: - * - * The filter to be used when scaling textures down. - * - * See also: gsk_renderer_set_scaling_filters() - * - * Since: 3.22 - */ - gsk_renderer_properties[PROP_MINIFICATION_FILTER] = - g_param_spec_enum ("minification-filter", - "Minification Filter", - "The minification filter used by the renderer for texture targets", - GSK_TYPE_SCALING_FILTER, - GSK_SCALING_FILTER_LINEAR, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | - G_PARAM_EXPLICIT_NOTIFY); - - /** - * GskRenderer:magnification-filter: - * - * The filter to be used when scaling textures up. - * - * See also: gsk_renderer_set_scaling_filters() - * - * Since: 3.22 - */ - gsk_renderer_properties[PROP_MAGNIFICATION_FILTER] = - g_param_spec_enum ("magnification-filter", - "Magnification Filter", - "The magnification filter used by the renderer for texture targets", - GSK_TYPE_SCALING_FILTER, - GSK_SCALING_FILTER_LINEAR, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | - G_PARAM_EXPLICIT_NOTIFY); - - /** * GskRenderer:auto-clear: * * Automatically clear the rendering surface when rendering. @@ -419,9 +363,6 @@ gsk_renderer_init (GskRenderer *self) priv->auto_clear = TRUE; priv->scale_factor = 1; - - priv->min_filter = GSK_SCALING_FILTER_LINEAR; - priv->mag_filter = GSK_SCALING_FILTER_LINEAR; } /** @@ -479,72 +420,6 @@ gsk_renderer_get_viewport (GskRenderer *renderer, } /** - * gsk_renderer_set_scaling_filters: - * @renderer: a #GskRenderer - * @min_filter: the minification scaling filter - * @mag_filter: the magnification scaling filter - * - * Sets the scaling filters to be applied when scaling textures - * up and down. - * - * Since: 3.22 - */ -void -gsk_renderer_set_scaling_filters (GskRenderer *renderer, - GskScalingFilter min_filter, - GskScalingFilter mag_filter) -{ - GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer); - GObject *gobject; - - g_return_if_fail (GSK_IS_RENDERER (renderer)); - - gobject = G_OBJECT (renderer); - - g_object_freeze_notify (gobject); - - if (priv->min_filter != min_filter) - { - priv->min_filter = min_filter; - g_object_notify_by_pspec (gobject, gsk_renderer_properties[PROP_MINIFICATION_FILTER]); - } - - if (priv->mag_filter != mag_filter) - { - priv->mag_filter = mag_filter; - g_object_notify_by_pspec (gobject, gsk_renderer_properties[PROP_MAGNIFICATION_FILTER]); - } - - g_object_thaw_notify (gobject); -} - -/** - * gsk_renderer_get_scaling_filters: - * @renderer: a #GskRenderer - * @min_filter: (out) (nullable): return location for the minification filter - * @mag_filter: (out) (nullable): return location for the magnification filter - * - * Retrieves the minification and magnification filters used by the #GskRenderer. - * - * Since: 3.22 - */ -void -gsk_renderer_get_scaling_filters (GskRenderer *renderer, - GskScalingFilter *min_filter, - GskScalingFilter *mag_filter) -{ - GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer); - - g_return_if_fail (GSK_IS_RENDERER (renderer)); - - if (min_filter != NULL) - *min_filter = priv->min_filter; - - if (mag_filter != NULL) - *mag_filter = priv->mag_filter; -} - -/** * gsk_renderer_set_scale_factor: * @renderer: a #GskRenderer * @scale_factor: the new scale factor diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h index 28c587ad0c..60195396e1 100644 --- a/gsk/gskrenderer.h +++ b/gsk/gskrenderer.h @@ -49,14 +49,6 @@ GDK_AVAILABLE_IN_3_22 void gsk_renderer_get_viewport (GskRenderer *renderer, graphene_rect_t *viewport); GDK_AVAILABLE_IN_3_22 -void gsk_renderer_set_scaling_filters (GskRenderer *renderer, - GskScalingFilter min_filter, - GskScalingFilter mag_filter); -GDK_AVAILABLE_IN_3_22 -void gsk_renderer_get_scaling_filters (GskRenderer *renderer, - GskScalingFilter *min_filter, - GskScalingFilter *mag_filter); -GDK_AVAILABLE_IN_3_22 void gsk_renderer_set_scale_factor (GskRenderer *renderer, int scale_factor); GDK_AVAILABLE_IN_3_22 diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c index c39480ee13..63a1c371be 100644 --- a/gsk/gskrendernode.c +++ b/gsk/gskrendernode.c @@ -182,6 +182,9 @@ gsk_render_node_init (GskRenderNode *self) self->opacity = 1.0; + self->min_filter = GSK_SCALING_FILTER_NEAREST; + self->mag_filter = GSK_SCALING_FILTER_NEAREST; + self->is_mutable = TRUE; self->needs_world_matrix_update = TRUE; } @@ -1244,6 +1247,19 @@ gsk_render_node_get_surface (GskRenderNode *node) return node->surface; } +void +gsk_render_node_set_scaling_filters (GskRenderNode *node, + GskScalingFilter min_filter, + GskScalingFilter mag_filter) +{ + g_return_if_fail (GSK_IS_RENDER_NODE (node)); + + if (node->min_filter != min_filter) + node->min_filter = min_filter; + if (node->mag_filter != mag_filter) + node->mag_filter = mag_filter; +} + /*< private > * gsk_render_node_get_world_matrix: * @node: a #GskRenderNode diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h index d597ea7163..1aaa43ab5b 100644 --- a/gsk/gskrendernode.h +++ b/gsk/gskrendernode.h @@ -124,6 +124,11 @@ void gsk_render_node_set_texture (GskRenderNode * int texture_id); GDK_AVAILABLE_IN_3_22 +void gsk_render_node_set_scaling_filter (GskRenderNode *node, + GskScalingFilter min_filter, + GskScalingFilter mag_filter); + +GDK_AVAILABLE_IN_3_22 int gsk_render_node_get_scale_factor (GskRenderNode *node); GDK_AVAILABLE_IN_3_22 diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h index 84ee2f08fd..8077e73eeb 100644 --- a/gsk/gskrendernodeprivate.h +++ b/gsk/gskrendernodeprivate.h @@ -47,6 +47,10 @@ struct _GskRenderNode /* Blend mode */ GskBlendMode blend_mode; + /* Scaling filters */ + GskScalingFilter min_filter; + GskScalingFilter mag_filter; + /* Clip rectangle */ graphene_rect_t bounds; |