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

View File

@ -73,7 +73,7 @@ _glamor_get_spans(DrawablePtr drawable,
/* XXX prepare whole pixmap is not efficient. */ /* XXX prepare whole pixmap is not efficient. */
temp_fbo = 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, type, no_alpha,
revert, swap_rb); revert, swap_rb);
if (temp_fbo == NULL) if (temp_fbo == NULL)

View File

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

View File

@ -465,7 +465,7 @@ void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
pixmap_priv); pixmap_priv);
glamor_pixmap_fbo * 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); GLenum type, int no_alpha, int revert, int swap_rb);
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch, Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,