[PATCH 2/3] gdi32: Handle the case of a partial source byte separately.

Huw Davies huw at codeweavers.com
Wed Aug 24 02:55:33 CDT 2016


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/gdi32/dibdrv/primitives.c | 79 +++++++++++++++++++++++++++++++++++++++---
 dlls/gdi32/tests/dib.c         | 36 +++++++++++--------
 2 files changed, 96 insertions(+), 19 deletions(-)

diff --git a/dlls/gdi32/dibdrv/primitives.c b/dlls/gdi32/dibdrv/primitives.c
index d512af2..b547aa3 100644
--- a/dlls/gdi32/dibdrv/primitives.c
+++ b/dlls/gdi32/dibdrv/primitives.c
@@ -5267,7 +5267,7 @@ static void mask_rect_32( const dib_info *dst, const RECT *rc,
     DWORD *dst_start = get_pixel_ptr_32(dst, rc->left, rc->top), dst_colors[256];
     DWORD src_val, bit_val, i, full, pos;
     struct rop_codes codes;
-    int x, y;
+    int x, y, origin_end = origin->x + rc->right - rc->left;
     const RGBQUAD *color_table = get_dib_color_table( src );
     BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
 
@@ -5287,6 +5287,23 @@ static void mask_rect_32( const dib_info *dst, const RECT *rc,
     for (i = 2; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
         dst_colors[i] = dst_colors[i & 1];
 
+    /* Special case starting and finishing in same byte, neither on byte boundary */
+    if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
+    {
+        for (y = rc->top; y < rc->bottom; y++)
+        {
+            pos = origin->x & 7;
+            for (x = 0; x < rc->right - rc->left; x++, pos++)
+            {
+                bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
+                do_rop_codes_32( dst_start + x, dst_colors[bit_val], &codes );
+            }
+            dst_start += dst->stride / 4;
+            src_start += src->stride;
+        }
+        return;
+    }
+
     for (y = rc->top; y < rc->bottom; y++)
     {
         pos = origin->x & 7;
@@ -5337,13 +5354,33 @@ static void mask_rect_24( const dib_info *dst, const RECT *rc,
     BYTE *dst_start = get_pixel_ptr_24(dst, rc->left, rc->top);
     DWORD src_val, bit_val, i, full, pos;
     struct rop_codes codes;
-    int x, y;
+    int x, y, origin_end = origin->x + rc->right - rc->left;
     const RGBQUAD *color_table = get_dib_color_table( src );
     BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
     RGBQUAD rgb;
 
     get_rop_codes( rop2, &codes );
 
+    /* Special case starting and finishing in same byte, neither on byte boundary */
+    if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
+    {
+        for (y = rc->top; y < rc->bottom; y++)
+        {
+            pos = origin->x & 7;
+            for (x = 0; x < rc->right - rc->left; x++, pos++)
+            {
+                bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
+                rgb = color_table[bit_val];
+                do_rop_codes_8( dst_start + x * 3, rgb.rgbBlue, &codes );
+                do_rop_codes_8( dst_start + x * 3 + 1, rgb.rgbGreen, &codes );
+                do_rop_codes_8( dst_start + x * 3 + 2, rgb.rgbRed, &codes );
+            }
+            dst_start += dst->stride;
+            src_start += src->stride;
+        }
+        return;
+    }
+
     for (y = rc->top; y < rc->bottom; y++)
     {
         pos = origin->x & 7;
@@ -5439,7 +5476,7 @@ static void mask_rect_16( const dib_info *dst, const RECT *rc,
     WORD *dst_start = get_pixel_ptr_16(dst, rc->left, rc->top), dst_colors[2];
     DWORD src_val, bit_val, i, full, pos;
     struct rop_codes codes;
-    int x, y;
+    int x, y, origin_end = origin->x + rc->right - rc->left;
     const RGBQUAD *color_table = get_dib_color_table( src );
     BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
 
@@ -5456,6 +5493,23 @@ static void mask_rect_16( const dib_info *dst, const RECT *rc,
                             put_field(color_table[i].rgbGreen, dst->green_shift, dst->green_len) |
                             put_field(color_table[i].rgbBlue,  dst->blue_shift,  dst->blue_len);
 
+    /* Special case starting and finishing in same byte, neither on byte boundary */
+    if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
+    {
+        for (y = rc->top; y < rc->bottom; y++)
+        {
+            pos = origin->x & 7;
+            for (x = 0; x < rc->right - rc->left; x++, pos++)
+            {
+                bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
+                do_rop_codes_16( dst_start + x, dst_colors[bit_val], &codes );
+            }
+            dst_start += dst->stride / 2;
+            src_start += src->stride;
+        }
+        return;
+    }
+
     for (y = rc->top; y < rc->bottom; y++)
     {
         pos = origin->x & 7;
@@ -5506,7 +5560,7 @@ static void mask_rect_8( const dib_info *dst, const RECT *rc,
     BYTE *dst_start = get_pixel_ptr_8(dst, rc->left, rc->top), dst_colors[2];
     DWORD src_val, bit_val, i, full, pos;
     struct rop_codes codes;
-    int x, y;
+    int x, y, origin_end = origin->x + rc->right - rc->left;
     const RGBQUAD *color_table = get_dib_color_table( src );
     BYTE *src_start = get_pixel_ptr_1(src, origin->x, origin->y);
 
@@ -5516,6 +5570,23 @@ static void mask_rect_8( const dib_info *dst, const RECT *rc,
         dst_colors[i] = rgb_to_pixel_colortable( dst, color_table[i].rgbRed, color_table[i].rgbGreen,
                                                  color_table[i].rgbBlue );
 
+    /* Special case starting and finishing in same byte, neither on byte boundary */
+    if ((origin->x & 7) && (origin_end & 7) && (origin->x & ~7) == (origin_end & ~7))
+    {
+        for (y = rc->top; y < rc->bottom; y++)
+        {
+            pos = origin->x & 7;
+            for (x = 0; x < rc->right - rc->left; x++, pos++)
+            {
+                bit_val = (src_start[pos / 8] & pixel_masks_1[pos % 8]) ? 1 : 0;
+                do_rop_codes_8( dst_start + x, dst_colors[bit_val], &codes );
+            }
+            dst_start += dst->stride;
+            src_start += src->stride;
+        }
+        return;
+    }
+
     for (y = rc->top; y < rc->bottom; y++)
     {
         pos = origin->x & 7;
diff --git a/dlls/gdi32/tests/dib.c b/dlls/gdi32/tests/dib.c
index b59c0dd..ffbd773 100644
--- a/dlls/gdi32/tests/dib.c
+++ b/dlls/gdi32/tests/dib.c
@@ -128,7 +128,7 @@ static const char *sha1_graphics_a8r8g8b8[] =
     "a1fe9aa885584a0f713d7c6f76c89830fbf28563",
     "d7085333becdec7759a5229e5fe9ba1e11db0c22",
     "aaf62842bb98d8a2945c4f643baf50afaeea9307",
-    "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab",
+    "d7e34fa02db7ad52327f80389bd1ba1b72b6c692",
     "d7dd4700f49808541bba99244b7eb5840e0a2439",
     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
     "568f87f0194ca19b69a5b2bcdef795d89c5721ce",
@@ -201,7 +201,7 @@ static const char *sha1_graphics_a8r8g8b8_bitfields[] =
     "a1fe9aa885584a0f713d7c6f76c89830fbf28563",
     "d7085333becdec7759a5229e5fe9ba1e11db0c22",
     "aaf62842bb98d8a2945c4f643baf50afaeea9307",
-    "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab",
+    "d7e34fa02db7ad52327f80389bd1ba1b72b6c692",
     "d7dd4700f49808541bba99244b7eb5840e0a2439",
     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
     "568f87f0194ca19b69a5b2bcdef795d89c5721ce",
@@ -274,7 +274,7 @@ static const char *sha1_graphics_a8b8g8r8[] =
     "88fd743d00bd37d2ed722092146795b044d08a6e",
     "c0537ec24147e74939219213d864ee113cad9967",
     "118bf4c5bddc206ba737f7aa8b239940cd1aadc2",
-    "7cb51f6c5f1dae926601986c934533df5f8baa9f",
+    "eac5d164b83edf2cf85bac242686f9f617ec1fa4",
     "86c84cc8306975edecc6d4a89a8aff29f59b55a7",
     "af99228aa4cfbd1f61bd824db046144a3c6c2ed7",
     "25675c30adfe24d6cae60793b156dfdaa36ac3ba",
@@ -347,7 +347,7 @@ static const char *sha1_graphics_r10g10b10[] =
     "0790585dfaef94f912b1ee81477d4ac448708708",
     "589fb8a85d924ad19ed78409ae89475ba479c30a",
     "43d67bc61ef54014b022891e5c024fc24b1fe797",
-    "e8783644428b637adbe80bcd084a33428cb69983",
+    "5a713a91fd471fd331bd13b0868c994aa2ffe2b2",
     "fc0c32afb719295f28bcfef22803bef94f798e20",
     "36f6db4fbe2a1630a7597d3a446f2902755c96ef",
     "d3f08946300e1700865042aed121870e292d1095",
@@ -420,7 +420,7 @@ static const char *sha1_graphics_r6g6b6[] =
     "47499ad13b719de18c59c2bc9b38ed578db50b95",
     "643e82ac67ab2b0c034a3fcfa498b072a5f2be5c",
     "cd01f2c0a63b2229d4467d2f874d58edca32b3d4",
-    "94b54f1da5212b3f3a1195eda5ea927e160bc89d",
+    "8ad5cd520cd628b76d2e5a3f318ae1bbb6b4c994",
     "49341c297a887186bd47d7465d827ab3147f05e3",
     "325279e76367200d3fd7194d81c09fd139988ece",
     "c3def160a1e847605ff0fc7edd30397fa90635a0",
@@ -493,7 +493,7 @@ static const char *sha1_graphics_24[] =
     "80086808fca03e757d812e31d1ae576bf90dac9d",
     "9560096f1b85ae6d939d736165c44df00a47c424",
     "1015e0217ea13eaa62c7666b8b81aafd75f8f610",
-    "93e1aec608e037af3bfb7bd32dde446abe4eea11",
+    "5578c80048520732557abf3a3a3fa22c85015d7d",
     "b25ba91487ec945410deb2b51bc1156890c032a8",
     "d347ca5c6c4b6a61389247c3b6f61564033e8c25",
     "ee315634ed92da3a32c2675ecd1b369471c60936",
@@ -569,7 +569,7 @@ static const char *sha1_graphics_r5g5b5[] =
     "059db9f0426b371e464ef3d30f1a4f4aa599e101",
     "a52d6ceee5c2a04b4e059c0d49337a997cc17e40",
     "aa4a0a4b7f2697aaf270c89874631974bd9d7183",
-    "585061e403d9cac1603a38af420efe87338f381a",
+    "a7506e2c001d271593297c9eda9b984d4d894774",
     "8f447a3820c83662086dfa836da2205b0130fd5f",
     "3772003c7fb420003512d0c437b3659d96d89ce4",
     "dab47c9dc149e570045d699598b14a613bf319b3",
@@ -642,7 +642,7 @@ static const char *sha1_graphics_r4g4b4[] =
     "8c40d6d8e0c696c31f04c896e492a2a38703d870",
     "e13c821c236ea0b67cca64c9da7be15e88fc712f",
     "9af4907a8144458a73dbb7471784f8c3d9aeffcf",
-    "e4731b63d41f6b51e30752ea52d85c4a2938731b",
+    "104e85bad287a62dfe25f0e78280179f18bac765",
     "f0acb3cfcda62e95bee5f7bc8830ffeb3dd7e5a7",
     "07b10c3f191d0a93e5e5694aae37dcad407e10f5",
     "f7900e60347029876ba55e8f0c4c02e89deb36b6",
@@ -720,7 +720,7 @@ static const char *sha1_graphics_8_color[] =
     "46f772c2832b3aad584674db666bd63e48b4f338",
     "a9f9ca0049235db51ab7359a5fc3d21be42d2aac",
     "f3dc739da41fb299637c8660e8c46917ddcf87a8",
-    "eae47bf865d932f22a6e59b6fe8d041f220e1fbc",
+    "abd2fff80f74b311072ecdb91ce9ceba268fa6e9",
     "9ae38bb94c7b4c0c6dfebbee23d1de4db9b77488",
     "678979a45126a76eb629992cd64734862f53a555",
     "2f7ba8803604c032cb1a1228bc021f0f1c03e245",
@@ -802,7 +802,7 @@ static const char *sha1_graphics_8_grayscale[] =
     "640a49455acabca6954a7fbb6af4e872af342d11",
     "589e7911e09332ee090371deae17b0120ff990b5",
     "a1a941fa270cda48c648553ed4b427e16e96f8e0",
-    "f30a8d9f73ca043c5bfc18d9595e299fc0a39eec",
+    "115c90df05b1ff754dbdfe2a712ef126034d952d",
     "fb63bbb2f944fb63ed2d7399f07b168740c1034b",
     "3685c9ae95118a83db3569832c29753276fa1264",
     "09640bad951c33e7d70a1fced83b1869f65b3fc5",
@@ -879,7 +879,7 @@ static const char *sha1_graphics_8[] =
     "9e996fc74eeef53f0a6c31aabb2edce6e103f189",
     "6b8abd1785304d6531c1e4cc65c1ffcdcb2196a5",
     "7d1bfff706b0713e53209407889f83a0da26a81d",
-    "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2",
+    "5a1d8f9ea978b820edbc5c9e1c6f1cac022620ad",
     "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2",
     "465d9cd0a77ab4fcf035aa67544b2a26269e0b09",
     "600d6b2713d5e4c0d90c02660245ed26c7ae3033",
@@ -951,7 +951,7 @@ static const char *sha1_graphics_4[] =
     "7811c536a6527112b438a6413f3927f2c79086a7",
     "525ef3615040225752a2fe646ab99ee64e360630",
     "46760975993f9881b7bbe94123173e6a683d3f25",
-    "df5feb905a31c288008cf5e82d73ac818a160d82",
+    "c644f460937107214a88d5eb9e846d27abd8c874",
     "df5feb905a31c288008cf5e82d73ac818a160d82",
     "d8af3868c66c7d6dac35ec8ee0317b38a6910bb1",
     "ec8e2aebfb4a1c28ebcd0e053b9e4d8638b50951",
@@ -1023,7 +1023,7 @@ static const char *sha1_graphics_4_grayscale[] =
     "2f3fb1bd8f416198d70e06f6d519571cd5eb4ef4",
     "cc96ccaf6b99f60a49b03017515f83cba22b4c40",
     "5eeb56afea8040a8fb18c11f29931b836474126d",
-    "a3405c085fc2f2184bcd0d1edcdcc66927e33659",
+    "30c256a783c4874261667bb31307eb282ab9470e",
     "f8681c09f1abfc38d31e47622cb8798cd896a00e",
     "b5ee51cfc73acb59a2f6124509ea236f8fc7f9f7",
     "d374d4d92c940ae42a9b42c14d744341b68a8c14",
@@ -1113,7 +1113,7 @@ static const char *sha1_graphics_1[] =
     "ee22f43ea867228c6ff937d39e1826e285a107e8",
     "832c3c3afd056e5d1cdfb2f466f27225c4adcc6c",
     "a2a928de9007d765da496abec8c21b23601f8c45",
-    "28ded40e72d4327b9413571476b167fb28a1f420",
+    "41a417c1f25f2619301afa44bfcde85198985792",
     "23366004515f3bc46796ea505d748f8d0f97fbe1",
     "88763f8e8fcf4f78fa864325791a9dd35a0bd279",
     "013cee26bac8f815eadad4bfc012d9b5d01c3b7f",
@@ -1187,7 +1187,7 @@ static const RECT graphics_bounds[] =
     { 100, 100, 356, 356 },
     { 100, 100, 356, 356 },
     { 100, 100, 356, 356 },
-    { 100, 100, 356, 356 },
+    { 10, 10, 356, 356 },
     { 100, 100, 356, 356 },
     { 10, 10, 416, 26 },
     { 10, 8, 60, 104 },
@@ -2398,6 +2398,12 @@ static void draw_graphics(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
             src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y;
 
     BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
+    /* Some interesting src co-ords */
+    BitBlt( hdc, 10, 10, 3, 10, src_dc, 0, 0, SRCCOPY );
+    BitBlt( hdc, 20, 10, 3, 10, src_dc, 2, 0, SRCCOPY );
+    BitBlt( hdc, 30, 10, 3, 10, src_dc, 5, 0, SRCCOPY );
+    BitBlt( hdc, 40, 10, 3, 10, src_dc, 6, 0, SRCCOPY );
+    BitBlt( hdc, 50, 10, 20, 10, src_dc, 6, 0, SRCCOPY );
     compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp SRCCOPY" );
 
     blend.SourceConstantAlpha = 0x90;
-- 
2.7.4




More information about the wine-patches mailing list