summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-11-30 11:04:01 +0000
committerMichael Meeks <michael.meeks@collabora.com>2015-11-30 11:21:58 +0000
commitef242ae01047f6b8a0a9012e4e40509dd1c03145 (patch)
treeceb0c738b95ecd31573a198b592dc2f65168f118
parent268e4e90f9696998333026ac45b52c4f349d0069 (diff)
vcl: move gtk+ to sharing the same SalGraphics per SalFrame.
This makes the code consistent with other: Mac, Unx, Windows backends, and allows us to cache an OpenGL back-buffer on the SalGraphics - as per Mac. The lifecycle of a SalFrame and a SalGraphics should be consistent for real OS graphics now. Change-Id: I11fea2ce1c1386b1c6b0161a718e5c909c81612c Reviewed-on: https://gerrit.libreoffice.org/20283 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx16
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx93
2 files changed, 37 insertions, 72 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 472aae7e33b1..d1203a3a50c5 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -62,19 +62,6 @@ typedef ::Window GdkNativeWindow;
class GtkSalFrame : public SalFrame, public X11WindowProvider
{
- static const int nMaxGraphics = 2;
-
- struct GraphicsHolder
- {
- GtkSalGraphics* pGraphics;
- bool bInUse;
- GraphicsHolder()
- : pGraphics( nullptr ),
- bInUse( false )
- {}
- ~GraphicsHolder();
- };
-
struct IMHandler
{
@@ -187,7 +174,8 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
std::list< GtkSalFrame* > m_aChildren;
GdkWindowState m_nState;
SystemEnvData m_aSystemData;
- GraphicsHolder m_aGraphics[ nMaxGraphics ];
+ GtkSalGraphics *m_pGraphics;
+ bool m_bGraphics;
sal_uInt16 m_nKeyModifiers;
GdkCursor *m_pCurrentCursor;
GdkVisibilityState m_nVisibility;
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 923581d0fbee..6da958d169c7 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -492,11 +492,6 @@ void GtkSalFrame::doKeyCallback( guint state,
CallCallback( SALEVENT_KEYUP, &aEvent );
}
-GtkSalFrame::GraphicsHolder::~GraphicsHolder()
-{
- delete pGraphics;
-}
-
GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
: m_nXScreen( getDisplay()->GetDefaultXScreen() )
{
@@ -845,15 +840,13 @@ void GtkSalFrame::EnsureAppMenuWatch()
void GtkSalFrame::InvalidateGraphics()
{
- for (unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i)
+ if( m_pGraphics )
{
- if( !m_aGraphics[i].pGraphics )
- continue;
#if !GTK_CHECK_VERSION(3,0,0)
- m_aGraphics[i].pGraphics->SetDrawable( None, m_nXScreen );
- m_aGraphics[i].pGraphics->SetWindow(nullptr);
+ m_pGraphics->SetDrawable( None, m_nXScreen );
+ m_pGraphics->SetWindow(nullptr);
#endif
- m_aGraphics[i].bInUse = false;
+ m_bGraphics = false;
}
}
@@ -926,6 +919,9 @@ GtkSalFrame::~GtkSalFrame()
g_object_unref( G_OBJECT( m_pForeignParent ) );
if( m_pForeignTopLevel )
g_object_unref( G_OBJECT( m_pForeignTopLevel) );
+
+ delete m_pGraphics;
+ m_pGraphics = NULL;
}
void GtkSalFrame::moveWindow( long nX, long nY )
@@ -1172,6 +1168,9 @@ void GtkSalFrame::InitCommon()
m_aSystemData.pAppContext = nullptr;
m_aSystemData.pShellWidget = m_aSystemData.pWidget;
+ m_bGraphics = false;
+ m_pGraphics = NULL;
+
// fake an initial geometry, gets updated via configure event or SetPosSize
if( m_bDefaultPos || m_bDefaultSize )
{
@@ -1596,45 +1595,32 @@ void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
SalGraphics* GtkSalFrame::AcquireGraphics()
{
- if( m_pWindow )
+ if( m_bGraphics )
+ return nullptr;
+
+ if( !m_pGraphics )
{
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( ! m_aGraphics[i].bInUse )
- {
- m_aGraphics[i].bInUse = true;
- if( ! m_aGraphics[i].pGraphics )
- {
#if GTK_CHECK_VERSION(3,0,0)
- m_aGraphics[i].pGraphics = new GtkSalGraphics( this, m_pWindow );
- if( !m_aFrame.get() )
- {
- AllocateFrame();
- TriggerPaintEvent();
- }
- m_aGraphics[i].pGraphics->setDevice( m_aFrame );
+ m_pGraphics = new GtkSalGraphics( this, m_pWindow );
+ if( !m_aFrame.get() )
+ {
+ AllocateFrame();
+ TriggerPaintEvent();
+ }
+ m_pGraphics->setDevice( m_aFrame );
#else // common case:
- m_aGraphics[i].pGraphics = new GtkSalGraphics( this, m_pWindow, m_nXScreen );
+ m_pGraphics = new GtkSalGraphics( this, m_pWindow, m_nXScreen );
#endif
- }
- return m_aGraphics[i].pGraphics;
- }
- }
}
-
- return nullptr;
+ m_bGraphics = true;
+ return m_pGraphics;
}
void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
{
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( m_aGraphics[i].pGraphics == pGraphics )
- {
- m_aGraphics[i].bInUse = false;
- break;
- }
- }
+ (void) pGraphics;
+ assert( pGraphics == m_pGraphics );
+ m_bGraphics = false;
}
bool GtkSalFrame::PostEvent(ImplSVEvent* pData)
@@ -1978,13 +1964,8 @@ void GtkSalFrame::AllocateFrame()
m_aFrame->clear( basebmp::Color( 255, 127, 0 ) );
#endif
- // update device in existing graphics
- for( unsigned int i = 0; i < SAL_N_ELEMENTS( m_aGraphics ); ++i )
- {
- if( !m_aGraphics[i].pGraphics )
- continue;
- m_aGraphics[i].pGraphics->setDevice( m_aFrame );
- }
+ if( m_pGraphics )
+ m_pGraphics->setDevice( m_aFrame );
}
#endif
}
@@ -2835,7 +2816,7 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
if( ! m_pWindow )
return;
- GtkSalGraphics* pGraphics = static_cast<GtkSalGraphics*>(m_aGraphics[0].pGraphics);
+ GtkSalGraphics* pGraphics = m_pGraphics;
bool bFreeGraphics = false;
if( ! pGraphics )
{
@@ -2914,9 +2895,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
}
// free xrender resources
- for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
- if( m_aGraphics[i].bInUse )
- m_aGraphics[i].pGraphics->SetDrawable( None, m_nXScreen );
+ if( m_pGraphics )
+ m_pGraphics->SetDrawable( None, m_nXScreen );
// first deinit frame
if( m_pIMHandler )
@@ -2957,13 +2937,10 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
}
// update graphics
- for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
+ if( m_pGraphics )
{
- if( m_aGraphics[i].bInUse )
- {
- m_aGraphics[i].pGraphics->SetDrawable( widget_get_xid(m_pWindow), m_nXScreen );
- m_aGraphics[i].pGraphics->SetWindow( m_pWindow );
- }
+ m_pGraphics->SetDrawable( widget_get_xid(m_pWindow), m_nXScreen );
+ m_pGraphics->SetWindow( m_pWindow );
}
if( ! m_aTitle.isEmpty() )