summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-06-07 16:11:02 +0200
committerAndras Timar <andras.timar@collabora.com>2016-06-11 10:04:33 +0200
commit87f11e19d84f01fd143dd1096d156589f330137f (patch)
tree49d17908398b95441633c19450d80dd764e1680a
parent9d3454cdf77b29e7233e2dc26429daf3a170fc65 (diff)
only init the OpenGL context if we need it
Change-Id: I8634589bc0c8ef317089eb08c07974ed81d98982 Reviewed-on: https://gerrit.libreoffice.org/26050 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 8a94e538c3306b2af1a76c724e4dcae0e3968164)
-rw-r--r--chart2/source/controller/main/ChartWindow.cxx2
-rw-r--r--chart2/source/view/main/ChartView.cxx4
-rw-r--r--include/vcl/openglwin.hxx6
-rw-r--r--vcl/source/window/openglwin.cxx46
4 files changed, 50 insertions, 8 deletions
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 80b076930623..de815c16c118 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -49,7 +49,7 @@ ChartWindow::ChartWindow( ChartController* pController, vcl::Window* pParent, Wi
: Window(pParent, nStyle)
, m_pWindowController( pController )
, m_bInPaint(false)
- , m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this))
+ , m_pOpenGLWindow(VclPtr<OpenGLWindow>::Create(this, false))
{
this->SetHelpId( HID_SCH_WIN_DOCUMENT );
this->SetMapMode( MapMode(MAP_100TH_MM) );
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 9814f3cbc71d..0c9a9450215b 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2725,6 +2725,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 3f95894181d1..c4a41e9b5e91 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 = OpenGLContext::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,20 @@ OpenGLWindowImpl::~OpenGLWindowImpl()
mxChildWindow.disposeAndClear();
}
-OpenGLWindow::OpenGLWindow(vcl::Window* pParent):
+bool OpenGLWindowImpl::IsInitialized() const
+{
+ return mbInitialized;
+}
+
+void OpenGLWindowImpl::Initialize()
+{
+ mxContext->init(mxChildWindow.get());
+ mbInitialized = true;
+}
+
+OpenGLWindow::OpenGLWindow(vcl::Window* pParent, bool bInit):
Window(pParent, 0),
- mxImpl(new OpenGLWindowImpl(this)),
+ mxImpl(new OpenGLWindowImpl(this, bInit)),
mpRenderer(nullptr)
{
}
@@ -118,4 +141,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: */