Merge lp:~kdub/mir/n7-support into lp:mir
- n7-support
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1222 |
Proposed branch: | lp:~kdub/mir/n7-support |
Merge into: | lp:mir |
Diff against target: |
1174 lines (+277/-420) 12 files modified
include/test/mir_test_doubles/mock_hwc_composer_device_1.h (+10/-2) src/server/graphics/android/hwc10_device.cpp (+7/-9) src/server/graphics/android/hwc10_device.h (+3/-0) src/server/graphics/android/hwc11_device.cpp (+10/-9) src/server/graphics/android/hwc11_device.h (+3/-5) src/server/graphics/android/hwc_layerlist.cpp (+81/-102) src/server/graphics/android/hwc_layerlist.h (+35/-59) src/server/graphics/android/resource_factory.cpp (+1/-2) tests/unit-tests/graphics/android/test_hwc10_device.cpp (+5/-8) tests/unit-tests/graphics/android/test_hwc11_device.cpp (+14/-50) tests/unit-tests/graphics/android/test_hwc_device.cpp (+13/-40) tests/unit-tests/graphics/android/test_hwc_layerlist.cpp (+95/-134) |
To merge this branch: | bzr merge lp:~kdub/mir/n7-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Alexandros Frantzis (community) | Needs Fixing | ||
Daniel van Vugt | manual testing | Approve | |
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email:
|
Commit message
graphics: android: support 'old aka 2012' nexus 7 hwc (nvidia tegra3 SoC) better.
Description of the change
graphics: android: support 'old aka 2012' nexus 7 hwc (nvidia tegra3 SoC) better.
improve hwc1.0 support to avert segfaulting on mir startup with hwc1.0 on tegra 3.
Mir demo clients seem to work well. Unity8 is still affected by lp:1238695
improve HWCLayerList class a bit as well. Before it was just made one layer on construction, now you can use an initializer list to have multiple layers.
These are hwc1.0 changes primarily, so I gave a basic sanity test to:
Galaxy Nexus (hwc1.0)
Nexus 7 (hwc1.0)
Nexus 4 (hwc1.1)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
Seems to run fine on the N7. Although I don't see any change in performance compared to trunk. Should there be an improvement?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandros Frantzis (afrantzis) wrote : | # |
54 + layer_list(
'true' is not very informative in this context. Perhaps use an enum?
491 + HWCLayer& operator=(HWCLayer const& layer)
492 + {
493 + memcpy(this, &layer, sizeof(HWCLayer));
494 + this->visibleRe
495 + return *this;
496 + }
497 +
498 + HWCLayer(HWCLayer const& layer)
499 + {
500 + memcpy(this, &layer, sizeof(HWCLayer));
501 + this->visibleRe
502 + }
Could (should) be in .cpp file.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
> Seems to run fine on the N7. Although I don't see any change in performance
> compared to trunk. Should there be an improvement?
Stock images are missing hwcomposer.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
> 'true' is not very informative in this context. Perhaps use an enum?
fair enough, used the existing enum from hwcomposer, HWC_SKIP_LAYER.
> Could (should) be in .cpp file.
moved to a cpp
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
> Stock images are missing hwcomposer.
> won't really affect much until that library is returned to the build. I don't
> expect much performance change from this patch
Is there a bug for that?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandros Frantzis (afrantzis) wrote : | # |
> 'true' is not very informative in this context. Perhaps use an enum?
> fair enough, used the existing enum from hwcomposer, HWC_SKIP_LAYER.
54 + layer_list(
It's still there :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
> > 'true' is not very informative in this context. Perhaps use an enum?
> > fair enough, used the existing enum from hwcomposer, HWC_SKIP_LAYER.
>
> 54 + layer_list(
>
> It's still there :)
"true" an unusual synonym for 1.
(Is there any good reason this constructor takes an int rather than an enum class?)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
> "true" an unusual synonym for 1.
yeah, an oversight when I was updating. will fix.
> (Is there any good reason this constructor takes an int rather than an enum
> class?)
we're using a header from android for this enum, which is unamed
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin DuBois (kdub) wrote : | # |
> Is there a bug for that?
not that I know of, I'll file one once this lands (less disruption that way)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
OK I don't see anything I object too.
Preview Diff
1 | === modified file 'include/test/mir_test_doubles/mock_hwc_composer_device_1.h' | |||
2 | --- include/test/mir_test_doubles/mock_hwc_composer_device_1.h 2013-04-24 05:22:20 +0000 | |||
3 | +++ include/test/mir_test_doubles/mock_hwc_composer_device_1.h 2013-11-12 23:50:30 +0000 | |||
4 | @@ -21,6 +21,8 @@ | |||
5 | 21 | 21 | ||
6 | 22 | #include <hardware/hwcomposer.h> | 22 | #include <hardware/hwcomposer.h> |
7 | 23 | #include <gmock/gmock.h> | 23 | #include <gmock/gmock.h> |
8 | 24 | #include <vector> | ||
9 | 25 | #include <memory> | ||
10 | 24 | 26 | ||
11 | 25 | namespace mir | 27 | namespace mir |
12 | 26 | { | 28 | { |
13 | @@ -59,10 +61,9 @@ | |||
14 | 59 | 61 | ||
15 | 60 | hwc_display_contents_1_t* primary_display = *in; | 62 | hwc_display_contents_1_t* primary_display = *in; |
16 | 61 | memcpy(out, primary_display, sizeof(hwc_display_contents_1_t)); | 63 | memcpy(out, primary_display, sizeof(hwc_display_contents_1_t)); |
17 | 62 | |||
18 | 63 | return 0; | 64 | return 0; |
19 | 65 | } | ||
20 | 64 | 66 | ||
21 | 65 | } | ||
22 | 66 | int save_last_prepare_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) | 67 | int save_last_prepare_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) |
23 | 67 | { | 68 | { |
24 | 68 | return save_args(&display0_prepare_content, displays); | 69 | return save_args(&display0_prepare_content, displays); |
25 | @@ -70,6 +71,12 @@ | |||
26 | 70 | 71 | ||
27 | 71 | int save_last_set_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) | 72 | int save_last_set_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) |
28 | 72 | { | 73 | { |
29 | 74 | hwc_display_contents_1_t* display = *displays; | ||
30 | 75 | for(auto i = 0u; i < display->numHwLayers; i++) | ||
31 | 76 | { | ||
32 | 77 | set_layerlist.push_back(display->hwLayers[i]); | ||
33 | 78 | set_layerlist.back().visibleRegionScreen = {0, nullptr}; | ||
34 | 79 | } | ||
35 | 73 | return save_args(&display0_set_content, displays); | 80 | return save_args(&display0_set_content, displays); |
36 | 74 | } | 81 | } |
37 | 75 | 82 | ||
38 | @@ -120,6 +127,7 @@ | |||
39 | 120 | MOCK_METHOD5(getDisplayAttributes_interface, int(struct hwc_composer_device_1*, int, uint32_t, const uint32_t*, int32_t*)); | 127 | MOCK_METHOD5(getDisplayAttributes_interface, int(struct hwc_composer_device_1*, int, uint32_t, const uint32_t*, int32_t*)); |
40 | 121 | 128 | ||
41 | 122 | hwc_display_contents_1_t display0_set_content; | 129 | hwc_display_contents_1_t display0_set_content; |
42 | 130 | std::vector<hwc_layer_1> set_layerlist; | ||
43 | 123 | hwc_display_contents_1_t display0_prepare_content; | 131 | hwc_display_contents_1_t display0_prepare_content; |
44 | 124 | }; | 132 | }; |
45 | 125 | 133 | ||
46 | 126 | 134 | ||
47 | === modified file 'src/server/graphics/android/hwc10_device.cpp' | |||
48 | --- src/server/graphics/android/hwc10_device.cpp 2013-10-25 16:39:50 +0000 | |||
49 | +++ src/server/graphics/android/hwc10_device.cpp 2013-11-12 23:50:30 +0000 | |||
50 | @@ -30,6 +30,7 @@ | |||
51 | 30 | std::shared_ptr<DisplayDevice> const& fbdev, | 30 | std::shared_ptr<DisplayDevice> const& fbdev, |
52 | 31 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) | 31 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) |
53 | 32 | : HWCCommonDevice(hwc_device, coordinator), | 32 | : HWCCommonDevice(hwc_device, coordinator), |
54 | 33 | layer_list({mga::CompositionLayer{HWC_SKIP_LAYER}}), | ||
55 | 33 | fb_device(fbdev), | 34 | fb_device(fbdev), |
56 | 34 | wait_for_vsync(true) | 35 | wait_for_vsync(true) |
57 | 35 | { | 36 | { |
58 | @@ -63,20 +64,17 @@ | |||
59 | 63 | { | 64 | { |
60 | 64 | auto lg = lock_unblanked(); | 65 | auto lg = lock_unblanked(); |
61 | 65 | 66 | ||
69 | 66 | hwc_display_contents_1 display_contents; | 67 | auto display_list = layer_list.native_list(); |
70 | 67 | display_contents.dpy = dpy; | 68 | display_list->dpy = dpy; |
71 | 68 | display_contents.sur = sur; | 69 | display_list->sur = sur; |
65 | 69 | display_contents.retireFenceFd = -1; | ||
66 | 70 | display_contents.flags = 0; | ||
67 | 71 | display_contents.numHwLayers = 0; | ||
68 | 72 | hwc_display_contents_1* contents = &display_contents; | ||
72 | 73 | 70 | ||
74 | 74 | auto rc = hwc_device->prepare(hwc_device.get(), 1, &contents); | 71 | auto rc = hwc_device->prepare(hwc_device.get(), 1, &display_list); |
75 | 75 | if (rc != 0) | 72 | if (rc != 0) |
76 | 76 | { | 73 | { |
77 | 77 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()")); | 74 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()")); |
78 | 78 | } | 75 | } |
80 | 79 | rc = hwc_device->set(hwc_device.get(), 1, &contents); | 76 | |
81 | 77 | rc = hwc_device->set(hwc_device.get(), 1, &display_list); | ||
82 | 80 | if (rc != 0) | 78 | if (rc != 0) |
83 | 81 | { | 79 | { |
84 | 82 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); | 80 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); |
85 | 83 | 81 | ||
86 | === modified file 'src/server/graphics/android/hwc10_device.h' | |||
87 | --- src/server/graphics/android/hwc10_device.h 2013-10-25 16:39:50 +0000 | |||
88 | +++ src/server/graphics/android/hwc10_device.h 2013-11-12 23:50:30 +0000 | |||
89 | @@ -19,6 +19,7 @@ | |||
90 | 19 | #ifndef MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ | 19 | #ifndef MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ |
91 | 20 | #define MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ | 20 | #define MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ |
92 | 21 | #include "hwc_common_device.h" | 21 | #include "hwc_common_device.h" |
93 | 22 | #include "hwc_layerlist.h" | ||
94 | 22 | 23 | ||
95 | 23 | namespace mir | 24 | namespace mir |
96 | 24 | { | 25 | { |
97 | @@ -44,6 +45,8 @@ | |||
98 | 44 | void commit_frame(EGLDisplay dpy, EGLSurface sur); | 45 | void commit_frame(EGLDisplay dpy, EGLSurface sur); |
99 | 45 | 46 | ||
100 | 46 | private: | 47 | private: |
101 | 48 | LayerList layer_list; | ||
102 | 49 | |||
103 | 47 | std::shared_ptr<DisplayDevice> const fb_device; | 50 | std::shared_ptr<DisplayDevice> const fb_device; |
104 | 48 | bool wait_for_vsync; | 51 | bool wait_for_vsync; |
105 | 49 | }; | 52 | }; |
106 | 50 | 53 | ||
107 | === modified file 'src/server/graphics/android/hwc11_device.cpp' | |||
108 | --- src/server/graphics/android/hwc11_device.cpp 2013-10-31 16:37:35 +0000 | |||
109 | +++ src/server/graphics/android/hwc11_device.cpp 2013-11-12 23:50:30 +0000 | |||
110 | @@ -22,6 +22,8 @@ | |||
111 | 22 | #include "hwc_vsync_coordinator.h" | 22 | #include "hwc_vsync_coordinator.h" |
112 | 23 | #include "android_format_conversion-inl.h" | 23 | #include "android_format_conversion-inl.h" |
113 | 24 | #include "mir/graphics/android/sync_fence.h" | 24 | #include "mir/graphics/android/sync_fence.h" |
114 | 25 | #include "mir/graphics/android/native_buffer.h" | ||
115 | 26 | #include "mir/graphics/buffer.h" | ||
116 | 25 | 27 | ||
117 | 26 | #include <EGL/eglext.h> | 28 | #include <EGL/eglext.h> |
118 | 27 | #include <boost/throw_exception.hpp> | 29 | #include <boost/throw_exception.hpp> |
119 | @@ -70,12 +72,9 @@ | |||
120 | 70 | } | 72 | } |
121 | 71 | 73 | ||
122 | 72 | mga::HWC11Device::HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, | 74 | mga::HWC11Device::HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
123 | 73 | std::shared_ptr<HWCLayerList> const& layer_list, | ||
124 | 74 | std::shared_ptr<DisplayDevice> const& fbdev, | ||
125 | 75 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) | 75 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) |
126 | 76 | : HWCCommonDevice(hwc_device, coordinator), | 76 | : HWCCommonDevice(hwc_device, coordinator), |
129 | 77 | layer_list(layer_list), | 77 | layer_list({mga::FramebufferLayer{}}), |
128 | 78 | fb_device(fbdev), | ||
130 | 79 | sync_ops(std::make_shared<mga::RealSyncFileOps>()), | 78 | sync_ops(std::make_shared<mga::RealSyncFileOps>()), |
131 | 80 | fb_format(determine_fb_format()) | 79 | fb_format(determine_fb_format()) |
132 | 81 | { | 80 | { |
133 | @@ -118,16 +117,19 @@ | |||
134 | 118 | 117 | ||
135 | 119 | void mga::HWC11Device::set_next_frontbuffer(std::shared_ptr<mg::Buffer> const& buffer) | 118 | void mga::HWC11Device::set_next_frontbuffer(std::shared_ptr<mg::Buffer> const& buffer) |
136 | 120 | { | 119 | { |
138 | 121 | layer_list->set_fb_target(buffer); | 120 | layer_list.set_fb_target(buffer->native_buffer_handle()); |
139 | 121 | //TODO: wait for framebuffer render to complete here. Eventually, we want to pass the fence right | ||
140 | 122 | // into hwc_device->set() and let that wait for the render to complete. | ||
141 | 123 | buffer->native_buffer_handle()->wait_for_content(); | ||
142 | 122 | } | 124 | } |
143 | 123 | 125 | ||
144 | 124 | void mga::HWC11Device::commit_frame(EGLDisplay dpy, EGLSurface sur) | 126 | void mga::HWC11Device::commit_frame(EGLDisplay dpy, EGLSurface sur) |
145 | 125 | { | 127 | { |
146 | 126 | auto lg = lock_unblanked(); | 128 | auto lg = lock_unblanked(); |
148 | 127 | 129 | ||
149 | 128 | //note, although we only have a primary display right now, | 130 | //note, although we only have a primary display right now, |
150 | 129 | // set the second display to nullptr, as exynos hwc always derefs displays[1] | 131 | // set the second display to nullptr, as exynos hwc always derefs displays[1] |
152 | 130 | hwc_display_contents_1_t* displays[HWC_NUM_DISPLAY_TYPES] {layer_list->native_list(), nullptr}; | 132 | hwc_display_contents_1_t* displays[HWC_NUM_DISPLAY_TYPES] {layer_list.native_list(), nullptr}; |
153 | 131 | 133 | ||
154 | 132 | if (hwc_device->prepare(hwc_device.get(), 1, displays)) | 134 | if (hwc_device->prepare(hwc_device.get(), 1, displays)) |
155 | 133 | { | 135 | { |
156 | @@ -135,7 +137,7 @@ | |||
157 | 135 | } | 137 | } |
158 | 136 | 138 | ||
159 | 137 | /* note, swapbuffers will go around through the driver and call | 139 | /* note, swapbuffers will go around through the driver and call |
161 | 138 | set_next_frontbuffer, updating the fb target before committing */ | 140 | set_next_frontbuffer, updating the fb in layerlist before committing */ |
162 | 139 | if (eglSwapBuffers(dpy, sur) == EGL_FALSE) | 141 | if (eglSwapBuffers(dpy, sur) == EGL_FALSE) |
163 | 140 | { | 142 | { |
164 | 141 | BOOST_THROW_EXCEPTION(std::runtime_error("error during eglSwapBuffers")); | 143 | BOOST_THROW_EXCEPTION(std::runtime_error("error during eglSwapBuffers")); |
165 | @@ -145,7 +147,6 @@ | |||
166 | 145 | { | 147 | { |
167 | 146 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); | 148 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); |
168 | 147 | } | 149 | } |
169 | 148 | |||
170 | 149 | mga::SyncFence fence(sync_ops, displays[HWC_DISPLAY_PRIMARY]->retireFenceFd); | 150 | mga::SyncFence fence(sync_ops, displays[HWC_DISPLAY_PRIMARY]->retireFenceFd); |
171 | 150 | fence.wait(); | 151 | fence.wait(); |
172 | 151 | } | 152 | } |
173 | 152 | 153 | ||
174 | === modified file 'src/server/graphics/android/hwc11_device.h' | |||
175 | --- src/server/graphics/android/hwc11_device.h 2013-10-31 16:27:43 +0000 | |||
176 | +++ src/server/graphics/android/hwc11_device.h 2013-11-12 23:50:30 +0000 | |||
177 | @@ -19,6 +19,7 @@ | |||
178 | 19 | #ifndef MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ | 19 | #ifndef MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ |
179 | 20 | #define MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ | 20 | #define MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ |
180 | 21 | #include "hwc_common_device.h" | 21 | #include "hwc_common_device.h" |
181 | 22 | #include "hwc_layerlist.h" | ||
182 | 22 | #include <memory> | 23 | #include <memory> |
183 | 23 | 24 | ||
184 | 24 | namespace mir | 25 | namespace mir |
185 | @@ -29,7 +30,6 @@ | |||
186 | 29 | 30 | ||
187 | 30 | namespace android | 31 | namespace android |
188 | 31 | { | 32 | { |
189 | 32 | class HWCLayerList; | ||
190 | 33 | class HWCVsyncCoordinator; | 33 | class HWCVsyncCoordinator; |
191 | 34 | class SyncFileOps; | 34 | class SyncFileOps; |
192 | 35 | 35 | ||
193 | @@ -37,8 +37,6 @@ | |||
194 | 37 | { | 37 | { |
195 | 38 | public: | 38 | public: |
196 | 39 | HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, | 39 | HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
197 | 40 | std::shared_ptr<HWCLayerList> const& layer_list, | ||
198 | 41 | std::shared_ptr<DisplayDevice> const& fbdev, | ||
199 | 42 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator); | 40 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator); |
200 | 43 | ~HWC11Device() noexcept; | 41 | ~HWC11Device() noexcept; |
201 | 44 | 42 | ||
202 | @@ -51,8 +49,8 @@ | |||
203 | 51 | void commit_frame(EGLDisplay dpy, EGLSurface sur); | 49 | void commit_frame(EGLDisplay dpy, EGLSurface sur); |
204 | 52 | 50 | ||
205 | 53 | private: | 51 | private: |
208 | 54 | std::shared_ptr<HWCLayerList> const layer_list; | 52 | LayerList layer_list; |
209 | 55 | std::shared_ptr<DisplayDevice> const fb_device; | 53 | |
210 | 56 | std::shared_ptr<SyncFileOps> const sync_ops; | 54 | std::shared_ptr<SyncFileOps> const sync_ops; |
211 | 57 | unsigned int primary_display_config; | 55 | unsigned int primary_display_config; |
212 | 58 | geometry::PixelFormat fb_format; | 56 | geometry::PixelFormat fb_format; |
213 | 59 | 57 | ||
214 | === modified file 'src/server/graphics/android/hwc_layerlist.cpp' | |||
215 | --- src/server/graphics/android/hwc_layerlist.cpp 2013-10-16 03:27:36 +0000 | |||
216 | +++ src/server/graphics/android/hwc_layerlist.cpp 2013-11-12 23:50:30 +0000 | |||
217 | @@ -19,7 +19,6 @@ | |||
218 | 19 | #include "mir/graphics/android/sync_fence.h" | 19 | #include "mir/graphics/android/sync_fence.h" |
219 | 20 | #include "mir/graphics/android/native_buffer.h" | 20 | #include "mir/graphics/android/native_buffer.h" |
220 | 21 | #include "hwc_layerlist.h" | 21 | #include "hwc_layerlist.h" |
221 | 22 | #include "buffer.h" | ||
222 | 23 | 22 | ||
223 | 24 | #include <cstring> | 23 | #include <cstring> |
224 | 25 | 24 | ||
225 | @@ -27,112 +26,92 @@ | |||
226 | 27 | namespace mga=mir::graphics::android; | 26 | namespace mga=mir::graphics::android; |
227 | 28 | namespace geom=mir::geometry; | 27 | namespace geom=mir::geometry; |
228 | 29 | 28 | ||
328 | 30 | mga::HWCRect::HWCRect() | 29 | mga::HWCLayer& mga::HWCLayer::operator=(HWCLayer const& layer) |
329 | 31 | : self{0,0,0,0} | 30 | { |
330 | 32 | { | 31 | memcpy(this, &layer, sizeof(HWCLayer)); |
331 | 33 | } | 32 | this->visibleRegionScreen = {1, &this->visible_rect}; |
332 | 34 | 33 | return *this; | |
333 | 35 | mga::HWCRect::HWCRect(geom::Rectangle& rect) | 34 | } |
334 | 36 | { | 35 | |
335 | 37 | self.top = rect.top_left.y.as_uint32_t(); | 36 | mga::HWCLayer::HWCLayer(HWCLayer const& layer) |
336 | 38 | self.left = rect.top_left.x.as_uint32_t(); | 37 | { |
337 | 39 | self.bottom= rect.size.height.as_uint32_t(); | 38 | memcpy(this, &layer, sizeof(HWCLayer)); |
338 | 40 | self.right = rect.size.width.as_uint32_t(); | 39 | this->visibleRegionScreen = {1, &this->visible_rect}; |
339 | 41 | } | 40 | } |
340 | 42 | 41 | ||
341 | 43 | mga::HWCDefaultLayer::HWCDefaultLayer(std::initializer_list<mga::HWCRect> list) | 42 | mga::HWCLayer::HWCLayer(int type, buffer_handle_t buffer_handle, int width, int height, int layer_flags) |
342 | 44 | { | 43 | { |
343 | 45 | /* default values.*/ | 44 | compositionType = type; |
344 | 46 | self.compositionType = HWC_FRAMEBUFFER_TARGET; | 45 | hints = 0; |
345 | 47 | self.hints = 0; | 46 | flags = layer_flags; |
346 | 48 | self.flags = 0; | 47 | transform = 0; |
347 | 49 | self.transform = 0; | 48 | blending = HWC_BLENDING_NONE; |
348 | 50 | self.blending = HWC_BLENDING_NONE; | 49 | //TODO: acquireFenceFd should be buffer.fence() |
349 | 51 | self.acquireFenceFd = -1; | 50 | acquireFenceFd = -1; |
350 | 52 | self.releaseFenceFd = -1; | 51 | releaseFenceFd = -1; |
351 | 53 | 52 | ||
352 | 54 | HWCRect emptyrect; | 53 | visible_rect.top = 0; |
353 | 55 | self.sourceCrop = emptyrect; | 54 | visible_rect.left = 0; |
354 | 56 | self.displayFrame = emptyrect; | 55 | visible_rect.bottom = height; |
355 | 57 | self.visibleRegionScreen.numRects=list.size(); | 56 | visible_rect.right = width; |
356 | 58 | self.visibleRegionScreen.rects=nullptr; | 57 | sourceCrop = visible_rect; |
357 | 59 | if (list.size() != 0) | 58 | displayFrame = visible_rect; |
358 | 60 | { | 59 | visibleRegionScreen.numRects=1; |
359 | 61 | auto rect_array = new hwc_rect_t[list.size()]; | 60 | visibleRegionScreen.rects= &visible_rect; |
360 | 62 | auto i = 0u; | 61 | handle = buffer_handle; |
361 | 63 | for( auto& rect : list ) | 62 | } |
362 | 64 | { | 63 | |
363 | 65 | rect_array[i++] = rect; | 64 | mga::FramebufferLayer::FramebufferLayer() |
364 | 66 | } | 65 | : HWCLayer(HWC_FRAMEBUFFER_TARGET, nullptr, 0, 0, 0) |
365 | 67 | self.visibleRegionScreen.rects = rect_array; | 66 | { |
366 | 68 | } | 67 | } |
367 | 69 | } | 68 | |
368 | 70 | 69 | mga::FramebufferLayer::FramebufferLayer(mg::NativeBuffer const& buffer) | |
369 | 71 | mga::HWCDefaultLayer::~HWCDefaultLayer() | 70 | : HWCLayer(HWC_FRAMEBUFFER_TARGET, buffer.handle(), |
370 | 72 | { | 71 | buffer.anwb()->width, buffer.anwb()->height, 0) |
371 | 73 | if (self.visibleRegionScreen.rects) | 72 | { |
372 | 74 | { | 73 | } |
373 | 75 | delete[] self.visibleRegionScreen.rects; | 74 | |
374 | 76 | } | 75 | mga::CompositionLayer::CompositionLayer(int layer_flags) |
375 | 77 | } | 76 | : HWCLayer(HWC_FRAMEBUFFER, nullptr, 0, 0, layer_flags) |
376 | 78 | 77 | { | |
377 | 79 | mga::HWCFBLayer::HWCFBLayer( | 78 | } |
378 | 80 | buffer_handle_t native_handle, | 79 | |
379 | 81 | HWCRect display_frame_rect) | 80 | mga::CompositionLayer::CompositionLayer(mg::NativeBuffer const& buffer, int layer_flags) |
380 | 82 | : HWCDefaultLayer{display_frame_rect} | 81 | : HWCLayer(HWC_FRAMEBUFFER, buffer.handle(), |
381 | 83 | { | 82 | buffer.anwb()->width, buffer.anwb()->height, layer_flags) |
382 | 84 | self.compositionType = HWC_FRAMEBUFFER_TARGET; | 83 | { |
383 | 85 | 84 | } | |
384 | 86 | self.handle = native_handle; | 85 | |
385 | 87 | self.sourceCrop = display_frame_rect; | 86 | mga::LayerList::LayerList(std::initializer_list<HWCLayer> const& layer_list) |
386 | 88 | self.displayFrame = display_frame_rect; | 87 | { |
387 | 89 | } | 88 | auto struct_size = sizeof(hwc_display_contents_1_t) + sizeof(hwc_layer_1_t)*(layer_list.size()); |
388 | 90 | 89 | hwc_representation = std::shared_ptr<hwc_display_contents_1_t>( | |
389 | 91 | mga::HWCFBLayer::HWCFBLayer() | 90 | static_cast<hwc_display_contents_1_t*>( ::operator new(struct_size))); |
291 | 92 | : HWCFBLayer{nullptr, mga::HWCRect{}} | ||
292 | 93 | { | ||
293 | 94 | } | ||
294 | 95 | |||
295 | 96 | mga::LayerList::LayerList() | ||
296 | 97 | : layer_list{std::make_shared<HWCFBLayer>()}, | ||
297 | 98 | hwc_representation{std::make_shared<hwc_display_contents_1_t>()} | ||
298 | 99 | { | ||
299 | 100 | memset(hwc_representation.get(), 0, sizeof(hwc_display_contents_1_t)); | ||
300 | 101 | update_list(); | ||
301 | 102 | } | ||
302 | 103 | |||
303 | 104 | void mga::LayerList::set_fb_target(std::shared_ptr<mg::Buffer> const& buffer) | ||
304 | 105 | { | ||
305 | 106 | auto native_buffer = buffer->native_buffer_handle(); | ||
306 | 107 | native_buffer->wait_for_content(); | ||
307 | 108 | |||
308 | 109 | geom::Point pt{0, 0}; | ||
309 | 110 | geom::Rectangle rect{pt, buffer->size()}; | ||
310 | 111 | HWCRect display_rect(rect); | ||
311 | 112 | |||
312 | 113 | auto fb_layer = std::make_shared<HWCFBLayer>(native_buffer->handle(), display_rect); | ||
313 | 114 | layer_list[fb_position] = fb_layer; | ||
314 | 115 | |||
315 | 116 | update_list(); | ||
316 | 117 | } | ||
317 | 118 | |||
318 | 119 | void mga::LayerList::update_list() | ||
319 | 120 | { | ||
320 | 121 | if (layer_list.size() != hwc_representation->numHwLayers) | ||
321 | 122 | { | ||
322 | 123 | auto struct_size = sizeof(hwc_display_contents_1_t) + sizeof(hwc_layer_1_t)*(layer_list.size()); | ||
323 | 124 | hwc_representation = std::shared_ptr<hwc_display_contents_1_t>( | ||
324 | 125 | static_cast<hwc_display_contents_1_t*>( ::operator new(struct_size))); | ||
325 | 126 | |||
326 | 127 | hwc_representation->numHwLayers = layer_list.size(); | ||
327 | 128 | } | ||
390 | 129 | 91 | ||
391 | 130 | auto i = 0u; | 92 | auto i = 0u; |
393 | 131 | for( auto& layer : layer_list) | 93 | for(auto& layer : layer_list) |
394 | 132 | { | 94 | { |
396 | 133 | hwc_representation->hwLayers[i++] = *layer; | 95 | hwc_representation->hwLayers[i++] = layer; |
397 | 134 | } | 96 | } |
398 | 97 | hwc_representation->numHwLayers = layer_list.size(); | ||
399 | 135 | hwc_representation->retireFenceFd = -1; | 98 | hwc_representation->retireFenceFd = -1; |
400 | 99 | hwc_representation->flags = HWC_GEOMETRY_CHANGED; | ||
401 | 100 | |||
402 | 101 | //aosp exynos hwc in particular, checks that these fields are non-null in hwc1.1, although | ||
403 | 102 | //these fields are deprecated in hwc1.1 and later. | ||
404 | 103 | hwc_representation->dpy = reinterpret_cast<void*>(0xDECAF); | ||
405 | 104 | hwc_representation->sur = reinterpret_cast<void*>(0xC0FFEE); | ||
406 | 105 | |||
407 | 106 | } | ||
408 | 107 | |||
409 | 108 | void mga::LayerList::set_fb_target(std::shared_ptr<NativeBuffer> const& native_buffer) | ||
410 | 109 | { | ||
411 | 110 | auto fb_position = hwc_representation->numHwLayers - 1; | ||
412 | 111 | if (hwc_representation->hwLayers[fb_position].compositionType == HWC_FRAMEBUFFER_TARGET) | ||
413 | 112 | { | ||
414 | 113 | hwc_representation->hwLayers[fb_position] = mga::FramebufferLayer(*native_buffer); | ||
415 | 114 | } | ||
416 | 136 | } | 115 | } |
417 | 137 | 116 | ||
418 | 138 | hwc_display_contents_1_t* mga::LayerList::native_list() const | 117 | hwc_display_contents_1_t* mga::LayerList::native_list() const |
419 | 139 | 118 | ||
420 | === modified file 'src/server/graphics/android/hwc_layerlist.h' | |||
421 | --- src/server/graphics/android/hwc_layerlist.h 2013-09-11 00:50:04 +0000 | |||
422 | +++ src/server/graphics/android/hwc_layerlist.h 2013-11-12 23:50:30 +0000 | |||
423 | @@ -24,76 +24,52 @@ | |||
424 | 24 | #include <memory> | 24 | #include <memory> |
425 | 25 | #include <vector> | 25 | #include <vector> |
426 | 26 | #include <initializer_list> | 26 | #include <initializer_list> |
427 | 27 | |||
428 | 27 | namespace mir | 28 | namespace mir |
429 | 28 | { | 29 | { |
430 | 29 | namespace graphics | 30 | namespace graphics |
431 | 30 | { | 31 | { |
432 | 32 | |||
433 | 33 | class NativeBuffer; | ||
434 | 31 | class Buffer; | 34 | class Buffer; |
435 | 32 | 35 | ||
436 | 33 | namespace android | 36 | namespace android |
437 | 34 | { | 37 | { |
493 | 35 | 38 | ||
494 | 36 | struct HWCRect | 39 | struct HWCLayer : public hwc_layer_1 |
495 | 37 | { | 40 | { |
496 | 38 | HWCRect(); | 41 | virtual ~HWCLayer() = default; |
497 | 39 | HWCRect(geometry::Rectangle& rect); | 42 | |
498 | 40 | 43 | HWCLayer& operator=(HWCLayer const& layer); | |
499 | 41 | operator hwc_rect_t const& () const { return self; } | 44 | HWCLayer(HWCLayer const& layer); |
500 | 42 | operator hwc_rect_t& () { return self; } | 45 | |
501 | 43 | private: | 46 | protected: |
502 | 44 | hwc_rect_t self; | 47 | HWCLayer(int type, buffer_handle_t handle, int width, int height, int layer_flags); |
503 | 45 | }; | 48 | |
504 | 46 | 49 | hwc_rect_t visible_rect; | |
505 | 47 | struct HWCDefaultLayer | 50 | }; |
506 | 48 | { | 51 | |
507 | 49 | HWCDefaultLayer(std::initializer_list<HWCRect> list); | 52 | struct CompositionLayer : public HWCLayer |
508 | 50 | ~HWCDefaultLayer(); | 53 | { |
509 | 51 | 54 | CompositionLayer(int layer_flags); | |
510 | 52 | operator hwc_layer_1 const& () const { return self; } | 55 | CompositionLayer(NativeBuffer const&, int layer_flags); |
511 | 53 | operator hwc_layer_1& () { return self; } | 56 | }; |
512 | 54 | 57 | ||
513 | 55 | protected: | 58 | struct FramebufferLayer : public HWCLayer |
514 | 56 | HWCDefaultLayer& operator=(HWCDefaultLayer const&) = delete; | 59 | { |
515 | 57 | HWCDefaultLayer(HWCDefaultLayer const&) = delete; | 60 | FramebufferLayer(); |
516 | 58 | 61 | FramebufferLayer(NativeBuffer const&); | |
517 | 59 | hwc_layer_1 self; | 62 | }; |
518 | 60 | }; | 63 | |
519 | 61 | 64 | class LayerList | |
520 | 62 | struct HWCFBLayer : public HWCDefaultLayer | 65 | { |
521 | 63 | { | 66 | public: |
522 | 64 | HWCFBLayer(); | 67 | LayerList(std::initializer_list<HWCLayer> const& layers); |
523 | 65 | HWCFBLayer(buffer_handle_t native_buf, | 68 | |
469 | 66 | HWCRect display_frame_rect); | ||
470 | 67 | }; | ||
471 | 68 | |||
472 | 69 | class HWCLayerList | ||
473 | 70 | { | ||
474 | 71 | public: | ||
475 | 72 | virtual ~HWCLayerList() = default; | ||
476 | 73 | |||
477 | 74 | virtual hwc_display_contents_1_t* native_list() const = 0; | ||
478 | 75 | virtual void set_fb_target(std::shared_ptr<Buffer> const&) = 0; | ||
479 | 76 | |||
480 | 77 | protected: | ||
481 | 78 | HWCLayerList() = default; | ||
482 | 79 | HWCLayerList& operator=(HWCLayerList const&) = delete; | ||
483 | 80 | HWCLayerList(HWCLayerList const&) = delete; | ||
484 | 81 | |||
485 | 82 | }; | ||
486 | 83 | |||
487 | 84 | class LayerList : public HWCLayerList | ||
488 | 85 | { | ||
489 | 86 | public: | ||
490 | 87 | LayerList(); | ||
491 | 88 | |||
492 | 89 | void set_fb_target(std::shared_ptr<Buffer> const&); | ||
524 | 90 | hwc_display_contents_1_t* native_list() const; | 69 | hwc_display_contents_1_t* native_list() const; |
525 | 70 | void set_fb_target(std::shared_ptr<NativeBuffer> const&); | ||
526 | 91 | 71 | ||
527 | 92 | private: | 72 | private: |
528 | 93 | std::vector<std::shared_ptr<HWCDefaultLayer>> layer_list; | ||
529 | 94 | void update_list(); | ||
530 | 95 | |||
531 | 96 | static size_t const fb_position = 0u; | ||
532 | 97 | std::shared_ptr<hwc_display_contents_1_t> hwc_representation; | 73 | std::shared_ptr<hwc_display_contents_1_t> hwc_representation; |
533 | 98 | }; | 74 | }; |
534 | 99 | 75 | ||
535 | 100 | 76 | ||
536 | === modified file 'src/server/graphics/android/resource_factory.cpp' | |||
537 | --- src/server/graphics/android/resource_factory.cpp 2013-10-28 22:17:13 +0000 | |||
538 | +++ src/server/graphics/android/resource_factory.cpp 2013-11-12 23:50:30 +0000 | |||
539 | @@ -106,9 +106,8 @@ | |||
540 | 106 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc11_device( | 106 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc11_device( |
541 | 107 | std::shared_ptr<hwc_composer_device_1> const& hwc_native_device) const | 107 | std::shared_ptr<hwc_composer_device_1> const& hwc_native_device) const |
542 | 108 | { | 108 | { |
543 | 109 | auto layer_list = std::make_shared<mga::LayerList>(); | ||
544 | 110 | auto syncer = std::make_shared<mga::HWCVsync>(); | 109 | auto syncer = std::make_shared<mga::HWCVsync>(); |
546 | 111 | return std::make_shared<mga::HWC11Device>(hwc_native_device, layer_list, nullptr, syncer); | 110 | return std::make_shared<mga::HWC11Device>(hwc_native_device, syncer); |
547 | 112 | } | 111 | } |
548 | 113 | 112 | ||
549 | 114 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc10_device( | 113 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc10_device( |
550 | 115 | 114 | ||
551 | === modified file 'tests/unit-tests/graphics/android/test_hwc10_device.cpp' | |||
552 | --- tests/unit-tests/graphics/android/test_hwc10_device.cpp 2013-10-25 16:39:50 +0000 | |||
553 | +++ tests/unit-tests/graphics/android/test_hwc10_device.cpp 2013-11-12 23:50:30 +0000 | |||
554 | @@ -86,14 +86,11 @@ | |||
555 | 86 | EXPECT_EQ(dpy, mock_device->display0_set_content.dpy); | 86 | EXPECT_EQ(dpy, mock_device->display0_set_content.dpy); |
556 | 87 | EXPECT_EQ(sur, mock_device->display0_set_content.sur); | 87 | EXPECT_EQ(sur, mock_device->display0_set_content.sur); |
557 | 88 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); | 88 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
566 | 89 | EXPECT_EQ(0u, mock_device->display0_set_content.flags); | 89 | EXPECT_EQ(HWC_GEOMETRY_CHANGED, mock_device->display0_set_content.flags); |
567 | 90 | EXPECT_EQ(0u, mock_device->display0_set_content.numHwLayers); | 90 | EXPECT_EQ(1u, mock_device->display0_set_content.numHwLayers); |
568 | 91 | 91 | ASSERT_NE(nullptr, mock_device->display0_set_content.hwLayers); | |
569 | 92 | EXPECT_EQ(dpy, mock_device->display0_prepare_content.dpy); | 92 | EXPECT_EQ(HWC_FRAMEBUFFER, mock_device->set_layerlist[0].compositionType); |
570 | 93 | EXPECT_EQ(sur, mock_device->display0_prepare_content.sur); | 93 | EXPECT_EQ(HWC_SKIP_LAYER, mock_device->set_layerlist[0].flags); |
563 | 94 | EXPECT_EQ(-1, mock_device->display0_prepare_content.retireFenceFd); | ||
564 | 95 | EXPECT_EQ(0u, mock_device->display0_prepare_content.flags); | ||
565 | 96 | EXPECT_EQ(0u, mock_device->display0_prepare_content.numHwLayers); | ||
571 | 97 | } | 94 | } |
572 | 98 | 95 | ||
573 | 99 | TEST_F(HWC10Device, hwc10_commit_frame_async) | 96 | TEST_F(HWC10Device, hwc10_commit_frame_async) |
574 | 100 | 97 | ||
575 | === modified file 'tests/unit-tests/graphics/android/test_hwc11_device.cpp' | |||
576 | --- tests/unit-tests/graphics/android/test_hwc11_device.cpp 2013-10-31 00:11:29 +0000 | |||
577 | +++ tests/unit-tests/graphics/android/test_hwc11_device.cpp 2013-11-12 23:50:30 +0000 | |||
578 | @@ -18,9 +18,7 @@ | |||
579 | 18 | 18 | ||
580 | 19 | #include "src/server/graphics/android/hwc11_device.h" | 19 | #include "src/server/graphics/android/hwc11_device.h" |
581 | 20 | #include "src/server/graphics/android/hwc_layerlist.h" | 20 | #include "src/server/graphics/android/hwc_layerlist.h" |
582 | 21 | #include "mir_test_doubles/mock_display_device.h" | ||
583 | 22 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" | 21 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" |
584 | 23 | #include "mir_test_doubles/mock_hwc_layerlist.h" | ||
585 | 24 | #include "mir_test_doubles/mock_buffer.h" | 22 | #include "mir_test_doubles/mock_buffer.h" |
586 | 25 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" | 23 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" |
587 | 26 | #include "mir_test_doubles/mock_egl.h" | 24 | #include "mir_test_doubles/mock_egl.h" |
588 | @@ -38,49 +36,27 @@ | |||
589 | 38 | virtual void SetUp() | 36 | virtual void SetUp() |
590 | 39 | { | 37 | { |
591 | 40 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); | 38 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); |
592 | 41 | mock_display_device = std::make_shared<testing::NiceMock<mtd::MockDisplayDevice>>(); | ||
593 | 42 | mock_hwc_layers = std::make_shared<testing::NiceMock<mtd::MockHWCLayerList>>(); | ||
594 | 43 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); | 39 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); |
595 | 44 | mock_egl.silence_uninteresting(); | ||
596 | 45 | |||
597 | 46 | empty_list.numHwLayers = 0; | ||
598 | 47 | empty_list.retireFenceFd = -1; | ||
599 | 48 | ON_CALL(*mock_hwc_layers, native_list()) | ||
600 | 49 | .WillByDefault(testing::Return(&empty_list)); | ||
601 | 50 | } | 40 | } |
602 | 51 | 41 | ||
603 | 52 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; | 42 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; |
604 | 53 | std::shared_ptr<mtd::MockHWCLayerList> mock_hwc_layers; | ||
605 | 54 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; | 43 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; |
606 | 55 | std::shared_ptr<mtd::MockDisplayDevice> mock_display_device; | ||
607 | 56 | EGLDisplay dpy; | 44 | EGLDisplay dpy; |
608 | 57 | EGLSurface surf; | 45 | EGLSurface surf; |
609 | 58 | testing::NiceMock<mtd::MockEGL> mock_egl; | 46 | testing::NiceMock<mtd::MockEGL> mock_egl; |
623 | 59 | hwc_display_contents_1_t empty_list; | 47 | }; |
611 | 60 | }; | ||
612 | 61 | |||
613 | 62 | namespace | ||
614 | 63 | { | ||
615 | 64 | struct HWCDummyLayer : public mga::HWCDefaultLayer | ||
616 | 65 | { | ||
617 | 66 | HWCDummyLayer() | ||
618 | 67 | : HWCDefaultLayer({}) | ||
619 | 68 | { | ||
620 | 69 | } | ||
621 | 70 | }; | ||
622 | 71 | } | ||
624 | 72 | 48 | ||
625 | 73 | TEST_F(HWC11Device, test_hwc_gles_set_empty_layerlist) | 49 | TEST_F(HWC11Device, test_hwc_gles_set_empty_layerlist) |
626 | 74 | { | 50 | { |
627 | 75 | using namespace testing; | 51 | using namespace testing; |
628 | 76 | 52 | ||
630 | 77 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 53 | mga::HWC11Device device(mock_device, mock_vsync); |
631 | 78 | 54 | ||
632 | 79 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) | 55 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) |
633 | 80 | .Times(1); | 56 | .Times(1); |
634 | 81 | device.commit_frame(dpy, surf); | 57 | device.commit_frame(dpy, surf); |
635 | 82 | 58 | ||
637 | 83 | EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_set_content.numHwLayers); | 59 | EXPECT_EQ(1, mock_device->display0_set_content.numHwLayers); |
638 | 84 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); | 60 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
639 | 85 | } | 61 | } |
640 | 86 | 62 | ||
641 | @@ -88,7 +64,7 @@ | |||
642 | 88 | { | 64 | { |
643 | 89 | using namespace testing; | 65 | using namespace testing; |
644 | 90 | 66 | ||
646 | 91 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 67 | mga::HWC11Device device(mock_device, mock_vsync); |
647 | 92 | 68 | ||
648 | 93 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) | 69 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) |
649 | 94 | .Times(1) | 70 | .Times(1) |
650 | @@ -106,7 +82,7 @@ | |||
651 | 106 | .Times(1) | 82 | .Times(1) |
652 | 107 | .WillOnce(Return(EGL_FALSE)); | 83 | .WillOnce(Return(EGL_FALSE)); |
653 | 108 | 84 | ||
655 | 109 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 85 | mga::HWC11Device device(mock_device, mock_vsync); |
656 | 110 | 86 | ||
657 | 111 | EXPECT_THROW({ | 87 | EXPECT_THROW({ |
658 | 112 | device.commit_frame(dpy, surf); | 88 | device.commit_frame(dpy, surf); |
659 | @@ -117,13 +93,11 @@ | |||
660 | 117 | { | 93 | { |
661 | 118 | using namespace testing; | 94 | using namespace testing; |
662 | 119 | 95 | ||
664 | 120 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 96 | mga::HWC11Device device(mock_device, mock_vsync); |
665 | 121 | 97 | ||
666 | 122 | //the order here is very important. eglSwapBuffers will alter the layerlist, | 98 | //the order here is very important. eglSwapBuffers will alter the layerlist, |
667 | 123 | //so it must come before assembling the data for set | 99 | //so it must come before assembling the data for set |
668 | 124 | InSequence seq; | 100 | InSequence seq; |
669 | 125 | EXPECT_CALL(*mock_hwc_layers, native_list()) | ||
670 | 126 | .Times(1); | ||
671 | 127 | EXPECT_CALL(*mock_device, prepare_interface(mock_device.get(), 1, _)) | 101 | EXPECT_CALL(*mock_device, prepare_interface(mock_device.get(), 1, _)) |
672 | 128 | .Times(1); | 102 | .Times(1); |
673 | 129 | EXPECT_CALL(mock_egl, eglSwapBuffers(dpy,surf)) | 103 | EXPECT_CALL(mock_egl, eglSwapBuffers(dpy,surf)) |
674 | @@ -133,22 +107,12 @@ | |||
675 | 133 | 107 | ||
676 | 134 | device.commit_frame(dpy, surf); | 108 | device.commit_frame(dpy, surf); |
677 | 135 | 109 | ||
679 | 136 | EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_prepare_content.numHwLayers); | 110 | EXPECT_EQ(1, mock_device->display0_prepare_content.numHwLayers); |
680 | 137 | EXPECT_EQ(-1, mock_device->display0_prepare_content.retireFenceFd); | 111 | EXPECT_EQ(-1, mock_device->display0_prepare_content.retireFenceFd); |
682 | 138 | EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_set_content.numHwLayers); | 112 | EXPECT_EQ(1, mock_device->display0_set_content.numHwLayers); |
683 | 139 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); | 113 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
684 | 140 | } | 114 | } |
685 | 141 | 115 | ||
686 | 142 | TEST_F(HWC11Device, hwc_device_set_next_frontbuffer_adds_to_layerlist) | ||
687 | 143 | { | ||
688 | 144 | std::shared_ptr<mg::Buffer> mock_buffer = std::make_shared<mtd::MockBuffer>(); | ||
689 | 145 | EXPECT_CALL(*this->mock_hwc_layers, set_fb_target(mock_buffer)) | ||
690 | 146 | .Times(1); | ||
691 | 147 | |||
692 | 148 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | ||
693 | 149 | device.set_next_frontbuffer(mock_buffer); | ||
694 | 150 | } | ||
695 | 151 | |||
696 | 152 | TEST_F(HWC11Device, test_hwc_device_display_config) | 116 | TEST_F(HWC11Device, test_hwc_device_display_config) |
697 | 153 | { | 117 | { |
698 | 154 | using namespace testing; | 118 | using namespace testing; |
699 | @@ -158,7 +122,7 @@ | |||
700 | 158 | .Times(1) | 122 | .Times(1) |
701 | 159 | .WillOnce(DoAll(SetArgPointee<2>(hwc_configs), Return(0))); | 123 | .WillOnce(DoAll(SetArgPointee<2>(hwc_configs), Return(0))); |
702 | 160 | 124 | ||
704 | 161 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 125 | mga::HWC11Device device(mock_device, mock_vsync); |
705 | 162 | } | 126 | } |
706 | 163 | 127 | ||
707 | 164 | 128 | ||
708 | @@ -172,7 +136,7 @@ | |||
709 | 172 | .WillOnce(Return(-1)); | 136 | .WillOnce(Return(-1)); |
710 | 173 | 137 | ||
711 | 174 | EXPECT_THROW({ | 138 | EXPECT_THROW({ |
713 | 175 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 139 | mga::HWC11Device device(mock_device, mock_vsync); |
714 | 176 | }, std::runtime_error); | 140 | }, std::runtime_error); |
715 | 177 | } | 141 | } |
716 | 178 | 142 | ||
717 | @@ -206,7 +170,7 @@ | |||
718 | 206 | .Times(1) | 170 | .Times(1) |
719 | 207 | .WillOnce(Invoke(display_attribute_handler)); | 171 | .WillOnce(Invoke(display_attribute_handler)); |
720 | 208 | 172 | ||
722 | 209 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 173 | mga::HWC11Device device(mock_device, mock_vsync); |
723 | 210 | 174 | ||
724 | 211 | auto size = device.display_size(); | 175 | auto size = device.display_size(); |
725 | 212 | EXPECT_EQ(size.width.as_uint32_t(), static_cast<unsigned int>(display_width)); | 176 | EXPECT_EQ(size.width.as_uint32_t(), static_cast<unsigned int>(display_width)); |
726 | @@ -215,7 +179,7 @@ | |||
727 | 215 | 179 | ||
728 | 216 | TEST_F(HWC11Device, hwc_device_reports_2_fbs_available_by_default) | 180 | TEST_F(HWC11Device, hwc_device_reports_2_fbs_available_by_default) |
729 | 217 | { | 181 | { |
731 | 218 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 182 | mga::HWC11Device device(mock_device, mock_vsync); |
732 | 219 | EXPECT_EQ(2u, device.number_of_framebuffers_available()); | 183 | EXPECT_EQ(2u, device.number_of_framebuffers_available()); |
733 | 220 | } | 184 | } |
734 | 221 | 185 | ||
735 | @@ -249,7 +213,7 @@ | |||
736 | 249 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) | 213 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) |
737 | 250 | .InSequence(seq); | 214 | .InSequence(seq); |
738 | 251 | 215 | ||
740 | 252 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 216 | mga::HWC11Device device(mock_device, mock_vsync); |
741 | 253 | EXPECT_EQ(geom::PixelFormat::argb_8888, device.display_format()); | 217 | EXPECT_EQ(geom::PixelFormat::argb_8888, device.display_format()); |
742 | 254 | } | 218 | } |
743 | 255 | 219 | ||
744 | @@ -272,6 +236,6 @@ | |||
745 | 272 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) | 236 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) |
746 | 273 | .InSequence(seq); | 237 | .InSequence(seq); |
747 | 274 | 238 | ||
749 | 275 | mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); | 239 | mga::HWC11Device device(mock_device, mock_vsync); |
750 | 276 | EXPECT_EQ(geom::PixelFormat::abgr_8888, device.display_format()); | 240 | EXPECT_EQ(geom::PixelFormat::abgr_8888, device.display_format()); |
751 | 277 | } | 241 | } |
752 | 278 | 242 | ||
753 | === modified file 'tests/unit-tests/graphics/android/test_hwc_device.cpp' | |||
754 | --- tests/unit-tests/graphics/android/test_hwc_device.cpp 2013-10-31 17:03:59 +0000 | |||
755 | +++ tests/unit-tests/graphics/android/test_hwc_device.cpp 2013-11-12 23:50:30 +0000 | |||
756 | @@ -21,7 +21,6 @@ | |||
757 | 21 | #include "src/server/graphics/android/hwc_layerlist.h" | 21 | #include "src/server/graphics/android/hwc_layerlist.h" |
758 | 22 | #include "src/server/graphics/android/hwc_vsync_coordinator.h" | 22 | #include "src/server/graphics/android/hwc_vsync_coordinator.h" |
759 | 23 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" | 23 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" |
760 | 24 | #include "mir_test_doubles/mock_hwc_layerlist.h" | ||
761 | 25 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" | 24 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" |
762 | 26 | #include "mir_test_doubles/mock_buffer.h" | 25 | #include "mir_test_doubles/mock_buffer.h" |
763 | 27 | #include "mir_test_doubles/mock_egl.h" | 26 | #include "mir_test_doubles/mock_egl.h" |
764 | @@ -39,14 +38,12 @@ | |||
765 | 39 | 38 | ||
766 | 40 | template<class T> | 39 | template<class T> |
767 | 41 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, | 40 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
768 | 42 | std::shared_ptr<mga::HWCLayerList> const& layer_list, | ||
769 | 43 | std::shared_ptr<mga::DisplayDevice> const& fbdev, | 41 | std::shared_ptr<mga::DisplayDevice> const& fbdev, |
770 | 44 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator); | 42 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator); |
771 | 45 | 43 | ||
772 | 46 | template <> | 44 | template <> |
773 | 47 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC10Device>( | 45 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC10Device>( |
774 | 48 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, | 46 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
775 | 49 | std::shared_ptr<mga::HWCLayerList> const&, | ||
776 | 50 | std::shared_ptr<mga::DisplayDevice> const& fbdev, | 47 | std::shared_ptr<mga::DisplayDevice> const& fbdev, |
777 | 51 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) | 48 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) |
778 | 52 | { | 49 | { |
779 | @@ -56,23 +53,10 @@ | |||
780 | 56 | template <> | 53 | template <> |
781 | 57 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC11Device>( | 54 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC11Device>( |
782 | 58 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, | 55 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
785 | 59 | std::shared_ptr<mga::HWCLayerList> const& layer_list, | 56 | std::shared_ptr<mga::DisplayDevice> const&, |
784 | 60 | std::shared_ptr<mga::DisplayDevice> const& fbdev, | ||
786 | 61 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) | 57 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) |
787 | 62 | { | 58 | { |
801 | 63 | return std::make_shared<mga::HWC11Device>(hwc_device, layer_list, fbdev, coordinator); | 59 | return std::make_shared<mga::HWC11Device>(hwc_device, coordinator); |
789 | 64 | } | ||
790 | 65 | |||
791 | 66 | namespace | ||
792 | 67 | { | ||
793 | 68 | struct HWCDummyLayer : public mga::HWCDefaultLayer | ||
794 | 69 | { | ||
795 | 70 | HWCDummyLayer() | ||
796 | 71 | : HWCDefaultLayer({}) | ||
797 | 72 | { | ||
798 | 73 | } | ||
799 | 74 | }; | ||
800 | 75 | |||
802 | 76 | } | 60 | } |
803 | 77 | 61 | ||
804 | 78 | template<typename T> | 62 | template<typename T> |
805 | @@ -84,14 +68,12 @@ | |||
806 | 84 | using namespace testing; | 68 | using namespace testing; |
807 | 85 | 69 | ||
808 | 86 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); | 70 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); |
809 | 87 | mock_layer_list = std::make_shared<testing::NiceMock<mtd::MockHWCLayerList>>(); | ||
810 | 88 | mock_fbdev = std::make_shared<testing::NiceMock<mtd::MockDisplayDevice>>(); | 71 | mock_fbdev = std::make_shared<testing::NiceMock<mtd::MockDisplayDevice>>(); |
811 | 89 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); | 72 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); |
812 | 90 | } | 73 | } |
813 | 91 | 74 | ||
814 | 92 | testing::NiceMock<mtd::MockEGL> mock_egl; | 75 | testing::NiceMock<mtd::MockEGL> mock_egl; |
815 | 93 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; | 76 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; |
816 | 94 | std::shared_ptr<mtd::MockHWCLayerList> mock_layer_list; | ||
817 | 95 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; | 77 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; |
818 | 96 | std::shared_ptr<mtd::MockDisplayDevice> mock_fbdev; | 78 | std::shared_ptr<mtd::MockDisplayDevice> mock_fbdev; |
819 | 97 | }; | 79 | }; |
820 | @@ -108,8 +90,7 @@ | |||
821 | 108 | .Times(1) | 90 | .Times(1) |
822 | 109 | .WillOnce(SaveArg<1>(&procs)); | 91 | .WillOnce(SaveArg<1>(&procs)); |
823 | 110 | 92 | ||
826 | 111 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 93 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
825 | 112 | this->mock_fbdev, this->mock_vsync); | ||
827 | 113 | 94 | ||
828 | 114 | EXPECT_NE(nullptr, procs->invalidate); | 95 | EXPECT_NE(nullptr, procs->invalidate); |
829 | 115 | EXPECT_NE(nullptr, procs->vsync); | 96 | EXPECT_NE(nullptr, procs->vsync); |
830 | @@ -127,8 +108,7 @@ | |||
831 | 127 | .Times(1) | 108 | .Times(1) |
832 | 128 | .WillOnce(Return(0)); | 109 | .WillOnce(Return(0)); |
833 | 129 | 110 | ||
836 | 130 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 111 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
835 | 131 | this->mock_fbdev, this->mock_vsync); | ||
837 | 132 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); | 112 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); |
838 | 133 | } | 113 | } |
839 | 134 | 114 | ||
840 | @@ -140,9 +120,9 @@ | |||
841 | 140 | .WillRepeatedly(Return(-EINVAL)); | 120 | .WillRepeatedly(Return(-EINVAL)); |
842 | 141 | 121 | ||
843 | 142 | 122 | ||
846 | 143 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 123 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
845 | 144 | this->mock_fbdev, this->mock_vsync); | ||
847 | 145 | EXPECT_THROW({ | 124 | EXPECT_THROW({ |
848 | 125 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); | ||
849 | 146 | device->mode(mir_power_mode_off); | 126 | device->mode(mir_power_mode_off); |
850 | 147 | }, std::runtime_error); | 127 | }, std::runtime_error); |
851 | 148 | } | 128 | } |
852 | @@ -156,8 +136,7 @@ | |||
853 | 156 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 0)) | 136 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 0)) |
854 | 157 | .Times(1); | 137 | .Times(1); |
855 | 158 | 138 | ||
858 | 159 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 139 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
857 | 160 | this->mock_fbdev, this->mock_vsync); | ||
859 | 161 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); | 140 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); |
860 | 162 | } | 141 | } |
861 | 163 | 142 | ||
862 | @@ -174,8 +153,7 @@ | |||
863 | 174 | .WillOnce(Return(-1)) | 153 | .WillOnce(Return(-1)) |
864 | 175 | .WillOnce(Return(0)); | 154 | .WillOnce(Return(0)); |
865 | 176 | 155 | ||
868 | 177 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 156 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
867 | 178 | this->mock_fbdev, this->mock_vsync); | ||
869 | 179 | EXPECT_THROW({ | 157 | EXPECT_THROW({ |
870 | 180 | device->mode(mir_power_mode_off); | 158 | device->mode(mir_power_mode_off); |
871 | 181 | }, std::runtime_error); | 159 | }, std::runtime_error); |
872 | @@ -192,8 +170,7 @@ | |||
873 | 192 | .Times(3) | 170 | .Times(3) |
874 | 193 | .WillRepeatedly(Return(0)); | 171 | .WillRepeatedly(Return(0)); |
875 | 194 | 172 | ||
878 | 195 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 173 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
877 | 196 | this->mock_fbdev, this->mock_vsync); | ||
879 | 197 | device->mode(mir_power_mode_off); | 174 | device->mode(mir_power_mode_off); |
880 | 198 | device->mode(mir_power_mode_on); | 175 | device->mode(mir_power_mode_on); |
881 | 199 | device->mode(mir_power_mode_suspend); | 176 | device->mode(mir_power_mode_suspend); |
882 | @@ -218,8 +195,7 @@ | |||
883 | 218 | .Times(1) | 195 | .Times(1) |
884 | 219 | .WillOnce(Return(0)); | 196 | .WillOnce(Return(0)); |
885 | 220 | 197 | ||
888 | 221 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 198 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
887 | 222 | this->mock_fbdev, this->mock_vsync); | ||
889 | 223 | device->mode(mir_power_mode_off); | 199 | device->mode(mir_power_mode_off); |
890 | 224 | } | 200 | } |
891 | 225 | 201 | ||
892 | @@ -239,15 +215,13 @@ | |||
893 | 239 | .Times(1) | 215 | .Times(1) |
894 | 240 | .WillOnce(Return(0)); | 216 | .WillOnce(Return(0)); |
895 | 241 | 217 | ||
898 | 242 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 218 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
897 | 243 | this->mock_fbdev, this->mock_vsync); | ||
899 | 244 | device->mode(mir_power_mode_on); | 219 | device->mode(mir_power_mode_on); |
900 | 245 | } | 220 | } |
901 | 246 | 221 | ||
902 | 247 | TYPED_TEST(HWCCommon, test_hwc_display_is_deactivated_on_destroy) | 222 | TYPED_TEST(HWCCommon, test_hwc_display_is_deactivated_on_destroy) |
903 | 248 | { | 223 | { |
906 | 249 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 224 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
905 | 250 | this->mock_fbdev, this->mock_vsync); | ||
907 | 251 | 225 | ||
908 | 252 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 1)) | 226 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 1)) |
909 | 253 | .Times(1); | 227 | .Times(1); |
910 | @@ -265,8 +239,7 @@ | |||
911 | 265 | .Times(1) | 239 | .Times(1) |
912 | 266 | .WillOnce(SaveArg<1>(&procs)); | 240 | .WillOnce(SaveArg<1>(&procs)); |
913 | 267 | 241 | ||
916 | 268 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, | 242 | auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
915 | 269 | this->mock_fbdev, this->mock_vsync); | ||
917 | 270 | 243 | ||
918 | 271 | EXPECT_CALL(*this->mock_vsync, notify_vsync()) | 244 | EXPECT_CALL(*this->mock_vsync, notify_vsync()) |
919 | 272 | .Times(1); | 245 | .Times(1); |
920 | 273 | 246 | ||
921 | === modified file 'tests/unit-tests/graphics/android/test_hwc_layerlist.cpp' | |||
922 | --- tests/unit-tests/graphics/android/test_hwc_layerlist.cpp 2013-10-15 08:53:10 +0000 | |||
923 | +++ tests/unit-tests/graphics/android/test_hwc_layerlist.cpp 2013-11-12 23:50:30 +0000 | |||
924 | @@ -36,140 +36,24 @@ | |||
925 | 36 | 36 | ||
926 | 37 | width = 432; | 37 | width = 432; |
927 | 38 | height = 876; | 38 | height = 876; |
928 | 39 | default_size = geom::Size{width, height}; | ||
929 | 40 | |||
930 | 41 | native_handle_1 = std::make_shared<mtd::StubAndroidNativeBuffer>(); | 39 | native_handle_1 = std::make_shared<mtd::StubAndroidNativeBuffer>(); |
931 | 40 | native_handle_1->anwb()->width = width; | ||
932 | 41 | native_handle_1->anwb()->height = height; | ||
933 | 42 | native_handle_2 = std::make_shared<mtd::StubAndroidNativeBuffer>(); | 42 | native_handle_2 = std::make_shared<mtd::StubAndroidNativeBuffer>(); |
934 | 43 | |||
935 | 44 | mock_buffer = std::make_shared<NiceMock<mtd::MockBuffer>>(); | ||
936 | 45 | ON_CALL(*mock_buffer, native_buffer_handle()) | ||
937 | 46 | .WillByDefault(Return(native_handle_1)); | ||
938 | 47 | ON_CALL(*mock_buffer, size()) | ||
939 | 48 | .WillByDefault(Return(default_size)); | ||
940 | 49 | } | 43 | } |
941 | 50 | 44 | ||
942 | 51 | int width; | 45 | int width; |
943 | 52 | int height; | 46 | int height; |
944 | 53 | geom::Size default_size; | ||
945 | 54 | |||
946 | 55 | std::shared_ptr<mg::NativeBuffer> native_handle_1; | 47 | std::shared_ptr<mg::NativeBuffer> native_handle_1; |
947 | 56 | std::shared_ptr<mg::NativeBuffer> native_handle_2; | 48 | std::shared_ptr<mg::NativeBuffer> native_handle_2; |
948 | 57 | std::shared_ptr<mtd::MockBuffer> mock_buffer; | ||
949 | 58 | }; | 49 | }; |
950 | 59 | 50 | ||
1064 | 60 | TEST(HWCLayerDeepCopy, hwc_layer) | 51 | TEST_F(HWCLayerListTest, fb_target_layer) |
1065 | 61 | { | 52 | { |
1066 | 62 | mga::HWCDefaultLayer original({}); | 53 | mga::FramebufferLayer target_layer(*native_handle_1); |
1067 | 63 | hwc_layer_1 layer = original; | 54 | |
1068 | 64 | EXPECT_EQ(0u, layer.visibleRegionScreen.numRects); | 55 | hwc_rect_t region = {0,0,width, height}; |
1069 | 65 | EXPECT_EQ(nullptr, layer.visibleRegionScreen.rects); | 56 | hwc_region_t visible_region {1, ®ion}; |
957 | 66 | |||
958 | 67 | geom::Rectangle r0{geom::Point{geom::X{0},geom::Y{1}}, | ||
959 | 68 | geom::Size{2, 3}}; | ||
960 | 69 | geom::Rectangle r1{geom::Point{geom::X{0},geom::Y{1}}, | ||
961 | 70 | geom::Size{3, 3}}; | ||
962 | 71 | geom::Rectangle r2{geom::Point{geom::X{1},geom::Y{1}}, | ||
963 | 72 | geom::Size{2, 3}}; | ||
964 | 73 | mga::HWCRect a(r0), b(r1), c(r2); | ||
965 | 74 | mga::HWCDefaultLayer original2({a, b, c}); | ||
966 | 75 | layer = original2; | ||
967 | 76 | |||
968 | 77 | ASSERT_EQ(3u, layer.visibleRegionScreen.numRects); | ||
969 | 78 | ASSERT_NE(nullptr, layer.visibleRegionScreen.rects); | ||
970 | 79 | EXPECT_THAT(a, HWCRectMatchesRect(layer.visibleRegionScreen.rects[0],"")); | ||
971 | 80 | EXPECT_THAT(b, HWCRectMatchesRect(layer.visibleRegionScreen.rects[1],"")); | ||
972 | 81 | EXPECT_THAT(c, HWCRectMatchesRect(layer.visibleRegionScreen.rects[2],"")); | ||
973 | 82 | } | ||
974 | 83 | |||
975 | 84 | TEST_F(HWCLayerListTest, hwc_list_creation_loads_latest_fb_target) | ||
976 | 85 | { | ||
977 | 86 | using namespace testing; | ||
978 | 87 | |||
979 | 88 | hwc_rect_t expected_sc, expected_df, expected_visible; | ||
980 | 89 | expected_sc = {0, 0, width, height}; | ||
981 | 90 | expected_df = expected_visible = expected_sc; | ||
982 | 91 | EXPECT_CALL(*mock_buffer, size()) | ||
983 | 92 | .Times(1) | ||
984 | 93 | .WillOnce(Return(default_size)); | ||
985 | 94 | |||
986 | 95 | mga::LayerList layerlist; | ||
987 | 96 | layerlist.set_fb_target(mock_buffer); | ||
988 | 97 | |||
989 | 98 | auto list = layerlist.native_list(); | ||
990 | 99 | ASSERT_EQ(1u, list->numHwLayers); | ||
991 | 100 | hwc_layer_1 target_layer = list->hwLayers[0]; | ||
992 | 101 | EXPECT_THAT(target_layer.sourceCrop, MatchesRect( expected_sc, "sourceCrop")); | ||
993 | 102 | EXPECT_THAT(target_layer.displayFrame, MatchesRect( expected_df, "displayFrame")); | ||
994 | 103 | |||
995 | 104 | ASSERT_EQ(1u, target_layer.visibleRegionScreen.numRects); | ||
996 | 105 | ASSERT_NE(nullptr, target_layer.visibleRegionScreen.rects); | ||
997 | 106 | EXPECT_THAT(target_layer.visibleRegionScreen.rects[0], MatchesRect( expected_visible, "visible")); | ||
998 | 107 | } | ||
999 | 108 | |||
1000 | 109 | TEST_F(HWCLayerListTest, fb_target) | ||
1001 | 110 | { | ||
1002 | 111 | using namespace testing; | ||
1003 | 112 | |||
1004 | 113 | mga::LayerList layerlist; | ||
1005 | 114 | |||
1006 | 115 | auto list = layerlist.native_list(); | ||
1007 | 116 | ASSERT_EQ(1u, list->numHwLayers); | ||
1008 | 117 | hwc_layer_1 target_layer = list->hwLayers[0]; | ||
1009 | 118 | EXPECT_EQ(nullptr, target_layer.handle); | ||
1010 | 119 | } | ||
1011 | 120 | |||
1012 | 121 | TEST_F(HWCLayerListTest, set_fb_target_gets_fb_handle) | ||
1013 | 122 | { | ||
1014 | 123 | using namespace testing; | ||
1015 | 124 | |||
1016 | 125 | mga::LayerList layerlist; | ||
1017 | 126 | |||
1018 | 127 | EXPECT_CALL(*mock_buffer, native_buffer_handle()) | ||
1019 | 128 | .Times(1) | ||
1020 | 129 | .WillOnce(Return(native_handle_1)); | ||
1021 | 130 | |||
1022 | 131 | layerlist.set_fb_target(mock_buffer); | ||
1023 | 132 | auto list = layerlist.native_list(); | ||
1024 | 133 | ASSERT_EQ(1u, list->numHwLayers); | ||
1025 | 134 | hwc_layer_1 target_layer = list->hwLayers[0]; | ||
1026 | 135 | EXPECT_EQ(native_handle_1->handle(), target_layer.handle); | ||
1027 | 136 | } | ||
1028 | 137 | |||
1029 | 138 | TEST_F(HWCLayerListTest, set_fb_target_2x) | ||
1030 | 139 | { | ||
1031 | 140 | using namespace testing; | ||
1032 | 141 | |||
1033 | 142 | mga::LayerList layerlist; | ||
1034 | 143 | |||
1035 | 144 | EXPECT_CALL(*mock_buffer, native_buffer_handle()) | ||
1036 | 145 | .Times(2) | ||
1037 | 146 | .WillOnce(Return(native_handle_1)) | ||
1038 | 147 | .WillOnce(Return(native_handle_2)); | ||
1039 | 148 | |||
1040 | 149 | layerlist.set_fb_target(mock_buffer); | ||
1041 | 150 | auto list = layerlist.native_list(); | ||
1042 | 151 | ASSERT_EQ(1u, list->numHwLayers); | ||
1043 | 152 | hwc_layer_1 target_layer = list->hwLayers[0]; | ||
1044 | 153 | EXPECT_EQ(native_handle_1->handle(), target_layer.handle); | ||
1045 | 154 | |||
1046 | 155 | layerlist.set_fb_target(mock_buffer); | ||
1047 | 156 | auto list_second = layerlist.native_list(); | ||
1048 | 157 | ASSERT_EQ(1u, list_second->numHwLayers); | ||
1049 | 158 | target_layer = list_second->hwLayers[0]; | ||
1050 | 159 | EXPECT_EQ(native_handle_2->handle(), target_layer.handle); | ||
1051 | 160 | } | ||
1052 | 161 | |||
1053 | 162 | TEST_F(HWCLayerListTest, set_fb_target_programs_other_struct_members_correctly) | ||
1054 | 163 | { | ||
1055 | 164 | using namespace testing; | ||
1056 | 165 | |||
1057 | 166 | mga::LayerList layerlist; | ||
1058 | 167 | layerlist.set_fb_target(mock_buffer); | ||
1059 | 168 | |||
1060 | 169 | hwc_rect_t source_region = {0,0,width, height}; | ||
1061 | 170 | hwc_rect_t target_region = source_region; | ||
1062 | 171 | hwc_region_t region {1, nullptr}; | ||
1063 | 172 | |||
1070 | 173 | hwc_layer_1 expected_layer; | 57 | hwc_layer_1 expected_layer; |
1071 | 174 | expected_layer.compositionType = HWC_FRAMEBUFFER_TARGET; | 58 | expected_layer.compositionType = HWC_FRAMEBUFFER_TARGET; |
1072 | 175 | expected_layer.hints = 0; | 59 | expected_layer.hints = 0; |
1073 | @@ -177,14 +61,91 @@ | |||
1074 | 177 | expected_layer.handle = native_handle_1->handle(); | 61 | expected_layer.handle = native_handle_1->handle(); |
1075 | 178 | expected_layer.transform = 0; | 62 | expected_layer.transform = 0; |
1076 | 179 | expected_layer.blending = HWC_BLENDING_NONE; | 63 | expected_layer.blending = HWC_BLENDING_NONE; |
1087 | 180 | expected_layer.sourceCrop = source_region; | 64 | expected_layer.sourceCrop = region; |
1088 | 181 | expected_layer.displayFrame = target_region; | 65 | expected_layer.displayFrame = region; |
1089 | 182 | expected_layer.visibleRegionScreen = region; | 66 | expected_layer.visibleRegionScreen = visible_region; |
1090 | 183 | expected_layer.acquireFenceFd = -1; | 67 | expected_layer.acquireFenceFd = -1; |
1091 | 184 | expected_layer.releaseFenceFd = -1; | 68 | expected_layer.releaseFenceFd = -1; |
1092 | 185 | 69 | ||
1093 | 186 | auto list = layerlist.native_list(); | 70 | EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); |
1094 | 187 | ASSERT_EQ(1u, list->numHwLayers); | 71 | } |
1095 | 188 | hwc_layer_1 target_layer = list->hwLayers[0]; | 72 | |
1096 | 189 | EXPECT_THAT(target_layer, MatchesLayer( expected_layer )); | 73 | TEST_F(HWCLayerListTest, gl_target_layer_with_force_gl) |
1097 | 74 | { | ||
1098 | 75 | mga::CompositionLayer target_layer(*native_handle_1, HWC_SKIP_LAYER); | ||
1099 | 76 | |||
1100 | 77 | hwc_rect_t region = {0,0,width, height}; | ||
1101 | 78 | hwc_region_t visible_region {1, ®ion}; | ||
1102 | 79 | hwc_layer_1 expected_layer; | ||
1103 | 80 | expected_layer.compositionType = HWC_FRAMEBUFFER; | ||
1104 | 81 | expected_layer.hints = 0; | ||
1105 | 82 | expected_layer.flags = HWC_SKIP_LAYER; | ||
1106 | 83 | expected_layer.handle = native_handle_1->handle(); | ||
1107 | 84 | expected_layer.transform = 0; | ||
1108 | 85 | expected_layer.blending = HWC_BLENDING_NONE; | ||
1109 | 86 | expected_layer.sourceCrop = region; | ||
1110 | 87 | expected_layer.displayFrame = region; | ||
1111 | 88 | expected_layer.visibleRegionScreen = visible_region; | ||
1112 | 89 | expected_layer.acquireFenceFd = -1; | ||
1113 | 90 | expected_layer.releaseFenceFd = -1; | ||
1114 | 91 | |||
1115 | 92 | EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); | ||
1116 | 93 | } | ||
1117 | 94 | |||
1118 | 95 | TEST_F(HWCLayerListTest, gl_target_layer_without_skip) | ||
1119 | 96 | { | ||
1120 | 97 | mga::CompositionLayer target_layer(*native_handle_1, 0); | ||
1121 | 98 | |||
1122 | 99 | hwc_rect_t region = {0,0,width, height}; | ||
1123 | 100 | hwc_region_t visible_region {1, ®ion}; | ||
1124 | 101 | hwc_layer_1 expected_layer; | ||
1125 | 102 | expected_layer.compositionType = HWC_FRAMEBUFFER; | ||
1126 | 103 | expected_layer.hints = 0; | ||
1127 | 104 | expected_layer.flags = 0; | ||
1128 | 105 | expected_layer.handle = native_handle_1->handle(); | ||
1129 | 106 | expected_layer.transform = 0; | ||
1130 | 107 | expected_layer.blending = HWC_BLENDING_NONE; | ||
1131 | 108 | expected_layer.sourceCrop = region; | ||
1132 | 109 | expected_layer.displayFrame = region; | ||
1133 | 110 | expected_layer.visibleRegionScreen = visible_region; | ||
1134 | 111 | expected_layer.acquireFenceFd = -1; | ||
1135 | 112 | expected_layer.releaseFenceFd = -1; | ||
1136 | 113 | |||
1137 | 114 | EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); | ||
1138 | 115 | } | ||
1139 | 116 | |||
1140 | 117 | TEST_F(HWCLayerListTest, hwc_list_creation) | ||
1141 | 118 | { | ||
1142 | 119 | using namespace testing; | ||
1143 | 120 | |||
1144 | 121 | mga::CompositionLayer surface_layer(*native_handle_1, 0); | ||
1145 | 122 | mga::FramebufferLayer target_layer(*native_handle_1); | ||
1146 | 123 | mga::LayerList layerlist({ | ||
1147 | 124 | surface_layer, | ||
1148 | 125 | target_layer}); | ||
1149 | 126 | |||
1150 | 127 | auto list = layerlist.native_list(); | ||
1151 | 128 | EXPECT_EQ(-1, list->retireFenceFd); | ||
1152 | 129 | EXPECT_EQ(HWC_GEOMETRY_CHANGED, list->flags); | ||
1153 | 130 | /* note, mali hwc1.1 actually falsely returns if these are not set to something. set to garbage */ | ||
1154 | 131 | EXPECT_NE(nullptr, list->dpy); | ||
1155 | 132 | EXPECT_NE(nullptr, list->sur); | ||
1156 | 133 | |||
1157 | 134 | ASSERT_EQ(2u, list->numHwLayers); | ||
1158 | 135 | EXPECT_THAT(surface_layer, MatchesLayer(list->hwLayers[0])); | ||
1159 | 136 | EXPECT_THAT(target_layer, MatchesLayer(list->hwLayers[1])); | ||
1160 | 137 | } | ||
1161 | 138 | |||
1162 | 139 | TEST_F(HWCLayerListTest, hwc_list_update) | ||
1163 | 140 | { | ||
1164 | 141 | using namespace testing; | ||
1165 | 142 | mga::LayerList layerlist({ | ||
1166 | 143 | mga::CompositionLayer(*native_handle_1, 0), | ||
1167 | 144 | mga::FramebufferLayer(*native_handle_1)}); | ||
1168 | 145 | layerlist.set_fb_target(native_handle_2); | ||
1169 | 146 | |||
1170 | 147 | auto list = layerlist.native_list(); | ||
1171 | 148 | ASSERT_EQ(2u, list->numHwLayers); | ||
1172 | 149 | EXPECT_EQ(list->hwLayers[0].handle, native_handle_1->handle()); | ||
1173 | 150 | EXPECT_EQ(list->hwLayers[1].handle, native_handle_2->handle()); | ||
1174 | 190 | } | 151 | } |
PASSED: Continuous integration, rev:1219 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/364/ jenkins. qa.ubuntu. com/job/ mir-android- trusty- i386-build/ 168 jenkins. qa.ubuntu. com/job/ mir-clang- trusty- amd64-build/ 165 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 93 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 93/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 93 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 93/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/mir- team-mir- development- branch- ci/364/ rebuild
http://