vcl/inc/qt5/Qt5Graphics.hxx     |  207 ++++++++++++++++++++++---------------
 vcl/inc/qt5/Qt5GraphicsBase.hxx |    3 
 vcl/inc/qt5/Qt5Painter.hxx      |    5 
 vcl/inc/salgdi.hxx              |   15 ++
 vcl/inc/salgdiimpl.hxx          |   15 ++
 vcl/qt5/Qt5Bitmap.cxx           |    2 
 vcl/qt5/Qt5Graphics.cxx         |   26 ----
 vcl/qt5/Qt5Graphics_GDI.cxx     |  220 ++++++++++++++++++++++++----------------
 vcl/qt5/Qt5Graphics_Text.cxx    |    2 
 vcl/qt5/Qt5Painter.cxx          |    2 
 10 files changed, 302 insertions(+), 195 deletions(-)

New commits:
commit 33da78c21f4243a3e469fb7df79ed1745df70078
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Apr 7 21:27:11 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Apr 7 17:46:14 2021 +0200

    vcl: move graphic handling into Qt5GraphicsBackend
    
    This is an effort to make SalGraphicsImpl mandatory for all
    backends.
    This introduces Qt5GraphicsBackend: a subclass of SalGraphicsImpl,
    which now handles graphic rendering.
    
    Change-Id: I42aece59d0c692ca1dd33e30f31c5bcceab02008
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113734
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index e90731179d53..011d3384e804 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -37,9 +37,8 @@ class Qt5FontFace;
 class Qt5Frame;
 class Qt5Painter;
 
-class Qt5Graphics final : public SalGraphics, public Qt5GraphicsBase
+class Qt5GraphicsBackend final : public SalGraphicsImpl, public Qt5GraphicsBase
 {
-    friend class Qt5Bitmap;
     friend class Qt5Painter;
 
     Qt5Frame* m_pFrame;
@@ -50,6 +49,124 @@ class Qt5Graphics final : public SalGraphics, public 
Qt5GraphicsBase
     Color m_aFillColor;
     QPainter::CompositionMode m_eCompositionMode;
 
+public:
+    Qt5GraphicsBackend(Qt5Frame* pFrame, QImage* pQImage);
+    ~Qt5GraphicsBackend() override;
+
+    void Init() override {}
+
+    QImage* getQImage() { return m_pQImage; }
+
+    void setQImage(QImage* pQImage) { m_pQImage = pQImage; }
+
+    void freeResources() override {}
+
+    OUString getRenderBackendName() const override { return "qt5"; }
+
+    bool setClipRegion(vcl::Region const& rRegion) override;
+    void ResetClipRegion() override;
+
+    sal_uInt16 GetBitCount() const override;
+
+    tools::Long GetGraphicsWidth() const override;
+
+    void SetLineColor() override;
+    void SetLineColor(Color nColor) override;
+    void SetFillColor() override;
+    void SetFillColor(Color nColor) override;
+    void SetXORMode(bool bSet, bool bInvertOnly) override;
+    void SetROPLineColor(SalROPColor nROPColor) override;
+    void SetROPFillColor(SalROPColor nROPColor) override;
+
+    void drawPixel(tools::Long nX, tools::Long nY) override;
+    void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
+
+    void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, 
tools::Long nY2) override;
+    void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight) override;
+    void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override;
+    void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override;
+    void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+                         const Point** pPointArray) override;
+
+    bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
+                         const basegfx::B2DPolyPolygon&, double fTransparency) 
override;
+
+    bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const 
basegfx::B2DPolygon&,
+                      double fTransparency, double fLineWidth, const 
std::vector<double>* pStroke,
+                      basegfx::B2DLineJoin, css::drawing::LineCap, double 
fMiterMinimumAngle,
+                      bool bPixelSnapHairline) override;
+
+    bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray,
+                            const PolyFlags* pFlagArray) override;
+
+    bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray,
+                           const PolyFlags* pFlagArray) override;
+
+    bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+                               const Point* const* pPointArray,
+                               const PolyFlags* const* pFlagArray) override;
+
+    void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, 
tools::Long nSrcY,
+                  tools::Long nSrcWidth, tools::Long nSrcHeight, bool 
bWindowInvalidate) override;
+
+    void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) 
override;
+
+    void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) 
override;
+
+    void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
+                    const SalBitmap& rMaskBitmap) override;
+
+    void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
+                  Color nMaskColor) override;
+
+    std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, 
tools::Long nWidth,
+                                         tools::Long nHeight) override;
+
+    Color getPixel(tools::Long nX, tools::Long nY) override;
+
+    void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight,
+                SalInvert nFlags) override;
+
+    void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) 
override;
+
+    bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight,
+                 void* pPtr, sal_uInt32 nSize) override;
+
+    bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
+
+    bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
+                          const SalBitmap& rMaskBitmap, const SalBitmap& 
rAlphaBitmap) override;
+
+    bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
+                         const SalBitmap& rAlphaBitmap) override;
+
+    bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const 
basegfx::B2DPoint& rX,
+                               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;
+
+    bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& 
rGradient) override;
+    bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon,
+                          SalGradient const& rGradient) override;
+
+    bool supportsOperation(OutDevSupportType eType) const override;
+
+private:
+    void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
+};
+
+class Qt5Graphics final : public SalGraphicsAutoDelegateToImpl, public 
Qt5GraphicsBase
+{
+    friend class Qt5Bitmap;
+
+    std::unique_ptr<Qt5GraphicsBackend> m_pBackend;
+
+    Qt5Frame* m_pFrame;
+
     rtl::Reference<Qt5Font> m_pTextStyle[MAX_FALLBACK];
     Color m_aTextColor;
 
@@ -70,12 +187,16 @@ public:
     }
     virtual ~Qt5Graphics() override;
 
+    QImage* getQImage() { return m_pBackend->getQImage(); }
+
     void ChangeQImage(QImage* pImage);
 
     virtual SalGraphicsImpl* GetImpl() const override;
     virtual SystemGraphicsData GetGraphicsData() const override;
-    virtual bool supportsOperation(OutDevSupportType) const override;
-    virtual OUString getRenderBackendName() const override { return "qt5"; }
+    virtual OUString getRenderBackendName() const override
+    {
+        return m_pBackend->getRenderBackendName();
+    }
 
 #if ENABLE_CAIRO_CANVAS
     virtual bool SupportsCairo() const override;
@@ -92,85 +213,7 @@ public:
 
     // GDI
 
-    virtual bool setClipRegion(const vcl::Region&) override;
-    virtual void ResetClipRegion() override;
-
-    virtual void drawPixel(tools::Long nX, tools::Long nY) override;
-    virtual void drawPixel(tools::Long nX, tools::Long nY, Color nColor) 
override;
-    virtual void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2,
-                          tools::Long nY2) override;
-    virtual void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
-                          tools::Long nHeight) override;
-    virtual void drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry) 
override;
-    virtual void drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) override;
-    virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
-                                 const Point** pPtAry) override;
-    virtual bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
-                                 const basegfx::B2DPolyPolygon&, double 
fTransparency) override;
-    virtual bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPtAry,
-                                    const PolyFlags* pFlgAry) override;
-    virtual bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPtAry,
-                                   const PolyFlags* pFlgAry) override;
-    virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* 
pPoints,
-                                       const Point* const* pPtAry,
-                                       const PolyFlags* const* pFlgAry) 
override;
-    virtual bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
-                              const basegfx::B2DPolygon&, double 
fTransparency, double fLineWidths,
-                              const std::vector<double>* pStroke, // MM01
-                              basegfx::B2DLineJoin, css::drawing::LineCap 
eLineCap,
-                              double fMiterMinimumAngle, bool 
bPixelSnapHairline) override;
-    virtual bool drawGradient(const tools::PolyPolygon&, const Gradient&) 
override;
-
-    virtual void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long 
nSrcX,
-                          tools::Long nSrcY, tools::Long nSrcWidth, 
tools::Long nSrcHeight,
-                          bool bWindowInvalidate) override;
-
-    virtual void copyBits(const SalTwoRect& rPosAry, SalGraphics* 
pSrcGraphics) override;
-    virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& 
rSalBitmap) override;
-    virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& 
rSalBitmap,
-                            const SalBitmap& rTransparentBitmap) override;
-    virtual void drawMask(const SalTwoRect& rPosAry, const SalBitmap& 
rSalBitmap,
-                          Color nMaskColor) override;
-
-    virtual std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long 
nY, tools::Long nWidth,
-                                                 tools::Long nHeight) override;
-    virtual Color getPixel(tools::Long nX, tools::Long nY) override;
-
-    virtual void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight,
-                        SalInvert nFlags) override;
-    virtual void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert 
nFlags) override;
-
-    virtual bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight,
-                         void* pPtr, sal_uInt32 nSize) override;
-
-    virtual bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) 
override;
-
-    virtual bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& 
rSrcBitmap,
-                                  const SalBitmap& rMaskBitmap,
-                                  const SalBitmap& rAlphaBitmap) override;
-
-    virtual bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& 
rSourceBitmap,
-                                 const SalBitmap& rAlphaBitmap) override;
-
-    bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const 
basegfx::B2DPoint& rX,
-                               const basegfx::B2DPoint& rY, 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;
-
     virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
-    virtual sal_uInt16 GetBitCount() const override;
-    virtual tools::Long GetGraphicsWidth() const override;
-
-    virtual void SetLineColor() override;
-    virtual void SetLineColor(Color nColor) override;
-    virtual void SetFillColor() override;
-    virtual void SetFillColor(Color nColor) override;
-    virtual void SetXORMode(bool bSet, bool bInvertOnly) override;
-    virtual void SetROPLineColor(SalROPColor nROPColor) override;
-    virtual void SetROPFillColor(SalROPColor nROPColor) override;
 
     // Text rendering + font support
 
diff --git a/vcl/inc/qt5/Qt5GraphicsBase.hxx b/vcl/inc/qt5/Qt5GraphicsBase.hxx
index ef7955186a6e..91b8bfb20e9e 100644
--- a/vcl/inc/qt5/Qt5GraphicsBase.hxx
+++ b/vcl/inc/qt5/Qt5GraphicsBase.hxx
@@ -15,7 +15,7 @@ class Qt5GraphicsBase
 {
     qreal m_fDPR;
 
-protected:
+public:
     Qt5GraphicsBase()
         : m_fDPR(qApp ? qApp->devicePixelRatio() : 1.0)
     {
@@ -23,7 +23,6 @@ protected:
 
     void setDevicePixelRatioF(qreal fDPR) { m_fDPR = fDPR; }
 
-public:
     qreal devicePixelRatioF() const { return m_fDPR; }
 };
 
diff --git a/vcl/inc/qt5/Qt5Painter.hxx b/vcl/inc/qt5/Qt5Painter.hxx
index 51ddc3d69695..ff3b22595144 100644
--- a/vcl/inc/qt5/Qt5Painter.hxx
+++ b/vcl/inc/qt5/Qt5Painter.hxx
@@ -28,11 +28,12 @@
 
 class Qt5Painter final : public QPainter
 {
-    Qt5Graphics& m_rGraphics;
+    Qt5GraphicsBackend& m_rGraphics;
     QRegion m_aRegion;
 
 public:
-    Qt5Painter(Qt5Graphics& rGraphics, bool bPrepareBrush = false, sal_uInt8 
nTransparency = 255);
+    Qt5Painter(Qt5GraphicsBackend& rGraphics, bool bPrepareBrush = false,
+               sal_uInt8 nTransparency = 255);
     ~Qt5Painter()
     {
         if (m_rGraphics.m_pFrame && !m_aRegion.isEmpty())
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 6cd814164059..9c99fcd5fa0b 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -80,8 +80,19 @@ public:
 
     virtual SalGraphicsImpl*    GetImpl() const = 0;
 
-    void                        setAntiAlias(bool bNew) { m_bAntiAlias = bNew; 
}
-    bool                        getAntiAlias() const { return m_bAntiAlias; }
+    void                        setAntiAlias(bool bNew)
+    {
+        m_bAntiAlias = bNew;
+
+        // Temporary store in both
+        if (GetImpl())
+            GetImpl()->setAntiAlias(bNew);
+    }
+
+    bool                        getAntiAlias() const
+    {
+        return m_bAntiAlias;
+    }
 
     // public SalGraphics methods, the interface to the independent vcl part
 
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 94505b1a83f6..cb4bc35bd942 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -40,8 +40,23 @@ struct SalGradient;
 
 class VCL_PLUGIN_PUBLIC SalGraphicsImpl
 {
+    bool m_bAntiAlias;
 public:
 
+    void setAntiAlias(bool bNew)
+    {
+        m_bAntiAlias = bNew;
+    }
+
+    bool getAntiAlias() const
+    {
+        return m_bAntiAlias;
+    }
+
+    SalGraphicsImpl()
+        : m_bAntiAlias(false)
+    {}
+
     virtual ~SalGraphicsImpl();
 
     virtual void Init() = 0;
diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx
index 6e8921294def..4ad2ea9c9f60 100644
--- a/vcl/qt5/Qt5Bitmap.cxx
+++ b/vcl/qt5/Qt5Bitmap.cxx
@@ -70,7 +70,7 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, SalGraphics* 
pSalGraphics)
 {
     const Qt5Bitmap* pBitmap = static_cast<const Qt5Bitmap*>(&rSalBmp);
     Qt5Graphics* pGraphics = static_cast<Qt5Graphics*>(pSalGraphics);
-    QImage* pImage = pGraphics->m_pQImage;
+    QImage* pImage = pGraphics->getQImage();
     m_pImage.reset(new 
QImage(pBitmap->m_pImage->convertToFormat(pImage->format())));
     return true;
 }
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index c769b4e13795..c89747f98869 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -32,14 +32,10 @@
 
 Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
     : m_pFrame( pFrame )
-    , m_pQImage( pQImage )
-    , m_aLineColor( 0x00, 0x00, 0x00 )
-    , m_aFillColor( 0xFF, 0xFF, 0XFF )
-    , m_eCompositionMode( QPainter::CompositionMode_SourceOver )
     , m_pTextStyle{ nullptr, }
     , m_aTextColor( 0x00, 0x00, 0x00 )
 {
-    ResetClipRegion();
+    m_pBackend = std::make_unique<Qt5GraphicsBackend>(m_pFrame, pQImage);
 
     if (!initWidgetDrawBackends(false))
     {
@@ -54,26 +50,14 @@ Qt5Graphics::~Qt5Graphics() { ReleaseFonts(); }
 
 void Qt5Graphics::ChangeQImage(QImage* pQImage)
 {
-    m_pQImage = pQImage;
-    ResetClipRegion();
+    m_pBackend->setQImage(pQImage);
+    m_pBackend->ResetClipRegion();
 }
 
-SalGraphicsImpl* Qt5Graphics::GetImpl() const { return nullptr; }
+SalGraphicsImpl* Qt5Graphics::GetImpl() const { return m_pBackend.get(); }
 
 SystemGraphicsData Qt5Graphics::GetGraphicsData() const { return 
SystemGraphicsData(); }
 
-bool Qt5Graphics::supportsOperation(OutDevSupportType eType) const
-{
-    switch (eType)
-    {
-        case OutDevSupportType::B2DDraw:
-        case OutDevSupportType::TransparentRect:
-            return true;
-        default:
-            return false;
-    }
-}
-
 #if ENABLE_CAIRO_CANVAS
 
 bool Qt5Graphics::SupportsCairo() const { return false; }
@@ -114,7 +98,7 @@ void Qt5Graphics::handleDamage(const tools::Rectangle& 
rDamagedRegion)
     QImage* pImage = 
static_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())->getImage();
     QImage blit(*pImage);
     blit.setDevicePixelRatio(1);
-    Qt5Painter aPainter(*this);
+    Qt5Painter aPainter(*m_pBackend);
     aPainter.drawImage(QPoint(rDamagedRegion.getX(), rDamagedRegion.getY()), 
blit);
     aPainter.update(toQRect(rDamagedRegion));
 }
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index bfcea039fd90..a2730be5ad4e 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -33,6 +33,18 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 
+Qt5GraphicsBackend::Qt5GraphicsBackend(Qt5Frame* pFrame, QImage* pQImage)
+    : m_pFrame(pFrame)
+    , m_pQImage(pQImage)
+    , m_aLineColor(0x00, 0x00, 0x00)
+    , m_aFillColor(0xFF, 0xFF, 0XFF)
+    , m_eCompositionMode(QPainter::CompositionMode_SourceOver)
+{
+    ResetClipRegion();
+}
+
+Qt5GraphicsBackend::~Qt5GraphicsBackend() {}
+
 const basegfx::B2DPoint aHalfPointOfs(0.5, 0.5);
 
 static void AddPolygonToPath(QPainterPath& rPath, const basegfx::B2DPolygon& 
rPolygon,
@@ -113,7 +125,7 @@ static bool AddPolyPolygonToPath(QPainterPath& rPath, const 
basegfx::B2DPolyPoly
     return true;
 }
 
-bool Qt5Graphics::setClipRegion(const vcl::Region& rRegion)
+bool Qt5GraphicsBackend::setClipRegion(const vcl::Region& rRegion)
 {
     if (rRegion.IsRectangle())
     {
@@ -153,7 +165,7 @@ bool Qt5Graphics::setClipRegion(const vcl::Region& rRegion)
     return true;
 }
 
-void Qt5Graphics::ResetClipRegion()
+void Qt5GraphicsBackend::ResetClipRegion()
 {
     if (m_pQImage)
         m_aClipRegion = QRegion(m_pQImage->rect());
@@ -166,14 +178,14 @@ void Qt5Graphics::ResetClipRegion()
     }
 }
 
-void Qt5Graphics::drawPixel(tools::Long nX, tools::Long nY)
+void Qt5GraphicsBackend::drawPixel(tools::Long nX, tools::Long nY)
 {
     Qt5Painter aPainter(*this);
     aPainter.drawPoint(nX, nY);
     aPainter.update(nX, nY, 1, 1);
 }
 
-void Qt5Graphics::drawPixel(tools::Long nX, tools::Long nY, Color nColor)
+void Qt5GraphicsBackend::drawPixel(tools::Long nX, tools::Long nY, Color 
nColor)
 {
     Qt5Painter aPainter(*this);
     aPainter.setPen(toQColor(nColor));
@@ -182,7 +194,8 @@ void Qt5Graphics::drawPixel(tools::Long nX, tools::Long nY, 
Color nColor)
     aPainter.update(nX, nY, 1, 1);
 }
 
-void Qt5Graphics::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, 
tools::Long nY2)
+void Qt5GraphicsBackend::drawLine(tools::Long nX1, tools::Long nY1, 
tools::Long nX2,
+                                  tools::Long nY2)
 {
     Qt5Painter aPainter(*this);
     aPainter.drawLine(nX1, nY1, nX2, nY2);
@@ -203,7 +216,8 @@ void Qt5Graphics::drawLine(tools::Long nX1, tools::Long 
nY1, tools::Long nX2, to
     aPainter.update(nX1, nY1, nX2 - nX1 + 1, nY2 - nY1 + 1);
 }
 
-void Qt5Graphics::drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight)
+void Qt5GraphicsBackend::drawRect(tools::Long nX, tools::Long nY, tools::Long 
nWidth,
+                                  tools::Long nHeight)
 {
     if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
         return;
@@ -216,7 +230,7 @@ void Qt5Graphics::drawRect(tools::Long nX, tools::Long nY, 
tools::Long nWidth, t
     aPainter.update(nX, nY, nWidth, nHeight);
 }
 
-void Qt5Graphics::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry)
+void Qt5GraphicsBackend::drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry)
 {
     if (0 == nPoints)
         return;
@@ -242,7 +256,7 @@ void Qt5Graphics::drawPolyLine(sal_uInt32 nPoints, const 
Point* pPtAry)
     aPainter.update(QRect(aTopLeft, aBottomRight));
 }
 
-void Qt5Graphics::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry)
+void Qt5GraphicsBackend::drawPolygon(sal_uInt32 nPoints, const Point* pPtAry)
 {
     Qt5Painter aPainter(*this, true);
     QPolygon aPolygon(nPoints);
@@ -252,8 +266,8 @@ void Qt5Graphics::drawPolygon(sal_uInt32 nPoints, const 
Point* pPtAry)
     aPainter.update(aPolygon.boundingRect());
 }
 
-void Qt5Graphics::drawPolyPolygon(sal_uInt32 nPolyCount, const sal_uInt32* 
pPoints,
-                                  const Point** ppPtAry)
+void Qt5GraphicsBackend::drawPolyPolygon(sal_uInt32 nPolyCount, const 
sal_uInt32* pPoints,
+                                         const Point** ppPtAry)
 {
     // ignore invisible polygons
     if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
@@ -279,8 +293,9 @@ void Qt5Graphics::drawPolyPolygon(sal_uInt32 nPolyCount, 
const sal_uInt32* pPoin
     aPainter.update(aPath.boundingRect());
 }
 
-bool Qt5Graphics::drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
-                                  const basegfx::B2DPolyPolygon& rPolyPolygon, 
double fTransparency)
+bool Qt5GraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& 
rObjectToDevice,
+                                         const basegfx::B2DPolyPolygon& 
rPolyPolygon,
+                                         double fTransparency)
 {
     // ignore invisible polygons
     if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
@@ -303,31 +318,32 @@ bool Qt5Graphics::drawPolyPolygon(const 
basegfx::B2DHomMatrix& rObjectToDevice,
     return true;
 }
 
-bool Qt5Graphics::drawPolyLineBezier(sal_uInt32 /*nPoints*/, const Point* 
/*pPtAry*/,
-                                     const PolyFlags* /*pFlgAry*/)
+bool Qt5GraphicsBackend::drawPolyLineBezier(sal_uInt32 /*nPoints*/, const 
Point* /*pPtAry*/,
+                                            const PolyFlags* /*pFlgAry*/)
 {
     return false;
 }
 
-bool Qt5Graphics::drawPolygonBezier(sal_uInt32 /*nPoints*/, const Point* 
/*pPtAry*/,
-                                    const PolyFlags* /*pFlgAry*/)
+bool Qt5GraphicsBackend::drawPolygonBezier(sal_uInt32 /*nPoints*/, const 
Point* /*pPtAry*/,
+                                           const PolyFlags* /*pFlgAry*/)
 {
     return false;
 }
 
-bool Qt5Graphics::drawPolyPolygonBezier(sal_uInt32 /*nPoly*/, const 
sal_uInt32* /*pPoints*/,
-                                        const Point* const* /*pPtAry*/,
-                                        const PolyFlags* const* /*pFlgAry*/)
+bool Qt5GraphicsBackend::drawPolyPolygonBezier(sal_uInt32 /*nPoly*/, const 
sal_uInt32* /*pPoints*/,
+                                               const Point* const* /*pPtAry*/,
+                                               const PolyFlags* const* 
/*pFlgAry*/)
 {
     return false;
 }
 
-bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
-                               const basegfx::B2DPolygon& rPolyLine, double 
fTransparency,
-                               double fLineWidth,
-                               const std::vector<double>* pStroke, // MM01
-                               basegfx::B2DLineJoin eLineJoin, 
css::drawing::LineCap eLineCap,
-                               double fMiterMinimumAngle, bool 
bPixelSnapHairline)
+bool Qt5GraphicsBackend::drawPolyLine(const basegfx::B2DHomMatrix& 
rObjectToDevice,
+                                      const basegfx::B2DPolygon& rPolyLine, 
double fTransparency,
+                                      double fLineWidth,
+                                      const std::vector<double>* pStroke, // 
MM01
+                                      basegfx::B2DLineJoin eLineJoin,
+                                      css::drawing::LineCap eLineCap, double 
fMiterMinimumAngle,
+                                      bool bPixelSnapHairline)
 {
     if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
     {
@@ -426,9 +442,19 @@ bool Qt5Graphics::drawPolyLine(const 
basegfx::B2DHomMatrix& rObjectToDevice,
     return true;
 }
 
-bool Qt5Graphics::drawGradient(const tools::PolyPolygon&, const Gradient&) { 
return false; }
+bool Qt5GraphicsBackend::drawGradient(const tools::PolyPolygon& 
/*rPolyPolygon*/,
+                                      const Gradient& /*rGradient*/)
+{
+    return false;
+}
+
+bool Qt5GraphicsBackend::implDrawGradient(basegfx::B2DPolyPolygon const& 
/*rPolyPolygon*/,
+                                          SalGradient const& /*rGradient*/)
+{
+    return false;
+}
 
-void Qt5Graphics::drawScaledImage(const SalTwoRect& rPosAry, const QImage& 
rImage)
+void Qt5GraphicsBackend::drawScaledImage(const SalTwoRect& rPosAry, const 
QImage& rImage)
 {
     Qt5Painter aPainter(*this);
     QRect aSrcRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, 
rPosAry.mnSrcHeight);
@@ -437,18 +463,25 @@ void Qt5Graphics::drawScaledImage(const SalTwoRect& 
rPosAry, const QImage& rImag
     aPainter.update(aDestRect);
 }
 
-void Qt5Graphics::copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long 
nSrcX,
-                           tools::Long nSrcY, tools::Long nSrcWidth, 
tools::Long nSrcHeight,
-                           bool /*bWindowInvalidate*/)
+void Qt5GraphicsBackend::copyArea(tools::Long nDestX, tools::Long nDestY, 
tools::Long nSrcX,
+                                  tools::Long nSrcY, tools::Long nSrcWidth, 
tools::Long nSrcHeight,
+                                  bool /*bWindowInvalidate*/)
 {
     if (nDestX == nSrcX && nDestY == nSrcY)
         return;
 
     SalTwoRect aTR(nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDestX, nDestY, 
nSrcWidth, nSrcHeight);
-    copyBits(aTR, this);
+
+    QImage* pImage = m_pQImage;
+    QImage aImage = pImage->copy(aTR.mnSrcX, aTR.mnSrcY, aTR.mnSrcWidth, 
aTR.mnSrcHeight);
+    pImage = &aImage;
+    aTR.mnSrcX = 0;
+    aTR.mnSrcY = 0;
+
+    drawScaledImage(aTR, *pImage);
 }
 
-void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* 
pSrcGraphics)
+void Qt5GraphicsBackend::copyBits(const SalTwoRect& rPosAry, SalGraphics* 
pSrcGraphics)
 {
     if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || 
rPosAry.mnDestWidth <= 0
         || rPosAry.mnDestHeight <= 0)
@@ -456,7 +489,8 @@ void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, 
SalGraphics* pSrcGraphics)
 
     QImage aImage, *pImage;
     SalTwoRect aPosAry = rPosAry;
-    if (!pSrcGraphics || this == pSrcGraphics)
+
+    if (!pSrcGraphics)
     {
         pImage = m_pQImage;
         aImage
@@ -466,12 +500,12 @@ void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, 
SalGraphics* pSrcGraphics)
         aPosAry.mnSrcY = 0;
     }
     else
-        pImage = static_cast<Qt5Graphics*>(pSrcGraphics)->m_pQImage;
+        pImage = static_cast<Qt5Graphics*>(pSrcGraphics)->getQImage();
 
     drawScaledImage(aPosAry, *pImage);
 }
 
-void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& 
rSalBitmap)
+void Qt5GraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const 
SalBitmap& rSalBitmap)
 {
     if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || 
rPosAry.mnDestWidth <= 0
         || rPosAry.mnDestHeight <= 0)
@@ -484,8 +518,8 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, 
const SalBitmap& rSalBit
     drawScaledImage(rPosAry, *pImage);
 }
 
-void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& 
/*rSalBitmap*/,
-                             const SalBitmap& /*rTransparentBitmap*/)
+void Qt5GraphicsBackend::drawBitmap(const SalTwoRect& rPosAry, const 
SalBitmap& /*rSalBitmap*/,
+                                    const SalBitmap& /*rTransparentBitmap*/)
 {
     if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || 
rPosAry.mnDestWidth <= 0
         || rPosAry.mnDestHeight <= 0)
@@ -495,8 +529,8 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, 
const SalBitmap& /*rSalB
     assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight);
 }
 
-void Qt5Graphics::drawMask(const SalTwoRect& rPosAry, const SalBitmap& 
/*rSalBitmap*/,
-                           Color /*nMaskColor*/)
+void Qt5GraphicsBackend::drawMask(const SalTwoRect& rPosAry, const SalBitmap& 
/*rSalBitmap*/,
+                                  Color /*nMaskColor*/)
 {
     if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || 
rPosAry.mnDestWidth <= 0
         || rPosAry.mnDestHeight <= 0)
@@ -506,19 +540,19 @@ void Qt5Graphics::drawMask(const SalTwoRect& rPosAry, 
const SalBitmap& /*rSalBit
     assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight);
 }
 
-std::shared_ptr<SalBitmap> Qt5Graphics::getBitmap(tools::Long nX, tools::Long 
nY,
-                                                  tools::Long nWidth, 
tools::Long nHeight)
+std::shared_ptr<SalBitmap> Qt5GraphicsBackend::getBitmap(tools::Long nX, 
tools::Long nY,
+                                                         tools::Long nWidth, 
tools::Long nHeight)
 {
     return std::make_shared<Qt5Bitmap>(m_pQImage->copy(nX, nY, nWidth, 
nHeight));
 }
 
-Color Qt5Graphics::getPixel(tools::Long nX, tools::Long nY)
+Color Qt5GraphicsBackend::getPixel(tools::Long nX, tools::Long nY)
 {
     return Color(ColorTransparency, m_pQImage->pixel(nX, nY));
 }
 
-void Qt5Graphics::invert(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight,
-                         SalInvert nFlags)
+void Qt5GraphicsBackend::invert(tools::Long nX, tools::Long nY, tools::Long 
nWidth,
+                                tools::Long nHeight, SalInvert nFlags)
 {
     Qt5Painter aPainter(*this);
     if (SalInvert::N50 & nFlags)
@@ -546,19 +580,25 @@ void Qt5Graphics::invert(tools::Long nX, tools::Long nY, 
tools::Long nWidth, too
     aPainter.update(nX, nY, nWidth, nHeight);
 }
 
-void Qt5Graphics::invert(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/, 
SalInvert /*nFlags*/) {}
+void Qt5GraphicsBackend::invert(sal_uInt32 /*nPoints*/, const Point* 
/*pPtAry*/,
+                                SalInvert /*nFlags*/)
+{
+}
 
-bool Qt5Graphics::drawEPS(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long 
/*nWidth*/,
-                          tools::Long /*nHeight*/, void* /*pPtr*/, sal_uInt32 
/*nSize*/)
+bool Qt5GraphicsBackend::drawEPS(tools::Long /*nX*/, tools::Long /*nY*/, 
tools::Long /*nWidth*/,
+                                 tools::Long /*nHeight*/, void* /*pPtr*/, 
sal_uInt32 /*nSize*/)
 {
     return false;
 }
 
-bool Qt5Graphics::blendBitmap(const SalTwoRect&, const SalBitmap& /*rBitmap*/) 
{ return false; }
+bool Qt5GraphicsBackend::blendBitmap(const SalTwoRect&, const SalBitmap& 
/*rBitmap*/)
+{
+    return false;
+}
 
-bool Qt5Graphics::blendAlphaBitmap(const SalTwoRect&, const SalBitmap& 
/*rSrcBitmap*/,
-                                   const SalBitmap& /*rMaskBitmap*/,
-                                   const SalBitmap& /*rAlphaBitmap*/)
+bool Qt5GraphicsBackend::blendAlphaBitmap(const SalTwoRect&, const SalBitmap& 
/*rSrcBitmap*/,
+                                          const SalBitmap& /*rMaskBitmap*/,
+                                          const SalBitmap& /*rAlphaBitmap*/)
 {
     return false;
 }
@@ -605,8 +645,8 @@ static bool getAlphaImage(const SalBitmap& rSourceBitmap, 
const SalBitmap& rAlph
     return true;
 }
 
-bool Qt5Graphics::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBitmap& 
rSourceBitmap,
-                                  const SalBitmap& rAlphaBitmap)
+bool Qt5GraphicsBackend::drawAlphaBitmap(const SalTwoRect& rPosAry, const 
SalBitmap& rSourceBitmap,
+                                         const SalBitmap& rAlphaBitmap)
 {
     QImage aImage;
     if (!getAlphaImage(rSourceBitmap, rAlphaBitmap, aImage))
@@ -615,9 +655,11 @@ bool Qt5Graphics::drawAlphaBitmap(const SalTwoRect& 
rPosAry, const SalBitmap& rS
     return true;
 }
 
-bool Qt5Graphics::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const 
basegfx::B2DPoint& rX,
-                                        const basegfx::B2DPoint& rY, const 
SalBitmap& rSourceBitmap,
-                                        const SalBitmap* pAlphaBitmap, double 
fAlpha)
+bool Qt5GraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& rNull,
+                                               const basegfx::B2DPoint& rX,
+                                               const basegfx::B2DPoint& rY,
+                                               const SalBitmap& rSourceBitmap,
+                                               const SalBitmap* pAlphaBitmap, 
double fAlpha)
 {
     if (fAlpha != 1.0)
         return false;
@@ -641,10 +683,10 @@ bool Qt5Graphics::drawTransformedBitmap(const 
basegfx::B2DPoint& rNull, const ba
     return true;
 }
 
-bool Qt5Graphics::hasFastDrawTransformedBitmap() const { return false; }
+bool Qt5GraphicsBackend::hasFastDrawTransformedBitmap() const { return false; }
 
-bool Qt5Graphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long 
nWidth,
-                                tools::Long nHeight, sal_uInt8 nTransparency)
+bool Qt5GraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, 
tools::Long nWidth,
+                                       tools::Long nHeight, sal_uInt8 
nTransparency)
 {
     if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor)
         return true;
@@ -660,6 +702,42 @@ bool Qt5Graphics::drawAlphaRect(tools::Long nX, 
tools::Long nY, tools::Long nWid
     return true;
 }
 
+sal_uInt16 Qt5GraphicsBackend::GetBitCount() const { return 
getFormatBits(m_pQImage->format()); }
+
+tools::Long Qt5GraphicsBackend::GetGraphicsWidth() const { return 
m_pQImage->width(); }
+
+void Qt5GraphicsBackend::SetLineColor() { m_aLineColor = SALCOLOR_NONE; }
+
+void Qt5GraphicsBackend::SetLineColor(Color nColor) { m_aLineColor = nColor; }
+
+void Qt5GraphicsBackend::SetFillColor() { m_aFillColor = SALCOLOR_NONE; }
+
+void Qt5GraphicsBackend::SetFillColor(Color nColor) { m_aFillColor = nColor; }
+
+void Qt5GraphicsBackend::SetXORMode(bool bSet, bool)
+{
+    if (bSet)
+        m_eCompositionMode = QPainter::CompositionMode_Xor;
+    else
+        m_eCompositionMode = QPainter::CompositionMode_SourceOver;
+}
+
+void Qt5GraphicsBackend::SetROPLineColor(SalROPColor /*nROPColor*/) {}
+
+void Qt5GraphicsBackend::SetROPFillColor(SalROPColor /*nROPColor*/) {}
+
+bool Qt5GraphicsBackend::supportsOperation(OutDevSupportType eType) const
+{
+    switch (eType)
+    {
+        case OutDevSupportType::B2DDraw:
+        case OutDevSupportType::TransparentRect:
+            return true;
+        default:
+            return false;
+    }
+}
+
 void Qt5Graphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY)
 {
     char* pForceDpi;
@@ -678,28 +756,4 @@ void Qt5Graphics::GetResolution(sal_Int32& rDPIX, 
sal_Int32& rDPIY)
     rDPIY = pScreen->logicalDotsPerInchY() * pScreen->devicePixelRatio() + 0.5;
 }
 
-sal_uInt16 Qt5Graphics::GetBitCount() const { return 
getFormatBits(m_pQImage->format()); }
-
-tools::Long Qt5Graphics::GetGraphicsWidth() const { return m_pQImage->width(); 
}
-
-void Qt5Graphics::SetLineColor() { m_aLineColor = SALCOLOR_NONE; }
-
-void Qt5Graphics::SetLineColor(Color nColor) { m_aLineColor = nColor; }
-
-void Qt5Graphics::SetFillColor() { m_aFillColor = SALCOLOR_NONE; }
-
-void Qt5Graphics::SetFillColor(Color nColor) { m_aFillColor = nColor; }
-
-void Qt5Graphics::SetXORMode(bool bSet, bool)
-{
-    if (bSet)
-        m_eCompositionMode = QPainter::CompositionMode_Xor;
-    else
-        m_eCompositionMode = QPainter::CompositionMode_SourceOver;
-}
-
-void Qt5Graphics::SetROPLineColor(SalROPColor /*nROPColor*/) {}
-
-void Qt5Graphics::SetROPFillColor(SalROPColor /*nROPColor*/) {}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index cfd148e8415e..b42948515ac9 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -328,7 +328,7 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& 
rLayout)
     aGlyphRun.setGlyphIndexes(glyphIndexes);
     aGlyphRun.setRawFont(aRawFont);
 
-    Qt5Painter aPainter(*this);
+    Qt5Painter aPainter(*m_pBackend);
     QColor aColor = toQColor(m_aTextColor);
     aPainter.setPen(aColor);
 
diff --git a/vcl/qt5/Qt5Painter.cxx b/vcl/qt5/Qt5Painter.cxx
index ce59bbe96d08..d898a6106406 100644
--- a/vcl/qt5/Qt5Painter.cxx
+++ b/vcl/qt5/Qt5Painter.cxx
@@ -21,7 +21,7 @@
 
 #include <QtGui/QColor>
 
-Qt5Painter::Qt5Painter(Qt5Graphics& rGraphics, bool bPrepareBrush, sal_uInt8 
nTransparency)
+Qt5Painter::Qt5Painter(Qt5GraphicsBackend& rGraphics, bool bPrepareBrush, 
sal_uInt8 nTransparency)
     : m_rGraphics(rGraphics)
 {
     if (rGraphics.m_pQImage)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to