diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-10-31 20:22:17 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-11-27 09:55:14 +0100 |
commit | cefafdf6865251e2efcbcfb8f19af6bfd72390c3 (patch) | |
tree | db46685219ffe7aaa3f8dd6f04ec91b2e878231f /vcl/backendtest | |
parent | 014c9f953eeae7b3db39f88c90af8b436553e1c1 (diff) |
backendtest: test blending of bitmap
This forces a blending of an alpha virtualdevice with a BitmapEx
which has an alpha component. This tries a fast-path with using
blendAlphaBitmap in the backend and does blending manually and
slower if the fast-path is not available.
Change-Id: I7e45dc78ce3e61ede408aa8388802a193cbc577a
Diffstat (limited to 'vcl/backendtest')
-rw-r--r-- | vcl/backendtest/outputdevice/bitmap.cxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vcl/backendtest/outputdevice/bitmap.cxx b/vcl/backendtest/outputdevice/bitmap.cxx index dbbb052c122e..58b7c5f03ff0 100644 --- a/vcl/backendtest/outputdevice/bitmap.cxx +++ b/vcl/backendtest/outputdevice/bitmap.cxx @@ -112,6 +112,39 @@ Bitmap OutputDeviceTestBitmap::setupDrawMask() return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); } +BitmapEx OutputDeviceTestBitmap::setupDrawBlend() +{ + Size aBitmapSize(9, 9); + Bitmap aBitmap(aBitmapSize, 24); + { + BitmapScopedWriteAccess aWriteAccess(aBitmap); + aWriteAccess->Erase(COL_WHITE); + aWriteAccess->SetLineColor(Color(0xFF, 0xFF, 0x00)); + aWriteAccess->DrawRect(tools::Rectangle(0, 0, 8, 8)); + aWriteAccess->DrawRect(tools::Rectangle(3, 3, 5, 5)); + } + + AlphaMask aAlpha(aBitmapSize); + { + AlphaScopedWriteAccess aWriteAccess(aAlpha); + aWriteAccess->Erase(COL_WHITE); + aWriteAccess->SetLineColor(Color(0x44, 0x44, 0x44)); + aWriteAccess->DrawRect(tools::Rectangle(0, 0, 8, 8)); + aWriteAccess->DrawRect(tools::Rectangle(3, 3, 5, 5)); + } + + initialSetup(13, 13, constBackgroundColor, false, true); + mpVirtualDevice->SetFillColor(constBackgroundColor); + mpVirtualDevice->SetLineColor(constBackgroundColor); + mpVirtualDevice->DrawRect(maVDRectangle); + + Point aPoint(alignToCenter(maVDRectangle, tools::Rectangle(Point(), aBitmapSize)).TopLeft()); + + mpVirtualDevice->DrawBitmapEx(aPoint, BitmapEx(aBitmap, aAlpha)); + + return mpVirtualDevice->GetBitmapEx(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap) { std::vector<Color> aExpected @@ -140,6 +173,20 @@ TestResult OutputDeviceTestBitmap::checkMask(Bitmap& rBitmap) return checkRectangle(rBitmap); } +TestResult OutputDeviceTestBitmap::checkBlend(BitmapEx& rBitmapEx) +{ + const Color aBlendedColor(0xEE, 0xEE, 0x33); + + std::vector<Color> aExpected + { + constBackgroundColor, constBackgroundColor, + aBlendedColor, constBackgroundColor, constBackgroundColor, + aBlendedColor, constBackgroundColor + }; + Bitmap aBitmap(rBitmapEx.GetBitmap()); + return checkRectangles(aBitmap, aExpected); +} + }} // end namespace vcl::test /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |