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 #pragma once
11 
12 #include <vcl/dllapi.h>
13 #include <vcl/sysdata.hxx>
14 #include <vcl/vclptr.hxx>
15 #include <rtl/ref.hxx>
16 
17 class Point;
18 class Size;
19 class SystemChildWindow;
20 namespace vcl { class Window; }
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 
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;
56 
57  void acquire() { mnRefCount++; }
58  void release() { if ( --mnRefCount == 0 ) delete this; }
59  void dispose();
60 
61  void requestLegacyContext();
62 
63  bool init(vcl::Window* pParent);
64 
65  void reset();
66 
68  virtual bool isCurrent();
70  virtual bool isAnyCurrent();
72  static void clearCurrent();
74  static void prepareForYield();
76  static bool hasCurrent();
77 
79  virtual void makeCurrent();
81  void registerAsCurrent();
83  virtual void resetCurrent();
85  virtual void restoreDefaultFramebuffer();
86  virtual void swapBuffers();
87  virtual void sync();
88  void show();
89 
90  void setWinPosAndSize(const Point &rPos, const Size& rSize);
91  virtual const GLWindow& getOpenGLWindow() const = 0;
92 
93  SystemChildWindow* getChildWindow();
94  const SystemChildWindow* getChildWindow() const;
95 
96  bool isInitialized() const
97  {
98  return mbInitialized;
99  }
100 
101  virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
102 
103 private:
104  virtual void initWindow();
105  virtual void destroyCurrentContext();
106  virtual void adjustToNewSize();
107 
108 protected:
109  bool InitGL();
110  static void InitGLDebugging();
111  static void InitChildWindow(SystemChildWindow *pChildWindow);
112  static void BuffersSwapped();
113  virtual GLWindow& getModifiableOpenGLWindow() = 0;
114  virtual bool ImplInit();
115 
117  VclPtr<vcl::Window> mpWindow; //points to m_pWindow or the parent window, don't delete it
122 
123 public:
124 
125  // Don't hold references to ourselves:
128 };
129 
130 /* 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