Kaydet (Commit) 555e1ff4 authored tarafından Caolán McNamara's avatar Caolán McNamara

bubble the original gtk surface type through rendering

this may make scrolling a tad faster

Change-Id: I0c2cc9df85932e25dbfed88727d3b83d299671c7
üst f9d0f55b
...@@ -150,7 +150,7 @@ SalGraphics* SvpSalFrame::AcquireGraphics() ...@@ -150,7 +150,7 @@ SalGraphics* SvpSalFrame::AcquireGraphics()
{ {
SvpSalGraphics* pGraphics = new SvpSalGraphics(); SvpSalGraphics* pGraphics = new SvpSalGraphics();
#ifndef IOS #ifndef IOS
pGraphics->setSurface( m_pSurface ); pGraphics->setSurface(m_pSurface, B2IVector(maGeometry.nWidth, maGeometry.nHeight));
#endif #endif
m_aGraphics.push_back( pGraphics ); m_aGraphics.push_back( pGraphics );
return pGraphics; return pGraphics;
...@@ -281,7 +281,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u ...@@ -281,7 +281,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
it != m_aGraphics.end(); ++it ) it != m_aGraphics.end(); ++it )
{ {
(*it)->setSurface(m_pSurface); (*it)->setSurface(m_pSurface, aFrameSize);
} }
} }
if( m_bVisible ) if( m_bVisible )
......
This diff is collapsed.
...@@ -38,7 +38,7 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice() ...@@ -38,7 +38,7 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice()
SalGraphics* SvpSalVirtualDevice::AcquireGraphics() SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
{ {
SvpSalGraphics* pGraphics = new SvpSalGraphics(); SvpSalGraphics* pGraphics = new SvpSalGraphics();
pGraphics->setSurface(m_pSurface); pGraphics->setSurface(m_pSurface, m_aFrameSize);
m_aGraphics.push_back( pGraphics ); m_aGraphics.push_back( pGraphics );
return pGraphics; return pGraphics;
} }
...@@ -62,12 +62,14 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, ...@@ -62,12 +62,14 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
if (nNewDY == 0) if (nNewDY == 0)
nNewDY = 1; nNewDY = 1;
nNewDX *= m_fScale; if (!m_pSurface || m_aFrameSize.getX() != nNewDX ||
nNewDY *= m_fScale; m_aFrameSize.getY() != nNewDY )
if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != nNewDX ||
cairo_image_surface_get_height(m_pSurface) != nNewDY )
{ {
m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
nNewDX *= m_fScale;
nNewDY *= m_fScale;
if (m_pSurface) if (m_pSurface)
{ {
cairo_surface_destroy(m_pSurface); cairo_surface_destroy(m_pSurface);
...@@ -96,20 +98,19 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, ...@@ -96,20 +98,19 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
// update device in existing graphics // update device in existing graphics
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
it != m_aGraphics.end(); ++it ) it != m_aGraphics.end(); ++it )
(*it)->setSurface(m_pSurface); (*it)->setSurface(m_pSurface, m_aFrameSize);
} }
return true; return true;
} }
long SvpSalVirtualDevice::GetWidth() const long SvpSalVirtualDevice::GetWidth() const
{ {
return m_pSurface ? cairo_image_surface_get_width(m_pSurface) : 0; return m_pSurface ? m_aFrameSize.getX() : 0;
} }
long SvpSalVirtualDevice::GetHeight() const long SvpSalVirtualDevice::GetHeight() const
{ {
return m_pSurface ? cairo_image_surface_get_height(m_pSurface) : 0; return m_pSurface ? m_aFrameSize.getY() : 0;
} }
#endif #endif
......
...@@ -80,6 +80,7 @@ struct VCL_DLLPUBLIC DamageHandler ...@@ -80,6 +80,7 @@ struct VCL_DLLPUBLIC DamageHandler
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
{ {
cairo_surface_t* m_pSurface; cairo_surface_t* m_pSurface;
basegfx::B2IVector m_aFrameSize;
double m_fScale; double m_fScale;
SalColor m_aLineColor; SalColor m_aLineColor;
SalColor m_aFillColor; SalColor m_aFillColor;
...@@ -87,7 +88,7 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics ...@@ -87,7 +88,7 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
public: public:
static GlyphCache& getPlatformGlyphCache(); static GlyphCache& getPlatformGlyphCache();
void setSurface(cairo_surface_t* pSurface); void setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize);
static cairo_user_data_key_t* getDamageKey(); static cairo_user_data_key_t* getDamageKey();
private: private:
...@@ -115,6 +116,8 @@ protected: ...@@ -115,6 +116,8 @@ protected:
const SalBitmap* pAlphaBitmap) override; const SalBitmap* pAlphaBitmap) override;
virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) override; virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) override;
cairo_t* createTmpCompatibleCairoContext() const;
public: public:
SvpSalGraphics(); SvpSalGraphics();
virtual ~SvpSalGraphics() override; virtual ~SvpSalGraphics() override;
......
...@@ -31,6 +31,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice ...@@ -31,6 +31,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
{ {
DeviceFormat m_eFormat; DeviceFormat m_eFormat;
cairo_surface_t* m_pSurface; cairo_surface_t* m_pSurface;
basegfx::B2IVector m_aFrameSize;
double m_fScale; double m_fScale;
std::list< SvpSalGraphics* > m_aGraphics; std::list< SvpSalGraphics* > m_aGraphics;
......
...@@ -246,6 +246,7 @@ class GtkSalFrame : public SalFrame ...@@ -246,6 +246,7 @@ class GtkSalFrame : public SalFrame
#endif #endif
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer ); static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
static void signalRealize(GtkWidget*, gpointer frame);
static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame); static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y, static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
gboolean keyboard_mode, GtkTooltip *tooltip, gboolean keyboard_mode, GtkTooltip *tooltip,
...@@ -346,6 +347,7 @@ class GtkSalFrame : public SalFrame ...@@ -346,6 +347,7 @@ class GtkSalFrame : public SalFrame
public: public:
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
cairo_surface_t* m_pSurface; cairo_surface_t* m_pSurface;
basegfx::B2IVector m_aFrameSize;
DamageHandler m_aDamageHandler; DamageHandler m_aDamageHandler;
int m_nGrabLevel; int m_nGrabLevel;
bool m_bSalObjectSetPosSize; bool m_bSalObjectSetPosSize;
......
...@@ -1039,6 +1039,7 @@ void GtkSalFrame::InitCommon() ...@@ -1039,6 +1039,7 @@ void GtkSalFrame::InitCommon()
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "scroll-event", G_CALLBACK(signalScroll), this )); 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), "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 ); g_signal_connect( G_OBJECT(m_pFixedContainer), "size-allocate", G_CALLBACK(sizeAllocated), this );
#if GTK_CHECK_VERSION(3,14,0) #if GTK_CHECK_VERSION(3,14,0)
GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget); GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget);
...@@ -1335,7 +1336,7 @@ SalGraphics* GtkSalFrame::AcquireGraphics() ...@@ -1335,7 +1336,7 @@ SalGraphics* GtkSalFrame::AcquireGraphics()
AllocateFrame(); AllocateFrame();
TriggerPaintEvent(); TriggerPaintEvent();
} }
m_pGraphics->setSurface(m_pSurface); m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
} }
m_bGraphics = true; m_bGraphics = true;
return m_pGraphics; return m_pGraphics;
...@@ -1562,13 +1563,11 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight ) ...@@ -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() void GtkSalFrame::AllocateFrame()
{ {
basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight ); basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != aFrameSize.getX() || if (!m_pSurface || m_aFrameSize.getX() != aFrameSize.getX() ||
cairo_image_surface_get_height(m_pSurface) != aFrameSize.getY() ) m_aFrameSize.getY() != aFrameSize.getY() )
{ {
if( aFrameSize.getX() == 0 ) if( aFrameSize.getX() == 0 )
aFrameSize.setX( 1 ); aFrameSize.setX( 1 );
...@@ -1578,30 +1577,17 @@ void GtkSalFrame::AllocateFrame() ...@@ -1578,30 +1577,17 @@ void GtkSalFrame::AllocateFrame()
if (m_pSurface) if (m_pSurface)
cairo_surface_destroy(m_pSurface); cairo_surface_destroy(m_pSurface);
#if GTK_CHECK_VERSION(3,10,0) m_pSurface = gdk_window_create_similar_surface(widget_get_window(m_pWindow),
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) CAIRO_CONTENT_COLOR_ALPHA,
int scale = gtk_widget_get_scale_factor(m_pWindow); aFrameSize.getX(),
#else aFrameSize.getY());
int scale = 1; m_aFrameSize = aFrameSize;
#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
cairo_surface_set_user_data(m_pSurface, SvpSalGraphics::getDamageKey(), &m_aDamageHandler, nullptr); 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); SAL_INFO("vcl.gtk3", "allocated Frame size of " << maGeometry.nWidth << " x " << maGeometry.nHeight);
if (m_pGraphics) 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) ...@@ -2889,13 +2875,23 @@ gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
return false; 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); GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
pThis->maGeometry.nWidth = pAllocation->width; pThis->maGeometry.nWidth = pAllocation->width;
pThis->maGeometry.nHeight = pAllocation->height; pThis->maGeometry.nHeight = pAllocation->height;
pThis->AllocateFrame(); bool bRealized = gtk_widget_get_realized(pWidget);
if (bRealized)
pThis->AllocateFrame();
pThis->CallCallbackExc( SalEvent::Resize, nullptr ); 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) if (pThis->m_bSalObjectSetPosSize)
return; return;
pThis->TriggerPaintEvent(); pThis->TriggerPaintEvent();
......
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