include/vcl/outdev.hxx | 4 include/vcl/region.hxx | 6 - vcl/inc/generic/genpspgraphics.h | 3 vcl/inc/headless/svpgdi.hxx | 3 vcl/inc/opengl/contextprovider.hxx | 28 ++++++ vcl/inc/opengl/salbmp.hxx | 2 vcl/inc/openglgdiimpl.hxx | 10 ++ vcl/inc/quartz/salgdi.h | 3 vcl/inc/salgdi.hxx | 3 vcl/inc/salgdiimpl.hxx | 3 vcl/inc/unx/salgdi.h | 10 +- vcl/inc/win/salgdi.h | 3 vcl/opengl/gdiimpl.cxx | 159 +++++++++++++++++++++++++------------ vcl/opengl/salbmp.cxx | 64 +++++++++++--- vcl/opengl/scale.cxx | 15 ++- vcl/opengl/x11/gdiimpl.cxx | 6 - vcl/source/gdi/region.cxx | 17 +++ vcl/source/opengl/OpenGLHelper.cxx | 1 vcl/source/outdev/outdev.cxx | 13 ++- vcl/source/window/paint.cxx | 7 + vcl/unx/generic/gdi/gdiimpl.hxx | 3 vcl/unx/generic/gdi/salgdi.cxx | 18 +++- vcl/win/source/gdi/gdiimpl.hxx | 3 vcl/win/source/gdi/salgdi.cxx | 9 +- vcl/workben/vcldemo.cxx | 23 +++-- 25 files changed, 309 insertions(+), 107 deletions(-)
New commits: commit 19274cdb71983daf684abe623dbad61d3ca3cb6a Author: Markus Mohrhard <[email protected]> Date: Thu Nov 13 06:16:03 2014 +0100 Revert "loplugin:unreffun" This reverts commit 3e90cc12731eaf149dce83237bfccb88ffbd26a9. diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 79e2fbc..177cd51 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -552,6 +552,17 @@ public: } }; + struct FetchDrawBitmap : public RegionRenderer + { + virtual void RenderRegion(OutputDevice &rDev, Rectangle r, + const RenderContext &) SAL_OVERRIDE + { + Bitmap aBitmap(rDev.GetBitmap(Point(0,0),rDev.GetOutputSizePixel())); + aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY); + rDev.DrawBitmap(r.TopLeft(), aBitmap); + } + }; + void drawToDevice(OutputDevice &rDev, bool bVdev) { RenderContext aCtx; commit 17bc7a4cb9eb22d59aae7d7646bf436df9e3fd8b Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 18:13:27 2014 -0500 vcldemo: Add some values to the gradient arrays Change-Id: I6c51bce7503866f39e72957752303e4d28145afb diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 5aeadc5..79e2fbc 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -356,20 +356,20 @@ public: sal_uInt32 nStartCols[] = { COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN, COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN, - COL_GRAY, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTCYAN, - COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK + COL_BLACK, COL_LIGHTGRAY, COL_WHITE, COL_BLUE, COL_CYAN, + COL_WHITE, COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK }; sal_uInt32 nEndCols[] = { - COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK, + COL_WHITE, COL_WHITE, COL_WHITE, COL_BLACK, COL_BLACK, COL_RED, COL_RED, COL_RED, COL_GREEN, COL_GREEN, COL_GRAY, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_BLUE, COL_BLUE, COL_BLUE, COL_CYAN, COL_CYAN }; GradientStyle eStyles[] = { GradientStyle_LINEAR, GradientStyle_AXIAL, GradientStyle_RADIAL, GradientStyle_ELLIPTICAL, GradientStyle_SQUARE, - GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL, + GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL, GradientStyle_LINEAR, GradientStyle_LINEAR, GradientStyle_AXIAL, GradientStyle_RADIAL, GradientStyle_ELLIPTICAL, GradientStyle_SQUARE, - GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL + GradientStyle_RECT, GradientStyle_FORCE_EQUAL_SIZE, GradientStyle_LINEAR, GradientStyle_RADIAL, GradientStyle_LINEAR }; sal_uInt16 nAngles[] = { 0, 0, 0, 0, 0, commit 1b3dcdbecbbcd5f5f1b838366bbfe194c4188c36 Author: Louis-Francis Ratté-Boulianne <[email protected]> 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 8396ffe..027d9ac 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 afd759a583e9dcbbbdda0697b57f97f8235d2741 Author: Louis-Francis Ratté-Boulianne <[email protected]> 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 f1206c3..8396ffe 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( GL_STENCIL_BUFFER_BIT ); + BeginSolid( MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ) ); + DrawPolyPolygon( rClip.GetAsB2DPolyPolygon() ); + EndSolid(); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + glStencilMask( 0x00 ); + glDisable( GL_STENCIL_TEST ); +} + bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) { SAL_INFO( "vcl.opengl", "::setClipRegion " << rClip ); @@ -150,22 +171,7 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) mbUseScissor = false; maContext.makeCurrent(); glViewport( 0, 0, GetWidth(), GetHeight() ); - - glEnable( GL_STENCIL_TEST ); - glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); - glStencilMask( 0xFF ); - glStencilFunc( GL_NEVER, 1, 0xFF ); - glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP ); - - glClear( GL_STENCIL_BUFFER_BIT ); - BeginSolid( SALCOLOR_NONE ); - DrawPolyPolygon( rClip.GetAsB2DPolyPolygon() ); - EndSolid(); - - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - glStencilMask( 0x00 ); - glStencilFunc( GL_EQUAL, 1, 0xFF ); - glDisable( GL_STENCIL_TEST ); + ImplSetClipBit( rClip, 0x01 ); } return true; @@ -1333,42 +1339,54 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, if( aBoundRect.IsEmpty() ) return true; + if( rGradient.GetStyle() != GradientStyle_LINEAR && + rGradient.GetStyle() != GradientStyle_RADIAL ) + return false; + aBoundRect.Left()--; aBoundRect.Top()--; aBoundRect.Right()++; aBoundRect.Bottom()++; + //TODO: lfrb: some missing transformation with the polygon in outdev + + PreDraw(); + + ImplSetClipBit( vcl::Region( rPolyPoly ), 0x02 ); + if( mbUseStencil ) + { + glEnable( GL_STENCIL_TEST ); + glStencilFunc( GL_EQUAL, 3, 0xFF ); + } + else + { + glEnable( GL_STENCIL_TEST ); + glStencilFunc( GL_EQUAL, 2, 0xFF ); + } // if border >= 100%, draw solid rectangle with start color if( rGradient.GetBorder() >= 100.0 ) { Color aCol = rGradient.GetStartColor(); long nF = rGradient.GetStartIntensity(); - PreDraw(); BeginSolid( MAKE_SALCOLOR( aCol.GetRed() * nF / 100, aCol.GetGreen() * nF / 100, aCol.GetBlue() * nF / 100 ) ); DrawRect( aBoundRect ); - EndSolid(); - PostDraw(); - return true; } - - //TODO: lfrb: some missing transformation with the polygon in outdev - if( rGradient.GetStyle() == GradientStyle_LINEAR ) + else if( rGradient.GetStyle() == GradientStyle_LINEAR ) { - PreDraw(); DrawLinearGradient( rGradient, aBoundRect ); - PostDraw(); - return true; } else if( rGradient.GetStyle() == GradientStyle_RADIAL ) { - PreDraw(); DrawRadialGradient( rGradient, aBoundRect ); - PostDraw(); - return true; } - return false; + + if( !mbUseStencil ) + glDisable( GL_STENCIL_TEST ); + PostDraw(); + + return true; } void OpenGLSalGraphicsImpl::beginPaint() commit 6ff6d0b00dee5f9afbd4b4f0747183a3c8ba7939 Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 15:55:23 2014 -0500 vcl: Use glScissor for rectangular clip regions Change-Id: I62bf28d854d889242a49146cfe87c3dd6be89c32 diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 408896b..f1206c3 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -135,7 +135,7 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) return true; } - if( false ) //rClip.IsRectangle() ) + if( rClip.IsRectangle() ) { Rectangle aRect( rClip.GetBoundRect() ); commit 0127e37a83bc3734045c084fe8e3eb61998afc9e Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 15:37:36 2014 -0500 vcl: Fix gradient programs attribute binding Change-Id: I4210f09759824bf9415350262fd07534c9b3a317 diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 252d303..408896b 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -341,8 +341,8 @@ bool OpenGLSalGraphicsImpl::CreateLinearGradientProgram( void ) if( mnLinearGradientProgram == 0 ) return false; - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" ); - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); + glBindAttribLocation( mnLinearGradientProgram, GL_ATTRIB_POS, "position" ); + glBindAttribLocation( mnLinearGradientProgram, GL_ATTRIB_TEX, "tex_coord_in" ); mnLinearGradientStartColorUniform = glGetUniformLocation( mnLinearGradientProgram, "start_color" ); mnLinearGradientEndColorUniform = glGetUniformLocation( mnLinearGradientProgram, "end_color" ); @@ -356,8 +356,8 @@ bool OpenGLSalGraphicsImpl::CreateRadialGradientProgram( void ) if( mnRadialGradientProgram == 0 ) return false; - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" ); - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); + glBindAttribLocation( mnRadialGradientProgram, GL_ATTRIB_POS, "position" ); + glBindAttribLocation( mnRadialGradientProgram, GL_ATTRIB_TEX, "tex_coord_in" ); mnRadialGradientStartColorUniform = glGetUniformLocation( mnRadialGradientProgram, "start_color" ); mnRadialGradientEndColorUniform = glGetUniformLocation( mnRadialGradientProgram, "end_color" ); mnRadialGradientCenterUniform = glGetUniformLocation( mnRadialGradientProgram, "center" ); commit a6fee2ca4c3bd502df755be64d2b62c1a4d2c1bb Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 15:37:11 2014 -0500 vcl: Use scissor or stencil for clipping in OpenGL backend Change-Id: Ib6620572391999d5f8124a1a8695909d6c48643d diff --git a/include/vcl/region.hxx b/include/vcl/region.hxx index 362fa45..b182d36 100644 --- a/include/vcl/region.hxx +++ b/include/vcl/region.hxx @@ -102,6 +102,8 @@ public: void SetEmpty(); void SetNull(); + bool IsRectangle() const; + Rectangle GetBoundRect() const; bool HasPolyPolygonOrB2DPolyPolygon() const { return (getB2DPolyPolygon() || getPolyPolygon()); } void GetRegionRectangles(RectangleVector& rTarget) const; @@ -144,9 +146,7 @@ inline std::basic_ostream<charT, traits> & operator <<( << *rRegion.getB2DPolyPolygon() << ")"; if (rRegion.getPolyPolygon()) - return stream << "PolyPolygon(" - << *rRegion.getPolyPolygon() - << ")"; + return stream << "unimplemented"; if (rRegion.getRegionBand()) { // inlined because RegionBand is private to vcl stream << "RegionBand("; diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 3d1c585..82bb919 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -40,6 +40,10 @@ protected: SalVirtualDevice* mpVDev; int mnPainting; + // clipping + bool mbUseScissor; + bool mbUseStencil; + bool mbOffscreen; GLuint mnFramebufferId; OpenGLTextureSharedPtr mpOffscreenTex; diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 669b190..252d303 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -61,6 +61,8 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() : mpFrame(NULL) , mnPainting(0) + , mbUseScissor(false) + , mbUseStencil(false) , mbOffscreen(false) , mnFramebufferId(0) , mpOffscreenTex(nullptr) @@ -97,6 +99,10 @@ void OpenGLSalGraphicsImpl::PreDraw() if( mbOffscreen ) glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId ); glViewport( 0, 0, GetWidth(), GetHeight() ); + if( mbUseScissor ) + glEnable( GL_SCISSOR_TEST ); + if( mbUseStencil ) + glEnable( GL_STENCIL_TEST ); CHECK_GL_ERROR(); } @@ -105,8 +111,12 @@ void OpenGLSalGraphicsImpl::PostDraw() { if( mbOffscreen ) glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - if( mnPainting == 0 ) + else if( mnPainting == 0 ) glFlush(); + if( mbUseScissor ) + glDisable( GL_SCISSOR_TEST ); + if( mbUseStencil ) + glDisable( GL_STENCIL_TEST ); CHECK_GL_ERROR(); } @@ -117,28 +127,46 @@ void OpenGLSalGraphicsImpl::freeResources() bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) { - const basegfx::B2DPolyPolygon aClip( rClip.GetAsB2DPolyPolygon() ); + SAL_INFO( "vcl.opengl", "::setClipRegion " << rClip ); - SAL_INFO( "vcl.opengl", "::setClipRegion" ); + if( rClip.IsEmpty() ) + { + ResetClipRegion(); + return true; + } - /*maContext.makeCurrent(); - glViewport( 0, 0, GetWidth(), GetHeight() ); + if( false ) //rClip.IsRectangle() ) + { + Rectangle aRect( rClip.GetBoundRect() ); - glEnable( GL_STENCIL_TEST ); + mbUseStencil = false; + mbUseScissor = true; + maContext.makeCurrent(); + glScissor( aRect.Left(), GetHeight() - aRect.Top(), aRect.GetWidth(), aRect.GetHeight() ); + } + else + { + mbUseStencil = true; + mbUseScissor = false; + maContext.makeCurrent(); + glViewport( 0, 0, GetWidth(), GetHeight() ); - glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); - glStencilMask( 0xFF ); - glStencilFunc( GL_NEVER, 1, 0xFF ); - glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP ); + glEnable( GL_STENCIL_TEST ); + glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + glStencilMask( 0xFF ); + glStencilFunc( GL_NEVER, 1, 0xFF ); + glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP ); - glClear( GL_STENCIL_BUFFER_BIT ); - BeginSolid( SALCOLOR_NONE ); - DrawPolyPolygon( aClip ); - EndSolid(); + glClear( GL_STENCIL_BUFFER_BIT ); + BeginSolid( SALCOLOR_NONE ); + DrawPolyPolygon( rClip.GetAsB2DPolyPolygon() ); + EndSolid(); - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - glStencilMask( 0x00 ); - glStencilFunc( GL_EQUAL, 1, 0xFF );*/ + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + glStencilMask( 0x00 ); + glStencilFunc( GL_EQUAL, 1, 0xFF ); + glDisable( GL_STENCIL_TEST ); + } return true; } @@ -147,10 +175,8 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) void OpenGLSalGraphicsImpl::ResetClipRegion() { SAL_INFO( "vcl.opengl", "::ResetClipRegion" ); - maContext.makeCurrent(); - glDisable(GL_STENCIL_TEST); - - CHECK_GL_ERROR(); + mbUseScissor = false; + mbUseStencil = false; } // get the depth of the device diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index 3f56d0e..6fb78b0 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -1434,6 +1434,23 @@ bool vcl::Region::IsOver( const Rectangle& rRect ) const return !aRegion.IsEmpty(); } +bool vcl::Region::IsRectangle() const +{ + if( IsEmpty() || IsNull() ) + return false; + + if( getB2DPolyPolygon() ) + return basegfx::tools::isRectangle( *getB2DPolyPolygon() ); + + if( getPolyPolygon() ) + return getPolyPolygon()->IsRect(); + + if( getRegionBand() ) + return (getRegionBand()->getRectangleCount() == 1); + + return false; +} + void vcl::Region::SetNull() { // reset all content commit c4e494bc62faa810c1b373f2e6ba7142c2b1c88d Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 14:55:33 2014 -0500 vcldemo: Draw mini-view of the whole window in the last rectangle Change-Id: I74e8807e6a4f50b99fdc761bbdbef6e43405a3ed diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 442ac47..5aeadc5 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -659,7 +659,7 @@ void DemoWin::InitRenderers() maRenderers.push_back(new DrawPolyPolygons()); maRenderers.push_back(new DrawToVirtualDevice()); maRenderers.push_back(new DrawIcons()); - maRenderers.push_back(new DrawBitmap()); + maRenderers.push_back(new FetchDrawBitmap()); } class DemoApp : public Application commit 1aef60fb3fbd5d9ce6521fd861207e6af7bcc5fb Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 13:16:29 2014 -0500 vcl: Add support for GPU scaling when no rendering is involved Change-Id: Id5aa4c1e843d286026a7bcd1297670db467dcbbc diff --git a/vcl/inc/opengl/contextprovider.hxx b/vcl/inc/opengl/contextprovider.hxx new file mode 100644 index 0000000..47eb98c --- /dev/null +++ b/vcl/inc/opengl/contextprovider.hxx @@ -0,0 +1,28 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX +#define INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX + +#include "vclpluginapi.h" + +#include <vcl/opengl/OpenGLContext.hxx> + +class VCLPLUG_GEN_PUBLIC OpenGLContextProvider +{ +public: + virtual ~OpenGLContextProvider() {}; + + /* Get the OpenGL context provided by this instance */ + virtual OpenGLContext* GetOpenGLContext() const = 0; +}; + +#endif // INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index e3d8a0c..f693ed1 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -32,6 +32,8 @@ #include "sallayout.hxx" #include "vclpluginapi.h" +#include "opengl/contextprovider.hxx" + #include <boost/scoped_ptr.hpp> #include <deque> @@ -60,7 +62,7 @@ namespace basegfx { class B2DTrapezoid; } -class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics +class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics, public OpenGLContextProvider { friend class ServerFontLayout; friend class X11SalGraphicsImpl; @@ -297,6 +299,9 @@ public: unsigned int w, unsigned int h, int dest_x, int dest_y ); static void releaseGlyphPeer(); + +public: + virtual OpenGLContext* GetOpenGLContext() const SAL_OVERRIDE; }; inline const SalDisplay *X11SalGraphics::GetDisplay() const diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index ad794b1..686a785 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -22,9 +22,12 @@ #include <vcl/opengl/OpenGLHelper.hxx> #include "vcl/bitmap.hxx" +#include "vcl/outdev.hxx" #include "vcl/salbtype.hxx" +#include "svdata.hxx" #include "salgdi.hxx" +#include "opengl/contextprovider.hxx" #include "opengl/salbmp.hxx" static bool isValidBitCount( sal_uInt16 nBitCount ) @@ -420,31 +423,44 @@ GLuint OpenGLSalBitmap::CreateTexture() bool OpenGLSalBitmap::ReadTexture() { - SalTwoRect aPosAry; - GLuint nFramebufferId, nRenderbufferDepthId, nRenderbufferColorId; + GLuint nFramebufferId; sal_uInt8* pData = maUserBuffer.get(); + GLenum nFormat = GL_RGBA; + GLenum nType = GL_UNSIGNED_BYTE; - SAL_INFO( "vcl.opengl", "::ReadTexture" ); + SAL_INFO( "vcl.opengl", "::ReadTexture " << mnWidth << "x" << mnHeight ); - // TODO Check mnTexWidth and mnTexHeight + if( pData == NULL ) + return false; + + if( mnBits == 16 || mnBits == 24 || mnBits == 32 ) + { + // no conversion needed for truecolor + pData = maUserBuffer.get(); + + switch( mnBits ) + { + case 16: nFormat = GL_RGB; + nType = GL_UNSIGNED_SHORT_5_6_5; + break; + case 24: nFormat = GL_RGB; + nType = GL_UNSIGNED_BYTE; + break; + case 32: nFormat = GL_RGBA; + nType = GL_UNSIGNED_BYTE; + break; + } + } mpContext->makeCurrent(); - OpenGLHelper::createFramebuffer( mnWidth, mnHeight, nFramebufferId, - nRenderbufferDepthId, nRenderbufferColorId, true ); + glGenFramebuffers( 1, &nFramebufferId ); glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId ); - aPosAry.mnSrcX = aPosAry.mnDestX = 0; - aPosAry.mnSrcY = aPosAry.mnDestY = 0; - aPosAry.mnSrcWidth = aPosAry.mnDestWidth = mnWidth; - aPosAry.mnSrcHeight = aPosAry.mnDestHeight = mnHeight; - - //DrawTexture( mnTexture, aPosAry ); - glReadPixels( 0, 0, mnWidth, mnHeight, GL_RGBA, GL_UNSIGNED_BYTE, pData ); + glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mpTexture->Id(), 0 ); + glReadPixels( 0, 0, mnWidth, mnHeight, nFormat, nType, pData ); glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glDeleteFramebuffers( 1, &nFramebufferId ); - glDeleteRenderbuffers( 1, &nRenderbufferDepthId ); - glDeleteRenderbuffers( 1, &nRenderbufferColorId ); CHECK_GL_ERROR(); return true; @@ -465,6 +481,22 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ ) return NULL; } + 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" ); + return NULL; + } + mpContext = pProvider->GetOpenGLContext(); + mpContext->makeCurrent(); + SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" ); + if( !CreateTexture() || !AllocateUserData() || !ReadTexture() ) + return NULL; + } + BitmapBuffer* pBuffer = new BitmapBuffer; pBuffer->mnWidth = mnWidth; pBuffer->mnHeight = mnHeight; diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 62e8989..2723db4 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -167,6 +167,15 @@ void X11SalGraphics::DeInit() SetDrawable( None, m_nXScreen ); } +OpenGLContext* X11SalGraphics::GetOpenGLContext() const +{ + OpenGLSalGraphicsImpl *pImpl; + pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get()); + if( pImpl ) + return &pImpl->GetOpenGLContext(); + return NULL; +} + void X11SalGraphics::SetClipRegion( GC pGC, Region pXReg ) const { Display *pDisplay = GetXDisplay(); commit 9ac5aa94665da9c6b9188716345e79ade00dd0cc Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 12:53:09 2014 -0500 vcl: Use new size when scaling with filter in OpenGL backend Change-Id: Ib5d12b0e57b537bbd1798121e80cd517d9c8f751 diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx index 77ac90b..c1f0cdb 100644 --- a/vcl/inc/opengl/salbmp.hxx +++ b/vcl/inc/opengl/salbmp.hxx @@ -106,7 +106,7 @@ private: GLuint mnConvKernelSizeUniform; GLuint mnConvOffsetsUniform; - bool ImplScaleFilter( GLenum nFilter ); + bool ImplScaleFilter( const double& rScaleX, const double& rScaleY, GLenum nFilter ); void ImplCreateKernel( const double& fScale, const Kernel& rKernel, GLfloat*& pWeights, sal_uInt32& aKernelSize ); bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel ); diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx index da73786..d1b85a5 100644 --- a/vcl/opengl/scale.cxx +++ b/vcl/opengl/scale.cxx @@ -81,12 +81,17 @@ GLuint OpenGLSalBitmap::ImplGetConvolutionProgram() return mnConvProgram; } -bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter ) +bool OpenGLSalBitmap::ImplScaleFilter( + const double& rScaleX, + const double& rScaleY, + GLenum nFilter ) { OpenGLTexture* pNewTex; GLuint nProgram; GLuint nFramebufferId; GLenum nOldFilter; + int nNewWidth( mnWidth * rScaleX ); + int nNewHeight( mnHeight * rScaleY ); nProgram = ImplGetTextureProgram(); if( nProgram == 0 ) @@ -97,7 +102,7 @@ bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter ) glUseProgram( nProgram ); glUniform1i( mnTexSamplerUniform, 0 ); - pNewTex = new OpenGLTexture( mnWidth, mnHeight ); + pNewTex = new OpenGLTexture( nNewWidth, nNewHeight ); glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pNewTex->Id(), 0 ); mpTexture->Bind(); @@ -111,6 +116,8 @@ bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter ) glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glDeleteFramebuffers( 1, &nFramebufferId ); + mnWidth = nNewWidth; + mnHeight = nNewHeight; mpTexture.reset( pNewTex ); CHECK_GL_ERROR(); @@ -241,11 +248,11 @@ bool OpenGLSalBitmap::ImplScale( const double& rScaleX, const double& rScaleY, s if( nScaleFlag == BMP_SCALE_FAST ) { - return ImplScaleFilter( GL_NEAREST ); + return ImplScaleFilter( rScaleX, rScaleY, GL_NEAREST ); } if( nScaleFlag == BMP_SCALE_BILINEAR ) { - return ImplScaleFilter( GL_LINEAR ); + return ImplScaleFilter( rScaleX, rScaleY, GL_LINEAR ); } else if( nScaleFlag == BMP_SCALE_SUPER ) { commit dc189f79e844c7208220c0903309852a09c8b1c1 Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 12:51:03 2014 -0500 vcl: Fix memory free bugs Change-Id: Ic8c507014f0b02c7a0baa40f3f48070301604ca4 diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 18d713d..ad794b1 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -403,7 +403,7 @@ GLuint OpenGLSalBitmap::CreateTexture() SAL_INFO( "vcl.opengl", "Created texture " << mpTexture->Id() ); if( bAllocated ) - delete pData; + delete[] pData; while( !maPendingOps.empty() ) { diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 13b7049..184abab 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -86,7 +86,7 @@ X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect XVisualInfo aVisualInfo; X11Pixmap* pPixmap; XImage* pImage; - sal_uInt8* pData; + char* pData; SAL_INFO( "vcl.opengl", "GetPixmapFromScreen" ); // TODO: lfrb: Use context depth @@ -100,12 +100,12 @@ X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect glXWaitX(); // TODO: lfrb: What if offscreen? - pData = new sal_uInt8[rRect.GetWidth() * rRect.GetHeight() * 4]; + pData = (char*) malloc( rRect.GetWidth() * rRect.GetHeight() * 4 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadPixels( rRect.Left(), GetHeight() - rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pData ); - pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, (char*) pData, + pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, pData, rRect.GetWidth(), rRect.GetHeight(), 8, 0 ); XInitImage( pImage ); GC aGC = XCreateGC( pDisplay, pPixmap->GetPixmap(), 0, NULL ); commit f3981e86d66e5d57e266961586a5b94ffd290fa9 Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 12:46:22 2014 -0500 vcl: Fix the masked texture program attributes binding Change-Id: Ie7440881f35eaf348aef35beea5a6d407d16a342 diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 2a6dcfc..669b190 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -285,8 +285,8 @@ bool OpenGLSalGraphicsImpl::CreateMaskedTextureProgram( void ) if( mnMaskedTextureProgram == 0 ) return false; - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" ); - glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); + glBindAttribLocation( mnMaskedTextureProgram, GL_ATTRIB_POS, "position" ); + glBindAttribLocation( mnMaskedTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" ); mnMaskedSamplerUniform = glGetUniformLocation( mnMaskedTextureProgram, "sampler" ); mnMaskSamplerUniform = glGetUniformLocation( mnMaskedTextureProgram, "mask" ); commit f433825259731e6fd0bc666f4d22b2f31dc99fa9 Author: Louis-Francis Ratté-Boulianne <[email protected]> Date: Wed Nov 12 12:45:36 2014 -0500 vcl: Use single-buffer rendering and only flush when necessary Change-Id: I832dd6f3647fbb423975fa928a5ec32447225e85 diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index a59b642..d80d394 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -501,7 +501,9 @@ public: const Point& rSrcPt, const Size& rSrcSize, sal_uInt16 nFlags = 0 ); - virtual bool SwapBuffers(); + // Call before and after a paint operation to reduce flushing + virtual void BeginPaint(); + virtual void EndPaint(); protected: diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index fb7169a..882e475 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -193,7 +193,8 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; - virtual bool SwapBuffers() SAL_OVERRIDE { return false; }; + virtual void BeginPaint() SAL_OVERRIDE { }; + virtual void EndPaint() SAL_OVERRIDE { }; }; #endif // INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index cd5622f..9f2604f 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -243,7 +243,8 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; - virtual bool SwapBuffers() SAL_OVERRIDE { return false; }; + virtual void BeginPaint() SAL_OVERRIDE { }; + virtual void EndPaint() SAL_OVERRIDE { }; #ifdef IOS void SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, int = 0 ); diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index f80c969..3d1c585 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -38,6 +38,7 @@ protected: OpenGLContext maContext; SalFrame* mpFrame; SalVirtualDevice* mpVDev; + int mnPainting; bool mbOffscreen; GLuint mnFramebufferId; @@ -285,7 +286,8 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE; - virtual bool swapBuffers() SAL_OVERRIDE; + virtual void beginPaint() SAL_OVERRIDE; + virtual void endPaint() SAL_OVERRIDE; private: }; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index caab577..6cc4526 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -394,7 +394,8 @@ public: GetGraphicsData() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE; - virtual bool SwapBuffers() SAL_OVERRIDE { return false; }; + virtual void BeginPaint() SAL_OVERRIDE { }; + virtual void EndPaint() SAL_OVERRIDE { }; private: // differences between VCL, Quartz and kHiThemeOrientation coordinate systems diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index a3917bb..2453450 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -412,7 +412,8 @@ public: sal_uInt8 nTransparency, const OutputDevice *pOutDev ); - virtual bool SwapBuffers() = 0; + virtual void BeginPaint() = 0; + virtual void EndPaint() = 0; virtual SystemGraphicsData GetGraphicsData() const = 0; diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx index 4b4b735..09ea28f 100644 --- a/vcl/inc/salgdiimpl.hxx +++ b/vcl/inc/salgdiimpl.hxx @@ -207,7 +207,8 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0; - virtual bool swapBuffers() = 0; + virtual void beginPaint() = 0; + virtual void endPaint() = 0; }; #endif diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 2546689..e3d8a0c 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -268,7 +268,8 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE; - virtual bool SwapBuffers() SAL_OVERRIDE; + virtual void BeginPaint() SAL_OVERRIDE; + virtual void EndPaint() SAL_OVERRIDE; // create a pixmap from a screen region X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ); diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index f09af28..69ea4cf 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -397,7 +397,8 @@ public: virtual SystemGraphicsData GetGraphicsData() const; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const; - virtual bool SwapBuffers() SAL_OVERRIDE; + virtual void BeginPaint() SAL_OVERRIDE; + virtual void EndPaint() SAL_OVERRIDE; /// Update settings based on the platform values static void updateSettingsNative( AllSettings& rSettings ); diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 1098b58..2a6dcfc 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -60,6 +60,7 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() : mpFrame(NULL) + , mnPainting(0) , mbOffscreen(false) , mnFramebufferId(0) , mpOffscreenTex(nullptr) @@ -104,7 +105,8 @@ void OpenGLSalGraphicsImpl::PostDraw() { if( mbOffscreen ) glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - + if( mnPainting == 0 ) + glFlush(); CHECK_GL_ERROR(); } @@ -1343,10 +1345,21 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, return false; } -bool OpenGLSalGraphicsImpl::swapBuffers() +void OpenGLSalGraphicsImpl::beginPaint() { - maContext.swapBuffers(); - return true; + mnPainting++; + SAL_INFO( "vcl.opengl", "BEGIN PAINT " << this ); +} + +void OpenGLSalGraphicsImpl::endPaint() +{ + mnPainting--; + SAL_INFO( "vcl.opengl", "END PAINT " << this ); + if( mnPainting == 0 ) + { + maContext.makeCurrent(); + glFlush(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 1fadd50..3ad99db 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -389,7 +389,6 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_DEPTH_SIZE, 24, - GLX_DOUBLEBUFFER, None }; pVI = glXChooseVisual( pDisplay, nScreen, aAttrib ); diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 5295fd4..af7d643 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -782,11 +782,16 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, return bDrawn; } -bool OutputDevice::SwapBuffers() +void OutputDevice::BeginPaint() { - if( !mpGraphics && !AcquireGraphics() ) - return false; - return mpGraphics->SwapBuffers(); + if( mpGraphics || AcquireGraphics() ) + mpGraphics->BeginPaint(); +} + +void OutputDevice::EndPaint() +{ + if( mpGraphics || AcquireGraphics() ) + mpGraphics->EndPaint(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index b3576db..4cdaf36 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -120,8 +120,10 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) pWindowImpl->mnPaintFlags = 0; if ( !pWindowImpl->maInvalidateRegion.IsEmpty() ) { + m_pWindow->BeginPaint(); m_pWindow->PushPaintHelper(this); m_pWindow->Paint(m_aPaintRect); + m_pWindow->EndPaint(); } } @@ -277,9 +279,10 @@ void Window::ImplCallOverlapPaint() { // - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL) // because we were called from the Sal layer - ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */); OutputDevice *pOutDev = GetOutDev(); - pOutDev->SwapBuffers(); + pOutDev->BeginPaint(); + ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */); + pOutDev->EndPaint(); } } diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index 5b0062c..fed9bc6 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -267,7 +267,8 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE; - virtual bool swapBuffers() SAL_OVERRIDE { return false; } + virtual void beginPaint() SAL_OVERRIDE { } + virtual void endPaint() SAL_OVERRIDE { } public: // implementation of X11GraphicsImpl diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 9609ec8..62e8989 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -471,9 +471,14 @@ bool X11SalGraphics::drawGradient(const tools::PolyPolygon& rPoly, const Gradien return mpImpl->drawGradient(rPoly, rGradient); } -bool X11SalGraphics::SwapBuffers() +void X11SalGraphics::BeginPaint() { - return mpImpl->swapBuffers(); + return mpImpl->beginPaint(); +} + +void X11SalGraphics::EndPaint() +{ + return mpImpl->endPaint(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx index 0159f7c..b21f138 100644 --- a/vcl/win/source/gdi/gdiimpl.hxx +++ b/vcl/win/source/gdi/gdiimpl.hxx @@ -217,7 +217,8 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE; - virtual bool swapBuffers() SAL_OVERRIDE { return false; } + virtual void beginPaint() SAL_OVERRIDE { } + virtual void endPaint() SAL_OVERRIDE { } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index 4543489..6be65a2 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -1027,9 +1027,14 @@ SystemGraphicsData WinSalGraphics::GetGraphicsData() const return aRes; } -bool WinSalGraphics::SwapBuffers() +void WinSalGraphics::BeginPaint() { - return mpImpl->swapBuffers(); + return mpImpl->beginPaint(); +} + +void WinSalGraphics::EndPaint() +{ + return mpImpl->endPaint(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
