[Libreoffice-commits] core.git: 6 commits - vcl/inc vcl/opengl vcl/Package_opengl.mk vcl/source
Michael Meeks
michael.meeks at collabora.com
Mon Nov 17 14:39:34 PST 2014
vcl/Package_opengl.mk | 1
vcl/inc/opengl/salbmp.hxx | 2
vcl/inc/opengl/win/gdiimpl.hxx | 1
vcl/inc/opengl/x11/gdiimpl.hxx | 1
vcl/inc/openglgdiimpl.hxx | 16 ++
vcl/opengl/gdiimpl.cxx | 174 ++++++++++++++++++++++---
vcl/opengl/maskFragmentShader.glsl | 10 -
vcl/opengl/salbmp.cxx | 31 +++-
vcl/opengl/transformedTextureVertexShader.glsl | 24 +++
vcl/opengl/win/gdiimpl.cxx | 6
vcl/opengl/x11/gdiimpl.cxx | 6
vcl/source/opengl/OpenGLContext.cxx | 27 +++
12 files changed, 262 insertions(+), 37 deletions(-)
New commits:
commit 414c2e2d5ae4c47865adf0338ef7e117fbb8775e
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 21:07:27 2014 +0000
vcl: initialize data when XGetWindowAttributes fails.
Change-Id: If6fc99483c06efec9a600226a09ead9a3f6dab59
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e7f7f71..33a019d 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -463,7 +463,12 @@ GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC, bool bUseDoubl
SAL_INFO("vcl.opengl", "window: " << win);
XWindowAttributes xattr;
- XGetWindowAttributes( dpy, win, &xattr );
+ if( !XGetWindowAttributes( dpy, win, &xattr ) )
+ {
+ SAL_WARN("vcl.opengl", "Failed to get window attributes for fbconfig " << win);
+ xattr.screen = 0;
+ xattr.visual = NULL;
+ }
int screen = XScreenNumberOfScreen( xattr.screen );
@@ -535,7 +540,11 @@ Visual* getVisual(Display* dpy, Window win)
initOpenGLFunctionPointers();
XWindowAttributes xattr;
- XGetWindowAttributes( dpy, win, &xattr );
+ if( !XGetWindowAttributes( dpy, win, &xattr ) )
+ {
+ SAL_WARN("vcl.opengl", "Failed to get window attributes for getVisual " << win);
+ xattr.visual = NULL;
+ }
SAL_INFO("vcl.opengl", "using VisualID " << xattr.visual);
return xattr.visual;
}
@@ -694,9 +703,17 @@ bool OpenGLContext::ImplInit()
SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions);
XWindowAttributes xWinAttr;
- XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr );
- m_aGLWin.Width = xWinAttr.width;
- m_aGLWin.Height = xWinAttr.height;
+ if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr ) )
+ {
+ SAL_WARN("vcl.opengl", "Failed to get window attributes on " << m_aGLWin.win);
+ m_aGLWin.Width = 0;
+ m_aGLWin.Height = 0;
+ }
+ else
+ {
+ m_aGLWin.Width = xWinAttr.width;
+ m_aGLWin.Height = xWinAttr.height;
+ }
if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
{
commit 1c20a126d43ca34332f050f6eb847621de99e1b0
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 20:33:41 2014 +0000
vcl: only use default windows' GL Context for bitmaps if NULL / uninitialized.
Change-Id: I6465c548ba5d50da2cca7cce24e9bd2a20b28f47
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 780c268..15ef1b3 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -464,14 +464,17 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
bool OpenGLSalBitmap::makeCurrent()
{
- OpenGLContextProvider *pProvider;
- pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
- if( pProvider == NULL )
+ if (!mpContext || !mpContext->isInitialized())
{
- SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
- return false;
+ OpenGLContextProvider *pProvider;
+ pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
+ if( pProvider == NULL )
+ {
+ SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
+ return false;
+ }
+ mpContext = pProvider->GetOpenGLContext();
}
- mpContext = pProvider->GetOpenGLContext();
mpContext->makeCurrent();
return true;
}
commit 95017eaf851c6b97db38cd226b6bea661e73dc60
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 17 10:00:33 2014 -0500
vcl: Fix DrawMask implementation in OpenGL backend
Change-Id: Idc0bedaba5a4cea351f131d402c2b1093ac1c53c
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 339f3c6..ab6b95f 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -406,7 +406,7 @@ bool OpenGLSalGraphicsImpl::CreateMaskProgram( void )
glBindAttribLocation( mnMaskProgram, GL_ATTRIB_POS, "position" );
glBindAttribLocation( mnMaskProgram, GL_ATTRIB_TEX, "tex_coord_in" );
mnMaskUniform = glGetUniformLocation( mnMaskProgram, "sampler" );
- mnMaskColorUniform = glGetUniformLocation( mnMaskProgram, "mask" );
+ mnMaskColorUniform = glGetUniformLocation( mnMaskProgram, "color" );
CHECK_GL_ERROR();
return true;
@@ -844,7 +844,7 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGL
CHECK_GL_ERROR();
}
-void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& /*pPosAry*/ )
+void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& pPosAry )
{
if( mnMaskProgram == 0 )
{
@@ -858,7 +858,10 @@ void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor,
glActiveTexture( GL_TEXTURE0 );
rMask.Bind();
- //DrawTextureRect( rMask, pPosAry );
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ DrawTextureRect( rMask, pPosAry );
+ glDisable( GL_BLEND );
rMask.Unbind();
glUseProgram( 0 );
diff --git a/vcl/opengl/maskFragmentShader.glsl b/vcl/opengl/maskFragmentShader.glsl
index 4a8204e..2cc7377 100644
--- a/vcl/opengl/maskFragmentShader.glsl
+++ b/vcl/opengl/maskFragmentShader.glsl
@@ -7,15 +7,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-precision mediump float;
varying vec2 tex_coord;
uniform sampler2D sampler;
-uniform vec4 color;"
+uniform vec4 color;
void main() {
- vec4 texel0;
- texel0 = texture2D(sampler, tex_coord);
- gl_FragColor = color * texel0.a;
+ vec4 texel0;
+ texel0 = texture2D(sampler, tex_coord);
+ gl_FragColor = color;
+ gl_FragColor.a = 1.0 - texel0.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2d12d89632e6939b0d34af3b8830cbb2b0257629
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 17 09:15:15 2014 -0500
vcl: Implement drawing of transformed bitmaps in OpenGL backend
Change-Id: I79717a608f33050b84244e378a6e51bd3be29232
diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk
index 18c56fc..9151d94 100644
--- a/vcl/Package_opengl.mk
+++ b/vcl/Package_opengl.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
solidVertexShader.glsl \
textureFragmentShader.glsl \
textureVertexShader.glsl \
+ transformedTextureVertexShader.glsl \
))
# vim: set noet sw=4 ts=4:
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 80d760a..29bc7a2 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -56,6 +56,17 @@ protected:
GLuint mnTextureProgram;
GLuint mnSamplerUniform;
+ GLuint mnTransformedTextureProgram;
+ GLuint mnTransformedViewportUniform;
+ GLuint mnTransformedTransformUniform;
+ GLuint mnTransformedSamplerUniform;
+
+ GLuint mnTransformedMaskedTextureProgram;
+ GLuint mnTransformedMaskedViewportUniform;
+ GLuint mnTransformedMaskedTransformUniform;
+ GLuint mnTransformedMaskedSamplerUniform;
+ GLuint mnTransformedMaskedMaskUniform;
+
GLuint mnMaskedTextureProgram;
GLuint mnMaskedSamplerUniform;
GLuint mnMaskSamplerUniform;
@@ -79,7 +90,9 @@ protected:
bool CreateSolidProgram( void );
bool CreateTextureProgram( void );
+ bool CreateTransformedTextureProgram( void );
bool CreateMaskedTextureProgram( void );
+ bool CreateTransformedMaskedTextureProgram( void );
bool CreateMaskProgram( void );
bool CreateLinearGradientProgram( void );
bool CreateRadialGradientProgram( void );
@@ -103,6 +116,7 @@ public:
void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
void DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false );
void DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false );
+ void DrawTransformedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY );
void DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false, bool pPremultiplied = false );
void DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry );
void DrawMask( OpenGLTexture& rTexture, SalColor nMaskColor, const SalTwoRect& rPosAry );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9ed40b6..339f3c6 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -33,6 +33,8 @@
#include "salgdi.hxx"
#include "opengl/salbmp.hxx"
+#include <glm/glm.hpp>
+#include <glm/gtc/type_ptr.hpp>
#include <vector>
#define GL_ATTRIB_POS 0
@@ -72,6 +74,15 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl()
, mnColorUniform(0)
, mnTextureProgram(0)
, mnSamplerUniform(0)
+ , mnTransformedTextureProgram(0)
+ , mnTransformedViewportUniform(0)
+ , mnTransformedTransformUniform(0)
+ , mnTransformedSamplerUniform(0)
+ , mnTransformedMaskedTextureProgram(0)
+ , mnTransformedMaskedViewportUniform(0)
+ , mnTransformedMaskedTransformUniform(0)
+ , mnTransformedMaskedSamplerUniform(0)
+ , mnTransformedMaskedMaskUniform(0)
, mnMaskedTextureProgram(0)
, mnMaskedSamplerUniform(0)
, mnMaskSamplerUniform(0)
@@ -338,6 +349,22 @@ bool OpenGLSalGraphicsImpl::CreateTextureProgram( void )
return true;
}
+bool OpenGLSalGraphicsImpl::CreateTransformedTextureProgram( void )
+{
+ mnTransformedTextureProgram = OpenGLHelper::LoadShaders( "transformedTextureVertexShader", "textureFragmentShader" );
+ if( mnTransformedTextureProgram == 0 )
+ return false;
+
+ glBindAttribLocation( mnTransformedTextureProgram, GL_ATTRIB_POS, "position" );
+ glBindAttribLocation( mnTransformedTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
+ mnTransformedViewportUniform = glGetUniformLocation( mnTransformedTextureProgram, "viewport" );
+ mnTransformedTransformUniform = glGetUniformLocation( mnTransformedTextureProgram, "transform" );
+ mnTransformedSamplerUniform = glGetUniformLocation( mnTransformedTextureProgram, "sampler" );
+
+ CHECK_GL_ERROR();
+ return true;
+}
+
bool OpenGLSalGraphicsImpl::CreateMaskedTextureProgram( void )
{
mnMaskedTextureProgram = OpenGLHelper::LoadShaders( "maskedTextureVertexShader", "maskedTextureFragmentShader" );
@@ -353,14 +380,31 @@ bool OpenGLSalGraphicsImpl::CreateMaskedTextureProgram( void )
return true;
}
+bool OpenGLSalGraphicsImpl::CreateTransformedMaskedTextureProgram( void )
+{
+ mnTransformedMaskedTextureProgram = OpenGLHelper::LoadShaders( "transformedTextureVertexShader", "maskedTextureFragmentShader" );
+ if( mnTransformedMaskedTextureProgram == 0 )
+ return false;
+
+ glBindAttribLocation( mnTransformedMaskedTextureProgram, GL_ATTRIB_POS, "position" );
+ glBindAttribLocation( mnTransformedMaskedTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
+ mnTransformedMaskedViewportUniform = glGetUniformLocation( mnTransformedMaskedTextureProgram, "viewport" );
+ mnTransformedMaskedTransformUniform = glGetUniformLocation( mnTransformedMaskedTextureProgram, "transform" );
+ mnTransformedMaskedSamplerUniform = glGetUniformLocation( mnTransformedMaskedTextureProgram, "sampler" );
+ mnTransformedMaskedMaskUniform = glGetUniformLocation( mnTransformedMaskedTextureProgram, "mask" );
+
+ CHECK_GL_ERROR();
+ return true;
+}
+
bool OpenGLSalGraphicsImpl::CreateMaskProgram( void )
{
- mnMaskedTextureProgram = OpenGLHelper::LoadShaders( "maskVertexShader", "maskFragmentShader" );
- if( mnMaskedTextureProgram == 0 )
+ mnMaskProgram = OpenGLHelper::LoadShaders( "maskVertexShader", "maskFragmentShader" );
+ if( mnMaskProgram == 0 )
return false;
- glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" );
- glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
+ glBindAttribLocation( mnMaskProgram, GL_ATTRIB_POS, "position" );
+ glBindAttribLocation( mnMaskProgram, GL_ATTRIB_TEX, "tex_coord_in" );
mnMaskUniform = glGetUniformLocation( mnMaskProgram, "sampler" );
mnMaskColorUniform = glGetUniformLocation( mnMaskProgram, "mask" );
@@ -675,6 +719,88 @@ void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRe
CHECK_GL_ERROR();
}
+void OpenGLSalGraphicsImpl::DrawTransformedTexture(
+ OpenGLTexture& rTexture,
+ OpenGLTexture& rMask,
+ const basegfx::B2DPoint& rNull,
+ const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY )
+{
+ const basegfx::B2DVector aXRel = rX - rNull;
+ const basegfx::B2DVector aYRel = rY - rNull;
+ const float aValues[] = {
+ (float) aXRel.getX()/rTexture.GetWidth(), (float) aXRel.getY()/rTexture.GetWidth(), 0, 0,
+ (float) aYRel.getX()/rTexture.GetHeight(), (float) aYRel.getY()/rTexture.GetHeight(), 0, 0,
+ 0, 0, 1, 0,
+ (float) rNull.getX(), (float) rNull.getY(), 0, 1 };
+ glm::mat4 mMatrix = glm::make_mat4( aValues );
+ GLfloat aVertices[8] = {
+ 0, (float) rTexture.GetHeight(), 0, 0,
+ (float) rTexture.GetWidth(), 0, (float) rTexture.GetWidth(), (float) rTexture.GetHeight() };
+ GLfloat aTexCoord[8];
+ SalTwoRect aPosAry;
+
+ if( rMask )
+ {
+ if( mnTransformedMaskedTextureProgram == 0 )
+ {
+ if( !CreateTransformedMaskedTextureProgram() )
+ return;
+ }
+ glUseProgram( mnTransformedMaskedTextureProgram );
+ glUniform2f( mnTransformedMaskedViewportUniform, GetWidth(), GetHeight() );
+ glUniformMatrix4fv( mnTransformedMaskedTransformUniform, 1, GL_FALSE, glm::value_ptr( mMatrix ) );
+ glUniform1i( mnTransformedMaskedSamplerUniform, 0 );
+ glUniform1i( mnTransformedMaskedMaskUniform, 1 );
+ glActiveTexture( GL_TEXTURE1 );
+ rMask.Bind();
+ rMask.SetFilter( GL_LINEAR );
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
+ else
+ {
+ if( mnTransformedTextureProgram == 0 )
+ {
+ if( !CreateTransformedTextureProgram() )
+ return;
+ }
+ glUseProgram( mnTransformedTextureProgram );
+ glUniform2f( mnTransformedViewportUniform, GetWidth(), GetHeight() );
+ glUniformMatrix4fv( mnTransformedTransformUniform, 1, GL_FALSE, glm::value_ptr( mMatrix ) );
+ glUniform1i( mnTransformedSamplerUniform, 0 );
+ }
+
+ glActiveTexture( GL_TEXTURE0 );
+ rTexture.Bind();
+ rTexture.SetFilter( GL_LINEAR );
+ CHECK_GL_ERROR();
+
+ aPosAry.mnSrcX = aPosAry.mnSrcY = 0;
+ aPosAry.mnSrcWidth = rTexture.GetWidth();
+ aPosAry.mnSrcHeight = rTexture.GetHeight();
+ rTexture.GetCoord( aTexCoord, aPosAry );
+ glEnableVertexAttribArray( GL_ATTRIB_TEX );
+ glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord );
+ glEnableVertexAttribArray( GL_ATTRIB_POS );
+ glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
+ glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
+ glDisableVertexAttribArray( GL_ATTRIB_POS );
+ glDisableVertexAttribArray( GL_ATTRIB_TEX );
+
+ if( rMask )
+ {
+ glDisable( GL_BLEND );
+ glActiveTexture( GL_TEXTURE1 );
+ rMask.Unbind();
+ }
+
+ glActiveTexture( GL_TEXTURE0 );
+ rTexture.Unbind();
+ glUseProgram( 0 );
+ CHECK_GL_ERROR();
+}
+
void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied )
{
glEnable( GL_BLEND );
@@ -1390,13 +1516,26 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
bool OpenGLSalGraphicsImpl::drawTransformedBitmap(
- const basegfx::B2DPoint& /*rNull*/,
- const basegfx::B2DPoint& /*rX*/,
- const basegfx::B2DPoint& /*rY*/,
- const SalBitmap& /*rSourceBitmap*/,
- const SalBitmap* /*pAlphaBitmap*/)
-{
- return false;
+ const basegfx::B2DPoint& rNull,
+ const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY,
+ const SalBitmap& rSrcBitmap,
+ const SalBitmap* pAlphaBitmap)
+{
+ const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSrcBitmap);
+ const OpenGLSalBitmap* pMaskBitmap = static_cast<const OpenGLSalBitmap*>(pAlphaBitmap);
+ OpenGLTexture& rTexture( rBitmap.GetTexture( maContext ) );
+ OpenGLTexture aMask; // no texture
+
+ if( pMaskBitmap != NULL )
+ aMask = pMaskBitmap->GetTexture( maContext );
+
+ SAL_INFO( "vcl.opengl", "::drawTransformedBitmap" );
+ PreDraw();
+ DrawTransformedTexture( rTexture, aMask, rNull, rX, rY );
+ PostDraw();
+
+ return true;
}
/** Render solid rectangle with given transparency
diff --git a/vcl/opengl/transformedTextureVertexShader.glsl b/vcl/opengl/transformedTextureVertexShader.glsl
new file mode 100644
index 0000000..51485a0
--- /dev/null
+++ b/vcl/opengl/transformedTextureVertexShader.glsl
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+attribute vec4 position;
+attribute vec2 tex_coord_in;
+uniform vec2 viewport;
+uniform mat4 transform;
+varying vec2 tex_coord;
+
+void main() {
+ vec4 pos = transform * position;
+ pos.x = (2.0 * pos.x) / viewport.x - 1.0;
+ pos.y = 1.0 - (2.0 * pos.y / viewport.y);
+ gl_Position = pos;
+ tex_coord = tex_coord_in;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit bd14a48e414f4f04cc1b08f5ac29c403f161d69d
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 05:15:13 2014 +0000
vcl: always use the default windows' GL Context for now to create bitmaps.
Change-Id: Ie20b10656788113709b0b0720d3cae2653639d78
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index dbb29d8..9995645 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -52,6 +52,8 @@ private:
int mnBufHeight;
std::deque< OpenGLSalBitmapOp* > maPendingOps;
+ bool makeCurrent();
+
public:
OpenGLSalBitmap();
virtual ~OpenGLSalBitmap();
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 4b5287e..780c268 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -395,7 +395,7 @@ GLuint OpenGLSalBitmap::CreateTexture()
}
}
- mpContext->makeCurrent();
+ makeCurrent();
maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
@@ -449,7 +449,7 @@ bool OpenGLSalBitmap::ReadTexture()
return false;
}
- mpContext->makeCurrent();
+ makeCurrent();
maTexture.Read( nFormat, nType, pData );
mnBufWidth = mnWidth;
mnBufHeight = mnHeight;
@@ -462,6 +462,20 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
+bool OpenGLSalBitmap::makeCurrent()
+{
+ OpenGLContextProvider *pProvider;
+ pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
+ if( pProvider == NULL )
+ {
+ SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
+ return false;
+ }
+ mpContext = pProvider->GetOpenGLContext();
+ mpContext->makeCurrent();
+ return true;
+}
+
BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
{
if( !maUserBuffer.get() )
@@ -474,15 +488,9 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
if( !maPendingOps.empty() )
{
- OpenGLContextProvider *pProvider;
- pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
- if( pProvider == NULL )
- {
- SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
+ if (!makeCurrent())
return NULL;
- }
- mpContext = pProvider->GetOpenGLContext();
- mpContext->makeCurrent();
+
SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
return NULL;
commit dfeaee01a30109883e41f45faf28fc247dadb3b2
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Nov 17 04:35:29 2014 +0000
vcl: copyBits should operate on mrParent if no context supplied.
eg. OutputDevice::DrawOutDev:
mpGraphics->CopyBits( aPosAry, NULL, this, NULL );
Change-Id: I0b041bb5aa6aba573b9f589842084722481cb438
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 085be79..557e58a 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -29,6 +29,7 @@ protected:
virtual GLfloat GetHeight() const SAL_OVERRIDE;
public:
+ virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
};
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index 00eaf8c..a2b863e 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -32,6 +32,7 @@ protected:
public:
// implementation of X11GraphicsImpl
+ virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
void Init() SAL_OVERRIDE;
bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index dd0b1e3..80d760a 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -216,7 +216,7 @@ public:
// CopyBits and DrawBitmap --> RasterOp and ClipRegion
// CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
- virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
+ void DoCopyBits( const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl *pSrcImpl );
virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 8532ba0..9ed40b6 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1171,9 +1171,9 @@ void OpenGLSalGraphicsImpl::copyArea(
// CopyBits and DrawBitmap --> RasterOp and ClipRegion
// CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
-void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+void OpenGLSalGraphicsImpl::DoCopyBits( const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl* pSrcImpl )
{
- OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : NULL;
+ OpenGLSalGraphicsImpl *pImpl = pSrcImpl;
SAL_INFO( "vcl.opengl", "::copyBits" );
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index e829ca4..67a192e 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -18,6 +18,12 @@ WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics):
{
}
+void WinOpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+ OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
+ OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, pImpl );
+}
+
GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const
{
if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) )
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 5292038..dcefcc2 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -81,6 +81,12 @@ void X11OpenGLSalGraphicsImpl::Init()
}
}
+void X11OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+ OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
+ OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, pImpl );
+}
+
bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY )
{
Display* pDisplay = mrParent.GetXDisplay();
More information about the Libreoffice-commits
mailing list