diff options
author | Zhigang Gong <zhigang.gong@linux.intel.com> | 2012-04-09 15:57:05 +0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-18 11:23:49 -0800 |
commit | d96226ac6f34aa61fc00ad15ef58c1ed1253160e (patch) | |
tree | 12ab4fb27436d9fba79695e6fcf351cae2bf0d3c | |
parent | 3dbdd40c6ce4203619f2a3492029a444bb9217af (diff) |
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>
-rw-r--r-- | glamor/glamor_getimage.c | 19 | ||||
-rw-r--r-- | glamor/glamor_getspans.c | 2 | ||||
-rw-r--r-- | glamor/glamor_pixmap.c | 14 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 2 |
4 files changed, 19 insertions, 18 deletions
diff --git a/glamor/glamor_getimage.c b/glamor/glamor_getimage.c index 3aabaa5d3..15ee89dcf 100644 --- a/glamor/glamor_getimage.c +++ b/glamor/glamor_getimage.c @@ -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: diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c index 8341df42e..bd6a5ec19 100644 --- a/glamor/glamor_getspans.c +++ b/glamor/glamor_getspans.c @@ -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) diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index de8774035..bab91af84 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -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; diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index bea4f662a..3e13ef8e2 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -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, |