[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - 3 commits - vcl/inc vcl/qt5 vcl/unx
Katarina Behrens
Katarina.Behrens at cib.de
Thu Apr 19 15:11:33 UTC 2018
vcl/inc/qt5/Qt5Frame.hxx | 7 ++++++-
vcl/qt5/Qt5Frame.cxx | 28 +++++++++++++++++-----------
vcl/unx/kde5/KDE5SalFrame.cxx | 32 ++++++++++++++++----------------
vcl/unx/kde5/KDE5SalFrame.hxx | 24 +++++-------------------
vcl/unx/kde5/KDE5SalGraphics.cxx | 26 ++++++++++++--------------
vcl/unx/kde5/KDE5SalGraphics.hxx | 6 +-----
6 files changed, 57 insertions(+), 66 deletions(-)
New commits:
commit b49dffa71654488e296b02cbab343ff5a56f52cc
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Apr 19 17:09:14 2018 +0200
Kill GraphicsHolder with fire
Change-Id: I6bcdb872a1c7279bd08fbbfecd582e698532e0b3
diff --git a/vcl/unx/kde5/KDE5SalFrame.cxx b/vcl/unx/kde5/KDE5SalFrame.cxx
index 0709a79e6fe6..23e800cb5558 100644
--- a/vcl/unx/kde5/KDE5SalFrame.cxx
+++ b/vcl/unx/kde5/KDE5SalFrame.cxx
@@ -334,28 +334,4 @@ void KDE5SalFrame::ReleaseGraphics( SalGraphics* pSalGraph )
m_bGraphicsInUse = false;
}
-void KDE5SalFrame::updateGraphics( bool bClear )
-{
- vcl::Window* pWindow = GetWindow();
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- /*if( m_aGraphics[i].bInUse )
- m_aGraphics[i].pGraphics->SetDrawable( aDrawable, GetScreenNumber() );*/
- }
-}
-
-cairo_t* KDE5SalFrame::getCairoContext() const
-{
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( ! m_aGraphics[i].bInUse )
- {
- cairo_t* cr = cairo_create( m_aGraphics[i].pSurface );
- assert(cr);
- return cr;
- }
- }
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalFrame.hxx b/vcl/unx/kde5/KDE5SalFrame.hxx
index 2066b443e19f..64f43867a8d4 100644
--- a/vcl/unx/kde5/KDE5SalFrame.hxx
+++ b/vcl/unx/kde5/KDE5SalFrame.hxx
@@ -20,7 +20,6 @@
#pragma once
#include <memory>
-#include <cairo.h>
#undef Status
@@ -36,18 +35,6 @@ class KDE5SalGraphics;
class KDE5SalFrame : public Qt5Frame
{
private:
- static const int nMaxGraphics = 2;
-
- struct GraphicsHolder
- {
- std::unique_ptr<KDE5SalGraphics> pGraphics;
- bool bInUse;
- cairo_surface_t* pSurface;
-
- GraphicsHolder() : bInUse( false ), pSurface(nullptr) {}
- };
-
- GraphicsHolder m_aGraphics[ nMaxGraphics ];
std::unique_ptr<KDE5SalGraphics> m_pKDE5Graphics;
bool m_bGraphicsInUse;
@@ -56,7 +43,6 @@ class KDE5SalFrame : public Qt5Frame
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics *pGraphics ) override;
- void updateGraphics( bool bClear );
virtual void UpdateSettings( AllSettings& rSettings ) override;
virtual void DrawMenuBar() override { return; }
@@ -68,8 +54,6 @@ class KDE5SalFrame : public Qt5Frame
virtual KeyIndicatorState GetIndicatorState() override { return KeyIndicatorState(); }
virtual void SetScreenNumber( unsigned int ) override { return; }
-
- cairo_t* getCairoContext() const;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a05e74491a78a91d791d3952e6bd53c82269253d
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Apr 19 15:09:36 2018 +0200
Restore Acquire/ReleaseGraphics, use KDE5SalGraphics
commented out most of KDE5SalGraphics code for the time being
Change-Id: I73654bd8376a9648a462505702dcf284f46ef315
diff --git a/vcl/unx/kde5/KDE5SalFrame.cxx b/vcl/unx/kde5/KDE5SalFrame.cxx
index ffee47165a37..0709a79e6fe6 100644
--- a/vcl/unx/kde5/KDE5SalFrame.cxx
+++ b/vcl/unx/kde5/KDE5SalFrame.cxx
@@ -49,6 +49,7 @@
KDE5SalFrame::KDE5SalFrame( KDE5SalFrame* pParent, SalFrameStyleFlags nState, bool bUseCairo )
:Qt5Frame( pParent, nState, bUseCairo )
+ ,m_bGraphicsInUse(false)
{
}
@@ -310,6 +311,29 @@ void KDE5SalFrame::UpdateSettings( AllSettings& rSettings )
rSettings.SetStyleSettings( style );
}
+SalGraphics* KDE5SalFrame::AcquireGraphics()
+{
+ if (m_bGraphicsInUse)
+ return nullptr;
+
+ m_bGraphicsInUse = true;
+
+ if ( !m_pKDE5Graphics.get() )
+ {
+ m_pKDE5Graphics.reset( new KDE5SalGraphics());
+ Qt5Frame::InitSvpSalGraphics( m_pKDE5Graphics.get() );
+ }
+
+ return m_pKDE5Graphics.get();
+}
+
+void KDE5SalFrame::ReleaseGraphics( SalGraphics* pSalGraph )
+{
+ (void)pSalGraph;
+ assert( pSalGraph == m_pKDE5Graphics.get() );
+ m_bGraphicsInUse = false;
+}
+
void KDE5SalFrame::updateGraphics( bool bClear )
{
vcl::Window* pWindow = GetWindow();
diff --git a/vcl/unx/kde5/KDE5SalFrame.hxx b/vcl/unx/kde5/KDE5SalFrame.hxx
index c939141ec4e0..2066b443e19f 100644
--- a/vcl/unx/kde5/KDE5SalFrame.hxx
+++ b/vcl/unx/kde5/KDE5SalFrame.hxx
@@ -24,8 +24,8 @@
#undef Status
-#include <unx/saldisp.hxx>
#include <qt5/Qt5Frame.hxx>
+#include <unx/saldisp.hxx>
#include <unx/salgdi.h>
#include "KDE5SalGraphics.hxx"
@@ -48,12 +48,14 @@ class KDE5SalFrame : public Qt5Frame
};
GraphicsHolder m_aGraphics[ nMaxGraphics ];
-
- QWidget* m_pWindow;
+ std::unique_ptr<KDE5SalGraphics> m_pKDE5Graphics;
+ bool m_bGraphicsInUse;
public:
KDE5SalFrame( KDE5SalFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo );
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics( SalGraphics *pGraphics ) override;
void updateGraphics( bool bClear );
virtual void UpdateSettings( AllSettings& rSettings ) override;
diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx
index 39e2a8ff235c..45600c3b1bb7 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.cxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.cxx
@@ -70,16 +70,14 @@ QRect region2QRect( const tools::Rectangle& rControlRegion )
return QRect(rControlRegion.Left(), rControlRegion.Top(), rControlRegion.GetWidth(), rControlRegion.GetHeight());
}
-KDE5SalGraphics::KDE5SalGraphics( KDE5SalFrame *pFrame, QWidget *pWindow )
- : SvpSalGraphics(),
- m_pWindow( pWindow ),
- m_pFrame( pFrame )
+KDE5SalGraphics::KDE5SalGraphics()
+ : SvpSalGraphics()
{
}
bool KDE5SalGraphics::IsNativeControlSupported( ControlType type, ControlPart part )
{
- switch (type)
+ /*switch (type)
{
case ControlType::Pushbutton:
case ControlType::Radiobutton:
@@ -112,7 +110,7 @@ bool KDE5SalGraphics::IsNativeControlSupported( ControlType type, ControlPart pa
default:
break;
- }
+ }*/
return false;
}
@@ -209,7 +207,7 @@ bool KDE5SalGraphics::drawNativeControl( ControlType type, ControlPart part,
const ImplControlValue& value,
const OUString& )
{
- bool nativeSupport = IsNativeControlSupported( type, part );
+ /*bool nativeSupport = IsNativeControlSupported( type, part );
if( ! nativeSupport ) {
assert( ! nativeSupport && "drawNativeControl called without native support!" );
return false;
@@ -603,8 +601,8 @@ bool KDE5SalGraphics::drawNativeControl( ControlType type, ControlPart part,
returnVal = false;
}
- delete localClipRegion;
- return returnVal;
+ delete localClipRegion;*/
+ return false;
}
bool KDE5SalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
@@ -615,7 +613,7 @@ bool KDE5SalGraphics::getNativeControlRegion( ControlType type, ControlPart part
{
bool retVal = false;
- QRect boundingRect = region2QRect( controlRegion );
+ /*QRect boundingRect = region2QRect( controlRegion );
QRect contentRect = boundingRect;
QStyleOptionComplex styleOption;
@@ -910,7 +908,7 @@ bool KDE5SalGraphics::getNativeControlRegion( ControlType type, ControlPart part
Point aPoint( contentRect.x(), contentRect.y() );
Size aSize( contentRect.width(), contentRect.height() );
nativeContentRegion = tools::Rectangle( aPoint, aSize );
- }
+ }*/
return retVal;
}
@@ -924,7 +922,7 @@ bool KDE5SalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart
const tools::Rectangle& rControlRegion, const Point& rPos,
bool& rIsInside )
{
- if ( nType == ControlType::Scrollbar )
+ /*if ( nType == ControlType::Scrollbar )
{
if( nPart != ControlPart::ButtonUp && nPart != ControlPart::ButtonDown
&& nPart != ControlPart::ButtonLeft && nPart != ControlPart::ButtonRight )
@@ -959,8 +957,8 @@ bool KDE5SalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart
else // DOWN, RIGHT
rIsInside = ( control == QStyle::SC_ScrollBarAddLine );
return TRUE;
- }
- return FALSE;
+ }*/
+ return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalGraphics.hxx b/vcl/unx/kde5/KDE5SalGraphics.hxx
index 298d2100fe0f..94000a8040cb 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.hxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.hxx
@@ -36,7 +36,7 @@ class KDE5SalFrame;
class KDE5SalGraphics : public SvpSalGraphics
{
public:
- KDE5SalGraphics( KDE5SalFrame *pFrame, QWidget *pWindow);
+ KDE5SalGraphics();
virtual bool IsNativeControlSupported( ControlType, ControlPart ) override;
virtual bool hitTestNativeControl( ControlType, ControlPart,
@@ -49,10 +49,6 @@ public:
ControlState, const ImplControlValue&,
const OUString&, tools::Rectangle&, tools::Rectangle& ) override;
-private:
- QWidget *m_pWindow;
- KDE5SalFrame *m_pFrame;
-
std::unique_ptr<QImage> m_image;
QRect lastPopupRect;
};
commit fa32a37d7412c6e1be1a0f65abd1b626878d37aa
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Apr 19 14:20:27 2018 +0200
Reorganize code to enable derived classes inject SvpSalGraphics
or derivative thereof
Change-Id: Iea0d5e838de0ea397dcbffd11c33f021d53face2
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;
More information about the Libreoffice-commits
mailing list