[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/inc vcl/opengl vcl/source
David Tardon
dtardon at redhat.com
Mon Nov 28 16:28:40 UTC 2016
include/vcl/opengl/OpenGLContext.hxx | 4 +-
vcl/inc/opengl/RenderState.hxx | 2 -
vcl/opengl/gdiimpl.cxx | 48 +++++++++++++++++------------------
vcl/opengl/program.cxx | 11 +++-----
vcl/opengl/salbmp.cxx | 16 +++++------
vcl/opengl/scale.cxx | 4 +-
vcl/opengl/texture.cxx | 24 ++++++++---------
vcl/opengl/x11/gdiimpl.cxx | 2 -
vcl/source/opengl/OpenGLContext.cxx | 2 -
9 files changed, 54 insertions(+), 59 deletions(-)
New commits:
commit 83288089d5efd2cd1d5c76b05a4ba3f782641e88
Author: David Tardon <dtardon at redhat.com>
Date: Mon Nov 28 16:47:23 2016 +0100
tdf#104139 keep the current OpenGL state
This hopefully fixes tdf#104139, which I cannot reproduce on my system.
Change-Id: I903f479a1f401804481b9645c9377c4aaeec13f7
diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx
index 1f526ba..25dd837 100644
--- a/vcl/inc/opengl/RenderState.hxx
+++ b/vcl/inc/opengl/RenderState.hxx
@@ -22,8 +22,6 @@ protected:
GenericCapabilityState()
: mbTest(readState())
{
- if (mbTest)
- disable();
}
static bool readState()
commit c03090c97dddbeecf477b4832c3b0a78a68220a3
Author: David Tardon <dtardon at redhat.com>
Date: Mon Nov 28 16:39:26 2016 +0100
don't leak impl. details
Also, returning std::unique_ptr<>& doesn't make any sense.
Change-Id: Iefb2a0bfe614264bc7b5d15652fcc15243df3d06
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index e3e9ce0..e77a6e9 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -98,9 +98,9 @@ public:
OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
void UseNoProgram();
- std::unique_ptr<RenderState>& state()
+ RenderState& state()
{
- return mpRenderState;
+ return *mpRenderState;
}
OpenGLCapabilitySwitch& getOpenGLCapabilitySwitch()
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 58f03f3..006b5c6 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -215,7 +215,7 @@ void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
CheckOffscreenTexture();
CHECK_GL_ERROR();
- mpContext->state()->viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
+ mpContext->state().viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
ImplInitClipRegion();
CHECK_GL_ERROR();
@@ -290,8 +290,8 @@ void OpenGLSalGraphicsImpl::freeResources()
void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMask )
{
- mpContext->state()->scissor().disable();
- mpContext->state()->stencil().enable();
+ mpContext->state().scissor().disable();
+ mpContext->state().stencil().enable();
VCL_GL_INFO( "Adding complex clip / stencil" );
GLuint nStencil = maOffscreenTex.StencilId();
@@ -331,7 +331,7 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa
glStencilMask( 0x00 );
CHECK_GL_ERROR();
- mpContext->state()->stencil().disable();
+ mpContext->state().stencil().disable();
}
void OpenGLSalGraphicsImpl::ImplInitClipRegion()
@@ -349,23 +349,23 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion()
if (mbUseScissor)
{
Rectangle aRect(maClipRegion.GetBoundRect());
- mpContext->state()->scissor().set(aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth(), aRect.GetHeight());
- mpContext->state()->scissor().enable();
+ mpContext->state().scissor().set(aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth(), aRect.GetHeight());
+ mpContext->state().scissor().enable();
}
else
{
- mpContext->state()->scissor().disable();
+ mpContext->state().scissor().disable();
}
if (mbUseStencil)
{
glStencilFunc( GL_EQUAL, 1, 0x1 );
CHECK_GL_ERROR();
- mpContext->state()->stencil().enable();
+ mpContext->state().stencil().enable();
}
else
{
- mpContext->state()->stencil().disable();
+ mpContext->state().stencil().disable();
}
}
@@ -543,8 +543,8 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
// TODO: lfrb: User GL_ARB_copy_image?
OpenGLTexture aNewTex = OpenGLTexture( GetWidth(), GetHeight() );
- mpContext->state()->scissor().disable();
- mpContext->state()->stencil().disable();
+ mpContext->state().scissor().disable();
+ mpContext->state().stencil().disable();
mpContext->AcquireFramebuffer( aNewTex );
DrawTexture( maOffscreenTex, aPosAry );
@@ -1096,8 +1096,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture(
// The scissor area is set to the current window size in PreDraw,
// so if we do not disable the scissor test, the texture produced
// by the first downscaling is clipped to the current window size.
- mpContext->state()->scissor().disable();
- mpContext->state()->stencil().disable();
+ mpContext->state().scissor().disable();
+ mpContext->state().stencil().disable();
// the square root of the whole inverted scale ratio
double ixscalesqrt = std::floor(std::sqrt(ixscale));
@@ -1118,10 +1118,10 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture(
// Re-enable scissor and stencil tests if needed.
if (mbUseScissor)
- mpContext->state()->scissor().enable();
+ mpContext->state().scissor().enable();
if (mbUseStencil)
- mpContext->state()->stencil().enable();
+ mpContext->state().stencil().enable();
}
}
@@ -1985,14 +1985,14 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
ImplSetClipBit( vcl::Region( rPolyPoly ), 0x02 );
if( mbUseStencil )
{
- mpContext->state()->stencil().enable();
+ mpContext->state().stencil().enable();
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 3, 0xFF );
CHECK_GL_ERROR();
}
else
{
- mpContext->state()->stencil().enable();
+ mpContext->state().stencil().enable();
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 2, 0xFF );
CHECK_GL_ERROR();
@@ -2032,7 +2032,7 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
#if FIXME_BROKEN_STENCIL_FOR_GRADIENTS
if( !mbUseStencil )
{
- mpContext->state()->stencil().disable();
+ mpContext->state().stencil().disable();
CHECK_GL_ERROR();
}
#endif
@@ -2063,8 +2063,8 @@ void OpenGLSalGraphicsImpl::doFlush()
if (OpenGLContext::hasCurrent())
{
- mpContext->state()->scissor().disable();
- mpContext->state()->stencil().disable();
+ mpContext->state().scissor().disable();
+ mpContext->state().stencil().disable();
}
if( IsOffscreen() )
@@ -2108,10 +2108,10 @@ void OpenGLSalGraphicsImpl::doFlush()
CHECK_GL_ERROR();
- mpWindowContext->state()->sync();
- mpWindowContext->state()->viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
- mpWindowContext->state()->scissor().disable();
- mpWindowContext->state()->stencil().disable();
+ mpWindowContext->state().sync();
+ mpWindowContext->state().viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
+ mpWindowContext->state().scissor().disable();
+ mpWindowContext->state().stencil().disable();
#if OSL_DEBUG_LEVEL > 0 // random background glClear
glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX,
diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx
index 692b61a..0dab8b0 100644
--- a/vcl/opengl/program.cxx
+++ b/vcl/opengl/program.cxx
@@ -185,7 +185,7 @@ GLuint OpenGLProgram::GetUniformLocation( const OString& rName )
void OpenGLProgram::DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices)
{
if (!mbBlending)
- OpenGLContext::getVCLContext()->state()->blend().disable();
+ OpenGLContext::getVCLContext()->state().blend().disable();
SetVertices(aVertices.data());
glDrawArrays(aMode, 0, aVertices.size() / 2);
@@ -194,7 +194,7 @@ void OpenGLProgram::DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices)
void OpenGLProgram::DrawElements(GLenum aMode, GLuint nNumberOfVertices)
{
if (!mbBlending)
- OpenGLContext::getVCLContext()->state()->blend().disable();
+ OpenGLContext::getVCLContext()->state().blend().disable();
glDrawElements(aMode, nNumberOfVertices, GL_UNSIGNED_INT, nullptr);
}
@@ -295,8 +295,7 @@ void OpenGLProgram::SetTexture( const OString& rName, OpenGLTexture& rTexture )
glUniform1i( nUniform, nIndex );
CHECK_GL_ERROR();
- std::unique_ptr<RenderState>& rState = OpenGLContext::getVCLContext()->state();
- rState->texture().active(nIndex);
+ OpenGLContext::getVCLContext()->state().texture().active(nIndex);
rTexture.Bind();
maTextures.push_back(rTexture);
@@ -359,8 +358,8 @@ void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset)
void OpenGLProgram::SetBlendMode(GLenum nSFactor, GLenum nDFactor)
{
- OpenGLContext::getVCLContext()->state()->blend().enable();
- OpenGLContext::getVCLContext()->state()->blend().func(nSFactor, nDFactor);
+ OpenGLContext::getVCLContext()->state().blend().enable();
+ OpenGLContext::getVCLContext()->state().blend().func(nSFactor, nDFactor);
mbBlending = true;
}
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 9fb8c47..c3686604 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -549,8 +549,8 @@ bool OpenGLSalBitmap::ReadTexture()
OpenGLVCLContextZone aContextZone;
rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext();
- xContext->state()->scissor().disable();
- xContext->state()->stencil().disable();
+ xContext->state().scissor().disable();
+ xContext->state().stencil().disable();
if (mnBits == 8 || mnBits == 16 || mnBits == 24 || mnBits == 32)
{
@@ -632,8 +632,8 @@ bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType&
OUString FragShader("areaHashCRC64TFragmentShader");
rtl::Reference< OpenGLContext > xContext = OpenGLContext::getVCLContext();
- xContext->state()->scissor().disable();
- xContext->state()->stencil().disable();
+ xContext->state().scissor().disable();
+ xContext->state().stencil().disable();
static vcl::DeleteOnDeinit<OpenGLTexture> gCRCTableTexture(
new OpenGLTexture(512, 1, GL_RGBA, GL_UNSIGNED_BYTE,
@@ -864,8 +864,8 @@ bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceC
OpenGLZone aZone;
rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext();
- xContext->state()->scissor().disable();
- xContext->state()->stencil().disable();
+ xContext->state().scissor().disable();
+ xContext->state().stencil().disable();
OpenGLFramebuffer* pFramebuffer;
OpenGLProgram* pProgram;
@@ -904,8 +904,8 @@ bool OpenGLSalBitmap::ConvertToGreyscale()
OpenGLZone aZone;
rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext();
- xContext->state()->scissor().disable();
- xContext->state()->stencil().disable();
+ xContext->state().scissor().disable();
+ xContext->state().stencil().disable();
OpenGLFramebuffer* pFramebuffer;
OpenGLProgram* pProgram;
diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx
index 3e2b9d4..3ffb6a3 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -334,8 +334,8 @@ bool OpenGLSalBitmap::ImplScale( const double& rScaleX, const double& rScaleY, B
mpUserBuffer.reset();
OpenGLVCLContextZone aContextZone;
rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext();
- xContext->state()->scissor().disable();
- xContext->state()->stencil().disable();
+ xContext->state().scissor().disable();
+ xContext->state().stencil().disable();
if (rScaleX <= 1 && rScaleY <= 1)
{
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 918dd80..aff717d 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -50,8 +50,8 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate )
auto& rState = OpenGLContext::getVCLContext()->state();
TextureState::generate(mnTexture);
- rState->texture().active(0);
- rState->texture().bind(mnTexture);
+ rState.texture().active(0);
+ rState.texture().bind(mnTexture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
@@ -85,8 +85,8 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight )
auto& rState = OpenGLContext::getVCLContext()->state();
TextureState::generate(mnTexture);
- rState->texture().active(0);
- rState->texture().bind(mnTexture);
+ rState.texture().active(0);
+ rState.texture().bind(mnTexture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
@@ -114,8 +114,8 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int
auto& rState = OpenGLContext::getVCLContext()->state();
TextureState::generate(mnTexture);
- rState->texture().active(0);
- rState->texture().bind(mnTexture);
+ rState.texture().active(0);
+ rState.texture().bind(mnTexture);
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
CHECK_GL_ERROR();
@@ -179,7 +179,7 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
mnOptStencil = 0;
}
auto& rState = pContext->state();
- rState->texture().unbindAndDelete(mnTexture);
+ rState.texture().unbindAndDelete(mnTexture);
mnTexture = 0;
}
else
@@ -196,8 +196,8 @@ bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, in
return false;
rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext();
- xContext->state()->texture().active(0);
- xContext->state()->texture().bind(mnTexture);
+ xContext->state().texture().active(0);
+ xContext->state().texture().bind(mnTexture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
CHECK_GL_ERROR();
@@ -482,8 +482,7 @@ void OpenGLTexture::Bind()
{
if (IsValid())
{
- std::unique_ptr<RenderState>& rState = OpenGLContext::getVCLContext()->state();
- rState->texture().bind(mpImpl->mnTexture);
+ OpenGLContext::getVCLContext()->state().texture().bind(mpImpl->mnTexture);
}
else
VCL_GL_INFO( "OpenGLTexture::Binding invalid texture" );
@@ -495,8 +494,7 @@ void OpenGLTexture::Unbind()
{
if (IsValid())
{
- std::unique_ptr<RenderState>& rState = OpenGLContext::getVCLContext()->state();
- rState->texture().unbind(mpImpl->mnTexture);
+ OpenGLContext::getVCLContext()->state().texture().unbind(mpImpl->mnTexture);
}
}
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index b4f87a3..82f8bc9 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -774,7 +774,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask
rCombo.mpTexture.reset(new OpenGLTexture(pPixmap->GetWidth(), pPixmap->GetHeight(), false));
- mpContext->state()->texture().active(0);
+ mpContext->state().texture().active(0);
rCombo.mpTexture->Bind();
glXBindTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT, nullptr );
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 979e2bf..f681dc2 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -707,7 +707,7 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText
BindFramebuffer( pFramebuffer );
pFramebuffer->AttachTexture( rTexture );
- state()->viewport(Rectangle(Point(), Size(rTexture.GetWidth(), rTexture.GetHeight())));
+ state().viewport(Rectangle(Point(), Size(rTexture.GetWidth(), rTexture.GetHeight())));
return pFramebuffer;
}
More information about the Libreoffice-commits
mailing list