diff options
-rw-r--r-- | chart2/source/controller/main/ChartWindow.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 4 | ||||
-rw-r--r-- | include/vcl/openglwin.hxx | 6 | ||||
-rw-r--r-- | vcl/source/window/openglwin.cxx | 45 |
4 files changed, 49 insertions, 8 deletions
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 25bdc33c7a13..3d3b8492b4e9 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -50,7 +50,7 @@ ChartWindow::ChartWindow( ChartController* pController, vcl::Window* pParent, Wi , m_pWindowController( pController ) , m_bInPaint(false) #if HAVE_FEATURE_OPENGL - , m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this)) + , m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this, false)) #else , m_pOpenGLWindow(nullptr) #endif diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 569eeaee3f47..56c7a59e795b 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2731,6 +2731,10 @@ void ChartView::impl_updateView( bool bCheckLockedCtrler ) //create chart view { + OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); + if (pWindow && ChartHelper::isGL3DDiagram(mrChartModel.getFirstDiagram())) + pWindow->Initialize(); + m_bViewDirty = false; m_bViewUpdatePending = false; createShapes(); diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx index 6b2e58dd5c40..cac81a6968ea 100644 --- a/include/vcl/openglwin.hxx +++ b/include/vcl/openglwin.hxx @@ -33,7 +33,7 @@ public: class VCL_DLLPUBLIC OpenGLWindow : public vcl::Window { public: - OpenGLWindow(vcl::Window* pParent); + OpenGLWindow(vcl::Window* pParent, bool bInit = true); virtual ~OpenGLWindow(); virtual void dispose() override; @@ -48,6 +48,10 @@ public: virtual void MouseMove( const MouseEvent& rMEvt ) override; virtual void Command( const CommandEvent& rCEvt ) override; + bool IsInitialized() const; + + void Initialize(); + private: std::unique_ptr<OpenGLWindowImpl> mxImpl; IRenderer* mpRenderer; diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx index 442d1daa6483..bef5a8035a60 100644 --- a/vcl/source/window/openglwin.cxx +++ b/vcl/source/window/openglwin.cxx @@ -15,21 +15,33 @@ class OpenGLWindowImpl { public: - explicit OpenGLWindowImpl(vcl::Window* pWindow); + explicit OpenGLWindowImpl(vcl::Window* pWindow, bool bInit); ~OpenGLWindowImpl(); OpenGLContext& getContext() { return *mxContext.get(); } + + bool IsInitialized() const; + + void Initialize(); + private: + rtl::Reference<OpenGLContext> mxContext; VclPtr<SystemChildWindow> mxChildWindow; + + bool mbInitialized; }; -OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow) - : mxContext(OpenGLContext::Create()) +OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow, bool bInit) + : mxContext(OpenGLContext::Create()), + mbInitialized(bInit) { SystemWindowData aData = mxContext->generateWinData(pWindow, false); mxChildWindow.reset(VclPtr<SystemChildWindow>::Create(pWindow, 0, &aData)); mxChildWindow->Show(); - mxContext->init(mxChildWindow.get()); + + if (bInit) + mxContext->init(mxChildWindow.get()); + pWindow->SetMouseTransparent(false); } @@ -39,9 +51,19 @@ OpenGLWindowImpl::~OpenGLWindowImpl() mxChildWindow.disposeAndClear(); } -OpenGLWindow::OpenGLWindow(vcl::Window* pParent): +bool OpenGLWindowImpl::IsInitialized() const +{ + return mbInitialized; +} + +void OpenGLWindowImpl::Initialize() +{ + mxContext->init(mxChildWindow.get()); +} + +OpenGLWindow::OpenGLWindow(vcl::Window* pParent, bool bInit): Window(pParent, 0), - mxImpl(new OpenGLWindowImpl(this)), + mxImpl(new OpenGLWindowImpl(this, bInit)), mpRenderer(nullptr) { } @@ -118,4 +140,15 @@ void OpenGLWindow::setRenderer(IRenderer* pRenderer) mpRenderer = pRenderer; } +bool OpenGLWindow::IsInitialized() const +{ + return mxImpl->IsInitialized(); +} + +void OpenGLWindow::Initialize() +{ + if (!IsInitialized()) + mxImpl->Initialize(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |