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 | 2 | benchmarks | 2 | benchmarks |
6 | 3 | ) | 3 | ) |
7 | 4 | 4 | ||
9 | 5 | add_subdirectory(android-input) | 5 | if (MIR_ENABLE_TESTS) |
10 | 6 | add_subdirectory(android-input) | ||
11 | 7 | endif () | ||
12 | 6 | add_subdirectory(cpu) | 8 | add_subdirectory(cpu) |
13 | 7 | add_subdirectory(memory) | 9 | add_subdirectory(memory) |
14 | 8 | 10 | ||
15 | 9 | 11 | ||
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 | 51 | ubuntu package) to produce armhf code. This is typically the quickest way to | 51 | ubuntu package) to produce armhf code. This is typically the quickest way to |
21 | 52 | compile and run code, and is well suited for a development workflow. | 52 | compile and run code, and is well suited for a development workflow. |
22 | 53 | 53 | ||
55 | 54 | - Be sure that the cross compiler that you are using matches the target | 54 | Initial setup of a desktop machine for cross-compiling to armhf is simple: |
56 | 55 | environment. (eg, make sure you're using the trusty toolchain if you're | 55 | |
57 | 56 | targeting a trusty phablet image) You can specify the toolchain version | 56 | $ sudo apt-get install g++-arm-linux-gnueabihf/trusty debootstrap |
58 | 57 | thusly: | 57 | $ 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 | 58 | 58 | $ sudo apt-get update | |
60 | 59 | $ apt-get install g++-arm-linux-gnueabihf/trusty | 59 | |
61 | 60 | 60 | Now to test that everything is working you can try downloading a package like | |
62 | 61 | - Get access to armhf packages via apt-get. On an amd64/ia32 system, you can | 61 | this: |
63 | 62 | do this by adding a file like the one below to /etc/apt/sources.list.d/ | 62 | |
64 | 63 | 63 | $ apt-get download gcc:armhf | |
65 | 64 | #example sources.list with armhf dependencies | 64 | |
66 | 65 | deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse | 65 | Once you're able to download armhf packages from the repository, the |
67 | 66 | 66 | cross-compile-chroot.sh script provides an example of how to build Mir for | |
68 | 67 | Then you should run: | 67 | armhf: |
69 | 68 | 68 | ||
70 | 69 | $ apt-get update | 69 | $ ./cross-compile-chroot.sh |
71 | 70 | 70 | $ ls -l build-android-arm/* # binaries to copy to your device | |
72 | 71 | To test, try downloading a package like this: | 71 | |
73 | 72 | 72 | To speed up the process for future branches you may wish to cache the files | |
74 | 73 | $ apt-get download my-package:armhf | 73 | downloaded by setting environment variable MIR_NDK_PATH to point to a directory |
75 | 74 | 74 | that cross-compile-chroot.sh should reuse each time. | |
44 | 75 | - Once you're able to download armhf packages from the repository, the | ||
45 | 76 | cross-compile-chroot.sh script provides an example of how to download | ||
46 | 77 | a partial chroot with the mir dependencies, and compile the source for | ||
47 | 78 | android targets. | ||
48 | 79 | |||
49 | 80 | The script sets up a partial chroot via tools/setup-partial-armhf-chroot.sh | ||
50 | 81 | and then runs build commands similar to this: | ||
51 | 82 | |||
52 | 83 | $ mkdir mir/build; cd mir/build | ||
53 | 84 | $ MIR_NDK_PATH=/path/to/depenendcies/chroot cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake -DBoost_COMPILER=-gcc -DMIR_PLATFORM=android .. | ||
54 | 85 | $ make | ||
76 | 86 | 75 | ||
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 | 1 | /* | ||
82 | 2 | * Copyright © 2013 Canonical Ltd. | ||
83 | 3 | * | ||
84 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
85 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
86 | 6 | * as published by the Free Software Foundation. | ||
87 | 7 | * | ||
88 | 8 | * This program is distributed in the hope that it will be useful, | ||
89 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
90 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
91 | 11 | * GNU Lesser General Public License for more details. | ||
92 | 12 | * | ||
93 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
94 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
95 | 15 | * | ||
96 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
97 | 17 | */ | ||
98 | 18 | |||
99 | 19 | #include "mir_toolkit/common.h" | ||
100 | 20 | |||
101 | 21 | namespace mir | ||
102 | 22 | { | ||
103 | 23 | namespace graphics | ||
104 | 24 | { | ||
105 | 25 | |||
106 | 26 | /*! | ||
107 | 27 | * \name MirPixelFormat utility functions | ||
108 | 28 | * | ||
109 | 29 | * A set of functions to query details of MirPixelFormat | ||
110 | 30 | * TODO improve this through https://bugs.launchpad.net/mir/+bug/1236254 | ||
111 | 31 | * \{ | ||
112 | 32 | */ | ||
113 | 33 | bool contains_alpha(MirPixelFormat format); | ||
114 | 34 | int red_channel_depth(MirPixelFormat format); | ||
115 | 35 | int blue_channel_depth(MirPixelFormat format); | ||
116 | 36 | int green_channel_depth(MirPixelFormat format); | ||
117 | 37 | int alpha_channel_depth(MirPixelFormat format); | ||
118 | 38 | bool valid_format(MirPixelFormat format); | ||
119 | 39 | /*! | ||
120 | 40 | * \} | ||
121 | 41 | */ | ||
122 | 42 | |||
123 | 43 | |||
124 | 44 | } | ||
125 | 45 | } | ||
126 | 0 | 46 | ||
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 | 1 | /* | ||
132 | 2 | * Copyright © 2013 Canonical Ltd. | ||
133 | 3 | * | ||
134 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
135 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
136 | 6 | * as published by the Free Software Foundation. | ||
137 | 7 | * | ||
138 | 8 | * This program is distributed in the hope that it will be useful, | ||
139 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
140 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
141 | 11 | * GNU Lesser General Public License for more details. | ||
142 | 12 | * | ||
143 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
144 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
145 | 15 | * | ||
146 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | ||
147 | 17 | */ | ||
148 | 18 | |||
149 | 19 | #ifndef MIR_LOGGING_INPUT_TIMESTAMP_H_ | ||
150 | 20 | #define MIR_LOGGING_INPUT_TIMESTAMP_H_ | ||
151 | 21 | |||
152 | 22 | #include "mir_toolkit/event.h" | ||
153 | 23 | #include <string> | ||
154 | 24 | |||
155 | 25 | namespace mir | ||
156 | 26 | { | ||
157 | 27 | namespace logging | ||
158 | 28 | { | ||
159 | 29 | |||
160 | 30 | std::string input_timestamp(nsecs_t when); | ||
161 | 31 | |||
162 | 32 | } | ||
163 | 33 | } | ||
164 | 34 | |||
165 | 35 | #endif // MIR_LOGGING_INPUT_TIMESTAMP_H_ | ||
166 | 0 | 36 | ||
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 | 31 | 31 | ||
172 | 32 | struct MockSurfaceRenderer : public compositor::Renderer | 32 | struct MockSurfaceRenderer : public compositor::Renderer |
173 | 33 | { | 33 | { |
174 | 34 | MOCK_CONST_METHOD0(begin, void()); | ||
175 | 34 | MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&)); | 35 | MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&)); |
177 | 35 | MOCK_CONST_METHOD0(clear, void()); | 36 | MOCK_CONST_METHOD0(end, void()); |
178 | 36 | 37 | ||
179 | 37 | ~MockSurfaceRenderer() noexcept {} | 38 | ~MockSurfaceRenderer() noexcept {} |
180 | 38 | }; | 39 | }; |
181 | 39 | 40 | ||
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 | 19 | #include "input_receiver_report.h" | 19 | #include "input_receiver_report.h" |
187 | 20 | 20 | ||
188 | 21 | #include "mir/logging/logger.h" | 21 | #include "mir/logging/logger.h" |
189 | 22 | #include "mir/logging/input_timestamp.h" | ||
190 | 22 | 23 | ||
191 | 23 | #include <boost/throw_exception.hpp> | 24 | #include <boost/throw_exception.hpp> |
192 | 24 | 25 | ||
193 | @@ -53,7 +54,7 @@ | |||
194 | 53 | ss << " scan_code: " << ev.scan_code << std::endl; | 54 | ss << " scan_code: " << ev.scan_code << std::endl; |
195 | 54 | ss << " repeat_count: " << ev.repeat_count << std::endl; | 55 | ss << " repeat_count: " << ev.repeat_count << std::endl; |
196 | 55 | ss << " down_time: " << ev.down_time << std::endl; | 56 | ss << " down_time: " << ev.down_time << std::endl; |
198 | 56 | ss << " event_time: " << ev.event_time << std::endl; | 57 | ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl; |
199 | 57 | ss << " is_system_key: " << ev.is_system_key << std::endl; | 58 | ss << " is_system_key: " << ev.is_system_key << std::endl; |
200 | 58 | ss << "}"; | 59 | ss << "}"; |
201 | 59 | } | 60 | } |
202 | @@ -73,7 +74,7 @@ | |||
203 | 73 | ss << " x_precision: " << ev.x_precision << std::endl; | 74 | ss << " x_precision: " << ev.x_precision << std::endl; |
204 | 74 | ss << " y_precision: " << ev.y_precision << std::endl; | 75 | ss << " y_precision: " << ev.y_precision << std::endl; |
205 | 75 | ss << " down_time: " << ev.down_time << std::endl; | 76 | ss << " down_time: " << ev.down_time << std::endl; |
207 | 76 | ss << " event_time: " << ev.event_time << std::endl; | 77 | ss << " event_time: " << ml::input_timestamp(ev.event_time) << std::endl; |
208 | 77 | ss << " pointer_count: " << ev.pointer_count << std::endl; | 78 | ss << " pointer_count: " << ev.pointer_count << std::endl; |
209 | 78 | for (unsigned int i = 0; i < ev.pointer_count; i++) | 79 | for (unsigned int i = 0; i < ev.pointer_count; i++) |
210 | 79 | { | 80 | { |
211 | 80 | 81 | ||
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 | 10 | display_configuration.cpp | 10 | display_configuration.cpp |
217 | 11 | null_display_report.cpp | 11 | null_display_report.cpp |
218 | 12 | buffer_basic.cpp | 12 | buffer_basic.cpp |
219 | 13 | pixel_format_utils.cpp | ||
220 | 13 | ) | 14 | ) |
221 | 14 | 15 | ||
222 | 15 | add_library( | 16 | add_library( |
223 | 16 | 17 | ||
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 | 1 | /* | ||
229 | 2 | * Copyright © 2013 Canonical Ltd. | ||
230 | 3 | * | ||
231 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
232 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
233 | 6 | * as published by the Free Software Foundation. | ||
234 | 7 | * | ||
235 | 8 | * This program is distributed in the hope that it will be useful, | ||
236 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
237 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
238 | 11 | * GNU Lesser General Public License for more details. | ||
239 | 12 | * | ||
240 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
241 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
242 | 15 | * | ||
243 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
244 | 17 | */ | ||
245 | 18 | |||
246 | 19 | #include "mir/graphics/pixel_format_utils.h" | ||
247 | 20 | |||
248 | 21 | namespace mir | ||
249 | 22 | { | ||
250 | 23 | namespace graphics | ||
251 | 24 | { | ||
252 | 25 | |||
253 | 26 | bool contains_alpha(MirPixelFormat format) | ||
254 | 27 | { | ||
255 | 28 | return (format == mir_pixel_format_abgr_8888 || | ||
256 | 29 | format == mir_pixel_format_argb_8888); | ||
257 | 30 | } | ||
258 | 31 | |||
259 | 32 | int red_channel_depth(MirPixelFormat format) | ||
260 | 33 | { | ||
261 | 34 | if (mir_pixel_format_invalid < format && | ||
262 | 35 | format < mir_pixel_formats) | ||
263 | 36 | return 8; | ||
264 | 37 | return 0; | ||
265 | 38 | } | ||
266 | 39 | |||
267 | 40 | int blue_channel_depth(MirPixelFormat format) | ||
268 | 41 | { | ||
269 | 42 | if (mir_pixel_format_invalid < format && | ||
270 | 43 | format < mir_pixel_formats) | ||
271 | 44 | return 8; | ||
272 | 45 | return 0; | ||
273 | 46 | } | ||
274 | 47 | |||
275 | 48 | int green_channel_depth(MirPixelFormat format) | ||
276 | 49 | { | ||
277 | 50 | if (mir_pixel_format_invalid < format && | ||
278 | 51 | format < mir_pixel_formats) | ||
279 | 52 | return 8; | ||
280 | 53 | return 0; | ||
281 | 54 | } | ||
282 | 55 | |||
283 | 56 | int alpha_channel_depth(MirPixelFormat format) | ||
284 | 57 | { | ||
285 | 58 | if (format == mir_pixel_format_abgr_8888 || | ||
286 | 59 | format == mir_pixel_format_argb_8888) | ||
287 | 60 | return 8; | ||
288 | 61 | return 0; | ||
289 | 62 | } | ||
290 | 63 | |||
291 | 64 | bool valid_format(MirPixelFormat format) | ||
292 | 65 | { | ||
293 | 66 | return (format > mir_pixel_format_invalid && | ||
294 | 67 | format < mir_pixel_formats); | ||
295 | 68 | } | ||
296 | 69 | |||
297 | 70 | } | ||
298 | 71 | } | ||
299 | 0 | 72 | ||
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 | 135 | mc::OcclusionMatch occlusion_match; | 135 | mc::OcclusionMatch occlusion_match; |
305 | 136 | scene->reverse_for_each_if(occlusion_search, occlusion_match); | 136 | scene->reverse_for_each_if(occlusion_search, occlusion_match); |
306 | 137 | 137 | ||
308 | 138 | renderer->clear(); | 138 | renderer->begin(); |
309 | 139 | mc::RenderingOperator applicator(*renderer, save_resource, local_frameno); | 139 | mc::RenderingOperator applicator(*renderer, save_resource, local_frameno); |
310 | 140 | FilterForVisibleSceneInRegion selector(view_area, occlusion_match); | 140 | FilterForVisibleSceneInRegion selector(view_area, occlusion_match); |
311 | 141 | scene->for_each_if(selector, applicator); | 141 | scene->for_each_if(selector, applicator); |
312 | 142 | renderer->end(); | ||
313 | 142 | 143 | ||
314 | 143 | display_buffer.post_update(); | 144 | display_buffer.post_update(); |
315 | 144 | } | 145 | } |
316 | 145 | 146 | ||
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 | 117 | 117 | ||
322 | 118 | } | 118 | } |
323 | 119 | 119 | ||
325 | 120 | mc::GLRenderer::Resources::Resources() : | 120 | mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) : |
326 | 121 | vertex_shader(0), | 121 | vertex_shader(0), |
327 | 122 | fragment_shader(0), | 122 | fragment_shader(0), |
328 | 123 | program(0), | 123 | program(0), |
329 | @@ -128,24 +128,6 @@ | |||
330 | 128 | vertex_attribs_vbo(0), | 128 | vertex_attribs_vbo(0), |
331 | 129 | texture(0) | 129 | texture(0) |
332 | 130 | { | 130 | { |
333 | 131 | } | ||
334 | 132 | |||
335 | 133 | mc::GLRenderer::Resources::~Resources() | ||
336 | 134 | { | ||
337 | 135 | if (vertex_shader) | ||
338 | 136 | glDeleteShader(vertex_shader); | ||
339 | 137 | if (fragment_shader) | ||
340 | 138 | glDeleteShader(fragment_shader); | ||
341 | 139 | if (program) | ||
342 | 140 | glDeleteProgram(program); | ||
343 | 141 | if (vertex_attribs_vbo) | ||
344 | 142 | glDeleteBuffers(1, &vertex_attribs_vbo); | ||
345 | 143 | if (texture) | ||
346 | 144 | glDeleteTextures(1, &texture); | ||
347 | 145 | } | ||
348 | 146 | |||
349 | 147 | void mc::GLRenderer::Resources::setup(geometry::Rectangle const& display_area) | ||
350 | 148 | { | ||
351 | 149 | GLint param = 0; | 131 | GLint param = 0; |
352 | 150 | 132 | ||
353 | 151 | /* Create shaders and program */ | 133 | /* Create shaders and program */ |
354 | @@ -235,14 +217,23 @@ | |||
355 | 235 | glUseProgram(0); | 217 | glUseProgram(0); |
356 | 236 | } | 218 | } |
357 | 237 | 219 | ||
359 | 238 | mc::GLRenderer::GLRenderer(geom::Rectangle const& display_area) | 220 | mc::GLRenderer::~GLRenderer() noexcept |
360 | 239 | { | 221 | { |
362 | 240 | resources.setup(display_area); | 222 | if (vertex_shader) |
363 | 223 | glDeleteShader(vertex_shader); | ||
364 | 224 | if (fragment_shader) | ||
365 | 225 | glDeleteShader(fragment_shader); | ||
366 | 226 | if (program) | ||
367 | 227 | glDeleteProgram(program); | ||
368 | 228 | if (vertex_attribs_vbo) | ||
369 | 229 | glDeleteBuffers(1, &vertex_attribs_vbo); | ||
370 | 230 | if (texture) | ||
371 | 231 | glDeleteTextures(1, &texture); | ||
372 | 241 | } | 232 | } |
373 | 242 | 233 | ||
374 | 243 | void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const | 234 | void mc::GLRenderer::render(CompositingCriteria const& criteria, mg::Buffer& buffer) const |
375 | 244 | { | 235 | { |
377 | 245 | glUseProgram(resources.program); | 236 | glUseProgram(program); |
378 | 246 | 237 | ||
379 | 247 | if (criteria.shaped() || criteria.alpha() < 1.0f) | 238 | if (criteria.shaped() || criteria.alpha() < 1.0f) |
380 | 248 | { | 239 | { |
381 | @@ -255,32 +246,36 @@ | |||
382 | 255 | } | 246 | } |
383 | 256 | glActiveTexture(GL_TEXTURE0); | 247 | glActiveTexture(GL_TEXTURE0); |
384 | 257 | 248 | ||
386 | 258 | glUniformMatrix4fv(resources.transform_uniform_loc, 1, GL_FALSE, | 249 | glUniformMatrix4fv(transform_uniform_loc, 1, GL_FALSE, |
387 | 259 | glm::value_ptr(criteria.transformation())); | 250 | glm::value_ptr(criteria.transformation())); |
389 | 260 | glUniform1f(resources.alpha_uniform_loc, criteria.alpha()); | 251 | glUniform1f(alpha_uniform_loc, criteria.alpha()); |
390 | 261 | 252 | ||
391 | 262 | /* Set up vertex attribute data */ | 253 | /* Set up vertex attribute data */ |
394 | 263 | glBindBuffer(GL_ARRAY_BUFFER, resources.vertex_attribs_vbo); | 254 | glBindBuffer(GL_ARRAY_BUFFER, vertex_attribs_vbo); |
395 | 264 | glVertexAttribPointer(resources.position_attr_loc, 3, GL_FLOAT, | 255 | glVertexAttribPointer(position_attr_loc, 3, GL_FLOAT, |
396 | 265 | GL_FALSE, sizeof(VertexAttributes), 0); | 256 | GL_FALSE, sizeof(VertexAttributes), 0); |
398 | 266 | glVertexAttribPointer(resources.texcoord_attr_loc, 2, GL_FLOAT, | 257 | glVertexAttribPointer(texcoord_attr_loc, 2, GL_FLOAT, |
399 | 267 | GL_FALSE, sizeof(VertexAttributes), | 258 | GL_FALSE, sizeof(VertexAttributes), |
400 | 268 | reinterpret_cast<void*>(sizeof(glm::vec3))); | 259 | reinterpret_cast<void*>(sizeof(glm::vec3))); |
401 | 269 | 260 | ||
402 | 270 | /* Use the renderable's texture */ | 261 | /* Use the renderable's texture */ |
404 | 271 | glBindTexture(GL_TEXTURE_2D, resources.texture); | 262 | glBindTexture(GL_TEXTURE_2D, texture); |
405 | 272 | 263 | ||
406 | 273 | buffer.bind_to_texture(); | 264 | buffer.bind_to_texture(); |
407 | 274 | 265 | ||
408 | 275 | /* Draw */ | 266 | /* Draw */ |
411 | 276 | glEnableVertexAttribArray(resources.position_attr_loc); | 267 | glEnableVertexAttribArray(position_attr_loc); |
412 | 277 | glEnableVertexAttribArray(resources.texcoord_attr_loc); | 268 | glEnableVertexAttribArray(texcoord_attr_loc); |
413 | 278 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 269 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
416 | 279 | glDisableVertexAttribArray(resources.texcoord_attr_loc); | 270 | glDisableVertexAttribArray(texcoord_attr_loc); |
417 | 280 | glDisableVertexAttribArray(resources.position_attr_loc); | 271 | glDisableVertexAttribArray(position_attr_loc); |
418 | 281 | } | 272 | } |
419 | 282 | 273 | ||
421 | 283 | void mc::GLRenderer::clear() const | 274 | void mc::GLRenderer::begin() const |
422 | 284 | { | 275 | { |
423 | 285 | glClear(GL_COLOR_BUFFER_BIT); | 276 | glClear(GL_COLOR_BUFFER_BIT); |
424 | 286 | } | 277 | } |
425 | 278 | |||
426 | 279 | void mc::GLRenderer::end() const | ||
427 | 280 | { | ||
428 | 281 | } | ||
429 | 287 | 282 | ||
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 | 32 | { | 32 | { |
435 | 33 | public: | 33 | public: |
436 | 34 | GLRenderer(geometry::Rectangle const& display_area); | 34 | GLRenderer(geometry::Rectangle const& display_area); |
437 | 35 | virtual ~GLRenderer() noexcept; | ||
438 | 35 | 36 | ||
439 | 37 | void begin() const override; | ||
440 | 36 | void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override; | 38 | void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override; |
444 | 37 | void clear() const override; | 39 | void end() const override; |
442 | 38 | |||
443 | 39 | ~GLRenderer() noexcept {} | ||
445 | 40 | 40 | ||
446 | 41 | private: | 41 | private: |
466 | 42 | class Resources | 42 | GLuint vertex_shader; |
467 | 43 | { | 43 | GLuint fragment_shader; |
468 | 44 | public: | 44 | GLuint program; |
469 | 45 | Resources(); | 45 | GLuint position_attr_loc; |
470 | 46 | ~Resources(); | 46 | GLuint texcoord_attr_loc; |
471 | 47 | void setup(geometry::Rectangle const& display_area); | 47 | GLuint transform_uniform_loc; |
472 | 48 | 48 | GLuint alpha_uniform_loc; | |
473 | 49 | GLuint vertex_shader; | 49 | GLuint vertex_attribs_vbo; |
474 | 50 | GLuint fragment_shader; | 50 | GLuint texture; |
456 | 51 | GLuint program; | ||
457 | 52 | GLuint position_attr_loc; | ||
458 | 53 | GLuint texcoord_attr_loc; | ||
459 | 54 | GLuint transform_uniform_loc; | ||
460 | 55 | GLuint alpha_uniform_loc; | ||
461 | 56 | GLuint vertex_attribs_vbo; | ||
462 | 57 | GLuint texture; | ||
463 | 58 | }; | ||
464 | 59 | |||
465 | 60 | Resources resources; | ||
475 | 61 | }; | 51 | }; |
476 | 62 | 52 | ||
477 | 63 | } | 53 | } |
478 | 64 | 54 | ||
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 | 34 | public: | 34 | public: |
484 | 35 | virtual ~Renderer() = default; | 35 | virtual ~Renderer() = default; |
485 | 36 | 36 | ||
487 | 37 | virtual void clear() const = 0; | 37 | virtual void begin() const = 0; |
488 | 38 | virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0; | 38 | virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0; |
489 | 39 | virtual void end() const = 0; | ||
490 | 39 | 40 | ||
491 | 40 | protected: | 41 | protected: |
492 | 41 | Renderer() = default; | 42 | Renderer() = default; |
493 | 42 | 43 | ||
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 | 18 | 18 | ||
499 | 19 | #include "mir/logging/input_report.h" | 19 | #include "mir/logging/input_report.h" |
500 | 20 | #include "mir/logging/logger.h" | 20 | #include "mir/logging/logger.h" |
501 | 21 | #include "mir/logging/input_timestamp.h" | ||
502 | 21 | 22 | ||
503 | 22 | #include "std/MirLog.h" | 23 | #include "std/MirLog.h" |
504 | 23 | #include <std/Log.h> | 24 | #include <std/Log.h> |
505 | @@ -108,7 +109,7 @@ | |||
506 | 108 | std::stringstream ss; | 109 | std::stringstream ss; |
507 | 109 | 110 | ||
508 | 110 | ss << "Received event" | 111 | ss << "Received event" |
510 | 111 | << " time=" << when | 112 | << " time=" << ml::input_timestamp(when) |
511 | 112 | << " type=" << type | 113 | << " type=" << type |
512 | 113 | << " code=" << code | 114 | << " code=" << code |
513 | 114 | << " value=" << value; | 115 | << " value=" << value; |
514 | @@ -122,7 +123,7 @@ | |||
515 | 122 | 123 | ||
516 | 123 | ss << "Published key event" | 124 | ss << "Published key event" |
517 | 124 | << " seq_id=" << seq_id | 125 | << " seq_id=" << seq_id |
519 | 125 | << " time=" << event_time | 126 | << " time=" << ml::input_timestamp(event_time) |
520 | 126 | << " dest_fd=" << dest_fd; | 127 | << " dest_fd=" << dest_fd; |
521 | 127 | 128 | ||
522 | 128 | logger->log(Logger::informational, ss.str(), component()); | 129 | logger->log(Logger::informational, ss.str(), component()); |
523 | @@ -134,7 +135,7 @@ | |||
524 | 134 | 135 | ||
525 | 135 | ss << "Published motion event" | 136 | ss << "Published motion event" |
526 | 136 | << " seq_id=" << seq_id | 137 | << " seq_id=" << seq_id |
528 | 137 | << " time=" << event_time | 138 | << " time=" << ml::input_timestamp(event_time) |
529 | 138 | << " dest_fd=" << dest_fd; | 139 | << " dest_fd=" << dest_fd; |
530 | 139 | 140 | ||
531 | 140 | logger->log(Logger::informational, ss.str(), component()); | 141 | logger->log(Logger::informational, ss.str(), component()); |
532 | 141 | 142 | ||
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 | 16 | 16 | ||
538 | 17 | add_library(mirsharedlogging STATIC | 17 | add_library(mirsharedlogging STATIC |
539 | 18 | dumb_console_logger.cpp | 18 | dumb_console_logger.cpp |
540 | 19 | input_timestamp.cpp | ||
541 | 19 | ) | 20 | ) |
542 | 20 | 21 | ||
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 | 1 | /* | ||
548 | 2 | * Copyright © 2013 Canonical Ltd. | ||
549 | 3 | * | ||
550 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
551 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
552 | 6 | * as published by the Free Software Foundation. | ||
553 | 7 | * | ||
554 | 8 | * This program is distributed in the hope that it will be useful, | ||
555 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
556 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
557 | 11 | * GNU Lesser General Public License for more details. | ||
558 | 12 | * | ||
559 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
560 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
561 | 15 | * | ||
562 | 16 | * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> | ||
563 | 17 | */ | ||
564 | 18 | |||
565 | 19 | #include "mir/logging/input_timestamp.h" | ||
566 | 20 | #include <ctime> | ||
567 | 21 | #include <cstdio> | ||
568 | 22 | #include <string> | ||
569 | 23 | |||
570 | 24 | std::string mir::logging::input_timestamp(nsecs_t when) | ||
571 | 25 | { | ||
572 | 26 | // Input events use CLOCK_REALTIME, and so we must... | ||
573 | 27 | struct timespec ts; | ||
574 | 28 | clock_gettime(CLOCK_REALTIME, &ts); | ||
575 | 29 | |||
576 | 30 | nsecs_t now = ts.tv_sec * 1000000000LL + ts.tv_nsec; | ||
577 | 31 | nsecs_t age = now - when; | ||
578 | 32 | |||
579 | 33 | char str[64]; | ||
580 | 34 | snprintf(str, sizeof str, "%lld (%ld.%06ld ms ago)", | ||
581 | 35 | static_cast<long long>(when), | ||
582 | 36 | static_cast<long>(age / 1000000LL), | ||
583 | 37 | static_cast<long>(age % 1000000LL)); | ||
584 | 38 | |||
585 | 39 | return std::string(str); | ||
586 | 40 | } | ||
587 | 41 | |||
588 | 0 | 42 | ||
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 | 48 | class NullRenderer : public mc::Renderer | 48 | class NullRenderer : public mc::Renderer |
594 | 49 | { | 49 | { |
595 | 50 | public: | 50 | public: |
596 | 51 | void begin() const override | ||
597 | 52 | { | ||
598 | 53 | } | ||
599 | 54 | |||
600 | 51 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override | 55 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
601 | 52 | { | 56 | { |
602 | 53 | /* | 57 | /* |
603 | @@ -58,7 +62,7 @@ | |||
604 | 58 | std::this_thread::yield(); | 62 | std::this_thread::yield(); |
605 | 59 | } | 63 | } |
606 | 60 | 64 | ||
608 | 61 | void clear() const override | 65 | void end() const override |
609 | 62 | { | 66 | { |
610 | 63 | } | 67 | } |
611 | 64 | }; | 68 | }; |
612 | 65 | 69 | ||
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 | 87 | { | 87 | { |
618 | 88 | struct StubRenderer : public mc::Renderer | 88 | struct StubRenderer : public mc::Renderer |
619 | 89 | { | 89 | { |
621 | 90 | void clear() const override | 90 | void begin() const override |
622 | 91 | { | 91 | { |
623 | 92 | } | 92 | } |
624 | 93 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override | 93 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
625 | 94 | { | 94 | { |
626 | 95 | } | 95 | } |
627 | 96 | void end() const override | ||
628 | 97 | { | ||
629 | 98 | } | ||
630 | 96 | }; | 99 | }; |
631 | 97 | 100 | ||
632 | 98 | struct StubRendererFactory : public mc::RendererFactory | 101 | struct StubRendererFactory : public mc::RendererFactory |
633 | 99 | 102 | ||
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 | 96 | { | 96 | { |
639 | 97 | } | 97 | } |
640 | 98 | 98 | ||
642 | 99 | void clear() const override | 99 | void begin() const override |
643 | 100 | { | 100 | { |
644 | 101 | } | 101 | } |
645 | 102 | 102 | ||
646 | @@ -105,6 +105,10 @@ | |||
647 | 105 | while (write(render_operations_fd, "a", 1) != 1) continue; | 105 | while (write(render_operations_fd, "a", 1) != 1) continue; |
648 | 106 | } | 106 | } |
649 | 107 | 107 | ||
650 | 108 | void end() const override | ||
651 | 109 | { | ||
652 | 110 | } | ||
653 | 111 | |||
654 | 108 | private: | 112 | private: |
655 | 109 | int render_operations_fd; | 113 | int render_operations_fd; |
656 | 110 | }; | 114 | }; |
657 | 111 | 115 | ||
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 | 201 | class StubRenderer : public mc::Renderer | 201 | class StubRenderer : public mc::Renderer |
663 | 202 | { | 202 | { |
664 | 203 | public: | 203 | public: |
665 | 204 | void begin() const override | ||
666 | 205 | { | ||
667 | 206 | } | ||
668 | 207 | |||
669 | 204 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override | 208 | void render(mc::CompositingCriteria const&, mg::Buffer&) const override |
670 | 205 | { | 209 | { |
671 | 206 | } | 210 | } |
672 | 207 | 211 | ||
674 | 208 | void clear() const override | 212 | void end() const override |
675 | 209 | { | 213 | { |
676 | 210 | } | 214 | } |
677 | 211 | }; | 215 | }; |
678 | 212 | 216 | ||
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 | 106 | { | 106 | { |
684 | 107 | } | 107 | } |
685 | 108 | 108 | ||
687 | 109 | void clear() const override | 109 | void begin() const override |
688 | 110 | { | 110 | { |
690 | 111 | renderer->clear(); | 111 | renderer->begin(); |
691 | 112 | } | 112 | } |
692 | 113 | 113 | ||
693 | 114 | void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override | 114 | void render(mc::CompositingCriteria const& criteria, mg::Buffer& buffer) const override |
694 | @@ -116,6 +116,11 @@ | |||
695 | 116 | renderer->render(criteria, buffer); | 116 | renderer->render(criteria, buffer); |
696 | 117 | } | 117 | } |
697 | 118 | 118 | ||
698 | 119 | void end() const override | ||
699 | 120 | { | ||
700 | 121 | renderer->end(); | ||
701 | 122 | } | ||
702 | 123 | |||
703 | 119 | mc::Renderer* const renderer; | 124 | mc::Renderer* const renderer; |
704 | 120 | }; | 125 | }; |
705 | 121 | 126 | ||
706 | @@ -241,10 +246,14 @@ | |||
707 | 241 | renderable_vec.push_back(&small); | 246 | renderable_vec.push_back(&small); |
708 | 242 | renderable_vec.push_back(&fullscreen); | 247 | renderable_vec.push_back(&fullscreen); |
709 | 243 | 248 | ||
710 | 249 | EXPECT_CALL(renderer_factory.mock_renderer, begin()) | ||
711 | 250 | .Times(0); | ||
712 | 244 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_)) | 251 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_)) |
713 | 245 | .Times(0); | 252 | .Times(0); |
714 | 246 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_)) | 253 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(fullscreen),_)) |
715 | 247 | .Times(0); | 254 | .Times(0); |
716 | 255 | EXPECT_CALL(renderer_factory.mock_renderer, end()) | ||
717 | 256 | .Times(0); | ||
718 | 248 | 257 | ||
719 | 249 | FakeScene scene(renderable_vec); | 258 | FakeScene scene(renderable_vec); |
720 | 250 | 259 | ||
721 | @@ -263,6 +272,58 @@ | |||
722 | 263 | comp->composite(); | 272 | comp->composite(); |
723 | 264 | } | 273 | } |
724 | 265 | 274 | ||
725 | 275 | TEST(DefaultDisplayBufferCompositor, calls_renderer_in_sequence) | ||
726 | 276 | { | ||
727 | 277 | using namespace testing; | ||
728 | 278 | |||
729 | 279 | StubRendererFactory renderer_factory; | ||
730 | 280 | |||
731 | 281 | geom::Rectangle screen{{0, 0}, {1366, 768}}; | ||
732 | 282 | |||
733 | 283 | mtd::MockDisplayBuffer display_buffer; | ||
734 | 284 | |||
735 | 285 | EXPECT_CALL(display_buffer, view_area()) | ||
736 | 286 | .WillRepeatedly(Return(screen)); | ||
737 | 287 | EXPECT_CALL(display_buffer, can_bypass()) | ||
738 | 288 | .WillRepeatedly(Return(false)); | ||
739 | 289 | |||
740 | 290 | mtd::StubCompositingCriteria big(5, 10, 100, 200); | ||
741 | 291 | mtd::StubCompositingCriteria small(10, 20, 30, 40); | ||
742 | 292 | |||
743 | 293 | std::vector<mc::CompositingCriteria*> renderable_vec; | ||
744 | 294 | renderable_vec.push_back(&big); | ||
745 | 295 | renderable_vec.push_back(&small); | ||
746 | 296 | |||
747 | 297 | Sequence render_seq; | ||
748 | 298 | |||
749 | 299 | EXPECT_CALL(display_buffer, make_current()) | ||
750 | 300 | .InSequence(render_seq); | ||
751 | 301 | EXPECT_CALL(renderer_factory.mock_renderer, begin()) | ||
752 | 302 | .InSequence(render_seq); | ||
753 | 303 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(big),_)) | ||
754 | 304 | .InSequence(render_seq); | ||
755 | 305 | EXPECT_CALL(renderer_factory.mock_renderer, render(Ref(small),_)) | ||
756 | 306 | .InSequence(render_seq); | ||
757 | 307 | EXPECT_CALL(renderer_factory.mock_renderer, end()) | ||
758 | 308 | .InSequence(render_seq); | ||
759 | 309 | EXPECT_CALL(display_buffer, post_update()) | ||
760 | 310 | .InSequence(render_seq); | ||
761 | 311 | |||
762 | 312 | FakeScene scene(renderable_vec); | ||
763 | 313 | |||
764 | 314 | auto compositor_buffer = std::make_shared<mtd::MockBuffer>(); | ||
765 | 315 | EXPECT_CALL(*compositor_buffer, can_bypass()) | ||
766 | 316 | .Times(0); | ||
767 | 317 | |||
768 | 318 | mc::DefaultDisplayBufferCompositorFactory factory( | ||
769 | 319 | mt::fake_shared(scene), | ||
770 | 320 | mt::fake_shared(renderer_factory)); | ||
771 | 321 | |||
772 | 322 | auto comp = factory.create_compositor_for(display_buffer); | ||
773 | 323 | |||
774 | 324 | comp->composite(); | ||
775 | 325 | } | ||
776 | 326 | |||
777 | 266 | TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass) | 327 | TEST(DefaultDisplayBufferCompositor, obscured_fullscreen_does_not_bypass) |
778 | 267 | { | 328 | { |
779 | 268 | using namespace testing; | 329 | using namespace testing; |
780 | 269 | 330 | ||
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 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_configuration_policy.cpp |
786 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_id.cpp |
787 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp |
788 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp | ||
789 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp |
790 | 10 | ) | 11 | ) |
791 | 11 | 12 | ||
792 | 12 | 13 | ||
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 | 1 | /* | ||
798 | 2 | * Copyright © 2013 Canonical Ltd. | ||
799 | 3 | * | ||
800 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
801 | 5 | * under the terms of the GNU General Public License version 3, | ||
802 | 6 | * as published by the Free Software Foundation. | ||
803 | 7 | * | ||
804 | 8 | * This program is distributed in the hope that it will be useful, | ||
805 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
806 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
807 | 11 | * GNU General Public License for more details. | ||
808 | 12 | * | ||
809 | 13 | * You should have received a copy of the GNU General Public License | ||
810 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
811 | 15 | * | ||
812 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
813 | 17 | */ | ||
814 | 18 | |||
815 | 19 | #include "mir_toolkit/common.h" | ||
816 | 20 | #include "mir/graphics/pixel_format_utils.h" | ||
817 | 21 | #include <gmock/gmock.h> | ||
818 | 22 | #include <gtest/gtest.h> | ||
819 | 23 | |||
820 | 24 | using namespace mir::graphics; | ||
821 | 25 | TEST(MirPixelformat, contains_alpha) | ||
822 | 26 | { | ||
823 | 27 | EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888)); | ||
824 | 28 | EXPECT_FALSE(contains_alpha(mir_pixel_format_bgr_888)); | ||
825 | 29 | EXPECT_FALSE(contains_alpha(mir_pixel_format_xrgb_8888)); | ||
826 | 30 | EXPECT_FALSE(contains_alpha(mir_pixel_format_xbgr_8888)); | ||
827 | 31 | EXPECT_TRUE(contains_alpha(mir_pixel_format_argb_8888)); | ||
828 | 32 | EXPECT_TRUE(contains_alpha(mir_pixel_format_abgr_8888)); | ||
829 | 33 | EXPECT_FALSE(contains_alpha(mir_pixel_format_invalid)); | ||
830 | 34 | } | ||
831 | 35 | |||
832 | 36 | TEST(MirPixelformat, red_channel_depths) | ||
833 | 37 | { | ||
834 | 38 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888)); | ||
835 | 39 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_bgr_888)); | ||
836 | 40 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xrgb_8888)); | ||
837 | 41 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_xbgr_8888)); | ||
838 | 42 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_argb_8888)); | ||
839 | 43 | EXPECT_EQ(8, red_channel_depth(mir_pixel_format_abgr_8888)); | ||
840 | 44 | EXPECT_EQ(0, red_channel_depth(mir_pixel_format_invalid)); | ||
841 | 45 | } | ||
842 | 46 | |||
843 | 47 | TEST(MirPixelformat, blue_channel_depths) | ||
844 | 48 | { | ||
845 | 49 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888)); | ||
846 | 50 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_bgr_888)); | ||
847 | 51 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xrgb_8888)); | ||
848 | 52 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_xbgr_8888)); | ||
849 | 53 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_argb_8888)); | ||
850 | 54 | EXPECT_EQ(8, blue_channel_depth(mir_pixel_format_abgr_8888)); | ||
851 | 55 | EXPECT_EQ(0, blue_channel_depth(mir_pixel_format_invalid)); | ||
852 | 56 | } | ||
853 | 57 | |||
854 | 58 | TEST(MirPixelformat, green_channel_depths) | ||
855 | 59 | { | ||
856 | 60 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888)); | ||
857 | 61 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_bgr_888)); | ||
858 | 62 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xrgb_8888)); | ||
859 | 63 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_xbgr_8888)); | ||
860 | 64 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_argb_8888)); | ||
861 | 65 | EXPECT_EQ(8, green_channel_depth(mir_pixel_format_abgr_8888)); | ||
862 | 66 | EXPECT_EQ(0, green_channel_depth(mir_pixel_format_invalid)); | ||
863 | 67 | } | ||
864 | 68 | |||
865 | 69 | |||
866 | 70 | TEST(MirPixelformat, alpha_channel_depths) | ||
867 | 71 | { | ||
868 | 72 | EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888)); | ||
869 | 73 | EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_bgr_888)); | ||
870 | 74 | EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xrgb_8888)); | ||
871 | 75 | EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_xbgr_8888)); | ||
872 | 76 | EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_argb_8888)); | ||
873 | 77 | EXPECT_EQ(8, alpha_channel_depth(mir_pixel_format_abgr_8888)); | ||
874 | 78 | EXPECT_EQ(0, alpha_channel_depth(mir_pixel_format_invalid)); | ||
875 | 79 | } | ||
876 | 80 | |||
877 | 81 | TEST(MirPixelformat, valid_format) | ||
878 | 82 | { | ||
879 | 83 | EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888)); | ||
880 | 84 | EXPECT_TRUE(valid_format(mir_pixel_format_bgr_888)); | ||
881 | 85 | EXPECT_TRUE(valid_format(mir_pixel_format_xrgb_8888)); | ||
882 | 86 | EXPECT_TRUE(valid_format(mir_pixel_format_xbgr_8888)); | ||
883 | 87 | EXPECT_TRUE(valid_format(mir_pixel_format_argb_8888)); | ||
884 | 88 | EXPECT_TRUE(valid_format(mir_pixel_format_abgr_8888)); | ||
885 | 89 | EXPECT_FALSE(valid_format(mir_pixel_format_invalid)); | ||
886 | 90 | } |