summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-12 12:45:36 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-11-13 07:54:14 +0100
commitf433825259731e6fd0bc666f4d22b2f31dc99fa9 (patch)
treead87450a3cb1d14154d03a89c1ab4d40a922ed5a /vcl
parent8fa5a65792dc109791cbfbf5b8674cd9b65159dd (diff)
vcl: Use single-buffer rendering and only flush when necessary
Change-Id: I832dd6f3647fbb423975fa928a5ec32447225e85
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/generic/genpspgraphics.h3
-rw-r--r--vcl/inc/headless/svpgdi.hxx3
-rw-r--r--vcl/inc/openglgdiimpl.hxx4
-rw-r--r--vcl/inc/quartz/salgdi.h3
-rw-r--r--vcl/inc/salgdi.hxx3
-rw-r--r--vcl/inc/salgdiimpl.hxx3
-rw-r--r--vcl/inc/unx/salgdi.h3
-rw-r--r--vcl/inc/win/salgdi.h3
-rw-r--r--vcl/opengl/gdiimpl.cxx21
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx1
-rw-r--r--vcl/source/outdev/outdev.cxx13
-rw-r--r--vcl/source/window/paint.cxx7
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.hxx3
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx9
-rw-r--r--vcl/win/source/gdi/gdiimpl.hxx3
-rw-r--r--vcl/win/source/gdi/salgdi.cxx9
16 files changed, 66 insertions, 25 deletions
diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h
index fb7169afa804..882e475c1cd5 100644
--- a/vcl/inc/generic/genpspgraphics.h
+++ b/vcl/inc/generic/genpspgraphics.h
@@ -193,7 +193,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
- virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+ virtual void BeginPaint() SAL_OVERRIDE { };
+ virtual void EndPaint() SAL_OVERRIDE { };
};
#endif // INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index cd5622f9aa20..9f2604f073c5 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -243,7 +243,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
- virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+ virtual void BeginPaint() SAL_OVERRIDE { };
+ virtual void EndPaint() SAL_OVERRIDE { };
#ifdef IOS
void SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, int = 0 );
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index f80c9699a403..3d1c585cb6ab 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -38,6 +38,7 @@ protected:
OpenGLContext maContext;
SalFrame* mpFrame;
SalVirtualDevice* mpVDev;
+ int mnPainting;
bool mbOffscreen;
GLuint mnFramebufferId;
@@ -285,7 +286,8 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
- virtual bool swapBuffers() SAL_OVERRIDE;
+ virtual void beginPaint() SAL_OVERRIDE;
+ virtual void endPaint() SAL_OVERRIDE;
private:
};
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index caab5774accd..6cc452674c01 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -394,7 +394,8 @@ public:
GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE;
- virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+ virtual void BeginPaint() SAL_OVERRIDE { };
+ virtual void EndPaint() SAL_OVERRIDE { };
private:
// differences between VCL, Quartz and kHiThemeOrientation coordinate systems
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index a3917bb3e78d..24534508b6c1 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -412,7 +412,8 @@ public:
sal_uInt8 nTransparency,
const OutputDevice *pOutDev );
- virtual bool SwapBuffers() = 0;
+ virtual void BeginPaint() = 0;
+ virtual void EndPaint() = 0;
virtual SystemGraphicsData GetGraphicsData() const = 0;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 4b4b7353df98..09ea28fdc92b 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -207,7 +207,8 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
- virtual bool swapBuffers() = 0;
+ virtual void beginPaint() = 0;
+ virtual void endPaint() = 0;
};
#endif
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 2546689b3618..e3d8a0c085f0 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -268,7 +268,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE;
- virtual bool SwapBuffers() SAL_OVERRIDE;
+ virtual void BeginPaint() SAL_OVERRIDE;
+ virtual void EndPaint() SAL_OVERRIDE;
// create a pixmap from a screen region
X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect );
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f09af2813e79..69ea4cfde2cb 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -397,7 +397,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const;
- virtual bool SwapBuffers() SAL_OVERRIDE;
+ virtual void BeginPaint() SAL_OVERRIDE;
+ virtual void EndPaint() SAL_OVERRIDE;
/// Update settings based on the platform values
static void updateSettingsNative( AllSettings& rSettings );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 1098b5872f29..2a6dcfc1c070 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -60,6 +60,7 @@
OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl()
: mpFrame(NULL)
+ , mnPainting(0)
, mbOffscreen(false)
, mnFramebufferId(0)
, mpOffscreenTex(nullptr)
@@ -104,7 +105,8 @@ void OpenGLSalGraphicsImpl::PostDraw()
{
if( mbOffscreen )
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-
+ if( mnPainting == 0 )
+ glFlush();
CHECK_GL_ERROR();
}
@@ -1343,10 +1345,21 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
return false;
}
-bool OpenGLSalGraphicsImpl::swapBuffers()
+void OpenGLSalGraphicsImpl::beginPaint()
{
- maContext.swapBuffers();
- return true;
+ mnPainting++;
+ SAL_INFO( "vcl.opengl", "BEGIN PAINT " << this );
+}
+
+void OpenGLSalGraphicsImpl::endPaint()
+{
+ mnPainting--;
+ SAL_INFO( "vcl.opengl", "END PAINT " << this );
+ if( mnPainting == 0 )
+ {
+ maContext.makeCurrent();
+ glFlush();
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 1fadd50c3e75..3ad99db6b67f 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -389,7 +389,6 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
- GLX_DOUBLEBUFFER,
None };
pVI = glXChooseVisual( pDisplay, nScreen, aAttrib );
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 5295fd49925c..af7d6431e57e 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -782,11 +782,16 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}
-bool OutputDevice::SwapBuffers()
+void OutputDevice::BeginPaint()
{
- if( !mpGraphics && !AcquireGraphics() )
- return false;
- return mpGraphics->SwapBuffers();
+ if( mpGraphics || AcquireGraphics() )
+ mpGraphics->BeginPaint();
+}
+
+void OutputDevice::EndPaint()
+{
+ if( mpGraphics || AcquireGraphics() )
+ mpGraphics->EndPaint();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index b3576db29689..4cdaf36f805d 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -120,8 +120,10 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion)
pWindowImpl->mnPaintFlags = 0;
if ( !pWindowImpl->maInvalidateRegion.IsEmpty() )
{
+ m_pWindow->BeginPaint();
m_pWindow->PushPaintHelper(this);
m_pWindow->Paint(m_aPaintRect);
+ m_pWindow->EndPaint();
}
}
@@ -277,9 +279,10 @@ void Window::ImplCallOverlapPaint()
{
// - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL)
// because we were called from the Sal layer
- ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
OutputDevice *pOutDev = GetOutDev();
- pOutDev->SwapBuffers();
+ pOutDev->BeginPaint();
+ ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
+ pOutDev->EndPaint();
}
}
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 5b0062c93949..fed9bc6b9a4b 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -267,7 +267,8 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
- virtual bool swapBuffers() SAL_OVERRIDE { return false; }
+ virtual void beginPaint() SAL_OVERRIDE { }
+ virtual void endPaint() SAL_OVERRIDE { }
public:
// implementation of X11GraphicsImpl
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 9609ec8543e4..62e8989d4839 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -471,9 +471,14 @@ bool X11SalGraphics::drawGradient(const tools::PolyPolygon& rPoly, const Gradien
return mpImpl->drawGradient(rPoly, rGradient);
}
-bool X11SalGraphics::SwapBuffers()
+void X11SalGraphics::BeginPaint()
{
- return mpImpl->swapBuffers();
+ return mpImpl->beginPaint();
+}
+
+void X11SalGraphics::EndPaint()
+{
+ return mpImpl->endPaint();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index 0159f7c831a1..b21f138c396d 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -217,7 +217,8 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon,
const Gradient& rGradient) SAL_OVERRIDE;
- virtual bool swapBuffers() SAL_OVERRIDE { return false; }
+ virtual void beginPaint() SAL_OVERRIDE { }
+ virtual void endPaint() SAL_OVERRIDE { }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 454348922048..6be65a2329c2 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -1027,9 +1027,14 @@ SystemGraphicsData WinSalGraphics::GetGraphicsData() const
return aRes;
}
-bool WinSalGraphics::SwapBuffers()
+void WinSalGraphics::BeginPaint()
{
- return mpImpl->swapBuffers();
+ return mpImpl->beginPaint();
+}
+
+void WinSalGraphics::EndPaint()
+{
+ return mpImpl->endPaint();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */