[PATCH 06/12] glamor: Use the actual picture's format when uploading memory pixmaps.

Eric Anholt eric at anholt.net
Wed Jul 8 12:45:12 PDT 2015


The pixmap->picture is just the *last* picture attached to the pixmap,
so you'd potentially be looking at the wrong one when trying to
temporarily upload to avoid a composite fallback.

There's some trickiness in glamor_render.c when we're dealing with the
upload of a GLAMOR_MEMORY pixmap as both the source and mask using
different formats, where we smash the source's format to a new value
so that the mask can use the same uploaded bits.  Dropping most of
that should be safe, since it will be uploaded as the source first, so
the smashed format will still be used.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 glamor/glamor_picture.c | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 3b0b7c9..c36d9d6 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -307,22 +307,15 @@ glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
 
 static int
 glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
+                                       PictFormatShort pict_format,
                                        GLenum *format,
                                        GLenum *type,
                                        int *no_alpha,
                                        int *revert, int *swap_rb, int is_upload)
 {
-    glamor_pixmap_private *pixmap_priv;
-    PictFormatShort pict_format;
     glamor_screen_private *glamor_priv =
         glamor_get_screen_private(pixmap->drawable.pScreen);
 
-    pixmap_priv = glamor_get_pixmap_private(pixmap);
-    if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
-        pict_format = pixmap_priv->picture->format;
-    else
-        pict_format = format_for_depth(pixmap->drawable.depth);
-
     if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
         return glamor_get_tex_format_type_from_pictformat_gl(pict_format,
                                                              format, type,
@@ -774,7 +767,8 @@ glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
 
 static Bool
 glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
-                                    int h, int stride, void *bits, int pbo)
+                                    int h, int stride, void *bits, int pbo,
+                                    PictFormatShort pict_format)
 {
     ScreenPtr screen = pixmap->drawable.pScreen;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -784,6 +778,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
     Bool force_clip;
 
     if (glamor_get_tex_format_type_from_pixmap(pixmap,
+                                               pict_format,
                                                &format,
                                                &type,
                                                &no_alpha,
@@ -884,23 +879,6 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
                                                      pbo);
 }
 
-static enum glamor_pixmap_status
-glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
-{
-    int ret;
-
-    if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
-                                            pixmap->drawable.width,
-                                            pixmap->drawable.height,
-                                            pixmap->devKind,
-                                            pixmap->devPrivate.ptr, 0))
-        ret = GLAMOR_UPLOAD_DONE;
-    else
-        ret = GLAMOR_UPLOAD_FAILED;
-
-    return ret;
-}
-
 /* Upload picture to texture.  We may need to flip the y axis or
  * wire alpha to 1. So we may conditional create fbo for the picture.
  * */
@@ -912,7 +890,15 @@ glamor_upload_picture_to_texture(PicturePtr picture)
     assert(picture->pDrawable);
     pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
 
-    return glamor_upload_pixmap_to_texture(pixmap);
+    if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
+                                            pixmap->drawable.width,
+                                            pixmap->drawable.height,
+                                            pixmap->devKind,
+                                            pixmap->devPrivate.ptr, 0,
+                                            picture->format))
+        return GLAMOR_UPLOAD_DONE;
+    else
+        return GLAMOR_UPLOAD_FAILED;
 }
 
 /*
-- 
2.1.4



More information about the xorg-devel mailing list