glamor: Unify the variable name which used to indicate no alpha.

The original code use different name and the name is vague.
Now change it to no_alpha.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
This commit is contained in:
Zhigang Gong 2011-08-11 15:27:12 -04:00 committed by Zhigang Gong
parent 5e7fdbb498
commit 667d65534d
5 changed files with 41 additions and 39 deletions

View File

@ -41,7 +41,7 @@ glamor_get_spans(DrawablePtr drawable,
{ {
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type; GLenum format, type;
int ax; int no_alpha;
glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen); glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
int i; int i;
@ -56,7 +56,7 @@ glamor_get_spans(DrawablePtr drawable,
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
&ax &no_alpha
)) { )) {
glamor_fallback("unknown depth. %d \n", glamor_fallback("unknown depth. %d \n",
drawable->depth); drawable->depth);

View File

@ -272,7 +272,8 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type,
* */ * */
static void static void
_glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, int ax, int flip) _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
GLenum type, int no_alpha, int flip)
{ {
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
@ -299,7 +300,7 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, i
/* Try fast path firstly, upload the pixmap to the texture attached /* Try fast path firstly, upload the pixmap to the texture attached
* to the fbo directly. */ * to the fbo directly. */
if (ax == 0 && !need_flip) { if (no_alpha == 0 && !need_flip) {
__glamor_upload_pixmap_to_texture(pixmap, format, type, pixmap_priv->tex); __glamor_upload_pixmap_to_texture(pixmap, format, type, pixmap_priv->tex);
return; return;
} }
@ -341,9 +342,9 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, i
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
#if 0 #if 0
glUseProgram(glamor_priv->finish_access_prog[ax]); glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
#else #else
glUseProgram(glamor_priv->finish_access_prog[ax + 2]); glUseProgram(glamor_priv->finish_access_prog[no_alpha + 2]);
#endif #endif
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -397,13 +398,13 @@ glamor_pixmap_ensure_fb(PixmapPtr pixmap)
/* /*
* Prepare to upload a pixmap to texture memory. * Prepare to upload a pixmap to texture memory.
* ax 1 means the format needs to wire alpha to 1. * no_alpha equals 1 means the format needs to wire alpha to 1.
* Two condtion need to setup a fbo for a pixmap * Two condtion need to setup a fbo for a pixmap
* 1. !yInverted, we need to do flip if we are not yInverted. * 1. !yInverted, we need to do flip if we are not yInverted.
* 2. ax != 0, we need to wire the alpha. * 2. no_alpha != 0, we need to wire the alpha.
* */ * */
static int static int
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int ax) glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha)
{ {
int need_fbo; int need_fbo;
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
@ -419,7 +420,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, int ax)
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return 0; return 0;
if (ax != 0 || !glamor_priv->yInverted) if (no_alpha != 0 || !glamor_priv->yInverted)
need_fbo = 1; need_fbo = 1;
else else
need_fbo = 0; need_fbo = 0;
@ -444,16 +445,16 @@ enum glamor_pixmap_status
glamor_upload_pixmap_to_texture(PixmapPtr pixmap) glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
{ {
GLenum format, type; GLenum format, type;
int ax; int no_alpha;
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
&ax)) { &no_alpha)) {
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth); glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
return GLAMOR_UPLOAD_FAILED; return GLAMOR_UPLOAD_FAILED;
} }
if (glamor_pixmap_upload_prepare(pixmap, ax)) if (glamor_pixmap_upload_prepare(pixmap, no_alpha))
return GLAMOR_UPLOAD_FAILED; return GLAMOR_UPLOAD_FAILED;
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD, glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD,
"Uploading pixmap %p %dx%d depth%d.\n", "Uploading pixmap %p %dx%d depth%d.\n",
@ -461,7 +462,7 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
pixmap->drawable.width, pixmap->drawable.width,
pixmap->drawable.height, pixmap->drawable.height,
pixmap->drawable.depth); pixmap->drawable.depth);
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 1); _glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha, 1);
return GLAMOR_UPLOAD_DONE; return GLAMOR_UPLOAD_DONE;
} }
@ -485,16 +486,16 @@ void
glamor_restore_pixmap_to_texture(PixmapPtr pixmap) glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
{ {
GLenum format, type; GLenum format, type;
int ax; int no_alpha;
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
&ax)) { &no_alpha)) {
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth); ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
assert(0); assert(0);
} }
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 1); _glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha, 1);
} }
@ -514,7 +515,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
unsigned int stride, row_length, y; unsigned int stride, row_length, y;
GLenum format, type, gl_access, gl_usage; GLenum format, type, gl_access, gl_usage;
int ax; int no_alpha;
uint8_t *data, *read; uint8_t *data, *read;
glamor_screen_private *glamor_priv = glamor_screen_private *glamor_priv =
glamor_get_screen_private(pixmap->drawable.pScreen); glamor_get_screen_private(pixmap->drawable.pScreen);
@ -522,12 +523,10 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return TRUE; return TRUE;
/* XXX we may don't need to validate it on GPU here,
* we can just validate it on CPU. */
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
&ax)) { &no_alpha)) {
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth); ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
assert(0); // Should never happen. assert(0); // Should never happen.
return FALSE; return FALSE;
@ -543,6 +542,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
stride = pixmap->devKind; stride = pixmap->devKind;
glamor_set_destination_pixmap_priv_nc(pixmap_priv); glamor_set_destination_pixmap_priv_nc(pixmap_priv);
/* XXX we may don't need to validate it on GPU here,
* we can just validate it on CPU. */
glamor_validate_pixmap(pixmap); glamor_validate_pixmap(pixmap);
switch (access) { switch (access) {
case GLAMOR_ACCESS_RO: case GLAMOR_ACCESS_RO:

View File

@ -404,7 +404,7 @@ format_for_pixmap(PixmapPtr pixmap)
/* /*
* Map picture's format to the correct gl texture format and type. * Map picture's format to the correct gl texture format and type.
* xa is used to indicate whehter we need to wire alpha to 1. * no_alpha is used to indicate whehter we need to wire alpha to 1.
* *
* Return 0 if find a matched texture type. Otherwise return -1. * Return 0 if find a matched texture type. Otherwise return -1.
**/ **/
@ -412,41 +412,41 @@ static inline int
glamor_get_tex_format_type_from_pictformat(PictFormatShort format, glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
GLenum *tex_format, GLenum *tex_format,
GLenum *tex_type, GLenum *tex_type,
int *xa) int *no_alpha)
{ {
*xa = 0; *no_alpha = 0;
switch (format) { switch (format) {
case PICT_a1: case PICT_a1:
*tex_format = GL_COLOR_INDEX; *tex_format = GL_COLOR_INDEX;
*tex_type = GL_BITMAP; *tex_type = GL_BITMAP;
break; break;
case PICT_b8g8r8x8: case PICT_b8g8r8x8:
*xa = 1; *no_alpha = 1;
case PICT_b8g8r8a8: case PICT_b8g8r8a8:
*tex_format = GL_BGRA; *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8; *tex_type = GL_UNSIGNED_INT_8_8_8_8;
break; break;
case PICT_x8r8g8b8: case PICT_x8r8g8b8:
*xa = 1; *no_alpha = 1;
case PICT_a8r8g8b8: case PICT_a8r8g8b8:
*tex_format = GL_BGRA; *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV; *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
break; break;
case PICT_x8b8g8r8: case PICT_x8b8g8r8:
*xa = 1; *no_alpha = 1;
case PICT_a8b8g8r8: case PICT_a8b8g8r8:
*tex_format = GL_RGBA; *tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV; *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
break; break;
case PICT_x2r10g10b10: case PICT_x2r10g10b10:
*xa = 1; *no_alpha = 1;
case PICT_a2r10g10b10: case PICT_a2r10g10b10:
*tex_format = GL_BGRA; *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV; *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
break; break;
case PICT_x2b10g10r10: case PICT_x2b10g10r10:
*xa = 1; *no_alpha = 1;
case PICT_a2b10g10r10: case PICT_a2b10g10r10:
*tex_format = GL_RGBA; *tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV; *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
@ -461,14 +461,14 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV; *tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
break; break;
case PICT_x1b5g5r5: case PICT_x1b5g5r5:
*xa = 1; *no_alpha = 1;
case PICT_a1b5g5r5: case PICT_a1b5g5r5:
*tex_format = GL_RGBA; *tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
break; break;
case PICT_x1r5g5b5: case PICT_x1r5g5b5:
*xa = 1; *no_alpha = 1;
case PICT_a1r5g5b5: case PICT_a1r5g5b5:
*tex_format = GL_BGRA; *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
@ -478,14 +478,14 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
*tex_type = GL_UNSIGNED_BYTE; *tex_type = GL_UNSIGNED_BYTE;
break; break;
case PICT_x4r4g4b4: case PICT_x4r4g4b4:
*xa = 1; *no_alpha = 1;
case PICT_a4r4g4b4: case PICT_a4r4g4b4:
*tex_format = GL_BGRA; *tex_format = GL_BGRA;
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV; *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
break; break;
case PICT_x4b4g4r4: case PICT_x4b4g4r4:
*xa = 1; *no_alpha = 1;
case PICT_a4b4g4r4: case PICT_a4b4g4r4:
*tex_format = GL_RGBA; *tex_format = GL_RGBA;
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV; *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;

View File

@ -265,7 +265,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
float vertices[8], texcoords[8]; float vertices[8], texcoords[8];
GLfloat xscale, yscale, txscale, tyscale; GLfloat xscale, yscale, txscale, tyscale;
GLuint tex; GLuint tex;
int ax = 0; int no_alpha;
if (image_format == XYBitmap) { if (image_format == XYBitmap) {
assert(depth == 1); assert(depth == 1);
goto fail; goto fail;
@ -290,7 +290,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
&ax &no_alpha
)) { )) {
glamor_fallback("unknown depth. %d \n", glamor_fallback("unknown depth. %d \n",
drawable->depth); drawable->depth);
@ -347,9 +347,9 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
#if 0 #if 0
glUseProgram(glamor_priv->finish_access_prog[ax]); glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
#else #else
glUseProgram(glamor_priv->finish_access_prog[ax + 2]); glUseProgram(glamor_priv->finish_access_prog[no_alpha + 2]);
#endif #endif
x += drawable->x; x += drawable->x;

View File

@ -37,18 +37,19 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
{ {
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable); PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type; GLenum format, type;
int ax, i; int no_alpha, i;
uint8_t *drawpixels_src = (uint8_t *)src; uint8_t *drawpixels_src = (uint8_t *)src;
RegionPtr clip = fbGetCompositeClip(gc); RegionPtr clip = fbGetCompositeClip(gc);
BoxRec *pbox; BoxRec *pbox;
int x_off, y_off; int x_off, y_off;
goto fail; goto fail;
if (glamor_get_tex_format_type_from_pixmap(dest_pixmap, if (glamor_get_tex_format_type_from_pixmap(dest_pixmap,
&format, &format,
&type, &type,
&ax &no_alpha
)) { )) {
glamor_fallback("unknown depth. %d \n", glamor_fallback("unknown depth. %d \n",
drawable->depth); drawable->depth);