Mir
real_hwc_wrapper.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_REAL_HWC_WRAPPER_H_
20 #define MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_
21 
22 #include "hwc_wrapper.h"
23 #include <memory>
24 #include <hardware/hwcomposer.h>
25 
26 #include <mutex>
27 #include <unordered_map>
28 
29 namespace mir
30 {
31 namespace graphics
32 {
33 namespace android
34 {
35 class HwcReport;
36 class RealHwcWrapper;
38 {
39  hwc_procs_t hooks;
41 };
42 
43 class RealHwcWrapper : public HwcWrapper
44 {
45 public:
47  //should probably be unique_ptr
48  std::shared_ptr<hwc_composer_device_1> const& hwc_device,
49  std::shared_ptr<HwcReport> const& report);
51 
53  void const* subscriber,
54  std::function<void(DisplayName, std::chrono::nanoseconds)> const& vsync_callback,
55  std::function<void(DisplayName, bool)> const& hotplug_callback,
56  std::function<void()> const& invalidate_callback) override;
57  void unsubscribe_from_events(void const* subscriber) noexcept override;
58 
59  void prepare(std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> const&) const override;
60  void set(std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> const&) const override;
61  void vsync_signal_on(DisplayName) const override;
62  void vsync_signal_off(DisplayName) const override;
63  void display_on(DisplayName) const override;
64  void display_off(DisplayName) const override;
65  std::vector<ConfigId> display_configs(DisplayName) const override;
67  DisplayName, ConfigId, uint32_t const* attributes, int32_t* values) const override;
68  void power_mode(DisplayName , PowerMode mode) const override;
69  bool has_active_config(DisplayName name) const override;
70  ConfigId active_config_for(DisplayName name) const override;
71  void set_active_config(DisplayName name, ConfigId id) const override;
72 
73  void vsync(DisplayName, std::chrono::nanoseconds) noexcept;
74  void hotplug(DisplayName, bool) noexcept;
75  void invalidate() noexcept;
76 
77  bool display_connected(DisplayName) const;
78 private:
79  std::shared_ptr<hwc_composer_device_1> const hwc_device;
80  std::shared_ptr<HwcReport> const report;
81  std::mutex callback_map_lock;
82  struct Callbacks
83  {
84  std::function<void(DisplayName, std::chrono::nanoseconds)> vsync;
85  std::function<void(DisplayName, bool)> hotplug;
86  std::function<void()> invalidate;
87  };
88  std::unordered_map<void const*, Callbacks> callback_map;
89 };
90 
91 }
92 }
93 }
94 #endif /* MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_ */
All things Mir.
Definition: atomic_callback.h:25
void display_off(DisplayName) const override
Definition: real_hwc_wrapper.cpp:172
void display_on(DisplayName) const override
Definition: real_hwc_wrapper.cpp:161
Definition: real_hwc_wrapper.h:37
~RealHwcWrapper()
Definition: real_hwc_wrapper.cpp:94
void subscribe_to_events(void const *subscriber, std::function< void(DisplayName, std::chrono::nanoseconds)> const &vsync_callback, std::function< void(DisplayName, bool)> const &hotplug_callback, std::function< void()> const &invalidate_callback) override
Definition: real_hwc_wrapper.cpp:183
void set_active_config(DisplayName name, ConfigId id) const override
Definition: real_hwc_wrapper.cpp:298
std::vector< ConfigId > display_configs(DisplayName) const override
Definition: real_hwc_wrapper.cpp:246
Definition: hwc_wrapper.h:43
PowerMode
Definition: power_mode.h:31
DisplayName
Definition: display_name.h:31
ConfigId active_config_for(DisplayName name) const override
Definition: real_hwc_wrapper.cpp:286
hwc_procs_t hooks
Definition: real_hwc_wrapper.h:39
int display_attributes(DisplayName, ConfigId, uint32_t const *attributes, int32_t *values) const override
Definition: real_hwc_wrapper.cpp:262
void invalidate() noexcept
Definition: real_hwc_wrapper.cpp:231
void unsubscribe_from_events(void const *subscriber) noexceptoverride
Definition: real_hwc_wrapper.cpp:193
void set(std::array< hwc_display_contents_1_t *, HWC_NUM_DISPLAY_TYPES > const &) const override
Definition: real_hwc_wrapper.cpp:115
void power_mode(DisplayName, PowerMode mode) const override
Definition: real_hwc_wrapper.cpp:269
void vsync_signal_on(DisplayName) const override
Definition: real_hwc_wrapper.cpp:139
Definition: int_wrapper.h:27
void hotplug(DisplayName, bool) noexcept
Definition: real_hwc_wrapper.cpp:216
bool has_active_config(DisplayName name) const override
Definition: real_hwc_wrapper.cpp:280
RealHwcWrapper(std::shared_ptr< hwc_composer_device_1 > const &hwc_device, std::shared_ptr< HwcReport > const &report)
Definition: real_hwc_wrapper.cpp:83
void vsync_signal_off(DisplayName) const override
Definition: real_hwc_wrapper.cpp:150
void vsync(DisplayName, std::chrono::nanoseconds) noexcept
Definition: real_hwc_wrapper.cpp:201
Definition: real_hwc_wrapper.h:43
Definition: android_input_receiver.h:36
void prepare(std::array< hwc_display_contents_1_t *, HWC_NUM_DISPLAY_TYPES > const &) const override
Definition: real_hwc_wrapper.cpp:100
bool display_connected(DisplayName) const
Definition: real_hwc_wrapper.cpp:305

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