vcl/inc/openglgdiimpl.hxx |2
vcl/opengl/gdiimpl.cxx| 96 +++---
2 files changed, 59 insertions(+), 39 deletions(-)
New commits:
commit b334ac1f891eaa5b8cea17ea7d71e2e51b0d1f12
Author: Louis-Francis Ratté-Boulianne l...@collabora.com
Date: Wed Nov 12 18:12:00 2014 -0500
vcl: Fix several coordinates calculations
Change-Id: I15878b4d91081a7ac880713ad278893aaad4a844
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9b17d98..c4e8bb4 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -447,7 +447,7 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
GLfloat pPoint[2];
pPoint[0] = 2 * nX / GetWidth() - 1.0f;
-pPoint[1] = 2 * (GetHeight() - nY) / GetHeight() - 1.0f;
+pPoint[1] = 1.0f - 2 * nY / GetHeight();
glEnableVertexAttribArray( GL_ATTRIB_POS );
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pPoint );
@@ -462,9 +462,9 @@ void OpenGLSalGraphicsImpl::DrawLine( long nX1, long nY1,
long nX2, long nY2 )
GLfloat pPoints[4];
pPoints[0] = (2 * nX1) / GetWidth() - 1.0;
-pPoints[1] = (2 * (GetHeight() - nY1)) / GetHeight() - 1.0;
+pPoints[1] = 1.0f - 2 * nY1 / GetHeight();
pPoints[2] = (2 * nX2) / GetWidth() - 1.0;;
-pPoints[3] = (2 * (GetHeight() - nY2)) / GetHeight() - 1.0;
+pPoints[3] = 1.0f - 2 * nY2 / GetHeight();
glEnableVertexAttribArray( GL_ATTRIB_POS );
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pPoints );
@@ -504,7 +504,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32
nPoints, const SalPoin
for( i = 0, j = 0; i nPoints; i++, j += 2 )
{
aVertices[j] = (2 * pPtAry[i].mnX) / GetWidth() - 1.0;
-aVertices[j+1] = (2 * pPtAry[i].mnY) / GetHeight() - 1.0;
+aVertices[j+1] = 1.0 - (2 * pPtAry[i].mnY / GetHeight());
}
glEnableVertexAttribArray( GL_ATTRIB_POS );
@@ -525,7 +525,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const
Polygon rPolygon )
{
const Point rPt = rPolygon.GetPoint( i );
aVertices[j] = (2 * rPt.X()) / GetWidth() - 1.0;
-aVertices[j+1] = (2 * (GetHeight() - rPt.Y())) / GetHeight() - 1.0;
+aVertices[j+1] = 1.0 - (2 * rPt.Y() / GetHeight());
}
glEnableVertexAttribArray( GL_ATTRIB_POS );
@@ -539,9 +539,9 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const
Polygon rPolygon )
void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long
nHeight )
{
long nX1( nX );
-long nY1( GetHeight() - nY );
+long nY1( nY );
long nX2( nX + nWidth );
-long nY2( GetHeight() - nY - nHeight );
+long nY2( nY + nHeight );
const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
{ nX2, nY1 }, { nX2, nY2 }};
@@ -551,9 +551,9 @@ void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY,
long nWidth, long nHeigh
void OpenGLSalGraphicsImpl::DrawRect( const Rectangle rRect )
{
long nX1( rRect.Left() );
-long nY1( GetHeight() - rRect.Top() );
+long nY1( rRect.Top() );
long nX2( rRect.Right() );
-long nY2( GetHeight() - rRect.Bottom() );
+long nY2( rRect.Bottom() );
const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
{ nX2, nY1 }, { nX2, nY2 }};
commit 0774719910e808bcf7ef3e891b7456e05d3deae6
Author: Louis-Francis Ratté-Boulianne l...@collabora.com
Date: Wed Nov 12 18:11:34 2014 -0500
vcl: Use stencil mask to clip gradient shape
Change-Id: I5dc17a20ab65f0b0bad4741a7d1ec76a0e028e23
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 82bb919..167fe60 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -74,6 +74,8 @@ protected:
GLuint mnRadialGradientEndColorUniform;
GLuint mnRadialGradientCenterUniform;
+void ImplSetClipBit( const vcl::Region rClip, GLuint nMask );
+
bool CreateSolidProgram( void );
bool CreateTextureProgram( void );
bool CreateMaskedTextureProgram( void );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 661a197..9b17d98 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -102,7 +102,10 @@ void OpenGLSalGraphicsImpl::PreDraw()
if( mbUseScissor )
glEnable( GL_SCISSOR_TEST );
if( mbUseStencil )
+{
+glStencilFunc( GL_EQUAL, 1, 0x1 );
glEnable( GL_STENCIL_TEST );
+}
CHECK_GL_ERROR();
}
@@ -125,6 +128,24 @@ void OpenGLSalGraphicsImpl::freeResources()
// TODO Delete shaders, programs and textures if not shared
}
+void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region rClip, GLuint
nMask )
+{
+glEnable( GL_STENCIL_TEST );
+glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
+glStencilMask( nMask );
+glStencilFunc( GL_NEVER, nMask, 0xFF );
+glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
+
+glClear(