Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hwc_common_device.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 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_COMMON_DEVICE_H_
20 #define MIR_GRAPHICS_ANDROID_HWC_COMMON_DEVICE_H_
21 
22 #include "display_device.h"
23 #include <hardware/hwcomposer.h>
24 
25 #include <memory>
26 #include <mutex>
27 #include <condition_variable>
28 #include <atomic>
29 
30 namespace mir
31 {
32 namespace graphics
33 {
34 namespace android
35 {
36 
37 class HwcWrapper;
38 class HWCVsyncCoordinator;
39 class HWCCommonDevice;
41 {
42  hwc_procs_t hooks;
43  std::atomic<HWCCommonDevice*> self;
44 };
45 
47 {
48 public:
49  virtual ~HWCCommonDevice() noexcept;
50 
51  void notify_vsync();
52  void mode(MirPowerMode mode);
53  bool apply_orientation(MirOrientation orientation) const;
54 
55 protected:
56  HWCCommonDevice(std::shared_ptr<HwcWrapper> const& hwc_wrapper,
57  std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
58 
59  std::shared_ptr<HWCVsyncCoordinator> const coordinator;
60  std::unique_lock<std::mutex> lock_unblanked();
61 
62 private:
63  void turn_screen_on() const;
64  void turn_screen_off();
65  virtual void turned_screen_off();
66 
67  std::shared_ptr<HWCCallbacks> const callbacks;
68  std::shared_ptr<HwcWrapper> const hwc_device;
69 
70  std::mutex blanked_mutex;
71  std::condition_variable blanked_cond;
72  MirPowerMode current_mode;
73 };
74 
75 }
76 }
77 }
78 
79 #endif /* MIR_GRAPHICS_ANDROID_HWC_COMMON_DEVICE_H_ */
All things Mir.
Definition: aging_buffer.h:24
std::shared_ptr< HWCVsyncCoordinator > const coordinator
Definition: hwc_common_device.h:59
Definition: display_device.h:38
Definition: hwc_common_device.h:46
Definition: hwc_common_device.h:40
bool apply_orientation(MirOrientation orientation) const
Definition: hwc_common_device.cpp:142
void mode(MirPowerMode mode)
Definition: hwc_common_device.cpp:92
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:134
MirPowerMode
Definition: common.h:96
void notify_vsync()
Definition: hwc_common_device.cpp:87
HWCCommonDevice(std::shared_ptr< HwcWrapper > const &hwc_wrapper, std::shared_ptr< HWCVsyncCoordinator > const &coordinator)
Definition: hwc_common_device.cpp:48
std::unique_lock< std::mutex > lock_unblanked()
Definition: hwc_common_device.cpp:117
hwc_wrapper(hwc_wrapper)
Definition: android_input_receiver.h:32
virtual ~HWCCommonDevice() noexcept
Definition: hwc_common_device.cpp:72
hwc_procs_t hooks
Definition: hwc_common_device.h:42

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014