Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hwc_layerlist.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 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_ANDROID_HWC_LAYERLIST_H_
20 #define MIR_GRAPHICS_ANDROID_HWC_LAYERLIST_H_
21 
22 #include "mir/geometry/rectangle.h"
23 #include <hardware/hwcomposer.h>
24 #include <memory>
25 #include <vector>
26 #include <initializer_list>
27 namespace mir
28 {
29 namespace graphics
30 {
31 class Buffer;
32 
33 namespace android
34 {
35 
36 struct HWCRect
37 {
38  HWCRect();
39  HWCRect(geometry::Rectangle& rect);
40 
41  operator hwc_rect_t const& () const { return self; }
42  operator hwc_rect_t& () { return self; }
43 private:
44  hwc_rect_t self;
45 };
46 
47 struct HWCDefaultLayer
48 {
49  HWCDefaultLayer(std::initializer_list<HWCRect> list);
50  ~HWCDefaultLayer();
51 
52  operator hwc_layer_1 const& () const { return self; }
53  operator hwc_layer_1& () { return self; }
54 
55 protected:
56  HWCDefaultLayer& operator=(HWCDefaultLayer const&) = delete;
57  HWCDefaultLayer(HWCDefaultLayer const&) = delete;
58 
59  hwc_layer_1 self;
60 };
61 
62 struct HWCFBLayer : public HWCDefaultLayer
63 {
64  HWCFBLayer();
65  HWCFBLayer(buffer_handle_t native_buf,
66  HWCRect display_frame_rect);
67 };
68 
69 class HWCLayerList
70 {
71 public:
72  virtual ~HWCLayerList() = default;
73 
74  virtual hwc_display_contents_1_t* native_list() const = 0;
75  virtual void set_fb_target(std::shared_ptr<Buffer> const&) = 0;
76 
77 protected:
78  HWCLayerList() = default;
79  HWCLayerList& operator=(HWCLayerList const&) = delete;
80  HWCLayerList(HWCLayerList const&) = delete;
81 
82 };
83 
84 class LayerList : public HWCLayerList
85 {
86 public:
87  LayerList();
88 
89  void set_fb_target(std::shared_ptr<Buffer> const&);
90  hwc_display_contents_1_t* native_list() const;
91 
92 private:
93  std::vector<std::shared_ptr<HWCDefaultLayer>> layer_list;
94  void update_list();
95 
96  static size_t const fb_position = 0u;
97  std::shared_ptr<hwc_display_contents_1_t> hwc_representation;
98 };
99 
100 }
101 }
102 }
103 
104 #endif /* MIR_GRAPHICS_ANDROID_HWC_LAYERLIST_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013