[gtk+/wip/ebassi/gsk-renderer: 180/194] gsk: Move scaling filters to GskRenderNode
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 180/194] gsk: Move scaling filters to GskRenderNode
- Date: Wed, 24 Aug 2016 10:21:26 +0000 (UTC)
commit 338c2f5e0f6862979205729f6efee6212c58969c
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sat Aug 13 08:34:22 2016 +0100
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.
gsk/gskglrenderer.c | 27 ++++------
gsk/gskrenderer.c | 125 --------------------------------------------
gsk/gskrenderer.h | 8 ---
gsk/gskrendernode.c | 16 ++++++
gsk/gskrendernode.h | 5 ++
gsk/gskrendernodeprivate.h | 4 ++
6 files changed, 35 insertions(+), 150 deletions(-)
---
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 4d5c4f3..f9218ea 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 5d97d85..b81c9df 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 28c587a..6019539 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 c39480e..63a1c37 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 d597ea7..1aaa43a 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 84ee2f0..8077e73 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]