Fix the problem of x_source and y_source causing radial error
The x_source and y_source cause some problem in gradient. The old way to handle it by recaulate P1 P2 to minus the x_source and y_source, but this causes problem in radial shader. Now we modify the manner to set the texture coordinates: (x_source, y_source) --> (x_source + width, y_source + height) to handle all the cases. Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Signed-off-by: Junyan He <junyan.he@linux.intel.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
553910d08b
commit
4c174f4c9c
@ -814,14 +814,16 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
|
|||||||
|
|
||||||
if (tex_normalize) {
|
if (tex_normalize) {
|
||||||
glamor_set_normalize_tcoords(*xscale, *yscale,
|
glamor_set_normalize_tcoords(*xscale, *yscale,
|
||||||
0, 0,
|
x_source, y_source,
|
||||||
(INT16)(dst_picture->pDrawable->width),
|
(INT16)(dst_picture->pDrawable->width + x_source),
|
||||||
(INT16)(dst_picture->pDrawable->height),
|
(INT16)(dst_picture->pDrawable->height + y_source),
|
||||||
glamor_priv->yInverted, tex_vertices);
|
glamor_priv->yInverted, tex_vertices);
|
||||||
} else {
|
} else {
|
||||||
glamor_set_tcoords(0, 0,
|
glamor_set_tcoords((INT16)(dst_picture->pDrawable->width),
|
||||||
(INT16)(dst_picture->pDrawable->width),
|
|
||||||
(INT16)(dst_picture->pDrawable->height),
|
(INT16)(dst_picture->pDrawable->height),
|
||||||
|
x_source, y_source,
|
||||||
|
(INT16)(dst_picture->pDrawable->width) + x_source,
|
||||||
|
(INT16)(dst_picture->pDrawable->height) + y_source,
|
||||||
glamor_priv->yInverted, tex_vertices);
|
glamor_priv->yInverted, tex_vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,14 +1203,11 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||||||
r1 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.radius);
|
r1 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.radius);
|
||||||
r2 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.radius);
|
r2 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.radius);
|
||||||
|
|
||||||
|
glamor_set_circle_centre(width, height, c1x, c1y, glamor_priv->yInverted, cxy);
|
||||||
cxy[0] = c1x;
|
|
||||||
cxy[1] = c1y;
|
|
||||||
dispatch->glUniform2fv(c1_uniform_location, 1, cxy);
|
dispatch->glUniform2fv(c1_uniform_location, 1, cxy);
|
||||||
dispatch->glUniform1f(r1_uniform_location, r1);
|
dispatch->glUniform1f(r1_uniform_location, r1);
|
||||||
|
|
||||||
cxy[0] = c2x;
|
glamor_set_circle_centre(width, height, c2x, c2y, glamor_priv->yInverted, cxy);
|
||||||
cxy[1] = c2y;
|
|
||||||
dispatch->glUniform2fv(c2_uniform_location, 1, cxy);
|
dispatch->glUniform2fv(c2_uniform_location, 1, cxy);
|
||||||
dispatch->glUniform1f(r2_uniform_location, r2);
|
dispatch->glUniform1f(r2_uniform_location, r2);
|
||||||
|
|
||||||
@ -1282,7 +1281,7 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
float slope;
|
float slope;
|
||||||
GLfloat xscale, yscale;
|
GLfloat xscale, yscale;
|
||||||
GLfloat pt1[4], pt2[4];
|
GLfloat pt1[2], pt2[2];
|
||||||
float vertices[8];
|
float vertices[8];
|
||||||
float transform_mat[3][3];
|
float transform_mat[3][3];
|
||||||
static const float identity_mat[3][3] = {{1.0, 0.0, 0.0},
|
static const float identity_mat[3][3] = {{1.0, 0.0, 0.0},
|
||||||
@ -1292,8 +1291,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||||||
GLfloat n_stops_st[LINEAR_SMALL_STOPS];
|
GLfloat n_stops_st[LINEAR_SMALL_STOPS];
|
||||||
|
|
||||||
GLint transform_mat_uniform_location = 0;
|
GLint transform_mat_uniform_location = 0;
|
||||||
GLint pt1_uniform_location = 0;
|
|
||||||
GLint pt2_uniform_location = 0;
|
|
||||||
GLint n_stop_uniform_location = 0;
|
GLint n_stop_uniform_location = 0;
|
||||||
GLint stops_uniform_location = 0;
|
GLint stops_uniform_location = 0;
|
||||||
GLint stop0_uniform_location = 0;
|
GLint stop0_uniform_location = 0;
|
||||||
@ -1441,24 +1438,20 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||||||
|
|
||||||
/* Normalize the PTs. */
|
/* Normalize the PTs. */
|
||||||
glamor_set_normalize_pt(xscale, yscale,
|
glamor_set_normalize_pt(xscale, yscale,
|
||||||
pixman_fixed_to_int(src_picture->pSourcePict->linear.p1.x),
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
|
||||||
x_source,
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y),
|
||||||
pixman_fixed_to_int(src_picture->pSourcePict->linear.p1.y),
|
|
||||||
y_source,
|
|
||||||
glamor_priv->yInverted,
|
glamor_priv->yInverted,
|
||||||
pt1);
|
pt1);
|
||||||
dispatch->glUniform4fv(pt1_uniform_location, 1, pt1);
|
DEBUGF("pt1:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
|
||||||
DEBUGF("pt1:(%f %f)\n", pt1[0], pt1[1]);
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y), pt1[0], pt1[1]);
|
||||||
|
|
||||||
glamor_set_normalize_pt(xscale, yscale,
|
glamor_set_normalize_pt(xscale, yscale,
|
||||||
pixman_fixed_to_int(src_picture->pSourcePict->linear.p2.x),
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
|
||||||
x_source,
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y),
|
||||||
pixman_fixed_to_int(src_picture->pSourcePict->linear.p2.y),
|
|
||||||
y_source,
|
|
||||||
glamor_priv->yInverted,
|
glamor_priv->yInverted,
|
||||||
pt2);
|
pt2);
|
||||||
dispatch->glUniform4fv(pt2_uniform_location, 1, pt2);
|
DEBUGF("pt2:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
|
||||||
DEBUGF("pt2:(%f %f)\n", pt2[0], pt2[1]);
|
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y), pt2[0], pt2[1]);
|
||||||
|
|
||||||
/* Set all the stops and colors to shader. */
|
/* Set all the stops and colors to shader. */
|
||||||
if (stops_count > LINEAR_SMALL_STOPS) {
|
if (stops_count > LINEAR_SMALL_STOPS) {
|
||||||
|
@ -143,54 +143,65 @@
|
|||||||
(vertices)[7] = (vertices)[5]; \
|
(vertices)[7] = (vertices)[5]; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define glamor_set_tcoords(x1, y1, x2, y2, yInverted, vertices) \
|
#define glamor_set_tcoords(width, height, x1, y1, x2, y2, \
|
||||||
do { \
|
yInverted, vertices) \
|
||||||
(vertices)[0] = (x1); \
|
do { \
|
||||||
(vertices)[2] = (x2); \
|
(vertices)[0] = (x1); \
|
||||||
(vertices)[4] = (vertices)[2]; \
|
(vertices)[2] = (x2); \
|
||||||
(vertices)[6] = (vertices)[0]; \
|
(vertices)[4] = (vertices)[2]; \
|
||||||
if (yInverted) { \
|
(vertices)[6] = (vertices)[0]; \
|
||||||
(vertices)[1] = (y1); \
|
if (yInverted) { \
|
||||||
(vertices)[5] = (y2); \
|
(vertices)[1] = (y1); \
|
||||||
} \
|
(vertices)[5] = (y2); \
|
||||||
else { \
|
} \
|
||||||
(vertices)[1] = (y2); \
|
else { \
|
||||||
(vertices)[5] = (y1); \
|
(vertices)[1] = height - (y2); \
|
||||||
} \
|
(vertices)[5] = height - (y1); \
|
||||||
(vertices)[3] = (vertices)[1]; \
|
} \
|
||||||
(vertices)[7] = (vertices)[5]; \
|
(vertices)[3] = (vertices)[1]; \
|
||||||
|
(vertices)[7] = (vertices)[5]; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
#define glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2, \
|
#define glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2, \
|
||||||
yInverted, vertices) \
|
yInverted, vertices) \
|
||||||
do { \
|
do { \
|
||||||
(vertices)[0] = v_from_x_coord_x(xscale, x1); \
|
(vertices)[0] = v_from_x_coord_x(xscale, x1); \
|
||||||
(vertices)[2] = v_from_x_coord_x(xscale, x2); \
|
(vertices)[2] = v_from_x_coord_x(xscale, x2); \
|
||||||
(vertices)[4] = (vertices)[2]; \
|
(vertices)[4] = (vertices)[2]; \
|
||||||
(vertices)[6] = (vertices)[0]; \
|
(vertices)[6] = (vertices)[0]; \
|
||||||
if (yInverted) { \
|
if (yInverted) { \
|
||||||
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y1); \
|
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y1); \
|
||||||
(vertices)[5] = v_from_x_coord_y_inverted(yscale, y2); \
|
(vertices)[5] = v_from_x_coord_y_inverted(yscale, y2); \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
(vertices)[1] = v_from_x_coord_y(yscale, y1); \
|
(vertices)[1] = v_from_x_coord_y(yscale, y1); \
|
||||||
(vertices)[5] = v_from_x_coord_y(yscale, y2); \
|
(vertices)[5] = v_from_x_coord_y(yscale, y2); \
|
||||||
} \
|
} \
|
||||||
(vertices)[3] = (vertices)[1]; \
|
(vertices)[3] = (vertices)[1]; \
|
||||||
(vertices)[7] = (vertices)[5]; \
|
(vertices)[7] = (vertices)[5]; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define glamor_set_normalize_pt(xscale, yscale, x, x_start, y, y_start, \
|
#define glamor_set_normalize_pt(xscale, yscale, x, y, \
|
||||||
yInverted, pt) \
|
yInverted, pt) \
|
||||||
do { \
|
do { \
|
||||||
(pt)[0] = t_from_x_coord_x(xscale, x - x_start); \
|
(pt)[0] = t_from_x_coord_x(xscale, x); \
|
||||||
if (yInverted) { \
|
if (yInverted) { \
|
||||||
(pt)[1] = t_from_x_coord_y_inverted(yscale, y - y_start); \
|
(pt)[1] = t_from_x_coord_y_inverted(yscale, y); \
|
||||||
} else { \
|
} else { \
|
||||||
(pt)[1] = t_from_x_coord_y(yscale, y - y_start); \
|
(pt)[1] = t_from_x_coord_y(yscale, y); \
|
||||||
} \
|
} \
|
||||||
(pt)[2] = (pt)[3] = 0.0; \
|
} while(0)
|
||||||
|
|
||||||
|
#define glamor_set_circle_centre(width, height, x, y, \
|
||||||
|
yInverted, c) \
|
||||||
|
do { \
|
||||||
|
(c)[0] = (float)x; \
|
||||||
|
if (yInverted) { \
|
||||||
|
(c)[1] = (float)y; \
|
||||||
|
} else { \
|
||||||
|
(c)[1] = (float)height - (float)y; \
|
||||||
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
|
Loading…
Reference in New Issue
Block a user