Mir
screencast_display_buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
20 #define MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_
21 
24 
25 #include MIR_SERVER_GL_H
26 #include MIR_SERVER_GLEXT_H
27 
28 namespace mir
29 {
30 namespace graphics
31 {
32 class Display;
33 class GLContext;
34 }
35 namespace renderer { namespace gl { class TextureSource; }}
36 namespace compositor
37 {
38 
39 namespace detail
40 {
41 
42 template <void (*Delete)(GLsizei,GLuint const*)>
44 {
45 public:
47  GLResource(GLuint resource) : resource{resource} {}
48  ~GLResource() { reset(); }
49 
50  operator GLuint() const { return resource; }
51 
52  void reset()
53  {
54  if (resource)
55  {
56  Delete(1, &resource);
57  resource = 0;
58  }
59  }
60 
61  GLResource(GLResource&& other) : resource {other.resource}
62  {
63  other.resource = 0;
64  }
65 
67  {
68  resource = other.resource;
69  other.resource = 0;
70  return *this;
71  }
72 
73 private:
74  GLResource(GLResource const&) = delete;
75  GLResource& operator=(GLResource const&) = delete;
76  GLuint resource{0};
77 };
78 }
79 
80 class Schedule;
84 {
85 public:
87  geometry::Rectangle const& rect,
88  geometry::Size const& size,
89  MirMirrorMode mirror_mode,
90  Schedule& free_queue,
91  Schedule& ready_queue,
92  graphics::Display& display);
94 
95  geometry::Rectangle view_area() const override;
96 
97  void make_current() override;
98 
99  void bind() override;
100 
101  void release_current() override;
102 
103  bool post_renderables_if_optimizable(graphics::RenderableList const&) override;
104 
105  void swap_buffers() override;
106 
107  MirOrientation orientation() const override;
108 
109  MirMirrorMode mirror_mode() const override;
110 
111  NativeDisplayBuffer* native_display_buffer() override;
112 
113 private:
114  std::unique_ptr<graphics::GLContext> gl_context;
115  geometry::Rectangle const rect;
116  MirMirrorMode const mirror_mode_;
117 
118  Schedule& free_queue;
119  Schedule& ready_queue;
120  std::shared_ptr<graphics::Buffer> current_buffer;
121 
122  GLint old_fbo;
123  GLint old_viewport[4];
124 
128 };
129 
130 }
131 }
132 
133 #endif /* MIR_COMPOSITOR_SCREENCAST_DISPLAY_BUFFER_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
bool make_current(mrg::RenderTarget *render_target)
Definition: server_example_adorning_compositor.cpp:39
Definition: screencast_display_buffer.h:81
Interface to an output framebuffer.
Definition: display_buffer.h:47
void reset()
Definition: screencast_display_buffer.h:52
Definition: screencast_display_buffer.h:43
GLResource & operator=(GLResource &&other)
Definition: screencast_display_buffer.h:66
GLResource()
Definition: screencast_display_buffer.h:46
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
~GLResource()
Definition: screencast_display_buffer.h:48
Definition: display_buffer.h:35
MirMirrorMode
Mirroring axis relative to the "natural" orientation of the display.
Definition: common.h:173
Definition: render_target.h:29
GLResource(GLuint resource)
Definition: screencast_display_buffer.h:47
std::vector< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:79
GLResource(GLResource &&other)
Definition: screencast_display_buffer.h:61
Definition: rectangle.h:33
Definition: schedule.h:29
int const size
Definition: make_socket_rpc_channel.cpp:51
Interface to the display subsystem.
Definition: display.h:88

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016