[Libreoffice-commits] core.git: canvas/source include/vcl vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/skia vcl/source vcl/unx vcl/win

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 11:40:34 UTC 2021


 canvas/source/vcl/canvashelper.cxx       |   22 ++++++++++++++++++++++
 include/vcl/outdev.hxx                   |    6 ++++++
 vcl/headless/svpgdi.cxx                  |    5 +++++
 vcl/inc/headless/svpgdi.hxx              |    1 +
 vcl/inc/qt5/Qt5Graphics.hxx              |    1 +
 vcl/inc/quartz/salgdi.h                  |    2 ++
 vcl/inc/salgdi.hxx                       |    5 +++++
 vcl/inc/salgdiimpl.hxx                   |    3 +++
 vcl/inc/skia/gdiimpl.hxx                 |    2 ++
 vcl/inc/unx/genpspgraphics.h             |    1 +
 vcl/inc/unx/salgdi.h                     |    2 ++
 vcl/inc/win/salgdi.h                     |    3 +++
 vcl/qt5/Qt5Graphics_GDI.cxx              |    2 ++
 vcl/quartz/salgdicommon.cxx              |    5 +++++
 vcl/skia/gdiimpl.cxx                     |    7 +++++++
 vcl/source/gdi/salgdilayout.cxx          |    5 +++++
 vcl/source/outdev/bitmap.cxx             |   11 +++++++++++
 vcl/unx/generic/gdi/gdiimpl.cxx          |    5 +++++
 vcl/unx/generic/gdi/gdiimpl.hxx          |    2 ++
 vcl/unx/generic/gdi/salgdi2.cxx          |    5 +++++
 vcl/unx/generic/print/genpspgraphics.cxx |    5 +++++
 vcl/win/gdi/gdiimpl.cxx                  |    5 +++++
 vcl/win/gdi/gdiimpl.hxx                  |    2 ++
 vcl/win/gdi/salgdi_gdiplus.cxx           |    5 +++++
 24 files changed, 112 insertions(+)

New commits:
commit f57872d2da23c8a3f90c67b6ad4a3ad0f699a276
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Feb 19 15:06:14 2021 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Feb 24 12:39:45 2021 +0100

    simply use drawTransformedBitmap()
    
    At least with Skia this is faster than GraphicObject trying
    to handle it manually, even in raster mode.
    
    Change-Id: If77d108751f5621878d4ea87a996c2ea0253d111
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111246
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 501741301d8e..89ee207989c6 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -723,6 +723,28 @@ namespace vclcanvas
                 // itself serves this purpose
                 return uno::Reference< rendering::XCachedPrimitive >(nullptr);
             }
+            else if( !bModulateColors && mpOutDevProvider->getOutDev().HasFastDrawTransformedBitmap())
+            {
+                ::basegfx::B2DHomMatrix aSizeTransform;
+                aSizeTransform.scale( aBmpEx.GetSizePixel().Width(), aBmpEx.GetSizePixel().Height() );
+                aMatrix = aMatrix * aSizeTransform;
+
+                mpOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmpEx );
+                if( mp2ndOutDevProvider )
+                {
+                    // HACK. Normally, CanvasHelper does not care about
+                    // actually what mp2ndOutDev is...  well, here we do &
+                    // assume a 1bpp target - everything beyond 97%
+                    // transparency is fully transparent
+                    if( aBmpEx.IsAlpha() )
+                    {
+                        BitmapFilter::Filter(aBmpEx, BitmapAlphaClampFilter(253));
+                    }
+
+                    mp2ndOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmpEx );
+                }
+                return uno::Reference< rendering::XCachedPrimitive >(nullptr);
+            }
             else
             {
                 // Matrix contains non-trivial transformation (or
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index d101b6c8c571..2eb6fd9e882e 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1485,6 +1485,12 @@ public:
                                     const basegfx::B2DHomMatrix& rTransformation,
                                     const BitmapEx& rBitmapEx);
 
+    /** Return true if DrawTransformedBitmapEx() is fast.
+
+        @since 7.2
+    */
+    bool                        HasFastDrawTransformedBitmap() const;
+
 protected:
 
     virtual void                DrawDeviceBitmap(
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index ab28f158be0a..5c713657d755 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -829,6 +829,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 d9ec43c0b0ef..a0a20e508d72 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -145,6 +145,7 @@ protected:
         const basegfx::B2DPoint& rY,
         const SalBitmap& rSourceBitmap,
         const SalBitmap* pAlphaBitmap) 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/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index a163db87d94a..87ffc938becf 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -155,6 +155,7 @@ public:
     bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
                                const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
                                const SalBitmap* pAlphaBitmap) 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/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index ce68b75b0b06..b3df7550ebf9 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -296,6 +296,8 @@ public:
                                             const SalBitmap& rSourceBitmap,
                                             const SalBitmap* pAlphaBitmap) 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/salgdi.hxx b/vcl/inc/salgdi.hxx
index 92a587841a9c..44ddf34a50ff 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -416,6 +416,8 @@ public:
                                     const SalBitmap* pAlphaBitmap,
                                     const OutputDevice& rOutDev );
 
+    bool                        HasFastDrawTransformedBitmap() const;
+
     bool                        DrawAlphaRect(
                                     tools::Long nX, tools::Long nY,
                                     tools::Long nWidth, tools::Long nHeight,
@@ -580,6 +582,9 @@ protected:
                                     const SalBitmap& rSourceBitmap,
                                     const SalBitmap* pAlphaBitmap) = 0;
 
+    /// Used e.g. by canvas to know whether to cache the drawing.
+    virtual bool hasFastDrawTransformedBitmap() const = 0;
+
     /** Render solid rectangle with given transparency
      *
      * @param nX             Top left coordinate of rectangle
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index e349edadddc4..eb1508dcf7d6 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -196,6 +196,9 @@ public:
                 const SalBitmap& rSourceBitmap,
                 const SalBitmap* pAlphaBitmap) = 0;
 
+    /// Used e.g. by canvas to know whether to cache the drawing.
+    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 6b60f63ae405..53a9a0ae0978 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -176,6 +176,8 @@ public:
                                        const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
                                        const SalBitmap* pAlphaBitmap) 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/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index b8e55627cf8c..a572a9013c63 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -190,6 +190,7 @@ public:
                                                    const basegfx::B2DPoint& rY,
                                                    const SalBitmap& rSourceBitmap,
                                                    const SalBitmap* pAlphaBitmap) 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/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 56f587e521a8..d8e175750813 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -248,6 +248,8 @@ public:
                                         const SalBitmap& rSourceBitmap,
                                         const SalBitmap* pAlphaBitmap) 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 52b04aaf26b9..ca04f2469d66 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -290,6 +290,9 @@ public:
                            const basegfx::B2DPoint& rY,
                            const SalBitmap& rSourceBitmap,
                            const SalBitmap* pAlphaBitmap) 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/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index 5c4db9ecceb3..fbcc3d32d0d9 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -653,6 +653,8 @@ bool Qt5Graphics::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const ba
     return true;
 }
 
+bool Qt5Graphics::hasFastDrawTransformedBitmap() const { return false; }
+
 bool Qt5Graphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
                                 tools::Long nHeight, sal_uInt8 nTransparency)
 {
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index f58cfecf712e..b74dbda15360 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -375,6 +375,11 @@ bool AquaSalGraphics::drawTransformedBitmap(
     return true;
 }
 
+bool AquaSalGraphics::hasFastDrawTransformedBitmap() const
+{
+    return false;
+}
+
 bool AquaSalGraphics::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 f9fdfcaa1300..d8077df48a68 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1751,6 +1751,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;
+}
+
 bool SkiaSalGraphicsImpl::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
                                                 const basegfx::B2DPoint& rX,
                                                 const basegfx::B2DPoint& rY,
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index ed2a2ed21df2..d019b93e816b 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -859,6 +859,11 @@ bool SalGraphics::DrawTransformedBitmap(
     return drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap);
 }
 
+bool SalGraphics::HasFastDrawTransformedBitmap() const
+{
+    return hasFastDrawTransformedBitmap();
+}
+
 bool SalGraphics::DrawAlphaRect( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
                                  sal_uInt8 nTransparency, const OutputDevice& rOutDev )
 {
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 6c93084f0062..8f4fbef24ee0 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -1430,6 +1430,17 @@ void OutputDevice::DrawTransformedBitmapEx(
     DrawBitmapEx(aDestPt, aDestSize, aTransformed);
 }
 
+bool OutputDevice::HasFastDrawTransformedBitmap() const
+{
+    if( ImplIsRecordLayout() )
+        return false;
+
+    if ( !mpGraphics && !AcquireGraphics() )
+        return false;
+
+    return mpGraphics->HasFastDrawTransformedBitmap();
+}
+
 void OutputDevice::DrawImage( const Point& rPos, const Image& rImage, DrawImageFlags nStyle )
 {
     assert(!is_double_buffered_window());
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 97d9067d0be7..680a9e5d14b8 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -851,6 +851,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 bb3092b25356..dcc4f641f3a3 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -272,6 +272,8 @@ public:
                 const SalBitmap& rSourceBitmap,
                 const SalBitmap* pAlphaBitmap) 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 d688f00fa743..c4954e9e6119 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -141,6 +141,11 @@ bool X11SalGraphics::drawTransformedBitmap(
     return mxImpl->drawTransformedBitmap( rNull, rX, rY, rSourceBitmap, pAlphaBitmap );
 }
 
+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/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 3d93a2c05ffe..4218da4ed53b 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -854,6 +854,11 @@ bool GenPspGraphics::drawTransformedBitmap(
     return false;
 }
 
+bool GenPspGraphics::hasFastDrawTransformedBitmap() const
+{
+    return false;
+}
+
 bool GenPspGraphics::drawAlphaRect( tools::Long, tools::Long, tools::Long, tools::Long, sal_uInt8 )
 {
     return false;
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 7e524fd5f9ac..40c7bbbbdb84 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -2710,6 +2710,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 b7e87ce97116..0d9d9b30ce2c 100644
--- a/vcl/win/gdi/gdiimpl.hxx
+++ b/vcl/win/gdi/gdiimpl.hxx
@@ -228,6 +228,8 @@ public:
                 const SalBitmap& rSourceBitmap,
                 const SalBitmap* pAlphaBitmap) 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 f56a227609f9..8a85f033783b 100644
--- a/vcl/win/gdi/salgdi_gdiplus.cxx
+++ b/vcl/win/gdi/salgdi_gdiplus.cxx
@@ -95,4 +95,9 @@ bool WinSalGraphics::drawTransformedBitmap(
             rSourceBitmap, pAlphaBitmap);
 }
 
+bool WinSalGraphics::hasFastDrawTransformedBitmap() const
+{
+    return mpImpl->hasFastDrawTransformedBitmap();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list