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 "mir/graphics/display.h"
25 #include "display_helpers.h"
26 #include "platform_common.h"
27 
28 #include <vector>
29 #include <memory>
30 #include <atomic>
31 
32 namespace mir
33 {
34 namespace graphics
35 {
36 
37 class DisplayReport;
38 class GLConfig;
39 
40 namespace mesa
41 {
42 
43 class Platform;
44 class BufferObject;
45 class KMSOutput;
46 
51 {
52 public:
53  DisplayBuffer(BypassOption bypass_options,
54  std::shared_ptr<helpers::DRMHelper> const& drm,
55  std::shared_ptr<helpers::GBMHelper> const& gbm,
56  std::shared_ptr<DisplayReport> const& listener,
57  std::vector<std::shared_ptr<KMSOutput>> const& outputs,
58  GBMSurfaceUPtr surface_gbm,
59  geometry::Rectangle const& area,
60  MirOrientation rot,
61  GLConfig const& gl_config,
62  EGLContext shared_context);
64 
65  geometry::Rectangle view_area() const override;
66  void make_current() override;
67  void release_current() override;
68  void swap_buffers() override;
69  bool post_renderables_if_optimizable(RenderableList const& renderlist) override;
70  void bind() override;
71 
73  std::function<void(graphics::DisplayBuffer&)> const& f) override;
74  void post() override;
75  std::chrono::milliseconds recommended_sleep() const override;
76 
77  MirOrientation orientation() const override;
78  MirMirrorMode mirror_mode() const override;
80 
81  void set_orientation(MirOrientation const rot, geometry::Rectangle const& a);
82  void schedule_set_crtc();
83  void wait_for_page_flip();
84 
85 private:
86  BufferObject* get_front_buffer_object();
87  BufferObject* get_buffer_object(struct gbm_bo *bo);
88  bool schedule_page_flip(BufferObject* bufobj);
89  void set_crtc(BufferObject const*);
90 
91  BufferObject* visible_composite_frame;
92  BufferObject* scheduled_composite_frame;
93  std::shared_ptr<graphics::Buffer> visible_bypass_frame, scheduled_bypass_frame;
94  std::shared_ptr<Buffer> bypass_buf{nullptr};
95  BufferObject* bypass_bufobj{nullptr};
96  std::shared_ptr<DisplayReport> const listener;
97  BypassOption bypass_option;
98  /* DRM helper from mgm::Platform */
99  std::shared_ptr<helpers::DRMHelper> const drm;
100  std::shared_ptr<helpers::GBMHelper> const gbm;
101  std::vector<std::shared_ptr<KMSOutput>> outputs;
102  GBMSurfaceUPtr surface_gbm;
103  helpers::EGLHelper egl;
104  geometry::Rectangle area;
105  uint32_t fb_width, fb_height;
106  MirOrientation rotation;
107  std::atomic<bool> needs_set_crtc;
108  std::chrono::milliseconds recommend_sleep{0};
109  bool page_flips_pending;
110 };
111 
112 }
113 }
114 }
115 
116 #endif /* MIR_GRAPHICS_MESA_DISPLAY_BUFFER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Interface to an output framebuffer.
Definition: display_buffer.h:47
void bind() override
Binds any necessary resources (fbos, textures if any) in preparation for drawing. ...
geometry::Rectangle view_area() const override
The area the DisplayBuffer occupies in the virtual screen space.
void post() override
Post the content of the DisplayBuffers associated with this DisplaySyncGroup.
std::unique_ptr< gbm_surface, std::function< void(gbm_surface *)> > GBMSurfaceUPtr
Definition: display_helpers.h:45
void set_orientation(MirOrientation const rot, geometry::Rectangle const &a)
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:55
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
void make_current() override
Makes GL render target current to calling thread.
Interface for customizing aspects of the GL config used by the server.
Definition: gl_config.h:30
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.h:35
MirMirrorMode
Mirroring axis relative to the "natural" orientation of the display.
Definition: common.h:173
Definition: display_helpers.h:101
MirOrientation orientation() const override
Returns the orientation of the display buffer relative to how the user should see it (the orientation...
void swap_buffers() override
Swap buffers for OpenGL rendering.
Definition: render_target.h:29
MirMirrorMode mirror_mode() const override
Returns the mirror mode of the display buffer relative to orientation.
void for_each_display_buffer(std::function< void(graphics::DisplayBuffer &)> const &f) override
std::vector< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:79
Definition: rectangle.h:33
NativeDisplayBuffer * native_display_buffer() override
Returns a pointer to the native display buffer object backing this display buffer.
std::chrono::milliseconds recommended_sleep() const override
Returns a recommendation to the compositor as to how long it should wait before sampling the scene fo...
Definition: display_buffer.h:47
void release_current() override
Releases the current GL render target.
BypassOption
Definition: platform_common.h:29

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