diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-11-08 14:45:52 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-11-16 11:10:27 +0100 |
commit | 383ddecb47a29e785dd88c765455696ca72bbe0f (patch) | |
tree | 2f5707b63a9a946c48d7215e8deeb73d21c3fdf5 | |
parent | 1b5a847230ebb96e0936d9a6baa5c3a35148c0d5 (diff) |
backend bitmap test for 32-bit bitmapfeature/nativealpha
Change-Id: I64223910cef1a44d616faa1f0a8982acc4344657
-rw-r--r-- | vcl/backendtest/VisualBackendTest.cxx | 11 | ||||
-rw-r--r-- | vcl/backendtest/outputdevice/bitmap.cxx | 23 | ||||
-rw-r--r-- | vcl/inc/test/outputdevice.hxx | 2 |
3 files changed, 33 insertions, 3 deletions
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx index ced23d971f7d..fb617f8c83e4 100644 --- a/vcl/backendtest/VisualBackendTest.cxx +++ b/vcl/backendtest/VisualBackendTest.cxx @@ -343,7 +343,7 @@ public: Rectangle aRectangle; size_t index = 0; - std::vector<Rectangle> aRegions = setupRegions(2, 2, nWidth, nHeight); + std::vector<Rectangle> aRegions = setupRegions(2, 3, nWidth, nHeight); aRectangle = aRegions[index++]; { @@ -363,7 +363,7 @@ public: { vcl::test::OutputDeviceTestBitmap aOutDevTest; Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(); - assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap), aRectangle, rRenderContext); + assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkAlphaBitmap(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } aRectangle = aRegions[index++]; @@ -373,6 +373,13 @@ public: assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap), aRectangle, rRenderContext); drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); } + aRectangle = aRegions[index++]; + { + vcl::test::OutputDeviceTestBitmap aOutDevTest; + Bitmap aBitmap = aOutDevTest.setupDrawNativeBitmapWithAlpha(); + assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkAlphaBitmap(aBitmap), aRectangle, rRenderContext); + drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext); + } } virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/) override diff --git a/vcl/backendtest/outputdevice/bitmap.cxx b/vcl/backendtest/outputdevice/bitmap.cxx index 351dfa2eb802..fc7f0223a766 100644 --- a/vcl/backendtest/outputdevice/bitmap.cxx +++ b/vcl/backendtest/outputdevice/bitmap.cxx @@ -111,6 +111,27 @@ Bitmap OutputDeviceTestBitmap::setupDrawMask() return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); } +Bitmap OutputDeviceTestBitmap::setupDrawNativeBitmapWithAlpha() +{ + Size aBitmapSize(9, 9); + Bitmap aBitmap(aBitmapSize, 32); + { + Bitmap::ScopedWriteAccess aWriteAccess(aBitmap); + aWriteAccess->Erase(COL_TRANSPARENT); + aWriteAccess->SetLineColor(Color(0x44, 0xFF, 0xFF, 0x00)); + aWriteAccess->DrawRect(Rectangle(0, 0, 8, 8)); + aWriteAccess->DrawRect(Rectangle(3, 3, 5, 5)); + } + + initialSetup(13, 13, constBackgroundColor); + + Point aPoint(alignToCenter(maVDRectangle, Rectangle(Point(), aBitmapSize)).TopLeft()); + + mpVirtualDevice->DrawBitmap(aPoint, aBitmap); + + return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()); +} + TestResult OutputDeviceTestBitmap::checkBitmap(Bitmap& rBitmap) { std::vector<Color> aExpected @@ -131,7 +152,7 @@ TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap) return checkRectangles(rBitmap, aExpected); } -TestResult OutputDeviceTestBitmap::checkBitmapExWithAlpha(Bitmap& rBitmap) +TestResult OutputDeviceTestBitmap::checkAlphaBitmap(Bitmap& rBitmap) { const Color aBlendedColor(0xEE, 0xEE, 0x33); diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx index cc90b000b10d..53b17bc696e9 100644 --- a/vcl/inc/test/outputdevice.hxx +++ b/vcl/inc/test/outputdevice.hxx @@ -77,11 +77,13 @@ public: Bitmap setupDrawBitmap(); Bitmap setupDrawBitmapExWithAlpha(); Bitmap setupDrawMask(); + Bitmap setupDrawNativeBitmapWithAlpha(); static TestResult checkBitmap(Bitmap& rBitmap); static TestResult checkTransformedBitmap(Bitmap& rBitmap); static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap); static TestResult checkMask(Bitmap& rBitmap); + static TestResult checkAlphaBitmap(Bitmap& rBitmap); }; class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon |