[PATCH v2 0/2] MR9722: windowscodecs: Support trivial cases for copying 1bpp indexed data.
-- v2: windowscodecs: Remove optimization for 1bpp pixel formats from WICConvertBitmapSource(). windowscodecs: Support trivial cases for copying 1bpp indexed data. https://gitlab.winehq.org/wine/wine/-/merge_requests/9722
From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/windowscodecs/converter.c | 18 +++++++++++++++++- dlls/windowscodecs/tests/converter.c | 8 +++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index d6be5920ea2..cc31447ec47 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -1773,6 +1773,22 @@ static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WIC return hr; } +static HRESULT copypixels_to_1bppIndexed(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + switch (source_format) + { + case format_1bppIndexed: + case format_BlackWhite: + if (prc) + return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + return S_OK; + default: + FIXME("Unimplemented conversion path! %d\n", source_format); + return WINCODEC_ERR_UNSUPPORTEDOPERATION; + } +} + static HRESULT copypixels_to_16bppBGRA5551(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) { @@ -2189,7 +2205,7 @@ static HRESULT copypixels_to_128bppRGBFloat(struct FormatConverter *This, const } static const struct pixelformatinfo supported_formats[] = { - {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL, TRUE}, + {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, copypixels_to_1bppIndexed, TRUE}, {format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL, TRUE}, {format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL, TRUE}, {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, copypixels_to_8bppIndexed, TRUE}, diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index bce0cbb189b..4f15dfbfb17 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -363,6 +363,7 @@ static void compare_bitmap_data(const struct bitmap_data *src, const struct bitm hr = IWICBitmapSource_GetPixelFormat(source, &dst_pixelformat); ok(SUCCEEDED(hr), "GetPixelFormat(%s) failed, hr=%lx\n", name, hr); + todo_wine_if(IsEqualGUID(&dst_pixelformat, &GUID_WICPixelFormatBlackWhite) && IsEqualGUID(expect->format, &GUID_WICPixelFormat1bppIndexed)) ok(IsEqualGUID(&dst_pixelformat, expect->format), "got unexpected pixel format %s (%s)\n", wine_dbgstr_guid(&dst_pixelformat), name); prc.X = 0; @@ -830,7 +831,7 @@ static void test_can_convert(void) td[] = { {WIC_PIXEL_FORMAT(Undefined)}, - {WIC_PIXEL_FORMAT(1bppIndexed), TRUE, TRUE, 35}, + {WIC_PIXEL_FORMAT(1bppIndexed), TRUE, TRUE, 33}, {WIC_PIXEL_FORMAT(2bppIndexed), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(4bppIndexed), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(8bppIndexed), TRUE, TRUE, 26}, @@ -2176,7 +2177,7 @@ static void test_converter_8bppIndexed(void) hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, &GUID_WICPixelFormat1bppIndexed, WICBitmapDitherTypeNone, NULL, 0.0, WICBitmapPaletteTypeMedianCut); - todo_wine ok(hr == S_OK, "unexpected error %#lx\n", hr); + ok(hr == S_OK, "unexpected error %#lx\n", hr); IWICFormatConverter_Release(converter); hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); @@ -2184,7 +2185,7 @@ static void test_converter_8bppIndexed(void) hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, &GUID_WICPixelFormat1bppIndexed, WICBitmapDitherTypeNone, NULL, 0.0, WICBitmapPaletteTypeFixedBW); - todo_wine ok(hr == S_OK, "unexpected error %#lx\n", hr); + ok(hr == S_OK, "unexpected error %#lx\n", hr); IWICFormatConverter_Release(converter); hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); @@ -2323,6 +2324,7 @@ START_TEST(converter) test_conversion(&testdata_24bppRGB, &testdata_4bppIndexed, "24bppRGB -> 4bppIndexed", TRUE); test_conversion(&testdata_24bppRGB, &testdata_8bppIndexed, "24bppRGB -> 8bppIndexed", FALSE); + test_conversion(&testdata_BlackWhite, &testdata_1bppIndexed, "BlackWhite -> 1bppIndexed", FALSE); test_conversion(&testdata_BlackWhite, &testdata_8bppIndexed_BW, "BlackWhite -> 8bppIndexed", FALSE); test_conversion(&testdata_BlackWhite, &testdata_24bppBGR_BW, "BlackWhite -> 24bppBGR", FALSE); test_conversion(&testdata_1bppIndexed, &testdata_8bppIndexed_BW, "1bppIndexed -> 8bppIndexed", TRUE); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9722
From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/windowscodecs/info.c | 8 +------- dlls/windowscodecs/tests/converter.c | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c index e210b5d81d9..4063196e27c 100644 --- a/dlls/windowscodecs/info.c +++ b/dlls/windowscodecs/info.c @@ -2652,12 +2652,6 @@ HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnkn return hr; } -static BOOL is_1bpp_format(const WICPixelFormatGUID *format) -{ - return IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite) || - IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed); -} - HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst) { HRESULT res; @@ -2675,7 +2669,7 @@ HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitma res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat); if (FAILED(res)) return res; - if (IsEqualGUID(&srcFormat, dstFormat) || (is_1bpp_format(&srcFormat) && is_1bpp_format(dstFormat))) + if (IsEqualGUID(&srcFormat, dstFormat)) { IWICBitmapSource_AddRef(pISrc); *ppIDst = pISrc; diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 4f15dfbfb17..a6cfdbc5148 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -363,7 +363,6 @@ static void compare_bitmap_data(const struct bitmap_data *src, const struct bitm hr = IWICBitmapSource_GetPixelFormat(source, &dst_pixelformat); ok(SUCCEEDED(hr), "GetPixelFormat(%s) failed, hr=%lx\n", name, hr); - todo_wine_if(IsEqualGUID(&dst_pixelformat, &GUID_WICPixelFormatBlackWhite) && IsEqualGUID(expect->format, &GUID_WICPixelFormat1bppIndexed)) ok(IsEqualGUID(&dst_pixelformat, expect->format), "got unexpected pixel format %s (%s)\n", wine_dbgstr_guid(&dst_pixelformat), name); prc.X = 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9722
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9722
participants (3)
-
Dmitry Timoshkov -
Dmitry Timoshkov (@dmitry) -
Esme Povirk (@madewokherd)