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 #include <atomic>
29 
30 namespace mir
31 {
32 namespace graphics
33 {
34 namespace android
35 {
36 class HwcReport;
37 class RealHwcWrapper;
39 {
40  hwc_procs_t hooks;
42 };
43 
44 class RealHwcWrapper : public HwcWrapper
45 {
46 public:
48  //should probably be unique_ptr
49  std::shared_ptr<hwc_composer_device_1> const& hwc_device,
50  std::shared_ptr<HwcReport> const& report);
51  ~RealHwcWrapper();
52 
53  void subscribe_to_events(
54  void const* subscriber,
55  std::function<void(DisplayName, std::chrono::nanoseconds)> const& vsync_callback,
56  std::function<void(DisplayName, bool)> const& hotplug_callback,
57  std::function<void()> const& invalidate_callback) override;
58  void unsubscribe_from_events(void const* subscriber) noexcept override;
59 
60  void prepare(std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> const&) const override;
61  void set(std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> const&) const override;
62  void vsync_signal_on(DisplayName) const override;
63  void vsync_signal_off(DisplayName) const override;
64  void display_on(DisplayName) const override;
65  void display_off(DisplayName) const override;
66  std::vector<ConfigId> display_configs(DisplayName) const override;
67  int display_attributes(
68  DisplayName, ConfigId, uint32_t const* attributes, int32_t* values) const override;
69  void power_mode(DisplayName , PowerMode mode) const override;
70  bool has_active_config(DisplayName name) const override;
71  ConfigId active_config_for(DisplayName name) const override;
72  void set_active_config(DisplayName name, ConfigId id) const override;
73 
74  void vsync(DisplayName, std::chrono::nanoseconds) noexcept;
75  void hotplug(DisplayName, bool) noexcept;
76  void invalidate() noexcept;
77 
78  bool display_connected(DisplayName) const;
79 private:
80  std::shared_ptr<hwc_composer_device_1> const hwc_device;
81  std::shared_ptr<HwcReport> const report;
82  std::mutex callback_map_lock;
83  struct Callbacks
84  {
85  std::function<void(DisplayName, std::chrono::nanoseconds)> vsync;
86  std::function<void(DisplayName, bool)> hotplug;
87  std::function<void()> invalidate;
88  };
89  std::unordered_map<void const*, Callbacks> callback_map;
90  std::atomic<bool> is_plugged[HWC_NUM_DISPLAY_TYPES];
91 };
92 
93 }
94 }
95 }
96 #endif /* MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: real_hwc_wrapper.h:38
Definition: hwc_wrapper.h:43
PowerMode
Definition: power_mode.h:31
DisplayName
Definition: display_name.h:32
hwc_procs_t hooks
Definition: real_hwc_wrapper.h:40
Definition: int_wrapper.h:27
Definition: real_hwc_wrapper.h:44
Definition: android_input_receiver.h:36

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016