diff options
author | marha <marha@users.sourceforge.net> | 2014-03-04 08:57:07 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-03-04 08:57:07 +0100 |
commit | 321c01267ae1c446f1bd22b642567fcafa016c02 (patch) | |
tree | 69f6e12bdfd1ccda5d054398321bc1876dd3fc89 /xorg-server/glamor/glamor_utils.h | |
parent | 982ac918afe6a1c02d5cf735d7b6c56443a048cc (diff) | |
download | vcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.tar.gz vcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.tar.bz2 vcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.zip |
libX11 libxcb mesa xserver xcb-proto xkeyboard-config git update 4 Mar 2014
xserver commit b634e909895f6001e7d9543e1350b20c82c8c01c
libxcb commit 4ffa6f83b92763eb901c7ddb7c20775e24d507ca
libxcb/xcb-proto commit 4270141a7cb3c68f50251be19a5a628aa18553e6
xkeyboard-config commit d9e3d0ec1a48a5f61ea6dd6d20b8682eeecf3a39
libX11 commit d6bd988bc00494914b38b95ee5df77ac4f32f19f
libXdmcp commit 089081dca4ba3598c6f9bf401c029378943b5854
libXext commit d5447c0156f556114dbf97d6064c0c7b0fcd5f70
libfontenc commit 0037a42107b952c9d903719615747e760e4e7247
libXinerama commit edd95182b26eb5d576d4878c559e0f17dddaa909
libXau commit 1e4635be11154dd8262f37b379511bd627defa2a
xkbcomp commit 31b90ee4ffc774e0da540277907fc5540c0b012c
pixman commit 82d094654a46bd97d47f1f132a01ae0a74b986f3
xextproto commit 66afec3f49e8eb0d4c2e9af7088fc3116d4bafd7
randrproto commit a4a6694c059d74247c16527eef4a0ec9f56bbef6
glproto commit f84853d97d5749308992412a215fa518b6536eb3
mkfontscale commit eac564e0fc9052a39981ea47b271f7f3d2821944
xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13
libXft commit 4acfdaf95adb0a05c2a25550bdde036c865902f4
libXmu commit 22d9c590901e121936f50dee97dc60c4f7defb63
libxtrans commit 3f0de269abe59353acbd7a5587d68ce0da91db67
fontconfig commit e310d2fac2d874d5aa76c609df70cc7b871c0b6d
mesa commit 1a568e0f2b65e4e1e1d19a6dece3a792a33da825
Diffstat (limited to 'xorg-server/glamor/glamor_utils.h')
-rw-r--r-- | xorg-server/glamor/glamor_utils.h | 373 |
1 files changed, 20 insertions, 353 deletions
diff --git a/xorg-server/glamor/glamor_utils.h b/xorg-server/glamor/glamor_utils.h index ea827df3b..9374c9d4d 100644 --- a/xorg-server/glamor/glamor_utils.h +++ b/xorg-server/glamor/glamor_utils.h @@ -869,19 +869,17 @@ format_for_depth(int depth) } } -static inline void -gl_iformat_for_depth(int depth, GLenum * format) +static inline GLenum +gl_iformat_for_pixmap(PixmapPtr pixmap) { - switch (depth) { -#ifndef GLAMOR_GLES2 - case 1: - case 8: - *format = GL_ALPHA; - break; -#endif - default: - *format = GL_RGBA; - break; + glamor_screen_private *glamor_priv = + glamor_get_screen_private(pixmap->drawable.pScreen); + + if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && + (pixmap->drawable.depth == 1 || pixmap->drawable.depth == 8)) { + return GL_ALPHA; + } else { + return GL_RGBA; } } @@ -916,298 +914,6 @@ format_for_pixmap(PixmapPtr pixmap) #define SWAP_UPLOADING 2 #define SWAP_NONE_UPLOADING 3 -/* - * Map picture's format to the correct gl texture format and type. - * no_alpha is used to indicate whehter we need to wire alpha to 1. - * - * Although opengl support A1/GL_BITMAP, we still don't use it - * here, it seems that mesa has bugs when uploading a A1 bitmap. - * - * Return 0 if find a matched texture type. Otherwise return -1. - **/ -#ifndef GLAMOR_GLES2 -static inline int -glamor_get_tex_format_type_from_pictformat(PictFormatShort format, - GLenum * tex_format, - GLenum * tex_type, - int *no_alpha, - int *revert, - int *swap_rb, int is_upload) -{ - *no_alpha = 0; - *revert = REVERT_NONE; - *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING; - switch (format) { - case PICT_a1: - *tex_format = GL_ALPHA; - *tex_type = GL_UNSIGNED_BYTE; - *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1; - break; - case PICT_b8g8r8x8: - *no_alpha = 1; - case PICT_b8g8r8a8: - *tex_format = GL_BGRA; - *tex_type = GL_UNSIGNED_INT_8_8_8_8; - break; - - case PICT_x8r8g8b8: - *no_alpha = 1; - case PICT_a8r8g8b8: - *tex_format = GL_BGRA; - *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV; - break; - case PICT_x8b8g8r8: - *no_alpha = 1; - case PICT_a8b8g8r8: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV; - break; - case PICT_x2r10g10b10: - *no_alpha = 1; - case PICT_a2r10g10b10: - *tex_format = GL_BGRA; - *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV; - break; - case PICT_x2b10g10r10: - *no_alpha = 1; - case PICT_a2b10g10r10: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV; - break; - - case PICT_r5g6b5: - *tex_format = GL_RGB; - *tex_type = GL_UNSIGNED_SHORT_5_6_5; - break; - case PICT_b5g6r5: - *tex_format = GL_RGB; - *tex_type = GL_UNSIGNED_SHORT_5_6_5_REV; - break; - case PICT_x1b5g5r5: - *no_alpha = 1; - case PICT_a1b5g5r5: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; - break; - - case PICT_x1r5g5b5: - *no_alpha = 1; - case PICT_a1r5g5b5: - *tex_format = GL_BGRA; - *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; - break; - case PICT_a8: - *tex_format = GL_ALPHA; - *tex_type = GL_UNSIGNED_BYTE; - break; - case PICT_x4r4g4b4: - *no_alpha = 1; - case PICT_a4r4g4b4: - *tex_format = GL_BGRA; - *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV; - break; - - case PICT_x4b4g4r4: - *no_alpha = 1; - case PICT_a4b4g4r4: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV; - break; - - default: - LogMessageVerb(X_INFO, 0, - "fail to get matched format for %x \n", format); - return -1; - } - return 0; -} - -/* Currently, we use RGBA to represent all formats. */ -inline static int -cache_format(GLenum format) -{ - switch (format) { - case GL_ALPHA: - return 1; - case GL_RGBA: - return 0; - default: - return -1; - } -} - -#else -#define IS_LITTLE_ENDIAN (IMAGE_BYTE_ORDER == LSBFirst) - -static inline int -glamor_get_tex_format_type_from_pictformat(PictFormatShort format, - GLenum * tex_format, - GLenum * tex_type, - int *no_alpha, - int *revert, - int *swap_rb, int is_upload) -{ - int need_swap_rb = 0; - - *no_alpha = 0; - *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL; - - switch (format) { - case PICT_b8g8r8x8: - *no_alpha = 1; - case PICT_b8g8r8a8: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_BYTE; - need_swap_rb = 1; - *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE; - break; - - case PICT_x8r8g8b8: - *no_alpha = 1; - case PICT_a8r8g8b8: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_BYTE; - need_swap_rb = 1; - break; - - case PICT_x8b8g8r8: - *no_alpha = 1; - case PICT_a8b8g8r8: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_BYTE; - break; - - case PICT_x2r10g10b10: - *no_alpha = 1; - case PICT_a2r10g10b10: - *tex_format = GL_RGBA; - /* glReadPixmap doesn't support GL_UNSIGNED_INT_10_10_10_2. - * we have to use GL_UNSIGNED_BYTE and do the conversion in - * shader latter.*/ - *tex_type = GL_UNSIGNED_BYTE; - if (is_upload == 1) { - if (!IS_LITTLE_ENDIAN) - *revert = REVERT_UPLOADING_10_10_10_2; - else - *revert = REVERT_UPLOADING_2_10_10_10; - } - else { - if (!IS_LITTLE_ENDIAN) { - *revert = REVERT_DOWNLOADING_10_10_10_2; - } - else { - *revert = REVERT_DOWNLOADING_2_10_10_10; - } - } - need_swap_rb = 1; - - break; - - case PICT_x2b10g10r10: - *no_alpha = 1; - case PICT_a2b10g10r10: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_BYTE; - if (is_upload == 1) { - if (!IS_LITTLE_ENDIAN) - *revert = REVERT_UPLOADING_10_10_10_2; - else - *revert = REVERT_UPLOADING_2_10_10_10; - } - else { - if (!IS_LITTLE_ENDIAN) { - *revert = REVERT_DOWNLOADING_10_10_10_2; - } - else { - *revert = REVERT_DOWNLOADING_2_10_10_10; - } - } - break; - - case PICT_r5g6b5: - *tex_format = GL_RGB; - *tex_type = GL_UNSIGNED_SHORT_5_6_5; - *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL; - - break; - - case PICT_b5g6r5: - *tex_format = GL_RGB; - *tex_type = GL_UNSIGNED_SHORT_5_6_5; - need_swap_rb = IS_LITTLE_ENDIAN ? 1 : 0;; - break; - - case PICT_x1b5g5r5: - *no_alpha = 1; - case PICT_a1b5g5r5: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_5_5_5_1; - if (IS_LITTLE_ENDIAN) { - *revert = - is_upload ? REVERT_UPLOADING_1_5_5_5 : - REVERT_DOWNLOADING_1_5_5_5; - } - else - *revert = REVERT_NONE; - break; - - case PICT_x1r5g5b5: - *no_alpha = 1; - case PICT_a1r5g5b5: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_5_5_5_1; - if (IS_LITTLE_ENDIAN) { - *revert = - is_upload ? REVERT_UPLOADING_1_5_5_5 : - REVERT_DOWNLOADING_1_5_5_5; - } - else - *revert = REVERT_NONE; - need_swap_rb = 1; - break; - - case PICT_a1: - *tex_format = GL_ALPHA; - *tex_type = GL_UNSIGNED_BYTE; - *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1; - break; - - case PICT_a8: - *tex_format = GL_ALPHA; - *tex_type = GL_UNSIGNED_BYTE; - *revert = REVERT_NONE; - break; - - case PICT_x4r4g4b4: - *no_alpha = 1; - case PICT_a4r4g4b4: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_4_4_4_4; - *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE; - need_swap_rb = 1; - break; - - case PICT_x4b4g4r4: - *no_alpha = 1; - case PICT_a4b4g4r4: - *tex_format = GL_RGBA; - *tex_type = GL_UNSIGNED_SHORT_4_4_4_4; - *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE; - break; - - default: - LogMessageVerb(X_INFO, 0, - "fail to get matched format for %x \n", format); - return -1; - } - - if (need_swap_rb) - *swap_rb = is_upload ? SWAP_UPLOADING : SWAP_DOWNLOADING; - else - *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING; - return 0; -} - inline static int cache_format(GLenum format) { @@ -1223,31 +929,6 @@ cache_format(GLenum format) } } -#endif - -static inline 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) -{ - glamor_pixmap_private *pixmap_priv; - PictFormatShort pict_format; - - pixmap_priv = glamor_get_pixmap_private(pixmap); - if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) - pict_format = pixmap_priv->base.picture->format; - else - pict_format = format_for_depth(pixmap->drawable.depth); - - return glamor_get_tex_format_type_from_pictformat(pict_format, - format, type, - no_alpha, - revert, - swap_rb, is_upload); -} - /* borrowed from uxa */ static inline Bool glamor_get_rgba_from_pixel(CARD32 pixel, @@ -1319,16 +1000,18 @@ glamor_get_rgba_from_pixel(CARD32 pixel, } inline static Bool -glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth) +glamor_pict_format_is_compatible(PicturePtr picture) { GLenum iformat; + PixmapPtr pixmap = glamor_get_drawable_pixmap(picture->pDrawable); - gl_iformat_for_depth(depth, &iformat); + iformat = gl_iformat_for_pixmap(pixmap); switch (iformat) { case GL_RGBA: - return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8); + return (picture->format == PICT_a8r8g8b8 || + picture->format == PICT_x8r8g8b8); case GL_ALPHA: - return (pict_format == PICT_a8); + return (picture->format == PICT_a8); default: return FALSE; } @@ -1817,31 +1500,15 @@ __fls(unsigned long x) #endif static inline void -glamor_make_current(ScreenPtr screen) +glamor_get_context(glamor_screen_private * glamor_priv) { - glamor_egl_make_current(screen); -} - -static inline void -glamor_restore_current(ScreenPtr screen) -{ - glamor_egl_restore_context(screen); -} - -static inline glamor_gl_dispatch * -glamor_get_dispatch(glamor_screen_private * glamor_priv) -{ - if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) - glamor_make_current(glamor_priv->screen); - - return &glamor_priv->_dispatch; + glamor_priv->ctx.get_context(&glamor_priv->ctx); } static inline void -glamor_put_dispatch(glamor_screen_private * glamor_priv) +glamor_put_context(glamor_screen_private * glamor_priv) { - if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN) - glamor_restore_current(glamor_priv->screen); + glamor_priv->ctx.put_context(&glamor_priv->ctx); } #endif |