Kaydet (Commit) ef242ae0 authored tarafından Michael Meeks's avatar Michael Meeks

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/20283Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 268e4e90
...@@ -62,19 +62,6 @@ typedef ::Window GdkNativeWindow; ...@@ -62,19 +62,6 @@ typedef ::Window GdkNativeWindow;
class GtkSalFrame : public SalFrame, public X11WindowProvider 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 struct IMHandler
{ {
...@@ -187,7 +174,8 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider ...@@ -187,7 +174,8 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
std::list< GtkSalFrame* > m_aChildren; std::list< GtkSalFrame* > m_aChildren;
GdkWindowState m_nState; GdkWindowState m_nState;
SystemEnvData m_aSystemData; SystemEnvData m_aSystemData;
GraphicsHolder m_aGraphics[ nMaxGraphics ]; GtkSalGraphics *m_pGraphics;
bool m_bGraphics;
sal_uInt16 m_nKeyModifiers; sal_uInt16 m_nKeyModifiers;
GdkCursor *m_pCurrentCursor; GdkCursor *m_pCurrentCursor;
GdkVisibilityState m_nVisibility; GdkVisibilityState m_nVisibility;
......
...@@ -492,11 +492,6 @@ void GtkSalFrame::doKeyCallback( guint state, ...@@ -492,11 +492,6 @@ void GtkSalFrame::doKeyCallback( guint state,
CallCallback( SALEVENT_KEYUP, &aEvent ); CallCallback( SALEVENT_KEYUP, &aEvent );
} }
GtkSalFrame::GraphicsHolder::~GraphicsHolder()
{
delete pGraphics;
}
GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
: m_nXScreen( getDisplay()->GetDefaultXScreen() ) : m_nXScreen( getDisplay()->GetDefaultXScreen() )
{ {
...@@ -845,15 +840,13 @@ void GtkSalFrame::EnsureAppMenuWatch() ...@@ -845,15 +840,13 @@ void GtkSalFrame::EnsureAppMenuWatch()
void GtkSalFrame::InvalidateGraphics() 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) #if !GTK_CHECK_VERSION(3,0,0)
m_aGraphics[i].pGraphics->SetDrawable( None, m_nXScreen ); m_pGraphics->SetDrawable( None, m_nXScreen );
m_aGraphics[i].pGraphics->SetWindow(nullptr); m_pGraphics->SetWindow(nullptr);
#endif #endif
m_aGraphics[i].bInUse = false; m_bGraphics = false;
} }
} }
...@@ -926,6 +919,9 @@ GtkSalFrame::~GtkSalFrame() ...@@ -926,6 +919,9 @@ GtkSalFrame::~GtkSalFrame()
g_object_unref( G_OBJECT( m_pForeignParent ) ); g_object_unref( G_OBJECT( m_pForeignParent ) );
if( m_pForeignTopLevel ) if( m_pForeignTopLevel )
g_object_unref( G_OBJECT( m_pForeignTopLevel) ); g_object_unref( G_OBJECT( m_pForeignTopLevel) );
delete m_pGraphics;
m_pGraphics = NULL;
} }
void GtkSalFrame::moveWindow( long nX, long nY ) void GtkSalFrame::moveWindow( long nX, long nY )
...@@ -1172,6 +1168,9 @@ void GtkSalFrame::InitCommon() ...@@ -1172,6 +1168,9 @@ void GtkSalFrame::InitCommon()
m_aSystemData.pAppContext = nullptr; m_aSystemData.pAppContext = nullptr;
m_aSystemData.pShellWidget = m_aSystemData.pWidget; m_aSystemData.pShellWidget = m_aSystemData.pWidget;
m_bGraphics = false;
m_pGraphics = NULL;
// fake an initial geometry, gets updated via configure event or SetPosSize // fake an initial geometry, gets updated via configure event or SetPosSize
if( m_bDefaultPos || m_bDefaultSize ) if( m_bDefaultPos || m_bDefaultSize )
{ {
...@@ -1596,45 +1595,32 @@ void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) ...@@ -1596,45 +1595,32 @@ void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
SalGraphics* GtkSalFrame::AcquireGraphics() 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) #if GTK_CHECK_VERSION(3,0,0)
m_aGraphics[i].pGraphics = new GtkSalGraphics( this, m_pWindow ); m_pGraphics = new GtkSalGraphics( this, m_pWindow );
if( !m_aFrame.get() ) if( !m_aFrame.get() )
{ {
AllocateFrame(); AllocateFrame();
TriggerPaintEvent(); TriggerPaintEvent();
} }
m_aGraphics[i].pGraphics->setDevice( m_aFrame ); m_pGraphics->setDevice( m_aFrame );
#else // common case: #else // common case:
m_aGraphics[i].pGraphics = new GtkSalGraphics( this, m_pWindow, m_nXScreen ); m_pGraphics = new GtkSalGraphics( this, m_pWindow, m_nXScreen );
#endif #endif
}
return m_aGraphics[i].pGraphics;
}
}
} }
m_bGraphics = true;
return nullptr; return m_pGraphics;
} }
void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics ) void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
{ {
for( int i = 0; i < nMaxGraphics; i++ ) (void) pGraphics;
{ assert( pGraphics == m_pGraphics );
if( m_aGraphics[i].pGraphics == pGraphics ) m_bGraphics = false;
{
m_aGraphics[i].bInUse = false;
break;
}
}
} }
bool GtkSalFrame::PostEvent(ImplSVEvent* pData) bool GtkSalFrame::PostEvent(ImplSVEvent* pData)
...@@ -1978,13 +1964,8 @@ void GtkSalFrame::AllocateFrame() ...@@ -1978,13 +1964,8 @@ void GtkSalFrame::AllocateFrame()
m_aFrame->clear( basebmp::Color( 255, 127, 0 ) ); m_aFrame->clear( basebmp::Color( 255, 127, 0 ) );
#endif #endif
// update device in existing graphics if( m_pGraphics )
for( unsigned int i = 0; i < SAL_N_ELEMENTS( m_aGraphics ); ++i ) m_pGraphics->setDevice( m_aFrame );
{
if( !m_aGraphics[i].pGraphics )
continue;
m_aGraphics[i].pGraphics->setDevice( m_aFrame );
}
} }
#endif #endif
} }
...@@ -2835,7 +2816,7 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings ) ...@@ -2835,7 +2816,7 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
if( ! m_pWindow ) if( ! m_pWindow )
return; return;
GtkSalGraphics* pGraphics = static_cast<GtkSalGraphics*>(m_aGraphics[0].pGraphics); GtkSalGraphics* pGraphics = m_pGraphics;
bool bFreeGraphics = false; bool bFreeGraphics = false;
if( ! pGraphics ) if( ! pGraphics )
{ {
...@@ -2914,9 +2895,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre ...@@ -2914,9 +2895,8 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
} }
// free xrender resources // free xrender resources
for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ ) if( m_pGraphics )
if( m_aGraphics[i].bInUse ) m_pGraphics->SetDrawable( None, m_nXScreen );
m_aGraphics[i].pGraphics->SetDrawable( None, m_nXScreen );
// first deinit frame // first deinit frame
if( m_pIMHandler ) if( m_pIMHandler )
...@@ -2957,13 +2937,10 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre ...@@ -2957,13 +2937,10 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre
} }
// update graphics // update graphics
for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ ) if( m_pGraphics )
{ {
if( m_aGraphics[i].bInUse ) m_pGraphics->SetDrawable( widget_get_xid(m_pWindow), m_nXScreen );
{ m_pGraphics->SetWindow( m_pWindow );
m_aGraphics[i].pGraphics->SetDrawable( widget_get_xid(m_pWindow), m_nXScreen );
m_aGraphics[i].pGraphics->SetWindow( m_pWindow );
}
} }
if( ! m_aTitle.isEmpty() ) if( ! m_aTitle.isEmpty() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment