glamor_es2_pixmap_read_prepare: Just prepare the required region.

Don't need to prepare the whole source pixmap.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2012-04-09 15:57:05 +08:00 committed by Eric Anholt
parent 3dbdd40c6c
commit d96226ac6f
4 changed files with 19 additions and 18 deletions

View File

@ -81,20 +81,25 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_validate_pixmap(pixmap);
x += drawable->x + x_off;
y += drawable->y + y_off;
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
&& ( swap_rb != SWAP_NONE_DOWNLOADING
|| revert != REVERT_NONE)) {
/* XXX prepare whole pixmap is not efficient. */
temp_fbo =
glamor_es2_pixmap_read_prepare(pixmap, tex_format,
glamor_es2_pixmap_read_prepare(pixmap, x, y, w, h, tex_format,
tex_type, no_alpha,
revert, swap_rb);
if (temp_fbo == NULL)
if (temp_fbo == NULL) {
x -= (drawable->x + x_off);
y -= (drawable->y + y_off);
goto fall_back;
}
x = 0;
y = 0;
}
dispatch = glamor_get_dispatch(glamor_priv);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
int row_length = PixmapBytePad(w, drawable->depth);
@ -105,9 +110,6 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
}
x += drawable->x + x_off;
y += drawable->y + y_off;
if (glamor_priv->yInverted)
dispatch->glReadPixels(x,
y,
@ -124,7 +126,6 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
glamor_put_dispatch(glamor_priv);
if (temp_fbo)
glamor_destroy_fbo(temp_fbo);
ret = TRUE;
fall_back:

View File

@ -73,7 +73,7 @@ _glamor_get_spans(DrawablePtr drawable,
/* XXX prepare whole pixmap is not efficient. */
temp_fbo =
glamor_es2_pixmap_read_prepare(pixmap, format,
glamor_es2_pixmap_read_prepare(pixmap, 0, 0, pixmap->drawable.width, pixmap->drawable.height, format,
type, no_alpha,
revert, swap_rb);
if (temp_fbo == NULL)

View File

@ -788,7 +788,7 @@ glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
* */
glamor_pixmap_fbo *
glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum format,
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
GLenum type, int no_alpha, int revert, int swap_rb)
{
@ -806,8 +806,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum format,
glamor_priv = glamor_get_screen_private(screen);
source_priv = glamor_get_pixmap_private(source);
temp_fbo = glamor_create_fbo(glamor_priv,
source->drawable.width,
source->drawable.height,
w, h,
format,
0);
if (temp_fbo == NULL)
@ -820,7 +819,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum format,
glamor_set_normalize_vcoords(temp_xscale,
temp_yscale,
0, 0,
source->drawable.width, source->drawable.height,
w, h,
glamor_priv->yInverted,
vertices);
@ -832,8 +831,8 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum format,
pixmap_priv_get_scale(source_priv, &source_xscale, &source_yscale);
glamor_set_normalize_tcoords(source_xscale,
source_yscale,
0, 0,
source->drawable.width, source->drawable.height,
x, y,
x + w, y + h,
glamor_priv->yInverted,
texcoords);
@ -928,7 +927,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
&& !need_post_conversion
&& (swap_rb != SWAP_NONE_DOWNLOADING || revert != REVERT_NONE)) {
if (!(temp_fbo = glamor_es2_pixmap_read_prepare(pixmap, format,
if (!(temp_fbo = glamor_es2_pixmap_read_prepare(pixmap, 0, 0,
pixmap->drawable.width, pixmap->drawable.height, format,
type, no_alpha,
revert, swap_rb)))
return FALSE;

View File

@ -465,7 +465,7 @@ void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
pixmap_priv);
glamor_pixmap_fbo *
glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum format,
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
GLenum type, int no_alpha, int revert, int swap_rb);
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,