[clutter] Use the content scaling filters
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Use the content scaling filters
- Date: Fri, 16 Mar 2012 12:49:26 +0000 (UTC)
commit fb106ece058ee43673f425b997e34886540ac751
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Thu Mar 8 17:19:12 2012 +0000
Use the content scaling filters
Both ClutterCanvas and ClutterImage should use the minification and
magnification filters set on the actor, just like the use the content
box and the paint opacity.
clutter/clutter-canvas.c | 4 ++-
clutter/clutter-image.c | 4 ++-
clutter/clutter-paint-nodes.c | 58 ++++++++++++++++++++++++++++------------
clutter/clutter-paint-nodes.h | 4 ++-
4 files changed, 49 insertions(+), 21 deletions(-)
---
diff --git a/clutter/clutter-canvas.c b/clutter/clutter-canvas.c
index c0122ac..7913936 100644
--- a/clutter/clutter-canvas.c
+++ b/clutter/clutter-canvas.c
@@ -293,6 +293,7 @@ clutter_canvas_paint_content (ClutterContent *content,
ClutterActorBox box;
ClutterColor color;
guint8 paint_opacity;
+ ClutterScalingFilter min_f, mag_f;
if (self->priv->buffer == NULL)
return;
@@ -305,13 +306,14 @@ clutter_canvas_paint_content (ClutterContent *content,
clutter_actor_get_content_box (actor, &box);
paint_opacity = clutter_actor_get_paint_opacity (actor);
+ clutter_actor_get_content_scaling_filters (actor, &min_f, &mag_f);
color.red = paint_opacity;
color.green = paint_opacity;
color.blue = paint_opacity;
color.alpha = paint_opacity;
- node = clutter_texture_node_new (texture, &color);
+ node = clutter_texture_node_new (texture, &color, min_f, mag_f);
cogl_object_unref (texture);
clutter_paint_node_set_name (node, "Canvas");
diff --git a/clutter/clutter-image.c b/clutter/clutter-image.c
index 2f49f7a..9002bd8 100644
--- a/clutter/clutter-image.c
+++ b/clutter/clutter-image.c
@@ -87,6 +87,7 @@ clutter_image_paint_content (ClutterContent *content,
ClutterPaintNode *root)
{
ClutterImagePrivate *priv = CLUTTER_IMAGE (content)->priv;
+ ClutterScalingFilter min_f, mag_f;
ClutterPaintNode *node;
ClutterActorBox box;
ClutterColor color;
@@ -97,13 +98,14 @@ clutter_image_paint_content (ClutterContent *content,
clutter_actor_get_content_box (actor, &box);
paint_opacity = clutter_actor_get_paint_opacity (actor);
+ clutter_actor_get_content_scaling_filters (actor, &min_f, &mag_f);
color.red = paint_opacity;
color.green = paint_opacity;
color.blue = paint_opacity;
color.alpha = paint_opacity;
- node = clutter_texture_node_new (priv->texture, &color);
+ node = clutter_texture_node_new (priv->texture, &color, min_f, mag_f);
clutter_paint_node_set_name (node, "Image");
clutter_paint_node_add_rectangle (node, &box);
clutter_paint_node_add_child (root, node);
diff --git a/clutter/clutter-paint-nodes.c b/clutter/clutter-paint-nodes.c
index 63792de..3495ae7 100644
--- a/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter-paint-nodes.c
@@ -609,10 +609,30 @@ clutter_texture_node_init (ClutterTextureNode *self)
pnode->pipeline = cogl_pipeline_copy (default_texture_pipeline);
}
+static CoglPipelineFilter
+clutter_scaling_filter_to_cogl_pipeline_filter (ClutterScalingFilter filter)
+{
+ switch (filter)
+ {
+ case CLUTTER_SCALING_FILTER_NEAREST:
+ return COGL_PIPELINE_FILTER_NEAREST;
+
+ case CLUTTER_SCALING_FILTER_LINEAR:
+ return COGL_PIPELINE_FILTER_LINEAR;
+
+ case CLUTTER_SCALING_FILTER_BILINEAR:
+ return COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR;
+ }
+
+ return COGL_PIPELINE_FILTER_LINEAR;
+}
+
/**
* clutter_texture_node_new:
- * @texture: (allow-none): a #CoglTexture
- * @color: (allow-none): a #ClutterColor
+ * @texture: a #CoglTexture
+ * @color: a #ClutterColor
+ * @min_filter: the minification filter for the texture
+ * @mag_filter: the magnification filter for the texture
*
* Creates a new #ClutterPaintNode that will paint the passed @texture.
*
@@ -625,30 +645,32 @@ clutter_texture_node_init (ClutterTextureNode *self)
* Since: 1.10
*/
ClutterPaintNode *
-clutter_texture_node_new (CoglTexture *texture,
- const ClutterColor *color)
+clutter_texture_node_new (CoglTexture *texture,
+ const ClutterColor *color,
+ ClutterScalingFilter min_filter,
+ ClutterScalingFilter mag_filter)
{
ClutterPipelineNode *tnode;
+ CoglColor cogl_color;
+ CoglPipelineFilter min_f, mag_f;
- g_return_val_if_fail (texture == NULL || cogl_is_texture (texture), NULL);
+ g_return_val_if_fail (cogl_is_texture (texture), NULL);
tnode = _clutter_paint_node_internal (CLUTTER_TYPE_TEXTURE_NODE);
- if (texture != NULL)
- cogl_pipeline_set_layer_texture (tnode->pipeline, 0, texture);
+ cogl_pipeline_set_layer_texture (tnode->pipeline, 0, texture);
- if (color != NULL)
- {
- CoglColor cogl_color;
+ min_f = clutter_scaling_filter_to_cogl_pipeline_filter (min_filter);
+ mag_f = clutter_scaling_filter_to_cogl_pipeline_filter (mag_filter);
+ cogl_pipeline_set_layer_filters (tnode->pipeline, 0, min_f, mag_f);
- cogl_color_init_from_4ub (&cogl_color,
- color->red,
- color->green,
- color->blue,
- color->alpha);
- cogl_color_premultiply (&cogl_color);
- cogl_pipeline_set_color (tnode->pipeline, &cogl_color);
- }
+ cogl_color_init_from_4ub (&cogl_color,
+ color->red,
+ color->green,
+ color->blue,
+ color->alpha);
+ cogl_color_premultiply (&cogl_color);
+ cogl_pipeline_set_color (tnode->pipeline, &cogl_color);
return (ClutterPaintNode *) tnode;
}
diff --git a/clutter/clutter-paint-nodes.h b/clutter/clutter-paint-nodes.h
index 8305e47..3eb2cf7 100644
--- a/clutter/clutter-paint-nodes.h
+++ b/clutter/clutter-paint-nodes.h
@@ -71,7 +71,9 @@ typedef struct _ClutterTextureNodeClass ClutterTextureNodeClass;
GType clutter_texture_node_get_type (void) G_GNUC_CONST;
ClutterPaintNode * clutter_texture_node_new (CoglTexture *texture,
- const ClutterColor *color);
+ const ClutterColor *color,
+ ClutterScalingFilter min_filter,
+ ClutterScalingFilter mag_filter);
#define CLUTTER_TYPE_CLIP_NODE (clutter_clip_node_get_type ())
#define CLUTTER_CLIP_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLIP_NODE, ClutterClipNode))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]