move to OpenGLWindow step one
Change-Id: I9f019a397f8b0daf27f0969b1f23539438eb6422
This commit is contained in:
parent
adde053786
commit
8822b255e5
9 changed files with 57 additions and 123 deletions
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include <rtl/ustring.hxx>
|
||||
|
||||
class OpenGLWindow;
|
||||
|
||||
namespace chart {
|
||||
|
||||
|
||||
|
@ -239,6 +241,9 @@ public:
|
|||
*/
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage) = 0;
|
||||
|
||||
virtual bool preRender(OpenGLWindow* pWindow) = 0;
|
||||
virtual void postRender(OpenGLWindow* pWindow) = 0;
|
||||
|
||||
virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage) = 0;
|
||||
|
||||
static ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
|
||||
|
@ -284,6 +289,7 @@ public:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -186,6 +186,9 @@ public:
|
|||
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage) SAL_OVERRIDE;
|
||||
|
||||
virtual bool preRender(OpenGLWindow* pWindow) SAL_OVERRIDE;
|
||||
virtual void postRender(OpenGLWindow* pWindow) SAL_OVERRIDE;
|
||||
|
||||
virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > xDrawPage) SAL_OVERRIDE;
|
||||
};
|
||||
|
||||
|
|
|
@ -199,6 +199,9 @@ public:
|
|||
*/
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > ) SAL_OVERRIDE {}
|
||||
|
||||
virtual bool preRender(OpenGLWindow*) SAL_OVERRIDE { return true; }
|
||||
virtual void postRender(OpenGLWindow*) SAL_OVERRIDE {}
|
||||
|
||||
virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > ) SAL_OVERRIDE {}
|
||||
|
||||
private:
|
||||
|
|
|
@ -2615,7 +2615,13 @@ void ChartView::createShapes()
|
|||
//cleanup: remove all empty group shapes to avoid grey border lines:
|
||||
lcl_removeEmptyGroupShapes( mxRootShape );
|
||||
|
||||
pShapeFactory->render( m_xDrawPage );
|
||||
OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
|
||||
bool bRender = pShapeFactory->preRender(pWindow);
|
||||
if(bRender)
|
||||
{
|
||||
pShapeFactory->render(m_xDrawPage);
|
||||
pShapeFactory->postRender(pWindow);
|
||||
}
|
||||
|
||||
if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
|
||||
{
|
||||
|
|
|
@ -1145,9 +1145,9 @@ void DummyXShapes::render()
|
|||
}
|
||||
}
|
||||
|
||||
DummyChart::DummyChart(uno::Reference< drawing::XShape > xTarget):
|
||||
DummyChart::DummyChart():
|
||||
mbNotInit(true),
|
||||
m_GLRender(xTarget)
|
||||
m_GLRender()
|
||||
{
|
||||
SAL_INFO("chart2.opengl", "DummyXShape::DummyChart()-----test: ");
|
||||
setName("com.sun.star.chart2.shapes");
|
||||
|
|
|
@ -387,7 +387,7 @@ protected:
|
|||
class DummyChart : public DummyXShapes
|
||||
{
|
||||
public:
|
||||
DummyChart(com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xDrawPage);
|
||||
DummyChart();
|
||||
virtual ~DummyChart();
|
||||
virtual DummyChart* getRootShape() SAL_OVERRIDE;
|
||||
|
||||
|
|
|
@ -375,49 +375,6 @@ void OpenGLRender::prepareToRender()
|
|||
|
||||
void OpenGLRender::renderToBitmap()
|
||||
{
|
||||
if (mbArbMultisampleSupported)
|
||||
{
|
||||
GLenum status;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_frameBufferMS);
|
||||
status = glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
SAL_INFO("chart2.opengl", "The frame buffer status is not complete!");
|
||||
}
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FboID[0]);
|
||||
status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
SAL_INFO("chart2.opengl", "The frame buffer status is not complete!");
|
||||
}
|
||||
glBlitFramebuffer(0, 0 ,m_iWidth, m_iHeight, 0, 0,m_iWidth ,m_iHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER,0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_FboID[0]);
|
||||
|
||||
BitmapEx aBitmap = GetAsBitmap();
|
||||
#if RENDER_TO_FILE
|
||||
static int nIdx = 0;
|
||||
OUString aName = OUString( "file:///home/moggi/Documents/work/text" ) + OUString::number( nIdx++ ) + ".png";
|
||||
try {
|
||||
vcl::PNGWriter aWriter( aBitmap );
|
||||
SvFileStream sOutput( aName, STREAM_WRITE );
|
||||
aWriter.Write( sOutput );
|
||||
sOutput.Close();
|
||||
} catch (...) {
|
||||
SAL_WARN("chart2.opengl", "Error writing png to " << aName);
|
||||
}
|
||||
#else
|
||||
Graphic aGraphic(aBitmap);
|
||||
uno::Reference< awt::XBitmap> xBmp( aGraphic.GetXGraphic(), uno::UNO_QUERY );
|
||||
uno::Reference < beans::XPropertySet > xPropSet ( mxTarget, uno::UNO_QUERY );
|
||||
xPropSet->setPropertyValue("Graphic", uno::makeAny(aGraphic.GetXGraphic()));
|
||||
mxTarget->setSize(awt::Size(m_iWidth*OPENGL_SCALE_VALUE, m_iHeight*OPENGL_SCALE_VALUE));
|
||||
mxTarget->setPosition(awt::Point(0,0));
|
||||
#endif
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
int OpenGLRender::CreateTextureObj(int width, int height)
|
||||
|
@ -502,9 +459,8 @@ void OpenGLRender::Release()
|
|||
glDeleteRenderbuffers(1, &m_renderBufferDepthMS);
|
||||
}
|
||||
|
||||
OpenGLRender::OpenGLRender(uno::Reference< drawing::XShape > xTarget)
|
||||
: mxTarget(xTarget)
|
||||
, m_iWidth(1600)
|
||||
OpenGLRender::OpenGLRender()
|
||||
: m_iWidth(1600)
|
||||
, m_iHeight(900)
|
||||
, m_Model(glm::mat4(1.0f))
|
||||
, m_VertexBuffer(0)
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef std::vector<GLfloat> PointList;
|
|||
class OpenGLRender
|
||||
{
|
||||
public:
|
||||
OpenGLRender(com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xTarget);
|
||||
OpenGLRender();
|
||||
~OpenGLRender();
|
||||
int InitOpenGL();
|
||||
int MoveModelf(PosVecf3 trans, PosVecf3 angle, PosVecf3 scale);
|
||||
|
@ -125,9 +125,6 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
|
||||
com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxTarget;
|
||||
|
||||
#if 0
|
||||
//for performance
|
||||
double m_dFreq;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <svx/svdocirc.hxx>
|
||||
#include <svx/svdopath.hxx>
|
||||
#include <vcl/opengl/IOpenGLRenderer.hxx>
|
||||
#include <vcl/openglwin.hxx>
|
||||
|
||||
#include <basegfx/point/b2dpoint.hxx>
|
||||
#include <basegfx/matrix/b3dhommatrix.hxx>
|
||||
|
@ -64,24 +65,6 @@ extern "C" {
|
|||
{ return new opengl::OpenglShapeFactory();}
|
||||
}
|
||||
|
||||
class OpenGLChartAdapter : public IOpenGLRenderer
|
||||
{
|
||||
public:
|
||||
OpenGLChartAdapter(uno::Reference<drawing::XShapes> xShapes):
|
||||
mxShapes(xShapes) {}
|
||||
|
||||
virtual ~OpenGLChartAdapter() {}
|
||||
|
||||
uno::Reference<drawing::XShapes> getShapes()
|
||||
{
|
||||
return mxShapes;
|
||||
}
|
||||
|
||||
private:
|
||||
uno::Reference<drawing::XShapes> mxShapes; // here to fix lifetime
|
||||
};
|
||||
|
||||
|
||||
using dummy::DummyXShape;
|
||||
using dummy::DummyXShapes;
|
||||
using dummy::DummyCylinder;
|
||||
|
@ -93,8 +76,10 @@ namespace opengl {
|
|||
|
||||
namespace {
|
||||
|
||||
IOpenGLRenderer* getRenderer(const uno::Reference< drawing::XDrawPage>& xDrawPage )
|
||||
uno::Reference< drawing::XShapes > getChartShape(
|
||||
const uno::Reference< drawing::XDrawPage>& xDrawPage )
|
||||
{
|
||||
uno::Reference< drawing::XShapes > xRet;
|
||||
uno::Reference< drawing::XShapes > xShapes( xDrawPage, uno::UNO_QUERY );
|
||||
if( xShapes.is() )
|
||||
{
|
||||
|
@ -104,33 +89,20 @@ IOpenGLRenderer* getRenderer(const uno::Reference< drawing::XDrawPage>& xDrawPag
|
|||
{
|
||||
if( xShapes->getByIndex( nN ) >>= xShape )
|
||||
{
|
||||
|
||||
OUString aRet;
|
||||
|
||||
uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
|
||||
xProp->getPropertyValue( UNO_NAME_MISC_OBJ_NAME ) >>= aRet;
|
||||
if( aRet.equals("com.sun.star.chart2.shapes") )
|
||||
{
|
||||
SvxOpenGLObject* pGLObj = dynamic_cast<SvxOpenGLObject*>(xShape.get());
|
||||
IOpenGLRenderer* pRenderer = pGLObj ? pGLObj->getRenderer() : NULL;
|
||||
if (pRenderer)
|
||||
return pRenderer;
|
||||
xRet = dynamic_cast<SvxDummyShapeContainer*>(xShape.get())->getWrappedShape();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uno::Reference< drawing::XShapes > getChartShape(
|
||||
const uno::Reference< drawing::XDrawPage>& xDrawPage )
|
||||
{
|
||||
IOpenGLRenderer* pRenderer = getRenderer(xDrawPage);
|
||||
OpenGLChartAdapter* pAdapter = dynamic_cast<OpenGLChartAdapter*>(pRenderer);
|
||||
if(pAdapter)
|
||||
return pAdapter->getShapes();
|
||||
|
||||
return uno::Reference< drawing::XShapes> ();
|
||||
return xRet;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -144,20 +116,11 @@ uno::Reference< drawing::XShapes > OpenglShapeFactory::getOrCreateChartRootShape
|
|||
//create the root shape
|
||||
SAL_WARN("chart2.opengl", "getOrCreateChartRootShape");
|
||||
|
||||
uno::Reference< drawing::XShape > xTarget (m_xShapeFactory->createInstance(
|
||||
"com.sun.star.drawing.OpenGLObject" ), uno::UNO_QUERY );
|
||||
uno::Reference<drawing::XShapes> xChart(new dummy::DummyChart(xTarget));
|
||||
xDrawPage->add(xTarget);
|
||||
uno::Any aName;
|
||||
aName <<= OUString("com.sun.star.chart2.shapes");
|
||||
uno::Reference<beans::XPropertySet> xPropSet( xTarget, uno::UNO_QUERY_THROW );
|
||||
xPropSet->setPropertyValue( UNO_NAME_MISC_OBJ_NAME, aName );
|
||||
|
||||
SvxOpenGLObject* pObj = dynamic_cast<SvxOpenGLObject*>(xTarget.get());
|
||||
if (pObj)
|
||||
pObj->setRenderer(new OpenGLChartAdapter(xChart));
|
||||
|
||||
xRet = getChartShape( xDrawPage );
|
||||
dummy::DummyChart *pChart = new dummy::DummyChart();
|
||||
SvxDummyShapeContainer* pContainer = new SvxDummyShapeContainer(pChart);
|
||||
pContainer->setSize(awt::Size(0,0));
|
||||
xRet = pChart;
|
||||
xDrawPage->add(pContainer);
|
||||
}
|
||||
return xRet;
|
||||
}
|
||||
|
@ -486,32 +449,32 @@ uno::Reference< drawing::XShape >
|
|||
|
||||
void OpenglShapeFactory::render(uno::Reference< drawing::XDrawPage > xDrawPage)
|
||||
{
|
||||
IOpenGLRenderer* pRenderer = getRenderer(xDrawPage);
|
||||
if(!pRenderer)
|
||||
return;
|
||||
|
||||
if(!pRenderer->isOpenGLInitialized())
|
||||
return;
|
||||
|
||||
OpenGLChartAdapter* pAdapter = dynamic_cast<OpenGLChartAdapter*>(pRenderer);
|
||||
if(!pAdapter)
|
||||
return;
|
||||
|
||||
uno::Reference< drawing::XShapes > xRootShape = pAdapter->getShapes();
|
||||
uno::Reference< drawing::XShapes > xRootShape = getChartShape(xDrawPage);
|
||||
dummy::DummyChart* pChart = dynamic_cast<dummy::DummyChart*>(xRootShape.get());
|
||||
assert(pChart);
|
||||
pChart->render();
|
||||
}
|
||||
|
||||
bool OpenglShapeFactory::preRender(OpenGLWindow* pWindow)
|
||||
{
|
||||
if(!pWindow)
|
||||
return false;
|
||||
|
||||
pWindow->Show();
|
||||
pWindow->getContext()->makeCurrent();
|
||||
Size aSize = pWindow->GetSizePixel();
|
||||
pWindow->getContext()->setWinSize(aSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenglShapeFactory::postRender(OpenGLWindow* pWindow)
|
||||
{
|
||||
pWindow->getContext()->swapBuffers();
|
||||
}
|
||||
|
||||
void OpenglShapeFactory::clearPage(uno::Reference< drawing::XDrawPage > xDrawPage)
|
||||
{
|
||||
IOpenGLRenderer* pRenderer = getRenderer(xDrawPage);
|
||||
|
||||
OpenGLChartAdapter* pAdapter = dynamic_cast<OpenGLChartAdapter*>(pRenderer);
|
||||
if(!pAdapter)
|
||||
return;
|
||||
|
||||
uno::Reference< drawing::XShapes > xRootShape = pAdapter->getShapes();
|
||||
uno::Reference< drawing::XShapes > xRootShape = getChartShape(xDrawPage);
|
||||
dummy::DummyChart* pChart = dynamic_cast<dummy::DummyChart*>(xRootShape.get());
|
||||
assert(pChart);
|
||||
pChart->clear();
|
||||
|
|
Loading…
Reference in a new issue