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:
Zolnai Tamás
2014-07-20 09:52:04 +02:00
parent 46cea34638
commit cbc50c90ad
7 changed files with 18 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {}

View File

@@ -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);
}
}

View File

@@ -395,6 +395,7 @@ public:
virtual void render() SAL_OVERRIDE;
void clear();
void invalidateInit() { mbNotInit = true; }
TextCache& getTextCache() { return maTextCache;}
private:

View File

@@ -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();
}