From aacc3d56284f6258e7853e5e086bcc05aca98c8d Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 5 Jul 2015 14:53:33 -0700 Subject: [PATCH] shaped-texture: Repeat edge pixels instead of mirroring the image While nothing will completely fix X11's artifacts, this tends to look a bit better, *especially* with mask textures that have black at the edges (which are most of them). It's also faster for GPUs to manage. --- src/compositor/meta-shaped-texture.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 685be36b4..31db9bcc0 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -187,10 +187,25 @@ meta_shaped_texture_dispose (GObject *object) G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object); } +static CoglPipeline * +get_base_pipeline (CoglContext *ctx) +{ + static CoglPipeline *template = NULL; + if (G_UNLIKELY (template == NULL)) + { + template = cogl_pipeline_new (ctx); + cogl_pipeline_set_layer_wrap_mode_s (template, 0, COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); + cogl_pipeline_set_layer_wrap_mode_t (template, 0, COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); + cogl_pipeline_set_layer_wrap_mode_s (template, 1, COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); + cogl_pipeline_set_layer_wrap_mode_t (template, 1, COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); + } + return template; +} + static CoglPipeline * get_unmasked_pipeline (CoglContext *ctx) { - return cogl_pipeline_new (ctx); + return cogl_pipeline_copy (get_base_pipeline (ctx)); } static CoglPipeline * @@ -199,7 +214,7 @@ get_masked_pipeline (CoglContext *ctx) static CoglPipeline *template = NULL; if (G_UNLIKELY (template == NULL)) { - template = cogl_pipeline_new (ctx); + template = cogl_pipeline_copy (get_base_pipeline (ctx)); cogl_pipeline_set_layer_combine (template, 1, "RGBA = MODULATE (PREVIOUS, TEXTURE[A])", NULL); @@ -215,7 +230,7 @@ get_unblended_pipeline (CoglContext *ctx) if (G_UNLIKELY (template == NULL)) { CoglColor color; - template = cogl_pipeline_new (ctx); + template = cogl_pipeline_copy (get_base_pipeline (ctx)); cogl_color_init_from_4ub (&color, 255, 255, 255, 255); cogl_pipeline_set_blend (template, "RGBA = ADD (SRC_COLOR, 0)",