Fix OpenGL chart reinitializing
Problem after ChartWindow was disabled and enabled again, OpenGL content was lost. Two things: -After setting a new OpenGLWindow the corresponding IRenderer must be set (x3DWindowProvider->update) -InitOpenGL() call should not depend on DummyChart, but on OpenGLWindow (OpenGLContext). Change-Id: If74e1945de9973d3921ceea1ca6fef39311add7a
This commit is contained in:
@@ -64,6 +64,7 @@ ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits
|
||||
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(pController->getModel(), uno::UNO_QUERY_THROW);
|
||||
sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(m_pOpenGLWindow);
|
||||
x3DWindowProvider->setWindow(nWindowPtr);
|
||||
x3DWindowProvider->update();
|
||||
}
|
||||
|
||||
ChartWindow::~ChartWindow()
|
||||
@@ -72,6 +73,7 @@ ChartWindow::~ChartWindow()
|
||||
{
|
||||
uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(m_pWindowController->getModel(), uno::UNO_QUERY_THROW);
|
||||
x3DWindowProvider->setWindow(0);
|
||||
x3DWindowProvider->update();
|
||||
}
|
||||
delete m_pOpenGLWindow;
|
||||
}
|
||||
|
@@ -238,7 +238,7 @@ public:
|
||||
/**
|
||||
* Only necessary for stateless implementations
|
||||
*/
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape) = 0;
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, bool bInitOpenGL = true) = 0;
|
||||
|
||||
virtual bool preRender(OpenGLWindow* pWindow) = 0;
|
||||
virtual void postRender(OpenGLWindow* pWindow) = 0;
|
||||
|
@@ -184,7 +184,7 @@ public:
|
||||
|
||||
virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize ) SAL_OVERRIDE;
|
||||
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xDrawPage) SAL_OVERRIDE;
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xDrawPage, bool bInitOpenGL = true) SAL_OVERRIDE;
|
||||
|
||||
virtual bool preRender(OpenGLWindow* pWindow) SAL_OVERRIDE;
|
||||
virtual void postRender(OpenGLWindow* pWindow) SAL_OVERRIDE;
|
||||
|
@@ -197,7 +197,7 @@ public:
|
||||
/**
|
||||
* not necessary right now
|
||||
*/
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > ) SAL_OVERRIDE {}
|
||||
virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >, bool ) SAL_OVERRIDE {}
|
||||
|
||||
virtual bool preRender(OpenGLWindow*) SAL_OVERRIDE { return true; }
|
||||
virtual void postRender(OpenGLWindow*) SAL_OVERRIDE {}
|
||||
|
@@ -166,6 +166,7 @@ public:
|
||||
virtual void scroll(long nDelta) SAL_OVERRIDE;
|
||||
virtual void contextDestroyed() SAL_OVERRIDE;
|
||||
|
||||
const OpenGLWindow* getOpenGLWindow() const;
|
||||
void updateOpenGLWindow();
|
||||
private:
|
||||
ChartView* mpView;
|
||||
@@ -208,6 +209,11 @@ void GL2DRenderer::contextDestroyed()
|
||||
mbContextDestroyed = true;
|
||||
}
|
||||
|
||||
const OpenGLWindow* GL2DRenderer::getOpenGLWindow() const
|
||||
{
|
||||
return mpWindow;
|
||||
}
|
||||
|
||||
void GL2DRenderer::updateOpenGLWindow()
|
||||
{
|
||||
if(mbContextDestroyed)
|
||||
@@ -2765,7 +2771,7 @@ void ChartView::render()
|
||||
bool bRender = pShapeFactory->preRender(pWindow);
|
||||
if(bRender)
|
||||
{
|
||||
pShapeFactory->render(mxRootShape);
|
||||
pShapeFactory->render(mxRootShape, pWindow != mp2DRenderer->getOpenGLWindow());
|
||||
pShapeFactory->postRender(pWindow);
|
||||
}
|
||||
}
|
||||
|
@@ -395,6 +395,7 @@ public:
|
||||
virtual void render() SAL_OVERRIDE;
|
||||
|
||||
void clear();
|
||||
void invalidateInit() { mbNotInit = true; }
|
||||
TextCache& getTextCache() { return maTextCache;}
|
||||
|
||||
private:
|
||||
|
@@ -446,9 +446,13 @@ uno::Reference< drawing::XShape >
|
||||
return pText;
|
||||
}
|
||||
|
||||
void OpenglShapeFactory::render(uno::Reference< drawing::XShapes > xRootShape)
|
||||
void OpenglShapeFactory::render(uno::Reference< drawing::XShapes > xRootShape, bool bInitOpenGL)
|
||||
{
|
||||
dummy::DummyChart& rChart = dynamic_cast<dummy::DummyChart&>(*xRootShape.get());
|
||||
if(bInitOpenGL)
|
||||
{
|
||||
rChart.invalidateInit();
|
||||
}
|
||||
rChart.render();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user