summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-05-15 15:25:41 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2012-05-16 11:15:44 +0800
commitda9563fd123263c5124ae336369d2aa8a5bdb9e4 (patch)
treea776a3cea0236ad59ae3a1d1e660671f70f4f155
parent36d4d32bdd6ecc03f45fd68b1c214748ab5e0c0b (diff)
glamor_set_destination_pixmap_priv_nc: set drawable's width x height.
Previous implementation set the whole fbo's width and height as the viewpoint. This may increase the numerical error as we may only has a partial region as the valid pixmap. So add a new marco pixmap_priv_get_dest_scale to get proper scale factor for the destination pixmap. For the source/mask pixmap, we still need to consider the whole fbo's size. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--src/glamor_copyarea.c4
-rw-r--r--src/glamor_fill.c2
-rw-r--r--src/glamor_pixmap.c19
-rw-r--r--src/glamor_priv.h2
-rw-r--r--src/glamor_render.c4
-rw-r--r--src/glamor_tile.c2
-rw-r--r--src/glamor_utils.h6
7 files changed, 22 insertions, 17 deletions
diff --git a/src/glamor_copyarea.c b/src/glamor_copyarea.c
index 3bb077c..356e0f9 100644
--- a/src/glamor_copyarea.c
+++ b/src/glamor_copyarea.c
@@ -183,7 +183,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
alu = gc->alu;
}
- pixmap_priv_get_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
@@ -206,8 +206,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
&src_y_off);
dx += src_x_off;
dy += src_y_off;
- pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
- &src_yscale);
dispatch->glActiveTexture(GL_TEXTURE0);
dispatch->glBindTexture(GL_TEXTURE_2D,
diff --git a/src/glamor_fill.c b/src/glamor_fill.c
index 072408e..57dd698 100644
--- a/src/glamor_fill.c
+++ b/src/glamor_fill.c
@@ -237,7 +237,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
GL_FALSE, 2 * sizeof(float),
vertices);
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
- pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
+ pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2,
glamor_priv->yInverted, vertices);
diff --git a/src/glamor_pixmap.c b/src/glamor_pixmap.c
index 3f268d9..f0c1586 100644
--- a/src/glamor_pixmap.c
+++ b/src/glamor_pixmap.c
@@ -64,7 +64,7 @@ glamor_pixmap_fini(ScreenPtr screen)
}
void
-glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo)
+glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0, int width, int height)
{
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
@@ -74,9 +74,8 @@ glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo)
dispatch->glMatrixMode(GL_MODELVIEW);
dispatch->glLoadIdentity();
#endif
- dispatch->glViewport(0, 0,
- fbo->width,
- fbo->height);
+ dispatch->glViewport(x0, y0,
+ width, height);
glamor_put_dispatch(fbo->glamor_priv);
}
@@ -84,7 +83,9 @@ glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo)
void
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv)
{
- glamor_set_destination_pixmap_fbo(pixmap_priv->fbo);
+ glamor_set_destination_pixmap_fbo(pixmap_priv->fbo, 0, 0,
+ pixmap_priv->container->drawable.width,
+ pixmap_priv->container->drawable.height);
}
int
@@ -507,7 +508,7 @@ ready_to_upload:
else
ptexcoords = texcoords_inv;
- pixmap_priv_get_scale(pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
glamor_set_normalize_vcoords(dst_xscale,
dst_yscale,
x, y,
@@ -733,8 +734,8 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLe
return NULL;
dispatch = glamor_get_dispatch(glamor_priv);
- temp_xscale = 1.0 / temp_fbo->width;
- temp_yscale = 1.0 / temp_fbo->height;
+ temp_xscale = 1.0 / w;
+ temp_yscale = 1.0 / h;
glamor_set_normalize_vcoords(temp_xscale,
temp_yscale,
@@ -770,7 +771,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLe
GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
- glamor_set_destination_pixmap_fbo(temp_fbo);
+ glamor_set_destination_pixmap_fbo(temp_fbo, 0, 0, w, h);
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
dispatch->glUniform1i(glamor_priv->
finish_access_revert[no_alpha],
diff --git a/src/glamor_priv.h b/src/glamor_priv.h
index d26f59f..8f1d428 100644
--- a/src/glamor_priv.h
+++ b/src/glamor_priv.h
@@ -456,7 +456,7 @@ void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
int glamor_set_destination_pixmap(PixmapPtr pixmap);
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *
pixmap_priv);
-void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *);
+void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *, int, int, int, int);
/* nc means no check. caller must ensure this pixmap has valid fbo.
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
diff --git a/src/glamor_render.c b/src/glamor_render.c
index a17b6fd..94f7dc5 100644
--- a/src/glamor_render.c
+++ b/src/glamor_render.c
@@ -1210,7 +1210,7 @@ glamor_composite_with_shader(CARD8 op,
glamor_get_drawable_deltas(dest->pDrawable, dest_pixmap,
&dest_x_off, &dest_y_off);
- pixmap_priv_get_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_dest_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
if (glamor_priv->has_source_coords) {
glamor_get_drawable_deltas(source->pDrawable,
@@ -2109,7 +2109,7 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
- pixmap_priv_get_scale(pixmap_priv, xscale, yscale);
+ pixmap_priv_get_dest_scale(pixmap_priv, xscale, yscale);
glamor_priv->has_source_coords = 1;
glamor_priv->has_mask_coords = 0;
diff --git a/src/glamor_tile.c b/src/glamor_tile.c
index df66d05..6790550 100644
--- a/src/glamor_tile.c
+++ b/src/glamor_tile.c
@@ -154,7 +154,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
}
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
- pixmap_priv_get_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
dispatch = glamor_get_dispatch(glamor_priv);
if (!glamor_set_alu(dispatch, alu)) {
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index 5cd37de..8dad2df 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -39,6 +39,12 @@
#define t_from_x_coord_y(_yscale_, _y_) (1.0 - (_y_) * (_yscale_))
#define t_from_x_coord_y_inverted(_yscale_, _y_) ((_y_) * (_yscale_))
+#define pixmap_priv_get_dest_scale(_pixmap_priv_, _pxscale_, _pyscale_) \
+ do { \
+ *(_pxscale_) = 1.0 / (_pixmap_priv_)->container->drawable.width; \
+ *(_pyscale_) = 1.0 / (_pixmap_priv_)->container->drawable.height; \
+ } while(0)
+
#define pixmap_priv_get_scale(_pixmap_priv_, _pxscale_, _pyscale_) \
do { \
*(_pxscale_) = 1.0 / (_pixmap_priv_)->fbo->width; \