Commit 81692804 authored by Zhigang Gong's avatar Zhigang Gong Committed by Eric Anholt

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: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 7f55e484
......@@ -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,
......
......@@ -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);
......
......@@ -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],
......
......@@ -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.
......
......@@ -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;
......
......@@ -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)) {
......
......@@ -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; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment