1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <vcl/dllapi.h>
13 #include <vcl/sysdata.hxx>
14 #include <vcl/vclptr.hxx>
15 #include <rtl/ref.hxx>
19 class SystemChildWindow
;
20 namespace vcl
{ class Window
; }
22 /// Holds the information of our new child window
23 struct VCL_DLLPUBLIC GLWindow
27 bool bMultiSampleSupported
;
32 , bMultiSampleSupported(false)
36 virtual bool Synchronize(bool bOnoff
) const;
41 class VCL_DLLPUBLIC OpenGLContext
43 friend class OpenGLTests
;
47 static rtl::Reference
<OpenGLContext
> Create();
48 virtual ~OpenGLContext();
50 // Avoid implicitly defined copy constructors/assignments for the DLLPUBLIC class (they may
51 // require forward-declared classes used internally to be defined in places using OpenGLContext)
52 OpenGLContext(const OpenGLContext
&) = delete;
53 OpenGLContext(OpenGLContext
&&) = delete;
54 OpenGLContext
& operator=(const OpenGLContext
&) = delete;
55 OpenGLContext
& operator=(OpenGLContext
&&) = delete;
57 void acquire() { mnRefCount
++; }
58 void release() { if ( --mnRefCount
== 0 ) delete this; }
61 void requestLegacyContext();
63 bool init(vcl::Window
* pParent
);
67 /// Is this GL context the current context ?
68 virtual bool isCurrent();
69 /// Is any GL context the current context ?
70 virtual bool isAnyCurrent();
71 /// release bound resources from the current context
72 static void clearCurrent();
73 /// release contexts etc. before (potentially) allowing another thread run.
74 SAL_DLLPRIVATE
static void prepareForYield();
75 /// Is there a current GL context ?
76 SAL_DLLPRIVATE
static bool hasCurrent();
78 /// make this GL context current - so it is implicit in subsequent GL calls
79 SAL_DLLPRIVATE
virtual void makeCurrent();
80 /// Put this GL context to the end of the context list.
81 void registerAsCurrent();
82 /// reset the GL context so this context is not implicit in subsequent GL calls.
83 SAL_DLLPRIVATE
virtual void resetCurrent();
84 /// unbind the GL_FRAMEBUFFER to its default state, needed for gtk3
85 virtual void restoreDefaultFramebuffer();
86 SAL_DLLPRIVATE
virtual void swapBuffers();
90 void setWinPosAndSize(const Point
&rPos
, const Size
& rSize
);
91 virtual const GLWindow
& getOpenGLWindow() const = 0;
93 SystemChildWindow
* getChildWindow();
94 SAL_DLLPRIVATE
const SystemChildWindow
* getChildWindow() const;
96 bool isInitialized() const
101 virtual SystemWindowData
generateWinData(vcl::Window
* pParent
, bool bRequestLegacyContext
);
104 SAL_DLLPRIVATE
virtual void initWindow();
105 SAL_DLLPRIVATE
virtual void destroyCurrentContext();
106 virtual void adjustToNewSize();
110 static void InitGLDebugging();
111 static void InitChildWindow(SystemChildWindow
*pChildWindow
);
112 static void BuffersSwapped();
113 virtual GLWindow
& getModifiableOpenGLWindow() = 0;
114 SAL_DLLPRIVATE
virtual bool ImplInit();
116 VclPtr
<vcl::Window
> m_xWindow
;
117 VclPtr
<vcl::Window
> mpWindow
; //points to m_pWindow or the parent window, don't delete it
118 VclPtr
<SystemChildWindow
> m_pChildWindow
;
121 bool mbRequestLegacyContext
;
125 // Don't hold references to ourselves:
126 OpenGLContext
*mpPrevContext
;
127 OpenGLContext
*mpNextContext
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */