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 
27 #include <vector>
28 #include <memory>
29 #include <atomic>
30 
31 namespace mir
32 {
33 namespace graphics
34 {
35 
36 class DisplayReport;
37 class GLConfig;
38 
39 namespace mesa
40 {
41 
42 class Platform;
43 class BufferObject;
44 class KMSOutput;
45 
50 {
51 public:
52  DisplayBuffer(std::shared_ptr<Platform> const& platform,
53  std::shared_ptr<DisplayReport> const& listener,
54  std::vector<std::shared_ptr<KMSOutput>> const& outputs,
55  GBMSurfaceUPtr surface_gbm,
56  geometry::Rectangle const& area,
57  MirOrientation rot,
58  GLConfig const& gl_config,
59  EGLContext shared_context);
61 
62  geometry::Rectangle view_area() const override;
63  void make_current() override;
64  void release_current() override;
65  void swap_buffers() override;
66  bool post_renderables_if_optimizable(RenderableList const& renderlist) override;
67 
69  std::function<void(graphics::DisplayBuffer&)> const& f) override;
70  void post() override;
71  std::chrono::milliseconds recommended_sleep() const override;
72 
73  MirOrientation orientation() const override;
75 
76  void set_orientation(MirOrientation const rot, geometry::Rectangle const& a);
77  void schedule_set_crtc();
78  void wait_for_page_flip();
79 
80 private:
81  BufferObject* get_front_buffer_object();
82  BufferObject* get_buffer_object(struct gbm_bo *bo);
83  bool schedule_page_flip(BufferObject* bufobj);
84  void set_crtc(BufferObject const*);
85 
86  BufferObject* visible_composite_frame;
87  BufferObject* scheduled_composite_frame;
88  std::shared_ptr<graphics::Buffer> visible_bypass_frame, scheduled_bypass_frame;
89  std::shared_ptr<Buffer> bypass_buf{nullptr};
90  BufferObject* bypass_bufobj{nullptr};
91  std::shared_ptr<Platform> const platform;
92  std::shared_ptr<DisplayReport> const listener;
93  /* DRM helper from mgm::Platform */
94  helpers::DRMHelper& drm;
95  std::vector<std::shared_ptr<KMSOutput>> outputs;
96  GBMSurfaceUPtr surface_gbm;
99  uint32_t fb_width, fb_height;
100  MirOrientation rotation;
101  std::atomic<bool> needs_set_crtc;
102  std::chrono::milliseconds recommend_sleep{0};
103  bool page_flips_pending;
104 };
105 
106 }
107 }
108 }
109 
110 #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
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:46
Definition: display_helpers.h:57
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:54
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
void make_current() override
Makes the the current GL render target.
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
Definition: display_helpers.h:102
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
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:46
void release_current() override
Releases the current GL render target.

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015