Module: wine Branch: master Commit: ccc347038bd38d793536ca3c080f9198372c7e6f URL: http://source.winehq.org/git/wine.git/?a=commit;h=ccc347038bd38d793536ca3c08...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Jul 23 19:32:05 2015 +0200
d2d1: Also infer the alpha mode in d2d_d3d_render_target_CreateBitmapFromWicBitmap().
---
dlls/d2d1/render_target.c | 48 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index e939fef..1c641e7 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -300,14 +300,28 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateBitmap(ID2D1RenderT static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateBitmapFromWicBitmap(ID2D1RenderTarget *iface, IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap) { + const D2D1_PIXEL_FORMAT *d2d_format; D2D1_BITMAP_PROPERTIES bitmap_desc; + WICPixelFormatGUID wic_format; unsigned int bpp, data_size; D2D1_SIZE_U size; + unsigned int i; WICRect rect; UINT32 pitch; HRESULT hr; void *data;
+ static const struct + { + const WICPixelFormatGUID *wic; + D2D1_PIXEL_FORMAT d2d; + } + format_lookup[] = + { + {&GUID_WICPixelFormat32bppPBGRA, {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED}}, + {&GUID_WICPixelFormat32bppBGR, {DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE}}, + }; + TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n", iface, bitmap_source, desc, bitmap);
@@ -329,28 +343,32 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateBitmapFromWicBitmap bitmap_desc = *desc; }
- if (bitmap_desc.pixelFormat.format == DXGI_FORMAT_UNKNOWN) + if (FAILED(hr = IWICBitmapSource_GetPixelFormat(bitmap_source, &wic_format))) { - WICPixelFormatGUID wic_format; + WARN("Failed to get bitmap format, hr %#x.\n", hr); + return hr; + }
- if (FAILED(hr = IWICBitmapSource_GetPixelFormat(bitmap_source, &wic_format))) + for (i = 0, d2d_format = NULL; i < sizeof(format_lookup) / sizeof(*format_lookup); ++i) + { + if (IsEqualGUID(&wic_format, format_lookup[i].wic)) { - WARN("Failed to get bitmap format, hr %#x.\n", hr); - return hr; + d2d_format = &format_lookup[i].d2d; + break; } + }
- if (IsEqualGUID(&wic_format, &GUID_WICPixelFormat32bppPBGRA) - || IsEqualGUID(&wic_format, &GUID_WICPixelFormat32bppBGR)) - { - bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; - } - else - { - WARN("Unsupported WIC bitmap format %s.\n", debugstr_guid(&wic_format)); - return D2DERR_UNSUPPORTED_PIXEL_FORMAT; - } + if (!d2d_format) + { + WARN("Unsupported WIC bitmap format %s.\n", debugstr_guid(&wic_format)); + return D2DERR_UNSUPPORTED_PIXEL_FORMAT; }
+ if (bitmap_desc.pixelFormat.format == DXGI_FORMAT_UNKNOWN) + bitmap_desc.pixelFormat.format = d2d_format->format; + if (bitmap_desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_UNKNOWN) + bitmap_desc.pixelFormat.alphaMode = d2d_format->alphaMode; + switch (bitmap_desc.pixelFormat.format) { case DXGI_FORMAT_B8G8R8A8_UNORM: