summaryrefslogtreecommitdiff
path: root/glamor/glamor_render.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-13 16:19:38 -0700
committerKeith Packard <keithp@keithp.com>2016-05-26 09:17:59 -0700
commit181a4bd0cc436f89582408196038ff37032f9bac (patch)
treebfe2f05ad19c6468c82ae88f08efed2385992e8e /glamor/glamor_render.c
parentb07bc700b3cf2f5c8912fc5b9e0dad2baf395525 (diff)
glamor: Preserve GL_RED bits in R channel when destination is GL_RED [v2]
A1 and A8 pixmaps are usually stored in the Red channel to conform with more recent GL versions. When using these pixmaps as mask values, that works great. When using these pixmaps as source values, then the value we want depends on what the destination looks like. For RGBA or RGB destinations, then we want to use the Red channel for A values and leave RGB all set to zero. For A destinations, then we want to leave the R values in the Red channel so that they end up in the Red channel of the output. This patch adds a helper function, glamor_bind_texture, which performs the glBindTexture call along with setting the swizzle parameter correctly for the Red channel. The swizzle parameter for the Alpha channel doesn't depend on the destination as it's safe to leave it always swizzled from the Red channel. This fixes incorrect rendering in firefox for this page: https://gfycat.com/HoarseCheapAmericankestrel while not breaking rendering for this page: https://feedly.com v2: Add change accidentally left in patch for missing glDisable(GL_COLOR_LOGIC_OP). Found by Emil Velikov <emil.l.velikov@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63397 Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Diffstat (limited to 'glamor/glamor_render.c')
-rw-r--r--glamor/glamor_render.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index a67965e1c..9c5cca67e 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -512,15 +512,24 @@ static void
glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
PicturePtr picture,
PixmapPtr pixmap,
- GLuint wh_location, GLuint repeat_location)
+ GLuint wh_location, GLuint repeat_location,
+ glamor_pixmap_private *dest_priv)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+ glamor_pixmap_fbo *fbo = pixmap_priv->fbo;
float wh[4];
int repeat_type;
glamor_make_current(glamor_priv);
- glActiveTexture(GL_TEXTURE0 + unit);
- glBindTexture(GL_TEXTURE_2D, pixmap_priv->fbo->tex);
+
+ /* The red channel swizzling doesn't depend on whether we're using
+ * 'fbo' as source or mask as we must have the same answer in case
+ * the same fbo is being used for both. That means the mask
+ * channel will sometimes get red bits in the R channel, and
+ * sometimes get zero bits in the R channel, which is harmless.
+ */
+ glamor_bind_texture(glamor_priv, GL_TEXTURE0 + unit, fbo,
+ glamor_fbo_red_is_alpha(glamor_priv, dest_priv->fbo));
repeat_type = picture->repeatType;
switch (picture->repeatType) {
case RepeatNone:
@@ -1075,7 +1084,8 @@ glamor_composite_set_shader_blend(glamor_screen_private *glamor_priv,
glamor_set_composite_texture(glamor_priv, 0,
shader->source,
shader->source_pixmap, shader->source_wh,
- shader->source_repeat_mode);
+ shader->source_repeat_mode,
+ dest_priv);
}
if (key->mask != SHADER_MASK_NONE) {
@@ -1087,7 +1097,8 @@ glamor_composite_set_shader_blend(glamor_screen_private *glamor_priv,
glamor_set_composite_texture(glamor_priv, 1,
shader->mask,
shader->mask_pixmap, shader->mask_wh,
- shader->mask_repeat_mode);
+ shader->mask_repeat_mode,
+ dest_priv);
}
}