diff options
26 files changed, 92 insertions, 68 deletions
diff --git a/bin/find-can-be-private-symbols.functions.results b/bin/find-can-be-private-symbols.functions.results index f5ebcac3d329..be8116b9ff90 100644 --- a/bin/find-can-be-private-symbols.functions.results +++ b/bin/find-can-be-private-symbols.functions.results @@ -2750,8 +2750,8 @@ SalGraphics::DrawTransformedBitmap(basegfx::B2DPoint const&, basegfx::B2DPoint c SalGraphics::FillFontSubsetInfo(vcl::TTGlobalFontInfo_ const&, rtl::OUString const&, FontSubsetInfo&) SalGraphics::GetBitmap(long, long, long, long, OutputDevice const&) SalGraphics::GetNativeControlRegion(ControlType, ControlPart, tools::Rectangle const&, ControlState, ImplControlValue const&, tools::Rectangle&, tools::Rectangle&, OutputDevice const&) -SalGraphics::ImplementsFastDrawTransformedBitmap(bool) const SalGraphics::GetPixel(long, long, OutputDevice const&) +SalGraphics::HasFastDrawTransformedBitmap() const SalGraphics::HitTestNativeScrollbar(ControlPart, tools::Rectangle const&, Point const&, bool&, OutputDevice const&) SalGraphics::Invert(long, long, long, long, SalInvert, OutputDevice const&) SalGraphics::Invert(unsigned int, Point const*, SalInvert, OutputDevice const&) diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 2ba45cbfa75d..918a8f5f97fe 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -721,7 +721,7 @@ namespace vclcanvas // itself serves this purpose return uno::Reference< rendering::XCachedPrimitive >(nullptr); } - else if( mpOutDevProvider->getOutDev().ImplementsFastDrawTransformedBitmap()) + else if( mpOutDevProvider->getOutDev().HasFastDrawTransformedBitmap()) { ::basegfx::B2DHomMatrix aSizeTransform; aSizeTransform.scale( aBmpEx.GetSizePixel().Width(), aBmpEx.GetSizePixel().Height() ); diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index acf3c78c0d5c..eec957e14973 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1381,11 +1381,11 @@ public: const BitmapEx& rBitmapEx, double fAlpha = 1.0); - /** Return true if DrawTransformedBitmapEx() is implemented. It may still fail, - e.g when fAlpha != 1.0 and that aspect is not implemented. This is a hint - that calling it is worth a try + /** Return true if DrawTransformedBitmapEx() is fast. + + @since 7.2 */ - bool ImplementsFastDrawTransformedBitmap() const; + bool HasFastDrawTransformedBitmap() const; protected: diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index b894183102be..ac375c3fadf0 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -830,6 +830,11 @@ bool SvpSalGraphics::drawTransformedBitmap( return true; } +bool SvpSalGraphics::hasFastDrawTransformedBitmap() const +{ + return false; +} + void SvpSalGraphics::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) { RectangleVector aRectangles; diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index c69462b89742..32168d87e727 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -147,6 +147,7 @@ protected: const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) override; cairo_t* createTmpCompatibleCairoContext() const; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index b5756584f11b..fed7c2cb88f0 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -149,6 +149,8 @@ public: const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; + bool hasFastDrawTransformedBitmap() const override; + bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index f996ffff378d..f0aa925c6083 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -431,6 +431,8 @@ public: const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; + bool hasFastDrawTransformedBitmap() const override; + bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 121f7044ca5c..716c9aa934a6 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -430,7 +430,7 @@ public: double fAlpha, const OutputDevice& rOutDev ); - bool ImplementsFastDrawTransformedBitmap(bool bTestAllowed) const; + bool HasFastDrawTransformedBitmap() const; bool DrawAlphaRect( tools::Long nX, tools::Long nY, @@ -600,6 +600,10 @@ protected: const SalBitmap* pAlphaBitmap, double fAlpha) = 0; + /// Used e.g. by canvas to know whether to cache the drawing. + /// See also tdf#138068. + virtual bool hasFastDrawTransformedBitmap() const = 0; + /** Render solid rectangle with given transparency * * @param nX Top left coordinate of rectangle @@ -625,10 +629,6 @@ private: bool m_bLastMirrorDeviceLTRButBiDiRtlSet; protected: - /// check/remember if FastDraw is implemented for this SalGraphics - bool m_bFastDrawTransformedBitmapChecked; - bool m_bFastDrawTransformedBitmap; - /// flags which hold the SetAntialiasing() value from OutputDevice bool m_bAntiAlias : 1; @@ -894,6 +894,11 @@ public: return GetImpl()->drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha); } + bool hasFastDrawTransformedBitmap() const override + { + return GetImpl()->hasFastDrawTransformedBitmap(); + } + bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override { diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx index 035f896b2456..cb4bc35bd942 100644 --- a/vcl/inc/salgdiimpl.hxx +++ b/vcl/inc/salgdiimpl.hxx @@ -212,6 +212,10 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) = 0; + /// Used e.g. by canvas to know whether to cache the drawing. + /// See also tdf#138068. + virtual bool hasFastDrawTransformedBitmap() const = 0; + virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 6db0e87cdb99..b5144a249207 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -173,6 +173,8 @@ public: const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; + /** Render solid rectangle with given transparency @param nX Top left coordinate of rectangle diff --git a/vcl/inc/unx/GenPspGfxBackend.hxx b/vcl/inc/unx/GenPspGfxBackend.hxx index 181d9f7ab95d..a37ee433e6eb 100644 --- a/vcl/inc/unx/GenPspGfxBackend.hxx +++ b/vcl/inc/unx/GenPspGfxBackend.hxx @@ -111,6 +111,8 @@ public: const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, const SalBitmap* pAlphaBitmap, double fAlpha) override; + bool hasFastDrawTransformedBitmap() const override; + bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override; diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 92c638ba660a..2a1a9945bd17 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -253,6 +253,8 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; + virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) override; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 065e7e25aa5a..b472ece0a256 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -309,6 +309,8 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; + virtual bool drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) override; private: diff --git a/vcl/qt5/QtGraphics_GDI.cxx b/vcl/qt5/QtGraphics_GDI.cxx index cbbe2d819c96..f87de50827df 100644 --- a/vcl/qt5/QtGraphics_GDI.cxx +++ b/vcl/qt5/QtGraphics_GDI.cxx @@ -661,7 +661,6 @@ bool QtGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, { if (fAlpha != 1.0) return false; - QImage aImage; if (pAlphaBitmap && !getAlphaImage(rSourceBitmap, *pAlphaBitmap, aImage)) return false; @@ -682,6 +681,8 @@ bool QtGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, return true; } +bool QtGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } + bool QtGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) { diff --git a/vcl/quartz/AquaGraphicsBackend.cxx b/vcl/quartz/AquaGraphicsBackend.cxx index 060ca471aef8..056d2cd0e32f 100644 --- a/vcl/quartz/AquaGraphicsBackend.cxx +++ b/vcl/quartz/AquaGraphicsBackend.cxx @@ -1299,6 +1299,8 @@ bool AquaGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull, return true; } +bool AquaGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } + bool AquaGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) { diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 9e022a02dec6..593e2ffb57e4 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1829,6 +1829,13 @@ void SkiaSalGraphicsImpl::drawShader(const SalTwoRect& rPosAry, const sk_sp<SkSh postDraw(); } +bool SkiaSalGraphicsImpl::hasFastDrawTransformedBitmap() const +{ + // Return true even in raster mode, even that way Skia is faster than e.g. GraphicObject + // trying to handle stuff manually. + return true; +} + // Whether applying matrix needs image smoothing for the transformation. static bool matrixNeedsHighQuality(const SkMatrix& matrix) { diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 15a1a1384540..aafa8f157e70 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -54,8 +54,6 @@ SalGraphics::SalGraphics() m_aLastMirrorW(0), m_nLastMirrorDeviceLTRButBiDiRtlTranslate(0), m_bLastMirrorDeviceLTRButBiDiRtlSet(false), - m_bFastDrawTransformedBitmapChecked(false), - m_bFastDrawTransformedBitmap(false), m_bAntiAlias(false) { // read global RTL settings @@ -844,9 +842,6 @@ bool SalGraphics::DrawTransformedBitmap( double fAlpha, const OutputDevice& rOutDev) { - bool bRetval(false); - bool bDone(false); - if( (m_nLayout & SalLayoutFlags::BiDiRtl) || rOutDev.IsRTLEnabled() ) { // mirroring set @@ -861,49 +856,16 @@ bool SalGraphics::DrawTransformedBitmap( basegfx::B2DPoint aX = aTranslateToMirroredBounds * rX; basegfx::B2DPoint aY = aTranslateToMirroredBounds * rY; - bRetval = drawTransformedBitmap(aNull, aX, aY, rSourceBitmap, pAlphaBitmap, fAlpha); - bDone = true; + return drawTransformedBitmap(aNull, aX, aY, rSourceBitmap, pAlphaBitmap, fAlpha); } } - if(!bDone) - { - bRetval = drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha); - } - - if(bRetval && !m_bFastDrawTransformedBitmap) - { - // we had a sucessful call, note it for this SalGraphics - m_bFastDrawTransformedBitmap = true; - } - - return bRetval; + return drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha); } -bool SalGraphics::ImplementsFastDrawTransformedBitmap(bool bTestAllowed) const +bool SalGraphics::HasFastDrawTransformedBitmap() const { - // do not check when we already had a sucessful usage of drawTransformedBitmap (see above) - // only check if calling OutputDevice is not empty (bTestAllowed) - // check only once using the direct check method (see below) - if(!m_bFastDrawTransformedBitmap && bTestAllowed && !m_bFastDrawTransformedBitmapChecked) - { - // for check and to not change anything, get the top-left pixel as SalBitmap - // and try to paint it again. This avoids an extra virtual method hat would need - // to be implemened at all backends and cald all the time (virual calls). - // Nothing simpler came to my mind, maybe there is something... - SalGraphics* that(const_cast<SalGraphics*>(this)); - std::shared_ptr<SalBitmap> aTest(that->getBitmap(0, 0, 1, 1)); - that->m_bFastDrawTransformedBitmapChecked = true; - that->m_bFastDrawTransformedBitmap = that->drawTransformedBitmap( - basegfx::B2DPoint::getEmptyPoint(), - basegfx::B2DPoint(1.0, 0.0), - basegfx::B2DPoint(0.0, 1.0), - *aTest, - nullptr, - 1.0); - } - - return m_bFastDrawTransformedBitmap; + return hasFastDrawTransformedBitmap(); } bool SalGraphics::DrawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 2c6d3a50a7d9..53a9f774b71d 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -691,6 +691,18 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, mpMetaFile = pOldMetaFile; } +bool OutputDevice::HasFastDrawTransformedBitmap() const +{ + if( ImplIsRecordLayout() ) + return false; + + if (!mpGraphics && !AcquireGraphics()) + return false; + assert(mpGraphics); + + return mpGraphics->HasFastDrawTransformedBitmap(); +} + void OutputDevice::DrawImage( const Point& rPos, const Image& rImage, DrawImageFlags nStyle ) { assert(!is_double_buffered_window()); diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index d5d35b762ede..7855d1ae5613 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -525,7 +525,7 @@ void OutputDevice::DrawTransformedBitmapEx( if(rtl::math::approxEqual( fAlpha, 1.0 )) fAlpha = 1.0; // avoid the need for approxEqual in backends - if(bTryDirectPaint && DrawTransformBitmapExDirect(aFullTransform, bitmapEx)) + if(bTryDirectPaint && mpGraphics->HasFastDrawTransformedBitmap() && DrawTransformBitmapExDirect(aFullTransform, bitmapEx)) return; // decompose matrix to check rotation and shear @@ -689,9 +689,4 @@ void OutputDevice::DrawTransformedBitmapEx( DrawBitmapEx(aDestPt, aDestSize, aTransformed); } -bool OutputDevice::ImplementsFastDrawTransformedBitmap() const -{ - return mpGraphics->ImplementsFastDrawTransformedBitmap(!GetOutputSizePixel().IsEmpty()); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index 7c167255d33b..53226821b4a1 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -852,6 +852,11 @@ bool X11SalGraphicsImpl::drawTransformedBitmap( return false; } +bool X11SalGraphicsImpl::hasFastDrawTransformedBitmap() const +{ + return false; +} + bool X11SalGraphicsImpl::drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) { diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index 56cfba5ba371..6257b47d613d 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -272,6 +272,8 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; + /** Render solid rectangle with given transparency @param nTransparency diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx index 648de56744a0..cfdb272005a5 100644 --- a/vcl/unx/generic/gdi/salgdi2.cxx +++ b/vcl/unx/generic/gdi/salgdi2.cxx @@ -139,13 +139,14 @@ bool X11SalGraphics::drawTransformedBitmap( const SalBitmap* pAlphaBitmap, double fAlpha) { - // called mxImpl->drawTransformedBitmap anyways returns false, but spares a call - if( fAlpha != 1.0 ) - return false; - return mxImpl->drawTransformedBitmap( rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha ); } +bool X11SalGraphics::hasFastDrawTransformedBitmap() const +{ + return mxImpl->hasFastDrawTransformedBitmap(); +} + bool X11SalGraphics::drawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency ) { diff --git a/vcl/unx/generic/print/GenPspGfxBackend.cxx b/vcl/unx/generic/print/GenPspGfxBackend.cxx index 2201c54c69d8..7b461ff4f5c6 100644 --- a/vcl/unx/generic/print/GenPspGfxBackend.cxx +++ b/vcl/unx/generic/print/GenPspGfxBackend.cxx @@ -387,6 +387,8 @@ bool GenPspGfxBackend::drawTransformedBitmap(const basegfx::B2DPoint& /*rNull*/, return false; } +bool GenPspGfxBackend::hasFastDrawTransformedBitmap() const { return false; } + bool GenPspGfxBackend::drawAlphaRect(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, tools::Long /*nHeight*/, sal_uInt8 /*nTransparency*/) { diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 5d0bab4ebaac..2c418732561b 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -2714,6 +2714,11 @@ bool WinSalGraphicsImpl::drawTransformedBitmap( return false; } +bool WinSalGraphicsImpl::hasFastDrawTransformedBitmap() const +{ + return false; +} + bool WinSalGraphicsImpl::drawGradient(const tools::PolyPolygon& /*rPolygon*/, const Gradient& /*rGradient*/) { diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx index 697ae97dde17..86342533fc6c 100644 --- a/vcl/win/gdi/gdiimpl.hxx +++ b/vcl/win/gdi/gdiimpl.hxx @@ -228,6 +228,8 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) override; + virtual bool hasFastDrawTransformedBitmap() const override; + /** Render solid rectangle with given transparency @param nTransparency diff --git a/vcl/win/gdi/salgdi_gdiplus.cxx b/vcl/win/gdi/salgdi_gdiplus.cxx index bbf4889c14f4..13452f5c7a6e 100644 --- a/vcl/win/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/gdi/salgdi_gdiplus.cxx @@ -92,12 +92,13 @@ bool WinSalGraphics::drawTransformedBitmap( const SalBitmap* pAlphaBitmap, double fAlpha) { - // called mpImpl->drawTransformedBitmap also checks this, but spares a call - if( fAlpha != 1.0 ) - return false; - return mpImpl->drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap, fAlpha); } +bool WinSalGraphics::hasFastDrawTransformedBitmap() const +{ + return mpImpl->hasFastDrawTransformedBitmap(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |