summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-11-28 16:39:26 +0100
committerDavid Tardon <dtardon@redhat.com>2016-11-28 17:25:58 +0100
commitc03090c97dddbeecf477b4832c3b0a78a68220a3 (patch)
tree7b5816094af85640391a9421d2160caf0698d824 /vcl
parent039261b3f63a8949fd0f20e7cb80d017f26c9f08 (diff)
don't leak impl. details
Also, returning std::unique_ptr<>& doesn't make any sense. Change-Id: Iefb2a0bfe614264bc7b5d15652fcc15243df3d06
Diffstat (limited to 'vcl')
-rw-r--r--vcl/opengl/gdiimpl.cxx48
-rw-r--r--vcl/opengl/program.cxx11
-rw-r--r--vcl/opengl/salbmp.cxx16
-rw-r--r--vcl/opengl/scale.cxx4
-rw-r--r--vcl/opengl/texture.cxx24
-rw-r--r--vcl/opengl/x11/gdiimpl.cxx2
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx2
7 files changed, 52 insertions, 55 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 58f03f32ba57..006b5c620453 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 692b61afb6d7..0dab8b02e1f6 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 9fb8c474818b..c36866045d0a 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 3e2b9d4127fc..3ffb6a34dd45 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 918dd80aa0e9..aff717dd8eb8 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 b4f87a3a92ef..82f8bc9f14bd 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 979e2bf32a98..f681dc21a4ec 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;
}