[PATCH 1/2] gdiplus: Simplify modulo 8 math used for rendering origin.
Jeff Smith
whydoubt at gmail.com
Wed Jun 17 16:39:53 CDT 2020
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
Supersedes uncommitted portions of 187295 and 187296.
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);
--
2.23.0
More information about the wine-devel
mailing list