Mir
hwc_layers.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_ANDROID_HWC_LAYERS_H_
20 #define MIR_GRAPHICS_ANDROID_HWC_LAYERS_H_
21 
23 #include "fence.h"
24 #include "mir/geometry/rectangle.h"
25 #include <hardware/hwcomposer.h>
26 #include <memory>
27 #include <vector>
28 #include <initializer_list>
29 #include <list>
30 
31 namespace mir
32 {
33 namespace graphics
34 {
35 
36 class Renderable;
37 class Buffer;
38 class NativeBuffer;
39 
40 namespace android
41 {
43 {
48 };
49 
51 {
52 public:
53  virtual void fill_source_crop(hwc_layer_1_t&, geometry::Rectangle const& crop_size) const = 0;
54  virtual bool needs_fb_target() const = 0;
55  virtual ~LayerAdapter() = default;
56  LayerAdapter() = default;
57  LayerAdapter(LayerAdapter const&) = delete;
58  LayerAdapter& operator=(LayerAdapter const&) = delete;
59 };
60 
61 //HWC 1.0 has int sourceCrop and no fbtarget
62 class Hwc10Adapter : public LayerAdapter
63 {
64  void fill_source_crop(hwc_layer_1_t&, geometry::Rectangle const& crop_size) const override;
65  bool needs_fb_target() const override;
66 };
67 
68 //HWC 1.1 to 1.2 have int sourceCrop and fbtarget
70 {
71  void fill_source_crop(hwc_layer_1_t&, geometry::Rectangle const& crop_size) const override;
72  bool needs_fb_target() const override;
73 };
74 
75 //HWC 1.3 and later have float sourceCrop and fbtarget
77 {
78  void fill_source_crop(hwc_layer_1_t&, geometry::Rectangle const& crop_size) const override;
79  bool needs_fb_target() const override;
80 };
81 
82 class HWCLayer
83 {
84 public:
85  HWCLayer(
86  std::shared_ptr<LayerAdapter> const&,
87  std::shared_ptr<hwc_display_contents_1_t> const& list,
88  size_t layer_index);
89 
90  HWCLayer(
91  std::shared_ptr<LayerAdapter> const&,
92  std::shared_ptr<hwc_display_contents_1_t> const& list,
93  size_t layer_index,
94  LayerType,
95  geometry::Rectangle const& screen_position,
96  bool alpha_enabled,
97  std::shared_ptr<Buffer> const& buffer);
98 
99  HWCLayer& operator=(HWCLayer && layer);
100  HWCLayer(HWCLayer && layer);
101 
102  HWCLayer& operator=(HWCLayer const& layer) = delete;
103  HWCLayer(HWCLayer const& layer) = delete;
104 
105  bool setup_layer(
106  LayerType type,
107  geometry::Rectangle const& position,
108  bool alpha_enabled,
109  std::shared_ptr<Buffer> const& buffer);
110 
111  bool is_overlay() const;
112  bool needs_gl_render() const;
113  void set_acquirefence();
114  void release_buffer();
115  std::shared_ptr<Buffer> buffer();
116 
117 private:
118  std::shared_ptr<LayerAdapter> layer_adapter;
119  hwc_layer_1_t* hwc_layer;
120  std::shared_ptr<hwc_display_contents_1_t> hwc_list;
121  hwc_rect_t visible_rect;
122  std::shared_ptr<Buffer> associated_buffer;
123 };
124 }
125 }
126 }
127 
128 #endif /* MIR_GRAPHICS_ANDROID_HWC_LAYERS_H_ */
Definition: hwc_layers.h:62
All things Mir.
Definition: atomic_callback.h:25
struct MirBufferPackage NativeBuffer
Definition: native_buffer.h:35
Definition: hwc_layers.h:45
LayerType
Definition: hwc_layers.h:42
Definition: hwc_layers.h:82
LayerAdapter & operator=(LayerAdapter const &)=delete
Definition: hwc_layers.h:47
Definition: hwc_layers.h:44
Definition: hwc_layers.h:50
virtual bool needs_fb_target() const =0
Definition: rectangle.h:33
Definition: android_input_receiver.h:36
Definition: hwc_layers.h:76
virtual void fill_source_crop(hwc_layer_1_t &, geometry::Rectangle const &crop_size) const =0

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016