diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-05-17 04:32:58 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-08-29 17:40:25 +0200 |
commit | 43d23a24fde16addb37376a92d36dba78263614a (patch) | |
tree | 763f4b8b9ef75da93dd6ee92b337affd0f1762dd /chart2 | |
parent | 235fa0334e0b45c736b636ba1689e2f8c7458697 (diff) |
opengl charts: Move the init from sc to chart2, to have the right parent.
Conflicts:
chart2/source/view/charttypes/GL3DBarChart.cxx
Change-Id: I1e23329345e00e7d8e1f269c832e84d015824c0a
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/Library_chartcontroller.mk | 1 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 3 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartWindow.cxx | 33 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartWindow.hxx | 9 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 1 | ||||
-rw-r--r-- | chart2/source/view/charttypes/GL3DBarChart.cxx | 60 | ||||
-rw-r--r-- | chart2/source/view/inc/GL3DBarChart.hxx | 6 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 8 |
8 files changed, 86 insertions, 35 deletions
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index f77ef70b9056..b147fc103829 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -43,6 +43,7 @@ $(eval $(call gb_Library_use_libraries,chartcontroller,\ ucbhelper \ utl \ vcl \ + vclopengl \ $(gb_UWINAPI) \ )) diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index b57045d09bfe..d5eca79114b9 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -726,6 +726,9 @@ void SAL_CALL ChartController::dispose() //--release all resources and references { + uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(getModel(), uno::UNO_QUERY_THROW); + x3DWindowProvider->setWindow(0); + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); if( xViewBroadcaster.is() ) xViewBroadcaster->removeModeChangeListener(this); diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 917d69e8ae74..37335c4b87a2 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -22,8 +22,11 @@ #include "HelpIds.hrc" #include <vcl/help.hxx> +#include <vcl/openglwin.hxx> #include <vcl/settings.hxx> +#include <com/sun/star/chart2/X3DChartWindowProvider.hpp> + using namespace ::com::sun::star; namespace @@ -42,10 +45,11 @@ namespace namespace chart { -ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ) +ChartWindow::ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle ) : Window(pParent, nStyle) - , m_pWindowController( pWindowController ) + , m_pWindowController( pController ) , m_bInPaint(false) + , m_pOpenGLWindow(new OpenGLWindow(this)) { this->SetHelpId( HID_SCH_WIN_DOCUMENT ); this->SetMapMode( MapMode(MAP_100TH_MM) ); @@ -55,10 +59,21 @@ ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, EnableRTL( false ); if( pParent ) pParent->EnableRTL( false );// #i96215# necessary for a correct position of the context menu in rtl mode + + m_pOpenGLWindow->Show(); + uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(pController->getModel(), uno::UNO_QUERY_THROW); + sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(m_pOpenGLWindow); + x3DWindowProvider->setWindow(nWindowPtr); } ChartWindow::~ChartWindow() { + if (m_pWindowController && m_pWindowController->getModel().is()) + { + uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider(m_pWindowController->getModel(), uno::UNO_QUERY_THROW); + x3DWindowProvider->setWindow(0); + } + delete m_pOpenGLWindow; } void ChartWindow::clear() @@ -79,10 +94,18 @@ void ChartWindow::PrePaint() void ChartWindow::Paint( const Rectangle& rRect ) { m_bInPaint = true; - if( m_pWindowController ) - m_pWindowController->execute_Paint( rRect ); + if (m_pOpenGLWindow && m_pOpenGLWindow->IsVisible()) + { + m_pOpenGLWindow->Paint(rRect); + } + else if (m_pWindowController) + { + m_pWindowController->execute_Paint(rRect); + } else + { Window::Paint( rRect ); + } m_bInPaint = false; } @@ -124,6 +147,8 @@ void ChartWindow::Resize() m_pWindowController->execute_Resize(); else Window::Resize(); + + m_pOpenGLWindow->SetSizePixel(GetSizePixel()); } void ChartWindow::Activate() diff --git a/chart2/source/controller/main/ChartWindow.hxx b/chart2/source/controller/main/ChartWindow.hxx index ec5c05bde7c5..ee5884f013e5 100644 --- a/chart2/source/controller/main/ChartWindow.hxx +++ b/chart2/source/controller/main/ChartWindow.hxx @@ -21,10 +21,12 @@ #include <vcl/window.hxx> +class OpenGLWindow; + namespace chart { -class WindowController; +class ChartController; /** The ChartWindow collects events from the window and forwards them the to the controller thus the controller can perform appropriate actions @@ -33,7 +35,7 @@ thus the controller can perform appropriate actions class ChartWindow : public Window { public: - ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ); + ChartWindow( ChartController* pController, Window* pParent, WinBits nStyle ); virtual ~ChartWindow(); void clear(); @@ -63,8 +65,9 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; private: - WindowController* m_pWindowController; + ChartController* m_pWindowController; bool m_bInPaint; + OpenGLWindow* m_pOpenGLWindow; void adjustHighContrastMode(); }; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index f65f5403e327..ed0d24e0b2ff 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -1412,7 +1412,6 @@ void ChartModel::setWindow( const sal_uInt64 nWindowPtr ) { void* pPtr = (void*)nWindowPtr; OpenGLWindow* pWindow = reinterpret_cast<OpenGLWindow*>(pPtr); - assert(pWindow); mpOpenGLWindow = pWindow; } diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index e43f90e5e333..e5cfb2c6d3e0 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -103,8 +103,8 @@ void RenderThread::renderFrame() if(!mpChart->mbValidContext) return; - mpChart->mrWindow.getContext().makeCurrent(); - Size aSize = mpChart->mrWindow.GetSizePixel(); + mpChart->mpWindow->getContext().makeCurrent(); + Size aSize = mpChart->mpWindow->GetSizePixel(); mpChart->mpRenderer->SetSize(aSize); if(mpChart->mbNeedsNewRender) { @@ -121,7 +121,7 @@ void RenderThread::renderFrame() } mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender); mpChart->mbNeedsNewRender = false; - mpChart->mrWindow.getContext().swapBuffers(); + mpChart->mpWindow->getContext().swapBuffers(); } @@ -438,10 +438,10 @@ void RenderBenchMarkThread::execute() GL3DBarChart::GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartType, - OpenGLWindow& rWindow) : + OpenGLWindow* pWindow) : mxChartType(xChartType), mpRenderer(new opengl3D::OpenGL3DRenderer()), - mrWindow(rWindow), + mpWindow(pWindow), mpCamera(NULL), mbValidContext(true), mpTextCache(new opengl3D::TextCache()), @@ -492,9 +492,14 @@ GL3DBarChart::GL3DBarChart( osl_getSystemTime(&maDataUpdateStartTime); osl_getSystemTime(&maDataUpdateEndTime); } - Size aSize = mrWindow.GetSizePixel(); + Size aSize; + if (mpWindow) + { + mpWindow->setRenderer(this); + Size aSize = mpWindow->GetSizePixel(); + } mpRenderer->SetSize(aSize); - mrWindow.setRenderer(this); + mpWindow->setRenderer(this); mpRenderer->init(); } @@ -518,8 +523,8 @@ GL3DBarChart::~GL3DBarChart() if(mpRenderThread.is()) mpRenderThread->join(); - if(mbValidContext) - mrWindow.setRenderer(NULL); + if(mbValidContext && mpWindow) + mpWindow->setRenderer(NULL); } void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer, @@ -741,10 +746,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer mpRenderer->SetScrollSpeed((float)(BAR_SIZE_X + BAR_DISTANCE_X) / (float)miScrollRate); mpRenderer->SetScrollDistance((float)(BAR_SIZE_X + BAR_DISTANCE_X)); } - Size aSize = mrWindow.GetSizePixel(); - mrWindow.getContext().setWinSize(aSize); + Size aSize = mpWindow->GetSizePixel(); + mpWindow->getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderBenchMarkThread(this)); - mrWindow.getContext().resetCurrent(); + mpWindow->getContext().resetCurrent(); mpRenderThread->launch(); } miDataUpdateCounter++; @@ -758,10 +763,10 @@ void GL3DBarChart::update() return; if(mpRenderThread.is()) mpRenderThread->join(); - Size aSize = mrWindow.GetSizePixel(); - mrWindow.getContext().setWinSize(aSize); + Size aSize = mpWindow->GetSizePixel(); + mpWindow->getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this)); - mrWindow.getContext().resetCurrent(); + mpWindow->getContext().resetCurrent(); mpRenderThread->launch(); } @@ -807,10 +812,10 @@ void GL3DBarChart::moveToDefault() mpRenderThread->join(); osl::MutexGuard aGuard(maMutex); - Size aSize = mrWindow.GetSizePixel(); - mrWindow.getContext().setWinSize(aSize); + Size aSize = mpWindow->GetSizePixel(); + mpWindow->getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, maDefaultCameraPosition, STEPS)); - mrWindow.getContext().resetCurrent(); + mpWindow->getContext().resetCurrent(); mpRenderThread->launch(); /* @@ -879,10 +884,10 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons) glm::vec3 aTargetPosition = rBarInfo.maPos; aTargetPosition.z += 240; aTargetPosition.y += BAR_SIZE_Y / 2.0f; - Size aSize = mrWindow.GetSizePixel(); - mrWindow.getContext().setWinSize(aSize); + Size aSize = mpWindow->GetSizePixel(); + mpWindow->getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, aTargetPosition, STEPS)); - mrWindow.getContext().resetCurrent(); + mpWindow->getContext().resetCurrent(); mpRenderThread->launch(); /* @@ -969,11 +974,11 @@ void GL3DBarChart::moveToCorner() osl::MutexGuard aGuard(maMutex); - Size aSize = mrWindow.GetSizePixel(); - mrWindow.getContext().setWinSize(aSize); + Size aSize = mpWindow->GetSizePixel(); + mpWindow->getContext().setWinSize(aSize); mpRenderThread = rtl::Reference<RenderThread>(new RenderAnimationThread(this, maCameraPosition, getCornerPosition(mnCornerId), STEPS)); - mrWindow.getContext().resetCurrent(); + mpWindow->getContext().resetCurrent(); mpRenderThread->launch(); // TODO: moggi: add to thread @@ -1305,6 +1310,13 @@ IMPL_LINK_NOARG(GL3DBarChart, updateTimer) maTimer.Start(); return 0; } + +void GL3DBarChart::setOpenGLWindow(OpenGLWindow* pWindow) +{ + if (mpWindow != pWindow) + mpWindow = pWindow; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx index d256ac401a64..007b8ad95829 100644 --- a/chart2/source/view/inc/GL3DBarChart.hxx +++ b/chart2/source/view/inc/GL3DBarChart.hxx @@ -65,7 +65,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer public: GL3DBarChart( const css::uno::Reference<css::chart2::XChartType>& xChartType, - OpenGLWindow& rContext); + OpenGLWindow* pContext); virtual ~GL3DBarChart(); @@ -81,6 +81,8 @@ public: virtual void scroll(long nDelta) SAL_OVERRIDE; virtual void contextDestroyed() SAL_OVERRIDE; + void setOpenGLWindow(OpenGLWindow* pWindow); + private: void moveToCorner(); @@ -110,7 +112,7 @@ private: boost::ptr_vector<opengl3D::Renderable3DObject> maShapes; boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer; - OpenGLWindow& mrWindow; + OpenGLWindow* mpWindow; opengl3D::Camera* mpCamera; bool mbValidContext; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 7f583f71179e..dff0e12fe294 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -3191,7 +3191,13 @@ void ChartView::createShapes3D() if (!m_pGL3DPlotter) { - m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow)); + m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, pWindow)); + } + else + { + GL3DBarChart* pChart = dynamic_cast<GL3DBarChart*>(m_pGL3DPlotter.get()); + if (pChart) + pChart->setOpenGLWindow(pWindow); } uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); |