Mir
display_buffer.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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_MESA_DISPLAY_BUFFER_H_
20 #define MIR_GRAPHICS_MESA_DISPLAY_BUFFER_H_
21 
23 #include "display_helpers.h"
24 
25 #include <vector>
26 #include <memory>
27 #include <atomic>
28 
29 namespace mir
30 {
31 namespace graphics
32 {
33 
34 class DisplayReport;
35 class GLConfig;
36 
37 namespace mesa
38 {
39 
40 class Platform;
41 class BufferObject;
42 class KMSOutput;
43 
45 {
46 public:
47  DisplayBuffer(std::shared_ptr<Platform> const& platform,
48  std::shared_ptr<DisplayReport> const& listener,
49  std::vector<std::shared_ptr<KMSOutput>> const& outputs,
50  GBMSurfaceUPtr surface_gbm,
51  geometry::Rectangle const& area,
52  MirOrientation rot,
53  GLConfig const& gl_config,
54  EGLContext shared_context);
56 
57  geometry::Rectangle view_area() const override;
58  void make_current() override;
59  void release_current() override;
60  void gl_swap_buffers() override;
61  void flip() override;
62  bool post_renderables_if_optimizable(RenderableList const& renderlist) override;
63 
64  MirOrientation orientation() const override;
65  void set_orientation(MirOrientation const rot, geometry::Rectangle const& a);
66  bool uses_alpha() const override;
67  void schedule_set_crtc();
68  void wait_for_page_flip();
69 
70 private:
71  bool flip(std::shared_ptr<graphics::Buffer> bypass_buf);
72 
73  BufferObject* get_front_buffer_object();
74  BufferObject* get_buffer_object(struct gbm_bo *bo);
75  bool schedule_page_flip(BufferObject* bufobj);
76 
77  BufferObject* last_flipped_bufobj;
78  BufferObject* scheduled_bufobj;
79  std::shared_ptr<graphics::Buffer> last_flipped_bypass_buf;
80  std::shared_ptr<Platform> const platform;
81  std::shared_ptr<DisplayReport> const listener;
82  /* DRM helper from mgm::Platform */
83  helpers::DRMHelper& drm;
84  std::vector<std::shared_ptr<KMSOutput>> outputs;
85  GBMSurfaceUPtr surface_gbm;
88  uint32_t fb_width, fb_height;
89  MirOrientation rotation;
90  std::atomic<bool> needs_set_crtc;
91  bool page_flips_pending;
92 };
93 
94 }
95 }
96 }
97 
98 #endif /* MIR_GRAPHICS_MESA_DISPLAY_BUFFER_H_ */
All things Mir.
Definition: buffer_stream.h:37
Interface to an output framebuffer.
Definition: display_buffer.h:38
std::unique_ptr< gbm_surface, std::function< void(gbm_surface *)> > GBMSurfaceUPtr
Definition: display_helpers.h:46
void flip() override
After gl_swap_buffers, flip the new front buffer to the screen This most likely involves a wait for v...
Definition: display_buffer.cpp:219
Definition: display_helpers.h:51
void set_orientation(MirOrientation const rot, geometry::Rectangle const &a)
Definition: display_buffer.cpp:187
bool uses_alpha() const override
Returns true if the display buffer has an alpha channel and the alpha channel will be read from at so...
Definition: display_buffer.cpp:193
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:142
void make_current() override
Makes the DisplayBuffer the current GL rendering target.
Definition: display_buffer.cpp:432
Interface for customizing aspects of the GL config used by the server.
Definition: gl_config.h:30
std::list< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:80
void gl_swap_buffers() override
Swap buffers for OpenGL rendering.
Definition: display_buffer.cpp:224
bool post_renderables_if_optimizable(RenderableList const &renderlist) override
This will render renderlist to the screen and post the result to the screen if there is a hardware op...
Definition: display_buffer.cpp:198
Definition: display_helpers.h:95
MirOrientation orientation() const override
Returns the orientation of the display buffer relative to how the user should see it (the orientation...
Definition: display_buffer.cpp:181
~DisplayBuffer()
Definition: display_buffer.cpp:163
Definition: rectangle.h:33
Definition: display_buffer.h:44
geometry::Rectangle view_area() const override
The area the DisplayBuffer occupies in the virtual screen space.
Definition: display_buffer.cpp:176
void schedule_set_crtc()
Definition: display_buffer.cpp:445
void release_current() override
Releases the current GL rendering target.
Definition: display_buffer.cpp:440
void wait_for_page_flip()
Definition: display_buffer.cpp:421

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015