[Libreoffice-commits] core.git: vcl/inc vcl/unx

Michael Meeks michael.meeks at collabora.com
Mon Nov 30 03:22:34 PST 2015


 vcl/inc/unx/gtk/gtkframe.hxx |   16 -------
 vcl/unx/gtk/gtksalframe.cxx  |   93 ++++++++++++++++---------------------------
 2 files changed, 37 insertions(+), 72 deletions(-)

New commits:
commit ef242ae01047f6b8a0a9012e4e40509dd1c03145
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 30 11:04:01 2015 +0000

    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 at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 472aae7..d1203a3 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 923581d..6da958d 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() )


More information about the Libreoffice-commits mailing list