Mir

Merge lp:~andreas-pokorny/mir/add-pixel-format-to-display-configuration into lp:mir/0.1

Proposed by Andreas Pokorny on 2014-01-02
Status: Superseded
Proposed branch: lp:~andreas-pokorny/mir/add-pixel-format-to-display-configuration
Merge into: lp:mir/0.1
Diff against target: 2751 lines (+957/-452)
58 files modified
benchmarks/CMakeLists.txt (+3/-1)
doc/building_source_for_android.md (+21/-32)
examples/demo-shell/window_manager.cpp (+2/-1)
examples/server_configuration.cpp (+8/-4)
include/platform/mir/graphics/display_configuration.h (+3/-3)
include/platform/mir/graphics/pixel_format_utils.h (+50/-0)
include/platform/mir/graphics/platform.h (+1/-1)
include/shared/mir/logging/input_timestamp.h (+35/-0)
include/shared/mir_toolkit/client_types.h (+1/-1)
include/test/mir_test_doubles/mock_surface_renderer.h (+2/-1)
include/test/mir_test_doubles/null_display_configuration.h (+1/-1)
include/test/mir_test_doubles/stub_display_configuration.h (+6/-5)
src/client/display_configuration.cpp (+1/-1)
src/client/logging/input_receiver_report.cpp (+3/-2)
src/platform/graphics/CMakeLists.txt (+1/-0)
src/platform/graphics/android/android_display_configuration.cpp (+4/-2)
src/platform/graphics/android/android_display_configuration.h (+1/-1)
src/platform/graphics/mesa/real_kms_display_configuration.cpp (+64/-40)
src/platform/graphics/mesa/real_kms_display_configuration.h (+2/-2)
src/platform/graphics/pixel_format_utils.cpp (+71/-0)
src/server/compositor/default_display_buffer_compositor.cpp (+2/-1)
src/server/compositor/gl_renderer.cpp (+28/-33)
src/server/compositor/gl_renderer.h (+12/-22)
src/server/compositor/renderer.h (+2/-1)
src/server/frontend/protobuf_buffer_packer.cpp (+1/-1)
src/server/frontend/session_mediator.cpp (+3/-1)
src/server/graphics/default_display_configuration_policy.cpp (+54/-19)
src/server/graphics/nested/nested_display.cpp (+42/-57)
src/server/graphics/nested/nested_display.h (+6/-5)
src/server/graphics/nested/nested_display_configuration.cpp (+35/-10)
src/server/graphics/nested/nested_display_configuration.h (+1/-1)
src/server/graphics/nested/nested_output.cpp (+3/-2)
src/server/graphics/nested/nested_output.h (+2/-1)
src/server/graphics/nested/nested_platform.cpp (+2/-2)
src/server/graphics/nested/nested_platform.h (+5/-5)
src/server/graphics/offscreen/display_configuration.cpp (+4/-2)
src/server/graphics/offscreen/display_configuration.h (+4/-4)
src/server/logging/input_report.cpp (+4/-3)
src/server/scene/mediating_display_changer.cpp (+1/-0)
src/shared/logging/CMakeLists.txt (+1/-0)
src/shared/logging/input_timestamp.cpp (+41/-0)
tests/acceptance-tests/test_server_shutdown.cpp (+5/-1)
tests/integration-tests/test_session.cpp (+4/-1)
tests/integration-tests/test_surface_first_frame_sync.cpp (+5/-1)
tests/mir_test/display_config_matchers.cpp (+2/-2)
tests/mir_test_framework/stubbed_server_configuration.cpp (+6/-2)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+63/-2)
tests/unit-tests/frontend/test_session_mediator.cpp (+7/-3)
tests/unit-tests/graphics/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/android/test_android_fb.cpp (+22/-22)
tests/unit-tests/graphics/mesa/test_cursor.cpp (+7/-7)
tests/unit-tests/graphics/mesa/test_display_configuration.cpp (+7/-7)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+16/-6)
tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp (+2/-2)
tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp (+27/-11)
tests/unit-tests/graphics/test_default_display_configuration_policy.cpp (+159/-116)
tests/unit-tests/graphics/test_display_configuration.cpp (+1/-1)
tests/unit-tests/graphics/test_pixel_format_utils.cpp (+90/-0)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/add-pixel-format-to-display-configuration
Reviewer Review Type Date Requested Status
Mir development team 2014-01-02 Pending
Review via email: mp+200292@code.launchpad.net

This proposal has been superseded by a proposal from 2014-01-02.

Description of the change

Adds a mir pixel format parameter to DisplayConfiguration::configure_output

So within DisplayConfigurationPolicy the format can be specified for each output.
The pixel format parameter is still ignored by android and also mesa to some degree,
which only validates it. It is supported by nested display. The default configuration
policy implementation tries to select an opaque format though.

To post a comment you must log in.
1308. By Andreas Pokorny on 2014-01-02

Provide opaque pixel formats to clients

Up to now only transparent pixel formats were advertized in the DisplayOutput structure
on android. Since with that MP the available formats are scanned for opaque and transparent
ones and then used in nested_display the format array must be more complete.

1309. By Andreas Pokorny on 2014-01-02

Invalid read fix in test case

1310. By Andreas Pokorny on 2014-01-07

abi bump and prerequisite branch updated

1311. By Andreas Pokorny on 2014-01-08

Android fixes

1312. By Andreas Pokorny on 2014-01-08

merged undoing of PixelFormat wrapper

1313. By Andreas Pokorny on 2014-01-09

more reasonable opaque format selection, and turned chnage into a real API change for the client_types

1314. By Andreas Pokorny on 2014-01-10

duplicate namespaces aliases removed

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'benchmarks/CMakeLists.txt'
2--- benchmarks/CMakeLists.txt 2013-10-15 10:10:05 +0000
3+++ benchmarks/CMakeLists.txt 2014-01-02 11:14:12 +0000
4@@ -2,7 +2,9 @@
5 benchmarks
6 )
7
8-add_subdirectory(android-input)
9+if (MIR_ENABLE_TESTS)
10+ add_subdirectory(android-input)
11+endif ()
12 add_subdirectory(cpu)
13 add_subdirectory(memory)
14
15
16=== modified file 'doc/building_source_for_android.md'
17--- doc/building_source_for_android.md 2013-12-17 18:24:51 +0000
18+++ doc/building_source_for_android.md 2014-01-02 11:14:12 +0000
19@@ -51,35 +51,24 @@
20 ubuntu package) to produce armhf code. This is typically the quickest way to
21 compile and run code, and is well suited for a development workflow.
22
23-- Be sure that the cross compiler that you are using matches the target
24- environment. (eg, make sure you're using the trusty toolchain if you're
25- targeting a trusty phablet image) You can specify the toolchain version
26- thusly:
27-
28- $ apt-get install g++-arm-linux-gnueabihf/trusty
29-
30-- Get access to armhf packages via apt-get. On an amd64/ia32 system, you can
31- do this by adding a file like the one below to /etc/apt/sources.list.d/
32-
33- #example sources.list with armhf dependencies
34- deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse
35-
36- Then you should run:
37-
38- $ apt-get update
39-
40- To test, try downloading a package like this:
41-
42- $ apt-get download my-package:armhf
43-
44-- Once you're able to download armhf packages from the repository, the
45- cross-compile-chroot.sh script provides an example of how to download
46- a partial chroot with the mir dependencies, and compile the source for
47- android targets.
48-
49- The script sets up a partial chroot via tools/setup-partial-armhf-chroot.sh
50- and then runs build commands similar to this:
51-
52- $ mkdir mir/build; cd mir/build
53- $ MIR_NDK_PATH=/path/to/depenendcies/chroot cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake -DBoost_COMPILER=-gcc -DMIR_PLATFORM=android ..
54- $ make
55+Initial setup of a desktop machine for cross-compiling to armhf is simple:
56+
57+ $ sudo apt-get install g++-arm-linux-gnueabihf/trusty debootstrap
58+ $ sudo sh -c 'echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse" > /etc/apt/sources.list.d/armhf-xcompile.list'
59+ $ sudo apt-get update
60+
61+Now to test that everything is working you can try downloading a package like
62+this:
63+
64+ $ apt-get download gcc:armhf
65+
66+Once you're able to download armhf packages from the repository, the
67+cross-compile-chroot.sh script provides an example of how to build Mir for
68+armhf:
69+
70+ $ ./cross-compile-chroot.sh
71+ $ ls -l build-android-arm/* # binaries to copy to your device
72+
73+To speed up the process for future branches you may wish to cache the files
74+downloaded by setting environment variable MIR_NDK_PATH to point to a directory
75+that cross-compile-chroot.sh should reuse each time.
76
77=== modified file 'examples/demo-shell/window_manager.cpp'
78--- examples/demo-shell/window_manager.cpp 2013-12-17 18:24:51 +0000
79+++ examples/demo-shell/window_manager.cpp 2014-01-02 11:14:12 +0000
80@@ -151,8 +151,9 @@
81 power_mode = mir_power_mode_off;
82
83 conf->configure_output(output.id, output.used,
84- output.top_left,
85+ output.top_left,
86 output.current_mode_index,
87+ output.current_format,
88 power_mode);
89 });
90 display_off = !display_off;
91
92=== modified file 'examples/server_configuration.cpp'
93--- examples/server_configuration.cpp 2013-10-21 10:40:19 +0000
94+++ examples/server_configuration.cpp 2014-01-02 11:14:12 +0000
95@@ -61,14 +61,16 @@
96 available_outputs_for_card[conf_output.card_id] > 0)
97 {
98 conf.configure_output(conf_output.id, true, geom::Point{max_x, 0},
99- preferred_mode_index, mir_power_mode_on);
100+ preferred_mode_index, conf_output.current_format,
101+ mir_power_mode_on);
102 max_x += conf_output.modes[preferred_mode_index].size.width.as_int();
103 --available_outputs_for_card[conf_output.card_id];
104 }
105 else
106 {
107 conf.configure_output(conf_output.id, false, conf_output.top_left,
108- conf_output.current_mode_index, mir_power_mode_on);
109+ conf_output.current_mode_index, conf_output.current_format,
110+ mir_power_mode_on);
111 }
112 });
113 }
114@@ -88,13 +90,15 @@
115 if (!done && conf_output.connected && conf_output.modes.size() > 0)
116 {
117 conf.configure_output(conf_output.id, true, geom::Point{0, 0},
118- preferred_mode_index, mir_power_mode_on);
119+ preferred_mode_index, conf_output.current_format,
120+ mir_power_mode_on);
121 done = true;
122 }
123 else
124 {
125 conf.configure_output(conf_output.id, false, conf_output.top_left,
126- conf_output.current_mode_index, mir_power_mode_on);
127+ conf_output.current_mode_index, conf_output.current_format,
128+ mir_power_mode_on);
129 }
130 });
131 }
132
133=== modified file 'include/platform/mir/graphics/display_configuration.h'
134--- include/platform/mir/graphics/display_configuration.h 2013-12-17 18:24:51 +0000
135+++ include/platform/mir/graphics/display_configuration.h 2014-01-02 11:14:12 +0000
136@@ -104,7 +104,7 @@
137 /** The index in the 'modes' vector of the current output mode. */
138 size_t current_mode_index;
139 /** The index in the 'pixel_format' vector of the current output pixel format. */
140- size_t current_format_index;
141+ MirPixelFormat current_format;
142 /** Current power mode **/
143 MirPowerMode power_mode;
144 };
145@@ -135,8 +135,8 @@
146 virtual void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const = 0;
147
148 /** Configures an output. */
149- virtual void configure_output(DisplayConfigurationOutputId id, bool used,
150- geometry::Point top_left, size_t mode_index, MirPowerMode power_mode) = 0;
151+ virtual void configure_output(DisplayConfigurationOutputId id, bool used, geometry::Point top_left,
152+ size_t mode_index, MirPixelFormat format, MirPowerMode power_mode) = 0;
153
154 protected:
155 DisplayConfiguration() = default;
156
157=== added file 'include/platform/mir/graphics/pixel_format_utils.h'
158--- include/platform/mir/graphics/pixel_format_utils.h 1970-01-01 00:00:00 +0000
159+++ include/platform/mir/graphics/pixel_format_utils.h 2014-01-02 11:14:12 +0000
160@@ -0,0 +1,50 @@
161+/*
162+ * Copyright © 2013 Canonical Ltd.
163+ *
164+ * This program is free software: you can redistribute it and/or modify it
165+ * under the terms of the GNU Lesser General Public License version 3,
166+ * as published by the Free Software Foundation.
167+ *
168+ * This program is distributed in the hope that it will be useful,
169+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
170+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171+ * GNU Lesser General Public License for more details.
172+ *
173+ * You should have received a copy of the GNU Lesser General Public License
174+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
175+ *
176+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
177+ */
178+
179+#ifndef MIR_GRAPHICS_PIXEL_FORMAT_UTILS_H_
180+#define MIR_GRAPHICS_PIXEL_FORMAT_UTILS_H_
181+
182+#include "mir_toolkit/common.h"
183+
184+namespace mir
185+{
186+namespace graphics
187+{
188+
189+/*!
190+ * \name MirPixelFormat utility functions
191+ *
192+ * A set of functions to query details of MirPixelFormat
193+ * TODO improve this through https://bugs.launchpad.net/mir/+bug/1236254
194+ * \{
195+ */
196+bool contains_alpha(MirPixelFormat format);
197+int red_channel_depth(MirPixelFormat format);
198+int blue_channel_depth(MirPixelFormat format);
199+int green_channel_depth(MirPixelFormat format);
200+int alpha_channel_depth(MirPixelFormat format);
201+bool valid_mir_pixel_format(MirPixelFormat format);
202+/*!
203+ * \}
204+ */
205+
206+
207+}
208+}
209+
210+#endif
211
212=== modified file 'include/platform/mir/graphics/platform.h'
213--- include/platform/mir/graphics/platform.h 2013-12-17 18:24:51 +0000
214+++ include/platform/mir/graphics/platform.h 2014-01-02 11:14:12 +0000
215@@ -81,7 +81,7 @@
216 * Creates the display subsystem.
217 */
218 virtual std::shared_ptr<Display> create_display(
219- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy) = 0;
220+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy) = 0;
221
222 /**
223 * Gets the IPC package for the platform.
224
225=== added file 'include/shared/mir/logging/input_timestamp.h'
226--- include/shared/mir/logging/input_timestamp.h 1970-01-01 00:00:00 +0000
227+++ include/shared/mir/logging/input_timestamp.h 2014-01-02 11:14:12 +0000
228@@ -0,0 +1,35 @@
229+/*
230+ * Copyright © 2013 Canonical Ltd.
231+ *
232+ * This program is free software: you can redistribute it and/or modify it
233+ * under the terms of the GNU Lesser General Public License version 3,
234+ * as published by the Free Software Foundation.
235+ *
236+ * This program is distributed in the hope that it will be useful,
237+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
238+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
239+ * GNU Lesser General Public License for more details.
240+ *
241+ * You should have received a copy of the GNU Lesser General Public License
242+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
243+ *
244+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
245+ */
246+
247+#ifndef MIR_LOGGING_INPUT_TIMESTAMP_H_
248+#define MIR_LOGGING_INPUT_TIMESTAMP_H_
249+
250+#include "mir_toolkit/event.h"
251+#include <string>
252+
253+namespace mir
254+{
255+namespace logging
256+{
257+
258+std::string input_timestamp(nsecs_t when);
259+
260+}
261+}
262+
263+#endif // MIR_LOGGING_INPUT_TIMESTAMP_H_
264
265=== modified file 'include/shared/mir_toolkit/client_types.h'
266--- include/shared/mir_toolkit/client_types.h 2013-12-17 18:24:51 +0000
267+++ include/shared/mir_toolkit/client_types.h 2014-01-02 11:14:12 +0000
268@@ -230,7 +230,7 @@
269
270 uint32_t num_output_formats;
271 MirPixelFormat* output_formats;
272- uint32_t current_output_format;
273+ MirPixelFormat current_output_format;
274
275 uint32_t card_id;
276 uint32_t output_id;
277
278=== modified file 'include/test/mir_test_doubles/mock_surface_renderer.h'
279--- include/test/mir_test_doubles/mock_surface_renderer.h 2013-12-17 18:24:51 +0000
280+++ include/test/mir_test_doubles/mock_surface_renderer.h 2014-01-02 11:14:12 +0000
281@@ -31,8 +31,9 @@
282
283 struct MockSurfaceRenderer : public compositor::Renderer
284 {
285+ MOCK_CONST_METHOD0(begin, void());
286 MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&));
287- MOCK_CONST_METHOD0(clear, void());
288+ MOCK_CONST_METHOD0(end, void());
289
290 ~MockSurfaceRenderer() noexcept {}
291 };
292
293=== modified file 'include/test/mir_test_doubles/null_display_configuration.h'
294--- include/test/mir_test_doubles/null_display_configuration.h 2013-09-12 21:36:55 +0000
295+++ include/test/mir_test_doubles/null_display_configuration.h 2014-01-02 11:14:12 +0000
296@@ -35,7 +35,7 @@
297 void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)>) const
298 {
299 }
300- void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPowerMode) override
301+ void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPixelFormat, MirPowerMode) override
302 {
303 }
304 };
305
306=== modified file 'include/test/mir_test_doubles/stub_display_configuration.h'
307--- include/test/mir_test_doubles/stub_display_configuration.h 2013-12-17 18:24:51 +0000
308+++ include/test/mir_test_doubles/stub_display_configuration.h 2014-01-02 11:14:12 +0000
309@@ -79,7 +79,7 @@
310 ((i % 2) == 0),
311 ((i % 2) == 1),
312 top_left,
313- mode_index, 1u,
314+ mode_index, pfs[1u],
315 mir_power_mode_off
316 };
317
318@@ -107,7 +107,8 @@
319 graphics::DisplayConfigurationOutputType::vga,
320 std::vector<MirPixelFormat>{mir_pixel_format_abgr_8888},
321 {{rect.size, 60.0}},
322- 0, geometry::Size{}, true, true, rect.top_left, 0, 0, mir_power_mode_on
323+ 0, geometry::Size{}, true, true, rect.top_left, 0,
324+ mir_pixel_format_abgr_8888, mir_power_mode_on
325 };
326
327 outputs.push_back(output);
328@@ -122,13 +123,13 @@
329 cards.push_back(card);
330 }
331
332- void for_each_card(std::function<void(graphics::DisplayConfigurationCard const&)> f) const
333+ void for_each_card(std::function<void(graphics::DisplayConfigurationCard const&)> f) const override
334 {
335 for (auto const& card : cards)
336 f(card);
337 }
338
339- void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)> f) const
340+ void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)> f) const override
341 {
342 for (auto& disp : outputs)
343 {
344@@ -136,7 +137,7 @@
345 }
346 }
347
348- void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPowerMode)
349+ void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPixelFormat, MirPowerMode) override
350 {
351 }
352
353
354=== modified file 'src/client/display_configuration.cpp'
355--- src/client/display_configuration.cpp 2013-12-17 18:24:51 +0000
356+++ src/client/display_configuration.cpp 2014-01-02 11:14:12 +0000
357@@ -88,7 +88,7 @@
358 {
359 output.output_formats[i] = static_cast<MirPixelFormat>(msg.pixel_format(i));
360 }
361- output.current_output_format = msg.current_format();
362+ output.current_output_format = static_cast<MirPixelFormat>(msg.current_format());
363
364 output.position_x = msg.position_x();
365 output.position_y = msg.position_y();
366
367=== modified file 'src/client/logging/input_receiver_report.cpp'
368--- src/client/logging/input_receiver_report.cpp 2013-12-17 18:24:51 +0000
369+++ src/client/logging/input_receiver_report.cpp 2014-01-02 11:14:12 +0000
370@@ -19,6 +19,7 @@
371 #include "input_receiver_report.h"
372
373 #include "mir/logging/logger.h"
374+#include "mir/logging/input_timestamp.h"
375
376 #include <boost/throw_exception.hpp>
377
378@@ -53,7 +54,7 @@
379 ss << " scan_code: " << ev.scan_code << std::endl;
380 ss << " repeat_count: " << ev.repeat_count << std::endl;
381 ss << " down_time: " << ev.down_time << std::endl;
382- ss << " event_time: " << ev.event_time << std::endl;
383+ ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl;
384 ss << " is_system_key: " << ev.is_system_key << std::endl;
385 ss << "}";
386 }
387@@ -73,7 +74,7 @@
388 ss << " x_precision: " << ev.x_precision << std::endl;
389 ss << " y_precision: " << ev.y_precision << std::endl;
390 ss << " down_time: " << ev.down_time << std::endl;
391- ss << " event_time: " << ev.event_time << std::endl;
392+ ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl;
393 ss << " pointer_count: " << ev.pointer_count << std::endl;
394 for (unsigned int i = 0; i < ev.pointer_count; i++)
395 {
396
397=== modified file 'src/platform/graphics/CMakeLists.txt'
398--- src/platform/graphics/CMakeLists.txt 2013-12-17 18:24:51 +0000
399+++ src/platform/graphics/CMakeLists.txt 2014-01-02 11:14:12 +0000
400@@ -10,6 +10,7 @@
401 display_configuration.cpp
402 null_display_report.cpp
403 buffer_basic.cpp
404+ pixel_format_utils.cpp
405 )
406
407 add_library(
408
409=== modified file 'src/platform/graphics/android/android_display_configuration.cpp'
410--- src/platform/graphics/android/android_display_configuration.cpp 2013-12-17 18:24:51 +0000
411+++ src/platform/graphics/android/android_display_configuration.cpp 2014-01-02 11:14:12 +0000
412@@ -31,7 +31,9 @@
413 true,
414 true,
415 geom::Point{0,0},
416- 0, 0, mir_power_mode_on},
417+ 0,
418+ mir_pixel_format_abgr_8888,
419+ mir_power_mode_on},
420 card{mg::DisplayConfigurationCardId{0}, 1}
421 {
422 }
423@@ -62,7 +64,7 @@
424 f(configuration);
425 }
426
427-void mga::AndroidDisplayConfiguration::configure_output(mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPowerMode power_mode)
428+void mga::AndroidDisplayConfiguration::configure_output(mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPixelFormat, MirPowerMode power_mode)
429 {
430 configuration.power_mode = power_mode;
431 }
432
433=== modified file 'src/platform/graphics/android/android_display_configuration.h'
434--- src/platform/graphics/android/android_display_configuration.h 2013-12-17 18:24:51 +0000
435+++ src/platform/graphics/android/android_display_configuration.h 2014-01-02 11:14:12 +0000
436@@ -37,7 +37,7 @@
437
438 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const;
439 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const;
440- void configure_output(DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPowerMode power_mode);
441+ void configure_output(DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPixelFormat, MirPowerMode power_mode);
442
443 private:
444 DisplayConfigurationOutput configuration;
445
446=== modified file 'src/platform/graphics/mesa/real_kms_display_configuration.cpp'
447--- src/platform/graphics/mesa/real_kms_display_configuration.cpp 2013-12-17 18:24:51 +0000
448+++ src/platform/graphics/mesa/real_kms_display_configuration.cpp 2014-01-02 11:14:12 +0000
449@@ -18,6 +18,7 @@
450
451 #include "real_kms_display_configuration.h"
452 #include "drm_mode_resources.h"
453+#include "mir/graphics/pixel_format_utils.h"
454
455 #include <cmath>
456 #include <limits>
457@@ -26,9 +27,15 @@
458 #include <stdexcept>
459 #include <algorithm>
460
461-namespace mg = mir::graphics;
462-namespace mgm = mir::graphics::mesa;
463-namespace geom = mir::geometry;
464+
465+namespace mir
466+{
467+namespace graphics
468+{
469+namespace mesa
470+{
471+
472+namespace geom = geometry;
473
474 namespace
475 {
476@@ -59,28 +66,33 @@
477 return round(vrefresh_hz * 10.0) / 10.0;
478 }
479
480-mg::DisplayConfigurationOutputType
481+DisplayConfigurationOutputType
482 kms_connector_type_to_output_type(uint32_t connector_type)
483 {
484- return static_cast<mg::DisplayConfigurationOutputType>(connector_type);
485-}
486-
487-}
488-
489-mgm::RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(int drm_fd)
490+ return static_cast<DisplayConfigurationOutputType>(connector_type);
491+}
492+
493+bool format_available_in_pixel_formats(MirPixelFormat format, DisplayConfigurationOutput const& output)
494+{
495+ return output.pixel_formats.end() != find(output.pixel_formats.begin(), output.pixel_formats.end(), format);
496+}
497+
498+}
499+
500+RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(int drm_fd)
501 : drm_fd{drm_fd}
502 {
503 update();
504 }
505
506-mgm::RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(
507+RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(
508 RealKMSDisplayConfiguration const& conf)
509 : KMSDisplayConfiguration(), drm_fd{conf.drm_fd},
510 card(conf.card), outputs{conf.outputs}
511 {
512 }
513
514-mgm::RealKMSDisplayConfiguration& mgm::RealKMSDisplayConfiguration::operator=(
515+RealKMSDisplayConfiguration& RealKMSDisplayConfiguration::operator=(
516 RealKMSDisplayConfiguration const& conf)
517 {
518 if (&conf != this)
519@@ -93,23 +105,23 @@
520 return *this;
521 }
522
523-void mgm::RealKMSDisplayConfiguration::for_each_card(
524+void RealKMSDisplayConfiguration::for_each_card(
525 std::function<void(DisplayConfigurationCard const&)> f) const
526 {
527 f(card);
528 }
529
530-void mgm::RealKMSDisplayConfiguration::for_each_output(
531+void RealKMSDisplayConfiguration::for_each_output(
532 std::function<void(DisplayConfigurationOutput const&)> f) const
533 {
534 for (auto const& output : outputs)
535 f(output);
536 }
537
538-void mgm::RealKMSDisplayConfiguration::configure_output(
539+void RealKMSDisplayConfiguration::configure_output(
540 DisplayConfigurationOutputId id, bool used,
541 geometry::Point top_left, size_t mode_index,
542- MirPowerMode power_mode)
543+ MirPixelFormat format, MirPowerMode power_mode)
544 {
545 auto iter = find_output_with_id(id);
546
547@@ -120,9 +132,15 @@
548 if (used && mode_index >= output.modes.size())
549 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid mode_index for used output"));
550
551+ if (used && !valid_mir_pixel_format(format))
552+ BOOST_THROW_EXCEPTION(std::runtime_error("Invalid format for used output"));
553+ if (used && !format_available_in_pixel_formats(format, output))
554+ BOOST_THROW_EXCEPTION(std::runtime_error("Format not available for used output"));
555+
556 output.used = used;
557 output.top_left = top_left;
558 output.current_mode_index = mode_index;
559+ output.current_format = format;
560 output.power_mode = power_mode;
561 }
562 else
563@@ -131,7 +149,7 @@
564 }
565 }
566
567-uint32_t mgm::RealKMSDisplayConfiguration::get_kms_connector_id(
568+uint32_t RealKMSDisplayConfiguration::get_kms_connector_id(
569 DisplayConfigurationOutputId id) const
570 {
571 auto iter = find_output_with_id(id);
572@@ -145,7 +163,7 @@
573 return id.as_value();
574 }
575
576-size_t mgm::RealKMSDisplayConfiguration::get_kms_mode_index(
577+size_t RealKMSDisplayConfiguration::get_kms_mode_index(
578 DisplayConfigurationOutputId id,
579 size_t conf_mode_index) const
580 {
581@@ -159,12 +177,12 @@
582
583 return conf_mode_index;
584 }
585-void mgm::RealKMSDisplayConfiguration::update()
586+void RealKMSDisplayConfiguration::update()
587 {
588 DRMModeResources resources{drm_fd};
589
590 size_t max_outputs = std::min(resources.num_crtcs(), resources.num_connectors());
591- card = {mg::DisplayConfigurationCardId{0}, max_outputs};
592+ card = {DisplayConfigurationCardId{0}, max_outputs};
593
594 resources.for_each_connector([&](DRMModeConnectorUPtr connector)
595 {
596@@ -172,7 +190,7 @@
597 });
598 }
599
600-void mgm::RealKMSDisplayConfiguration::add_or_update_output(
601+void RealKMSDisplayConfiguration::add_or_update_output(
602 DRMModeResources const& resources,
603 drmModeConnector const& connector)
604 {
605@@ -224,7 +242,8 @@
606 {
607 outputs.push_back({id, card_id, type, formats, modes, preferred_mode_index,
608 physical_size, connected, false, geom::Point(),
609- current_mode_index, 0u, mir_power_mode_on});
610+ current_mode_index, mir_pixel_format_xrgb_8888,
611+ mir_power_mode_on});
612 }
613 else
614 {
615@@ -235,25 +254,30 @@
616 output.physical_size_mm = physical_size;
617 output.connected = connected;
618 output.current_mode_index = current_mode_index;
619+ output.current_format = mir_pixel_format_xrgb_8888;
620 }
621 }
622
623-std::vector<mg::DisplayConfigurationOutput>::iterator
624-mgm::RealKMSDisplayConfiguration::find_output_with_id(DisplayConfigurationOutputId id)
625-{
626- return std::find_if(outputs.begin(), outputs.end(),
627- [id](DisplayConfigurationOutput const& output)
628- {
629- return output.id == id;
630- });
631-}
632-
633-std::vector<mg::DisplayConfigurationOutput>::const_iterator
634-mgm::RealKMSDisplayConfiguration::find_output_with_id(DisplayConfigurationOutputId id) const
635-{
636- return std::find_if(outputs.begin(), outputs.end(),
637- [id](DisplayConfigurationOutput const& output)
638- {
639- return output.id == id;
640- });
641+std::vector<DisplayConfigurationOutput>::iterator
642+RealKMSDisplayConfiguration::find_output_with_id(DisplayConfigurationOutputId id)
643+{
644+ return std::find_if(outputs.begin(), outputs.end(),
645+ [id](DisplayConfigurationOutput const& output)
646+ {
647+ return output.id == id;
648+ });
649+}
650+
651+std::vector<DisplayConfigurationOutput>::const_iterator
652+RealKMSDisplayConfiguration::find_output_with_id(DisplayConfigurationOutputId id) const
653+{
654+ return std::find_if(outputs.begin(), outputs.end(),
655+ [id](DisplayConfigurationOutput const& output)
656+ {
657+ return output.id == id;
658+ });
659+}
660+
661+}
662+}
663 }
664
665=== modified file 'src/platform/graphics/mesa/real_kms_display_configuration.h'
666--- src/platform/graphics/mesa/real_kms_display_configuration.h 2013-12-17 18:24:51 +0000
667+++ src/platform/graphics/mesa/real_kms_display_configuration.h 2014-01-02 11:14:12 +0000
668@@ -39,8 +39,8 @@
669
670 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const;
671 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const;
672- void configure_output(DisplayConfigurationOutputId id, bool used,
673- geometry::Point top_left, size_t mode_index, MirPowerMode power_mode);
674+ void configure_output(DisplayConfigurationOutputId id, bool used, geometry::Point top_left,
675+ size_t mode_index, MirPixelFormat format, MirPowerMode power_mode);
676
677 uint32_t get_kms_connector_id(DisplayConfigurationOutputId id) const;
678 size_t get_kms_mode_index(DisplayConfigurationOutputId id, size_t conf_mode_index) const;
679
680=== added file 'src/platform/graphics/pixel_format_utils.cpp'
681--- src/platform/graphics/pixel_format_utils.cpp 1970-01-01 00:00:00 +0000
682+++ src/platform/graphics/pixel_format_utils.cpp 2014-01-02 11:14:12 +0000
683@@ -0,0 +1,71 @@
684+/*
685+ * Copyright © 2013 Canonical Ltd.
686+ *
687+ * This program is free software: you can redistribute it and/or modify it
688+ * under the terms of the GNU Lesser General Public License version 3,
689+ * as published by the Free Software Foundation.
690+ *
691+ * This program is distributed in the hope that it will be useful,
692+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
693+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
694+ * GNU Lesser General Public License for more details.
695+ *
696+ * You should have received a copy of the GNU Lesser General Public License
697+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
698+ *
699+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
700+ */
701+
702+#include "mir/graphics/pixel_format_utils.h"
703+
704+namespace mir
705+{
706+namespace graphics
707+{
708+
709+bool contains_alpha(MirPixelFormat format)
710+{
711+ return (format == mir_pixel_format_abgr_8888 ||
712+ format == mir_pixel_format_argb_8888);
713+}
714+
715+int red_channel_depth(MirPixelFormat format)
716+{
717+ if (mir_pixel_format_invalid < format &&
718+ format < mir_pixel_formats)
719+ return 8;
720+ return 0;
721+}
722+
723+int blue_channel_depth(MirPixelFormat format)
724+{
725+ if (mir_pixel_format_invalid < format &&
726+ format < mir_pixel_formats)
727+ return 8;
728+ return 0;
729+}
730+
731+int green_channel_depth(MirPixelFormat format)
732+{
733+ if (mir_pixel_format_invalid < format &&
734+ format < mir_pixel_formats)
735+ return 8;
736+ return 0;
737+}
738+
739+int alpha_channel_depth(MirPixelFormat format)
740+{
741+ if (format == mir_pixel_format_abgr_8888 ||
742+ format == mir_pixel_format_argb_8888)
743+ return 8;
744+ return 0;
745+}
746+
747+bool valid_mir_pixel_format(MirPixelFormat format)
748+{
749+ return (format > mir_pixel_format_invalid &&
750+ format < mir_pixel_formats);
751+}
752+
753+}
754+}
755
756=== modified file 'src/server/compositor/default_display_buffer_compositor.cpp'
757--- src/server/compositor/default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000
758+++ src/server/compositor/default_display_buffer_compositor.cpp 2014-01-02 11:14:12 +0000
759@@ -135,10 +135,11 @@
760 mc::OcclusionMatch occlusion_match;
761 scene->reverse_for_each_if(occlusion_search, occlusion_match);
762
763- renderer->clear();
764+ renderer->begin();
765 mc::RenderingOperator applicator(*renderer, save_resource, local_frameno);
766 FilterForVisibleSceneInRegion selector(view_area, occlusion_match);
767 scene->for_each_if(selector, applicator);
768+ renderer->end();
769
770 display_buffer.post_update();
771 }
772
773=== modified file 'src/server/compositor/gl_renderer.cpp'
774--- src/server/compositor/gl_renderer.cpp 2013-12-17 18:24:51 +0000
775+++ src/server/compositor/gl_renderer.cpp 2014-01-02 11:14:12 +0000
776@@ -117,7 +117,7 @@
777
778 }
779
780-mc::GLRenderer::Resources::Resources() :
781+mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) :
782 vertex_shader(0),
783 fragment_shader(0),
784 program(0),
785@@ -128,24 +128,6 @@
786 vertex_attribs_vbo(0),
787 texture(0)
788 {
789-}
790-
791-mc::GLRenderer::Resources::~Resources()
792-{
793- if (vertex_shader)
794- glDeleteShader(vertex_shader);
795- if (fragment_shader)
796- glDeleteShader(fragment_shader);
797- if (program)
798- glDeleteProgram(program);
799- if (vertex_attribs_vbo)
800- glDeleteBuffers(1, &vertex_attribs_vbo);
801- if (texture)
802- glDeleteTextures(1, &texture);
803-}
804-
805-void mc::GLRenderer::Resources::setup(geometry::Rectangle const& display_area)
806-{
807 GLint param = 0;
808
809 /* Create shaders and program */
810@@ -235,14 +217,23 @@
811 glUseProgram(0);
812 }
813
814-mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area)
815+mc::GLRenderer::~GLRenderer() noexcept
816 {
817- resources.setup(display_area);
818+ if (vertex_shader)
819+ glDeleteShader(vertex_shader);
820+ if (fragment_shader)
821+ glDeleteShader(fragment_shader);
822+ if (program)
823+ glDeleteProgram(program);
824+ if (vertex_attribs_vbo)
825+ glDeleteBuffers(1, &vertex_attribs_vbo);
826+ if (texture)
827+ glDeleteTextures(1, &texture);
828 }
829
830 void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const
831 {
832- glUseProgram(resources.program);
833+ glUseProgram(program);
834
835 if (criteria.shaped() || criteria.alpha() < 1.0f)
836 {
837@@ -255,32 +246,36 @@
838 }
839 glActiveTexture(GL_TEXTURE0);
840
841- glUniformMatrix4fv(resources.transform_uniform_loc, 1, GL_FALSE,
842+ glUniformMatrix4fv(transform_uniform_loc, 1, GL_FALSE,
843 glm::value_ptr(criteria.transformation()));
844- glUniform1f(resources.alpha_uniform_loc, criteria.alpha());
845+ glUniform1f(alpha_uniform_loc, criteria.alpha());
846
847 /* Set up vertex attribute data */
848- glBindBuffer(GL_ARRAY_BUFFER, resources.vertex_attribs_vbo);
849- glVertexAttribPointer(resources.position_attr_loc, 3, GL_FLOAT,
850+ glBindBuffer(GL_ARRAY_BUFFER, vertex_attribs_vbo);
851+ glVertexAttribPointer(position_attr_loc, 3, GL_FLOAT,
852 GL_FALSE, sizeof(VertexAttributes), 0);
853- glVertexAttribPointer(resources.texcoord_attr_loc, 2, GL_FLOAT,
854+ glVertexAttribPointer(texcoord_attr_loc, 2, GL_FLOAT,
855 GL_FALSE, sizeof(VertexAttributes),
856 reinterpret_cast<void*>(sizeof(glm::vec3)));
857
858 /* Use the renderable's texture */
859- glBindTexture(GL_TEXTURE_2D, resources.texture);
860+ glBindTexture(GL_TEXTURE_2D, texture);
861
862 buffer.bind_to_texture();
863
864 /* Draw */
865- glEnableVertexAttribArray(resources.position_attr_loc);
866- glEnableVertexAttribArray(resources.texcoord_attr_loc);
867+ glEnableVertexAttribArray(position_attr_loc);
868+ glEnableVertexAttribArray(texcoord_attr_loc);
869 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
870- glDisableVertexAttribArray(resources.texcoord_attr_loc);
871- glDisableVertexAttribArray(resources.position_attr_loc);
872+ glDisableVertexAttribArray(texcoord_attr_loc);
873+ glDisableVertexAttribArray(position_attr_loc);
874 }
875
876-void mc::GLRenderer::clear() const
877+void mc::GLRenderer::begin() const
878 {
879 glClear(GL_COLOR_BUFFER_BIT);
880 }
881+
882+void mc::GLRenderer::end() const
883+{
884+}
885
886=== modified file 'src/server/compositor/gl_renderer.h'
887--- src/server/compositor/gl_renderer.h 2013-12-17 18:24:51 +0000
888+++ src/server/compositor/gl_renderer.h 2014-01-02 11:14:12 +0000
889@@ -32,32 +32,22 @@
890 {
891 public:
892 GLRenderer(geometry::Rectangle const& display_area);
893+ virtual ~GLRenderer() noexcept;
894
895+ void begin() const override;
896 void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override;
897- void clear() const override;
898-
899- ~GLRenderer() noexcept {}
900+ void end() const override;
901
902 private:
903- class Resources
904- {
905- public:
906- Resources();
907- ~Resources();
908- void setup(geometry::Rectangle const& display_area);
909-
910- GLuint vertex_shader;
911- GLuint fragment_shader;
912- GLuint program;
913- GLuint position_attr_loc;
914- GLuint texcoord_attr_loc;
915- GLuint transform_uniform_loc;
916- GLuint alpha_uniform_loc;
917- GLuint vertex_attribs_vbo;
918- GLuint texture;
919- };
920-
921- Resources resources;
922+ GLuint vertex_shader;
923+ GLuint fragment_shader;
924+ GLuint program;
925+ GLuint position_attr_loc;
926+ GLuint texcoord_attr_loc;
927+ GLuint transform_uniform_loc;
928+ GLuint alpha_uniform_loc;
929+ GLuint vertex_attribs_vbo;
930+ GLuint texture;
931 };
932
933 }
934
935=== modified file 'src/server/compositor/renderer.h'
936--- src/server/compositor/renderer.h 2013-12-17 18:24:51 +0000
937+++ src/server/compositor/renderer.h 2014-01-02 11:14:12 +0000
938@@ -34,8 +34,9 @@
939 public:
940 virtual ~Renderer() = default;
941
942- virtual void clear() const = 0;
943+ virtual void begin() const = 0;
944 virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0;
945+ virtual void end() const = 0;
946
947 protected:
948 Renderer() = default;
949
950=== modified file 'src/server/frontend/protobuf_buffer_packer.cpp'
951--- src/server/frontend/protobuf_buffer_packer.cpp 2013-12-17 18:24:51 +0000
952+++ src/server/frontend/protobuf_buffer_packer.cpp 2014-01-02 11:14:12 +0000
953@@ -64,7 +64,7 @@
954 protobuf_output.set_position_x(display_output.top_left.x.as_uint32_t());
955 protobuf_output.set_position_y(display_output.top_left.y.as_uint32_t());
956 protobuf_output.set_current_mode(display_output.current_mode_index);
957- protobuf_output.set_current_format(display_output.current_format_index);
958+ protobuf_output.set_current_format(static_cast<uint32_t>(display_output.current_format));
959 protobuf_output.set_power_mode(static_cast<uint32_t>(display_output.power_mode));
960 }
961
962
963=== modified file 'src/server/frontend/session_mediator.cpp'
964--- src/server/frontend/session_mediator.cpp 2013-12-17 18:24:51 +0000
965+++ src/server/frontend/session_mediator.cpp 2014-01-02 11:14:12 +0000
966@@ -321,7 +321,9 @@
967 mg::DisplayConfigurationOutputId output_id{static_cast<int>(output.output_id())};
968 config->configure_output(output_id, output.used(),
969 geom::Point{output.position_x(), output.position_y()},
970- output.current_mode(), static_cast<MirPowerMode>(output.power_mode()));
971+ output.current_mode(),
972+ static_cast<MirPixelFormat>(output.current_format()),
973+ static_cast<MirPowerMode>(output.power_mode()));
974 }
975
976 display_changer->configure(session, config);
977
978=== modified file 'src/server/graphics/default_display_configuration_policy.cpp'
979--- src/server/graphics/default_display_configuration_policy.cpp 2013-12-17 18:24:51 +0000
980+++ src/server/graphics/default_display_configuration_policy.cpp 2014-01-02 11:14:12 +0000
981@@ -18,13 +18,47 @@
982
983 #include "default_display_configuration_policy.h"
984 #include "mir/graphics/display_configuration.h"
985+#include "mir/graphics/pixel_format_utils.h"
986
987 #include <unordered_map>
988-
989-namespace mg = mir::graphics;
990-namespace geom = mir::geometry;
991-
992-void mg::DefaultDisplayConfigurationPolicy::apply_to(DisplayConfiguration& conf)
993+#include <algorithm>
994+
995+namespace mir
996+{
997+namespace geom = geometry;
998+namespace graphics
999+{
1000+
1001+namespace
1002+{
1003+inline size_t select_mode_index(size_t mode_index, std::vector<DisplayConfigurationMode> const & modes)
1004+{
1005+ if (modes.empty())
1006+ return std::numeric_limits<size_t>::max();
1007+ if (mode_index > modes.size())
1008+ return 0;
1009+ return mode_index;
1010+}
1011+
1012+inline MirPixelFormat select_format(MirPixelFormat format, std::vector<MirPixelFormat> const& formats)
1013+{
1014+ if (formats.empty())
1015+ return mir_pixel_format_invalid;
1016+
1017+ if (!contains_alpha(format))
1018+ return format;
1019+
1020+ auto opaque_pos = std::find_if_not(formats.begin(), formats.end(), contains_alpha);
1021+
1022+ if (opaque_pos == formats.end())
1023+ return format;
1024+
1025+ return *opaque_pos;
1026+}
1027+
1028+}
1029+
1030+void DefaultDisplayConfigurationPolicy::apply_to(DisplayConfiguration& conf)
1031 {
1032 static MirPowerMode const default_power_state = mir_power_mode_on;
1033 std::unordered_map<DisplayConfigurationCardId, size_t> available_outputs_for_card;
1034@@ -38,23 +72,24 @@
1035 conf.for_each_output(
1036 [&](DisplayConfigurationOutput const& conf_output)
1037 {
1038- if (conf_output.connected && conf_output.modes.size() > 0 &&
1039- available_outputs_for_card[conf_output.card_id] > 0)
1040- {
1041- size_t preferred_mode_index{conf_output.preferred_mode_index};
1042- if (preferred_mode_index > conf_output.modes.size())
1043- preferred_mode_index = 0;
1044-
1045- conf.configure_output(conf_output.id, true, geom::Point(),
1046- preferred_mode_index, default_power_state);
1047-
1048- --available_outputs_for_card[conf_output.card_id];
1049- }
1050- else
1051+ if (!conf_output.connected || conf_output.modes.empty() ||
1052+ available_outputs_for_card[conf_output.card_id] == 0)
1053 {
1054 conf.configure_output(conf_output.id, false, conf_output.top_left,
1055- conf_output.current_mode_index, default_power_state);
1056+ conf_output.current_mode_index, conf_output.current_format,
1057+ default_power_state);
1058+ return;
1059 }
1060+
1061+ size_t preferred_mode_index{select_mode_index(conf_output.preferred_mode_index, conf_output.modes)};
1062+ MirPixelFormat format{select_format(conf_output.current_format, conf_output.pixel_formats)};
1063+
1064+ conf.configure_output(conf_output.id, true, geom::Point(), preferred_mode_index,
1065+ format, default_power_state);
1066+
1067+ --available_outputs_for_card[conf_output.card_id];
1068 });
1069 }
1070
1071+} // graphics
1072+} // mir
1073
1074=== modified file 'src/server/graphics/nested/nested_display.cpp'
1075--- src/server/graphics/nested/nested_display.cpp 2013-12-19 19:05:57 +0000
1076+++ src/server/graphics/nested/nested_display.cpp 2014-01-02 11:14:12 +0000
1077@@ -22,8 +22,10 @@
1078 #include "mir_api_wrappers.h"
1079
1080 #include "mir/geometry/rectangle.h"
1081+#include "mir/graphics/pixel_format_utils.h"
1082 #include "mir/graphics/gl_context.h"
1083 #include "mir/graphics/surfaceless_egl_context.h"
1084+#include "mir/graphics/display_configuration_policy.h"
1085 #include "host_connection.h"
1086
1087 #include <boost/throw_exception.hpp>
1088@@ -34,45 +36,8 @@
1089 namespace mgnw = mir::graphics::nested::mir_api_wrappers;
1090 namespace geom = mir::geometry;
1091
1092-namespace
1093-{
1094-
1095-MirPixelFormat find_opaque_surface_format(MirConnection* connection)
1096-{
1097- static unsigned const max_formats = 32;
1098- MirPixelFormat formats[max_formats];
1099- unsigned int valid_formats;
1100-
1101- mir_connection_get_available_surface_formats(connection, formats,
1102- max_formats, &valid_formats);
1103-
1104- // Find an opaque surface format
1105- for (auto f = formats; f != formats+valid_formats; ++f)
1106- {
1107- if (*f == mir_pixel_format_xbgr_8888 ||
1108- *f == mir_pixel_format_xrgb_8888)
1109- {
1110- return *f;
1111- }
1112- }
1113-
1114- BOOST_THROW_EXCEPTION(
1115- std::runtime_error("Nested Mir failed to find an opaque surface format"));
1116-}
1117-
1118-}
1119-
1120-EGLint const mgn::detail::nested_egl_config_attribs[] = {
1121- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1122- EGL_RED_SIZE, 8,
1123- EGL_GREEN_SIZE, 8,
1124- EGL_BLUE_SIZE, 8,
1125- EGL_ALPHA_SIZE, 0,
1126- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1127- EGL_NONE
1128-};
1129-
1130-EGLint const mgn::detail::nested_egl_context_attribs[] = {
1131+EGLint const mgn::detail::nested_egl_context_attribs[] =
1132+{
1133 EGL_CONTEXT_CLIENT_VERSION, 2,
1134 EGL_NONE
1135 };
1136@@ -93,6 +58,8 @@
1137 }
1138
1139 mgn::detail::EGLDisplayHandle::EGLDisplayHandle(MirConnection* connection)
1140+ : egl_display(EGL_NO_DISPLAY),
1141+ egl_context_(EGL_NO_CONTEXT)
1142 {
1143 auto const native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection);
1144 egl_display = eglGetDisplay(native_display);
1145@@ -100,7 +67,7 @@
1146 BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to fetch EGL display."));
1147 }
1148
1149-void mgn::detail::EGLDisplayHandle::initialize()
1150+void mgn::detail::EGLDisplayHandle::initialize(MirPixelFormat format)
1151 {
1152 int major;
1153 int minor;
1154@@ -110,17 +77,28 @@
1155 BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to initialize EGL."));
1156 }
1157
1158- egl_context_ = eglCreateContext(egl_display, choose_config(detail::nested_egl_config_attribs), EGL_NO_CONTEXT, detail::nested_egl_context_attribs);
1159+ egl_context_ = eglCreateContext(egl_display, choose_windowed_es_config(format), EGL_NO_CONTEXT, detail::nested_egl_context_attribs);
1160+
1161 if (egl_context_ == EGL_NO_CONTEXT)
1162 BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create shared EGL context"));
1163 }
1164
1165-EGLConfig mgn::detail::EGLDisplayHandle::choose_config(const EGLint attrib_list[]) const
1166+EGLConfig mgn::detail::EGLDisplayHandle::choose_windowed_es_config(MirPixelFormat format) const
1167 {
1168+ EGLint const nested_egl_config_attribs[] =
1169+ {
1170+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1171+ EGL_RED_SIZE, mg::red_channel_depth(format),
1172+ EGL_GREEN_SIZE, mg::green_channel_depth(format),
1173+ EGL_BLUE_SIZE, mg::blue_channel_depth(format),
1174+ EGL_ALPHA_SIZE, mg::alpha_channel_depth(format),
1175+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1176+ EGL_NONE
1177+ };
1178 EGLConfig result;
1179 int n;
1180
1181- int res = eglChooseConfig(egl_display, attrib_list, &result, 1, &n);
1182+ int res = eglChooseConfig(egl_display, nested_egl_config_attribs, &result, 1, &n);
1183 if ((res != EGL_TRUE) || (n != 1))
1184 BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to choose EGL configuration."));
1185
1186@@ -149,17 +127,18 @@
1187 mgn::NestedDisplay::NestedDisplay(
1188 std::shared_ptr<HostConnection> const& connection,
1189 std::shared_ptr<input::EventFilter> const& event_handler,
1190- std::shared_ptr<mg::DisplayReport> const& display_report) :
1191+ std::shared_ptr<mg::DisplayReport> const& display_report,
1192+ std::shared_ptr<mg::DisplayConfigurationPolicy> const& initial_conf_policy) :
1193 connection{connection},
1194 event_handler{event_handler},
1195 display_report{display_report},
1196 egl_display{*connection},
1197- egl_pixel_format{find_opaque_surface_format(*connection)},
1198 outputs{}
1199 {
1200- egl_display.initialize();
1201- eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_display.egl_context());
1202- configure(*configuration());
1203+
1204+ std::shared_ptr<DisplayConfiguration> conf(configuration());
1205+ initial_conf_policy->apply_to(*conf);
1206+ configure(*conf);
1207 }
1208
1209 mgn::NestedDisplay::~NestedDisplay() noexcept
1210@@ -178,6 +157,14 @@
1211 return std::make_shared<NestedDisplayConfiguration>(mir_connection_create_display_config(*connection));
1212 }
1213
1214+void mgn::NestedDisplay::complete_display_initialization(MirPixelFormat format)
1215+{
1216+ if (egl_display.egl_context() != EGL_NO_CONTEXT) return;
1217+
1218+ egl_display.initialize(format);
1219+ eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_display.egl_context());
1220+}
1221+
1222 void mgn::NestedDisplay::configure(mg::DisplayConfiguration const& configuration)
1223 {
1224 decltype(outputs) result;
1225@@ -193,13 +180,16 @@
1226 geometry::Rectangle const area{output.top_left, output.modes[output.current_mode_index].size};
1227
1228 auto const& egl_display_mode = output.modes[output.current_mode_index];
1229+ auto const& egl_config_format = output.current_format;
1230+
1231+ complete_display_initialization(egl_config_format);
1232
1233 MirSurfaceParameters const request_params =
1234 {
1235 "Mir nested display",
1236 egl_display_mode.size.width.as_int(),
1237 egl_display_mode.size.height.as_int(),
1238- egl_pixel_format,
1239+ egl_config_format,
1240 mir_buffer_usage_hardware,
1241 static_cast<uint32_t>(output.id.as_value())
1242 };
1243@@ -213,7 +203,8 @@
1244 egl_display,
1245 mir_surface,
1246 area,
1247- event_handler);
1248+ event_handler,
1249+ output.current_format);
1250 }
1251 });
1252
1253@@ -274,13 +265,7 @@
1254 return std::weak_ptr<Cursor>();
1255 }
1256
1257-namespace
1258-{
1259-}
1260-
1261 std::unique_ptr<mg::GLContext> mgn::NestedDisplay::create_gl_context()
1262 {
1263- return std::unique_ptr<mg::GLContext>{new SurfacelessEGLContext(egl_display,
1264- detail::nested_egl_config_attribs,
1265- EGL_NO_CONTEXT)};
1266+ return std::unique_ptr<mg::GLContext>{new SurfacelessEGLContext(egl_display, EGL_NO_CONTEXT)};
1267 }
1268
1269=== modified file 'src/server/graphics/nested/nested_display.h'
1270--- src/server/graphics/nested/nested_display.h 2013-12-17 18:24:51 +0000
1271+++ src/server/graphics/nested/nested_display.h 2014-01-02 11:14:12 +0000
1272@@ -42,6 +42,7 @@
1273 {
1274 class DisplayReport;
1275 class DisplayBuffer;
1276+class DisplayConfigurationPolicy;
1277
1278 namespace nested
1279 {
1280@@ -67,8 +68,8 @@
1281 explicit EGLDisplayHandle(MirConnection* connection);
1282 ~EGLDisplayHandle() noexcept;
1283
1284- void initialize();
1285- EGLConfig choose_config(const EGLint attrib_list[]) const;
1286+ void initialize(MirPixelFormat format);
1287+ EGLConfig choose_windowed_es_config (MirPixelFormat format) const;
1288 EGLNativeWindowType native_window(EGLConfig egl_config, MirSurface* mir_surface) const;
1289 EGLContext egl_context() const;
1290 operator EGLDisplay() const { return egl_display; }
1291@@ -83,7 +84,6 @@
1292
1293 class NestedOutput;
1294
1295-extern EGLint const nested_egl_config_attribs[];
1296 extern EGLint const nested_egl_context_attribs[];
1297 }
1298
1299@@ -95,7 +95,8 @@
1300 NestedDisplay(
1301 std::shared_ptr<HostConnection> const& connection,
1302 std::shared_ptr<input::EventFilter> const& event_handler,
1303- std::shared_ptr<DisplayReport> const& display_report);
1304+ std::shared_ptr<DisplayReport> const& display_report,
1305+ std::shared_ptr<DisplayConfigurationPolicy> const& conf_policy);
1306
1307 ~NestedDisplay() noexcept;
1308
1309@@ -124,11 +125,11 @@
1310 std::shared_ptr<input::EventFilter> const event_handler;
1311 std::shared_ptr<DisplayReport> const display_report;
1312 detail::EGLDisplayHandle egl_display;
1313- MirPixelFormat const egl_pixel_format;
1314
1315 std::mutex outputs_mutex;
1316 std::unordered_map<DisplayConfigurationOutputId, std::shared_ptr<detail::NestedOutput>> outputs;
1317 DisplayConfigurationChangeHandler my_conf_change_handler;
1318+ void complete_display_initialization(MirPixelFormat format);
1319 };
1320
1321 }
1322
1323=== modified file 'src/server/graphics/nested/nested_display_configuration.cpp'
1324--- src/server/graphics/nested/nested_display_configuration.cpp 2013-12-17 18:24:51 +0000
1325+++ src/server/graphics/nested/nested_display_configuration.cpp 2014-01-02 11:14:12 +0000
1326@@ -18,26 +18,40 @@
1327
1328 #include "nested_display_configuration.h"
1329
1330-namespace mg = mir::graphics;
1331-namespace mgn = mg::nested;
1332+#include "mir/graphics/pixel_format_utils.h"
1333
1334 #include <boost/throw_exception.hpp>
1335
1336 #include <stdexcept>
1337 #include <algorithm>
1338
1339-namespace mgn = mir::graphics::nested;
1340-
1341-mgn::NestedDisplayConfiguration::NestedDisplayConfiguration(MirDisplayConfiguration* connection) :
1342+namespace mir
1343+{
1344+namespace graphics
1345+{
1346+namespace nested
1347+{
1348+
1349+namespace
1350+{
1351+bool format_valid_for_output(MirDisplayOutput const& output, MirPixelFormat format)
1352+{
1353+ MirPixelFormat * end = output.output_formats + output.num_output_formats;
1354+ return end != std::find(output.output_formats, end, format);
1355+}
1356+
1357+}
1358+
1359+NestedDisplayConfiguration::NestedDisplayConfiguration(MirDisplayConfiguration* connection) :
1360 display_config{connection}
1361 {
1362 }
1363
1364-mgn::NestedDisplayConfiguration::~NestedDisplayConfiguration() noexcept
1365+NestedDisplayConfiguration::~NestedDisplayConfiguration() noexcept
1366 {
1367 }
1368
1369-void mgn::NestedDisplayConfiguration::for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const
1370+void NestedDisplayConfiguration::for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const
1371 {
1372 std::for_each(
1373 display_config->cards,
1374@@ -48,7 +62,7 @@
1375 });
1376 }
1377
1378-void mgn::NestedDisplayConfiguration::for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const
1379+void NestedDisplayConfiguration::for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const
1380 {
1381 std::for_each(
1382 display_config->outputs,
1383@@ -85,8 +99,8 @@
1384 });
1385 }
1386
1387-void mgn::NestedDisplayConfiguration::configure_output(DisplayConfigurationOutputId id, bool used,
1388- geometry::Point top_left, size_t mode_index, MirPowerMode power_mode)
1389+void NestedDisplayConfiguration::configure_output(DisplayConfigurationOutputId id, bool used,
1390+ geometry::Point top_left, size_t mode_index, MirPixelFormat format, MirPowerMode power_mode)
1391 {
1392 for (auto mir_output = display_config->outputs;
1393 mir_output != display_config->outputs+display_config->num_outputs;
1394@@ -97,13 +111,24 @@
1395 if (used && mode_index >= mir_output->num_modes)
1396 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid mode_index for used output"));
1397
1398+ if (used && !valid_mir_pixel_format(format))
1399+ BOOST_THROW_EXCEPTION(std::runtime_error("Invalid format for used output"));
1400+
1401+ if (used && !format_valid_for_output(*mir_output, format))
1402+ BOOST_THROW_EXCEPTION(std::runtime_error("Format not available for used output"));
1403+
1404 mir_output->used = used;
1405 mir_output->position_x = top_left.x.as_uint32_t();
1406 mir_output->position_y = top_left.y.as_uint32_t();
1407 mir_output->current_mode = mode_index;
1408+ mir_output->current_output_format = format;
1409 mir_output->power_mode = static_cast<MirPowerMode>(power_mode);
1410 return;
1411 }
1412 }
1413 BOOST_THROW_EXCEPTION(std::runtime_error("Trying to configure invalid output"));
1414 }
1415+
1416+} // nested
1417+} // graphics
1418+} // mir
1419
1420=== modified file 'src/server/graphics/nested/nested_display_configuration.h'
1421--- src/server/graphics/nested/nested_display_configuration.h 2013-09-12 21:36:55 +0000
1422+++ src/server/graphics/nested/nested_display_configuration.h 2014-01-02 11:14:12 +0000
1423@@ -38,7 +38,7 @@
1424 void for_each_output(std::function<void(DisplayConfigurationOutput const&)>) const;
1425
1426 void configure_output(DisplayConfigurationOutputId id, bool used, geometry::Point top_left, size_t mode_index,
1427- MirPowerMode power_mode);
1428+ MirPixelFormat format, MirPowerMode power_mode);
1429
1430 operator MirDisplayConfiguration*() const { return display_config; }
1431 private:
1432
1433=== modified file 'src/server/graphics/nested/nested_output.cpp'
1434--- src/server/graphics/nested/nested_output.cpp 2013-09-23 13:37:44 +0000
1435+++ src/server/graphics/nested/nested_output.cpp 2014-01-02 11:14:12 +0000
1436@@ -41,10 +41,11 @@
1437 EGLDisplayHandle const& egl_display,
1438 MirSurface* mir_surface,
1439 geometry::Rectangle const& area,
1440- std::shared_ptr<input::EventFilter> const& event_handler) :
1441+ std::shared_ptr<input::EventFilter> const& event_handler,
1442+ MirPixelFormat preferred_format) :
1443 egl_display(egl_display),
1444 mir_surface{mir_surface},
1445- egl_config{egl_display.choose_config(nested_egl_config_attribs)},
1446+ egl_config{egl_display.choose_windowed_es_config(preferred_format)},
1447 egl_context{egl_display, eglCreateContext(egl_display, egl_config, egl_display.egl_context(), nested_egl_context_attribs)},
1448 area{area.top_left, area.size},
1449 event_handler{event_handler},
1450
1451=== modified file 'src/server/graphics/nested/nested_output.h'
1452--- src/server/graphics/nested/nested_output.h 2013-09-23 13:37:44 +0000
1453+++ src/server/graphics/nested/nested_output.h 2014-01-02 11:14:12 +0000
1454@@ -54,7 +54,8 @@
1455 EGLDisplayHandle const& egl_display,
1456 MirSurface* mir_surface,
1457 geometry::Rectangle const& area,
1458- std::shared_ptr<input::EventFilter> const& event_handler);
1459+ std::shared_ptr<input::EventFilter> const& event_handler,
1460+ MirPixelFormat preferred_format);
1461
1462 ~NestedOutput() noexcept;
1463
1464
1465=== modified file 'src/server/graphics/nested/nested_platform.cpp'
1466--- src/server/graphics/nested/nested_platform.cpp 2013-12-17 18:24:51 +0000
1467+++ src/server/graphics/nested/nested_platform.cpp 2014-01-02 11:14:12 +0000
1468@@ -113,9 +113,9 @@
1469 return native_platform->create_buffer_allocator(buffer_initializer);
1470 }
1471
1472-std::shared_ptr<mg::Display> mgn::NestedPlatform::create_display(std::shared_ptr<mg::DisplayConfigurationPolicy> const& /*initial_conf_policy*/)
1473+std::shared_ptr<mg::Display> mgn::NestedPlatform::create_display(std::shared_ptr<mg::DisplayConfigurationPolicy> const& conf_policy)
1474 {
1475- return std::make_shared<mgn::NestedDisplay>(connection, event_handler, display_report);
1476+ return std::make_shared<mgn::NestedDisplay>(connection, event_handler, display_report, conf_policy);
1477 }
1478
1479 std::shared_ptr<mg::PlatformIPCPackage> mgn::NestedPlatform::get_ipc_package()
1480
1481=== modified file 'src/server/graphics/nested/nested_platform.h'
1482--- src/server/graphics/nested/nested_platform.h 2013-12-17 18:24:51 +0000
1483+++ src/server/graphics/nested/nested_platform.h 2014-01-02 11:14:12 +0000
1484@@ -42,12 +42,12 @@
1485
1486 ~NestedPlatform() noexcept;
1487 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(
1488- std::shared_ptr<BufferInitializer> const& buffer_initializer);
1489+ std::shared_ptr<BufferInitializer> const& buffer_initializer) override;
1490 std::shared_ptr<Display> create_display(
1491- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy);
1492- std::shared_ptr<PlatformIPCPackage> get_ipc_package();
1493- std::shared_ptr<InternalClient> create_internal_client();
1494- void fill_ipc_package(BufferIPCPacker* packer, Buffer const* Buffer) const;
1495+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy) override;
1496+ std::shared_ptr<PlatformIPCPackage> get_ipc_package() override;
1497+ std::shared_ptr<InternalClient> create_internal_client() override;
1498+ void fill_ipc_package(BufferIPCPacker* packer, Buffer const* Buffer) const override;
1499 EGLNativeDisplayType egl_native_display() const;
1500
1501 private:
1502
1503=== modified file 'src/server/graphics/offscreen/display_configuration.cpp'
1504--- src/server/graphics/offscreen/display_configuration.cpp 2013-12-17 18:24:51 +0000
1505+++ src/server/graphics/offscreen/display_configuration.cpp 2014-01-02 11:14:12 +0000
1506@@ -31,7 +31,9 @@
1507 true,
1508 true,
1509 geom::Point{0,0},
1510- 0, 0, mir_power_mode_on},
1511+ 0,
1512+ mir_pixel_format_xrgb_8888,
1513+ mir_power_mode_on},
1514 card{mg::DisplayConfigurationCardId{0}, 1}
1515 {
1516 }
1517@@ -67,6 +69,6 @@
1518 }
1519
1520 void mgo::DisplayConfiguration::configure_output(
1521- mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPowerMode)
1522+ mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPixelFormat, MirPowerMode)
1523 {
1524 }
1525
1526=== modified file 'src/server/graphics/offscreen/display_configuration.h'
1527--- src/server/graphics/offscreen/display_configuration.h 2013-11-12 17:23:53 +0000
1528+++ src/server/graphics/offscreen/display_configuration.h 2014-01-02 11:14:12 +0000
1529@@ -33,10 +33,10 @@
1530 DisplayConfiguration(DisplayConfiguration const& other);
1531 DisplayConfiguration& operator=(DisplayConfiguration const& other);
1532
1533- void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const;
1534- void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const;
1535- void configure_output(DisplayConfigurationOutputId, bool, geometry::Point,
1536- size_t, MirPowerMode power_mode);
1537+ void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const override;
1538+ void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const override;
1539+ virtual void configure_output(DisplayConfigurationOutputId id, bool used, geometry::Point top_left,
1540+ size_t mode_index, MirPixelFormat format, MirPowerMode power_mode) override;
1541
1542 private:
1543 DisplayConfigurationOutput output;
1544
1545=== modified file 'src/server/logging/input_report.cpp'
1546--- src/server/logging/input_report.cpp 2013-12-19 16:33:56 +0000
1547+++ src/server/logging/input_report.cpp 2014-01-02 11:14:12 +0000
1548@@ -18,6 +18,7 @@
1549
1550 #include "mir/logging/input_report.h"
1551 #include "mir/logging/logger.h"
1552+#include "mir/logging/input_timestamp.h"
1553
1554 #include "std/MirLog.h"
1555 #include <std/Log.h>
1556@@ -108,7 +109,7 @@
1557 std::stringstream ss;
1558
1559 ss << "Received event"
1560- << " time=" << when
1561+ << " time=" << ml::input_timestamp(when)
1562 << " type=" << type
1563 << " code=" << code
1564 << " value=" << value;
1565@@ -122,7 +123,7 @@
1566
1567 ss << "Published key event"
1568 << " seq_id=" << seq_id
1569- << " time=" << event_time
1570+ << " time=" << ml::input_timestamp(event_time)
1571 << " dest_fd=" << dest_fd;
1572
1573 logger->log(Logger::informational, ss.str(), component());
1574@@ -134,7 +135,7 @@
1575
1576 ss << "Published motion event"
1577 << " seq_id=" << seq_id
1578- << " time=" << event_time
1579+ << " time=" << ml::input_timestamp(event_time)
1580 << " dest_fd=" << dest_fd;
1581
1582 logger->log(Logger::informational, ss.str(), component());
1583
1584=== modified file 'src/server/scene/mediating_display_changer.cpp'
1585--- src/server/scene/mediating_display_changer.cpp 2013-12-17 18:24:51 +0000
1586+++ src/server/scene/mediating_display_changer.cpp 2014-01-02 11:14:12 +0000
1587@@ -136,6 +136,7 @@
1588 conf->configure_output(output.id, output.used,
1589 output.top_left,
1590 output.current_mode_index,
1591+ output.current_format,
1592 mir_power_mode_on);
1593 }
1594 });
1595
1596=== modified file 'src/shared/logging/CMakeLists.txt'
1597--- src/shared/logging/CMakeLists.txt 2013-12-12 07:51:12 +0000
1598+++ src/shared/logging/CMakeLists.txt 2014-01-02 11:14:12 +0000
1599@@ -16,4 +16,5 @@
1600
1601 add_library(mirsharedlogging STATIC
1602 dumb_console_logger.cpp
1603+ input_timestamp.cpp
1604 )
1605
1606=== added file 'src/shared/logging/input_timestamp.cpp'
1607--- src/shared/logging/input_timestamp.cpp 1970-01-01 00:00:00 +0000
1608+++ src/shared/logging/input_timestamp.cpp 2014-01-02 11:14:12 +0000
1609@@ -0,0 +1,41 @@
1610+/*
1611+ * Copyright © 2013 Canonical Ltd.
1612+ *
1613+ * This program is free software: you can redistribute it and/or modify it
1614+ * under the terms of the GNU Lesser General Public License version 3,
1615+ * as published by the Free Software Foundation.
1616+ *
1617+ * This program is distributed in the hope that it will be useful,
1618+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1619+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1620+ * GNU Lesser General Public License for more details.
1621+ *
1622+ * You should have received a copy of the GNU Lesser General Public License
1623+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1624+ *
1625+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1626+ */
1627+
1628+#include "mir/logging/input_timestamp.h"
1629+#include <ctime>
1630+#include <cstdio>
1631+#include <string>
1632+
1633+std::string mir::logging::input_timestamp(nsecs_t when)
1634+{
1635+ // Input events use CLOCK_REALTIME, and so we must...
1636+ struct timespec ts;
1637+ clock_gettime(CLOCK_REALTIME, &ts);
1638+
1639+ nsecs_t now = ts.tv_sec * 1000000000LL + ts.tv_nsec;
1640+ nsecs_t age = now - when;
1641+
1642+ char str[64];
1643+ snprintf(str, sizeof str, "%lld (%ld.%06ld ms ago)",
1644+ static_cast<long long>(when),
1645+ static_cast<long>(age / 1000000LL),
1646+ static_cast<long>(age % 1000000LL));
1647+
1648+ return std::string(str);
1649+}
1650+
1651
1652=== modified file 'tests/acceptance-tests/test_server_shutdown.cpp'
1653--- tests/acceptance-tests/test_server_shutdown.cpp 2013-12-17 18:24:51 +0000
1654+++ tests/acceptance-tests/test_server_shutdown.cpp 2014-01-02 11:14:12 +0000
1655@@ -48,6 +48,10 @@
1656 class NullRenderer : public mc::Renderer
1657 {
1658 public:
1659+ void begin() const override
1660+ {
1661+ }
1662+
1663 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
1664 {
1665 /*
1666@@ -58,7 +62,7 @@
1667 std::this_thread::yield();
1668 }
1669
1670- void clear() const override
1671+ void end() const override
1672 {
1673 }
1674 };
1675
1676=== modified file 'tests/integration-tests/test_session.cpp'
1677--- tests/integration-tests/test_session.cpp 2013-12-17 18:24:51 +0000
1678+++ tests/integration-tests/test_session.cpp 2014-01-02 11:14:12 +0000
1679@@ -87,12 +87,15 @@
1680 {
1681 struct StubRenderer : public mc::Renderer
1682 {
1683- void clear() const override
1684+ void begin() const override
1685 {
1686 }
1687 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
1688 {
1689 }
1690+ void end() const override
1691+ {
1692+ }
1693 };
1694
1695 struct StubRendererFactory : public mc::RendererFactory
1696
1697=== modified file 'tests/integration-tests/test_surface_first_frame_sync.cpp'
1698--- tests/integration-tests/test_surface_first_frame_sync.cpp 2013-12-17 18:24:51 +0000
1699+++ tests/integration-tests/test_surface_first_frame_sync.cpp 2014-01-02 11:14:12 +0000
1700@@ -96,7 +96,7 @@
1701 {
1702 }
1703
1704- void clear() const override
1705+ void begin() const override
1706 {
1707 }
1708
1709@@ -105,6 +105,10 @@
1710 while (write(render_operations_fd, "a", 1) != 1) continue;
1711 }
1712
1713+ void end() const override
1714+ {
1715+ }
1716+
1717 private:
1718 int render_operations_fd;
1719 };
1720
1721=== modified file 'tests/mir_test/display_config_matchers.cpp'
1722--- tests/mir_test/display_config_matchers.cpp 2013-12-17 18:24:51 +0000
1723+++ tests/mir_test/display_config_matchers.cpp 2014-01-02 11:14:12 +0000
1724@@ -67,7 +67,7 @@
1725 geom::Point{protobuf_output.position_x(),
1726 protobuf_output.position_y()},
1727 protobuf_output.current_mode(),
1728- protobuf_output.current_format(),
1729+ static_cast<MirPixelFormat>(protobuf_output.current_format()),
1730 static_cast<MirPowerMode>(protobuf_output.power_mode())
1731 };
1732
1733@@ -175,7 +175,7 @@
1734 }
1735
1736 void configure_output(mg::DisplayConfigurationOutputId, bool,
1737- geom::Point, size_t, MirPowerMode)
1738+ geom::Point, size_t, MirPixelFormat, MirPowerMode)
1739 {
1740 }
1741
1742
1743=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
1744--- tests/mir_test_framework/stubbed_server_configuration.cpp 2013-12-19 16:34:53 +0000
1745+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-01-02 11:14:12 +0000
1746@@ -132,7 +132,7 @@
1747 mg::DisplayConfigurationCardId{0},
1748 mg::DisplayConfigurationOutputType::vga,
1749 std::vector<MirPixelFormat>{mir_pixel_format_abgr_8888},
1750- modes, 0, geom::Size{}, true, true, geom::Point{0,0}, 0, 0, mir_power_mode_on};
1751+ modes, 0, geom::Size{}, true, true, geom::Point{0,0}, 0, mir_pixel_format_abgr_8888, mir_power_mode_on};
1752
1753 f(dummy_output_config);
1754 }
1755@@ -201,11 +201,15 @@
1756 class StubRenderer : public mc::Renderer
1757 {
1758 public:
1759+ void begin() const override
1760+ {
1761+ }
1762+
1763 void render(mc::CompositingCriteria const&, mg::Buffer&) const override
1764 {
1765 }
1766
1767- void clear() const override
1768+ void end() const override
1769 {
1770 }
1771 };
1772
1773=== modified file 'tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp'
1774--- tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000
1775+++ tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2014-01-02 11:14:12 +0000
1776@@ -106,9 +106,9 @@
1777 {
1778 }
1779
1780- void clear() const override
1781+ void begin() const override
1782 {
1783- renderer->clear();
1784+ renderer->begin();
1785 }
1786
1787 void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override
1788@@ -116,6 +116,11 @@
1789 renderer->render(criteria, buffer);
1790 }
1791
1792+ void end() const override
1793+ {
1794+ renderer->end();
1795+ }
1796+
1797 mc::Renderer* const renderer;
1798 };
1799
1800@@ -241,10 +246,14 @@
1801 renderable_vec.push_back(&small);
1802 renderable_vec.push_back(&fullscreen);
1803
1804+ EXPECT_CALL(renderer_factory.mock_renderer, begin())
1805+ .Times(0);
1806 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_))
1807 .Times(0);
1808 EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_))
1809 .Times(0);
1810+ EXPECT_CALL(renderer_factory.mock_renderer, end())
1811+ .Times(0);
1812
1813 FakeScene scene(renderable_vec);
1814
1815@@ -263,6 +272,58 @@
1816 comp->composite();
1817 }
1818
1819+TEST(DefaultDisplayBufferCompositor, calls_renderer_in_sequence)
1820+{
1821+ using namespace testing;
1822+
1823+ StubRendererFactory renderer_factory;
1824+
1825+ geom::Rectangle screen{{0, 0}, {1366, 768}};
1826+
1827+ mtd::MockDisplayBuffer display_buffer;
1828+
1829+ EXPECT_CALL(display_buffer, view_area())
1830+ .WillRepeatedly(Return(screen));
1831+ EXPECT_CALL(display_buffer, can_bypass())
1832+ .WillRepeatedly(Return(false));
1833+
1834+ mtd::StubCompositingCriteria big(5, 10, 100, 200);
1835+ mtd::StubCompositingCriteria small(10, 20, 30, 40);
1836+
1837+ std::vector<mc::CompositingCriteria*> renderable_vec;
1838+ renderable_vec.push_back(&big);
1839+ renderable_vec.push_back(&small);
1840+
1841+ Sequence render_seq;
1842+
1843+ EXPECT_CALL(display_buffer, make_current())
1844+ .InSequence(render_seq);
1845+ EXPECT_CALL(renderer_factory.mock_renderer, begin())
1846+ .InSequence(render_seq);
1847+ EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(big),_))
1848+ .InSequence(render_seq);
1849+ EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_))
1850+ .InSequence(render_seq);
1851+ EXPECT_CALL(renderer_factory.mock_renderer, end())
1852+ .InSequence(render_seq);
1853+ EXPECT_CALL(display_buffer, post_update())
1854+ .InSequence(render_seq);
1855+
1856+ FakeScene scene(renderable_vec);
1857+
1858+ auto compositor_buffer = std::make_shared<mtd::MockBuffer>();
1859+ EXPECT_CALL(*compositor_buffer, can_bypass())
1860+ .Times(0);
1861+
1862+ mc::DefaultDisplayBufferCompositorFactory factory(
1863+ mt::fake_shared(scene),
1864+ mt::fake_shared(renderer_factory));
1865+
1866+ auto comp = factory.create_compositor_for(display_buffer);
1867+
1868+ comp->composite();
1869+}
1870+
1871 TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass)
1872 {
1873 using namespace testing;
1874
1875=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
1876--- tests/unit-tests/frontend/test_session_mediator.cpp 2013-12-17 18:24:51 +0000
1877+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-01-02 11:14:12 +0000
1878@@ -83,7 +83,7 @@
1879 {
1880 MOCK_CONST_METHOD1(for_each_card, void(std::function<void(mg::DisplayConfigurationCard const&)>));
1881 MOCK_CONST_METHOD1(for_each_output, void(std::function<void(mg::DisplayConfigurationOutput const&)>));
1882- MOCK_METHOD5(configure_output, void(mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPowerMode));
1883+ MOCK_METHOD6(configure_output, void(mg::DisplayConfigurationOutputId, bool, geom::Point, size_t, MirPixelFormat, MirPowerMode));
1884 };
1885
1886 }
1887@@ -555,6 +555,8 @@
1888 bool used0 = false, used1 = true;
1889 geom::Point pt0{44,22}, pt1{3,2};
1890 size_t mode_index0 = 1, mode_index1 = 3;
1891+ MirPixelFormat format0 = mir_pixel_format_invalid;
1892+ MirPixelFormat format1 = mir_pixel_format_argb_8888;
1893 mg::DisplayConfigurationOutputId id0{6}, id1{3};
1894
1895 NiceMock<MockConfig> mock_display_config;
1896@@ -568,9 +570,9 @@
1897 EXPECT_CALL(*mock_display_selector, active_configuration())
1898 .InSequence(seq)
1899 .WillOnce(Return(mt::fake_shared(mock_display_config)));
1900- EXPECT_CALL(mock_display_config, configure_output(id0, used0, pt0, mode_index0, mir_power_mode_on))
1901+ EXPECT_CALL(mock_display_config, configure_output(id0, used0, pt0, mode_index0, format0, mir_power_mode_on))
1902 .InSequence(seq);
1903- EXPECT_CALL(mock_display_config, configure_output(id1, used1, pt1, mode_index1, mir_power_mode_off))
1904+ EXPECT_CALL(mock_display_config, configure_output(id1, used1, pt1, mode_index1, format1, mir_power_mode_off))
1905 .InSequence(seq);
1906 EXPECT_CALL(*mock_display_selector, configure(_,_))
1907 .InSequence(seq);
1908@@ -593,6 +595,7 @@
1909 disp0->set_position_x(pt0.x.as_uint32_t());
1910 disp0->set_position_y(pt0.y.as_uint32_t());
1911 disp0->set_current_mode(mode_index0);
1912+ disp0->set_current_format(format0);
1913 disp0->set_power_mode(static_cast<uint32_t>(mir_power_mode_on));
1914
1915 auto disp1 = configuration.add_display_output();
1916@@ -601,6 +604,7 @@
1917 disp1->set_position_x(pt1.x.as_uint32_t());
1918 disp1->set_position_y(pt1.y.as_uint32_t());
1919 disp1->set_current_mode(mode_index1);
1920+ disp1->set_current_format(format1);
1921 disp1->set_power_mode(static_cast<uint32_t>(mir_power_mode_off));
1922
1923 session_mediator.configure_display(nullptr, &configuration,
1924
1925=== modified file 'tests/unit-tests/graphics/CMakeLists.txt'
1926--- tests/unit-tests/graphics/CMakeLists.txt 2013-12-19 19:05:57 +0000
1927+++ tests/unit-tests/graphics/CMakeLists.txt 2014-01-02 11:14:12 +0000
1928@@ -6,6 +6,7 @@
1929 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp
1930 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp
1931 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp
1932+ ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp
1933 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp
1934 )
1935
1936
1937=== modified file 'tests/unit-tests/graphics/android/test_android_fb.cpp'
1938--- tests/unit-tests/graphics/android/test_android_fb.cpp 2013-12-17 18:24:51 +0000
1939+++ tests/unit-tests/graphics/android/test_android_fb.cpp 2014-01-02 11:14:12 +0000
1940@@ -256,28 +256,28 @@
1941 configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1942 {
1943 configuration->configure_output(
1944- output.id, output.used, output.top_left, output.current_mode_index, mir_power_mode_on);
1945- });
1946- display.configure(*configuration);
1947-
1948- configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1949- {
1950- configuration->configure_output(
1951- output.id, output.used, output.top_left, output.current_mode_index, mir_power_mode_standby);
1952- });
1953- display.configure(*configuration);
1954-
1955- configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1956- {
1957- configuration->configure_output(
1958- output.id, output.used, output.top_left, output.current_mode_index, mir_power_mode_off);
1959- });
1960- display.configure(*configuration);
1961-
1962- configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1963- {
1964- configuration->configure_output(
1965- output.id, output.used, output.top_left, output.current_mode_index, mir_power_mode_suspend);
1966+ output.id, output.used, output.top_left, output.current_mode_index, output.current_format, mir_power_mode_on);
1967+ });
1968+ display.configure(*configuration);
1969+
1970+ configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1971+ {
1972+ configuration->configure_output(
1973+ output.id, output.used, output.top_left, output.current_mode_index, output.current_format, mir_power_mode_standby);
1974+ });
1975+ display.configure(*configuration);
1976+
1977+ configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1978+ {
1979+ configuration->configure_output(
1980+ output.id, output.used, output.top_left, output.current_mode_index, output.current_format, mir_power_mode_off);
1981+ });
1982+ display.configure(*configuration);
1983+
1984+ configuration->for_each_output([&](mg::DisplayConfigurationOutput const& output)
1985+ {
1986+ configuration->configure_output(
1987+ output.id, output.used, output.top_left, output.current_mode_index, output.current_format, mir_power_mode_suspend);
1988 });
1989 display.configure(*configuration);
1990 }
1991
1992=== modified file 'tests/unit-tests/graphics/mesa/test_cursor.cpp'
1993--- tests/unit-tests/graphics/mesa/test_cursor.cpp 2013-12-17 18:24:51 +0000
1994+++ tests/unit-tests/graphics/mesa/test_cursor.cpp 2014-01-02 11:14:12 +0000
1995@@ -105,7 +105,7 @@
1996 true,
1997 geom::Point{0, 0},
1998 1,
1999- 0,
2000+ mir_pixel_format_invalid,
2001 mir_power_mode_on
2002 });
2003 outputs.push_back(
2004@@ -124,33 +124,33 @@
2005 true,
2006 geom::Point{100, 50},
2007 0,
2008- 0,
2009+ mir_pixel_format_invalid,
2010 mir_power_mode_on
2011 });
2012 }
2013
2014- void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const
2015+ void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const override
2016 {
2017 f({card_id, outputs.size()});
2018 }
2019
2020- void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)> f) const
2021+ void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)> f) const override
2022 {
2023 for (auto const& output : outputs)
2024 f(output);
2025 }
2026
2027 void configure_output(mg::DisplayConfigurationOutputId, bool,
2028- geom::Point, size_t, MirPowerMode)
2029+ geom::Point, size_t, MirPixelFormat, MirPowerMode) override
2030 {
2031 }
2032
2033- uint32_t get_kms_connector_id(mg::DisplayConfigurationOutputId id) const
2034+ uint32_t get_kms_connector_id(mg::DisplayConfigurationOutputId id) const override
2035 {
2036 return id.as_value();
2037 }
2038
2039- size_t get_kms_mode_index(mg::DisplayConfigurationOutputId, size_t conf_mode_index) const
2040+ size_t get_kms_mode_index(mg::DisplayConfigurationOutputId, size_t conf_mode_index) const override
2041 {
2042 return conf_mode_index;
2043 }
2044
2045=== modified file 'tests/unit-tests/graphics/mesa/test_display_configuration.cpp'
2046--- tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2013-12-17 18:24:51 +0000
2047+++ tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2014-01-02 11:14:12 +0000
2048@@ -197,7 +197,7 @@
2049 true,
2050 geom::Point(),
2051 1,
2052- 0,
2053+ mir_pixel_format_invalid,
2054 mir_power_mode_on
2055 },
2056 {
2057@@ -212,7 +212,7 @@
2058 false,
2059 geom::Point(),
2060 std::numeric_limits<size_t>::max(),
2061- std::numeric_limits<size_t>::max(),
2062+ mir_pixel_format_invalid,
2063 mir_power_mode_on
2064 },
2065 {
2066@@ -227,7 +227,7 @@
2067 false,
2068 geom::Point(),
2069 std::numeric_limits<size_t>::max(),
2070- std::numeric_limits<size_t>::max(),
2071+ mir_pixel_format_invalid,
2072 mir_power_mode_on
2073 }
2074 };
2075@@ -381,7 +381,7 @@
2076 true,
2077 geom::Point(),
2078 1,
2079- 0,
2080+ mir_pixel_format_invalid,
2081 mir_power_mode_on
2082 },
2083 {
2084@@ -396,7 +396,7 @@
2085 false,
2086 geom::Point(),
2087 std::numeric_limits<size_t>::max(),
2088- std::numeric_limits<size_t>::max(),
2089+ mir_pixel_format_invalid,
2090 mir_power_mode_on
2091 },
2092 };
2093@@ -415,7 +415,7 @@
2094 true,
2095 geom::Point(),
2096 std::numeric_limits<size_t>::max(),
2097- std::numeric_limits<size_t>::max(),
2098+ mir_pixel_format_invalid,
2099 mir_power_mode_on
2100 },
2101 {
2102@@ -430,7 +430,7 @@
2103 false,
2104 geom::Point(),
2105 1,
2106- 0,
2107+ mir_pixel_format_invalid,
2108 mir_power_mode_on
2109 },
2110 };
2111
2112=== modified file 'tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp'
2113--- tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp 2013-12-17 18:24:51 +0000
2114+++ tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp 2014-01-02 11:14:12 +0000
2115@@ -57,12 +57,16 @@
2116 if (conf_output.connected && conf_output.modes.size() > 0)
2117 {
2118 conf.configure_output(conf_output.id, true, geom::Point{0, 0},
2119- conf_output.preferred_mode_index, mir_power_mode_on);
2120+ conf_output.preferred_mode_index,
2121+ conf_output.current_format,
2122+ mir_power_mode_on);
2123 }
2124 else
2125 {
2126 conf.configure_output(conf_output.id, false, conf_output.top_left,
2127- conf_output.current_mode_index, mir_power_mode_on);
2128+ conf_output.current_mode_index,
2129+ conf_output.current_format,
2130+ mir_power_mode_on);
2131 }
2132 });
2133 }
2134@@ -81,13 +85,17 @@
2135 if (conf_output.connected && conf_output.modes.size() > 0)
2136 {
2137 conf.configure_output(conf_output.id, true, geom::Point{max_x, 0},
2138- conf_output.preferred_mode_index, mir_power_mode_on);
2139+ conf_output.preferred_mode_index,
2140+ conf_output.current_format,
2141+ mir_power_mode_on);
2142 max_x += conf_output.modes[conf_output.preferred_mode_index].size.width.as_int();
2143 }
2144 else
2145 {
2146 conf.configure_output(conf_output.id, false, conf_output.top_left,
2147- conf_output.current_mode_index, mir_power_mode_on);
2148+ conf_output.current_mode_index,
2149+ conf_output.current_format,
2150+ mir_power_mode_on);
2151 }
2152 });
2153 }
2154@@ -472,7 +480,8 @@
2155 [&](mg::DisplayConfigurationOutput const& conf_output)
2156 {
2157 conf->configure_output(conf_output.id, false, conf_output.top_left,
2158- conf_output.preferred_mode_index, mir_power_mode_on);
2159+ conf_output.preferred_mode_index, mir_pixel_format_xrgb_8888,
2160+ mir_power_mode_on);
2161 });
2162
2163 display->configure(*conf);
2164@@ -508,7 +517,8 @@
2165 [&](mg::DisplayConfigurationOutput const& conf_output)
2166 {
2167 conf->configure_output(conf_output.id, false, conf_output.top_left,
2168- conf_output.preferred_mode_index, mir_power_mode_on);
2169+ conf_output.preferred_mode_index, mir_pixel_format_xrgb_8888,
2170+ mir_power_mode_on);
2171 });
2172
2173 display->configure(*conf);
2174
2175=== modified file 'tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp'
2176--- tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp 2013-12-17 18:24:51 +0000
2177+++ tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp 2014-01-02 11:14:12 +0000
2178@@ -79,7 +79,7 @@
2179 used,
2180 rect.top_left,
2181 i - 1,
2182- 0,
2183+ mir_pixel_format_invalid,
2184 mir_power_mode_on
2185 };
2186
2187@@ -89,7 +89,7 @@
2188 }
2189
2190 void configure_output(mg::DisplayConfigurationOutputId, bool,
2191- geom::Point, size_t, MirPowerMode)
2192+ geom::Point, size_t, MirPixelFormat, MirPowerMode)
2193 {
2194 }
2195
2196
2197=== modified file 'tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp'
2198--- tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp 2013-09-12 21:36:55 +0000
2199+++ tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp 2014-01-02 11:14:12 +0000
2200@@ -36,7 +36,7 @@
2201 uint32_t const default_current_mode = 0;
2202 uint32_t const default_num_output_formats = 0;
2203 MirPixelFormat* const default_output_formats = nullptr;
2204-uint32_t const default_current_output_format = 0;
2205+MirPixelFormat const default_current_output_format = mir_pixel_format_abgr_8888;
2206 uint32_t const default_card_id = 1;
2207 uint32_t const second_card_id = 2;
2208 uint32_t const default_output_id = 0;
2209@@ -84,7 +84,7 @@
2210 output->current_mode = 0;
2211 output->num_output_formats = NoOfFormats;
2212 output->output_formats = format_tmp;
2213- output->current_output_format = 0;
2214+ output->current_output_format = NoOfFormats > 0 ? formats[0] : mir_pixel_format_invalid;
2215 }
2216
2217 template<int NoOfOutputs, int NoOfModes, int NoOfFormats>
2218@@ -257,7 +257,7 @@
2219 mgn::NestedDisplayConfiguration config(build_trivial_configuration());
2220
2221 config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true,
2222- top_left, default_current_mode, mir_power_mode_on);
2223+ top_left, default_current_mode, default_current_output_format, mir_power_mode_on);
2224
2225 MockOutputVisitor ov;
2226 EXPECT_CALL(ov, f(_)).Times(Exactly(1));
2227@@ -268,6 +268,7 @@
2228 EXPECT_EQ(true, output.used);
2229 EXPECT_EQ(top_left, output.top_left);
2230 EXPECT_EQ(0, output.current_mode_index);
2231+ EXPECT_EQ(default_current_output_format, output.current_format);
2232 });
2233 }
2234
2235@@ -278,11 +279,25 @@
2236 mgn::NestedDisplayConfiguration config(build_trivial_configuration());
2237
2238 EXPECT_THROW(
2239- {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, -1, mir_power_mode_on);},
2240- std::runtime_error);
2241-
2242- EXPECT_THROW(
2243- {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, too_big_mode_index, mir_power_mode_on);},
2244+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, -1, default_current_output_format, mir_power_mode_on);},
2245+ std::runtime_error);
2246+
2247+ EXPECT_THROW(
2248+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, too_big_mode_index, default_current_output_format, mir_power_mode_on);},
2249+ std::runtime_error);
2250+}
2251+
2252+TEST_F(NestedDisplayConfiguration, configure_output_rejects_invalid_format)
2253+{
2254+ geom::Point const top_left{10,20};
2255+ mgn::NestedDisplayConfiguration config(build_trivial_configuration());
2256+
2257+ EXPECT_THROW(
2258+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, default_current_mode, mir_pixel_format_invalid, mir_power_mode_on);},
2259+ std::runtime_error);
2260+
2261+ EXPECT_THROW(
2262+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id), true, top_left, default_current_mode, mir_pixel_formats, mir_power_mode_on);},
2263 std::runtime_error);
2264 }
2265
2266@@ -292,11 +307,11 @@
2267 mgn::NestedDisplayConfiguration config(build_trivial_configuration());
2268
2269 EXPECT_THROW(
2270- {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id+1), true, top_left, default_current_mode, mir_power_mode_on);},
2271+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id+1), true, top_left, default_current_mode, default_current_output_format, mir_power_mode_on);},
2272 std::runtime_error);
2273
2274 EXPECT_THROW(
2275- {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id-1), true, top_left, default_current_mode, mir_power_mode_on);},
2276+ {config.configure_output(mg::DisplayConfigurationOutputId(default_output_id-1), true, top_left, default_current_mode, default_current_output_format, mir_power_mode_on);},
2277 std::runtime_error);
2278 }
2279
2280@@ -326,7 +341,7 @@
2281 geom::Point const top_left{100,200};
2282 mgn::NestedDisplayConfiguration config(build_non_trivial_configuration());
2283
2284- config.configure_output(id, true, top_left, 1, mir_power_mode_on);
2285+ config.configure_output(id, true, top_left, 1, mir_pixel_format_argb_8888, mir_power_mode_on);
2286
2287 MockOutputVisitor ov;
2288 EXPECT_CALL(ov, f(_)).Times(Exactly(3));
2289@@ -338,6 +353,7 @@
2290 EXPECT_EQ(true, output.used);
2291 EXPECT_EQ(top_left, output.top_left);
2292 EXPECT_EQ(1, output.current_mode_index);
2293+ EXPECT_EQ(mir_pixel_format_argb_8888, output.current_format);
2294 }
2295 });
2296 }
2297
2298=== modified file 'tests/unit-tests/graphics/test_default_display_configuration_policy.cpp'
2299--- tests/unit-tests/graphics/test_default_display_configuration_policy.cpp 2013-12-17 18:24:51 +0000
2300+++ tests/unit-tests/graphics/test_default_display_configuration_policy.cpp 2014-01-02 11:14:12 +0000
2301@@ -22,149 +22,158 @@
2302 #include <gtest/gtest.h>
2303 #include <gmock/gmock.h>
2304
2305-namespace mg = mir::graphics;
2306-namespace geom = mir::geometry;
2307+using namespace mir::graphics;
2308+using namespace mir::geometry;
2309
2310 namespace
2311 {
2312
2313-class MockDisplayConfiguration : public mg::DisplayConfiguration
2314+class MockDisplayConfiguration : public DisplayConfiguration
2315 {
2316 public:
2317- MockDisplayConfiguration(size_t max_simultaneous_outputs)
2318- : card_id{1}, max_simultaneous_outputs{max_simultaneous_outputs}
2319+ MockDisplayConfiguration(MockDisplayConfiguration && m)
2320+ : max_simultaneous_outputs{m.max_simultaneous_outputs},
2321+ outputs{std::move(m.outputs)}
2322 {
2323- /* Connected with modes */
2324- outputs.push_back(
2325- {
2326- mg::DisplayConfigurationOutputId{10},
2327- card_id,
2328- mg::DisplayConfigurationOutputType::vga,
2329- {
2330- mir_pixel_format_abgr_8888
2331- },
2332- {
2333- {geom::Size{123, 111}, 59.9},
2334- {geom::Size{123, 111}, 59.9},
2335- {geom::Size{123, 111}, 59.9}
2336- },
2337- 2,
2338- geom::Size{324, 642},
2339- true,
2340- false,
2341- geom::Point{geom::X{123}, geom::Y{343}},
2342- 1,
2343- 0,
2344- mir_power_mode_on
2345- });
2346- /* Connected without modes */
2347- outputs.push_back(
2348- {
2349- mg::DisplayConfigurationOutputId{11},
2350- card_id,
2351- mg::DisplayConfigurationOutputType::vga,
2352- {},
2353- {},
2354- std::numeric_limits<size_t>::max(),
2355- geom::Size{566, 111},
2356- true,
2357- false,
2358- geom::Point(),
2359- std::numeric_limits<size_t>::max(),
2360- std::numeric_limits<size_t>::max(),
2361- mir_power_mode_on
2362- });
2363- /* Connected with a single mode */
2364- outputs.push_back(
2365- {
2366- mg::DisplayConfigurationOutputId{12},
2367- card_id,
2368- mg::DisplayConfigurationOutputType::vga,
2369- {
2370- mir_pixel_format_abgr_8888
2371- },
2372- {
2373- {geom::Size{523, 555}, 60.0},
2374- },
2375- 0,
2376- geom::Size{324, 642},
2377- true,
2378- false,
2379- geom::Point(),
2380- 0,
2381- 0,
2382- mir_power_mode_on
2383- });
2384- /* Not connected */
2385- outputs.push_back(
2386- {
2387- mg::DisplayConfigurationOutputId{13},
2388- card_id,
2389- mg::DisplayConfigurationOutputType::vga,
2390- {
2391- mir_pixel_format_abgr_8888
2392- },
2393- {},
2394- 0,
2395- geom::Size{324, 642},
2396- false,
2397- false,
2398- geom::Point(),
2399- 1,
2400- 0,
2401- mir_power_mode_on
2402- });
2403+ }
2404
2405+ MockDisplayConfiguration(size_t max_simultaneous_outputs, std::vector<DisplayConfigurationOutput> && config)
2406+ : max_simultaneous_outputs{max_simultaneous_outputs},
2407+ outputs{config}
2408+ {
2409 if (max_simultaneous_outputs == max_simultaneous_outputs_all)
2410 max_simultaneous_outputs = outputs.size();
2411 }
2412
2413- MockDisplayConfiguration()
2414- : MockDisplayConfiguration{max_simultaneous_outputs_all}
2415- {
2416- }
2417-
2418- void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const
2419- {
2420- f({card_id, max_simultaneous_outputs});
2421- }
2422-
2423- void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)> f) const
2424+ MockDisplayConfiguration(std::vector<DisplayConfigurationOutput> && config)
2425+ : MockDisplayConfiguration(max_simultaneous_outputs_all, std::move(config))
2426+ {
2427+ }
2428+
2429+ void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const
2430+ {
2431+ f({DisplayConfigurationCardId{1}, max_simultaneous_outputs});
2432+ }
2433+
2434+ void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const
2435 {
2436 for (auto const& output : outputs)
2437 f(output);
2438 }
2439
2440- MOCK_METHOD5(configure_output, void(mg::DisplayConfigurationOutputId, bool,
2441- geom::Point, size_t, MirPowerMode));
2442+ MOCK_METHOD6(configure_output, void(DisplayConfigurationOutputId, bool,
2443+ Point, size_t, MirPixelFormat, MirPowerMode));
2444
2445+ static const size_t max_simultaneous_outputs_all{std::numeric_limits<size_t>::max()};
2446 private:
2447- static const size_t max_simultaneous_outputs_all{std::numeric_limits<size_t>::max()};
2448- mg::DisplayConfigurationCardId const card_id;
2449 size_t max_simultaneous_outputs;
2450- std::vector<mg::DisplayConfigurationOutput> outputs;
2451+ std::vector<DisplayConfigurationOutput> outputs;
2452 };
2453
2454 }
2455
2456+DisplayConfigurationOutput default_output(DisplayConfigurationOutputId id)
2457+{
2458+ return { id, DisplayConfigurationCardId{1},
2459+ DisplayConfigurationOutputType::vga,
2460+ {mir_pixel_format_abgr_8888},
2461+ { {Size{523, 555}, 60.0} },
2462+ 0,
2463+ Size{324, 642},
2464+ true,
2465+ false,
2466+ Point{X{123}, Y{343}},
2467+ 0,
2468+ mir_pixel_format_abgr_8888,
2469+ mir_power_mode_on
2470+ };
2471+}
2472+
2473+DisplayConfigurationOutput connected_with_modes()
2474+{
2475+ DisplayConfigurationOutput output = default_output(DisplayConfigurationOutputId{10}) ;
2476+ output.modes =
2477+ {
2478+ {Size{123, 111}, 59.9},
2479+ {Size{123, 111}, 59.9},
2480+ {Size{123, 111}, 59.9}
2481+ };
2482+ output.preferred_mode_index = 2;
2483+ output.current_mode_index = 1;
2484+ return output;
2485+}
2486+DisplayConfigurationOutput connected_without_modes()
2487+{
2488+ DisplayConfigurationOutput output = default_output(DisplayConfigurationOutputId{11});
2489+ output.pixel_formats = {};
2490+ output.modes = {};
2491+ output.current_format = mir_pixel_format_invalid;
2492+ output.current_mode_index = std::numeric_limits<size_t>::max();
2493+ return output;
2494+}
2495+
2496+DisplayConfigurationOutput connected_with_single_mode()
2497+{
2498+ return default_output(DisplayConfigurationOutputId{12});
2499+}
2500+
2501+DisplayConfigurationOutput not_connected()
2502+{
2503+ DisplayConfigurationOutput output = default_output(DisplayConfigurationOutputId{13});
2504+ output.connected = false;
2505+ output.current_mode_index = 1;
2506+ return output;
2507+}
2508+
2509+DisplayConfigurationOutput connected_with_rgba_and_xrgb()
2510+{
2511+ DisplayConfigurationOutput output = default_output(DisplayConfigurationOutputId{14});
2512+ output.pixel_formats = {mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888};
2513+ return output;
2514+}
2515+
2516+DisplayConfigurationOutput connected_with_xrgb_bgr()
2517+{
2518+ DisplayConfigurationOutput output = default_output(DisplayConfigurationOutputId{15});
2519+ output.pixel_formats = {mir_pixel_format_xrgb_8888, mir_pixel_format_bgr_888};
2520+ output.current_format = mir_pixel_format_bgr_888;
2521+ return output;
2522+}
2523+
2524+MockDisplayConfiguration create_default_configuration(size_t max_outputs = MockDisplayConfiguration::max_simultaneous_outputs_all)
2525+{
2526+ return MockDisplayConfiguration
2527+ {
2528+ max_outputs,
2529+ {
2530+ connected_with_modes(),
2531+ connected_without_modes(),
2532+ connected_with_single_mode(),
2533+ not_connected(),
2534+ }
2535+ };
2536+}
2537+
2538 TEST(DefaultDisplayConfigurationPolicyTest, uses_all_connected_valid_outputs)
2539 {
2540 using namespace ::testing;
2541
2542- mg::DefaultDisplayConfigurationPolicy policy;
2543- MockDisplayConfiguration conf;
2544+ DefaultDisplayConfigurationPolicy policy;
2545+ MockDisplayConfiguration conf{create_default_configuration()};
2546
2547- conf.for_each_output([&conf](mg::DisplayConfigurationOutput const& output)
2548+ conf.for_each_output([&conf](DisplayConfigurationOutput const& output)
2549 {
2550 if (output.connected && output.modes.size() > 0)
2551 {
2552- EXPECT_CALL(conf, configure_output(output.id, true, geom::Point(),
2553- output.preferred_mode_index, _));
2554+ EXPECT_CALL(conf, configure_output(output.id, true, Point(),
2555+ output.preferred_mode_index,
2556+ _, _));
2557 }
2558 else
2559 {
2560 EXPECT_CALL(conf, configure_output(output.id, false, output.top_left,
2561- output.current_mode_index, _));
2562+ output.current_mode_index,
2563+ _, _));
2564 }
2565 });
2566
2567@@ -175,12 +184,12 @@
2568 {
2569 using namespace ::testing;
2570
2571- mg::DefaultDisplayConfigurationPolicy policy;
2572- MockDisplayConfiguration conf;
2573+ DefaultDisplayConfigurationPolicy policy;
2574+ MockDisplayConfiguration conf{create_default_configuration()};
2575
2576- conf.for_each_output([&conf](mg::DisplayConfigurationOutput const& output)
2577+ conf.for_each_output([&conf](DisplayConfigurationOutput const& output)
2578 {
2579- EXPECT_CALL(conf, configure_output(output.id, _, _, _, mir_power_mode_on));
2580+ EXPECT_CALL(conf, configure_output(output.id, _, _, _, _, mir_power_mode_on));
2581 });
2582
2583 policy.apply_to(conf);
2584@@ -191,20 +200,54 @@
2585 using namespace ::testing;
2586
2587 size_t const max_simultaneous_outputs{1};
2588- mg::DefaultDisplayConfigurationPolicy policy;
2589- MockDisplayConfiguration conf{max_simultaneous_outputs};
2590+ DefaultDisplayConfigurationPolicy policy;
2591+ MockDisplayConfiguration conf{create_default_configuration(max_simultaneous_outputs)};
2592
2593 size_t output_count{0};
2594- conf.for_each_output([&output_count](mg::DisplayConfigurationOutput const&)
2595+ conf.for_each_output([&output_count](DisplayConfigurationOutput const&)
2596 {
2597 ++output_count;
2598 });
2599
2600- EXPECT_CALL(conf, configure_output(_, true, _, _, _))
2601+ EXPECT_CALL(conf, configure_output(_, true, _, _, _, _))
2602 .Times(AtMost(max_simultaneous_outputs));
2603
2604- EXPECT_CALL(conf, configure_output(_, false, _, _, _))
2605+ EXPECT_CALL(conf, configure_output(_, false, _, _, _, _))
2606 .Times(AtLeast(output_count - max_simultaneous_outputs));
2607
2608 policy.apply_to(conf);
2609 }
2610+
2611+TEST(DefaultDisplayConfigurationPolicyTest, prefer_opaque_over_alpha)
2612+{
2613+ using namespace ::testing;
2614+
2615+ DefaultDisplayConfigurationPolicy policy;
2616+ MockDisplayConfiguration pick_xrgb{ { connected_with_rgba_and_xrgb() } };
2617+
2618+ EXPECT_CALL(pick_xrgb, configure_output(_, true, _, _, mir_pixel_format_xrgb_8888, _));
2619+ policy.apply_to(pick_xrgb);
2620+}
2621+
2622+TEST(DefaultDisplayConfigurationPolicyTest, preserve_opaque_selection)
2623+{
2624+ using namespace ::testing;
2625+
2626+ DefaultDisplayConfigurationPolicy policy;
2627+ MockDisplayConfiguration keep_bgr{ { connected_with_xrgb_bgr() } };
2628+
2629+ EXPECT_CALL(keep_bgr, configure_output(_, true, _, _, mir_pixel_format_bgr_888, _));
2630+ policy.apply_to(keep_bgr);
2631+}
2632+
2633+TEST(DefaultDisplayConfigurationPolicyTest, accept_transparency_when_only_option)
2634+{
2635+ using namespace ::testing;
2636+
2637+ DefaultDisplayConfigurationPolicy policy;
2638+ MockDisplayConfiguration pick_rgba{ { default_output(DisplayConfigurationOutputId{15}) } };
2639+
2640+ EXPECT_CALL(pick_rgba, configure_output(_, true, _, _, mir_pixel_format_abgr_8888, _));
2641+ policy.apply_to(pick_rgba);
2642+}
2643+
2644
2645=== modified file 'tests/unit-tests/graphics/test_display_configuration.cpp'
2646--- tests/unit-tests/graphics/test_display_configuration.cpp 2013-12-17 18:24:51 +0000
2647+++ tests/unit-tests/graphics/test_display_configuration.cpp 2014-01-02 11:14:12 +0000
2648@@ -45,7 +45,7 @@
2649 true,
2650 geom::Point(),
2651 2,
2652- 0,
2653+ mir_pixel_format_abgr_8888,
2654 mir_power_mode_on
2655 };
2656
2657
2658=== added file 'tests/unit-tests/graphics/test_pixel_format_utils.cpp'
2659--- tests/unit-tests/graphics/test_pixel_format_utils.cpp 1970-01-01 00:00:00 +0000
2660+++ tests/unit-tests/graphics/test_pixel_format_utils.cpp 2014-01-02 11:14:12 +0000
2661@@ -0,0 +1,90 @@
2662+/*
2663+ * Copyright © 2013 Canonical Ltd.
2664+ *
2665+ * This program is free software: you can redistribute it and/or modify it
2666+ * under the terms of the GNU General Public License version 3,
2667+ * as published by the Free Software Foundation.
2668+ *
2669+ * This program is distributed in the hope that it will be useful,
2670+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2671+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2672+ * GNU General Public License for more details.
2673+ *
2674+ * You should have received a copy of the GNU General Public License
2675+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2676+ *
2677+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
2678+ */
2679+
2680+#include "mir_toolkit/common.h"
2681+#include "mir/graphics/pixel_format_utils.h"
2682+#include <gmock/gmock.h>
2683+#include <gtest/gtest.h>
2684+
2685+using namespace mir::graphics;
2686+TEST(MirPixelFormatUtils, contains_alpha)
2687+{
2688+ EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
2689+ EXPECT_FALSE(contains_alpha(mir_pixel_format_bgr_888));
2690+ EXPECT_FALSE(contains_alpha(mir_pixel_format_xrgb_8888));
2691+ EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888));
2692+ EXPECT_TRUE(contains_alpha(mir_pixel_format_argb_8888));
2693+ EXPECT_TRUE(contains_alpha(mir_pixel_format_abgr_8888));
2694+ EXPECT_FALSE(contains_alpha(mir_pixel_format_invalid));
2695+}
2696+
2697+TEST(MirPixelFormatUtils, red_channel_depths)
2698+{
2699+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
2700+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_bgr_888));
2701+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xrgb_8888));
2702+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888));
2703+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_argb_8888));
2704+ EXPECT_EQ(8, red_channel_depth(mir_pixel_format_abgr_8888));
2705+ EXPECT_EQ(0, red_channel_depth(mir_pixel_format_invalid));
2706+}
2707+
2708+TEST(MirPixelFormatUtils, blue_channel_depths)
2709+{
2710+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
2711+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_bgr_888));
2712+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xrgb_8888));
2713+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888));
2714+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_argb_8888));
2715+ EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_abgr_8888));
2716+ EXPECT_EQ(0, blue_channel_depth(mir_pixel_format_invalid));
2717+}
2718+
2719+TEST(MirPixelFormatUtils, green_channel_depths)
2720+{
2721+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
2722+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_bgr_888));
2723+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xrgb_8888));
2724+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888));
2725+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_argb_8888));
2726+ EXPECT_EQ(8, green_channel_depth(mir_pixel_format_abgr_8888));
2727+ EXPECT_EQ(0, green_channel_depth(mir_pixel_format_invalid));
2728+}
2729+
2730+
2731+TEST(MirPixelFormatUtils, alpha_channel_depths)
2732+{
2733+ EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
2734+ EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_bgr_888));
2735+ EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xrgb_8888));
2736+ EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888));
2737+ EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_argb_8888));
2738+ EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_abgr_8888));
2739+ EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_invalid));
2740+}
2741+
2742+TEST(MirPixelFormatUtils, valid_mir_pixel_format)
2743+{
2744+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_xbgr_8888));
2745+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_bgr_888));
2746+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_xrgb_8888));
2747+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_xbgr_8888));
2748+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_argb_8888));
2749+ EXPECT_TRUE(valid_mir_pixel_format(mir_pixel_format_abgr_8888));
2750+ EXPECT_FALSE(valid_mir_pixel_format(mir_pixel_format_invalid));
2751+}

Subscribers

People subscribed via source and target branches