Mir

Merge lp:~kdub/mir/power-control-to-display into lp:mir

Proposed by Kevin DuBois on 2014-12-17
Status: Merged
Approved by: Daniel van Vugt on 2015-01-09
Approved revision: 2170
Merged at revision: 2210
Proposed branch: lp:~kdub/mir/power-control-to-display
Merge into: lp:mir
Prerequisite: lp:~kdub/mir/hwc-common-cleanups
Diff against target: 1343 lines (+272/-268)
30 files modified
src/platforms/android/display.cpp (+34/-13)
src/platforms/android/display.h (+3/-0)
src/platforms/android/display_buffer.cpp (+3/-13)
src/platforms/android/display_buffer_builder.h (+3/-0)
src/platforms/android/display_device.h (+2/-2)
src/platforms/android/fb_device.cpp (+30/-18)
src/platforms/android/fb_device.h (+13/-1)
src/platforms/android/framebuffers.cpp (+5/-4)
src/platforms/android/framebuffers.h (+1/-0)
src/platforms/android/hwc_blanking_control.cpp (+6/-2)
src/platforms/android/hwc_common_device.cpp (+1/-37)
src/platforms/android/hwc_common_device.h (+0/-7)
src/platforms/android/hwc_configuration.h (+2/-1)
src/platforms/android/hwc_device.cpp (+2/-3)
src/platforms/android/hwc_device.h (+3/-4)
src/platforms/android/hwc_fb_device.cpp (+5/-2)
src/platforms/android/hwc_fb_device.h (+1/-2)
src/platforms/android/output_builder.cpp (+13/-1)
src/platforms/android/output_builder.h (+3/-2)
src/platforms/android/resource_factory.cpp (+2/-5)
tests/include/mir_test_doubles/mock_display_device.h (+1/-1)
tests/include/mir_test_doubles/stub_display_builder.h (+23/-2)
tests/unit-tests/graphics/android/test_display.cpp (+52/-6)
tests/unit-tests/graphics/android/test_display_buffer.cpp (+16/-10)
tests/unit-tests/graphics/android/test_fb_device.cpp (+12/-17)
tests/unit-tests/graphics/android/test_fb_simple_swapper.cpp (+3/-3)
tests/unit-tests/graphics/android/test_hwc_common_device.cpp (+2/-70)
tests/unit-tests/graphics/android/test_hwc_configuration.cpp (+8/-3)
tests/unit-tests/graphics/android/test_hwc_device.cpp (+20/-28)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+3/-11)
To merge this branch: bzr merge lp:~kdub/mir/power-control-to-display
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-01-09
Cemil Azizoglu (community) Approve on 2015-01-08
Alan Griffiths Approve on 2015-01-07
Robert Carr (community) Approve on 2015-01-06
Daniel van Vugt 2014-12-17 Abstain on 2015-01-06
Review via email: mp+245006@code.launchpad.net

Commit Message

android: move the display control from mga::DisplayDevice implementations to mga::Display.
mga::Display is the object that's best positioned to see and configure all the displays.

Description of the Change

android: move the display control from mga::DisplayDevice implementations to mga::Display.
mga::Display is the object that's best positioned to see and configure all the displays.

note: This branch has mga::Display controlling the display, and mga::DisplayBuffer used as storage space for the DisplayConfigurationOutput information. The subsequent branch will have the DisplayConfigurationOutput information move to mga::Display as well.

note: I have a hazy memory of us wanting to improve DisplayBufferBuilder's name, so added a TODO in l155

To post a comment you must log in.
Kevin DuBois (kdub) wrote :

conflicts a bit with unbury-display-config-query, will fix-up once one of them lands

Daniel van Vugt (vanvugt) wrote :

Text conflict in src/platforms/android/display_buffer.cpp
Text conflict in src/platforms/android/hwc_blanking_control.cpp
Text conflict in src/platforms/android/hwc_common_device.cpp
Text conflict in src/platforms/android/hwc_configuration.h
Text conflict in tests/include/mir_test_doubles/stub_display_builder.h
Text conflict in tests/unit-tests/graphics/android/test_fb_device.cpp
Text conflict in tests/unit-tests/graphics/android/test_hwc_common_device.cpp
Text conflict in tests/unit-tests/graphics/android/test_hwc_configuration.cpp
Text conflict in tests/unit-tests/graphics/android/test_hwc_device.cpp
Text conflict in tests/unit-tests/graphics/android/test_hwc_fb_device.cpp
10 conflicts encountered.

review: Needs Fixing
Robert Carr (robertcarr) wrote :

+} catch (...) {}

Can we log this?

+ off = false;

I think that the BlankingControl impl needs a mutex, or perhaps in Display::safe_power_mode_off

+ config.power_mode(mga::DisplayName::primary, mode);

It's enough to take ownership of the configuration mutex.

review: Needs Fixing
Robert Carr (robertcarr) wrote :

Im not so sure the mutex is really an issue I guess as its only not held during config changes during the ctor and dtor...I doubt this could be particularly problematic. I think it's worth acquiring the mutex from the dtor though (it may be worth updating the signature: safe_power_mode_off->safe_power_mode_off_locked).

Kevin DuBois (kdub) wrote :

> +} catch (...) {}
>
> Can we log this?

Some drivers report incorrect failure error codes on startup, I'd rather not log anything to avoid having people think there's problems when the driver is operating as best as we can get it to.

> + off = false;
>
> I think that the BlankingControl impl needs a mutex, or perhaps in
> Display::safe_power_mode_off
>
> + config.power_mode(mga::DisplayName::primary, mode);
>
> It's enough to take ownership of the configuration mutex.

Display now serializes the calls between the display posting functions and the blanking controls. The second mutex is not needed, nor could a mutex in BlankingControl protect against the display trying to post and turn on/off at the same time.

Kevin DuBois (kdub) wrote :

> +} catch (...) {}
>
> Can we log this?

Some drivers report incorrect failure error codes on startup, I'd rather not log anything to avoid having people think there's problems when the driver is operating as best as we can get it to.

> + off = false;
>
> I think that the BlankingControl impl needs a mutex, or perhaps in
> Display::safe_power_mode_off
>
> + config.power_mode(mga::DisplayName::primary, mode);
>
> It's enough to take ownership of the configuration mutex.

Display now serializes the calls between the display posting functions and the blanking controls. The second mutex is not needed, nor could a mutex in BlankingControl protect against the display trying to post and turn on/off at the same time.

Daniel van Vugt (vanvugt) :
review: Abstain
Robert Carr (robertcarr) wrote :

>> Some drivers report incorrect failure error codes on startup, I'd rather not log anything to >> avoid having people think there's problems when the driver is operating as best as we can get >> it to.

I would make the other call. Remember users aren't looking at logs. We are interpreting logs from users. The message could even warn of false positives.

>> Display now serializes the calls between the display posting functions and the blanking
>> controls. The second mutex is not needed, nor could a mutex in BlankingControl protect against >> the display trying to post and turn on/off at the same time.

Ah, sorry

review: Approve
Alan Griffiths (alan-griffiths) wrote :

Just nits

> > +} catch (...) {}
> >
> > Can we log this?
>
> Some drivers report incorrect failure error codes on startup, I'd rather not
> log anything to avoid having people think there's problems when the driver is
> operating as best as we can get it to.

Preexisting I guess, but I think that deserves a comment to explain the code.

~~~~

92 + ~Display();

Destructors ought to be noexcept

review: Needs Fixing
Kevin DuBois (kdub) wrote :

nits addressed

Alan Griffiths (alan-griffiths) wrote :

> nits addressed

Although I'd have put the comment at the "catch (...) {}" not at just one of the two call sites.

review: Approve
Cemil Azizoglu (cemil-azizoglu) wrote :

Just marking so I get a chance to review. I should be able to do it later today.

review: Needs Fixing
Cemil Azizoglu (cemil-azizoglu) wrote :

Ok.

review: Approve
Daniel van Vugt (vanvugt) wrote :

Looks like a CI hiccup that's affecting other branches too. Trying to top approve...

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/display.cpp'
2--- src/platforms/android/display.cpp 2014-12-08 04:03:47 +0000
3+++ src/platforms/android/display.cpp 2015-01-07 20:57:51 +0000
4@@ -32,14 +32,28 @@
5 namespace mg=mir::graphics;
6 namespace geom=mir::geometry;
7
8-mga::Display::Display(std::shared_ptr<mga::DisplayBufferBuilder> const& display_buffer_builder,
9- std::shared_ptr<mg::GLProgramFactory> const& gl_program_factory,
10- std::shared_ptr<GLConfig> const& gl_config,
11- std::shared_ptr<DisplayReport> const& display_report)
12- : display_buffer_builder{display_buffer_builder},
13- gl_context{display_buffer_builder->display_format(), *gl_config, *display_report},
14- display_buffer{display_buffer_builder->create_display_buffer(*gl_program_factory, gl_context)}
15-{
16+namespace
17+{
18+void safe_power_mode(mga::HwcConfiguration& config, MirPowerMode mode) noexcept
19+try
20+{
21+ config.power_mode(mga::DisplayName::primary, mode);
22+} catch (...) {}
23+}
24+
25+mga::Display::Display(
26+ std::shared_ptr<mga::DisplayBufferBuilder> const& display_buffer_builder,
27+ std::shared_ptr<mg::GLProgramFactory> const& gl_program_factory,
28+ std::shared_ptr<GLConfig> const& gl_config,
29+ std::shared_ptr<DisplayReport> const& display_report) :
30+ display_buffer_builder{display_buffer_builder},
31+ gl_context{display_buffer_builder->display_format(), *gl_config, *display_report},
32+ display_buffer{display_buffer_builder->create_display_buffer(*gl_program_factory, gl_context)},
33+ hwc_config{display_buffer_builder->create_hwc_configuration()}
34+{
35+ //Some drivers (depending on kernel state) incorrectly report an error code indicating that the display is already on. Ignore the first failure.
36+ safe_power_mode(*hwc_config, mir_power_mode_on);
37+
38 display_report->report_successful_setup_of_native_resources();
39
40 gl_context.make_current();
41@@ -48,6 +62,12 @@
42 display_report->report_successful_display_construction();
43 }
44
45+mga::Display::~Display() noexcept
46+{
47+ if (display_buffer->configuration().power_mode != mir_power_mode_off)
48+ safe_power_mode(*hwc_config, mir_power_mode_off);
49+}
50+
51 void mga::Display::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)
52 {
53 std::lock_guard<decltype(configuration_mutex)> lock{configuration_mutex};
54@@ -67,16 +87,17 @@
55 void mga::Display::configure(mg::DisplayConfiguration const& configuration)
56 {
57 if (!configuration.valid())
58- {
59- BOOST_THROW_EXCEPTION(
60- std::logic_error("Invalid or inconsistent display configuration"));
61- }
62+ BOOST_THROW_EXCEPTION(std::logic_error("Invalid or inconsistent display configuration"));
63
64 std::lock_guard<decltype(configuration_mutex)> lock{configuration_mutex};
65
66 configuration.for_each_output([&](mg::DisplayConfigurationOutput const& output)
67 {
68- display_buffer->configure(output);
69+ if (display_buffer->configuration().power_mode != output.power_mode)
70+ {
71+ hwc_config->power_mode(mga::DisplayName::primary, output.power_mode);
72+ display_buffer->configure(output);
73+ }
74 });
75 }
76
77
78=== modified file 'src/platforms/android/display.h'
79--- src/platforms/android/display.h 2014-12-08 04:03:47 +0000
80+++ src/platforms/android/display.h 2015-01-07 20:57:51 +0000
81@@ -21,6 +21,7 @@
82
83 #include "mir/graphics/display.h"
84 #include "gl_context.h"
85+#include "hwc_configuration.h"
86
87 #include <memory>
88 #include <mutex>
89@@ -47,6 +48,7 @@
90 std::shared_ptr<GLProgramFactory> const& gl_program_factory,
91 std::shared_ptr<GLConfig> const& gl_config,
92 std::shared_ptr<DisplayReport> const& display_report);
93+ ~Display() noexcept;
94
95 void for_each_display_buffer(std::function<void(graphics::DisplayBuffer&)> const& f) override;
96
97@@ -75,6 +77,7 @@
98
99 //we only have a primary display at the moment
100 std::unique_ptr<ConfigurableDisplayBuffer> const display_buffer;
101+ std::unique_ptr<HwcConfiguration> const hwc_config;
102 };
103
104 }
105
106=== modified file 'src/platforms/android/display_buffer.cpp'
107--- src/platforms/android/display_buffer.cpp 2014-12-19 02:31:34 +0000
108+++ src/platforms/android/display_buffer.cpp 2015-01-07 20:57:51 +0000
109@@ -128,19 +128,9 @@
110
111 void mga::DisplayBuffer::configure(DisplayConfigurationOutput const& new_configuration)
112 {
113- //power mode
114- MirPowerMode intended_power_mode = new_configuration.power_mode;
115- if ((intended_power_mode == mir_power_mode_standby) ||
116- (intended_power_mode == mir_power_mode_suspend))
117- {
118- intended_power_mode = mir_power_mode_off;
119- }
120-
121- if (intended_power_mode != current_configuration.power_mode)
122- {
123- display_device->mode(intended_power_mode);
124- current_configuration.power_mode = intended_power_mode;
125- }
126+ if (new_configuration.power_mode != mir_power_mode_on)
127+ display_device->content_cleared();
128+ current_configuration.power_mode = new_configuration.power_mode;
129
130 //TODO: We don't support rotation yet, so
131 //we preserve this orientation change so the compositor can rotate everything in GL
132
133=== modified file 'src/platforms/android/display_buffer_builder.h'
134--- src/platforms/android/display_buffer_builder.h 2014-12-08 04:03:47 +0000
135+++ src/platforms/android/display_buffer_builder.h 2015-01-07 20:57:51 +0000
136@@ -31,7 +31,9 @@
137 namespace android
138 {
139 class GLContext;
140+class HwcConfiguration;
141
142+//TODO: this name needs improvement.
143 class DisplayBufferBuilder
144 {
145 public:
146@@ -40,6 +42,7 @@
147 virtual MirPixelFormat display_format() = 0;
148 virtual std::unique_ptr<ConfigurableDisplayBuffer> create_display_buffer(
149 GLProgramFactory const& gl_program_factory, GLContext const& gl_context) = 0;
150+ virtual std::unique_ptr<HwcConfiguration> create_hwc_configuration() = 0;
151
152 protected:
153 DisplayBufferBuilder() = default;
154
155=== modified file 'src/platforms/android/display_device.h'
156--- src/platforms/android/display_device.h 2014-12-19 02:31:34 +0000
157+++ src/platforms/android/display_device.h 2015-01-07 20:57:51 +0000
158@@ -49,8 +49,8 @@
159 RenderableList const& list,
160 RenderableListCompositor const& list_compositor) = 0;
161
162- //TODO: remove the following from this interface
163- virtual void mode(MirPowerMode mode) = 0;
164+ //notify the DisplayDevice that the screen content was cleared in a way other than the above fns
165+ virtual void content_cleared() = 0;
166
167 protected:
168 DisplayDevice() = default;
169
170=== modified file 'src/platforms/android/fb_device.cpp'
171--- src/platforms/android/fb_device.cpp 2014-12-19 02:31:34 +0000
172+++ src/platforms/android/fb_device.cpp 2015-01-07 20:57:51 +0000
173@@ -32,16 +32,38 @@
174 namespace mga=mir::graphics::android;
175 namespace geom=mir::geometry;
176
177-mga::FBDevice::FBDevice(
178- std::shared_ptr<framebuffer_device_t> const& fbdev)
179- : fb_device(fbdev)
180+mga::FbControl::FbControl(std::shared_ptr<framebuffer_device_t> const& fbdev) :
181+ fb_device(fbdev)
182 {
183 if (fb_device->setSwapInterval)
184- {
185 fb_device->setSwapInterval(fb_device.get(), 1);
186- }
187-
188- mode(mir_power_mode_on);
189+}
190+
191+void mga::FbControl::power_mode(DisplayName display, MirPowerMode mode)
192+{
193+ if (display != mga::DisplayName::primary)
194+ BOOST_THROW_EXCEPTION(std::runtime_error("fb device cannot activate non-primary display"));
195+
196+ int enable = 0;
197+ if (mode == mir_power_mode_on)
198+ enable = 1;
199+
200+ if (fb_device->enableScreen)
201+ fb_device->enableScreen(fb_device.get(), enable);
202+}
203+
204+mga::DisplayAttribs mga::FbControl::active_attribs_for(DisplayName)
205+{
206+ return mga::DisplayAttribs{
207+ {fb_device->width, fb_device->height},
208+ {0,0},
209+ fb_device->fps,
210+ true};
211+}
212+
213+mga::FBDevice::FBDevice(std::shared_ptr<framebuffer_device_t> const& fbdev) :
214+ fb_device(fbdev)
215+{
216 }
217
218 void mga::FBDevice::post_gl(SwappingGLContext const& context)
219@@ -62,16 +84,6 @@
220 return false;
221 }
222
223-void mga::FBDevice::mode(MirPowerMode mode)
224+void mga::FBDevice::content_cleared()
225 {
226- int enable = 0;
227- if (mode == mir_power_mode_on)
228- {
229- enable = 1;
230- }
231-
232- if (fb_device->enableScreen)
233- {
234- fb_device->enableScreen(fb_device.get(), enable);
235- }
236 }
237
238=== modified file 'src/platforms/android/fb_device.h'
239--- src/platforms/android/fb_device.h 2014-12-19 02:31:34 +0000
240+++ src/platforms/android/fb_device.h 2015-01-07 20:57:51 +0000
241@@ -20,6 +20,7 @@
242 #define MIR_GRAPHICS_ANDROID_FB_DEVICE_H_
243
244 #include "display_device.h"
245+#include "hwc_configuration.h"
246 #include <hardware/gralloc.h>
247 #include <hardware/fb.h>
248
249@@ -30,12 +31,22 @@
250 namespace android
251 {
252
253+class FbControl : public HwcConfiguration
254+{
255+public:
256+ FbControl(std::shared_ptr<framebuffer_device_t> const& fbdev);
257+ void power_mode(DisplayName, MirPowerMode) override;
258+ DisplayAttribs active_attribs_for(DisplayName) override;
259+
260+private:
261+ std::shared_ptr<framebuffer_device_t> const fb_device;
262+};
263+
264 class FBDevice : public DisplayDevice
265 {
266 public:
267 FBDevice(std::shared_ptr<framebuffer_device_t> const& fbdev);
268
269- void mode(MirPowerMode mode);
270 virtual void post_gl(SwappingGLContext const& context);
271 virtual bool post_overlays(
272 SwappingGLContext const& context,
273@@ -44,6 +55,7 @@
274
275 private:
276 std::shared_ptr<framebuffer_device_t> const fb_device;
277+ void content_cleared() override;
278 };
279
280 }
281
282=== modified file 'src/platforms/android/framebuffers.cpp'
283--- src/platforms/android/framebuffers.cpp 2014-12-12 21:41:20 +0000
284+++ src/platforms/android/framebuffers.cpp 2015-01-07 20:57:51 +0000
285@@ -82,10 +82,11 @@
286
287 mga::Framebuffers::Framebuffers(
288 std::shared_ptr<mga::GraphicBufferAllocator> const& buffer_allocator,
289- std::shared_ptr<framebuffer_device_t> const& fb)
290- : format{mga::to_mir_format(fb->format)},
291- size({fb->width, fb->height}),
292- refresh_rate_hz{fb->fps}
293+ geom::Size size, double vrefresh_hz,
294+ std::shared_ptr<framebuffer_device_t> const& fb) :
295+ format{mga::to_mir_format(fb->format)},
296+ size{size},
297+ refresh_rate_hz{vrefresh_hz}
298 {
299 //guarantee always 2 fb's allocated
300 auto fb_num = static_cast<unsigned int>(fb->numFramebuffers);
301
302=== modified file 'src/platforms/android/framebuffers.h'
303--- src/platforms/android/framebuffers.h 2014-12-12 21:20:11 +0000
304+++ src/platforms/android/framebuffers.h 2015-01-07 20:57:51 +0000
305@@ -43,6 +43,7 @@
306 Framebuffers(std::shared_ptr<GraphicBufferAllocator> const& buffer_allocator,
307 geometry::Size size, double vrefresh_hz, unsigned int num_framebuffers);
308 Framebuffers(std::shared_ptr<GraphicBufferAllocator> const& buffer_allocator,
309+ geometry::Size size, double vrefresh_hz,
310 std::shared_ptr<framebuffer_device_t> const& fb);
311
312 MirPixelFormat fb_format();
313
314=== modified file 'src/platforms/android/hwc_blanking_control.cpp'
315--- src/platforms/android/hwc_blanking_control.cpp 2014-12-20 01:59:45 +0000
316+++ src/platforms/android/hwc_blanking_control.cpp 2015-01-07 20:57:51 +0000
317@@ -26,7 +26,8 @@
318
319 mga::HwcBlankingControl::HwcBlankingControl(
320 std::shared_ptr<mga::HwcWrapper> const& hwc_device) :
321- hwc_device{hwc_device}
322+ hwc_device{hwc_device},
323+ off{false}
324 {
325 }
326
327@@ -36,11 +37,14 @@
328 {
329 hwc_device->display_on(display_name);
330 hwc_device->vsync_signal_on(display_name);
331+ off = false;
332 }
333- else
334+ //suspend, standby, and off all count as off
335+ else if (!off)
336 {
337 hwc_device->vsync_signal_off(display_name);
338 hwc_device->display_off(display_name);
339+ off = true;
340 }
341 }
342
343
344=== modified file 'src/platforms/android/hwc_common_device.cpp'
345--- src/platforms/android/hwc_common_device.cpp 2014-12-19 02:31:34 +0000
346+++ src/platforms/android/hwc_common_device.cpp 2015-01-07 20:57:51 +0000
347@@ -44,13 +44,10 @@
348
349 mga::HWCCommonDevice::HWCCommonDevice(
350 std::shared_ptr<HwcWrapper> const& hwc_device,
351- std::shared_ptr<HwcConfiguration> const& hwc_config,
352 std::shared_ptr<HWCVsyncCoordinator> const& coordinator) :
353 coordinator(coordinator),
354 callbacks(std::make_shared<mga::HWCCallbacks>()),
355- hwc_device(hwc_device),
356- hwc_config(hwc_config),
357- current_mode(mir_power_mode_on)
358+ hwc_device(hwc_device)
359 {
360 callbacks->hooks.invalidate = invalidate_hook;
361 callbacks->hooks.vsync = vsync_hook;
362@@ -58,28 +55,10 @@
363 callbacks->self = this;
364
365 hwc_device->register_hooks(callbacks);
366-
367- try
368- {
369- mode(mir_power_mode_on);
370- } catch (...)
371- {
372- //TODO: log failure here. some drivers will throw if the screen is already on, which
373- // is not a fatal condition
374- }
375 }
376
377 mga::HWCCommonDevice::~HWCCommonDevice() noexcept
378 {
379- if (current_mode == mir_power_mode_on)
380- {
381- try
382- {
383- mode(mir_power_mode_off);
384- } catch (...)
385- {
386- }
387- }
388 callbacks->self = nullptr;
389 }
390
391@@ -87,18 +66,3 @@
392 {
393 coordinator->notify_vsync();
394 }
395-
396-void mga::HWCCommonDevice::mode(MirPowerMode mode_request)
397-{
398- hwc_config->power_mode(mga::DisplayName::primary, mode_request);
399-
400- if (mode_request == mir_power_mode_off)
401- turned_screen_off();
402-
403- //TODO the mode should be in the display mode structure that gets passed to the rest of the system
404- current_mode = mode_request;
405-}
406-
407-void mga::HWCCommonDevice::turned_screen_off()
408-{
409-}
410
411=== modified file 'src/platforms/android/hwc_common_device.h'
412--- src/platforms/android/hwc_common_device.h 2014-12-19 02:31:34 +0000
413+++ src/platforms/android/hwc_common_device.h 2015-01-07 20:57:51 +0000
414@@ -48,23 +48,16 @@
415 virtual ~HWCCommonDevice() noexcept;
416
417 void notify_vsync();
418- void mode(MirPowerMode mode);
419
420 protected:
421 HWCCommonDevice(std::shared_ptr<HwcWrapper> const& hwc_wrapper,
422- std::shared_ptr<HwcConfiguration> const& configuration,
423 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
424
425 std::shared_ptr<HWCVsyncCoordinator> const coordinator;
426
427 private:
428- virtual void turned_screen_off();
429-
430 std::shared_ptr<HWCCallbacks> const callbacks;
431 std::shared_ptr<HwcWrapper> const hwc_device;
432- std::shared_ptr<HwcConfiguration> const hwc_config;
433-
434- MirPowerMode current_mode;
435 };
436
437 }
438
439=== modified file 'src/platforms/android/hwc_configuration.h'
440--- src/platforms/android/hwc_configuration.h 2015-01-05 23:03:19 +0000
441+++ src/platforms/android/hwc_configuration.h 2015-01-07 20:57:51 +0000
442@@ -38,7 +38,7 @@
443 bool connected;
444 };
445
446-//interface adapting for the blanking interface differences between HWC 1.0-1.3 and HWC 1.4+
447+//interface adapting for the blanking interface differences between fb, HWC 1.0-1.3, and HWC 1.4+
448 class HwcConfiguration
449 {
450 public:
451@@ -61,6 +61,7 @@
452 DisplayAttribs active_attribs_for(DisplayName) override;
453 private:
454 std::shared_ptr<HwcWrapper> const hwc_device;
455+ bool off;
456 };
457
458 }
459
460=== modified file 'src/platforms/android/hwc_device.cpp'
461--- src/platforms/android/hwc_device.cpp 2014-12-19 02:31:34 +0000
462+++ src/platforms/android/hwc_device.cpp 2015-01-07 20:57:51 +0000
463@@ -66,10 +66,9 @@
464 }
465
466 mga::HwcDevice::HwcDevice(std::shared_ptr<HwcWrapper> const& hwc_wrapper,
467- std::shared_ptr<HwcConfiguration> const& hwc_config,
468 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,
469 std::shared_ptr<LayerAdapter> const& layer_adapter)
470- : HWCCommonDevice(hwc_wrapper, hwc_config, coordinator),
471+ : HWCCommonDevice(hwc_wrapper, coordinator),
472 hwc_list{layer_adapter, {}, fbtarget_plus_skip_size},
473 hwc_wrapper(hwc_wrapper)
474 {
475@@ -188,7 +187,7 @@
476 return true;
477 }
478
479-void mga::HwcDevice::turned_screen_off()
480+void mga::HwcDevice::content_cleared()
481 {
482 onscreen_overlay_buffers.clear();
483 }
484
485=== modified file 'src/platforms/android/hwc_device.h'
486--- src/platforms/android/hwc_device.h 2014-12-19 02:31:34 +0000
487+++ src/platforms/android/hwc_device.h 2015-01-07 20:57:51 +0000
488@@ -44,19 +44,18 @@
489 public:
490 HwcDevice(
491 std::shared_ptr<HwcWrapper> const& hwc_wrapper,
492- std::shared_ptr<HwcConfiguration> const& hwc_config,
493 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,
494 std::shared_ptr<LayerAdapter> const& layer_adapter);
495
496- virtual void post_gl(SwappingGLContext const& context) override;
497- virtual bool post_overlays(
498+ void post_gl(SwappingGLContext const& context) override;
499+ bool post_overlays(
500 SwappingGLContext const& context,
501 RenderableList const& list,
502 RenderableListCompositor const& list_compositor) override;
503+ void content_cleared() override;
504
505 private:
506 bool buffer_is_onscreen(Buffer const&) const;
507- void turned_screen_off() override;
508 LayerList hwc_list;
509 std::vector<std::shared_ptr<Buffer>> onscreen_overlay_buffers;
510
511
512=== modified file 'src/platforms/android/hwc_fb_device.cpp'
513--- src/platforms/android/hwc_fb_device.cpp 2014-12-19 02:31:34 +0000
514+++ src/platforms/android/hwc_fb_device.cpp 2015-01-07 20:57:51 +0000
515@@ -38,9 +38,8 @@
516 mga::HwcFbDevice::HwcFbDevice(
517 std::shared_ptr<HwcWrapper> const& hwc_wrapper,
518 std::shared_ptr<framebuffer_device_t> const& fb_device,
519- std::shared_ptr<HwcConfiguration> const& config,
520 std::shared_ptr<HWCVsyncCoordinator> const& coordinator) :
521- HWCCommonDevice(hwc_wrapper, config, coordinator),
522+ HWCCommonDevice(hwc_wrapper, coordinator),
523 hwc_wrapper(hwc_wrapper),
524 fb_device(fb_device),
525 layer_list{std::make_shared<IntegerSourceCrop>(), {}, 1}
526@@ -87,3 +86,7 @@
527 {
528 return false;
529 }
530+
531+void mga::HwcFbDevice::content_cleared()
532+{
533+}
534
535=== modified file 'src/platforms/android/hwc_fb_device.h'
536--- src/platforms/android/hwc_fb_device.h 2014-12-19 02:31:34 +0000
537+++ src/platforms/android/hwc_fb_device.h 2015-01-07 20:57:51 +0000
538@@ -31,14 +31,12 @@
539 namespace android
540 {
541 class HwcWrapper;
542-class HwcConfiguration;
543
544 class HwcFbDevice : public HWCCommonDevice
545 {
546 public:
547 HwcFbDevice(std::shared_ptr<HwcWrapper> const& hwc_wrapper,
548 std::shared_ptr<framebuffer_device_t> const& fb_device,
549- std::shared_ptr<HwcConfiguration> const& hwc_config,
550 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
551
552 virtual void post_gl(SwappingGLContext const& context);
553@@ -48,6 +46,7 @@
554 RenderableListCompositor const& list_compositor);
555
556 private:
557+ void content_cleared() override;
558 std::shared_ptr<HwcWrapper> const hwc_wrapper;
559 std::shared_ptr<framebuffer_device_t> const fb_device;
560 static int const num_displays{1};
561
562=== modified file 'src/platforms/android/output_builder.cpp'
563--- src/platforms/android/output_builder.cpp 2014-12-15 20:52:57 +0000
564+++ src/platforms/android/output_builder.cpp 2015-01-07 20:57:51 +0000
565@@ -16,6 +16,7 @@
566 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
567 */
568
569+#include "fb_device.h"
570 #include "device_quirks.h"
571 #include "output_builder.h"
572 #include "display_resource_factory.h"
573@@ -24,6 +25,7 @@
574 #include "framebuffers.h"
575 #include "real_hwc_wrapper.h"
576 #include "hwc_report.h"
577+#include "hwc_configuration.h"
578 #include "hwc_layers.h"
579 #include "hwc_configuration.h"
580
581@@ -57,7 +59,9 @@
582 if (force_backup_display || hwc_native->common.version == HWC_DEVICE_API_VERSION_1_0)
583 {
584 fb_native = res_factory->create_fb_native_device();
585- framebuffers = std::make_shared<mga::Framebuffers>(buffer_allocator, fb_native);
586+ mga::FbControl fb_control{fb_native};
587+ auto attribs = fb_control.active_attribs_for(mga::DisplayName::primary);
588+ framebuffers = std::make_shared<mga::Framebuffers>(buffer_allocator, attribs.pixel_size, attribs.vrefresh_hz, fb_native);
589 }
590 else
591 {
592@@ -118,3 +122,11 @@
593 gl_program_factory,
594 overlay_optimization));
595 }
596+
597+std::unique_ptr<mga::HwcConfiguration> mga::OutputBuilder::create_hwc_configuration()
598+{
599+ if (force_backup_display || hwc_native->common.version == HWC_DEVICE_API_VERSION_1_0)
600+ return std::unique_ptr<mga::HwcConfiguration>(new mga::FbControl(fb_native));
601+ else
602+ return std::unique_ptr<mga::HwcConfiguration>(new mga::HwcBlankingControl(hwc_wrapper));
603+}
604
605=== modified file 'src/platforms/android/output_builder.h'
606--- src/platforms/android/output_builder.h 2014-12-11 02:43:01 +0000
607+++ src/platforms/android/output_builder.h 2015-01-07 20:57:51 +0000
608@@ -47,10 +47,11 @@
609 OverlayOptimization overlay_option,
610 std::shared_ptr<HwcReport> const& hwc_report);
611
612- MirPixelFormat display_format();
613+ MirPixelFormat display_format() override;
614 std::unique_ptr<ConfigurableDisplayBuffer> create_display_buffer(
615 GLProgramFactory const& gl_program_factory,
616- GLContext const& gl_context);
617+ GLContext const& gl_context) override;
618+ std::unique_ptr<HwcConfiguration> create_hwc_configuration() override;
619
620 private:
621 std::shared_ptr<GraphicBufferAllocator> const buffer_allocator;
622
623=== modified file 'src/platforms/android/resource_factory.cpp'
624--- src/platforms/android/resource_factory.cpp 2014-12-19 02:31:34 +0000
625+++ src/platforms/android/resource_factory.cpp 2015-01-07 20:57:51 +0000
626@@ -29,7 +29,6 @@
627 #include "hwc_fb_device.h"
628 #include "hwc_layerlist.h"
629 #include "hwc_vsync.h"
630-#include "hwc_configuration.h"
631 #include "display.h"
632 #include "real_hwc_wrapper.h"
633
634@@ -95,8 +94,7 @@
635 std::shared_ptr<LayerAdapter> const& layer_adapter) const
636 {
637 auto syncer = std::make_shared<mga::HWCVsync>();
638- auto config = std::make_shared<mga::HwcBlankingControl>(wrapper);
639- return std::make_shared<mga::HwcDevice>(wrapper, config, syncer, layer_adapter);
640+ return std::make_shared<mga::HwcDevice>(wrapper, syncer, layer_adapter);
641 }
642
643 std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc_fb_device(
644@@ -104,6 +102,5 @@
645 std::shared_ptr<framebuffer_device_t> const& fb_native_device) const
646 {
647 auto syncer = std::make_shared<mga::HWCVsync>();
648- auto config = std::make_shared<mga::HwcBlankingControl>(wrapper);
649- return std::make_shared<mga::HwcFbDevice>(wrapper, fb_native_device, config, syncer);
650+ return std::make_shared<mga::HwcFbDevice>(wrapper, fb_native_device, syncer);
651 }
652
653=== modified file 'tests/include/mir_test_doubles/mock_display_device.h'
654--- tests/include/mir_test_doubles/mock_display_device.h 2014-12-19 02:31:34 +0000
655+++ tests/include/mir_test_doubles/mock_display_device.h 2015-01-07 20:57:51 +0000
656@@ -35,7 +35,7 @@
657 {
658 public:
659 ~MockDisplayDevice() noexcept {}
660- MOCK_METHOD1(mode, void(MirPowerMode));
661+ MOCK_METHOD0(content_cleared, void());
662 MOCK_METHOD1(post_gl, void(graphics::android::SwappingGLContext const&));
663 MOCK_METHOD3(post_overlays, bool(
664 graphics::android::SwappingGLContext const&,
665
666=== modified file 'tests/include/mir_test_doubles/stub_display_builder.h'
667--- tests/include/mir_test_doubles/stub_display_builder.h 2014-12-19 02:31:34 +0000
668+++ tests/include/mir_test_doubles/stub_display_builder.h 2015-01-07 20:57:51 +0000
669@@ -21,6 +21,7 @@
670
671 #include "src/platforms/android/display_buffer_builder.h"
672 #include "src/platforms/android/configurable_display_buffer.h"
673+#include "src/platforms/android/hwc_configuration.h"
674 #include <gmock/gmock.h>
675
676 namespace mir
677@@ -53,17 +54,24 @@
678 graphics::DisplayConfigurationCardId{0},
679 graphics::DisplayConfigurationOutputType::vga,
680 {}, {}, 0, {}, false, false, {}, 0, mir_pixel_format_abgr_8888,
681- mir_power_mode_off,
682+ mir_power_mode_on,
683 mir_orientation_normal};
684 }
685 private:
686 geometry::Rectangle rect;
687 };
688
689+struct MockHwcConfiguration : public graphics::android::HwcConfiguration
690+{
691+ MOCK_METHOD2(power_mode, void(graphics::android::DisplayName, MirPowerMode));
692+ MOCK_METHOD1(active_attribs_for, graphics::android::DisplayAttribs(graphics::android::DisplayName));
693+};
694+
695 struct StubDisplayBuilder : public graphics::android::DisplayBufferBuilder
696 {
697 StubDisplayBuilder(geometry::Size sz)
698- : sz(sz)
699+ : sz(sz),
700+ mock_config{new testing::NiceMock<MockHwcConfiguration>()}
701 {
702 }
703
704@@ -84,8 +92,21 @@
705 return std::unique_ptr<graphics::android::ConfigurableDisplayBuffer>(
706 new StubConfigurableDisplayBuffer(geometry::Rectangle{{0,0},sz}));
707 }
708+
709+ std::unique_ptr<graphics::android::HwcConfiguration> create_hwc_configuration() override
710+ {
711+ auto config = std::unique_ptr<MockHwcConfiguration>(new testing::NiceMock<MockHwcConfiguration>());
712+ std::swap(config, mock_config);
713+ return std::move(config);
714+ }
715
716+ void with_next_config(std::function<void(MockHwcConfiguration& mock_config)> const& fn)
717+ {
718+ fn(*mock_config);
719+ }
720+
721 geometry::Size sz;
722+ std::unique_ptr<MockHwcConfiguration> mock_config;
723 };
724 }
725 }
726
727=== modified file 'tests/unit-tests/graphics/android/test_display.cpp'
728--- tests/unit-tests/graphics/android/test_display.cpp 2014-12-19 02:31:34 +0000
729+++ tests/unit-tests/graphics/android/test_display.cpp 2015-01-07 20:57:51 +0000
730@@ -263,14 +263,60 @@
731 }, std::runtime_error);
732 }
733
734+
735+TEST_F(Display, turns_on_db_at_construction_and_off_at_destruction)
736+{
737+ stub_db_factory->with_next_config([](mtd::MockHwcConfiguration& mock_config)
738+ {
739+ testing::InSequence seq;
740+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on));
741+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off));
742+ });
743+
744+ mga::Display display(
745+ stub_db_factory,
746+ stub_gl_program_factory,
747+ stub_gl_config,
748+ null_display_report);
749+}
750+
751+TEST_F(Display, first_power_on_is_not_fatal) //lp:1345533
752+{
753+ stub_db_factory->with_next_config([](mtd::MockHwcConfiguration& mock_config)
754+ {
755+ ON_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on))
756+ .WillByDefault(testing::Throw(std::runtime_error("")));
757+ });
758+
759+ EXPECT_NO_THROW({
760+ mga::Display display(stub_db_factory, stub_gl_program_factory, stub_gl_config, null_display_report);});
761+}
762+
763+TEST_F(Display, catches_exceptions_when_turning_off_in_destructor)
764+{
765+ stub_db_factory->with_next_config([](mtd::MockHwcConfiguration& mock_config)
766+ {
767+ testing::InSequence seq;
768+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on));
769+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off))
770+ .WillOnce(testing::Throw(std::runtime_error("")));
771+ });
772+ mga::Display display(stub_db_factory, stub_gl_program_factory, stub_gl_config, null_display_report);
773+}
774+
775 TEST_F(Display, configures_display_buffer)
776 {
777- using namespace testing;
778- mga::Display display(
779- stub_db_factory,
780- stub_gl_program_factory,
781- stub_gl_config,
782- null_display_report);
783+ stub_db_factory->with_next_config([](mtd::MockHwcConfiguration& mock_config)
784+ {
785+ testing::InSequence seq;
786+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on));
787+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_standby));
788+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off));
789+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_suspend));
790+ EXPECT_CALL(mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off));
791+ });
792+
793+ mga::Display display(stub_db_factory, stub_gl_program_factory, stub_gl_config, null_display_report);
794
795 auto configuration = display.configuration();
796 configuration->for_each_output([&](mg::UserDisplayConfigurationOutput& output)
797
798=== modified file 'tests/unit-tests/graphics/android/test_display_buffer.cpp'
799--- tests/unit-tests/graphics/android/test_display_buffer.cpp 2014-12-19 02:31:34 +0000
800+++ tests/unit-tests/graphics/android/test_display_buffer.cpp 2015-01-07 20:57:51 +0000
801@@ -287,15 +287,10 @@
802
803 TEST_F(DisplayBuffer, changes_display_power_mode)
804 {
805- using namespace testing;
806 mga::DisplayBuffer db(
807 mock_fb_bundle, mock_display_device, native_window, *gl_context, stub_program_factory, mga::OverlayOptimization::enabled);
808
809- Sequence seq;
810- EXPECT_CALL(*mock_display_device, mode(mir_power_mode_off))
811- .InSequence(seq);
812- EXPECT_CALL(*mock_display_device, mode(mir_power_mode_on))
813- .InSequence(seq);
814+ EXPECT_CALL(*mock_display_device, content_cleared());
815
816 auto config = db.configuration();
817 config.power_mode = mir_power_mode_off;
818@@ -306,22 +301,33 @@
819 db.configure(config);
820 }
821
822-TEST_F(DisplayBuffer, disregards_double_display_power_mode_request)
823+TEST_F(DisplayBuffer, power_mode_request_stored)
824 {
825- using namespace testing;
826 mga::DisplayBuffer db(
827 mock_fb_bundle, mock_display_device, native_window, *gl_context, stub_program_factory, mga::OverlayOptimization::enabled);
828
829- EXPECT_CALL(*mock_display_device, mode(mir_power_mode_off))
830- .Times(1);
831+ EXPECT_CALL(*mock_display_device, content_cleared())
832+ .Times(3);
833
834 auto config = db.configuration();
835+ EXPECT_EQ(config.power_mode, mir_power_mode_on);
836 config.power_mode = mir_power_mode_off;
837 db.configure(config);
838+
839+ config = db.configuration();
840+ EXPECT_EQ(config.power_mode, mir_power_mode_off);
841 config.power_mode = mir_power_mode_suspend;
842 db.configure(config);
843+
844+ config = db.configuration();
845+ EXPECT_EQ(config.power_mode, mir_power_mode_suspend);
846 config.power_mode = mir_power_mode_standby;
847 db.configure(config);
848+
849+ config = db.configuration();
850+ EXPECT_EQ(config.power_mode, mir_power_mode_standby);
851+ config.power_mode = mir_power_mode_on;
852+ db.configure(config);
853 }
854
855 //configuration tests
856
857=== modified file 'tests/unit-tests/graphics/android/test_fb_device.cpp'
858--- tests/unit-tests/graphics/android/test_fb_device.cpp 2014-12-19 02:31:34 +0000
859+++ tests/unit-tests/graphics/android/test_fb_device.cpp 2015-01-07 20:57:51 +0000
860@@ -98,28 +98,19 @@
861 fbdev.post_gl(mock_context);
862 }
863
864-TEST_F(FBDevice, sets_swapinterval_1_on_start)
865-{
866- EXPECT_CALL(*fb_hal_mock, setSwapInterval_interface(fb_hal_mock.get(), 1))
867- .Times(1);
868- mga::FBDevice fbdev(fb_hal_mock);
869-}
870-
871 //not all fb devices provide a swap interval hook. make sure we don't explode if thats the case
872 TEST_F(FBDevice, does_not_segfault_if_null_swapinterval_hook)
873 {
874 fb_hal_mock->setSwapInterval = nullptr;
875- mga::FBDevice fbdev(fb_hal_mock);
876+ mga::FbControl fb_control(fb_hal_mock);
877 }
878
879 TEST_F(FBDevice, can_screen_on_off)
880 {
881- fb_hal_mock->setSwapInterval = nullptr;
882 using namespace testing;
883- //constructor turns on
884 Sequence seq;
885- EXPECT_CALL(*fb_hal_mock, enableScreen_interface(_,1))
886- .InSequence(seq);
887+ EXPECT_CALL(*fb_hal_mock, setSwapInterval_interface(fb_hal_mock.get(), 1))
888+ .Times(1);
889 EXPECT_CALL(*fb_hal_mock, enableScreen_interface(_,0))
890 .InSequence(seq);
891 EXPECT_CALL(*fb_hal_mock, enableScreen_interface(_,0))
892@@ -129,9 +120,13 @@
893 EXPECT_CALL(*fb_hal_mock, enableScreen_interface(_,1))
894 .InSequence(seq);
895
896- mga::FBDevice fbdev(fb_hal_mock);
897- fbdev.mode(mir_power_mode_standby);
898- fbdev.mode(mir_power_mode_suspend);
899- fbdev.mode(mir_power_mode_off);
900- fbdev.mode(mir_power_mode_on);
901+ mga::FbControl fb_control(fb_hal_mock);
902+ fb_control.power_mode(mga::DisplayName::primary, mir_power_mode_standby);
903+ fb_control.power_mode(mga::DisplayName::primary, mir_power_mode_suspend);
904+ fb_control.power_mode(mga::DisplayName::primary, mir_power_mode_off);
905+ fb_control.power_mode(mga::DisplayName::primary, mir_power_mode_on);
906+
907+ EXPECT_THROW({
908+ fb_control.power_mode(mga::DisplayName::external, mir_power_mode_on);
909+ }, std::runtime_error);
910 }
911
912=== modified file 'tests/unit-tests/graphics/android/test_fb_simple_swapper.cpp'
913--- tests/unit-tests/graphics/android/test_fb_simple_swapper.cpp 2014-12-20 01:59:45 +0000
914+++ tests/unit-tests/graphics/android/test_fb_simple_swapper.cpp 2015-01-07 20:57:51 +0000
915@@ -157,7 +157,7 @@
916 .Times(fbnum)
917 .WillRepeatedly(Return(nullptr));
918
919- mga::Framebuffers framebuffers(mock_allocator, mock_fb_hal);
920+ mga::Framebuffers framebuffers(mock_allocator, display_size, vrefresh_hz, mock_fb_hal);
921 EXPECT_EQ(display_size, framebuffers.fb_size());
922 EXPECT_EQ(mir_pixel_format_abgr_8888, framebuffers.fb_format());
923 }
924@@ -171,12 +171,12 @@
925 .Times(2)
926 .WillRepeatedly(Return(nullptr));
927
928- mga::Framebuffers framebuffers(mock_allocator, slightly_malformed_fb_hal_mock);
929+ mga::Framebuffers framebuffers(mock_allocator, display_size, vrefresh_hz, slightly_malformed_fb_hal_mock);
930 }
931
932 TEST_F(PostingFBBundleTest, last_rendered_returns_valid)
933 {
934- mga::Framebuffers framebuffers(mock_allocator, mock_fb_hal);
935+ mga::Framebuffers framebuffers(mock_allocator, display_size, vrefresh_hz, mock_fb_hal);
936
937 auto test_buffer = framebuffers.last_rendered_buffer();
938 EXPECT_TRUE((test_buffer == buffer1) || (test_buffer == buffer2));
939
940=== modified file 'tests/unit-tests/graphics/android/test_hwc_common_device.cpp'
941--- tests/unit-tests/graphics/android/test_hwc_common_device.cpp 2014-12-20 01:59:45 +0000
942+++ tests/unit-tests/graphics/android/test_hwc_common_device.cpp 2015-01-07 20:57:51 +0000
943@@ -41,15 +41,6 @@
944 namespace mtd=mir::test::doubles;
945 namespace geom=mir::geometry;
946
947-namespace
948-{
949-struct MockDisplayConfiguration : mga::HwcConfiguration
950-{
951- MOCK_METHOD2(power_mode, void(mga::DisplayName, MirPowerMode));
952- MOCK_METHOD1(active_attribs_for, mga::DisplayAttribs(mga::DisplayName));
953-};
954-}
955-
956 template<typename T>
957 class HWCCommon : public ::testing::Test
958 {
959@@ -59,7 +50,6 @@
960 mock_fbdev = std::make_shared<mtd::MockFBHalDevice>();
961 mock_device = std::make_shared<testing::NiceMock<mtd::MockHWCDeviceWrapper>>();
962 mock_vsync = std::make_shared<testing::NiceMock<mtd::MockVsyncCoordinator>>();
963- mock_config = std::make_shared<testing::NiceMock<MockDisplayConfiguration>>();
964 }
965
966 std::shared_ptr<mga::DisplayDevice> make_display_device();
967@@ -68,19 +58,18 @@
968 std::shared_ptr<mtd::MockVsyncCoordinator> mock_vsync;
969 std::shared_ptr<mtd::MockHWCDeviceWrapper> mock_device;
970 std::shared_ptr<mtd::MockFBHalDevice> mock_fbdev;
971- std::shared_ptr<MockDisplayConfiguration> mock_config;
972 };
973
974 template <>
975 std::shared_ptr<mga::DisplayDevice> HWCCommon<mga::HwcFbDevice>::make_display_device()
976 {
977- return std::make_shared<mga::HwcFbDevice>(mock_device, mock_fbdev, mock_config, mock_vsync);
978+ return std::make_shared<mga::HwcFbDevice>(mock_device, mock_fbdev, mock_vsync);
979 }
980
981 template <>
982 std::shared_ptr<mga::DisplayDevice> HWCCommon<mga::HwcDevice>::make_display_device()
983 {
984- return std::make_shared<mga::HwcDevice>(mock_device, mock_config, mock_vsync, std::make_shared<mga::IntegerSourceCrop>());
985+ return std::make_shared<mga::HwcDevice>(mock_device, mock_vsync, std::make_shared<mga::IntegerSourceCrop>());
986 }
987
988 typedef ::testing::Types<mga::HwcFbDevice, mga::HwcDevice> HWCDeviceTestTypes;
989@@ -117,60 +106,3 @@
990 device = nullptr;
991 EXPECT_THAT(callbacks->self, Eq(nullptr));
992 }
993-
994-TYPED_TEST(HWCCommon, registers_hooks_before_turning_on_display)
995-{
996- using namespace testing;
997-
998- Sequence seq;
999- EXPECT_CALL(*this->mock_device, register_hooks(_))
1000- .InSequence(seq);
1001- EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_on))
1002- .InSequence(seq);
1003-
1004- auto device = this->make_display_device();
1005- testing::Mock::VerifyAndClearExpectations(this->mock_config.get());
1006-}
1007-
1008-TYPED_TEST(HWCCommon, test_hwc_display_is_deactivated_on_destroy)
1009-{
1010- auto device = this->make_display_device();
1011- EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off));
1012- device.reset();
1013-}
1014-
1015-TYPED_TEST(HWCCommon, catches_exception_during_destruction)
1016-{
1017- auto device = this->make_display_device();
1018- EXPECT_CALL(*this->mock_config, power_mode(mga::DisplayName::primary, mir_power_mode_off))
1019- .WillOnce(testing::Throw(std::runtime_error("")));
1020- device.reset();
1021-}
1022-
1023-TYPED_TEST(HWCCommon, callback_calls_hwcvsync)
1024-{
1025- using namespace testing;
1026- std::shared_ptr<mga::HWCCallbacks> callbacks;
1027- EXPECT_CALL(*(this->mock_device), register_hooks(_))
1028- .Times(1)
1029- .WillOnce(SaveArg<0>(&callbacks));
1030-
1031- auto device = this->make_display_device();
1032-
1033- EXPECT_CALL(*this->mock_vsync, notify_vsync())
1034- .Times(1);
1035- ASSERT_THAT(callbacks, Ne(nullptr));
1036- callbacks->hooks.vsync(&callbacks->hooks, 0, 0);
1037-
1038- callbacks->self = nullptr;
1039- callbacks->hooks.vsync(&callbacks->hooks, 0, 0);
1040-}
1041-
1042-TYPED_TEST(HWCCommon, first_power_on_is_not_fatal) //lp:1345533
1043-{
1044- ON_CALL(*this->mock_config, power_mode(testing::_, mir_power_mode_on))
1045- .WillByDefault(testing::Throw(std::runtime_error("error")));
1046- EXPECT_NO_THROW({
1047- auto device = this->make_display_device();
1048- });
1049-}
1050
1051=== modified file 'tests/unit-tests/graphics/android/test_hwc_configuration.cpp'
1052--- tests/unit-tests/graphics/android/test_hwc_configuration.cpp 2014-12-20 01:59:45 +0000
1053+++ tests/unit-tests/graphics/android/test_hwc_configuration.cpp 2015-01-07 20:57:51 +0000
1054@@ -42,18 +42,23 @@
1055 config.power_mode(display, mir_power_mode_on);
1056 }
1057
1058-TEST_F(HwcConfiguration, turns_screen_off)
1059+TEST_F(HwcConfiguration, turns_screen_off_for_off_suspend_and_standby)
1060 {
1061 testing::InSequence seq;
1062 EXPECT_CALL(*mock_hwc_wrapper, vsync_signal_off(display));
1063 EXPECT_CALL(*mock_hwc_wrapper, display_off(display));
1064- EXPECT_CALL(*mock_hwc_wrapper, vsync_signal_off(display));
1065- EXPECT_CALL(*mock_hwc_wrapper, display_off(display));
1066+ EXPECT_CALL(*mock_hwc_wrapper, display_on(display));
1067+ EXPECT_CALL(*mock_hwc_wrapper, vsync_signal_on(display));
1068 EXPECT_CALL(*mock_hwc_wrapper, vsync_signal_off(display));
1069 EXPECT_CALL(*mock_hwc_wrapper, display_off(display));
1070 config.power_mode(display, mir_power_mode_off);
1071
1072 //HWC version 1.3 and prior do not support anything more than on and off.
1073+ config.power_mode(display, mir_power_mode_suspend);
1074+ config.power_mode(display, mir_power_mode_off);
1075+ config.power_mode(display, mir_power_mode_standby);
1076+ config.power_mode(display, mir_power_mode_on);
1077+ config.power_mode(display, mir_power_mode_standby);
1078 //translate this into blanking the screen
1079 config.power_mode(display, mir_power_mode_suspend);
1080 config.power_mode(display, mir_power_mode_standby);
1081
1082=== modified file 'tests/unit-tests/graphics/android/test_hwc_device.cpp'
1083--- tests/unit-tests/graphics/android/test_hwc_device.cpp 2014-12-20 01:59:45 +0000
1084+++ tests/unit-tests/graphics/android/test_hwc_device.cpp 2015-01-07 20:57:51 +0000
1085@@ -50,12 +50,6 @@
1086
1087 namespace
1088 {
1089-struct StubConfig : public mga::HwcConfiguration
1090-{
1091- void power_mode(mga::DisplayName, MirPowerMode) override {}
1092- mga::DisplayAttribs active_attribs_for(mga::DisplayName) override { return {{}, {}, 0.0, false}; }
1093-};
1094-
1095 struct MockFileOps : public mga::SyncFileOps
1096 {
1097 MOCK_METHOD3(ioctl, int(int,int,void*));
1098@@ -105,8 +99,7 @@
1099 mock_device(std::make_shared<testing::NiceMock<mtd::MockHWCDeviceWrapper>>()),
1100 stub_context{stub_fb_buffer},
1101 renderlist({stub_renderable1, stub_renderable2}),
1102- layer_adapter{std::make_shared<mga::IntegerSourceCrop>()},
1103- stub_config{std::make_shared<StubConfig>()}
1104+ layer_adapter{std::make_shared<mga::IntegerSourceCrop>()}
1105 {
1106 fill_hwc_layer(layer, &comp_rect, position1, *stub_buffer1, HWC_FRAMEBUFFER, 0);
1107 fill_hwc_layer(layer2, &comp2_rect, position2, *stub_buffer2, HWC_FRAMEBUFFER, 0);
1108@@ -152,7 +145,6 @@
1109 mtd::StubSwappingGLContext stub_context;
1110 mg::RenderableList renderlist;
1111 std::shared_ptr<mga::LayerAdapter> const layer_adapter;
1112- std::shared_ptr<mga::HwcConfiguration> const stub_config;
1113 };
1114 }
1115
1116@@ -168,7 +160,7 @@
1117 EXPECT_CALL(*mock_device, prepare(MatchesPrimaryList(expected_list)))
1118 .Times(1);
1119
1120- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1121+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1122 device.post_gl(stub_context);
1123 }
1124
1125@@ -202,7 +194,7 @@
1126 EXPECT_CALL(mock_compositor, render(expected_renderable_list,Ref(stub_context)))
1127 .InSequence(seq);
1128
1129- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1130+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1131 EXPECT_TRUE(device.post_overlays(stub_context, renderlist, mock_compositor));
1132 }
1133
1134@@ -227,7 +219,7 @@
1135 .InSequence(seq);
1136 EXPECT_CALL(*mock_device, prepare(MatchesPrimaryList(expected_list2)))
1137 .InSequence(seq);
1138- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1139+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1140
1141 EXPECT_TRUE(device.post_overlays(stub_context, renderlist, stub_compositor));
1142 device.post_gl(stub_context);
1143@@ -260,7 +252,7 @@
1144 EXPECT_CALL(*mock_native_buffer3, update_usage(fb_release_fence, mga::BufferAccess::read))
1145 .InSequence(seq);
1146
1147- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1148+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1149 device.post_gl(stub_context);
1150
1151 //check that the retire fence is closed
1152@@ -292,7 +284,7 @@
1153 &target_layer
1154 };
1155
1156- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1157+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1158
1159 EXPECT_CALL(*mock_native_buffer1, copy_fence())
1160 .Times(0);
1161@@ -346,7 +338,7 @@
1162 &target_layer
1163 };
1164
1165- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1166+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1167
1168 EXPECT_CALL(*mock_native_buffer3, copy_fence())
1169 .Times(0);
1170@@ -384,7 +376,7 @@
1171 EXPECT_CALL(*mock_device, set(_))
1172 .Times(1);
1173
1174- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1175+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1176 EXPECT_TRUE(device.post_overlays(stub_context, renderlist, stub_compositor));
1177 EXPECT_FALSE(device.post_overlays(stub_context, renderlist, stub_compositor));
1178 }
1179@@ -392,7 +384,7 @@
1180 TEST_F(HwcDevice, submits_every_time_if_at_least_one_layer_is_gl_rendered)
1181 {
1182 using namespace testing;
1183- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1184+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1185
1186 ON_CALL(*mock_device, prepare(_))
1187 .WillByDefault(Invoke([&](std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> const& contents)
1188@@ -415,7 +407,7 @@
1189 using namespace testing;
1190 mg::RenderableList renderlist({stub_renderable1});
1191 mg::RenderableList renderlist2({stub_renderable2});
1192- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1193+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1194
1195 std::list<hwc_layer_1_t*> expected_list1 { &layer, &target_layer };
1196 std::list<hwc_layer_1_t*> expected_list2 { &layer2, &target_layer };
1197@@ -439,7 +431,7 @@
1198 .WillOnce(Invoke(set_all_layers_to_overlay))
1199 .WillOnce(Return());
1200
1201- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1202+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1203
1204 auto use_count_before = stub_buffer1.use_count();
1205 EXPECT_TRUE(device.post_overlays(stub_context, {stub_renderable1}, stub_compositor));
1206@@ -522,7 +514,7 @@
1207 .InSequence(seq)
1208 .WillOnce(Invoke(set_fences_fn));
1209
1210- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1211+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1212 EXPECT_TRUE(device.post_overlays(stub_context, renderlist, stub_compositor));
1213 //set only the 2nd layer to a new buffer. the first buffer has the same buffer, and would
1214 //still be onscreen if this wasn't against a mock
1215@@ -541,7 +533,7 @@
1216 contents[0]->hwLayers[1].compositionType = HWC_FRAMEBUFFER_TARGET;
1217 }));
1218
1219- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1220+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1221
1222 auto use_count_before = stub_buffer1.use_count();
1223 EXPECT_TRUE(device.post_overlays(stub_context, {stub_renderable1}, stub_compositor));
1224@@ -550,7 +542,7 @@
1225
1226 TEST_F(HwcDevice, rejects_empty_list)
1227 {
1228- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1229+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1230
1231 std::list<std::shared_ptr<mg::Renderable>> renderlist{};
1232 EXPECT_FALSE(device.post_overlays(stub_context, renderlist, stub_compositor));
1233@@ -559,7 +551,7 @@
1234 //TODO: we could accept a 90 degree transform
1235 TEST_F(HwcDevice, rejects_list_containing_transformed)
1236 {
1237- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1238+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1239
1240 auto renderable = std::make_shared<mtd::StubTransformedRenderable>();
1241 mg::RenderableList renderlist{renderable};
1242@@ -571,7 +563,7 @@
1243 {
1244 using namespace testing;
1245
1246- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1247+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1248
1249 mg::RenderableList renderlist{std::make_shared<mtd::PlaneAlphaRenderable>()};
1250 EXPECT_FALSE(device.post_overlays(stub_context, renderlist, stub_compositor));
1251@@ -583,13 +575,13 @@
1252 EXPECT_CALL(*mock_device, prepare(_))
1253 .WillOnce(Invoke(set_all_layers_to_overlay));
1254
1255- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1256+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1257
1258 auto use_count_before = stub_buffer1.use_count();
1259 EXPECT_TRUE(device.post_overlays(stub_context, {stub_renderable1}, stub_compositor));
1260 EXPECT_THAT(stub_buffer1.use_count(), Gt(use_count_before));
1261
1262- device.mode(MirPowerMode::mir_power_mode_off);
1263+ device.content_cleared();
1264 EXPECT_THAT(stub_buffer1.use_count(), Eq(use_count_before));
1265 }
1266
1267@@ -678,7 +670,7 @@
1268 .InSequence(seq);
1269 //end second post
1270
1271- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1272+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1273 EXPECT_TRUE(device.post_overlays(stub_context, renderlist1, stub_compositor));
1274
1275 EXPECT_TRUE(device.post_overlays(stub_context, renderlist2, stub_compositor));
1276@@ -780,7 +772,7 @@
1277 .InSequence(seq);
1278 //end second post
1279
1280- mga::HwcDevice device(mock_device, stub_config, mock_vsync, layer_adapter);
1281+ mga::HwcDevice device(mock_device, mock_vsync, layer_adapter);
1282 EXPECT_TRUE(device.post_overlays(stub_context, renderlist, stub_compositor));
1283 EXPECT_TRUE(device.post_overlays(stub_context, renderlist2, stub_compositor));
1284 }
1285
1286=== modified file 'tests/unit-tests/graphics/android/test_hwc_fb_device.cpp'
1287--- tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2014-12-20 01:59:45 +0000
1288+++ tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2015-01-07 20:57:51 +0000
1289@@ -43,11 +43,6 @@
1290
1291 namespace
1292 {
1293-struct StubConfig : public mga::HwcConfiguration
1294-{
1295- void power_mode(mga::DisplayName, MirPowerMode) override {}
1296- mga::DisplayAttribs active_attribs_for(mga::DisplayName) override { return {{}, {}, 0.0, false}; }
1297-};
1298 class HwcFbDevice : public ::testing::Test
1299 {
1300 protected:
1301@@ -85,8 +80,6 @@
1302 .WillByDefault(Return(stub_native_buffer));
1303 ON_CALL(mock_context, last_rendered_buffer())
1304 .WillByDefault(Return(mock_buffer));
1305-
1306- stub_config = std::make_shared<StubConfig>();
1307 }
1308
1309 int fake_dpy = 0;
1310@@ -104,7 +97,6 @@
1311 std::shared_ptr<mtd::StubAndroidNativeBuffer> stub_native_buffer;
1312 mtd::StubSwappingGLContext stub_context;
1313 testing::NiceMock<mtd::MockSwappingGLContext> mock_context;
1314- std::shared_ptr<mga::HwcConfiguration> stub_config;
1315 hwc_layer_1_t skip_layer;
1316 };
1317 }
1318@@ -126,7 +118,7 @@
1319 EXPECT_CALL(*mock_hwc_device_wrapper, set(MatchesListWithEglFields(expected_list, dpy, sur)))
1320 .InSequence(seq);
1321
1322- mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, stub_config, mock_vsync);
1323+ mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, mock_vsync);
1324
1325 device.post_gl(mock_context);
1326 }
1327@@ -143,7 +135,7 @@
1328 renderable2
1329 };
1330
1331- mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, stub_config, mock_vsync);
1332+ mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, mock_vsync);
1333 EXPECT_FALSE(device.post_overlays(stub_context, renderlist, stub_compositor));
1334 }
1335
1336@@ -162,6 +154,6 @@
1337 .InSequence(seq);
1338 EXPECT_CALL(*mock_vsync, wait_for_vsync())
1339 .InSequence(seq);
1340- mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, stub_config, mock_vsync);
1341+ mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device, mock_vsync);
1342 device.post_gl(mock_context);
1343 }

Subscribers

People subscribed via source and target branches