Jeff Smith : gdiplus: Simplify modulo 8 math used for rendering origin.

Alexandre Julliard julliard at winehq.org
Mon Jun 22 15:55:57 CDT 2020


Module: wine
Branch: master
Commit: 47b0155f96a00e201abeaa01b05aea2084923dbc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=47b0155f96a00e201abeaa01b05aea2084923dbc

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Wed Jun 17 16:39:53 2020 -0500

gdiplus: Simplify modulo 8 math used for rendering origin.

Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Esme Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/graphics.c    | 10 +++++-----
 dlls/gdiplus/tests/brush.c |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 6619be9b58..4b141e19b6 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -159,8 +159,8 @@ static HBITMAP create_hatch_bitmap(const GpHatch *hatch, INT origin_x, INT origi
              * degree of shading needed. */
             for (y = 0; y < 8; y++)
             {
-                const int hy = (((y + origin_y) % 8) + 8) % 8;
-                const int hx = ((origin_x % 8) + 8) % 8;
+                const int hy = (y + origin_y) & 7;
+                const int hx = origin_x & 7;
                 unsigned int row = (0x10101 * hatch_data[hy]) >> hx;
 
                 for (x = 0; x < 8; x++, row >>= 1)
@@ -1198,13 +1198,13 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush,
         /* See create_hatch_bitmap for an explanation of how index is derived. */
         for (y = 0; y < fill_area->Height; y++, argb_pixels += cdwStride)
         {
-            const int hy = (7 - ((y + fill_area->Y - graphics->origin_y) % 8)) % 8;
-            const int hx = ((graphics->origin_x % 8) + 8) % 8;
+            const int hy = ~(y + fill_area->Y - graphics->origin_y) & 7;
+            const int hx = graphics->origin_x & 7;
             const unsigned int row = (0x10101 * hatch_data[hy]) >> hx;
 
             for (x = 0; x < fill_area->Width; x++)
             {
-                const unsigned int srow = row >> (7 - ((x + fill_area->X) % 8));
+                const unsigned int srow = row >> (~(x + fill_area->X) & 7);
                 int index;
                 if (hatch_data[8])
                     index = (srow & 1) ? 2 : (srow & 0x82) ? 1 : 0;
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index 5d5280c7f9..78939e6899 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -1814,8 +1814,8 @@ static void test_renderingOrigin(void)
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
-        const INT exp_x = ((tests[i][0] % 8) + 8) % 8;
-        const INT exp_y = ((tests[i][1] % 8) + 8) % 8;
+        const INT exp_x = tests[i][0] & 7;
+        const INT exp_y = tests[i][1] & 7;
 
         status = GdipSetRenderingOrigin(graphics_image, tests[i][0], tests[i][1]);
         expect(Ok, status);




More information about the wine-cvs mailing list