From f69dce851b366e9f317023d41569bee91dbb22a5 Mon Sep 17 00:00:00 2001
From: Roderick Colenbrander <thunderbird2k@gmail.com>
Date: Thu, 1 Oct 2009 21:45:47 +0200
Subject: [PATCH] Move computation of scaling factors to xrender_blit in order to prepare for tiling support.

---
 dlls/winex11.drv/xrender.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index a1e883e..ae22936 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -1780,14 +1780,17 @@ static void set_xrender_transformation(Picture src_pict, float xscale, float ysc
 }
 
 /* Helper function for (stretched) blitting using xrender */
-static void xrender_blit(Picture src_pict, Picture mask_pict, Picture dst_pict, int x_src, int y_src, float xscale, float yscale, int width, int height)
+static void xrender_blit(Picture src_pict, Picture mask_pict, Picture dst_pict, int x_src, int y_src, int width_src, int height_src, int width_dst, int height_dst)
 {
+    float xscale = width_src / (float)width_dst;
+    float yscale = height_src / (float)height_dst;
+
     /* Further down a transformation matrix is used for stretching and mirroring the source data.
      * xscale/yscale contain the scaling factors for the width and height. In case of mirroring
      * we also need a x- and y-offset because without the pixels will be in the wrong quadrant of the x-y plane.
      */
-    int x_offset = (xscale<0) ? width : 0;
-    int y_offset = (yscale<0) ? height : 0;
+    int x_offset = (xscale<0) ? width_dst : 0;
+    int y_offset = (yscale<0) ? height_dst : 0;
 
     /* When we need to scale we perform scaling and source_x / source_y translation using a transformation matrix.
      * This is needed because XRender is inaccurate in combination with scaled source coordinates passed to XRenderComposite.
@@ -1800,7 +1803,7 @@ static void xrender_blit(Picture src_pict, Picture mask_pict, Picture dst_pict,
         else
             set_xrender_transformation(src_pict, xscale, yscale, x_src + x_offset, y_src + y_offset);
 
-        pXRenderComposite(gdi_display, PictOpSrc, src_pict, mask_pict, dst_pict, 0, 0, 0, 0, 0, 0, width, height);
+        pXRenderComposite(gdi_display, PictOpSrc, src_pict, mask_pict, dst_pict, 0, 0, 0, 0, 0, 0, width_dst, height_dst);
     }
     else
     {
@@ -1810,7 +1813,7 @@ static void xrender_blit(Picture src_pict, Picture mask_pict, Picture dst_pict,
         else
             set_xrender_transformation(src_pict, 1, 1, 0, 0);
 
-        pXRenderComposite(gdi_display, PictOpSrc, src_pict, mask_pict, dst_pict, x_src, y_src, 0, 0, 0, 0, width, height);
+        pXRenderComposite(gdi_display, PictOpSrc, src_pict, mask_pict, dst_pict, x_src, y_src, 0, 0, 0, 0, width_dst, height_dst);
     }
 }
 
@@ -2042,7 +2045,7 @@ void X11DRV_XRender_CopyBrush(X11DRV_PDEVICE *physDev, X_PHYSBITMAP *physBitmap,
         src_pict = pXRenderCreatePicture(gdi_display, physBitmap->pixmap, src_format->pict_format, CPSubwindowMode|CPRepeat, &pa);
         dst_pict = pXRenderCreatePicture(gdi_display, physDev->brush.pixmap, dst_format->pict_format, CPSubwindowMode|CPRepeat, &pa);
 
-        xrender_blit(src_pict, 0, dst_pict, 0, 0, 1.0, 1.0, width, height);
+        xrender_blit(src_pict, 0, dst_pict, 0, 0, width, height, width, height);
         pXRenderFreePicture(gdi_display, src_pict);
         pXRenderFreePicture(gdi_display, dst_pict);
     }
@@ -2064,9 +2067,6 @@ BOOL X11DRV_XRender_GetSrcAreaStretch(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
     WineXRenderFormat *dst_format = get_xrender_format_from_color_shifts(physDevDst->depth, physDevDst->color_shifts);
     Picture src_pict=0, dst_pict=0, mask_pict=0;
 
-    double xscale = width_src/(double)width_dst;
-    double yscale = height_src/(double)height_dst;
-
     XRenderPictureAttributes pa;
     pa.subwindow_mode = IncludeInferiors;
     pa.repeat = RepeatNone;
@@ -2115,7 +2115,7 @@ BOOL X11DRV_XRender_GetSrcAreaStretch(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
         dst_pict = pXRenderCreatePicture(gdi_display, pixmap, dst_format->pict_format, CPSubwindowMode|CPRepeat, &pa);
         pXRenderFillRectangle(gdi_display, PictOpSrc, dst_pict, &col, 0, 0, width_dst, height_dst);
 
-        xrender_blit(src_pict, mask_pict, dst_pict, x_src, y_src, xscale, yscale, width_dst, height_dst);
+        xrender_blit(src_pict, mask_pict, dst_pict, x_src, y_src, width_src, height_src, width_dst, height_dst);
 
         if(dst_pict) pXRenderFreePicture(gdi_display, dst_pict);
         if(mask_pict) pXRenderFreePicture(gdi_display, mask_pict);
@@ -2132,7 +2132,7 @@ BOOL X11DRV_XRender_GetSrcAreaStretch(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE
                                           pixmap, dst_format->pict_format,
                                           CPSubwindowMode|CPRepeat, &pa);
 
-        xrender_blit(src_pict, 0, dst_pict, x_src, y_src, xscale, yscale, width_dst, height_dst);
+        xrender_blit(src_pict, 0, dst_pict, x_src, y_src, width_src, height_src, width_dst, height_dst);
 
         if(src_pict) pXRenderFreePicture(gdi_display, src_pict);
         if(dst_pict) pXRenderFreePicture(gdi_display, dst_pict);
-- 
1.6.0.4

