[PATCH 2/3] glamor: Use glamor_get_tex_format_type_from_pixmap for glamor_transfer

Keith Packard keithp at keithp.com
Fri Apr 25 15:07:02 PDT 2014


glamor_transfer had some hard-coded depth to format/type conversions
which may not match the format used with render. This switches to
using the same formats as the render portion of glamor.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 glamor/glamor_pixmap.c   |  2 +-
 glamor/glamor_priv.h     |  7 +++++++
 glamor/glamor_transfer.c | 27 +++++----------------------
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 54b414b..7b677ae 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -457,7 +457,7 @@ glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
     return 0;
 }
 
-static int
+int
 glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
                                        GLenum *format,
                                        GLenum *type,
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index a2a21fc..988f609 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -850,6 +850,13 @@ Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
  */
 enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
 
+int
+glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
+                                       GLenum *format,
+                                       GLenum *type,
+                                       int *no_alpha,
+                                       int *revert, int *swap_rb, int is_upload);
+
 Bool glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
                                          int h, int stride, void *bits,
                                          int pbo);
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index ad875c9..706ee01 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -27,28 +27,11 @@
 void
 glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
 {
-    switch (pixmap->drawable.depth) {
-    case 24:
-    case 32:
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_INT_8_8_8_8_REV;
-        break;
-    case 16:
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_5_6_5;
-        break;
-    case 15:
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-        break;
-    case 8:
-        *format = GL_ALPHA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    default:
-        FatalError("Invalid pixmap depth %d\n", pixmap->drawable.depth);
-        break;
-    }
+    int no_alpha, revert, swap_rb;
+
+    (void) glamor_get_tex_format_type_from_pixmap(pixmap, format, type,
+                                                  &no_alpha, &revert,
+                                                  &swap_rb, 0);
 }
 
 /*
-- 
2.0.0.rc0



More information about the xorg-devel mailing list