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 | |
6 | #include <hardware/hwcomposer.h> |
7 | #include <gmock/gmock.h> |
8 | +#include <vector> |
9 | +#include <memory> |
10 | |
11 | namespace mir |
12 | { |
13 | @@ -59,10 +61,9 @@ |
14 | |
15 | hwc_display_contents_1_t* primary_display = *in; |
16 | memcpy(out, primary_display, sizeof(hwc_display_contents_1_t)); |
17 | - |
18 | return 0; |
19 | + } |
20 | |
21 | - } |
22 | int save_last_prepare_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) |
23 | { |
24 | return save_args(&display0_prepare_content, displays); |
25 | @@ -70,6 +71,12 @@ |
26 | |
27 | int save_last_set_arguments(struct hwc_composer_device_1 *, size_t, hwc_display_contents_1_t** displays) |
28 | { |
29 | + hwc_display_contents_1_t* display = *displays; |
30 | + for(auto i = 0u; i < display->numHwLayers; i++) |
31 | + { |
32 | + set_layerlist.push_back(display->hwLayers[i]); |
33 | + set_layerlist.back().visibleRegionScreen = {0, nullptr}; |
34 | + } |
35 | return save_args(&display0_set_content, displays); |
36 | } |
37 | |
38 | @@ -120,6 +127,7 @@ |
39 | MOCK_METHOD5(getDisplayAttributes_interface, int(struct hwc_composer_device_1*, int, uint32_t, const uint32_t*, int32_t*)); |
40 | |
41 | hwc_display_contents_1_t display0_set_content; |
42 | + std::vector<hwc_layer_1> set_layerlist; |
43 | hwc_display_contents_1_t display0_prepare_content; |
44 | }; |
45 | |
46 | |
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 | std::shared_ptr<DisplayDevice> const& fbdev, |
52 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) |
53 | : HWCCommonDevice(hwc_device, coordinator), |
54 | + layer_list({mga::CompositionLayer{HWC_SKIP_LAYER}}), |
55 | fb_device(fbdev), |
56 | wait_for_vsync(true) |
57 | { |
58 | @@ -63,20 +64,17 @@ |
59 | { |
60 | auto lg = lock_unblanked(); |
61 | |
62 | - hwc_display_contents_1 display_contents; |
63 | - display_contents.dpy = dpy; |
64 | - display_contents.sur = sur; |
65 | - display_contents.retireFenceFd = -1; |
66 | - display_contents.flags = 0; |
67 | - display_contents.numHwLayers = 0; |
68 | - hwc_display_contents_1* contents = &display_contents; |
69 | + auto display_list = layer_list.native_list(); |
70 | + display_list->dpy = dpy; |
71 | + display_list->sur = sur; |
72 | |
73 | - auto rc = hwc_device->prepare(hwc_device.get(), 1, &contents); |
74 | + auto rc = hwc_device->prepare(hwc_device.get(), 1, &display_list); |
75 | if (rc != 0) |
76 | { |
77 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()")); |
78 | } |
79 | - rc = hwc_device->set(hwc_device.get(), 1, &contents); |
80 | + |
81 | + rc = hwc_device->set(hwc_device.get(), 1, &display_list); |
82 | if (rc != 0) |
83 | { |
84 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); |
85 | |
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 | #ifndef MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ |
91 | #define MIR_GRAPHICS_ANDROID_HWC10_DEVICE_H_ |
92 | #include "hwc_common_device.h" |
93 | +#include "hwc_layerlist.h" |
94 | |
95 | namespace mir |
96 | { |
97 | @@ -44,6 +45,8 @@ |
98 | void commit_frame(EGLDisplay dpy, EGLSurface sur); |
99 | |
100 | private: |
101 | + LayerList layer_list; |
102 | + |
103 | std::shared_ptr<DisplayDevice> const fb_device; |
104 | bool wait_for_vsync; |
105 | }; |
106 | |
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 | #include "hwc_vsync_coordinator.h" |
112 | #include "android_format_conversion-inl.h" |
113 | #include "mir/graphics/android/sync_fence.h" |
114 | +#include "mir/graphics/android/native_buffer.h" |
115 | +#include "mir/graphics/buffer.h" |
116 | |
117 | #include <EGL/eglext.h> |
118 | #include <boost/throw_exception.hpp> |
119 | @@ -70,12 +72,9 @@ |
120 | } |
121 | |
122 | mga::HWC11Device::HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
123 | - std::shared_ptr<HWCLayerList> const& layer_list, |
124 | - std::shared_ptr<DisplayDevice> const& fbdev, |
125 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator) |
126 | : HWCCommonDevice(hwc_device, coordinator), |
127 | - layer_list(layer_list), |
128 | - fb_device(fbdev), |
129 | + layer_list({mga::FramebufferLayer{}}), |
130 | sync_ops(std::make_shared<mga::RealSyncFileOps>()), |
131 | fb_format(determine_fb_format()) |
132 | { |
133 | @@ -118,16 +117,19 @@ |
134 | |
135 | void mga::HWC11Device::set_next_frontbuffer(std::shared_ptr<mg::Buffer> const& buffer) |
136 | { |
137 | - layer_list->set_fb_target(buffer); |
138 | + layer_list.set_fb_target(buffer->native_buffer_handle()); |
139 | + //TODO: wait for framebuffer render to complete here. Eventually, we want to pass the fence right |
140 | + // into hwc_device->set() and let that wait for the render to complete. |
141 | + buffer->native_buffer_handle()->wait_for_content(); |
142 | } |
143 | |
144 | void mga::HWC11Device::commit_frame(EGLDisplay dpy, EGLSurface sur) |
145 | { |
146 | auto lg = lock_unblanked(); |
147 | - |
148 | + |
149 | //note, although we only have a primary display right now, |
150 | // set the second display to nullptr, as exynos hwc always derefs displays[1] |
151 | - hwc_display_contents_1_t* displays[HWC_NUM_DISPLAY_TYPES] {layer_list->native_list(), nullptr}; |
152 | + hwc_display_contents_1_t* displays[HWC_NUM_DISPLAY_TYPES] {layer_list.native_list(), nullptr}; |
153 | |
154 | if (hwc_device->prepare(hwc_device.get(), 1, displays)) |
155 | { |
156 | @@ -135,7 +137,7 @@ |
157 | } |
158 | |
159 | /* note, swapbuffers will go around through the driver and call |
160 | - set_next_frontbuffer, updating the fb target before committing */ |
161 | + set_next_frontbuffer, updating the fb in layerlist before committing */ |
162 | if (eglSwapBuffers(dpy, sur) == EGL_FALSE) |
163 | { |
164 | BOOST_THROW_EXCEPTION(std::runtime_error("error during eglSwapBuffers")); |
165 | @@ -145,7 +147,6 @@ |
166 | { |
167 | BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()")); |
168 | } |
169 | - |
170 | mga::SyncFence fence(sync_ops, displays[HWC_DISPLAY_PRIMARY]->retireFenceFd); |
171 | fence.wait(); |
172 | } |
173 | |
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 | #ifndef MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ |
179 | #define MIR_GRAPHICS_ANDROID_HWC11_DEVICE_H_ |
180 | #include "hwc_common_device.h" |
181 | +#include "hwc_layerlist.h" |
182 | #include <memory> |
183 | |
184 | namespace mir |
185 | @@ -29,7 +30,6 @@ |
186 | |
187 | namespace android |
188 | { |
189 | -class HWCLayerList; |
190 | class HWCVsyncCoordinator; |
191 | class SyncFileOps; |
192 | |
193 | @@ -37,8 +37,6 @@ |
194 | { |
195 | public: |
196 | HWC11Device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
197 | - std::shared_ptr<HWCLayerList> const& layer_list, |
198 | - std::shared_ptr<DisplayDevice> const& fbdev, |
199 | std::shared_ptr<HWCVsyncCoordinator> const& coordinator); |
200 | ~HWC11Device() noexcept; |
201 | |
202 | @@ -51,8 +49,8 @@ |
203 | void commit_frame(EGLDisplay dpy, EGLSurface sur); |
204 | |
205 | private: |
206 | - std::shared_ptr<HWCLayerList> const layer_list; |
207 | - std::shared_ptr<DisplayDevice> const fb_device; |
208 | + LayerList layer_list; |
209 | + |
210 | std::shared_ptr<SyncFileOps> const sync_ops; |
211 | unsigned int primary_display_config; |
212 | geometry::PixelFormat fb_format; |
213 | |
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 | #include "mir/graphics/android/sync_fence.h" |
219 | #include "mir/graphics/android/native_buffer.h" |
220 | #include "hwc_layerlist.h" |
221 | -#include "buffer.h" |
222 | |
223 | #include <cstring> |
224 | |
225 | @@ -27,112 +26,92 @@ |
226 | namespace mga=mir::graphics::android; |
227 | namespace geom=mir::geometry; |
228 | |
229 | -mga::HWCRect::HWCRect() |
230 | - : self{0,0,0,0} |
231 | -{ |
232 | -} |
233 | - |
234 | -mga::HWCRect::HWCRect(geom::Rectangle& rect) |
235 | -{ |
236 | - self.top = rect.top_left.y.as_uint32_t(); |
237 | - self.left = rect.top_left.x.as_uint32_t(); |
238 | - self.bottom= rect.size.height.as_uint32_t(); |
239 | - self.right = rect.size.width.as_uint32_t(); |
240 | -} |
241 | - |
242 | -mga::HWCDefaultLayer::HWCDefaultLayer(std::initializer_list<mga::HWCRect> list) |
243 | -{ |
244 | - /* default values.*/ |
245 | - self.compositionType = HWC_FRAMEBUFFER_TARGET; |
246 | - self.hints = 0; |
247 | - self.flags = 0; |
248 | - self.transform = 0; |
249 | - self.blending = HWC_BLENDING_NONE; |
250 | - self.acquireFenceFd = -1; |
251 | - self.releaseFenceFd = -1; |
252 | - |
253 | - HWCRect emptyrect; |
254 | - self.sourceCrop = emptyrect; |
255 | - self.displayFrame = emptyrect; |
256 | - self.visibleRegionScreen.numRects=list.size(); |
257 | - self.visibleRegionScreen.rects=nullptr; |
258 | - if (list.size() != 0) |
259 | - { |
260 | - auto rect_array = new hwc_rect_t[list.size()]; |
261 | - auto i = 0u; |
262 | - for( auto& rect : list ) |
263 | - { |
264 | - rect_array[i++] = rect; |
265 | - } |
266 | - self.visibleRegionScreen.rects = rect_array; |
267 | - } |
268 | -} |
269 | - |
270 | -mga::HWCDefaultLayer::~HWCDefaultLayer() |
271 | -{ |
272 | - if (self.visibleRegionScreen.rects) |
273 | - { |
274 | - delete[] self.visibleRegionScreen.rects; |
275 | - } |
276 | -} |
277 | - |
278 | -mga::HWCFBLayer::HWCFBLayer( |
279 | - buffer_handle_t native_handle, |
280 | - HWCRect display_frame_rect) |
281 | - : HWCDefaultLayer{display_frame_rect} |
282 | -{ |
283 | - self.compositionType = HWC_FRAMEBUFFER_TARGET; |
284 | - |
285 | - self.handle = native_handle; |
286 | - self.sourceCrop = display_frame_rect; |
287 | - self.displayFrame = display_frame_rect; |
288 | -} |
289 | - |
290 | -mga::HWCFBLayer::HWCFBLayer() |
291 | - : HWCFBLayer{nullptr, mga::HWCRect{}} |
292 | -{ |
293 | -} |
294 | - |
295 | -mga::LayerList::LayerList() |
296 | - : layer_list{std::make_shared<HWCFBLayer>()}, |
297 | - hwc_representation{std::make_shared<hwc_display_contents_1_t>()} |
298 | -{ |
299 | - memset(hwc_representation.get(), 0, sizeof(hwc_display_contents_1_t)); |
300 | - update_list(); |
301 | -} |
302 | - |
303 | -void mga::LayerList::set_fb_target(std::shared_ptr<mg::Buffer> const& buffer) |
304 | -{ |
305 | - auto native_buffer = buffer->native_buffer_handle(); |
306 | - native_buffer->wait_for_content(); |
307 | - |
308 | - geom::Point pt{0, 0}; |
309 | - geom::Rectangle rect{pt, buffer->size()}; |
310 | - HWCRect display_rect(rect); |
311 | - |
312 | - auto fb_layer = std::make_shared<HWCFBLayer>(native_buffer->handle(), display_rect); |
313 | - layer_list[fb_position] = fb_layer; |
314 | - |
315 | - update_list(); |
316 | -} |
317 | - |
318 | -void mga::LayerList::update_list() |
319 | -{ |
320 | - if (layer_list.size() != hwc_representation->numHwLayers) |
321 | - { |
322 | - auto struct_size = sizeof(hwc_display_contents_1_t) + sizeof(hwc_layer_1_t)*(layer_list.size()); |
323 | - hwc_representation = std::shared_ptr<hwc_display_contents_1_t>( |
324 | - static_cast<hwc_display_contents_1_t*>( ::operator new(struct_size))); |
325 | - |
326 | - hwc_representation->numHwLayers = layer_list.size(); |
327 | - } |
328 | +mga::HWCLayer& mga::HWCLayer::operator=(HWCLayer const& layer) |
329 | +{ |
330 | + memcpy(this, &layer, sizeof(HWCLayer)); |
331 | + this->visibleRegionScreen = {1, &this->visible_rect}; |
332 | + return *this; |
333 | +} |
334 | + |
335 | +mga::HWCLayer::HWCLayer(HWCLayer const& layer) |
336 | +{ |
337 | + memcpy(this, &layer, sizeof(HWCLayer)); |
338 | + this->visibleRegionScreen = {1, &this->visible_rect}; |
339 | +} |
340 | + |
341 | +mga::HWCLayer::HWCLayer(int type, buffer_handle_t buffer_handle, int width, int height, int layer_flags) |
342 | +{ |
343 | + compositionType = type; |
344 | + hints = 0; |
345 | + flags = layer_flags; |
346 | + transform = 0; |
347 | + blending = HWC_BLENDING_NONE; |
348 | + //TODO: acquireFenceFd should be buffer.fence() |
349 | + acquireFenceFd = -1; |
350 | + releaseFenceFd = -1; |
351 | + |
352 | + visible_rect.top = 0; |
353 | + visible_rect.left = 0; |
354 | + visible_rect.bottom = height; |
355 | + visible_rect.right = width; |
356 | + sourceCrop = visible_rect; |
357 | + displayFrame = visible_rect; |
358 | + visibleRegionScreen.numRects=1; |
359 | + visibleRegionScreen.rects= &visible_rect; |
360 | + handle = buffer_handle; |
361 | +} |
362 | + |
363 | +mga::FramebufferLayer::FramebufferLayer() |
364 | + : HWCLayer(HWC_FRAMEBUFFER_TARGET, nullptr, 0, 0, 0) |
365 | +{ |
366 | +} |
367 | + |
368 | +mga::FramebufferLayer::FramebufferLayer(mg::NativeBuffer const& buffer) |
369 | + : HWCLayer(HWC_FRAMEBUFFER_TARGET, buffer.handle(), |
370 | + buffer.anwb()->width, buffer.anwb()->height, 0) |
371 | +{ |
372 | +} |
373 | + |
374 | +mga::CompositionLayer::CompositionLayer(int layer_flags) |
375 | + : HWCLayer(HWC_FRAMEBUFFER, nullptr, 0, 0, layer_flags) |
376 | +{ |
377 | +} |
378 | + |
379 | +mga::CompositionLayer::CompositionLayer(mg::NativeBuffer const& buffer, int layer_flags) |
380 | + : HWCLayer(HWC_FRAMEBUFFER, buffer.handle(), |
381 | + buffer.anwb()->width, buffer.anwb()->height, layer_flags) |
382 | +{ |
383 | +} |
384 | + |
385 | +mga::LayerList::LayerList(std::initializer_list<HWCLayer> const& layer_list) |
386 | +{ |
387 | + auto struct_size = sizeof(hwc_display_contents_1_t) + sizeof(hwc_layer_1_t)*(layer_list.size()); |
388 | + hwc_representation = std::shared_ptr<hwc_display_contents_1_t>( |
389 | + static_cast<hwc_display_contents_1_t*>( ::operator new(struct_size))); |
390 | |
391 | auto i = 0u; |
392 | - for( auto& layer : layer_list) |
393 | + for(auto& layer : layer_list) |
394 | { |
395 | - hwc_representation->hwLayers[i++] = *layer; |
396 | + hwc_representation->hwLayers[i++] = layer; |
397 | } |
398 | + hwc_representation->numHwLayers = layer_list.size(); |
399 | hwc_representation->retireFenceFd = -1; |
400 | + hwc_representation->flags = HWC_GEOMETRY_CHANGED; |
401 | + |
402 | + //aosp exynos hwc in particular, checks that these fields are non-null in hwc1.1, although |
403 | + //these fields are deprecated in hwc1.1 and later. |
404 | + hwc_representation->dpy = reinterpret_cast<void*>(0xDECAF); |
405 | + hwc_representation->sur = reinterpret_cast<void*>(0xC0FFEE); |
406 | + |
407 | +} |
408 | + |
409 | +void mga::LayerList::set_fb_target(std::shared_ptr<NativeBuffer> const& native_buffer) |
410 | +{ |
411 | + auto fb_position = hwc_representation->numHwLayers - 1; |
412 | + if (hwc_representation->hwLayers[fb_position].compositionType == HWC_FRAMEBUFFER_TARGET) |
413 | + { |
414 | + hwc_representation->hwLayers[fb_position] = mga::FramebufferLayer(*native_buffer); |
415 | + } |
416 | } |
417 | |
418 | hwc_display_contents_1_t* mga::LayerList::native_list() const |
419 | |
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 | #include <memory> |
425 | #include <vector> |
426 | #include <initializer_list> |
427 | + |
428 | namespace mir |
429 | { |
430 | namespace graphics |
431 | { |
432 | + |
433 | +class NativeBuffer; |
434 | class Buffer; |
435 | |
436 | namespace android |
437 | { |
438 | - |
439 | -struct HWCRect |
440 | -{ |
441 | - HWCRect(); |
442 | - HWCRect(geometry::Rectangle& rect); |
443 | - |
444 | - operator hwc_rect_t const& () const { return self; } |
445 | - operator hwc_rect_t& () { return self; } |
446 | -private: |
447 | - hwc_rect_t self; |
448 | -}; |
449 | - |
450 | -struct HWCDefaultLayer |
451 | -{ |
452 | - HWCDefaultLayer(std::initializer_list<HWCRect> list); |
453 | - ~HWCDefaultLayer(); |
454 | - |
455 | - operator hwc_layer_1 const& () const { return self; } |
456 | - operator hwc_layer_1& () { return self; } |
457 | - |
458 | -protected: |
459 | - HWCDefaultLayer& operator=(HWCDefaultLayer const&) = delete; |
460 | - HWCDefaultLayer(HWCDefaultLayer const&) = delete; |
461 | - |
462 | - hwc_layer_1 self; |
463 | -}; |
464 | - |
465 | -struct HWCFBLayer : public HWCDefaultLayer |
466 | -{ |
467 | - HWCFBLayer(); |
468 | - HWCFBLayer(buffer_handle_t native_buf, |
469 | - HWCRect display_frame_rect); |
470 | -}; |
471 | - |
472 | -class HWCLayerList |
473 | -{ |
474 | -public: |
475 | - virtual ~HWCLayerList() = default; |
476 | - |
477 | - virtual hwc_display_contents_1_t* native_list() const = 0; |
478 | - virtual void set_fb_target(std::shared_ptr<Buffer> const&) = 0; |
479 | - |
480 | -protected: |
481 | - HWCLayerList() = default; |
482 | - HWCLayerList& operator=(HWCLayerList const&) = delete; |
483 | - HWCLayerList(HWCLayerList const&) = delete; |
484 | - |
485 | -}; |
486 | - |
487 | -class LayerList : public HWCLayerList |
488 | -{ |
489 | -public: |
490 | - LayerList(); |
491 | - |
492 | - void set_fb_target(std::shared_ptr<Buffer> const&); |
493 | + |
494 | +struct HWCLayer : public hwc_layer_1 |
495 | +{ |
496 | + virtual ~HWCLayer() = default; |
497 | + |
498 | + HWCLayer& operator=(HWCLayer const& layer); |
499 | + HWCLayer(HWCLayer const& layer); |
500 | + |
501 | +protected: |
502 | + HWCLayer(int type, buffer_handle_t handle, int width, int height, int layer_flags); |
503 | + |
504 | + hwc_rect_t visible_rect; |
505 | +}; |
506 | + |
507 | +struct CompositionLayer : public HWCLayer |
508 | +{ |
509 | + CompositionLayer(int layer_flags); |
510 | + CompositionLayer(NativeBuffer const&, int layer_flags); |
511 | +}; |
512 | + |
513 | +struct FramebufferLayer : public HWCLayer |
514 | +{ |
515 | + FramebufferLayer(); |
516 | + FramebufferLayer(NativeBuffer const&); |
517 | +}; |
518 | + |
519 | +class LayerList |
520 | +{ |
521 | +public: |
522 | + LayerList(std::initializer_list<HWCLayer> const& layers); |
523 | + |
524 | hwc_display_contents_1_t* native_list() const; |
525 | + void set_fb_target(std::shared_ptr<NativeBuffer> const&); |
526 | |
527 | private: |
528 | - std::vector<std::shared_ptr<HWCDefaultLayer>> layer_list; |
529 | - void update_list(); |
530 | - |
531 | - static size_t const fb_position = 0u; |
532 | std::shared_ptr<hwc_display_contents_1_t> hwc_representation; |
533 | }; |
534 | |
535 | |
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 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc11_device( |
541 | std::shared_ptr<hwc_composer_device_1> const& hwc_native_device) const |
542 | { |
543 | - auto layer_list = std::make_shared<mga::LayerList>(); |
544 | auto syncer = std::make_shared<mga::HWCVsync>(); |
545 | - return std::make_shared<mga::HWC11Device>(hwc_native_device, layer_list, nullptr, syncer); |
546 | + return std::make_shared<mga::HWC11Device>(hwc_native_device, syncer); |
547 | } |
548 | |
549 | std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc10_device( |
550 | |
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 | EXPECT_EQ(dpy, mock_device->display0_set_content.dpy); |
556 | EXPECT_EQ(sur, mock_device->display0_set_content.sur); |
557 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
558 | - EXPECT_EQ(0u, mock_device->display0_set_content.flags); |
559 | - EXPECT_EQ(0u, mock_device->display0_set_content.numHwLayers); |
560 | - |
561 | - EXPECT_EQ(dpy, mock_device->display0_prepare_content.dpy); |
562 | - EXPECT_EQ(sur, mock_device->display0_prepare_content.sur); |
563 | - EXPECT_EQ(-1, mock_device->display0_prepare_content.retireFenceFd); |
564 | - EXPECT_EQ(0u, mock_device->display0_prepare_content.flags); |
565 | - EXPECT_EQ(0u, mock_device->display0_prepare_content.numHwLayers); |
566 | + EXPECT_EQ(HWC_GEOMETRY_CHANGED, mock_device->display0_set_content.flags); |
567 | + EXPECT_EQ(1u, mock_device->display0_set_content.numHwLayers); |
568 | + ASSERT_NE(nullptr, mock_device->display0_set_content.hwLayers); |
569 | + EXPECT_EQ(HWC_FRAMEBUFFER, mock_device->set_layerlist[0].compositionType); |
570 | + EXPECT_EQ(HWC_SKIP_LAYER, mock_device->set_layerlist[0].flags); |
571 | } |
572 | |
573 | TEST_F(HWC10Device, hwc10_commit_frame_async) |
574 | |
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 | |
580 | #include "src/server/graphics/android/hwc11_device.h" |
581 | #include "src/server/graphics/android/hwc_layerlist.h" |
582 | -#include "mir_test_doubles/mock_display_device.h" |
583 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" |
584 | -#include "mir_test_doubles/mock_hwc_layerlist.h" |
585 | #include "mir_test_doubles/mock_buffer.h" |
586 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" |
587 | #include "mir_test_doubles/mock_egl.h" |
588 | @@ -38,49 +36,27 @@ |
589 | virtual void SetUp() |
590 | { |
591 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); |
592 | - mock_display_device = std::make_shared<testing::NiceMock<mtd::MockDisplayDevice>>(); |
593 | - mock_hwc_layers = std::make_shared<testing::NiceMock<mtd::MockHWCLayerList>>(); |
594 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); |
595 | - mock_egl.silence_uninteresting(); |
596 | - |
597 | - empty_list.numHwLayers = 0; |
598 | - empty_list.retireFenceFd = -1; |
599 | - ON_CALL(*mock_hwc_layers, native_list()) |
600 | - .WillByDefault(testing::Return(&empty_list)); |
601 | } |
602 | |
603 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; |
604 | - std::shared_ptr<mtd::MockHWCLayerList> mock_hwc_layers; |
605 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; |
606 | - std::shared_ptr<mtd::MockDisplayDevice> mock_display_device; |
607 | EGLDisplay dpy; |
608 | EGLSurface surf; |
609 | testing::NiceMock<mtd::MockEGL> mock_egl; |
610 | - hwc_display_contents_1_t empty_list; |
611 | -}; |
612 | - |
613 | -namespace |
614 | -{ |
615 | -struct HWCDummyLayer : public mga::HWCDefaultLayer |
616 | -{ |
617 | - HWCDummyLayer() |
618 | - : HWCDefaultLayer({}) |
619 | - { |
620 | - } |
621 | -}; |
622 | -} |
623 | +}; |
624 | |
625 | TEST_F(HWC11Device, test_hwc_gles_set_empty_layerlist) |
626 | { |
627 | using namespace testing; |
628 | |
629 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
630 | + mga::HWC11Device device(mock_device, mock_vsync); |
631 | |
632 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) |
633 | .Times(1); |
634 | device.commit_frame(dpy, surf); |
635 | |
636 | - EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_set_content.numHwLayers); |
637 | + EXPECT_EQ(1, mock_device->display0_set_content.numHwLayers); |
638 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
639 | } |
640 | |
641 | @@ -88,7 +64,7 @@ |
642 | { |
643 | using namespace testing; |
644 | |
645 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
646 | + mga::HWC11Device device(mock_device, mock_vsync); |
647 | |
648 | EXPECT_CALL(*mock_device, set_interface(mock_device.get(), 1, _)) |
649 | .Times(1) |
650 | @@ -106,7 +82,7 @@ |
651 | .Times(1) |
652 | .WillOnce(Return(EGL_FALSE)); |
653 | |
654 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
655 | + mga::HWC11Device device(mock_device, mock_vsync); |
656 | |
657 | EXPECT_THROW({ |
658 | device.commit_frame(dpy, surf); |
659 | @@ -117,13 +93,11 @@ |
660 | { |
661 | using namespace testing; |
662 | |
663 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
664 | + mga::HWC11Device device(mock_device, mock_vsync); |
665 | |
666 | //the order here is very important. eglSwapBuffers will alter the layerlist, |
667 | //so it must come before assembling the data for set |
668 | InSequence seq; |
669 | - EXPECT_CALL(*mock_hwc_layers, native_list()) |
670 | - .Times(1); |
671 | EXPECT_CALL(*mock_device, prepare_interface(mock_device.get(), 1, _)) |
672 | .Times(1); |
673 | EXPECT_CALL(mock_egl, eglSwapBuffers(dpy,surf)) |
674 | @@ -133,22 +107,12 @@ |
675 | |
676 | device.commit_frame(dpy, surf); |
677 | |
678 | - EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_prepare_content.numHwLayers); |
679 | + EXPECT_EQ(1, mock_device->display0_prepare_content.numHwLayers); |
680 | EXPECT_EQ(-1, mock_device->display0_prepare_content.retireFenceFd); |
681 | - EXPECT_EQ(empty_list.numHwLayers, mock_device->display0_set_content.numHwLayers); |
682 | + EXPECT_EQ(1, mock_device->display0_set_content.numHwLayers); |
683 | EXPECT_EQ(-1, mock_device->display0_set_content.retireFenceFd); |
684 | } |
685 | |
686 | -TEST_F(HWC11Device, hwc_device_set_next_frontbuffer_adds_to_layerlist) |
687 | -{ |
688 | - std::shared_ptr<mg::Buffer> mock_buffer = std::make_shared<mtd::MockBuffer>(); |
689 | - EXPECT_CALL(*this->mock_hwc_layers, set_fb_target(mock_buffer)) |
690 | - .Times(1); |
691 | - |
692 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
693 | - device.set_next_frontbuffer(mock_buffer); |
694 | -} |
695 | - |
696 | TEST_F(HWC11Device, test_hwc_device_display_config) |
697 | { |
698 | using namespace testing; |
699 | @@ -158,7 +122,7 @@ |
700 | .Times(1) |
701 | .WillOnce(DoAll(SetArgPointee<2>(hwc_configs), Return(0))); |
702 | |
703 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
704 | + mga::HWC11Device device(mock_device, mock_vsync); |
705 | } |
706 | |
707 | |
708 | @@ -172,7 +136,7 @@ |
709 | .WillOnce(Return(-1)); |
710 | |
711 | EXPECT_THROW({ |
712 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
713 | + mga::HWC11Device device(mock_device, mock_vsync); |
714 | }, std::runtime_error); |
715 | } |
716 | |
717 | @@ -206,7 +170,7 @@ |
718 | .Times(1) |
719 | .WillOnce(Invoke(display_attribute_handler)); |
720 | |
721 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
722 | + mga::HWC11Device device(mock_device, mock_vsync); |
723 | |
724 | auto size = device.display_size(); |
725 | EXPECT_EQ(size.width.as_uint32_t(), static_cast<unsigned int>(display_width)); |
726 | @@ -215,7 +179,7 @@ |
727 | |
728 | TEST_F(HWC11Device, hwc_device_reports_2_fbs_available_by_default) |
729 | { |
730 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
731 | + mga::HWC11Device device(mock_device, mock_vsync); |
732 | EXPECT_EQ(2u, device.number_of_framebuffers_available()); |
733 | } |
734 | |
735 | @@ -249,7 +213,7 @@ |
736 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) |
737 | .InSequence(seq); |
738 | |
739 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
740 | + mga::HWC11Device device(mock_device, mock_vsync); |
741 | EXPECT_EQ(geom::PixelFormat::argb_8888, device.display_format()); |
742 | } |
743 | |
744 | @@ -272,6 +236,6 @@ |
745 | EXPECT_CALL(mock_egl, eglTerminate(fake_display)) |
746 | .InSequence(seq); |
747 | |
748 | - mga::HWC11Device device(mock_device, mock_hwc_layers, mock_display_device, mock_vsync); |
749 | + mga::HWC11Device device(mock_device, mock_vsync); |
750 | EXPECT_EQ(geom::PixelFormat::abgr_8888, device.display_format()); |
751 | } |
752 | |
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 | #include "src/server/graphics/android/hwc_layerlist.h" |
758 | #include "src/server/graphics/android/hwc_vsync_coordinator.h" |
759 | #include "mir_test_doubles/mock_hwc_composer_device_1.h" |
760 | -#include "mir_test_doubles/mock_hwc_layerlist.h" |
761 | #include "mir_test_doubles/mock_hwc_vsync_coordinator.h" |
762 | #include "mir_test_doubles/mock_buffer.h" |
763 | #include "mir_test_doubles/mock_egl.h" |
764 | @@ -39,14 +38,12 @@ |
765 | |
766 | template<class T> |
767 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device(std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
768 | - std::shared_ptr<mga::HWCLayerList> const& layer_list, |
769 | std::shared_ptr<mga::DisplayDevice> const& fbdev, |
770 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator); |
771 | |
772 | template <> |
773 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC10Device>( |
774 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
775 | - std::shared_ptr<mga::HWCLayerList> const&, |
776 | std::shared_ptr<mga::DisplayDevice> const& fbdev, |
777 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) |
778 | { |
779 | @@ -56,23 +53,10 @@ |
780 | template <> |
781 | std::shared_ptr<mga::HWCCommonDevice> make_hwc_device<mga::HWC11Device>( |
782 | std::shared_ptr<hwc_composer_device_1> const& hwc_device, |
783 | - std::shared_ptr<mga::HWCLayerList> const& layer_list, |
784 | - std::shared_ptr<mga::DisplayDevice> const& fbdev, |
785 | + std::shared_ptr<mga::DisplayDevice> const&, |
786 | std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator) |
787 | { |
788 | - return std::make_shared<mga::HWC11Device>(hwc_device, layer_list, fbdev, coordinator); |
789 | -} |
790 | - |
791 | -namespace |
792 | -{ |
793 | -struct HWCDummyLayer : public mga::HWCDefaultLayer |
794 | -{ |
795 | - HWCDummyLayer() |
796 | - : HWCDefaultLayer({}) |
797 | - { |
798 | - } |
799 | -}; |
800 | - |
801 | + return std::make_shared<mga::HWC11Device>(hwc_device, coordinator); |
802 | } |
803 | |
804 | template<typename T> |
805 | @@ -84,14 +68,12 @@ |
806 | using namespace testing; |
807 | |
808 | mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCComposerDevice1>>(); |
809 | - mock_layer_list = std::make_shared<testing::NiceMock<mtd::MockHWCLayerList>>(); |
810 | mock_fbdev = std::make_shared<testing::NiceMock<mtd::MockDisplayDevice>>(); |
811 | mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>(); |
812 | } |
813 | |
814 | testing::NiceMock<mtd::MockEGL> mock_egl; |
815 | std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync; |
816 | - std::shared_ptr<mtd::MockHWCLayerList> mock_layer_list; |
817 | std::shared_ptr<mtd::MockHWCComposerDevice1> mock_device; |
818 | std::shared_ptr<mtd::MockDisplayDevice> mock_fbdev; |
819 | }; |
820 | @@ -108,8 +90,7 @@ |
821 | .Times(1) |
822 | .WillOnce(SaveArg<1>(&procs)); |
823 | |
824 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
825 | - this->mock_fbdev, this->mock_vsync); |
826 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
827 | |
828 | EXPECT_NE(nullptr, procs->invalidate); |
829 | EXPECT_NE(nullptr, procs->vsync); |
830 | @@ -127,8 +108,7 @@ |
831 | .Times(1) |
832 | .WillOnce(Return(0)); |
833 | |
834 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
835 | - this->mock_fbdev, this->mock_vsync); |
836 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
837 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); |
838 | } |
839 | |
840 | @@ -140,9 +120,9 @@ |
841 | .WillRepeatedly(Return(-EINVAL)); |
842 | |
843 | |
844 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
845 | - this->mock_fbdev, this->mock_vsync); |
846 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
847 | EXPECT_THROW({ |
848 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
849 | device->mode(mir_power_mode_off); |
850 | }, std::runtime_error); |
851 | } |
852 | @@ -156,8 +136,7 @@ |
853 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 0)) |
854 | .Times(1); |
855 | |
856 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
857 | - this->mock_fbdev, this->mock_vsync); |
858 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
859 | testing::Mock::VerifyAndClearExpectations(this->mock_device.get()); |
860 | } |
861 | |
862 | @@ -174,8 +153,7 @@ |
863 | .WillOnce(Return(-1)) |
864 | .WillOnce(Return(0)); |
865 | |
866 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
867 | - this->mock_fbdev, this->mock_vsync); |
868 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
869 | EXPECT_THROW({ |
870 | device->mode(mir_power_mode_off); |
871 | }, std::runtime_error); |
872 | @@ -192,8 +170,7 @@ |
873 | .Times(3) |
874 | .WillRepeatedly(Return(0)); |
875 | |
876 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
877 | - this->mock_fbdev, this->mock_vsync); |
878 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
879 | device->mode(mir_power_mode_off); |
880 | device->mode(mir_power_mode_on); |
881 | device->mode(mir_power_mode_suspend); |
882 | @@ -218,8 +195,7 @@ |
883 | .Times(1) |
884 | .WillOnce(Return(0)); |
885 | |
886 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
887 | - this->mock_fbdev, this->mock_vsync); |
888 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
889 | device->mode(mir_power_mode_off); |
890 | } |
891 | |
892 | @@ -239,15 +215,13 @@ |
893 | .Times(1) |
894 | .WillOnce(Return(0)); |
895 | |
896 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
897 | - this->mock_fbdev, this->mock_vsync); |
898 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
899 | device->mode(mir_power_mode_on); |
900 | } |
901 | |
902 | TYPED_TEST(HWCCommon, test_hwc_display_is_deactivated_on_destroy) |
903 | { |
904 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
905 | - this->mock_fbdev, this->mock_vsync); |
906 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
907 | |
908 | EXPECT_CALL(*this->mock_device, blank_interface(this->mock_device.get(), HWC_DISPLAY_PRIMARY, 1)) |
909 | .Times(1); |
910 | @@ -265,8 +239,7 @@ |
911 | .Times(1) |
912 | .WillOnce(SaveArg<1>(&procs)); |
913 | |
914 | - auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_layer_list, |
915 | - this->mock_fbdev, this->mock_vsync); |
916 | + auto device = make_hwc_device<TypeParam>(this->mock_device, this->mock_fbdev, this->mock_vsync); |
917 | |
918 | EXPECT_CALL(*this->mock_vsync, notify_vsync()) |
919 | .Times(1); |
920 | |
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 | |
926 | width = 432; |
927 | height = 876; |
928 | - default_size = geom::Size{width, height}; |
929 | - |
930 | native_handle_1 = std::make_shared<mtd::StubAndroidNativeBuffer>(); |
931 | + native_handle_1->anwb()->width = width; |
932 | + native_handle_1->anwb()->height = height; |
933 | native_handle_2 = std::make_shared<mtd::StubAndroidNativeBuffer>(); |
934 | - |
935 | - mock_buffer = std::make_shared<NiceMock<mtd::MockBuffer>>(); |
936 | - ON_CALL(*mock_buffer, native_buffer_handle()) |
937 | - .WillByDefault(Return(native_handle_1)); |
938 | - ON_CALL(*mock_buffer, size()) |
939 | - .WillByDefault(Return(default_size)); |
940 | } |
941 | |
942 | int width; |
943 | int height; |
944 | - geom::Size default_size; |
945 | - |
946 | std::shared_ptr<mg::NativeBuffer> native_handle_1; |
947 | std::shared_ptr<mg::NativeBuffer> native_handle_2; |
948 | - std::shared_ptr<mtd::MockBuffer> mock_buffer; |
949 | }; |
950 | |
951 | -TEST(HWCLayerDeepCopy, hwc_layer) |
952 | -{ |
953 | - mga::HWCDefaultLayer original({}); |
954 | - hwc_layer_1 layer = original; |
955 | - EXPECT_EQ(0u, layer.visibleRegionScreen.numRects); |
956 | - EXPECT_EQ(nullptr, layer.visibleRegionScreen.rects); |
957 | - |
958 | - geom::Rectangle r0{geom::Point{geom::X{0},geom::Y{1}}, |
959 | - geom::Size{2, 3}}; |
960 | - geom::Rectangle r1{geom::Point{geom::X{0},geom::Y{1}}, |
961 | - geom::Size{3, 3}}; |
962 | - geom::Rectangle r2{geom::Point{geom::X{1},geom::Y{1}}, |
963 | - geom::Size{2, 3}}; |
964 | - mga::HWCRect a(r0), b(r1), c(r2); |
965 | - mga::HWCDefaultLayer original2({a, b, c}); |
966 | - layer = original2; |
967 | - |
968 | - ASSERT_EQ(3u, layer.visibleRegionScreen.numRects); |
969 | - ASSERT_NE(nullptr, layer.visibleRegionScreen.rects); |
970 | - EXPECT_THAT(a, HWCRectMatchesRect(layer.visibleRegionScreen.rects[0],"")); |
971 | - EXPECT_THAT(b, HWCRectMatchesRect(layer.visibleRegionScreen.rects[1],"")); |
972 | - EXPECT_THAT(c, HWCRectMatchesRect(layer.visibleRegionScreen.rects[2],"")); |
973 | -} |
974 | - |
975 | -TEST_F(HWCLayerListTest, hwc_list_creation_loads_latest_fb_target) |
976 | -{ |
977 | - using namespace testing; |
978 | - |
979 | - hwc_rect_t expected_sc, expected_df, expected_visible; |
980 | - expected_sc = {0, 0, width, height}; |
981 | - expected_df = expected_visible = expected_sc; |
982 | - EXPECT_CALL(*mock_buffer, size()) |
983 | - .Times(1) |
984 | - .WillOnce(Return(default_size)); |
985 | - |
986 | - mga::LayerList layerlist; |
987 | - layerlist.set_fb_target(mock_buffer); |
988 | - |
989 | - auto list = layerlist.native_list(); |
990 | - ASSERT_EQ(1u, list->numHwLayers); |
991 | - hwc_layer_1 target_layer = list->hwLayers[0]; |
992 | - EXPECT_THAT(target_layer.sourceCrop, MatchesRect( expected_sc, "sourceCrop")); |
993 | - EXPECT_THAT(target_layer.displayFrame, MatchesRect( expected_df, "displayFrame")); |
994 | - |
995 | - ASSERT_EQ(1u, target_layer.visibleRegionScreen.numRects); |
996 | - ASSERT_NE(nullptr, target_layer.visibleRegionScreen.rects); |
997 | - EXPECT_THAT(target_layer.visibleRegionScreen.rects[0], MatchesRect( expected_visible, "visible")); |
998 | -} |
999 | - |
1000 | -TEST_F(HWCLayerListTest, fb_target) |
1001 | -{ |
1002 | - using namespace testing; |
1003 | - |
1004 | - mga::LayerList layerlist; |
1005 | - |
1006 | - auto list = layerlist.native_list(); |
1007 | - ASSERT_EQ(1u, list->numHwLayers); |
1008 | - hwc_layer_1 target_layer = list->hwLayers[0]; |
1009 | - EXPECT_EQ(nullptr, target_layer.handle); |
1010 | -} |
1011 | - |
1012 | -TEST_F(HWCLayerListTest, set_fb_target_gets_fb_handle) |
1013 | -{ |
1014 | - using namespace testing; |
1015 | - |
1016 | - mga::LayerList layerlist; |
1017 | - |
1018 | - EXPECT_CALL(*mock_buffer, native_buffer_handle()) |
1019 | - .Times(1) |
1020 | - .WillOnce(Return(native_handle_1)); |
1021 | - |
1022 | - layerlist.set_fb_target(mock_buffer); |
1023 | - auto list = layerlist.native_list(); |
1024 | - ASSERT_EQ(1u, list->numHwLayers); |
1025 | - hwc_layer_1 target_layer = list->hwLayers[0]; |
1026 | - EXPECT_EQ(native_handle_1->handle(), target_layer.handle); |
1027 | -} |
1028 | - |
1029 | -TEST_F(HWCLayerListTest, set_fb_target_2x) |
1030 | -{ |
1031 | - using namespace testing; |
1032 | - |
1033 | - mga::LayerList layerlist; |
1034 | - |
1035 | - EXPECT_CALL(*mock_buffer, native_buffer_handle()) |
1036 | - .Times(2) |
1037 | - .WillOnce(Return(native_handle_1)) |
1038 | - .WillOnce(Return(native_handle_2)); |
1039 | - |
1040 | - layerlist.set_fb_target(mock_buffer); |
1041 | - auto list = layerlist.native_list(); |
1042 | - ASSERT_EQ(1u, list->numHwLayers); |
1043 | - hwc_layer_1 target_layer = list->hwLayers[0]; |
1044 | - EXPECT_EQ(native_handle_1->handle(), target_layer.handle); |
1045 | - |
1046 | - layerlist.set_fb_target(mock_buffer); |
1047 | - auto list_second = layerlist.native_list(); |
1048 | - ASSERT_EQ(1u, list_second->numHwLayers); |
1049 | - target_layer = list_second->hwLayers[0]; |
1050 | - EXPECT_EQ(native_handle_2->handle(), target_layer.handle); |
1051 | -} |
1052 | - |
1053 | -TEST_F(HWCLayerListTest, set_fb_target_programs_other_struct_members_correctly) |
1054 | -{ |
1055 | - using namespace testing; |
1056 | - |
1057 | - mga::LayerList layerlist; |
1058 | - layerlist.set_fb_target(mock_buffer); |
1059 | - |
1060 | - hwc_rect_t source_region = {0,0,width, height}; |
1061 | - hwc_rect_t target_region = source_region; |
1062 | - hwc_region_t region {1, nullptr}; |
1063 | - |
1064 | +TEST_F(HWCLayerListTest, fb_target_layer) |
1065 | +{ |
1066 | + mga::FramebufferLayer target_layer(*native_handle_1); |
1067 | + |
1068 | + hwc_rect_t region = {0,0,width, height}; |
1069 | + hwc_region_t visible_region {1, ®ion}; |
1070 | hwc_layer_1 expected_layer; |
1071 | expected_layer.compositionType = HWC_FRAMEBUFFER_TARGET; |
1072 | expected_layer.hints = 0; |
1073 | @@ -177,14 +61,91 @@ |
1074 | expected_layer.handle = native_handle_1->handle(); |
1075 | expected_layer.transform = 0; |
1076 | expected_layer.blending = HWC_BLENDING_NONE; |
1077 | - expected_layer.sourceCrop = source_region; |
1078 | - expected_layer.displayFrame = target_region; |
1079 | - expected_layer.visibleRegionScreen = region; |
1080 | - expected_layer.acquireFenceFd = -1; |
1081 | - expected_layer.releaseFenceFd = -1; |
1082 | - |
1083 | - auto list = layerlist.native_list(); |
1084 | - ASSERT_EQ(1u, list->numHwLayers); |
1085 | - hwc_layer_1 target_layer = list->hwLayers[0]; |
1086 | - EXPECT_THAT(target_layer, MatchesLayer( expected_layer )); |
1087 | + expected_layer.sourceCrop = region; |
1088 | + expected_layer.displayFrame = region; |
1089 | + expected_layer.visibleRegionScreen = visible_region; |
1090 | + expected_layer.acquireFenceFd = -1; |
1091 | + expected_layer.releaseFenceFd = -1; |
1092 | + |
1093 | + EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); |
1094 | +} |
1095 | + |
1096 | +TEST_F(HWCLayerListTest, gl_target_layer_with_force_gl) |
1097 | +{ |
1098 | + mga::CompositionLayer target_layer(*native_handle_1, HWC_SKIP_LAYER); |
1099 | + |
1100 | + hwc_rect_t region = {0,0,width, height}; |
1101 | + hwc_region_t visible_region {1, ®ion}; |
1102 | + hwc_layer_1 expected_layer; |
1103 | + expected_layer.compositionType = HWC_FRAMEBUFFER; |
1104 | + expected_layer.hints = 0; |
1105 | + expected_layer.flags = HWC_SKIP_LAYER; |
1106 | + expected_layer.handle = native_handle_1->handle(); |
1107 | + expected_layer.transform = 0; |
1108 | + expected_layer.blending = HWC_BLENDING_NONE; |
1109 | + expected_layer.sourceCrop = region; |
1110 | + expected_layer.displayFrame = region; |
1111 | + expected_layer.visibleRegionScreen = visible_region; |
1112 | + expected_layer.acquireFenceFd = -1; |
1113 | + expected_layer.releaseFenceFd = -1; |
1114 | + |
1115 | + EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); |
1116 | +} |
1117 | + |
1118 | +TEST_F(HWCLayerListTest, gl_target_layer_without_skip) |
1119 | +{ |
1120 | + mga::CompositionLayer target_layer(*native_handle_1, 0); |
1121 | + |
1122 | + hwc_rect_t region = {0,0,width, height}; |
1123 | + hwc_region_t visible_region {1, ®ion}; |
1124 | + hwc_layer_1 expected_layer; |
1125 | + expected_layer.compositionType = HWC_FRAMEBUFFER; |
1126 | + expected_layer.hints = 0; |
1127 | + expected_layer.flags = 0; |
1128 | + expected_layer.handle = native_handle_1->handle(); |
1129 | + expected_layer.transform = 0; |
1130 | + expected_layer.blending = HWC_BLENDING_NONE; |
1131 | + expected_layer.sourceCrop = region; |
1132 | + expected_layer.displayFrame = region; |
1133 | + expected_layer.visibleRegionScreen = visible_region; |
1134 | + expected_layer.acquireFenceFd = -1; |
1135 | + expected_layer.releaseFenceFd = -1; |
1136 | + |
1137 | + EXPECT_THAT(target_layer, MatchesLayer(expected_layer)); |
1138 | +} |
1139 | + |
1140 | +TEST_F(HWCLayerListTest, hwc_list_creation) |
1141 | +{ |
1142 | + using namespace testing; |
1143 | + |
1144 | + mga::CompositionLayer surface_layer(*native_handle_1, 0); |
1145 | + mga::FramebufferLayer target_layer(*native_handle_1); |
1146 | + mga::LayerList layerlist({ |
1147 | + surface_layer, |
1148 | + target_layer}); |
1149 | + |
1150 | + auto list = layerlist.native_list(); |
1151 | + EXPECT_EQ(-1, list->retireFenceFd); |
1152 | + EXPECT_EQ(HWC_GEOMETRY_CHANGED, list->flags); |
1153 | + /* note, mali hwc1.1 actually falsely returns if these are not set to something. set to garbage */ |
1154 | + EXPECT_NE(nullptr, list->dpy); |
1155 | + EXPECT_NE(nullptr, list->sur); |
1156 | + |
1157 | + ASSERT_EQ(2u, list->numHwLayers); |
1158 | + EXPECT_THAT(surface_layer, MatchesLayer(list->hwLayers[0])); |
1159 | + EXPECT_THAT(target_layer, MatchesLayer(list->hwLayers[1])); |
1160 | +} |
1161 | + |
1162 | +TEST_F(HWCLayerListTest, hwc_list_update) |
1163 | +{ |
1164 | + using namespace testing; |
1165 | + mga::LayerList layerlist({ |
1166 | + mga::CompositionLayer(*native_handle_1, 0), |
1167 | + mga::FramebufferLayer(*native_handle_1)}); |
1168 | + layerlist.set_fb_target(native_handle_2); |
1169 | + |
1170 | + auto list = layerlist.native_list(); |
1171 | + ASSERT_EQ(2u, list->numHwLayers); |
1172 | + EXPECT_EQ(list->hwLayers[0].handle, native_handle_1->handle()); |
1173 | + EXPECT_EQ(list->hwLayers[1].handle, native_handle_2->handle()); |
1174 | } |
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://