[Glamor] [PATCH 2/5] glamor_es2_pixmap_read_prepare: Just prepare the required region.
Zhigang Gong
zhigang.gong at linux.intel.com
Mon Apr 9 06:42:43 PDT 2012
Don't need to prepare the whole source pixmap.
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
src/glamor_getimage.c | 19 ++++++++++---------
src/glamor_getspans.c | 2 +-
src/glamor_pixmap.c | 14 +++++++-------
src/glamor_priv.h | 2 +-
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/glamor_getimage.c b/src/glamor_getimage.c
index 3aabaa5..15ee89d 100644
--- a/src/glamor_getimage.c
+++ b/src/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/src/glamor_getspans.c b/src/glamor_getspans.c
index 8341df4..bd6a5ec 100644
--- a/src/glamor_getspans.c
+++ b/src/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/src/glamor_pixmap.c b/src/glamor_pixmap.c
index de87740..bab91af 100644
--- a/src/glamor_pixmap.c
+++ b/src/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/src/glamor_priv.h b/src/glamor_priv.h
index bea4f66..3e13ef8 100644
--- a/src/glamor_priv.h
+++ b/src/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,
--
1.7.4.4
More information about the Glamor
mailing list