Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gl_renderer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 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_GL_RENDERER_H_
20 #define MIR_COMPOSITOR_GL_RENDERER_H_
21 
24 #include <mir/geometry/rectangle.h>
25 #include <mir/graphics/buffer_id.h>
30 #include <GLES2/gl2.h>
31 #include <unordered_map>
32 #include <unordered_set>
33 #include <vector>
34 
35 namespace mir
36 {
37 namespace compositor
38 {
39 
40 enum class DestinationAlpha;
41 
42 class GLRenderer : public Renderer
43 {
44 public:
45  GLRenderer(
46  graphics::GLProgramFactory const& program_factory,
47  std::unique_ptr<graphics::GLTextureCache> && texture_cache,
48  geometry::Rectangle const& display_area,
49  DestinationAlpha dest_alpha);
50 
51  // These are called with a valid GL context:
52  void set_viewport(geometry::Rectangle const& rect) override;
53  void set_rotation(float degrees) override;
54  void begin() const override;
55  void render(graphics::RenderableList const&) const override;
56  void end() const override;
57 
58  // This is called _without_ a GL context:
59  void suspend() override;
60 
77  virtual void tessellate(std::vector<graphics::GLPrimitive>& primitives,
78  graphics::Renderable const& renderable) const;
79 
80  virtual void render(graphics::Renderable const& renderable) const;
81 
83 
84 private:
85  std::unique_ptr<graphics::GLProgram> program;
86  std::unique_ptr<graphics::GLTextureCache> mutable texture_cache;
87  GLuint position_attr_loc;
88  GLuint texcoord_attr_loc;
89  GLuint centre_uniform_loc;
90  GLuint display_transform_uniform_loc;
91  GLuint transform_uniform_loc;
92  GLuint alpha_uniform_loc;
93  float rotation;
94  DestinationAlpha const dest_alpha;
95  geometry::Rectangle viewport;
96 
97  std::vector<graphics::GLPrimitive> mutable primitives;
98 };
99 
100 }
101 }
102 
103 #endif // MIR_COMPOSITOR_GL_RENDERER_H_
DestinationAlpha
Definition: destination_alpha.h:27
All things Mir.
Definition: aging_buffer.h:24
void render(graphics::RenderableList const &) const override
Definition: gl_renderer.cpp:114
virtual void tessellate(std::vector< graphics::GLPrimitive > &primitives, graphics::Renderable const &renderable) const
tessellate defines the list of triangles that will be used to render the surface. ...
Definition: gl_renderer.cpp:107
Definition: renderer.h:32
GLRenderer(graphics::GLProgramFactory const &program_factory, std::unique_ptr< graphics::GLTextureCache > &&texture_cache, geometry::Rectangle const &display_area, DestinationAlpha dest_alpha)
Definition: gl_renderer.cpp:72
Definition: gl_program_factory.h:31
std::list< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:88
Definition: gl_renderer.h:42
Definition: renderable.h:33
void set_rotation(float degrees) override
Definition: gl_renderer.cpp:224
void set_viewport(geometry::Rectangle const &rect) override
Definition: gl_renderer.cpp:180
void suspend() override
Definition: gl_renderer.cpp:262
DestinationAlpha destination_alpha() const
Definition: gl_renderer.cpp:267
Definition: rectangle.h:33
void end() const override
Definition: gl_renderer.cpp:257
void begin() const override
Definition: gl_renderer.cpp:243

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014