[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 2 commits - vcl/inc vcl/opengl

2014-11-12 Thread Louis-Francis Ratté-Boulianne
 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( 

[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 2 commits - vcl/inc vcl/opengl vcl/win

2014-11-09 Thread Markus Mohrhard
 vcl/inc/opengl/win/gdiimpl.hxx |4 +++-
 vcl/opengl/win/gdiimpl.cxx |   39 ++-
 vcl/win/source/gdi/salgdi.cxx  |4 ++--
 3 files changed, 43 insertions(+), 4 deletions(-)

New commits:
commit ea6622bb5e1e300856e7bd7bb6d0a307252d4cf8
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Nov 10 04:06:25 2014 +0100

only use OpenGL for window devices for now

That fixes the build problems that I have seen.

Change-Id: Ida89aa153d73ce4e07e3f0e0499df567e4df5009

diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index d9d333d..4e3b76f 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -590,7 +590,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, 
bool bScreen, HWND hW
 mnPenWidth(GSL_PEN_WIDTH)
 {
 static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
-bool bUseOpenGL = bOpenGLPossible  !mbPrinter ? 
officecfg::Office::Common::VCL::UseOpenGL::get() : false;
+bool bUseOpenGL = bOpenGLPossible  mbWindow ? 
officecfg::Office::Common::VCL::UseOpenGL::get() : false;
 if (bUseOpenGL)
 mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
 else
commit 381ed248e18bbcbb078908d93ef33b6101bc8439
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Nov 10 04:05:32 2014 +0100

add code for getting device width and height on window devices

Change-Id: Ib1b84745cd1211a5194da78d83646ade4b01e72a

diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 0af7089..aa29dd9 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -13,13 +13,15 @@
 #include vcl/dllapi.h
 
 #include openglgdiimpl.hxx
+#include win/salgdi.h
 
 class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl
 {
 private:
+WinSalGraphics mrParent;
 
 public:
-WinOpenGLSalGraphicsImpl();
+WinOpenGLSalGraphicsImpl(WinSalGraphics rGraphics);
 
 protected:
 virtual GLfloat GetWidth() const SAL_OVERRIDE;
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 17868c8..e829ca4 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -9,18 +9,55 @@
 
 #include opengl/win/gdiimpl.hxx
 
-WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl()
+#include win/wincomp.hxx
+#include win/saldata.hxx
+#include win/salframe.h
+
+WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics rGraphics):
+mrParent(rGraphics)
 {
 }
 
 GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const
 {
+if( mrParent.gethWnd()  IsWindow( mrParent.gethWnd() ) )
+{
+WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+if( pFrame )
+{
+if( pFrame-maGeometry.nWidth )
+return pFrame-maGeometry.nWidth;
+else
+{
+// TODO: perhaps not needed, maGeometry should always be 
up-to-date
+RECT aRect;
+GetClientRect( mrParent.gethWnd(), aRect );
+return aRect.right;
+}
+}
+}
 
 return 1;
 }
 
 GLfloat WinOpenGLSalGraphicsImpl::GetHeight() const
 {
+if( mrParent.gethWnd()  IsWindow( mrParent.gethWnd() ) )
+{
+WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+if( pFrame )
+{
+if( pFrame-maGeometry.nHeight )
+return pFrame-maGeometry.nHeight;
+else
+{
+// TODO: perhaps not needed, maGeometry should always be 
up-to-date
+RECT aRect;
+GetClientRect( mrParent.gethWnd(), aRect );
+return aRect.bottom;
+}
+}
+}
 
 return 1;
 }
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 28394b5..d9d333d 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -592,7 +592,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, 
bool bScreen, HWND hW
 static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
 bool bUseOpenGL = bOpenGLPossible  !mbPrinter ? 
officecfg::Office::Common::VCL::UseOpenGL::get() : false;
 if (bUseOpenGL)
-mpImpl.reset(new WinOpenGLSalGraphicsImpl());
+mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
 else
 mpImpl.reset(new WinSalGraphicsImpl(*this));
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits