[WINDOWSCODECS_WINETEST] Sync with Wine Staging 3.9. CORE-14656
authorAmine Khaldi <amine.khaldi@reactos.org>
Mon, 4 Jun 2018 02:56:11 +0000 (03:56 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Mon, 4 Jun 2018 02:56:11 +0000 (03:56 +0100)
modules/rostests/winetests/windowscodecs/bitmap.c
modules/rostests/winetests/windowscodecs/bmpformat.c
modules/rostests/winetests/windowscodecs/gifformat.c
modules/rostests/winetests/windowscodecs/info.c

index 42f452a..6e01f0b 100644 (file)
@@ -972,6 +972,64 @@ static void test_clipper(void)
     IWICBitmapClipper_Release(clipper);
 }
 
     IWICBitmapClipper_Release(clipper);
 }
 
+static HRESULT (WINAPI *pWICCreateBitmapFromSectionEx)
+    (UINT, UINT, REFWICPixelFormatGUID, HANDLE, UINT, UINT, WICSectionAccessLevel, IWICBitmap **);
+
+static void test_WICCreateBitmapFromSectionEx(void)
+{
+    SYSTEM_INFO sysinfo;
+    HANDLE hsection;
+    BITMAPINFO info;
+    void *bits;
+    HBITMAP hdib;
+    IWICBitmap *bitmap;
+    HRESULT hr;
+    pWICCreateBitmapFromSectionEx =
+        (void *)GetProcAddress(LoadLibraryA("windowscodecs"), "WICCreateBitmapFromSectionEx");
+
+    if (!pWICCreateBitmapFromSectionEx)
+    {
+        win_skip("WICCreateBitmapFromSectionEx not available\n");
+        return;
+    }
+
+    GetSystemInfo(&sysinfo);
+    hsection = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
+                                  sysinfo.dwAllocationGranularity * 2, NULL);
+    ok(hsection != NULL, "CreateFileMapping failed %u\n", GetLastError());
+
+    memset(&info, 0, sizeof(info));
+    info.bmiHeader.biSize        = sizeof(info.bmiHeader);
+    info.bmiHeader.biWidth       = 3;
+    info.bmiHeader.biHeight      = -3;
+    info.bmiHeader.biBitCount    = 24;
+    info.bmiHeader.biPlanes      = 1;
+    info.bmiHeader.biCompression = BI_RGB;
+
+    hdib = CreateDIBSection(0, &info, DIB_RGB_COLORS, &bits, hsection, 0);
+    ok(hdib != NULL, "CreateDIBSection failed\n");
+
+    hr = pWICCreateBitmapFromSectionEx(3, 3, &GUID_WICPixelFormat24bppBGR, hsection, 0, 0,
+                                       WICSectionAccessLevelReadWrite, &bitmap);
+    ok(hr == S_OK, "WICCreateBitmapFromSectionEx returned %#x\n", hr);
+    IWICBitmap_Release(bitmap);
+
+    /* non-zero offset, smaller than allocation granularity */
+    hr = pWICCreateBitmapFromSectionEx(3, 3, &GUID_WICPixelFormat24bppBGR, hsection, 0, 0x100,
+                                       WICSectionAccessLevelReadWrite, &bitmap);
+    ok(hr == S_OK, "WICCreateBitmapFromSectionEx returned %#x\n", hr);
+    IWICBitmap_Release(bitmap);
+
+    /* offset larger than allocation granularity */
+    hr = pWICCreateBitmapFromSectionEx(3, 3, &GUID_WICPixelFormat24bppBGR, hsection, 0,
+                                       sysinfo.dwAllocationGranularity + 1,
+                                       WICSectionAccessLevelReadWrite, &bitmap);
+    ok(hr == S_OK, "WICCreateBitmapFromSectionEx returned %#x\n", hr);
+    IWICBitmap_Release(bitmap);
+    DeleteObject(hdib);
+    CloseHandle(hsection);
+}
+
 START_TEST(bitmap)
 {
     HRESULT hr;
 START_TEST(bitmap)
 {
     HRESULT hr;
@@ -992,4 +1050,6 @@ START_TEST(bitmap)
     IWICImagingFactory_Release(factory);
 
     CoUninitialize();
     IWICImagingFactory_Release(factory);
 
     CoUninitialize();
+
+    test_WICCreateBitmapFromSectionEx();
 }
 }
index 48985b9..8bac7a3 100644 (file)
@@ -1058,80 +1058,6 @@ static void test_createfromstream(void)
     IWICImagingFactory_Release(factory);
 }
 
     IWICImagingFactory_Release(factory);
 }
 
-/* 1x1 pixel gif, missing trailer */
-static unsigned char gifimage_notrailer[] = {
-0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff,
-0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
-0x01,0x00
-};
-
-static void test_gif_notrailer(void)
-{
-    IWICBitmapDecoder *decoder;
-    IWICImagingFactory *factory;
-    HRESULT hr;
-    IWICStream *gifstream;
-    IWICBitmapFrameDecode *framedecode;
-    double dpiX = 0.0, dpiY = 0.0;
-    UINT framecount;
-
-    hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
-        &IID_IWICImagingFactory, (void**)&factory);
-    ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
-    if (FAILED(hr)) return;
-
-    hr = IWICImagingFactory_CreateStream(factory, &gifstream);
-    ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
-    if (SUCCEEDED(hr))
-    {
-        hr = IWICStream_InitializeFromMemory(gifstream, gifimage_notrailer,
-            sizeof(gifimage_notrailer));
-        ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
-
-        if (SUCCEEDED(hr))
-        {
-            hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER,
-                &IID_IWICBitmapDecoder, (void**)&decoder);
-            ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
-        }
-
-        if (SUCCEEDED(hr))
-        {
-            hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)gifstream,
-                WICDecodeMetadataCacheOnDemand);
-            ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
-
-            if (SUCCEEDED(hr))
-            {
-                hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
-                ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
-                if (SUCCEEDED(hr))
-                {
-                    hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
-                    ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
-                    ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX);
-                    ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
-
-                    IWICBitmapFrameDecode_Release(framedecode);
-                }
-            }
-
-            if (SUCCEEDED(hr))
-            {
-                hr = IWICBitmapDecoder_GetFrameCount(decoder, &framecount);
-                ok(hr == S_OK, "GetFrameCount failed, hr=%x\n", hr);
-                ok(framecount == 1, "framecount=%u\n", framecount);
-            }
-
-            IWICBitmapDecoder_Release(decoder);
-        }
-
-        IWICStream_Release(gifstream);
-    }
-
-    IWICImagingFactory_Release(factory);
-}
-
 static void test_create_decoder(void)
 {
     IWICBitmapDecoder *decoder;
 static void test_create_decoder(void)
 {
     IWICBitmapDecoder *decoder;
@@ -1170,7 +1096,6 @@ START_TEST(bmpformat)
     test_decode_rle4();
     test_componentinfo();
     test_createfromstream();
     test_decode_rle4();
     test_componentinfo();
     test_createfromstream();
-    test_gif_notrailer();
     test_create_decoder();
 
     CoUninitialize();
     test_create_decoder();
 
     CoUninitialize();
index 53b4e47..05affad 100644 (file)
@@ -490,6 +490,80 @@ static void test_truncated_gif(void)
     IStream_Release(stream);
 }
 
     IStream_Release(stream);
 }
 
+/* 1x1 pixel gif, missing trailer */
+static unsigned char gifimage_notrailer[] = {
+0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff,
+0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
+0x01,0x00
+};
+
+static void test_gif_notrailer(void)
+{
+    IWICBitmapDecoder *decoder;
+    IWICImagingFactory *factory;
+    HRESULT hr;
+    IWICStream *gifstream;
+    IWICBitmapFrameDecode *framedecode;
+    double dpiX = 0.0, dpiY = 0.0;
+    UINT framecount;
+
+    hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+        &IID_IWICImagingFactory, (void**)&factory);
+    ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
+    if (FAILED(hr)) return;
+
+    hr = IWICImagingFactory_CreateStream(factory, &gifstream);
+    ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
+    if (SUCCEEDED(hr))
+    {
+        hr = IWICStream_InitializeFromMemory(gifstream, gifimage_notrailer,
+            sizeof(gifimage_notrailer));
+        ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
+
+        if (SUCCEEDED(hr))
+        {
+            hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER,
+                &IID_IWICBitmapDecoder, (void**)&decoder);
+            ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
+        }
+
+        if (SUCCEEDED(hr))
+        {
+            hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)gifstream,
+                WICDecodeMetadataCacheOnDemand);
+            ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
+
+            if (SUCCEEDED(hr))
+            {
+                hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
+                ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
+                if (SUCCEEDED(hr))
+                {
+                    hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
+                    ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
+                    ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX);
+                    ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
+
+                    IWICBitmapFrameDecode_Release(framedecode);
+                }
+            }
+
+            if (SUCCEEDED(hr))
+            {
+                hr = IWICBitmapDecoder_GetFrameCount(decoder, &framecount);
+                ok(hr == S_OK, "GetFrameCount failed, hr=%x\n", hr);
+                ok(framecount == 1, "framecount=%u\n", framecount);
+            }
+
+            IWICBitmapDecoder_Release(decoder);
+        }
+
+        IWICStream_Release(gifstream);
+    }
+
+    IWICImagingFactory_Release(factory);
+}
+
 START_TEST(gifformat)
 {
     HRESULT hr;
 START_TEST(gifformat)
 {
     HRESULT hr;
@@ -504,6 +578,7 @@ START_TEST(gifformat)
     test_global_gif_palette_2frames();
     test_local_gif_palette();
     test_gif_frame_sizes();
     test_global_gif_palette_2frames();
     test_local_gif_palette();
     test_gif_frame_sizes();
+    test_gif_notrailer();
 
     IWICImagingFactory_Release(factory);
     CoUninitialize();
 
     IWICImagingFactory_Release(factory);
     CoUninitialize();
index 4a9c9c6..d00e9d8 100644 (file)
@@ -139,7 +139,6 @@ static void test_decoder_info(void)
             decoder_info2 = NULL;
             hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info2);
             ok(hr == S_OK, "Failed to get decoder info, hr %#x.\n", hr);
             decoder_info2 = NULL;
             hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info2);
             ok(hr == S_OK, "Failed to get decoder info, hr %#x.\n", hr);
-        todo_wine
             ok(decoder_info == decoder_info2, "Unexpected decoder info instance.\n");
 
             hr = IWICBitmapDecoderInfo_QueryInterface(decoder_info, &IID_IWICBitmapDecoder, (void **)&decoder2);
             ok(decoder_info == decoder_info2, "Unexpected decoder info instance.\n");
 
             hr = IWICBitmapDecoderInfo_QueryInterface(decoder_info, &IID_IWICBitmapDecoder, (void **)&decoder2);
@@ -470,17 +469,38 @@ static void test_pixelformat_info(void)
     IWICComponentInfo_Release(info);
 }
 
     IWICComponentInfo_Release(info);
 }
 
+static DWORD WINAPI cache_across_threads_test(void *arg)
+{
+    IWICComponentInfo *info;
+    HRESULT hr;
+
+    CoInitialize(NULL);
+
+    hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info);
+    ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
+    ok(info == arg, "unexpected info pointer %p\n", info);
+    IWICComponentInfo_Release(info);
+
+    CoUninitialize();
+    return 0;
+}
+
 static void test_reader_info(void)
 {
     IWICImagingFactory *factory;
 static void test_reader_info(void)
 {
     IWICImagingFactory *factory;
-    IWICComponentInfo *info;
+    IWICComponentInfo *info, *info2;
     IWICMetadataReaderInfo *reader_info;
     HRESULT hr;
     CLSID clsid;
     GUID container_formats[10];
     IWICMetadataReaderInfo *reader_info;
     HRESULT hr;
     CLSID clsid;
     GUID container_formats[10];
-    UINT count, size;
+    UINT count, size, tid;
+    HANDLE thread;
     WICMetadataPattern *patterns;
 
     WICMetadataPattern *patterns;
 
+    hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info2);
+    ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
+    IWICComponentInfo_Release(info2);
+
     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
         &IID_IWICImagingFactory, (void**)&factory);
     ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
         &IID_IWICImagingFactory, (void**)&factory);
     ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
@@ -488,6 +508,11 @@ static void test_reader_info(void)
 
     hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
 
     hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
+    ok(info == info2, "info != info2\n");
+
+    thread = CreateThread(NULL, 0, cache_across_threads_test, info, 0, &tid);
+    WaitForSingleObject(thread, INFINITE);
+    CloseHandle(thread);
 
     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
 
     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);