basegfx/source/polygon/b2dpolygon.cxx | 36 ++++++++++++++++++++---- basegfx/source/polygon/b2dpolypolygon.cxx | 12 ++++++++ canvas/source/opengl/ogl_canvascustomsprite.cxx | 24 ++++++++-------- canvas/source/opengl/ogl_canvastools.cxx | 11 ++++--- canvas/source/opengl/ogl_renderHelper.cxx | 10 ++++++ canvas/source/opengl/ogl_renderHelper.hxx | 5 +++ canvas/source/opengl/ogl_spritedevicehelper.cxx | 1 include/basegfx/polygon/b2dpolygon.hxx | 9 ++++++ include/basegfx/polygon/b2dpolypolygon.hxx | 9 ++++++ 9 files changed, 96 insertions(+), 21 deletions(-)
New commits: commit 8c9106457ac8c515b052cbd27f6c14414b11cfbf Author: Michael Jaumann <meta_...@yahoo.com> Date: Wed Jan 14 12:51:43 2015 +0000 set correct projection and viewport for sprites each sprite is drawn to a framebuffer/ texture set projection and viewport to the sprite resolution Change-Id: I3c6c53729c76ee1dc4fcb53b5b31b912be782d49 diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx index ac8272e..7acaceb 100644 --- a/canvas/source/opengl/ogl_canvascustomsprite.cxx +++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx @@ -139,6 +139,9 @@ namespace oglcanvas RenderHelper* pRenderHelper = maCanvasHelper.getDeviceHelper()->getRenderHelper(); IBufferContextSharedPtr pBufferContext; + GLint myviewport[4]; + glGetIntegerv(GL_VIEWPORT, myviewport); + if( mfAlpha != 0.0 || mxClip.is() ) { // drats. need to render to temp surface before, and then @@ -146,12 +149,20 @@ namespace oglcanvas // TODO(P3): buffer texture pBufferContext = maCanvasHelper.getDeviceHelper()->createBufferContext(aSpriteSizePixel); - //glViewport(0, 0,aSpriteSizePixel.x,aSpriteSizePixel.y); pBufferContext->startBufferRendering(); } // this ends up in pBufferContext, if that one's "current" + // Draw in spriteresolution + const glm::mat4 oldResulution = pRenderHelper->GetVP(); + pRenderHelper->SetVP(aSpriteSizePixel.x, aSpriteSizePixel.y); + glViewport(0, 0,aSpriteSizePixel.x,aSpriteSizePixel.y); + if( !maCanvasHelper.renderRecordedActions() ) return false; + + //go back to window resolution + pRenderHelper->SetVP(oldResulution); + glViewport(myviewport[0], myviewport[1],myviewport[2],myviewport[3]); const glm::mat4 translate = glm::translate(glm::vec3(maPosition.getX(), maPosition.getY(), 0)); if( pBufferContext ) { @@ -172,6 +183,7 @@ namespace oglcanvas pRenderHelper->SetModelAndMVP( translate *aGLTransform ); + GLuint nTexture = pBufferContext->getTextureId(); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, nTexture); @@ -237,16 +249,6 @@ namespace oglcanvas glBindTexture(GL_TEXTURE_2D, 0); } - std::vector<glm::vec2> vertices; - vertices.reserve(6); - vertices.push_back(glm::vec2(-2, -2)); - vertices.push_back(glm::vec2(-2, (float) maSize.Height+4)); - vertices.push_back(glm::vec2((float) maSize.Width+4, (float) maSize.Height+4)); - vertices.push_back(glm::vec2((float) maSize.Width+4, -2)); - vertices.push_back(glm::vec2(-2, -2)); - vertices.push_back(glm::vec2((float) maSize.Width+4, (float) maSize.Height+4)); - - pRenderHelper->renderVertexConstColor(vertices, glm::vec4(1, 0, 0, 1), GL_LINE_STRIP); #ifdef DEBUG_RENDERING std::vector<double> aVec; diff --git a/canvas/source/opengl/ogl_renderHelper.cxx b/canvas/source/opengl/ogl_renderHelper.cxx index 50e1269..21e03b4 100644 --- a/canvas/source/opengl/ogl_renderHelper.cxx +++ b/canvas/source/opengl/ogl_renderHelper.cxx @@ -87,6 +87,15 @@ namespace oglcanvas void RenderHelper::SetVP(const float nwidth, const float nheight) { m_VP = glm::ortho(0.0f, nwidth, nheight, 0.0f); + + void RenderHelper::SetVP(const glm::mat4 vp) + { + m_VP = vp; + } + + glm::mat4 RenderHelper::GetVP() + { + return m_VP; } static void cleanUp() @@ -142,6 +151,7 @@ namespace oglcanvas glDeleteProgram( m_texManProgID); glDeleteProgram( m_simpleProgID); glDeleteProgram( m_texProgID); + glDeleteProgram( m_texTransProgID); glDeleteProgram( mnRectangularTwoColorGradientProgram ); glDeleteProgram( mnRectangularMultiColorGradientProgram ); glDeleteProgram( mnRadialTwoColorGradientProgram ); diff --git a/canvas/source/opengl/ogl_renderHelper.hxx b/canvas/source/opengl/ogl_renderHelper.hxx index 011120a..383bbbc 100644 --- a/canvas/source/opengl/ogl_renderHelper.hxx +++ b/canvas/source/opengl/ogl_renderHelper.hxx @@ -55,6 +55,11 @@ namespace oglcanvas RenderHelper(); void SetVP(const float width, const float height); + + void SetVP(const glm::mat4 vp); + + glm::mat4 GetVP(); + void SetModelAndMVP(const glm::mat4& mat); void dispose(); void InitOpenGL(); commit 90a283dd5fcaf58b1955061cfcaa7baff140392c Author: Michael Jaumann <meta_...@yahoo.com> Date: Tue Jan 13 13:21:05 2015 +0000 show backbuffer Change-Id: Iefec84321103ca0d5ac28585403dbeed74d1a9f3 diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx index 087cedd..ce2a5f3 100644 --- a/canvas/source/opengl/ogl_spritedevicehelper.cxx +++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx @@ -310,6 +310,7 @@ namespace oglcanvas unx::glXWaitGL(); XSync( reinterpret_cast<unx::Display*>(mpDisplay), false ); */ + pChildWindow->Show(); mpContext->swapBuffers(); // flush texture cache, such that it does not build up commit eac0340c53a2b642ed6dd7cadd80e535ab21f908 Author: Michael Jaumann <meta_...@yahoo.com> Date: Fri Dec 19 08:45:59 2014 +0000 subdevide bezier segments into more points Change-Id: I239bb6cba30c5a01c0b7973d55b94779898ddb90 diff --git a/canvas/source/opengl/ogl_canvastools.cxx b/canvas/source/opengl/ogl_canvastools.cxx index cc41d1c..eacac6b 100644 --- a/canvas/source/opengl/ogl_canvastools.cxx +++ b/canvas/source/opengl/ogl_canvastools.cxx @@ -21,8 +21,9 @@ #include <com/sun/star/rendering/ARGBColor.hpp> #include <GL/glew.h> -#include <glm/gtc/type_ptr.hpp> +//subdivision count of bezier segments +#define COUNT_OF_ADAPTIVE_SUBDIVISION 40 using namespace ::com::sun::star; @@ -34,7 +35,7 @@ namespace oglcanvas { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) - aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); + aPolyPoly = rPolyPoly.getAdaptiveSubdivision(COUNT_OF_ADAPTIVE_SUBDIVISION); const ::basegfx::B2DPolygon& rTriangulatedPolygon( ::basegfx::triangulator::triangulate(aPolyPoly)); if(rTriangulatedPolygon.count()>0) @@ -56,7 +57,7 @@ namespace oglcanvas { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) - aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); + aPolyPoly = rPolyPoly.getAdaptiveSubdivision(COUNT_OF_ADAPTIVE_SUBDIVISION); const ::basegfx::B2DRange& rBounds(aPolyPoly.getB2DRange()); const double nWidth=rBounds.getWidth(); const double nHeight=rBounds.getHeight(); @@ -75,6 +76,7 @@ namespace oglcanvas } } + /** only use this for line polygons. better not leave triangulation to OpenGL. also, ignores texturing @@ -83,11 +85,10 @@ namespace oglcanvas { ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly); if( aPolyPoly.areControlPointsUsed() ) - aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision(); + aPolyPoly = rPolyPoly.getAdaptiveSubdivision(COUNT_OF_ADAPTIVE_SUBDIVISION); for(sal_uInt32 i=0; i<aPolyPoly.count(); i++ ) { - const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) ); const sal_uInt32 nPts=rPolygon.count(); commit 39fabcb219f9025abd9acc3109611b8410755e68 Author: Michael Jaumann <meta_...@yahoo.com> Date: Fri Dec 19 08:38:47 2014 +0000 adaptive subdivision of bezier curves additional method with a parameter, count of calculated points, instead of default point count Change-Id: I60d8977f6785dfb804228b0c88118897e860db6c diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 096c4a0..850c41e 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -481,12 +481,17 @@ public: const basegfx::B2DPolygon& getDefaultAdaptiveSubdivision(const basegfx::B2DPolygon& rSource) const { - if(!mpDefaultSubdivision) - { - const_cast< ImplBufferedData* >(this)->mpDefaultSubdivision.reset(new basegfx::B2DPolygon(basegfx::tools::adaptiveSubdivideByCount(rSource, 9))); - } + return getAdaptiveSubdivision(rSource, 9); + } - return *mpDefaultSubdivision; + + const basegfx::B2DPolygon& getAdaptiveSubdivision(const basegfx::B2DPolygon& rSource, const sal_uInt32 nCount) const + { + if(!mpDefaultSubdivision) + { + const_cast< ImplBufferedData* >(this)->mpDefaultSubdivision.reset(new basegfx ::B2DPolygon(basegfx::tools::adaptiveSubdivideByCount(rSource,nCount))); + } + return *mpDefaultSubdivision; } const basegfx::B2DRange& getB2DRange(const basegfx::B2DPolygon& rSource) const @@ -591,6 +596,22 @@ public: return mpBufferedData->getDefaultAdaptiveSubdivision(rSource); } + + const basegfx::B2DPolygon& getAdaptiveSubdivision(const basegfx::B2DPolygon& rSource, const sal_uInt32 nCount) const + { + if(!mpControlVector || !mpControlVector->isUsed()) + { + return rSource; + } + + if(!mpBufferedData) + { + const_cast< ImplB2DPolygon* >(this)->mpBufferedData.reset(new ImplBufferedData); + } + + return mpBufferedData->getAdaptiveSubdivision(rSource, nCount); + } + const basegfx::B2DRange& getB2DRange(const basegfx::B2DPolygon& rSource) const { if(!mpBufferedData) @@ -1379,6 +1400,11 @@ namespace basegfx return mpPolygon->getDefaultAdaptiveSubdivision(*this); } + B2DPolygon B2DPolygon::getAdaptiveSubdivision(const sal_uInt32 nCount) const + { + return mpPolygon->getAdaptiveSubdivision(*this, nCount); + } + B2DRange B2DPolygon::getB2DRange() const { return mpPolygon->getB2DRange(*this); diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 92b74e7..4b0dfe9 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -283,6 +283,18 @@ namespace basegfx return aRetval; } + B2DPolyPolygon B2DPolyPolygon::getAdaptiveSubdivision(const sal_uInt32 nCount) const + { + B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0L); a < mpPolyPolygon->count(); a++) + { + aRetval.append(mpPolyPolygon->getB2DPolygon(a).getAdaptiveSubdivision(nCount)); + } + + return aRetval; + } + B2DRange B2DPolyPolygon::getB2DRange() const { B2DRange aRetval; diff --git a/include/basegfx/polygon/b2dpolygon.hxx b/include/basegfx/polygon/b2dpolygon.hxx index da88050..a74fdfb 100644 --- a/include/basegfx/polygon/b2dpolygon.hxx +++ b/include/basegfx/polygon/b2dpolygon.hxx @@ -148,6 +148,15 @@ namespace basegfx */ B2DPolygon getDefaultAdaptiveSubdivision() const; + /** adaptive subdivision access + + see getDefaultAdaptiveSubdivision + + @nCount + count of subdivision, creates nCount+1 edges + and nCount +2 points + */ + B2DPolygon getAdaptiveSubdivision(const sal_uInt32 nCount) const; /** Get the B2DRange (Rectangle dimensions) of this B2DPolygon A polygon may have up to three ranges: diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx index 07bffcd..37a9a36 100644 --- a/include/basegfx/polygon/b2dpolypolygon.hxx +++ b/include/basegfx/polygon/b2dpolypolygon.hxx @@ -85,6 +85,15 @@ namespace basegfx */ B2DPolyPolygon getDefaultAdaptiveSubdivision() const; + /** adaptive subdivision access + + For details refer to B2DPolygon::getAdaptiveSubdivision() + + @return + The default subdivision of this polygon + */ + B2DPolyPolygon getAdaptiveSubdivision(const sal_uInt32 nCount) const; + /** Get the B2DRange (Rectangle dimensions) of this B2DPolyPolygon For details refer to B2DPolygon::getB2DRange() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits