Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gl_context.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_ANDROID_GL_CONTEXT_H_
20 #define MIR_GRAPHICS_ANDROID_GL_CONTEXT_H_
21 
24 #include "mir_toolkit/common.h"
25 #include <functional>
26 
27 namespace mir
28 {
29 namespace graphics
30 {
31 class DisplayReport;
32 class GLConfig;
33 namespace android
34 {
35 
36 //handy functions
37 EGLSurface create_dummy_pbuffer_surface(EGLDisplay, EGLConfig);
38 EGLSurface create_window_surface(EGLDisplay, EGLConfig, EGLNativeWindowType);
39 
40 class SwappingGLContext
41 {
42 public:
43  virtual ~SwappingGLContext() = default;
44  virtual void swap_buffers() const = 0;
45 
46 protected:
47  SwappingGLContext() = default;
48  SwappingGLContext(SwappingGLContext const&) = delete;
49  SwappingGLContext& operator=(SwappingGLContext const&) = delete;
50 };
51 
52 class GLContext : public SwappingGLContext,
53  public graphics::GLContext
54 {
55 public:
56  //For creating a gl context
57  GLContext(MirPixelFormat display_format,
58  GLConfig const& gl_config,
59  DisplayReport& report);
60 
61  //For creating a gl context shared with another GLContext
62  GLContext(GLContext const& shared_gl_context,
63  std::function<EGLSurface(EGLDisplay, EGLConfig)> const& create_egl_surface);
64 
65  ~GLContext();
66 
67  void make_current() const override;
68  void swap_buffers() const override;
69  void release_current() const override;
70 
71 private:
72  EGLDisplay const egl_display;
73  bool const own_display;
74  EGLConfig const egl_config;
75 
76  EGLContextStore const egl_context;
77  EGLSurfaceStore const egl_surface;
78 };
79 
80 }
81 }
82 }
83 
84 #endif /* MIR_GRAPHICS_ANDROID_GL_CONTEXT_H_ */
virtual void release_current() const =0
virtual void make_current() const =0
input_rectangles report(report)
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:99

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014