Merge lp:~andreas-pokorny/mir/pixel-format-utils into lp:mir/0.1
- pixel-format-utils
- Merge into trusty
Proposed by
Andreas Pokorny
Status: | Superseded |
---|---|
Proposed branch: | lp:~andreas-pokorny/mir/pixel-format-utils |
Merge into: | lp:mir/0.1 |
Diff against target: |
886 lines (+444/-102) 22 files modified
benchmarks/CMakeLists.txt (+3/-1) doc/building_source_for_android.md (+21/-32) include/platform/mir/graphics/pixel_format_utils.h (+45/-0) include/shared/mir/logging/input_timestamp.h (+35/-0) include/test/mir_test_doubles/mock_surface_renderer.h (+2/-1) src/client/logging/input_receiver_report.cpp (+3/-2) src/platform/graphics/CMakeLists.txt (+1/-0) 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/logging/input_report.cpp (+4/-3) 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_framework/stubbed_server_configuration.cpp (+5/-1) tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+63/-2) tests/unit-tests/graphics/CMakeLists.txt (+1/-0) tests/unit-tests/graphics/test_pixel_format_utils.cpp (+90/-0) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/pixel-format-utils |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+200277@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-01-02.
Commit message
Add mir pixel format utility functions
Description of the change
Add mir pixel format utility functions
To post a comment you must log in.
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 07:37:29 +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 07:37:29 +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 | === added file 'include/platform/mir/graphics/pixel_format_utils.h' |
78 | --- include/platform/mir/graphics/pixel_format_utils.h 1970-01-01 00:00:00 +0000 |
79 | +++ include/platform/mir/graphics/pixel_format_utils.h 2014-01-02 07:37:29 +0000 |
80 | @@ -0,0 +1,45 @@ |
81 | +/* |
82 | + * Copyright © 2013 Canonical Ltd. |
83 | + * |
84 | + * This program is free software: you can redistribute it and/or modify it |
85 | + * under the terms of the GNU Lesser General Public License version 3, |
86 | + * as published by the Free Software Foundation. |
87 | + * |
88 | + * This program is distributed in the hope that it will be useful, |
89 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
90 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91 | + * GNU Lesser General Public License for more details. |
92 | + * |
93 | + * You should have received a copy of the GNU Lesser General Public License |
94 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
95 | + * |
96 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
97 | + */ |
98 | + |
99 | +#include "mir_toolkit/common.h" |
100 | + |
101 | +namespace mir |
102 | +{ |
103 | +namespace graphics |
104 | +{ |
105 | + |
106 | +/*! |
107 | + * \name MirPixelFormat utility functions |
108 | + * |
109 | + * A set of functions to query details of MirPixelFormat |
110 | + * TODO improve this through https://bugs.launchpad.net/mir/+bug/1236254 |
111 | + * \{ |
112 | + */ |
113 | +bool contains_alpha(MirPixelFormat format); |
114 | +int red_channel_depth(MirPixelFormat format); |
115 | +int blue_channel_depth(MirPixelFormat format); |
116 | +int green_channel_depth(MirPixelFormat format); |
117 | +int alpha_channel_depth(MirPixelFormat format); |
118 | +bool valid_format(MirPixelFormat format); |
119 | +/*! |
120 | + * \} |
121 | + */ |
122 | + |
123 | + |
124 | +} |
125 | +} |
126 | |
127 | === added file 'include/shared/mir/logging/input_timestamp.h' |
128 | --- include/shared/mir/logging/input_timestamp.h 1970-01-01 00:00:00 +0000 |
129 | +++ include/shared/mir/logging/input_timestamp.h 2014-01-02 07:37:29 +0000 |
130 | @@ -0,0 +1,35 @@ |
131 | +/* |
132 | + * Copyright © 2013 Canonical Ltd. |
133 | + * |
134 | + * This program is free software: you can redistribute it and/or modify it |
135 | + * under the terms of the GNU Lesser General Public License version 3, |
136 | + * as published by the Free Software Foundation. |
137 | + * |
138 | + * This program is distributed in the hope that it will be useful, |
139 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
140 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
141 | + * GNU Lesser General Public License for more details. |
142 | + * |
143 | + * You should have received a copy of the GNU Lesser General Public License |
144 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
145 | + * |
146 | + * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
147 | + */ |
148 | + |
149 | +#ifndef MIR_LOGGING_INPUT_TIMESTAMP_H_ |
150 | +#define MIR_LOGGING_INPUT_TIMESTAMP_H_ |
151 | + |
152 | +#include "mir_toolkit/event.h" |
153 | +#include <string> |
154 | + |
155 | +namespace mir |
156 | +{ |
157 | +namespace logging |
158 | +{ |
159 | + |
160 | +std::string input_timestamp(nsecs_t when); |
161 | + |
162 | +} |
163 | +} |
164 | + |
165 | +#endif // MIR_LOGGING_INPUT_TIMESTAMP_H_ |
166 | |
167 | === modified file 'include/test/mir_test_doubles/mock_surface_renderer.h' |
168 | --- include/test/mir_test_doubles/mock_surface_renderer.h 2013-12-17 18:24:51 +0000 |
169 | +++ include/test/mir_test_doubles/mock_surface_renderer.h 2014-01-02 07:37:29 +0000 |
170 | @@ -31,8 +31,9 @@ |
171 | |
172 | struct MockSurfaceRenderer : public compositor::Renderer |
173 | { |
174 | + MOCK_CONST_METHOD0(begin, void()); |
175 | MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&)); |
176 | - MOCK_CONST_METHOD0(clear, void()); |
177 | + MOCK_CONST_METHOD0(end, void()); |
178 | |
179 | ~MockSurfaceRenderer() noexcept {} |
180 | }; |
181 | |
182 | === modified file 'src/client/logging/input_receiver_report.cpp' |
183 | --- src/client/logging/input_receiver_report.cpp 2013-12-17 18:24:51 +0000 |
184 | +++ src/client/logging/input_receiver_report.cpp 2014-01-02 07:37:29 +0000 |
185 | @@ -19,6 +19,7 @@ |
186 | #include "input_receiver_report.h" |
187 | |
188 | #include "mir/logging/logger.h" |
189 | +#include "mir/logging/input_timestamp.h" |
190 | |
191 | #include <boost/throw_exception.hpp> |
192 | |
193 | @@ -53,7 +54,7 @@ |
194 | ss << " scan_code: " << ev.scan_code << std::endl; |
195 | ss << " repeat_count: " << ev.repeat_count << std::endl; |
196 | ss << " down_time: " << ev.down_time << std::endl; |
197 | - ss << " event_time: " << ev.event_time << std::endl; |
198 | + ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl; |
199 | ss << " is_system_key: " << ev.is_system_key << std::endl; |
200 | ss << "}"; |
201 | } |
202 | @@ -73,7 +74,7 @@ |
203 | ss << " x_precision: " << ev.x_precision << std::endl; |
204 | ss << " y_precision: " << ev.y_precision << std::endl; |
205 | ss << " down_time: " << ev.down_time << std::endl; |
206 | - ss << " event_time: " << ev.event_time << std::endl; |
207 | + ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl; |
208 | ss << " pointer_count: " << ev.pointer_count << std::endl; |
209 | for (unsigned int i = 0; i < ev.pointer_count; i++) |
210 | { |
211 | |
212 | === modified file 'src/platform/graphics/CMakeLists.txt' |
213 | --- src/platform/graphics/CMakeLists.txt 2013-12-17 18:24:51 +0000 |
214 | +++ src/platform/graphics/CMakeLists.txt 2014-01-02 07:37:29 +0000 |
215 | @@ -10,6 +10,7 @@ |
216 | display_configuration.cpp |
217 | null_display_report.cpp |
218 | buffer_basic.cpp |
219 | + pixel_format_utils.cpp |
220 | ) |
221 | |
222 | add_library( |
223 | |
224 | === added file 'src/platform/graphics/pixel_format_utils.cpp' |
225 | --- src/platform/graphics/pixel_format_utils.cpp 1970-01-01 00:00:00 +0000 |
226 | +++ src/platform/graphics/pixel_format_utils.cpp 2014-01-02 07:37:29 +0000 |
227 | @@ -0,0 +1,71 @@ |
228 | +/* |
229 | + * Copyright © 2013 Canonical Ltd. |
230 | + * |
231 | + * This program is free software: you can redistribute it and/or modify it |
232 | + * under the terms of the GNU Lesser General Public License version 3, |
233 | + * as published by the Free Software Foundation. |
234 | + * |
235 | + * This program is distributed in the hope that it will be useful, |
236 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
237 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
238 | + * GNU Lesser General Public License for more details. |
239 | + * |
240 | + * You should have received a copy of the GNU Lesser General Public License |
241 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
242 | + * |
243 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
244 | + */ |
245 | + |
246 | +#include "mir/graphics/pixel_format_utils.h" |
247 | + |
248 | +namespace mir |
249 | +{ |
250 | +namespace graphics |
251 | +{ |
252 | + |
253 | +bool contains_alpha(MirPixelFormat format) |
254 | +{ |
255 | + return (format == mir_pixel_format_abgr_8888 || |
256 | + format == mir_pixel_format_argb_8888); |
257 | +} |
258 | + |
259 | +int red_channel_depth(MirPixelFormat format) |
260 | +{ |
261 | + if (mir_pixel_format_invalid < format && |
262 | + format < mir_pixel_formats) |
263 | + return 8; |
264 | + return 0; |
265 | +} |
266 | + |
267 | +int blue_channel_depth(MirPixelFormat format) |
268 | +{ |
269 | + if (mir_pixel_format_invalid < format && |
270 | + format < mir_pixel_formats) |
271 | + return 8; |
272 | + return 0; |
273 | +} |
274 | + |
275 | +int green_channel_depth(MirPixelFormat format) |
276 | +{ |
277 | + if (mir_pixel_format_invalid < format && |
278 | + format < mir_pixel_formats) |
279 | + return 8; |
280 | + return 0; |
281 | +} |
282 | + |
283 | +int alpha_channel_depth(MirPixelFormat format) |
284 | +{ |
285 | + if (format == mir_pixel_format_abgr_8888 || |
286 | + format == mir_pixel_format_argb_8888) |
287 | + return 8; |
288 | + return 0; |
289 | +} |
290 | + |
291 | +bool valid_format(MirPixelFormat format) |
292 | +{ |
293 | + return (format > mir_pixel_format_invalid && |
294 | + format < mir_pixel_formats); |
295 | +} |
296 | + |
297 | +} |
298 | +} |
299 | |
300 | === modified file 'src/server/compositor/default_display_buffer_compositor.cpp' |
301 | --- src/server/compositor/default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000 |
302 | +++ src/server/compositor/default_display_buffer_compositor.cpp 2014-01-02 07:37:29 +0000 |
303 | @@ -135,10 +135,11 @@ |
304 | mc::OcclusionMatch occlusion_match; |
305 | scene->reverse_for_each_if(occlusion_search, occlusion_match); |
306 | |
307 | - renderer->clear(); |
308 | + renderer->begin(); |
309 | mc::RenderingOperator applicator(*renderer, save_resource, local_frameno); |
310 | FilterForVisibleSceneInRegion selector(view_area, occlusion_match); |
311 | scene->for_each_if(selector, applicator); |
312 | + renderer->end(); |
313 | |
314 | display_buffer.post_update(); |
315 | } |
316 | |
317 | === modified file 'src/server/compositor/gl_renderer.cpp' |
318 | --- src/server/compositor/gl_renderer.cpp 2013-12-17 18:24:51 +0000 |
319 | +++ src/server/compositor/gl_renderer.cpp 2014-01-02 07:37:29 +0000 |
320 | @@ -117,7 +117,7 @@ |
321 | |
322 | } |
323 | |
324 | -mc::GLRenderer::Resources::Resources() : |
325 | +mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) : |
326 | vertex_shader(0), |
327 | fragment_shader(0), |
328 | program(0), |
329 | @@ -128,24 +128,6 @@ |
330 | vertex_attribs_vbo(0), |
331 | texture(0) |
332 | { |
333 | -} |
334 | - |
335 | -mc::GLRenderer::Resources::~Resources() |
336 | -{ |
337 | - if (vertex_shader) |
338 | - glDeleteShader(vertex_shader); |
339 | - if (fragment_shader) |
340 | - glDeleteShader(fragment_shader); |
341 | - if (program) |
342 | - glDeleteProgram(program); |
343 | - if (vertex_attribs_vbo) |
344 | - glDeleteBuffers(1, &vertex_attribs_vbo); |
345 | - if (texture) |
346 | - glDeleteTextures(1, &texture); |
347 | -} |
348 | - |
349 | -void mc::GLRenderer::Resources::setup(geometry::Rectangle const& display_area) |
350 | -{ |
351 | GLint param = 0; |
352 | |
353 | /* Create shaders and program */ |
354 | @@ -235,14 +217,23 @@ |
355 | glUseProgram(0); |
356 | } |
357 | |
358 | -mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) |
359 | +mc::GLRenderer::~GLRenderer() noexcept |
360 | { |
361 | - resources.setup(display_area); |
362 | + if (vertex_shader) |
363 | + glDeleteShader(vertex_shader); |
364 | + if (fragment_shader) |
365 | + glDeleteShader(fragment_shader); |
366 | + if (program) |
367 | + glDeleteProgram(program); |
368 | + if (vertex_attribs_vbo) |
369 | + glDeleteBuffers(1, &vertex_attribs_vbo); |
370 | + if (texture) |
371 | + glDeleteTextures(1, &texture); |
372 | } |
373 | |
374 | void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const |
375 | { |
376 | - glUseProgram(resources.program); |
377 | + glUseProgram(program); |
378 | |
379 | if (criteria.shaped() || criteria.alpha() < 1.0f) |
380 | { |
381 | @@ -255,32 +246,36 @@ |
382 | } |
383 | glActiveTexture(GL_TEXTURE0); |
384 | |
385 | - glUniformMatrix4fv(resources.transform_uniform_loc, 1, GL_FALSE, |
386 | + glUniformMatrix4fv(transform_uniform_loc, 1, GL_FALSE, |
387 | glm::value_ptr(criteria.transformation())); |
388 | - glUniform1f(resources.alpha_uniform_loc, criteria.alpha()); |
389 | + glUniform1f(alpha_uniform_loc, criteria.alpha()); |
390 | |
391 | /* Set up vertex attribute data */ |
392 | - glBindBuffer(GL_ARRAY_BUFFER, resources.vertex_attribs_vbo); |
393 | - glVertexAttribPointer(resources.position_attr_loc, 3, GL_FLOAT, |
394 | + glBindBuffer(GL_ARRAY_BUFFER, vertex_attribs_vbo); |
395 | + glVertexAttribPointer(position_attr_loc, 3, GL_FLOAT, |
396 | GL_FALSE, sizeof(VertexAttributes), 0); |
397 | - glVertexAttribPointer(resources.texcoord_attr_loc, 2, GL_FLOAT, |
398 | + glVertexAttribPointer(texcoord_attr_loc, 2, GL_FLOAT, |
399 | GL_FALSE, sizeof(VertexAttributes), |
400 | reinterpret_cast<void*>(sizeof(glm::vec3))); |
401 | |
402 | /* Use the renderable's texture */ |
403 | - glBindTexture(GL_TEXTURE_2D, resources.texture); |
404 | + glBindTexture(GL_TEXTURE_2D, texture); |
405 | |
406 | buffer.bind_to_texture(); |
407 | |
408 | /* Draw */ |
409 | - glEnableVertexAttribArray(resources.position_attr_loc); |
410 | - glEnableVertexAttribArray(resources.texcoord_attr_loc); |
411 | + glEnableVertexAttribArray(position_attr_loc); |
412 | + glEnableVertexAttribArray(texcoord_attr_loc); |
413 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
414 | - glDisableVertexAttribArray(resources.texcoord_attr_loc); |
415 | - glDisableVertexAttribArray(resources.position_attr_loc); |
416 | + glDisableVertexAttribArray(texcoord_attr_loc); |
417 | + glDisableVertexAttribArray(position_attr_loc); |
418 | } |
419 | |
420 | -void mc::GLRenderer::clear() const |
421 | +void mc::GLRenderer::begin() const |
422 | { |
423 | glClear(GL_COLOR_BUFFER_BIT); |
424 | } |
425 | + |
426 | +void mc::GLRenderer::end() const |
427 | +{ |
428 | +} |
429 | |
430 | === modified file 'src/server/compositor/gl_renderer.h' |
431 | --- src/server/compositor/gl_renderer.h 2013-12-17 18:24:51 +0000 |
432 | +++ src/server/compositor/gl_renderer.h 2014-01-02 07:37:29 +0000 |
433 | @@ -32,32 +32,22 @@ |
434 | { |
435 | public: |
436 | GLRenderer(geometry::Rectangle const& display_area); |
437 | + virtual ~GLRenderer() noexcept; |
438 | |
439 | + void begin() const override; |
440 | void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override; |
441 | - void clear() const override; |
442 | - |
443 | - ~GLRenderer() noexcept {} |
444 | + void end() const override; |
445 | |
446 | private: |
447 | - class Resources |
448 | - { |
449 | - public: |
450 | - Resources(); |
451 | - ~Resources(); |
452 | - void setup(geometry::Rectangle const& display_area); |
453 | - |
454 | - GLuint vertex_shader; |
455 | - GLuint fragment_shader; |
456 | - GLuint program; |
457 | - GLuint position_attr_loc; |
458 | - GLuint texcoord_attr_loc; |
459 | - GLuint transform_uniform_loc; |
460 | - GLuint alpha_uniform_loc; |
461 | - GLuint vertex_attribs_vbo; |
462 | - GLuint texture; |
463 | - }; |
464 | - |
465 | - Resources resources; |
466 | + GLuint vertex_shader; |
467 | + GLuint fragment_shader; |
468 | + GLuint program; |
469 | + GLuint position_attr_loc; |
470 | + GLuint texcoord_attr_loc; |
471 | + GLuint transform_uniform_loc; |
472 | + GLuint alpha_uniform_loc; |
473 | + GLuint vertex_attribs_vbo; |
474 | + GLuint texture; |
475 | }; |
476 | |
477 | } |
478 | |
479 | === modified file 'src/server/compositor/renderer.h' |
480 | --- src/server/compositor/renderer.h 2013-12-17 18:24:51 +0000 |
481 | +++ src/server/compositor/renderer.h 2014-01-02 07:37:29 +0000 |
482 | @@ -34,8 +34,9 @@ |
483 | public: |
484 | virtual ~Renderer() = default; |
485 | |
486 | - virtual void clear() const = 0; |
487 | + virtual void begin() const = 0; |
488 | virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0; |
489 | + virtual void end() const = 0; |
490 | |
491 | protected: |
492 | Renderer() = default; |
493 | |
494 | === modified file 'src/server/logging/input_report.cpp' |
495 | --- src/server/logging/input_report.cpp 2013-12-19 16:33:56 +0000 |
496 | +++ src/server/logging/input_report.cpp 2014-01-02 07:37:29 +0000 |
497 | @@ -18,6 +18,7 @@ |
498 | |
499 | #include "mir/logging/input_report.h" |
500 | #include "mir/logging/logger.h" |
501 | +#include "mir/logging/input_timestamp.h" |
502 | |
503 | #include "std/MirLog.h" |
504 | #include <std/Log.h> |
505 | @@ -108,7 +109,7 @@ |
506 | std::stringstream ss; |
507 | |
508 | ss << "Received event" |
509 | - << " time=" << when |
510 | + << " time=" << ml::input_timestamp(when) |
511 | << " type=" << type |
512 | << " code=" << code |
513 | << " value=" << value; |
514 | @@ -122,7 +123,7 @@ |
515 | |
516 | ss << "Published key event" |
517 | << " seq_id=" << seq_id |
518 | - << " time=" << event_time |
519 | + << " time=" << ml::input_timestamp(event_time) |
520 | << " dest_fd=" << dest_fd; |
521 | |
522 | logger->log(Logger::informational, ss.str(), component()); |
523 | @@ -134,7 +135,7 @@ |
524 | |
525 | ss << "Published motion event" |
526 | << " seq_id=" << seq_id |
527 | - << " time=" << event_time |
528 | + << " time=" << ml::input_timestamp(event_time) |
529 | << " dest_fd=" << dest_fd; |
530 | |
531 | logger->log(Logger::informational, ss.str(), component()); |
532 | |
533 | === modified file 'src/shared/logging/CMakeLists.txt' |
534 | --- src/shared/logging/CMakeLists.txt 2013-12-12 07:51:12 +0000 |
535 | +++ src/shared/logging/CMakeLists.txt 2014-01-02 07:37:29 +0000 |
536 | @@ -16,4 +16,5 @@ |
537 | |
538 | add_library(mirsharedlogging STATIC |
539 | dumb_console_logger.cpp |
540 | + input_timestamp.cpp |
541 | ) |
542 | |
543 | === added file 'src/shared/logging/input_timestamp.cpp' |
544 | --- src/shared/logging/input_timestamp.cpp 1970-01-01 00:00:00 +0000 |
545 | +++ src/shared/logging/input_timestamp.cpp 2014-01-02 07:37:29 +0000 |
546 | @@ -0,0 +1,41 @@ |
547 | +/* |
548 | + * Copyright © 2013 Canonical Ltd. |
549 | + * |
550 | + * This program is free software: you can redistribute it and/or modify it |
551 | + * under the terms of the GNU Lesser General Public License version 3, |
552 | + * as published by the Free Software Foundation. |
553 | + * |
554 | + * This program is distributed in the hope that it will be useful, |
555 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
556 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
557 | + * GNU Lesser General Public License for more details. |
558 | + * |
559 | + * You should have received a copy of the GNU Lesser General Public License |
560 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
561 | + * |
562 | + * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
563 | + */ |
564 | + |
565 | +#include "mir/logging/input_timestamp.h" |
566 | +#include <ctime> |
567 | +#include <cstdio> |
568 | +#include <string> |
569 | + |
570 | +std::string mir::logging::input_timestamp(nsecs_t when) |
571 | +{ |
572 | + // Input events use CLOCK_REALTIME, and so we must... |
573 | + struct timespec ts; |
574 | + clock_gettime(CLOCK_REALTIME, &ts); |
575 | + |
576 | + nsecs_t now = ts.tv_sec * 1000000000LL + ts.tv_nsec; |
577 | + nsecs_t age = now - when; |
578 | + |
579 | + char str[64]; |
580 | + snprintf(str, sizeof str, "%lld (%ld.%06ld ms ago)", |
581 | + static_cast<long long>(when), |
582 | + static_cast<long>(age / 1000000LL), |
583 | + static_cast<long>(age % 1000000LL)); |
584 | + |
585 | + return std::string(str); |
586 | +} |
587 | + |
588 | |
589 | === modified file 'tests/acceptance-tests/test_server_shutdown.cpp' |
590 | --- tests/acceptance-tests/test_server_shutdown.cpp 2013-12-17 18:24:51 +0000 |
591 | +++ tests/acceptance-tests/test_server_shutdown.cpp 2014-01-02 07:37:29 +0000 |
592 | @@ -48,6 +48,10 @@ |
593 | class NullRenderer : public mc::Renderer |
594 | { |
595 | public: |
596 | + void begin() const override |
597 | + { |
598 | + } |
599 | + |
600 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
601 | { |
602 | /* |
603 | @@ -58,7 +62,7 @@ |
604 | std::this_thread::yield(); |
605 | } |
606 | |
607 | - void clear() const override |
608 | + void end() const override |
609 | { |
610 | } |
611 | }; |
612 | |
613 | === modified file 'tests/integration-tests/test_session.cpp' |
614 | --- tests/integration-tests/test_session.cpp 2013-12-17 18:24:51 +0000 |
615 | +++ tests/integration-tests/test_session.cpp 2014-01-02 07:37:29 +0000 |
616 | @@ -87,12 +87,15 @@ |
617 | { |
618 | struct StubRenderer : public mc::Renderer |
619 | { |
620 | - void clear() const override |
621 | + void begin() const override |
622 | { |
623 | } |
624 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
625 | { |
626 | } |
627 | + void end() const override |
628 | + { |
629 | + } |
630 | }; |
631 | |
632 | struct StubRendererFactory : public mc::RendererFactory |
633 | |
634 | === modified file 'tests/integration-tests/test_surface_first_frame_sync.cpp' |
635 | --- tests/integration-tests/test_surface_first_frame_sync.cpp 2013-12-17 18:24:51 +0000 |
636 | +++ tests/integration-tests/test_surface_first_frame_sync.cpp 2014-01-02 07:37:29 +0000 |
637 | @@ -96,7 +96,7 @@ |
638 | { |
639 | } |
640 | |
641 | - void clear() const override |
642 | + void begin() const override |
643 | { |
644 | } |
645 | |
646 | @@ -105,6 +105,10 @@ |
647 | while (write(render_operations_fd, "a", 1) != 1) continue; |
648 | } |
649 | |
650 | + void end() const override |
651 | + { |
652 | + } |
653 | + |
654 | private: |
655 | int render_operations_fd; |
656 | }; |
657 | |
658 | === modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp' |
659 | --- tests/mir_test_framework/stubbed_server_configuration.cpp 2013-12-19 16:34:53 +0000 |
660 | +++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-01-02 07:37:29 +0000 |
661 | @@ -201,11 +201,15 @@ |
662 | class StubRenderer : public mc::Renderer |
663 | { |
664 | public: |
665 | + void begin() const override |
666 | + { |
667 | + } |
668 | + |
669 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
670 | { |
671 | } |
672 | |
673 | - void clear() const override |
674 | + void end() const override |
675 | { |
676 | } |
677 | }; |
678 | |
679 | === modified file 'tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp' |
680 | --- tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2013-12-17 18:24:51 +0000 |
681 | +++ tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2014-01-02 07:37:29 +0000 |
682 | @@ -106,9 +106,9 @@ |
683 | { |
684 | } |
685 | |
686 | - void clear() const override |
687 | + void begin() const override |
688 | { |
689 | - renderer->clear(); |
690 | + renderer->begin(); |
691 | } |
692 | |
693 | void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override |
694 | @@ -116,6 +116,11 @@ |
695 | renderer->render(criteria, buffer); |
696 | } |
697 | |
698 | + void end() const override |
699 | + { |
700 | + renderer->end(); |
701 | + } |
702 | + |
703 | mc::Renderer* const renderer; |
704 | }; |
705 | |
706 | @@ -241,10 +246,14 @@ |
707 | renderable_vec.push_back(&small); |
708 | renderable_vec.push_back(&fullscreen); |
709 | |
710 | + EXPECT_CALL(renderer_factory.mock_renderer, begin()) |
711 | + .Times(0); |
712 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_)) |
713 | .Times(0); |
714 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_)) |
715 | .Times(0); |
716 | + EXPECT_CALL(renderer_factory.mock_renderer, end()) |
717 | + .Times(0); |
718 | |
719 | FakeScene scene(renderable_vec); |
720 | |
721 | @@ -263,6 +272,58 @@ |
722 | comp->composite(); |
723 | } |
724 | |
725 | +TEST(DefaultDisplayBufferCompositor, calls_renderer_in_sequence) |
726 | +{ |
727 | + using namespace testing; |
728 | + |
729 | + StubRendererFactory renderer_factory; |
730 | + |
731 | + geom::Rectangle screen{{0, 0}, {1366, 768}}; |
732 | + |
733 | + mtd::MockDisplayBuffer display_buffer; |
734 | + |
735 | + EXPECT_CALL(display_buffer, view_area()) |
736 | + .WillRepeatedly(Return(screen)); |
737 | + EXPECT_CALL(display_buffer, can_bypass()) |
738 | + .WillRepeatedly(Return(false)); |
739 | + |
740 | + mtd::StubCompositingCriteria big(5, 10, 100, 200); |
741 | + mtd::StubCompositingCriteria small(10, 20, 30, 40); |
742 | + |
743 | + std::vector<mc::CompositingCriteria*> renderable_vec; |
744 | + renderable_vec.push_back(&big); |
745 | + renderable_vec.push_back(&small); |
746 | + |
747 | + Sequence render_seq; |
748 | + |
749 | + EXPECT_CALL(display_buffer, make_current()) |
750 | + .InSequence(render_seq); |
751 | + EXPECT_CALL(renderer_factory.mock_renderer, begin()) |
752 | + .InSequence(render_seq); |
753 | + EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(big),_)) |
754 | + .InSequence(render_seq); |
755 | + EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_)) |
756 | + .InSequence(render_seq); |
757 | + EXPECT_CALL(renderer_factory.mock_renderer, end()) |
758 | + .InSequence(render_seq); |
759 | + EXPECT_CALL(display_buffer, post_update()) |
760 | + .InSequence(render_seq); |
761 | + |
762 | + FakeScene scene(renderable_vec); |
763 | + |
764 | + auto compositor_buffer = std::make_shared<mtd::MockBuffer>(); |
765 | + EXPECT_CALL(*compositor_buffer, can_bypass()) |
766 | + .Times(0); |
767 | + |
768 | + mc::DefaultDisplayBufferCompositorFactory factory( |
769 | + mt::fake_shared(scene), |
770 | + mt::fake_shared(renderer_factory)); |
771 | + |
772 | + auto comp = factory.create_compositor_for(display_buffer); |
773 | + |
774 | + comp->composite(); |
775 | +} |
776 | + |
777 | TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass) |
778 | { |
779 | using namespace testing; |
780 | |
781 | === modified file 'tests/unit-tests/graphics/CMakeLists.txt' |
782 | --- tests/unit-tests/graphics/CMakeLists.txt 2013-12-19 19:05:57 +0000 |
783 | +++ tests/unit-tests/graphics/CMakeLists.txt 2014-01-02 07:37:29 +0000 |
784 | @@ -6,6 +6,7 @@ |
785 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp |
786 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp |
787 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp |
788 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp |
789 | ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp |
790 | ) |
791 | |
792 | |
793 | === added file 'tests/unit-tests/graphics/test_pixel_format_utils.cpp' |
794 | --- tests/unit-tests/graphics/test_pixel_format_utils.cpp 1970-01-01 00:00:00 +0000 |
795 | +++ tests/unit-tests/graphics/test_pixel_format_utils.cpp 2014-01-02 07:37:29 +0000 |
796 | @@ -0,0 +1,90 @@ |
797 | +/* |
798 | + * Copyright © 2013 Canonical Ltd. |
799 | + * |
800 | + * This program is free software: you can redistribute it and/or modify it |
801 | + * under the terms of the GNU General Public License version 3, |
802 | + * as published by the Free Software Foundation. |
803 | + * |
804 | + * This program is distributed in the hope that it will be useful, |
805 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
806 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
807 | + * GNU General Public License for more details. |
808 | + * |
809 | + * You should have received a copy of the GNU General Public License |
810 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
811 | + * |
812 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
813 | + */ |
814 | + |
815 | +#include "mir_toolkit/common.h" |
816 | +#include "mir/graphics/pixel_format_utils.h" |
817 | +#include <gmock/gmock.h> |
818 | +#include <gtest/gtest.h> |
819 | + |
820 | +using namespace mir::graphics; |
821 | +TEST(MirPixelformat, contains_alpha) |
822 | +{ |
823 | + EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888)); |
824 | + EXPECT_FALSE(contains_alpha(mir_pixel_format_bgr_888)); |
825 | + EXPECT_FALSE(contains_alpha(mir_pixel_format_xrgb_8888)); |
826 | + EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888)); |
827 | + EXPECT_TRUE(contains_alpha(mir_pixel_format_argb_8888)); |
828 | + EXPECT_TRUE(contains_alpha(mir_pixel_format_abgr_8888)); |
829 | + EXPECT_FALSE(contains_alpha(mir_pixel_format_invalid)); |
830 | +} |
831 | + |
832 | +TEST(MirPixelformat, red_channel_depths) |
833 | +{ |
834 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888)); |
835 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_bgr_888)); |
836 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xrgb_8888)); |
837 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888)); |
838 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_argb_8888)); |
839 | + EXPECT_EQ(8, red_channel_depth(mir_pixel_format_abgr_8888)); |
840 | + EXPECT_EQ(0, red_channel_depth(mir_pixel_format_invalid)); |
841 | +} |
842 | + |
843 | +TEST(MirPixelformat, blue_channel_depths) |
844 | +{ |
845 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888)); |
846 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_bgr_888)); |
847 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xrgb_8888)); |
848 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888)); |
849 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_argb_8888)); |
850 | + EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_abgr_8888)); |
851 | + EXPECT_EQ(0, blue_channel_depth(mir_pixel_format_invalid)); |
852 | +} |
853 | + |
854 | +TEST(MirPixelformat, green_channel_depths) |
855 | +{ |
856 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888)); |
857 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_bgr_888)); |
858 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xrgb_8888)); |
859 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888)); |
860 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_argb_8888)); |
861 | + EXPECT_EQ(8, green_channel_depth(mir_pixel_format_abgr_8888)); |
862 | + EXPECT_EQ(0, green_channel_depth(mir_pixel_format_invalid)); |
863 | +} |
864 | + |
865 | + |
866 | +TEST(MirPixelformat, alpha_channel_depths) |
867 | +{ |
868 | + EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888)); |
869 | + EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_bgr_888)); |
870 | + EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xrgb_8888)); |
871 | + EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888)); |
872 | + EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_argb_8888)); |
873 | + EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_abgr_8888)); |
874 | + EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_invalid)); |
875 | +} |
876 | + |
877 | +TEST(MirPixelformat, valid_format) |
878 | +{ |
879 | + EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888)); |
880 | + EXPECT_TRUE(valid_format(mir_pixel_format_bgr_888)); |
881 | + EXPECT_TRUE(valid_format(mir_pixel_format_xrgb_8888)); |
882 | + EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888)); |
883 | + EXPECT_TRUE(valid_format(mir_pixel_format_argb_8888)); |
884 | + EXPECT_TRUE(valid_format(mir_pixel_format_abgr_8888)); |
885 | + EXPECT_FALSE(valid_format(mir_pixel_format_invalid)); |
886 | +} |