Commit ca1908e1 authored by Zhigang Gong's avatar Zhigang Gong

glamor: Concentrate and reduce some coords processing code.

Concentrate the verties and texture coords processing code to a new
file glamor_utils.h. Change most of the code to macro. Will have some
performance benefit on slow machine. And reduce most of the duplicate
code when calculate the normalized coords.
Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 355334fc
...@@ -199,11 +199,13 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -199,11 +199,13 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src); PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst); PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
int i; int i;
float vertices[4][2], texcoords[4][2]; float vertices[8], texcoords[8];
glamor_pixmap_private *src_pixmap_priv; glamor_pixmap_private *src_pixmap_priv;
glamor_pixmap_private *dst_pixmap_priv; glamor_pixmap_private *dst_pixmap_priv;
int src_x_off, src_y_off, dst_x_off, dst_y_off; int src_x_off, src_y_off, dst_x_off, dst_y_off;
enum glamor_pixmap_status src_status = GLAMOR_NONE; enum glamor_pixmap_status src_status = GLAMOR_NONE;
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap); src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap); dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
...@@ -237,6 +239,9 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -237,6 +239,9 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
} }
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv); glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
pixmap_priv_get_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, &dst_y_off); glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off); glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
...@@ -258,42 +263,25 @@ glamor_copy_n_to_n_textured(DrawablePtr src, ...@@ -258,42 +263,25 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
assert(GLEW_ARB_fragment_shader); assert(GLEW_ARB_fragment_shader);
glUseProgramObjectARB(glamor_priv->finish_access_prog[0]); glUseProgramObjectARB(glamor_priv->finish_access_prog[0]);
for (i = 0; i < nbox; i++) { for (i = 0; i < nbox; i++) {
vertices[0][0] = v_from_x_coord_x(dst_pixmap, box[i].x1 + dst_x_off); glamor_set_normalize_vcoords(dst_xscale, dst_yscale,
vertices[1][0] = v_from_x_coord_x(dst_pixmap, box[i].x2 + dst_x_off); box[i].x1 + dst_x_off,
vertices[2][0] = v_from_x_coord_x(dst_pixmap, box[i].x2 + dst_x_off); box[i].y1 + dst_y_off,
vertices[3][0] = v_from_x_coord_x(dst_pixmap, box[i].x1 + dst_x_off); box[i].x2 + dst_x_off,
texcoords[0][0] = t_from_x_coord_x(src_pixmap, box[i].x1 + dx); box[i].y2 + dst_y_off,
texcoords[1][0] = t_from_x_coord_x(src_pixmap, box[i].x2 + dx); glamor_priv->yInverted,
texcoords[2][0] = t_from_x_coord_x(src_pixmap, box[i].x2 + dx); vertices);
texcoords[3][0] = t_from_x_coord_x(src_pixmap, box[i].x1 + dx);
glamor_set_normalize_tcoords(src_xscale, src_yscale,
if(glamor_priv->yInverted) { box[i].x1 + dx, box[i].y1 + dy,
box[i].x2 + dx, box[i].y2 + dy,
vertices[0][1] = v_from_x_coord_y_inverted(dst_pixmap, box[i].y1 + dst_y_off); glamor_priv->yInverted,
vertices[1][1] = v_from_x_coord_y_inverted(dst_pixmap, box[i].y1 + dst_y_off); texcoords);
vertices[2][1] = v_from_x_coord_y_inverted(dst_pixmap, box[i].y2 + dst_y_off);
vertices[3][1] = v_from_x_coord_y_inverted(dst_pixmap, box[i].y2 + dst_y_off); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
texcoords[0][1] = t_from_x_coord_y_inverted(src_pixmap, box[i].y1 + dy);
texcoords[1][1] = t_from_x_coord_y_inverted(src_pixmap, box[i].y1 + dy);
texcoords[2][1] = t_from_x_coord_y_inverted(src_pixmap, box[i].y2 + dy);
texcoords[3][1] = t_from_x_coord_y_inverted(src_pixmap, box[i].y2 + dy);
} else {
vertices[0][1] = v_from_x_coord_y(dst_pixmap, box[i].y1 + dst_y_off);
vertices[1][1] = v_from_x_coord_y(dst_pixmap, box[i].y1 + dst_y_off);
vertices[2][1] = v_from_x_coord_y(dst_pixmap, box[i].y2 + dst_y_off);
vertices[3][1] = v_from_x_coord_y(dst_pixmap, box[i].y2 + dst_y_off);
texcoords[0][1] = t_from_x_coord_y(src_pixmap, box[i].y1 + dy);
texcoords[1][1] = t_from_x_coord_y(src_pixmap, box[i].y1 + dy);
texcoords[2][1] = t_from_x_coord_y(src_pixmap, box[i].y2 + dy);
texcoords[3][1] = t_from_x_coord_y(src_pixmap, box[i].y2 + dy);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
glUseProgramObjectARB(0); glUseProgramObjectARB(0);
......
...@@ -146,14 +146,16 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, ...@@ -146,14 +146,16 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
{ {
ScreenPtr screen = pixmap->drawable.pScreen; ScreenPtr screen = pixmap->drawable.pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
int x1 = x; int x1 = x;
int x2 = x + width; int x2 = x + width;
int y1 = y; int y1 = y;
int y2 = y + height; int y2 = y + height;
GLfloat color[4]; GLfloat color[4];
float vertices[4][2]; float vertices[8];
GLfloat xscale, yscale;
if (glamor_set_destination_pixmap(pixmap)) {
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("dest has no fbo.\n"); glamor_fallback("dest has no fbo.\n");
goto fail; goto fail;
} }
...@@ -162,6 +164,9 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, ...@@ -162,6 +164,9 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glamor_fallback("Failedto set planemask in glamor_solid.\n"); glamor_fallback("Failedto set planemask in glamor_solid.\n");
goto fail; goto fail;
} }
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glUseProgramObjectARB(glamor_priv->solid_prog); glUseProgramObjectARB(glamor_priv->solid_prog);
glamor_get_rgba_from_pixel(fg_pixel, glamor_get_rgba_from_pixel(fg_pixel,
&color[0], &color[0],
...@@ -174,22 +179,11 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, ...@@ -174,22 +179,11 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices); glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
vertices[0][0] = v_from_x_coord_x(pixmap, x1); pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
vertices[1][0] = v_from_x_coord_x(pixmap, x2);
vertices[2][0] = v_from_x_coord_x(pixmap, x2); glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2,
vertices[3][0] = v_from_x_coord_x(pixmap, x1); glamor_priv->yInverted,
vertices);
if (glamor_priv->yInverted) {
vertices[0][1] = v_from_x_coord_y_inverted(pixmap, y1);
vertices[1][1] = v_from_x_coord_y_inverted(pixmap, y1);
vertices[2][1] = v_from_x_coord_y_inverted(pixmap, y2);
vertices[3][1] = v_from_x_coord_y_inverted(pixmap, y2);
} else {
vertices[0][1] = v_from_x_coord_y(pixmap, y1);
vertices[1][1] = v_from_x_coord_y(pixmap, y1);
vertices[2][1] = v_from_x_coord_y(pixmap, y2);
vertices[3][1] = v_from_x_coord_y(pixmap, y2);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
......
...@@ -42,11 +42,17 @@ glamor_get_spans(DrawablePtr drawable, ...@@ -42,11 +42,17 @@ glamor_get_spans(DrawablePtr drawable,
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
GLenum format, type; GLenum format, type;
int ax; int ax;
glamor_screen_private *glamor_priv = glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
glamor_get_screen_private(drawable->pScreen); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
int i; int i;
uint8_t *readpixels_dst = (uint8_t *)dst; uint8_t *readpixels_dst = (uint8_t *)dst;
int x_off, y_off; int x_off, y_off;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("pixmap has no fbo.\n");
goto fail;
}
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,
&type, &type,
...@@ -57,10 +63,8 @@ glamor_get_spans(DrawablePtr drawable, ...@@ -57,10 +63,8 @@ glamor_get_spans(DrawablePtr drawable,
goto fail; goto fail;
} }
if (glamor_set_destination_pixmap(pixmap)) { glamor_set_destination_pixmap_priv_nc(pixmap_priv);
glamor_fallback("pixmap has no fbo.\n");
goto fail;
}
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off); glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (glamor_priv->yInverted) { if (glamor_priv->yInverted) {
......
...@@ -505,44 +505,6 @@ glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask) ...@@ -505,44 +505,6 @@ glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
extern int glamor_debug_level; extern int glamor_debug_level;
static inline float
v_from_x_coord_x(PixmapPtr pixmap, int x)
{
return (float)x / pixmap->drawable.width * 2.0 - 1.0;
}
static inline float
v_from_x_coord_y(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height * -2.0 + 1.0;
}
static inline float
v_from_x_coord_y_inverted(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height * 2.0 - 1.0;
}
static inline float
t_from_x_coord_x(PixmapPtr pixmap, int x)
{
return (float)x / pixmap->drawable.width;
}
static inline float
t_from_x_coord_y(PixmapPtr pixmap, int y)
{
return 1.0 - (float)y / pixmap->drawable.height;
}
static inline float
t_from_x_coord_y_inverted(PixmapPtr pixmap, int y)
{
return (float)y / pixmap->drawable.height;
}
/* glamor.c */ /* glamor.c */
PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable); PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
...@@ -791,4 +753,7 @@ glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_pr ...@@ -791,4 +753,7 @@ glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_pr
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD #define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
#include"glamor_utils.h"
#endif /* GLAMOR_PRIV_H */ #endif /* GLAMOR_PRIV_H */
...@@ -87,17 +87,6 @@ glamor_init_putimage_shaders(ScreenPtr screen) ...@@ -87,17 +87,6 @@ glamor_init_putimage_shaders(ScreenPtr screen)
glUseProgramObjectARB(0); glUseProgramObjectARB(0);
} }
static int
y_flip(PixmapPtr pixmap, int y)
{
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap == screen_pixmap)
return (pixmap->drawable.height - 1) - y;
else
return y;
}
/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap /* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
* data (where each row starts at a bit index of left_pad), and the * data (where each row starts at a bit index of left_pad), and the
...@@ -110,6 +99,21 @@ y_flip(PixmapPtr pixmap, int y) ...@@ -110,6 +99,21 @@ y_flip(PixmapPtr pixmap, int y)
* case we might be better off just doing the fg/bg choosing in the CPU * case we might be better off just doing the fg/bg choosing in the CPU
* and just draw the resulting texture to the destination. * and just draw the resulting texture to the destination.
*/ */
#if 0
static int
y_flip(PixmapPtr pixmap, int y)
{
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
if (pixmap == screen_pixmap)
return (pixmap->drawable.height - 1) - y;
else
return y;
}
static void static void
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc, glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
int x, int y, int w, int h, int left_pad, int x, int y, int w, int h, int left_pad,
...@@ -124,25 +128,27 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc, ...@@ -124,25 +128,27 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
RegionPtr clip; RegionPtr clip;
BoxPtr box; BoxPtr box;
int nbox; int nbox;
float dest_coords[4][2]; float dest_coords[8];
const float bitmap_coords[8] = { const float bitmap_coords[8] = {
0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 1.0, 0.0,
1.0, 1.0, 1.0, 1.0,
0.0, 1.0, 0.0, 1.0,
}; };
GLfloat xscale, yscale;
glamor_pixmap_private *pixmap_priv;
pixmap_priv = glamor_get_pixmap_private(pixmap);
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
dest_coords[0][0] = v_from_x_coord_x(pixmap, x); glamor_set_normalize_vcoords(xscale, yscale,
dest_coords[0][1] = v_from_x_coord_y(pixmap, y); x, y,
dest_coords[1][0] = v_from_x_coord_x(pixmap, x + w); x + w, y + h,
dest_coords[1][1] = v_from_x_coord_y(pixmap, y); glamor_priv->yInverted,
dest_coords[2][0] = v_from_x_coord_x(pixmap, x + w); dest_coords);
dest_coords[2][1] = v_from_x_coord_y(pixmap, y + h);
dest_coords[3][0] = v_from_x_coord_x(pixmap, x);
dest_coords[3][1] = v_from_x_coord_y(pixmap, y + h);
glamor_fallback("glamor_put_image_xybitmap: disabled\n"); glamor_fallback("glamor_put_image_xybitmap: disabled\n");
goto fail; goto fail;
if (glamor_priv->put_image_xybitmap_prog == 0) { if (glamor_priv->put_image_xybitmap_prog == 0) {
...@@ -237,6 +243,8 @@ fail: ...@@ -237,6 +243,8 @@ fail:
glamor_finish_access(drawable); glamor_finish_access(drawable);
} }
} }
#endif
void void
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
...@@ -252,13 +260,13 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, ...@@ -252,13 +260,13 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
int nbox; int nbox;
int src_stride = PixmapBytePad(w, drawable->depth); int src_stride = PixmapBytePad(w, drawable->depth);
int x_off, y_off; int x_off, y_off;
float vertices[4][2], texcoords[4][2]; float vertices[8], texcoords[8];
GLfloat xscale, yscale, txscale, tyscale;
GLuint tex; GLuint tex;
int ax = 0; int ax = 0;
if (image_format == XYBitmap) { if (image_format == XYBitmap) {
assert(depth == 1); assert(depth == 1);
glamor_put_image_xybitmap(drawable, gc, x, y, w, h, goto fail;
left_pad, image_format, bits);
return; return;
} }
...@@ -319,8 +327,12 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, ...@@ -319,8 +327,12 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
y += drawable->y; y += drawable->y;
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off); glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
clip = fbGetCompositeClip(gc); clip = fbGetCompositeClip(gc);
txscale = 1.0/w;
tyscale = 1.0/h;
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
for (nbox = REGION_NUM_RECTS(clip), for (nbox = REGION_NUM_RECTS(clip),
pbox = REGION_RECTS(clip); pbox = REGION_RECTS(clip);
nbox--; nbox--;
...@@ -330,7 +342,6 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, ...@@ -330,7 +342,6 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
int y1 = y; int y1 = y;
int x2 = x + w; int x2 = x + w;
int y2 = y + h; int y2 = y + h;
float src_x1, src_x2, src_y1, src_y2;
if (x1 < pbox->x1) if (x1 < pbox->x1)
x1 = pbox->x1; x1 = pbox->x1;
...@@ -343,41 +354,18 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, ...@@ -343,41 +354,18 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
if (x1 >= x2 || y1 >= y2) if (x1 >= x2 || y1 >= y2)
continue; continue;
src_x1 = (float)(x1 - x) / w; glamor_set_normalize_tcoords( txscale, tyscale,
src_y1 = (float)(y1 - y) / h; x1 - x, y1 - y,
src_x2 = (float)(x2 - x) / w; x2 - x, y2 - y,
src_y2 = (float)(y2 - y) / h; 1,
texcoords);
vertices[0][0] = v_from_x_coord_x(pixmap, x1 + x_off);
vertices[1][0] = v_from_x_coord_x(pixmap, x2 + x_off); glamor_set_normalize_vcoords( xscale, yscale,
vertices[2][0] = v_from_x_coord_x(pixmap, x2 + x_off); x1 + x_off, y1 + y_off,
vertices[3][0] = v_from_x_coord_x(pixmap, x1 + x_off); x2 + x_off, y2 + y_off,
glamor_priv->yInverted,
texcoords[0][0] = src_x1; vertices);
texcoords[0][1] = src_y1;
texcoords[1][0] = src_x2;
texcoords[1][1] = src_y1;
texcoords[2][0] = src_x2;
texcoords[2][1] = src_y2;
texcoords[3][0] = src_x1;
texcoords[3][1] = src_y2;
if (glamor_priv->yInverted) {
vertices[0][1] = v_from_x_coord_y_inverted(pixmap, y1 + y_off);
vertices[1][1] = v_from_x_coord_y_inverted(pixmap, y1 + y_off);
vertices[2][1] = v_from_x_coord_y_inverted(pixmap, y2 + y_off);
vertices[3][1] = v_from_x_coord_y_inverted(pixmap, y2 + y_off);
} else {
vertices[0][1] = v_from_x_coord_y(pixmap, y1 + y_off);
vertices[1][1] = v_from_x_coord_y(pixmap, y1 + y_off);
vertices[2][1] = v_from_x_coord_y(pixmap, y2 + y_off);
vertices[3][1] = v_from_x_coord_y(pixmap, y2 + y_off);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
......
...@@ -533,41 +533,6 @@ good_dest_format(PicturePtr picture) ...@@ -533,41 +533,6 @@ good_dest_format(PicturePtr picture)
} }
} }
static inline float
xFixedToFloat(pixman_fixed_t val)
{
return ((float)xFixedToInt(val) + ((float)xFixedFrac(val) / 65536.0));
}
static void
glamor_set_transformed_point(PicturePtr picture, PixmapPtr pixmap,
float *texcoord, int x, int y)
{
float result[3];
int i;
float tx, ty;
ScreenPtr screen = picture->pDrawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
if (picture->transform) {
for (i = 0; i < 3; i++) {
result[i] = (xFixedToFloat(picture->transform->matrix[i][0]) * x +
xFixedToFloat(picture->transform->matrix[i][1]) * y +
xFixedToFloat(picture->transform->matrix[i][2]));
}
tx = result[0] / result[2];
ty = result[1] / result[2];
} else {
tx = x;
ty = y;
}
texcoord[0] = t_from_x_coord_x(pixmap, tx);
if (glamor_priv->yInverted)
texcoord[1] = t_from_x_coord_y_inverted(pixmap, ty);
else
texcoord[1] = t_from_x_coord_y(pixmap, ty);
}
static void static void
glamor_setup_composite_vbo(ScreenPtr screen) glamor_setup_composite_vbo(ScreenPtr screen)
{ {
...@@ -756,6 +721,8 @@ glamor_composite_with_shader(CARD8 op, ...@@ -756,6 +721,8 @@ glamor_composite_with_shader(CARD8 op,
glamor_pixmap_private *source_pixmap_priv = NULL; glamor_pixmap_private *source_pixmap_priv = NULL;
glamor_pixmap_private *mask_pixmap_priv = NULL; glamor_pixmap_private *mask_pixmap_priv = NULL;
glamor_pixmap_private *dest_pixmap_priv = NULL; glamor_pixmap_private *dest_pixmap_priv = NULL;
GLfloat dst_xscale, dst_yscale;
GLfloat mask_xscale = 1, mask_yscale = 1, src_xscale = 1, src_yscale = 1;
struct shader_key key; struct shader_key key;
glamor_composite_shader *shader; glamor_composite_shader *shader;
RegionRec region; RegionRec region;
...@@ -768,6 +735,8 @@ glamor_composite_with_shader(CARD8 op, ...@@ -768,6 +735,8 @@ glamor_composite_with_shader(CARD8 op,
enum glamor_pixmap_status source_status = GLAMOR_NONE; enum glamor_pixmap_status source_status = GLAMOR_NONE;
enum glamor_pixmap_status mask_status = GLAMOR_NONE; enum glamor_pixmap_status mask_status = GLAMOR_NONE;
PictFormatShort saved_source_format = 0; PictFormatShort saved_source_format = 0;
float src_matrix[9], mask_matrix[9];
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) { if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
...@@ -972,14 +941,24 @@ glamor_composite_with_shader(CARD8 op, ...@@ -972,14 +941,24 @@ glamor_composite_with_shader(CARD8 op,
glamor_get_drawable_deltas(dest->pDrawable, dest_pixmap, glamor_get_drawable_deltas(dest->pDrawable, dest_pixmap,
&dest_x_off, &dest_y_off); &dest_x_off, &dest_y_off);
pixmap_priv_get_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
if (source_pixmap) { if (source_pixmap) {
glamor_get_drawable_deltas(source->pDrawable, source_pixmap, glamor_get_drawable_deltas(source->pDrawable, source_pixmap,
&source_x_off, &source_y_off); &source_x_off, &source_y_off);
pixmap_priv_get_scale(source_pixmap_priv, &src_xscale, &src_yscale);
glamor_picture_get_matrixf(source, src_matrix);
} }
if (mask_pixmap) { if (mask_pixmap) {
glamor_get_drawable_deltas(mask->pDrawable, mask_pixmap, glamor_get_drawable_deltas(mask->pDrawable, mask_pixmap,
&mask_x_off, &mask_y_off); &mask_x_off, &mask_y_off);
pixmap_priv_get_scale(mask_pixmap_priv, &mask_xscale, &mask_yscale);
glamor_picture_get_matrixf(mask, mask_matrix);
} }
while (nrect--) { while (nrect--) {
INT16 x_source; INT16 x_source;
INT16 y_source; INT16 y_source;
...@@ -1025,65 +1004,41 @@ glamor_composite_with_shader(CARD8 op, ...@@ -1025,65 +1004,41 @@ glamor_composite_with_shader(CARD8 op,
box = REGION_RECTS(&region); box = REGION_RECTS(&region);
for (i = 0; i < REGION_NUM_RECTS(&region); i++) { for (i = 0; i < REGION_NUM_RECTS(&region); i++) {
vertices[0] = v_from_x_coord_x(dest_pixmap, int vx1 = box[i].x1 + dest_x_off;
box[i].x1 + dest_x_off); int vx2 = box[i].x2 + dest_x_off;
vertices[2] = v_from_x_coord_x(dest_pixmap, int vy1 = box[i].y1 + dest_y_off;
box[i].x2 + dest_x_off); int vy2 = box[i].y2 + dest_y_off;
vertices[4] = v_from_x_coord_x(dest_pixmap, glamor_set_normalize_vcoords(dst_xscale, dst_yscale, vx1, vy1, vx2, vy2,
box[i].x2 + dest_x_off); glamor_priv->yInverted, vertices);
vertices[6] = v_from_x_coord_x(dest_pixmap,
box[i].x1 + dest_x_off);
if (glamor_priv->yInverted) {