summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-11-13 14:31:09 +0000
committerMichael Meeks <michael.meeks@collabora.com>2015-12-04 01:53:13 +0000
commit437f36ea8687b79e773faa78159ce019f50ee308 (patch)
treeb96a39b1e5101c51237c89c1f1b3ecfed518fa8c
parentStep #2 - kill mbOffscreen. (diff)
downloadcore-437f36ea8687b79e773faa78159ce019f50ee308.tar.gz
core-437f36ea8687b79e773faa78159ce019f50ee308.zip
Stage #3 - first cut at flushing the whole buffer across ...
-rw-r--r--vcl/inc/openglgdiimpl.hxx4
-rw-r--r--vcl/inc/salgdi.hxx1
-rw-r--r--vcl/inc/salgdiimpl.hxx1
-rw-r--r--vcl/opengl/gdiimpl.cxx90
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx7
5 files changed, 95 insertions, 8 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 7ac3496e3508..418850bd20e4 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -160,6 +160,9 @@ protected:
/// retrieve the default context for offscreen rendering
static rtl::Reference<OpenGLContext> GetDefaultContext();
+ /// flush contents of the back-buffer to the screen & swap.
+ void FlushAndSwap();
+
/// create a new context for rendering to the underlying window
virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
@@ -346,6 +349,7 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override;
virtual OpenGLContext *beginPaint() override;
+ virtual void endPaint() override;
private:
};
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 98c3b8fa5c74..62f714f9d800 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -439,6 +439,7 @@ public:
const OutputDevice *pOutDev );
virtual OpenGLContext *BeginPaint() { return nullptr; }
+ virtual void EndPaint() { }
virtual SystemGraphicsData GetGraphicsData() const = 0;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 3324012dac29..1bef26beb57a 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -213,6 +213,7 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
virtual OpenGLContext *beginPaint() { return nullptr; }
+ virtual OpenGLContext *endPaint() { }
};
#endif
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 25cb53adf010..b1ee0ce886bc 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -133,6 +133,10 @@ void OpenGLSalGraphicsImpl::Init()
}
maOffscreenTex = OpenGLTexture();
}
+
+ if( mpWindowContext.is() )
+ mpWindowContext.reset();
+ mpWindowContext = CreateWinContext();
}
// Currently only used to get windows ordering right.
@@ -173,19 +177,13 @@ void OpenGLSalGraphicsImpl::PreDraw()
void OpenGLSalGraphicsImpl::PostDraw()
{
- if( mpContext->mnPainting == 0 )
- {
- if (!IsOffscreen()) ...
-#warning "Trigger re-rendering of the window if we have one"
- glFlush();
- }
if( mbUseScissor )
{
glDisable( GL_SCISSOR_TEST );
CHECK_GL_ERROR();
}
- if( mbUseStencil )
- {
+ if( mbUseStencil )
+ {
glDisable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
}
@@ -197,6 +195,16 @@ void OpenGLSalGraphicsImpl::PostDraw()
mProgramIsSolidColor = false;
#endif
}
+
+ if( mpContext->mnPainting == 0 )
+ {
+ if (!IsOffscreen())
+ {
+ SAL_DEBUG("PostDraw flush ?");
+ FlushAndSwap();
+ }
+ }
+
OpenGLZone::leave();
}
@@ -1864,10 +1872,76 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
{
+ SAL_DEBUG( "want to rid ourselves of this method" );
AcquireContext();
return mpContext.get();
}
+void OpenGLSalGraphicsImpl::FlushAndSwap()
+{
+ assert( !IsOffscreen() );
+ assert( mpContext.is() );
+
+ OpenGLZone aZone;
+
+// glFlush(); - not needed
+ mpWindowContext->makeCurrent();
+ CHECK_GL_ERROR();
+
+ mpWindowContext->AcquireDefaultFramebuffer();
+ CHECK_GL_ERROR();
+
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+ ImplInitClipRegion();
+ CHECK_GL_ERROR();
+
+ SalTwoRect aPosAry(0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
+ 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight());
+
+ OpenGLProgram *pProgram =
+ mpContext->UseProgram( "textureVertexShader", "textureFragmentShader", "" );
+
+ pProgram->SetTexture( "sampler", maOffscreenTex );
+
+ GLfloat aTexCoord[8];
+ maOffscreenTex.GetCoord( aTexCoord, rPosAry, false );
+ pProgram->SetTextureCoord( aTexCoord );
+
+ long nX1( rPosAry.mnDestX );
+ long nY1( rPosAry.mnDestY );
+ long nX2( nX1 + rPosAry.mnDestWidth );
+ long nY2( nY1 + rPosAry.mnDestHeight );
+ const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
+ { nX2, nY1 }, { nX2, nY2 }};
+
+ std::vector<GLfloat> aVertices(nPoints * 2);
+ sal_uInt32 i, j;
+
+ for( i = 0, j = 0; i < 4; i++, j += 2 )
+ {
+ aVertices[j] = GLfloat(aPoints[i].mnX);
+ aVertices[j+1] = GLfloat(aPoints[i].mnY);
+ }
+
+ pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
+ pProgram->SetVertices( &aVertices[0] );
+ glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+
+ pProgram->Clean();
+
+ mpContext->swapBuffers();
+}
+
+void OpenGLSalGraphicsImpl::endPaint()
+{
+ assert( !IsOffscreen() );
+
+ AcquireContext();
+ if( mpContext.is() &&
+ mpContext->mnPainting == 0 )
+ FlushAndSwap();
+}
+
bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
{
// so far a blunt heuristic: vcl uses shiny new contexts.
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index c7cbfa354d15..10875caae3dc 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -1089,6 +1089,7 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
if( pDev->mpGraphics || pDev->AcquireGraphics() )
{
OpenGLContext *pContext = pDev->mpGraphics->BeginPaint();
+/*
if( pContext )
{
assert( pContext->mnPainting >= 0 );
@@ -1096,6 +1097,7 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
pContext->acquire();
pHandle = static_cast<void *>( pContext );
}
+*/
}
}
@@ -1104,6 +1106,10 @@ OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
*/
void OutputDevice::PaintScope::flush()
{
+ if( pDev->mpGraphics || pDev->AcquireGraphics() )
+ pDev->mpGraphics->EndPaint();
+
+#if 0
if( pHandle )
{
OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
@@ -1120,6 +1126,7 @@ void OutputDevice::PaintScope::flush()
}
pContext->release();
}
+#endif
}
OutputDevice::PaintScope::~PaintScope()