From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/d2d1/bitmap.c | 12 ++++++-- dlls/d2d1/tests/d2d1.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 1cba26f5ca4..316d0f25ad6 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -544,15 +544,23 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, goto failed; }
- if (!desc) + if (desc) + { + d = *desc; + if (d.pixelFormat.format == DXGI_FORMAT_UNKNOWN) + d.pixelFormat.format = src_impl->format.format; + if (d.pixelFormat.alphaMode == D2D1_ALPHA_MODE_UNKNOWN) + d.pixelFormat.alphaMode = src_impl->format.alphaMode; + } + else { d.pixelFormat = src_impl->format; d.dpiX = src_impl->dpi_x; d.dpiY = src_impl->dpi_y; d.bitmapOptions = src_impl->options; d.colorContext = NULL; - desc = &d; } + desc = &d;
if (!format_supported(&desc->pixelFormat)) { diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 1935955ec84..47efba66447 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -5254,6 +5254,68 @@ static void test_shared_bitmap(BOOL d3d11) } }
+ ID2D1Bitmap_Release(bitmap1); + + /* Create from another bitmap, with a different description. */ + set_size_u(&size, 4, 4); + bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; + bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; + bitmap_desc.dpiX = 96.0f; + bitmap_desc.dpiY = 96.0f; + hr = ID2D1RenderTarget_CreateBitmap(rt2, size, NULL, 0, &bitmap_desc, &bitmap1); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + if (SUCCEEDED(hr)) + { + static const struct bitmap_format_test + { + D2D1_PIXEL_FORMAT original; + D2D1_PIXEL_FORMAT result; + HRESULT hr; + } + bitmap_format_tests[] = + { + { { DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED }, + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED } }, + + { { DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_IGNORE }, + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE } }, + + { { DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_UNKNOWN }, + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED } }, + + { { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_UNKNOWN }, + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED } }, + + { { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE }, + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE } }, + + { { DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_STRAIGHT }, { 0 }, D2DERR_UNSUPPORTED_PIXEL_FORMAT }, + { { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_STRAIGHT }, { 0 }, D2DERR_UNSUPPORTED_PIXEL_FORMAT }, + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(bitmap_format_tests); ++i) + { + bitmap_desc.pixelFormat = bitmap_format_tests[i].original; + + hr = ID2D1RenderTarget_CreateSharedBitmap(rt2, &IID_ID2D1Bitmap, bitmap1, &bitmap_desc, &bitmap2); + ok(hr == bitmap_format_tests[i].hr, "%u: Got unexpected hr %#lx.\n", i, hr); + + if (SUCCEEDED(hr) && hr == bitmap_format_tests[i].hr) + { + pixel_format = ID2D1Bitmap_GetPixelFormat(bitmap2); + ok(pixel_format.format == bitmap_format_tests[i].result.format, "%u: unexpected pixel format %#x.\n", + i, pixel_format.format); + ok(pixel_format.alphaMode == bitmap_format_tests[i].result.alphaMode, "%u: unexpected alpha mode %d.\n", + i, pixel_format.alphaMode); + } + + if (SUCCEEDED(hr)) + ID2D1Bitmap_Release(bitmap2); + } + } + ID2D1RenderTarget_Release(rt2);
ID2D1Bitmap_Release(bitmap1);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126279
Your paranoid android.
=== debian11 (32 bit report) ===
d3drm: d3drm.c:4776: Test failed: Cannot create IDirect3DRMDevice2 interface, hr 0x8007000e. d3drm.c:4778: Test failed: expected ref3 > ref1, got ref1 = 1 , ref3 = 1. d3drm.c:4782: Test failed: Expected surface_ref2 > surface_ref1, got surface_ref1 = 1, surface_ref2 = 1. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00410761).
=== debian11 (build log) ===
0544:err:winediag:d3d_device_create The application wants to create a Direct3D device, but the current DirectDrawRenderer does not support this.