Jacek Caban : gdi32/test: Add tests for recording MaskBlt and PlgBlt in EMFs.

Alexandre Julliard julliard at winehq.org
Fri Sep 10 15:29:45 CDT 2021


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Sep 10 14:27:20 2021 +0200

gdi32/test: Add tests for recording MaskBlt and PlgBlt in EMFs.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/tests/metafile.c | 185 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 185 insertions(+)

diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c
index 693353ea5f2..1040408725a 100644
--- a/dlls/gdi32/tests/metafile.c
+++ b/dlls/gdi32/tests/metafile.c
@@ -1763,6 +1763,117 @@ static const unsigned char mf_palette_brush_bits[] =
     0x00, 0x00, 0x00, 0x00
 };
 
+static const unsigned char emf_mask_blit_bits[] =
+{
+    0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x35, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+    0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
+    0x58, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x77, 0x07, 0x00, 0x00, 0x3b, 0x04, 0x00, 0x00,
+    0xfa, 0x01, 0x00, 0x00, 0x1f, 0x01, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x12, 0xb7, 0x07, 0x00,
+    0x4f, 0x5f, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00,
+    0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0xcc, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x80, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0xa8, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00,
+    0x28, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00,
+    0x0c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d,
+    0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
+    0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+    0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+    0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
+    0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xf0, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00,
+    0xf0, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00,
+    0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0xcc, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x80, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0xa8, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d,
+    0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
+    0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+    0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+    0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
+    0x4f, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x8c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0xb4, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00,
+    0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+    0x0c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+    0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d,
+    0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
+    0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+    0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+    0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
+    0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+    0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xf0, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00,
+    0xf0, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+    0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00
+};
+
 /* For debugging or dumping the raw metafiles produced by
  * new test functions.
  */
@@ -2036,6 +2147,13 @@ static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr
         if(!diff)
             diff = memcmp(eto1->aptl, eto2->aptl, eto1->cptl * sizeof(POINTL));
     }
+    else if (emr1->iType == EMR_PLGBLT && emr2->iType == EMR_PLGBLT)
+    {
+        EMRPLGBLT *eto1 = (EMRPLGBLT *)emr1;
+        EMRPLGBLT *eto2 = (EMRPLGBLT *)emr2;
+        diff = memcmp(emr1, emr2, sizeof(*emr1)) ||
+            memcmp(&eto1->aptlDest, &eto2->aptlDest, emr1->nSize - FIELD_OFFSET(EMRPLGBLT, aptlDest));
+    }
     else
         diff = memcmp(emr1, emr2, emr1->nSize);
 
@@ -4810,6 +4928,72 @@ static void test_emf_blit(void)
     ok(ret, "DeleteMetaFile(%p) error %d\n", hmf, GetLastError());
 }
 
+static void test_emf_mask_blit(void)
+{
+    BITMAPINFO bmi = {{ sizeof(bmi) }};
+    HBITMAP bitmap, mask_bitmap;
+    HENHMETAFILE emf;
+    HDC hdc, dib_hdc;
+    unsigned int i;
+    void *bits;
+    BOOL ret;
+
+    static const POINT plg_points[] = { { 2, 1 }, { 1, 1 }, { 1, 2 } };
+
+    hdc = CreateEnhMetaFileA(NULL, NULL, NULL, NULL);
+    ok(hdc != 0, "CreateMetaFileA failed\n");
+
+    dib_hdc = CreateCompatibleDC(NULL);
+    ok(!!dib_hdc, "CreateCompatibleDC failed\n");
+
+    bmi.bmiHeader.biHeight = 3;
+    bmi.bmiHeader.biWidth = 4;
+    bmi.bmiHeader.biBitCount = 24;
+    bmi.bmiHeader.biPlanes = 1;
+    bmi.bmiHeader.biCompression = BI_RGB;
+    bitmap = CreateDIBSection(dib_hdc, &bmi, DIB_RGB_COLORS, &bits, NULL, 0);
+    ok(!!bitmap, "CreateDIBSection failed, error %d\n", GetLastError());
+    for (i = 0; i < bmi.bmiHeader.biHeight * bmi.bmiHeader.biWidth * 3; i++)
+        ((BYTE *)bits)[i] = i + 10;
+
+    bmi.bmiHeader.biHeight = 3;
+    bmi.bmiHeader.biWidth = 4;
+    bmi.bmiHeader.biBitCount = 1;
+    bmi.bmiHeader.biPlanes = 1;
+    bmi.bmiHeader.biCompression = BI_RGB;
+    mask_bitmap = CreateDIBSection(dib_hdc, &bmi, DIB_RGB_COLORS, &bits, NULL, 0);
+    ok(!!mask_bitmap, "CreateDIBSection failed, error %d\n", GetLastError());
+    memset(bits, ~0, bmi.bmiHeader.biHeight * 4);
+
+    SelectObject(dib_hdc, bitmap);
+
+    ret = MaskBlt(hdc, 0, 0, 3, 4, dib_hdc, 0, 0, mask_bitmap, 0, 0, SRCCOPY);
+    ok(ret, "MaskBlt failed\n");
+
+    ret = MaskBlt(hdc, 0, 0, 3, 4, dib_hdc, 0, 0, NULL, 0, 0, SRCCOPY);
+    ok(ret, "MaskBlt failed\n");
+
+    ret = PlgBlt(hdc, plg_points, dib_hdc, 0, 0, 3, 4, mask_bitmap, 0, 0);
+    ok(ret, "PlgBlt failed\n");
+
+    DeleteDC(dib_hdc);
+    DeleteObject(bitmap);
+    DeleteObject(mask_bitmap);
+
+    emf = CloseEnhMetaFile(hdc);
+    ok(emf != 0, "CloseMetaFile failed\n");
+
+    if (compare_emf_bits(emf, emf_mask_blit_bits, sizeof(emf_mask_blit_bits),
+                         "emf_mask_blit", FALSE) != 0)
+    {
+        dump_emf_bits(emf, "emf_mask_blit");
+        dump_emf_records(emf, "emf_mask_blit");
+    }
+
+    ret = DeleteEnhMetaFile(emf);
+    ok(ret, "DeleteMetaFile(%p) error %d\n", emf, GetLastError());
+}
+
 static void test_mf_ExtTextOut_on_path(void)
 {
     HDC hdcMetafile;
@@ -7621,6 +7805,7 @@ START_TEST(metafile)
     test_emf_select();
     test_emf_blit();
     test_emf_pattern_brush();
+    test_emf_mask_blit();
 
     /* For win-format metafiles (mfdrv) */
     test_mf_SaveDC();




More information about the wine-cvs mailing list