diff options
-rw-r--r-- | vcl/inc/qt5/Qt5Frame.hxx | 7 | ||||
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 28 |
2 files changed, 23 insertions, 12 deletions
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx index e2b9b96936e2..4b0a99113536 100644 --- a/vcl/inc/qt5/Qt5Frame.hxx +++ b/vcl/inc/qt5/Qt5Frame.hxx @@ -44,7 +44,11 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public SalFrame std::unique_ptr<QImage> m_pQImage; std::unique_ptr<Qt5Graphics> m_pQt5Graphics; UniqueCairoSurface m_pSurface; - std::unique_ptr<SvpSalGraphics> m_pSvpGraphics; + std::unique_ptr<SvpSalGraphics> m_pOurSvpGraphics; + // in base class, this ptr is the same as m_pOurSvpGraphic + // in derived class, it can point to a derivative + // of SvpSalGraphics (which the derived class then owns) + SvpSalGraphics* m_pSvpGraphics; DamageHandler m_aDamageHandler; bool m_bGraphicsInUse; @@ -81,6 +85,7 @@ public: void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight) const; + virtual void InitSvpSalGraphics( SvpSalGraphics* pSvpSalGraphics ); virtual SalGraphics* AcquireGraphics() override; virtual void ReleaseGraphics(SalGraphics* pGraphics) override; diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index c8f8609ea14e..2af95ee039dd 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -140,6 +140,18 @@ void Qt5Frame::TriggerPaintEvent(QRect aRect) CallCallback(SalEvent::Paint, &aPaintEvt); } +void Qt5Frame::InitSvpSalGraphics( SvpSalGraphics* pSvpSalGraphics ) +{ + int width = m_pQWidget->size().width(); + int height = m_pQWidget->size().height(); + m_pSvpGraphics = pSvpSalGraphics; + m_pSurface.reset(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height)); + m_pSvpGraphics->setSurface(m_pSurface.get(), basegfx::B2IVector(width, height)); + cairo_surface_set_user_data(m_pSurface.get(), SvpSalGraphics::getDamageKey(), + &m_aDamageHandler, nullptr); + TriggerPaintEvent(); +} + SalGraphics* Qt5Frame::AcquireGraphics() { if (m_bGraphicsInUse) @@ -149,18 +161,12 @@ SalGraphics* Qt5Frame::AcquireGraphics() if (m_bUseCairo) { - if (!m_pSvpGraphics.get()) + if (!m_pOurSvpGraphics.get()) { - int width = m_pQWidget->size().width(); - int height = m_pQWidget->size().height(); - m_pSvpGraphics.reset(new SvpSalGraphics()); - m_pSurface.reset(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height)); - m_pSvpGraphics->setSurface(m_pSurface.get(), basegfx::B2IVector(width, height)); - cairo_surface_set_user_data(m_pSurface.get(), SvpSalGraphics::getDamageKey(), - &m_aDamageHandler, nullptr); - TriggerPaintEvent(); + m_pOurSvpGraphics.reset( new SvpSalGraphics() ); + InitSvpSalGraphics( m_pOurSvpGraphics.get() ); } - return m_pSvpGraphics.get(); + return m_pOurSvpGraphics.get(); } else { @@ -179,7 +185,7 @@ void Qt5Frame::ReleaseGraphics(SalGraphics* pSalGraph) { (void)pSalGraph; if (m_bUseCairo) - assert(pSalGraph == m_pSvpGraphics.get()); + assert(pSalGraph == m_pOurSvpGraphics.get()); else assert(pSalGraph == m_pQt5Graphics.get()); m_bGraphicsInUse = false; |