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.
This commit is contained in:
parent
77729c7362
commit
fb106ece05
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*
|
||||
@ -626,20 +646,23 @@ clutter_texture_node_init (ClutterTextureNode *self)
|
||||
*/
|
||||
ClutterPaintNode *
|
||||
clutter_texture_node_new (CoglTexture *texture,
|
||||
const ClutterColor *color)
|
||||
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);
|
||||
|
||||
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,
|
||||
@ -648,7 +671,6 @@ clutter_texture_node_new (CoglTexture *texture,
|
||||
color->alpha);
|
||||
cogl_color_premultiply (&cogl_color);
|
||||
cogl_pipeline_set_color (tnode->pipeline, &cogl_color);
|
||||
}
|
||||
|
||||
return (ClutterPaintNode *) tnode;
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user