glamor: Pass pixmaps around to unifdef glamor_iformat_for_depth().

v2: Just pass in the PicturePtr to glamor_pict_format_is_compatible()
    (suggestion by keithp)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Eric Anholt 2013-12-27 01:23:15 -08:00
parent f3f4fc7a65
commit d63283860a
4 changed files with 21 additions and 22 deletions

View File

@ -95,7 +95,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
glamor_destroy_fbo(fbo); glamor_destroy_fbo(fbo);
} }
gl_iformat_for_depth(pixmap->drawable.depth, &format); format = gl_iformat_for_pixmap(pixmap);
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width, fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
pixmap->drawable.height, format, tex, 0); pixmap->drawable.height, format, tex, 0);
@ -162,7 +162,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
pixmap_priv->base.pixmap = pixmap; pixmap_priv->base.pixmap = pixmap;
pixmap_priv->base.glamor_priv = glamor_priv; pixmap_priv->base.glamor_priv = glamor_priv;
gl_iformat_for_depth(depth, &format); format = gl_iformat_for_pixmap(pixmap);
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3; pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL); screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);

View File

@ -93,8 +93,7 @@ glamor_create_picture(PicturePtr picture)
* we have to mark this pixmap as a separated texture, and don't * we have to mark this pixmap as a separated texture, and don't
* fallback to DDX layer. */ * fallback to DDX layer. */
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
&& !glamor_pict_format_is_compatible(picture->format, && !glamor_pict_format_is_compatible(picture))
pixmap->drawable.depth))
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE); glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
} }
} }

View File

@ -403,7 +403,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
if (*tex == 0) { if (*tex == 0) {
glGenTextures(1, tex); glGenTextures(1, tex);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
gl_iformat_for_depth(pixmap->drawable.depth, &iformat); iformat = gl_iformat_for_pixmap(pixmap);
else else
iformat = format; iformat = format;
non_sub = 1; non_sub = 1;
@ -603,7 +603,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha,
return 0; return 0;
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
gl_iformat_for_depth(pixmap->drawable.depth, &iformat); iformat = gl_iformat_for_pixmap(pixmap);
else else
iformat = format; iformat = format;

View File

@ -869,19 +869,17 @@ format_for_depth(int depth)
} }
} }
static inline void static inline GLenum
gl_iformat_for_depth(int depth, GLenum * format) gl_iformat_for_pixmap(PixmapPtr pixmap)
{ {
switch (depth) { glamor_screen_private *glamor_priv =
#ifndef GLAMOR_GLES2 glamor_get_screen_private(pixmap->drawable.pScreen);
case 1:
case 8: if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
*format = GL_ALPHA; (pixmap->drawable.depth == 1 || pixmap->drawable.depth == 8)) {
break; return GL_ALPHA;
#endif } else {
default: return GL_RGBA;
*format = GL_RGBA;
break;
} }
} }
@ -1319,16 +1317,18 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
} }
inline static Bool inline static Bool
glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth) glamor_pict_format_is_compatible(PicturePtr picture)
{ {
GLenum iformat; GLenum iformat;
PixmapPtr pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
gl_iformat_for_depth(depth, &iformat); iformat = gl_iformat_for_pixmap(pixmap);
switch (iformat) { switch (iformat) {
case GL_RGBA: case GL_RGBA:
return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8); return (picture->format == PICT_a8r8g8b8 ||
picture->format == PICT_x8r8g8b8);
case GL_ALPHA: case GL_ALPHA:
return (pict_format == PICT_a8); return (picture->format == PICT_a8);
default: default:
return FALSE; return FALSE;
} }