[Libreoffice-commits] core.git: Branch 'feature/fixes19' - 2 commits - vcl/inc vcl/opengl
Tomaz Vajngerl
tomaz.vajngerl at collabora.com
Wed Apr 6 05:18:54 UTC 2016
vcl/inc/openglgdiimpl.hxx | 5 ++++-
vcl/opengl/gdiimpl.cxx | 34 ++++++++++++++++++++++++----------
vcl/opengl/texture.cxx | 15 ++++++++++++---
3 files changed, 40 insertions(+), 14 deletions(-)
New commits:
commit f80c2dd03d9d18c06ea0a9763ca59aeb1d2ed0e5
Author: Tomaz Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Apr 6 07:14:43 2016 +0200
opengl: use GL_BGRA as default backend format on WNT
Change-Id: Iccc4270b2df87c0c44c133732b6cf05448dfe7d3
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 1f270bc..0a83661 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -30,6 +30,15 @@
#include "opengl/texture.hxx"
#include "opengl/zone.hxx"
+namespace
+{
+#ifdef WNT
+const GLenum constDefaultBackendFormat = GL_RGBA;
+#else
+const GLenum constDefaultBackendFormat = GL_BGRA;
+#endif
+} // end anonymous namespace
+
// texture with allocated size
ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate ) :
mnRefCount( 1 ),
@@ -55,7 +64,7 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate )
CHECK_GL_ERROR();
if( bAllocate )
{
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr );
+ glTexImage2D( GL_TEXTURE_2D, 0, constDefaultBackendFormat, nWidth, nHeight, 0, constDefaultBackendFormat, GL_UNSIGNED_BYTE, nullptr );
CHECK_GL_ERROR();
}
glBindTexture( GL_TEXTURE_2D, 0 );
@@ -91,7 +100,7 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight )
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
- glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nX, nY, nWidth, nHeight, 0 );
+ glCopyTexImage2D( GL_TEXTURE_2D, 0, constDefaultBackendFormat, nX, nY, nWidth, nHeight, 0 );
CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
@@ -128,7 +137,7 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, mnWidth, mnHeight, 0, nFormat, nType, pData );
+ glTexImage2D( GL_TEXTURE_2D, 0, constDefaultBackendFormat, mnWidth, mnHeight, 0, nFormat, nType, pData );
CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
commit c71c18a8e9ea45b1dafe4c2218c69e0928be9bc5
Author: Tomaz Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Apr 6 07:13:37 2016 +0200
opengl: fix wrong clipping when drawing text
Change-Id: Icc953510f7111f630764486e1ca159c965b534e8
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index dc0cdc2..6dfa73c 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -148,7 +148,7 @@ public:
void DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect );
void DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect );
void DeferredTextDraw(OpenGLTexture& rTexture, const SalColor nMaskColor, const SalTwoRect& rPosAry);
- void FlushDeferredDrawing(bool bInDraw = false);
+ void FlushDeferredDrawing();
public:
// get the width of the device
@@ -169,6 +169,9 @@ public:
// operations to do before painting
void PreDraw(XOROption eOpt = IGNORE_XOR);
+ // initialize pre-draw state
+ void InitializePreDrawState(XOROption eOpt = IGNORE_XOR);
+
// operations to do after painting
void PostDraw();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index dae26d6..c403d1f 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -185,6 +185,13 @@ void OpenGLSalGraphicsImpl::DeInit()
void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
{
+ FlushDeferredDrawing();
+
+ InitializePreDrawState(eOpt);
+}
+
+void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
+{
OpenGLZone::enter();
mnDrawCount++;
@@ -204,8 +211,6 @@ void OpenGLSalGraphicsImpl::PreDraw(XOROption eOpt)
glViewport( 0, 0, GetWidth(), GetHeight() );
CHECK_GL_ERROR();
- FlushDeferredDrawing(true);
-
ImplInitClipRegion();
CHECK_GL_ERROR();
@@ -266,6 +271,7 @@ void OpenGLSalGraphicsImpl::freeResources()
{
VCL_GL_INFO( "freeResources" );
mpContext->makeCurrent();
+ FlushDeferredDrawing();
mpContext->ReleaseFramebuffer( maOffscreenTex );
}
ReleaseContext();
@@ -355,12 +361,16 @@ const vcl::Region& OpenGLSalGraphicsImpl::getClipRegion() const
bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
{
- VCL_GL_INFO( "::setClipRegion " << rClip );
if (maClipRegion == rClip)
+ {
+ VCL_GL_INFO("::setClipRegion (no change) " << rClip);
return true;
+ }
FlushDeferredDrawing();
+ VCL_GL_INFO( "::setClipRegion " << rClip );
+
maClipRegion = rClip;
mbUseStencil = false;
@@ -376,12 +386,16 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
// set the clip region to empty
void OpenGLSalGraphicsImpl::ResetClipRegion()
{
- VCL_GL_INFO( "::ResetClipRegion" );
if (maClipRegion.IsEmpty())
+ {
+ VCL_GL_INFO("::ResetClipRegion (no change) ");
return;
+ }
FlushDeferredDrawing();
+ VCL_GL_INFO("::ResetClipRegion");
+
maClipRegion.SetEmpty();
mbUseScissor = false;
mbUseStencil = false;
@@ -1574,13 +1588,12 @@ void OpenGLSalGraphicsImpl::DeferredTextDraw(OpenGLTexture& rTexture, SalColor a
mpAccumulatedTextures->insert(rTexture, aMaskColor, rPosAry);
}
-void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
+void OpenGLSalGraphicsImpl::FlushDeferredDrawing()
{
if (mpAccumulatedTextures->empty())
return;
- if (!bIsInDraw)
- PreDraw();
+ InitializePreDrawState();
VCL_GL_INFO("FlushDeferredDrawing");
@@ -1592,7 +1605,6 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
static sal_uInt8 b = 0xFF;
static std::unordered_map<GLuint, Color> aColorForTextureMap;
-
for (auto& rPair : mpAccumulatedTextures->getAccumulatedTexturesMap())
{
OpenGLTexture& rTexture = rPair.second->maTexture;
@@ -1625,7 +1637,9 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
if( !UseProgram( "textureVertexShader", "maskFragmentShader" ) )
return;
+
mpProgram->SetBlendMode(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
for (auto& rPair : mpAccumulatedTextures->getAccumulatedTexturesMap())
{
OpenGLTexture& rTexture = rPair.second->maTexture;
@@ -1642,8 +1656,8 @@ void OpenGLSalGraphicsImpl::FlushDeferredDrawing(bool bIsInDraw)
}
mpProgram->Clean();
mpAccumulatedTextures->clear();
- if (!bIsInDraw)
- PostDraw();
+
+ PostDraw();
}
void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect )
More information about the Libreoffice-commits
mailing list