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;
66  void display_attributes(
67  DisplayName, ConfigId, uint32_t const* attributes, int32_t* values) const override;
68 
69  void vsync(DisplayName, std::chrono::nanoseconds) noexcept;
70  void hotplug(DisplayName, bool) noexcept;
71  void invalidate() noexcept;
72 private:
73  std::shared_ptr<hwc_composer_device_1> const hwc_device;
74  std::shared_ptr<HwcReport> const report;
75  std::mutex callback_map_lock;
76  struct Callbacks
77  {
78  std::function<void(DisplayName, std::chrono::nanoseconds)> vsync;
79  std::function<void(DisplayName, bool)> hotplug;
80  std::function<void()> invalidate;
81  };
82  std::unordered_map<void const*, Callbacks> callback_map;
83 };
84 
85 }
86 }
87 }
88 #endif /* MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_ */
All things Mir.
Definition: buffer_stream.h:37
void display_off(DisplayName) const override
Definition: real_hwc_wrapper.cpp:161
void display_on(DisplayName) const override
Definition: real_hwc_wrapper.cpp:150
Definition: real_hwc_wrapper.h:37
~RealHwcWrapper()
Definition: real_hwc_wrapper.cpp:93
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:172
void display_attributes(DisplayName, ConfigId, uint32_t const *attributes, int32_t *values) const override
Definition: real_hwc_wrapper.cpp:251
std::vector< ConfigId > display_configs(DisplayName) const override
Definition: real_hwc_wrapper.cpp:235
Definition: hwc_wrapper.h:42
DisplayName
Definition: display_name.h:31
hwc_procs_t hooks
Definition: real_hwc_wrapper.h:39
void invalidate() noexcept
Definition: real_hwc_wrapper.cpp:220
void unsubscribe_from_events(void const *subscriber) noexceptoverride
Definition: real_hwc_wrapper.cpp:182
void set(std::array< hwc_display_contents_1_t *, HWC_NUM_DISPLAY_TYPES > const &) const override
Definition: real_hwc_wrapper.cpp:115
void vsync_signal_on(DisplayName) const override
Definition: real_hwc_wrapper.cpp:128
Definition: int_wrapper.h:27
void hotplug(DisplayName, bool) noexcept
Definition: real_hwc_wrapper.cpp:205
RealHwcWrapper(std::shared_ptr< hwc_composer_device_1 > const &hwc_device, std::shared_ptr< HwcReport > const &report)
Definition: real_hwc_wrapper.cpp:82
void vsync_signal_off(DisplayName) const override
Definition: real_hwc_wrapper.cpp:139
void vsync(DisplayName, std::chrono::nanoseconds) noexcept
Definition: real_hwc_wrapper.cpp:190
Definition: real_hwc_wrapper.h:43
Definition: android_input_receiver.h:32
void prepare(std::array< hwc_display_contents_1_t *, HWC_NUM_DISPLAY_TYPES > const &) const override
Definition: real_hwc_wrapper.cpp:99

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015