[Libreoffice-commits] core.git: Branch 'feature/opengl-canvas-rework' - 2 commits - canvas/source
Michael Jaumann
meta_dev at yahoo.com
Thu Dec 18 04:20:43 PST 2014
canvas/source/opengl/ogl_canvascustomsprite.cxx | 47 ++++++++++++------------
canvas/source/opengl/ogl_canvashelper.cxx | 17 +++++++-
2 files changed, 39 insertions(+), 25 deletions(-)
New commits:
commit c74a5358d92e3c163da541add4682e9f24482f4c
Author: Michael Jaumann <meta_dev at yahoo.com>
Date: Thu Dec 18 12:17:45 2014 +0000
subdivide bezier curves
Change-Id: I616eefabc083d78bd259689c77908edd45788cd6
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index 992fe87..9aa92e2 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -543,14 +543,27 @@ namespace oglcanvas
Action& rAct=mpRecordedActions->back();
setupGraphicsState( rAct, viewState, renderState );
+ //untested code, otherways commented out should work...
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(aBezierSegment.Px, aBezierSegment.Py));
+ aPoly.appendBezierSegment( basegfx::B2DPoint(aBezierSegment.C1x, aBezierSegment.C1y),
+ basegfx::B2DPoint(aBezierSegment.C1x, aBezierSegment.C1y),
+ basegfx::B2DPoint(aEndPoint.X,aEndPoint.Y));
+
+ basegfx::B2DPolyPolygon aPolyPoly;
+ aPolyPoly.append(aPoly);
+ rAct.maPolyPolys.push_back(aPolyPoly);
+ rAct.maPolyPolys.back().makeUnique(); // own copy, for thread safety
+ rAct.maFunction = lcl_drawPolyPolygon;
// TODO(F2): subdivide&render whole curve
- rAct.maFunction = ::boost::bind(&lcl_drawLine,
+ /* rAct.maFunction = ::boost::bind(&lcl_drawLine,
_1,_2,_3,_4,_5,
geometry::RealPoint2D(
aBezierSegment.Px,
aBezierSegment.Py),
- aEndPoint);
+ aEndPoint);*/
+
}
}
commit 9c3a9e987bc5a7b5f8e84349fc8c39a3999011f9
Author: Michael Jaumann <meta_dev at yahoo.com>
Date: Thu Dec 18 12:11:17 2014 +0000
renderSprite
renders still to framebuffer with the wrong offset ( polygon is
clipped, or entire out of texture bounds )
Change-Id: I485fd141c73d1e9783db7f4638bb33875e3af9be
diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx
index 9962eb4..ac8272e 100644
--- a/canvas/source/opengl/ogl_canvascustomsprite.cxx
+++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx
@@ -25,6 +25,7 @@
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <GL/glew.h>
+#include <vcl/opengl/GLMHelper.hxx>
using namespace ::com::sun::star;
@@ -131,42 +132,46 @@ namespace oglcanvas
if( ::basegfx::fTools::equalZero( mfAlpha ) )
return true;
- const glm::vec2 aSpriteSizePixel(
- ::canvas::tools::roundUp( maSize.Width ),
- ::canvas::tools::roundUp( maSize.Height ));
- RenderHelper* pRenderHelper = maCanvasHelper.getDeviceHelper()->getRenderHelper();
+ const glm::vec2 aSpriteSizePixel(
+ ::canvas::tools::roundUp( maSize.Width),
+ ::canvas::tools::roundUp( maSize.Height));
+
+ RenderHelper* pRenderHelper = maCanvasHelper.getDeviceHelper()->getRenderHelper();
IBufferContextSharedPtr pBufferContext;
- if( mfAlpha != 1.0 || mxClip.is() )
+
+ if( mfAlpha != 0.0 || mxClip.is() )
{
// drats. need to render to temp surface before, and then
// composite that to screen
// 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"
if( !maCanvasHelper.renderRecordedActions() )
return false;
-
const glm::mat4 translate = glm::translate(glm::vec3(maPosition.getX(), maPosition.getY(), 0));
if( pBufferContext )
{
+ //pRenderHelper->SetModelAndMVP( aGLTransform);
+ // content ended up in background buffer - compose to
+ // screen now. Calls below switches us back to window
+ // context, and binds to generated, dynamic texture
+
+ pBufferContext->endBufferRendering();
+
const glm::mat4 aGLTransform = glm::mat4(
maTransformation.m00, maTransformation.m10, 0, 0,
maTransformation.m01, maTransformation.m11, 0, 0,
0, 0, 1, 0,
maTransformation.m02, maTransformation.m12, 0, 1
- );
+ );
+
+ pRenderHelper->SetModelAndMVP( translate *aGLTransform );
- //pRenderHelper->SetModelAndMVP(translate * aGLTransform);
- pRenderHelper->SetModelAndMVP( aGLTransform);
- // content ended up in background buffer - compose to
- // screen now. Calls below switches us back to window
- // context, and binds to generated, dynamic texture
- pBufferContext->endBufferRendering();
GLuint nTexture = pBufferContext->getTextureId();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, nTexture);
@@ -212,22 +217,19 @@ namespace oglcanvas
}
else
{
- const double fWidth=maSize.Width/aSpriteSizePixel.x;
- const double fHeight=maSize.Height/aSpriteSizePixel.y;
-
std::vector<glm::vec2> vertices;
vertices.reserve(4);
- vertices.push_back(glm::vec2(0, 0));
- vertices.push_back(glm::vec2(0, (float) aSpriteSizePixel.y));
vertices.push_back(glm::vec2((float) aSpriteSizePixel.x, 0));
vertices.push_back(glm::vec2((float) aSpriteSizePixel.x, (float) aSpriteSizePixel.y));
+ vertices.push_back(glm::vec2(0, 0));
+ vertices.push_back(glm::vec2(0, (float) aSpriteSizePixel.y));
std::vector<glm::vec2> uvCoordinates;
uvCoordinates.reserve(4);
+ uvCoordinates.push_back(glm::vec2(1, 1));
+ uvCoordinates.push_back(glm::vec2(1, 0));
+ uvCoordinates.push_back(glm::vec2(0, 1));
uvCoordinates.push_back(glm::vec2(0, 0));
- uvCoordinates.push_back(glm::vec2(0, (float) fHeight));
- uvCoordinates.push_back(glm::vec2((float) fWidth, 0));
- uvCoordinates.push_back(glm::vec2((float) fWidth, (float) fHeight));
pRenderHelper->renderVertexUVTex(vertices, uvCoordinates, color, GL_TRIANGLE_STRIP );
}
@@ -235,7 +237,6 @@ namespace oglcanvas
glBindTexture(GL_TEXTURE_2D, 0);
}
-
std::vector<glm::vec2> vertices;
vertices.reserve(6);
vertices.push_back(glm::vec2(-2, -2));
More information about the Libreoffice-commits
mailing list