only init the OpenGL context if we need it
Change-Id: Ia88a1720d204b9933f1476bd703b99180e45abde Reviewed-on: https://gerrit.libreoffice.org/26023 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
parent
665844d8dd
commit
78b100ec9c
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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: */
|
||||
|
Loading…
x
Reference in New Issue
Block a user