Don't need to set GL_PACK_ROW_LENGTH/GL_UNPACK_ROW_LENGTH.

We already adjust the stride of the pixmap, and keep the alignment
as 4 should be ok to let the GL/GLES match the stride.

Previous version has a unbalanced PACK ROW length seting, and is
buggy, now fixed it.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2012-04-14 22:40:48 +08:00 committed by Eric Anholt
parent 18d69fb014
commit 420af44a3a
2 changed files with 6 additions and 16 deletions

View File

@ -819,7 +819,6 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
int stride, void *bits, int pbo, glamor_access_t access)
{
glamor_pixmap_private *pixmap_priv;
unsigned int row_length;
GLenum format, type, gl_access, gl_usage;
int no_alpha, revert, swap_rb;
void *data, *read;
@ -896,13 +895,8 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
}
dispatch = glamor_get_dispatch(glamor_priv);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 1);
dispatch->glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
} else {
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
}
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
if (!glamor_priv->yInverted) {
@ -941,17 +935,15 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
temp_pbo);
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
stride *
pixmap->drawable.height,
h,
NULL, GL_STREAM_READ);
dispatch->glReadPixels(0, 0, row_length,
pixmap->drawable.height,
dispatch->glReadPixels(0, 0, w, h,
format, type, 0);
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
GL_READ_ONLY);
for (yy = 0; yy < pixmap->drawable.height; yy++)
memcpy(data + yy * stride,
read + (pixmap->drawable.height -
yy - 1) * stride, stride);
read + (h - yy - 1) * stride, stride);
dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
dispatch->glDeleteBuffers(1, &temp_pbo);
@ -995,7 +987,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
{
glamor_pixmap_private *pixmap_priv =
glamor_get_pixmap_private(pixmap);
unsigned int stride, row_length, y;
unsigned int stride, y;
GLenum format, type, gl_access, gl_usage;
int no_alpha, revert, swap_rb;
void *data = NULL, *dst;

View File

@ -376,8 +376,6 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glamor_set_alu(dispatch, GXcopy);
glamor_set_planemask(pixmap, ~0);
glamor_put_dispatch(glamor_priv);