LibreOffice Module vcl (master)  1
OpenGLContext.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  */
9 
10 #ifndef INCLUDED_VCL_OPENGL_OPENGLCONTEXT_HXX
11 #define INCLUDED_VCL_OPENGL_OPENGLCONTEXT_HXX
12 
13 #include <epoxy/gl.h>
14 
15 #include <vcl/dllapi.h>
16 #include <vcl/syschild.hxx>
17 #include <rtl/ref.hxx>
18 
19 #include <memory>
20 #include <unordered_map>
21 
24 {
25  unsigned int Width;
26  unsigned int Height;
28 
30  : Width(0)
31  , Height(0)
32  , bMultiSampleSupported(false)
33  {
34  }
35 
36  virtual bool Synchronize(bool bOnoff) const;
37 
38  virtual ~GLWindow();
39 };
40 
42 {
43  friend class OpenGLTests;
44 protected:
45  OpenGLContext();
46 public:
48  virtual ~OpenGLContext();
49  void acquire() { mnRefCount++; }
50  void release() { if ( --mnRefCount == 0 ) delete this; }
51  void dispose();
52 
53  void requestLegacyContext();
54 
55  bool init(vcl::Window* pParent);
56 
57  void reset();
58 
60  virtual bool isCurrent();
62  virtual bool isAnyCurrent();
64  static void clearCurrent();
66  static void prepareForYield();
68  static bool hasCurrent();
69 
71  virtual void makeCurrent();
73  void registerAsCurrent();
75  virtual void resetCurrent();
77  virtual void restoreDefaultFramebuffer();
78  virtual void swapBuffers();
79  virtual void sync();
80  void show();
81 
82  void setWinPosAndSize(const Point &rPos, const Size& rSize);
83  virtual const GLWindow& getOpenGLWindow() const = 0;
84 
85  SystemChildWindow* getChildWindow();
86  const SystemChildWindow* getChildWindow() const;
87 
88  bool isInitialized() const
89  {
90  return mbInitialized;
91  }
92 
93  virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
94 
95 private:
96  virtual void initWindow();
97  virtual void destroyCurrentContext();
98  virtual void adjustToNewSize();
99 
100 protected:
101  bool InitGL();
102  static void InitGLDebugging();
103  static void InitChildWindow(SystemChildWindow *pChildWindow);
104  static void BuffersSwapped();
105  virtual GLWindow& getModifiableOpenGLWindow() = 0;
106  virtual bool ImplInit();
107 
109  VclPtr<vcl::Window> mpWindow; //points to m_pWindow or the parent window, don't delete it
114 
115 public:
116 
117  // Don't hold references to ourselves:
120 };
121 
122 #endif
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool bMultiSampleSupported
OpenGLContext * mpNextContext
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
unsigned int Height
bool mbInitialized
bool mbRequestLegacyContext
bool isInitialized() const
Holds the information of our new child window.
OpenGLContext * mpPrevContext
unsigned int Width
VclPtr< vcl::Window > m_xWindow
FILE * init(int, char **)
VclPtr< SystemChildWindow > m_pChildWindow
void dispose()
VclPtr< vcl::Window > mpWindow