include/vcl/virdev.hxx | 9 ++ vcl/backendtest/outputdevice/bitmap.cxx | 47 +++++++++++++ vcl/backendtest/outputdevice/common.cxx | 8 +- vcl/inc/skia/gdiimpl.hxx | 6 + vcl/inc/test/outputdevice.hxx | 6 + vcl/qa/cppunit/BackendTest.cxx | 22 ++++++ vcl/skia/gdiimpl.cxx | 108 ++++++++++++++++++++++---------- 7 files changed, 165 insertions(+), 41 deletions(-)
New commits: commit 796d3d40d056ff0395b0f983198a9af922b76b4a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 21:41:42 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 21:41:42 2019 +0100 skia: drawMask can be simplified with drawBitmap call Change-Id: Ie01c9dba1287495db9f176c1e1e25799e5f3e872 diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index d0c2c1a08058..35bb44f02f2a 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -728,7 +728,6 @@ void SkiaSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry, const SalBitmap& r void SkiaSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry, const SkBitmap& rBitmap, Color nMaskColor) { - preDraw(); SkBitmap tmpBitmap; if (!tmpBitmap.tryAllocN32Pixels(rBitmap.width(), rBitmap.height())) abort(); @@ -739,13 +738,8 @@ void SkiaSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry, const SkBitmap& rB paint.setBlendMode(SkBlendMode::kDstOut); SkCanvas canvas(tmpBitmap); canvas.drawBitmap(rBitmap, 0, 0, &paint); - mSurface->getCanvas()->drawBitmapRect( - tmpBitmap, - SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight), - SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, - rPosAry.mnDestHeight), - nullptr); - postDraw(); + + drawBitmap(rPosAry, tmpBitmap); } std::shared_ptr<SalBitmap> SkiaSalGraphicsImpl::getBitmap(long nX, long nY, long nWidth, commit 080bf40c2b81360a2eaf25fceee1c6007b595548 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 21:30:27 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 21:36:14 2019 +0100 skia: add common function to check the input SalTwoRects function is checkInvalidSourceOrDestination Change-Id: Id3b5dc69a3949f01b5335a9bdf0ce0ad165adab1 diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 0ab8be2f98cf..d0c2c1a08058 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -133,6 +133,14 @@ Color fromSkColor(SkColor color) return Color(255 - SkColorGetA(color), SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); } + +// returns true if the source or destination rectangles are invalid +bool checkInvalidSourceOrDestination(SalTwoRect const& rPosAry) +{ + return rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 + || rPosAry.mnDestHeight <= 0; +} + } // end anonymous namespace // Class that triggers flushing the backing buffer when idle. @@ -642,11 +650,8 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect& rPosAry, const SalBitmap& rBitmap) { - if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 - || rPosAry.mnDestHeight <= 0) - { + if (checkInvalidSourceOrDestination(rPosAry)) return false; - } assert(dynamic_cast<const SkiaSalBitmap*>(&rBitmap)); @@ -661,11 +666,8 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry, const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) { - if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 - || rPosAry.mnDestHeight <= 0) - { + if (checkInvalidSourceOrDestination(rPosAry)) return false; - } assert(dynamic_cast<const SkiaSalBitmap*>(&rSrcBitmap)); assert(dynamic_cast<const SkiaSalBitmap*>(&rMaskBitmap)); @@ -701,11 +703,8 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry, void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) { - if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 - || rPosAry.mnDestHeight <= 0) - { + if (checkInvalidSourceOrDestination(rPosAry)) return; - } assert(dynamic_cast<const SkiaSalBitmap*>(&rSalBitmap)); const SkiaSalBitmap& rSkiaSourceBitmap = static_cast<const SkiaSalBitmap&>(rSalBitmap); commit 672aa1c44b217d378a1bb58d133665acf82ae655 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 21:17:25 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 21:17:25 2019 +0100 skia: use a common drawBitmap in more cases Add an additional parameter to drawBitmap - blend mode, so we can also use the same bitmap drawing code for blendBitmap. Change-Id: Iaa0aff6724c6644d80056097e7477b31c8412b29 diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 828f7d916aaf..432f8f2512e5 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -185,8 +185,6 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override; - void drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& bitmap); - virtual bool supportsOperation(OutDevSupportType eType) const override; #ifdef DBG_UTIL @@ -194,6 +192,10 @@ public: static void dump(const SkBitmap& bitmap, const char* file); #endif + // Default blend mode for SkPaint is SkBlendMode::kSrcOver + void drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& aBitmap, + SkBlendMode eBlendMode = SkBlendMode::kSrcOver); + protected: // To be called before any drawing. void preDraw(); diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 150b47e83aa6..0ab8be2f98cf 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -650,21 +650,8 @@ bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect& rPosAry, const SalBitmap assert(dynamic_cast<const SkiaSalBitmap*>(&rBitmap)); - preDraw(); - const SkiaSalBitmap& rSkiaBitmap = static_cast<const SkiaSalBitmap&>(rBitmap); - - SkRect aSourceRect - = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); - SkRect aDestinationRect = SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, - rPosAry.mnDestWidth, rPosAry.mnDestHeight); - - SkPaint aPaint; - aPaint.setBlendMode(SkBlendMode::kMultiply); - mSurface->getCanvas()->drawBitmapRect(rSkiaBitmap.GetSkBitmap(), aSourceRect, aDestinationRect, - &aPaint); - - postDraw(); + drawBitmap(rPosAry, rSkiaBitmap.GetSkBitmap(), SkBlendMode::kMultiply); return true; } @@ -716,16 +703,14 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& { if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0) + { return; - preDraw(); + } + assert(dynamic_cast<const SkiaSalBitmap*>(&rSalBitmap)); - mSurface->getCanvas()->drawBitmapRect( - static_cast<const SkiaSalBitmap&>(rSalBitmap).GetSkBitmap(), - SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight), - SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, - rPosAry.mnDestHeight), - nullptr); - postDraw(); + const SkiaSalBitmap& rSkiaSourceBitmap = static_cast<const SkiaSalBitmap&>(rSalBitmap); + + drawBitmap(rPosAry, rSkiaSourceBitmap.GetSkBitmap()); } void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, @@ -905,15 +890,19 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi return true; } -void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& bitmap) +void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkBitmap& aBitmap, + SkBlendMode eBlendMode) { + SkRect aSourceRect + = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); + SkRect aDestinationRect = SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, + rPosAry.mnDestWidth, rPosAry.mnDestHeight); + + SkPaint aPaint; + aPaint.setBlendMode(eBlendMode); + preDraw(); - mSurface->getCanvas()->drawBitmapRect( - bitmap, - SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight), - SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, - rPosAry.mnDestHeight), - nullptr); + mSurface->getCanvas()->drawBitmapRect(aBitmap, aSourceRect, aDestinationRect, &aPaint); postDraw(); } commit 8d2a357f001c7d4b304dcf7ed43257ce57f03ce6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 20:45:25 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 21:10:52 2019 +0100 skia: implement blendAlphaBitmap and blendBitmap Change-Id: I83f33795bea5ed72f1f3269f30f64b1b24566538 diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index a406d85e924d..150b47e83aa6 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -640,20 +640,76 @@ void SkiaSalGraphicsImpl::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcG postDraw(); } -bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) +bool SkiaSalGraphicsImpl::blendBitmap(const SalTwoRect& rPosAry, const SalBitmap& rBitmap) { - (void)rBitmap; - return false; + if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 + || rPosAry.mnDestHeight <= 0) + { + return false; + } + + assert(dynamic_cast<const SkiaSalBitmap*>(&rBitmap)); + + preDraw(); + + const SkiaSalBitmap& rSkiaBitmap = static_cast<const SkiaSalBitmap&>(rBitmap); + + SkRect aSourceRect + = SkRect::MakeXYWH(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); + SkRect aDestinationRect = SkRect::MakeXYWH(rPosAry.mnDestX, rPosAry.mnDestY, + rPosAry.mnDestWidth, rPosAry.mnDestHeight); + + SkPaint aPaint; + aPaint.setBlendMode(SkBlendMode::kMultiply); + mSurface->getCanvas()->drawBitmapRect(rSkiaBitmap.GetSkBitmap(), aSourceRect, aDestinationRect, + &aPaint); + + postDraw(); + + return true; } -bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap, +bool SkiaSalGraphicsImpl::blendAlphaBitmap(const SalTwoRect& rPosAry, + const SalBitmap& rSourceBitmap, const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) { - (void)rSrcBitmap; - (void)rMaskBitmap; - (void)rAlphaBitmap; - return false; + if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 + || rPosAry.mnDestHeight <= 0) + { + return false; + } + + assert(dynamic_cast<const SkiaSalBitmap*>(&rSrcBitmap)); + assert(dynamic_cast<const SkiaSalBitmap*>(&rMaskBitmap)); + assert(dynamic_cast<const SkiaSalBitmap*>(&rAlphaBitmap)); + + SkBitmap aTempBitmap; + if (!aTempBitmap.tryAllocN32Pixels(rSourceBitmap.GetSize().Width(), + rSourceBitmap.GetSize().Height())) + { + return false; + } + + const SkiaSalBitmap& rSkiaSourceBitmap = static_cast<const SkiaSalBitmap&>(rSourceBitmap); + const SkiaSalBitmap& rSkiaMaskBitmap = static_cast<const SkiaSalBitmap&>(rMaskBitmap); + const SkiaSalBitmap& rSkiaAlphaBitmap = static_cast<const SkiaSalBitmap&>(rAlphaBitmap); + + SkCanvas aCanvas(aTempBitmap); + SkPaint aPaint; + + aPaint.setBlendMode(SkBlendMode::kSrc); + aCanvas.drawBitmap(rSkiaMaskBitmap.GetAlphaSkBitmap(), 0, 0, &aPaint); + + aPaint.setBlendMode(SkBlendMode::kSrcIn); + aCanvas.drawBitmap(rSkiaAlphaBitmap.GetAlphaSkBitmap(), 0, 0, &aPaint); + + aPaint.setBlendMode(SkBlendMode::kSrcOut); + aCanvas.drawBitmap(rSkiaSourceBitmap.GetSkBitmap(), 0, 0, &aPaint); + + drawBitmap(rPosAry, aTempBitmap); + + return true; } void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) commit 52737fc3fbb5e90eea04bfe39ea7a7fe4cfba0d5 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 20:26:44 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 20:26:44 2019 +0100 skia: don't loop to first point if the polygon is not closed This fixes drawing of non-closed polylines. Without this fix the non-closed polylines an extra step is still drawn from the last point in the polygon to the first one (as if the polyline would be closed). Change-Id: I0171aede3dc03f83b7dd8ae699e6b505b3fd4f7f diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index b375b39d1c28..a406d85e924d 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -59,6 +59,10 @@ void lclPolygonToPath(const basegfx::B2DPolygon& rPolygon, SkPath& rPath) for (sal_uInt32 nIndex = 0; nIndex <= nPointCount; nIndex++) { + if (nIndex == nPointCount && !bClosePath) + continue; + + // Make sure we loop the last point to first point nCurrentIndex = nIndex % nPointCount; aCurrentPoint = rPolygon.getB2DPoint(nCurrentIndex); commit e74002d7e02ed1245183db310cddf54d80c5a294 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 20:22:17 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 20:24:14 2019 +0100 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 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: */ diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx index 587bb7507d2e..fb625d7987f3 100644 --- a/vcl/inc/test/outputdevice.hxx +++ b/vcl/inc/test/outputdevice.hxx @@ -88,10 +88,12 @@ public: Bitmap setupDrawBitmap(); Bitmap setupDrawBitmapExWithAlpha(); Bitmap setupDrawMask(); + BitmapEx setupDrawBlend(); static TestResult checkTransformedBitmap(Bitmap& rBitmap); static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap); static TestResult checkMask(Bitmap& rBitmap); + static TestResult checkBlend(BitmapEx& rBitmap); }; class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx index 50e3981cc591..928d7746827b 100644 --- a/vcl/qa/cppunit/BackendTest.cxx +++ b/vcl/qa/cppunit/BackendTest.cxx @@ -22,6 +22,17 @@ class BackendTest : public test::BootstrapFixture // "xdg-open ./workdir/CppunitTest/vcl_backend_test.test.core/" static constexpr const bool mbExportBitmap = false; + void exportImage(OUString const& rsFilename, BitmapEx const& rBitmapEx) + { + if (mbExportBitmap) + { + BitmapEx aBitmapEx(rBitmapEx); + aBitmapEx.Scale(Size(128, 128), BmpScaleFlag::Fast); + SvFileStream aStream(rsFilename, StreamMode::WRITE | StreamMode::TRUNC); + GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmapEx, aStream); + } + } + void exportImage(OUString const& rsFilename, Bitmap const& rBitmap) { if (mbExportBitmap) @@ -377,6 +388,16 @@ public: CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); } + void testDrawBlend() + { + vcl::test::OutputDeviceTestBitmap aOutDevTest; + BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(); + auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx); + exportImage("08-05_blend_test.png", aBitmapEx); + if (aOutDevTest.getRenderBackendName() == "skia") + CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed); + } + CPPUNIT_TEST_SUITE(BackendTest); CPPUNIT_TEST(testDrawRectWithRectangle); CPPUNIT_TEST(testDrawRectWithPixel); @@ -417,6 +438,7 @@ public: CPPUNIT_TEST(testDrawTransformedBitmap); CPPUNIT_TEST(testDrawBitmapExWithAlpha); CPPUNIT_TEST(testDrawMask); + CPPUNIT_TEST(testDrawBlend); CPPUNIT_TEST_SUITE_END(); }; commit 71ffd66f465a75b3df13910078e109ad6b6a9158 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 20:17:50 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 20:17:50 2019 +0100 backendtest: support creating VirtualDevice with alpha Change-Id: I74c428b9b31b89536e72d53e418fc11b3f7e4e32 diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 167664d0e3d9..00c7b473e88a 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -223,7 +223,6 @@ const Color OutputDeviceTestCommon::constLineColor(COL_LIGHTBLUE); const Color OutputDeviceTestCommon::constFillColor(COL_LIGHTBLUE); OutputDeviceTestCommon::OutputDeviceTestCommon() - : mpVirtualDevice(VclPtr<VirtualDevice>::Create()) {} OUString OutputDeviceTestCommon::getRenderBackendName() const @@ -236,8 +235,13 @@ OUString OutputDeviceTestCommon::getRenderBackendName() const return OUString(); } -void OutputDeviceTestCommon::initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA) +void OutputDeviceTestCommon::initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA, bool bAlphaVirtualDevice) { + if (bAlphaVirtualDevice) + mpVirtualDevice = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); + else + mpVirtualDevice = VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT); + maVDRectangle = tools::Rectangle(Point(), Size (nWidth, nHeight)); mpVirtualDevice->SetOutputSizePixel(maVDRectangle.GetSize()); if (bEnableAA) diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx index 7c7e71c975e2..587bb7507d2e 100644 --- a/vcl/inc/test/outputdevice.hxx +++ b/vcl/inc/test/outputdevice.hxx @@ -34,7 +34,7 @@ class VCL_DLLPUBLIC OutputDeviceTestCommon { protected: - ScopedVclPtr<VirtualDevice> mpVirtualDevice; + VclPtr<VirtualDevice> mpVirtualDevice; tools::Rectangle maVDRectangle; static const Color constBackgroundColor; @@ -46,7 +46,7 @@ public: OUString getRenderBackendName() const; - void initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA = false); + void initialSetup(long nWidth, long nHeight, Color aColor, bool bEnableAA = false, bool bAlphaVirtualDevice = false); static TestResult checkRectangle(Bitmap& rBitmap); static TestResult checkRectangleAA(Bitmap& rBitmap); commit d84cb4a2d05b284b6d88b6e4ec7e47d451a63bb5 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 20:14:22 2019 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Oct 31 20:14:22 2019 +0100 vcl: allow creating a VirtualDevice with alpha sufrace Change-Id: Ie181eeb984d8531b437c267b410eeb3c552f844f diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 9baba707e23a..a70f8a110a5d 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -104,9 +104,14 @@ public: Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to indicate: take default screen depth. Only DeviceFormat::BITMASK is the other possibility to denote a binary mask. + + @param eAlphaFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. */ - explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT) - : VirtualDevice(nullptr, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {} + explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT, DeviceFormat eAlphaFormat = DeviceFormat::NONE) + : VirtualDevice(nullptr, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {} /** Create a virtual device of size 1x1 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits