summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-04 21:14:59 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-07 13:07:57 +0000
commit7863798f2ab420fdb91ba3dcda6cea2ab2aded9d (patch)
tree32ec8459ffd30c04b18c48d0c2374344ad7ebbec /vcl/unx/gtk3
parent5ddf5d8dc60cdc44515e5f551bf1a61a4f1e62bc (diff)
bubble the original gtk surface type through rendering
this may make scrolling a tad faster Change-Id: I5f11f9b3196c3d42c82ac03bc332ef84189f3737
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx50
1 files changed, 23 insertions, 27 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index a74555f23531..e2d19fe6ffb8 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -1039,6 +1039,7 @@ void GtkSalFrame::InitCommon()
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "scroll-event", G_CALLBACK(signalScroll), this ));
g_signal_connect( G_OBJECT(m_pFixedContainer), "draw", G_CALLBACK(signalDraw), this );
+ g_signal_connect( G_OBJECT(m_pFixedContainer), "realize", G_CALLBACK(signalRealize), this );
g_signal_connect( G_OBJECT(m_pFixedContainer), "size-allocate", G_CALLBACK(sizeAllocated), this );
#if GTK_CHECK_VERSION(3,14,0)
GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget);
@@ -1335,7 +1336,7 @@ SalGraphics* GtkSalFrame::AcquireGraphics()
AllocateFrame();
TriggerPaintEvent();
}
- m_pGraphics->setSurface(m_pSurface);
+ m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
}
m_bGraphics = true;
return m_pGraphics;
@@ -1562,13 +1563,11 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight )
}
}
-// FIXME: we should really be an SvpSalFrame sub-class, and
-// share their AllocateFrame !
void GtkSalFrame::AllocateFrame()
{
basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
- if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != aFrameSize.getX() ||
- cairo_image_surface_get_height(m_pSurface) != aFrameSize.getY() )
+ if (!m_pSurface || m_aFrameSize.getX() != aFrameSize.getX() ||
+ m_aFrameSize.getY() != aFrameSize.getY() )
{
if( aFrameSize.getX() == 0 )
aFrameSize.setX( 1 );
@@ -1578,30 +1577,17 @@ void GtkSalFrame::AllocateFrame()
if (m_pSurface)
cairo_surface_destroy(m_pSurface);
-#if GTK_CHECK_VERSION(3,10,0)
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- int scale = gtk_widget_get_scale_factor(m_pWindow);
-#else
- int scale = 1;
-#endif
- m_pSurface = gdk_window_create_similar_image_surface(widget_get_window(m_pWindow),
- CAIRO_FORMAT_ARGB32,
- aFrameSize.getX() * scale,
- aFrameSize.getY() * scale,
- scale);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- cairo_surface_set_device_scale(m_pSurface, scale, scale);
-#endif
-#else
- m_pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- aFrameSize.getX(),
- aFrameSize.getY());
-#endif
+ m_pSurface = gdk_window_create_similar_surface(widget_get_window(m_pWindow),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ aFrameSize.getX(),
+ aFrameSize.getY());
+ m_aFrameSize = aFrameSize;
+
cairo_surface_set_user_data(m_pSurface, SvpSalGraphics::getDamageKey(), &m_aDamageHandler, nullptr);
SAL_INFO("vcl.gtk3", "allocated Frame size of " << maGeometry.nWidth << " x " << maGeometry.nHeight);
if (m_pGraphics)
- m_pGraphics->setSurface(m_pSurface);
+ m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
}
}
@@ -2889,13 +2875,23 @@ gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
return false;
}
-void GtkSalFrame::sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame)
+void GtkSalFrame::sizeAllocated(GtkWidget* pWidget, GdkRectangle *pAllocation, gpointer frame)
{
GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
pThis->maGeometry.nWidth = pAllocation->width;
pThis->maGeometry.nHeight = pAllocation->height;
- pThis->AllocateFrame();
+ bool bRealized = gtk_widget_get_realized(pWidget);
+ if (bRealized)
+ pThis->AllocateFrame();
pThis->CallCallbackExc( SalEvent::Resize, nullptr );
+ if (bRealized && !pThis->m_bSalObjectSetPosSize)
+ pThis->TriggerPaintEvent();
+}
+
+void GtkSalFrame::signalRealize(GtkWidget*, gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ pThis->AllocateFrame();
if (pThis->m_bSalObjectSetPosSize)
return;
pThis->TriggerPaintEvent();