Merge lp:~kdub/mir/android-internal-client into lp:~mir-team/mir/trunk
- android-internal-client
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Kevin DuBois | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 681 | ||||||||
Proposed branch: | lp:~kdub/mir/android-internal-client | ||||||||
Merge into: | lp:~mir-team/mir/trunk | ||||||||
Diff against target: |
2860 lines (+1466/-454) 55 files modified
examples/CMakeLists.txt (+1/-4) examples/demo-inprocess-egl/demo_inprocess_egl.cpp (+1/-0) examples/demo-inprocess-egl/inprocess_egl_client.cpp (+17/-6) examples/demo-inprocess-egl/inprocess_egl_client.h (+5/-2) include/server/mir/graphics/egl/mesa_native_display.h (+0/-42) include/server/mir/graphics/internal_client.h (+43/-0) include/server/mir/graphics/platform.h (+6/-5) include/shared/mir_toolkit/mesa/native_display.h (+9/-0) include/test/mir_test_doubles/mock_interpreter_resource_cache.h (+37/-0) include/test/mir_test_doubles/mock_swapper.h (+1/-0) include/test/mir_test_doubles/stub_platform.h (+60/-0) src/server/graphics/CMakeLists.txt (+0/-4) src/server/graphics/android/CMakeLists.txt (+3/-0) src/server/graphics/android/android_platform.cpp (+5/-3) src/server/graphics/android/android_platform.h (+2/-3) src/server/graphics/android/default_framebuffer_factory.cpp (+3/-1) src/server/graphics/android/internal_client.cpp (+42/-0) src/server/graphics/android/internal_client.h (+52/-0) src/server/graphics/android/internal_client_window.cpp (+79/-0) src/server/graphics/android/internal_client_window.h (+58/-0) src/server/graphics/android/interpreter_cache.cpp (+41/-0) src/server/graphics/android/interpreter_cache.h (+45/-0) src/server/graphics/android/interpreter_resource_cache.h (+50/-0) src/server/graphics/android/server_render_window.cpp (+6/-12) src/server/graphics/android/server_render_window.h (+4/-3) src/server/graphics/egl/CMakeLists.txt (+0/-10) src/server/graphics/gbm/CMakeLists.txt (+2/-0) src/server/graphics/gbm/gbm_platform.cpp (+38/-12) src/server/graphics/gbm/gbm_platform.h (+7/-6) src/server/graphics/gbm/internal_client.cpp (+40/-0) src/server/graphics/gbm/internal_client.h (+55/-0) src/server/graphics/gbm/internal_native_display.cpp (+65/-112) src/server/graphics/gbm/internal_native_display.h (+56/-0) tests/integration-tests/graphics/android/CMakeLists.txt (+1/-0) tests/integration-tests/graphics/android/test_internal_client.cpp (+132/-0) tests/integration-tests/graphics/gbm/test_buffer_integration.cpp (+2/-2) tests/integration-tests/test_display_info.cpp (+5/-3) tests/integration-tests/test_drm_auth_magic.cpp (+2/-2) tests/integration-tests/test_surfaceloop.cpp (+6/-5) tests/mir_test_framework/testing_server_options.cpp (+2/-2) tests/unit-tests/client/gbm/test_gbm_client_platform.cpp (+4/-0) tests/unit-tests/frontend/test_session_mediator.cpp (+2/-26) tests/unit-tests/frontend/test_session_mediator_android.cpp (+3/-27) tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+2/-2) tests/unit-tests/graphics/CMakeLists.txt (+0/-1) tests/unit-tests/graphics/android/CMakeLists.txt (+4/-1) tests/unit-tests/graphics/android/test_internal_client.cpp (+87/-0) tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp (+149/-0) tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp (+86/-0) tests/unit-tests/graphics/android/test_server_interpreter.cpp (+24/-74) tests/unit-tests/graphics/egl/CMakeLists.txt (+0/-6) tests/unit-tests/graphics/gbm/CMakeLists.txt (+2/-0) tests/unit-tests/graphics/gbm/test_gbm_platform.cpp (+20/-0) tests/unit-tests/graphics/gbm/test_internal_client.cpp (+43/-0) tests/unit-tests/graphics/gbm/test_internal_native_display.cpp (+57/-78) |
||||||||
To merge this branch: | bzr merge lp:~kdub/mir/android-internal-client | ||||||||
Related bugs: |
|
||||||||
Related blueprints: |
Mir on the Phone (iteration 0)
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Alan Griffiths | Approve | ||
Robert Ancell | Approve | ||
Review via email: mp+163211@code.launchpad.net |
Commit message
enable internal clients (in-process-egl) for android. refactor platform abstraction for internal clients as well.
tested on my laptop (intel drivers), galaxy nexus, nexus4
fixes: lp:1173191
Description of the change
enable internal clients (in-process-egl) for android. refactor platform abstraction for internal clients as well.
tested on my laptop (intel drivers), galaxy nexus, nexus4
fixes: lp:1173191
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:712
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Robert Ancell (robert-ancell) wrote : | # |
I didn't review in depth, but at a high level looks good to me.
Kevin DuBois (kdub) wrote : | # |
Here are some places to zone in:
l70: the in-process client registers sigint/sigterm handlers to stop the render loop. this is what fixes one of the bugs I noticed in this branch.
l86/87: mg::InternalClient is the current way that the platform constructs an internal (in-process-egl) client. It is constructed in mg::Platform via an mf::Surface. I'd expect mg::InternalClient to expand in the future (say, so the internal clients can get at size/pixelforma
I rolled src/graphics/egl into src/graphics/gbm like I was talking about at the sprint. This involved a bit of refactoring of ShellMesaEGLNat
Kevin DuBois (kdub) wrote : | # |
furthermore, I added some comments in a bug that exists in current lp:mir (https:/
Alan Griffiths (alan-griffiths) wrote : | # |
I'm not clear on some of the semantics - e.g. what does this do and why does it need a surface:
266 + virtual std::shared_
But it seems to work without anything that leaps out as ugly.
Kevin DuBois (kdub) wrote : | # |
> I'm not clear on some of the semantics - e.g. what does this do and why does
> it need a surface:
>
> 266 + virtual std::shared_
> create_
>
> But it seems to work without anything that leaps out as ugly.
the drivers need to understand our surfaces to use them internally. With mesa/gbm platform, we can just use the mf::Surface interface directly, because we control those drivers. With Android, we wrap the mf::Surface interface in an interface that driver can understand, and then give that out to our clients. essentially, what the user of this function gets back is a platform-friendly representation of the mf::Surface that they can plug into their egl driver
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'examples/CMakeLists.txt' |
2 | --- examples/CMakeLists.txt 2013-05-01 00:58:45 +0000 |
3 | +++ examples/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
4 | @@ -120,10 +120,7 @@ |
5 | mir_eglplasma |
6 | ) |
7 | |
8 | -if (MIR_PLATFORM STREQUAL "gbm") |
9 | - add_subdirectory(demo-inprocess-egl) |
10 | -endif() |
11 | - |
12 | +add_subdirectory(demo-inprocess-egl) |
13 | add_subdirectory(demo-shell) |
14 | |
15 | install(TARGETS ${DEMO_CLIENTS} RUNTIME DESTINATION bin) |
16 | |
17 | === modified file 'examples/demo-inprocess-egl/demo_inprocess_egl.cpp' |
18 | --- examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-05-02 00:11:18 +0000 |
19 | +++ examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-05-09 21:03:25 +0000 |
20 | @@ -46,6 +46,7 @@ |
21 | mir::run_mir(config, [&config, &client](mir::DisplayServer&) |
22 | { |
23 | client = std::make_shared<me::InprocessEGLClient>( |
24 | + config.the_main_loop(), |
25 | config.the_graphics_platform(), |
26 | config.the_shell_surface_factory()); |
27 | }); |
28 | |
29 | === modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp' |
30 | --- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-05-02 00:11:18 +0000 |
31 | +++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-05-09 21:03:25 +0000 |
32 | @@ -19,12 +19,14 @@ |
33 | #include "inprocess_egl_client.h" |
34 | #include "example_egl_helper.h" |
35 | |
36 | +#include "mir/main_loop.h" |
37 | #include "mir/shell/surface_factory.h" |
38 | #include "mir/shell/surface.h" |
39 | #include "mir/frontend/surface_creation_parameters.h" |
40 | #include "mir/geometry/size.h" |
41 | #include "mir/compositor/buffer_properties.h" |
42 | #include "mir/graphics/platform.h" |
43 | +#include "mir/graphics/internal_client.h" |
44 | |
45 | #include "graphics.h" |
46 | |
47 | @@ -33,6 +35,8 @@ |
48 | #include <functional> |
49 | |
50 | #include <assert.h> |
51 | +#include <signal.h> |
52 | + |
53 | |
54 | namespace mf = mir::frontend; |
55 | namespace mc = mir::compositor; |
56 | @@ -41,12 +45,20 @@ |
57 | namespace me = mir::examples; |
58 | namespace geom = mir::geometry; |
59 | |
60 | -me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mg::Platform> const& graphics_platform, |
61 | +me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop, |
62 | + std::shared_ptr<mg::Platform> const& graphics_platform, |
63 | std::shared_ptr<msh::SurfaceFactory> const& surface_factory) |
64 | : graphics_platform(graphics_platform), |
65 | surface_factory(surface_factory), |
66 | - client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this) |
67 | + client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this), |
68 | + terminate(false) |
69 | { |
70 | + main_loop->register_signal_handler({SIGTERM, SIGINT}, |
71 | + [this](int) |
72 | + { |
73 | + terminate = true; |
74 | + } |
75 | + ); |
76 | client_thread.detach(); |
77 | } |
78 | |
79 | @@ -61,9 +73,8 @@ |
80 | .of_buffer_usage(mc::BufferUsage::hardware) |
81 | .of_pixel_format(geom::PixelFormat::argb_8888); |
82 | auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>()); |
83 | - |
84 | - auto native_display = graphics_platform->shell_egl_display(); |
85 | - me::EGLHelper helper(reinterpret_cast<EGLNativeDisplayType>(native_display), reinterpret_cast<EGLNativeWindowType>(surface.get())); |
86 | + auto internal_client = graphics_platform->create_internal_client(surface); |
87 | + me::EGLHelper helper(internal_client->egl_native_display(), internal_client->egl_native_window()); |
88 | |
89 | auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context()); |
90 | assert(rc == EGL_TRUE); |
91 | @@ -73,7 +84,7 @@ |
92 | ///\internal [setup_tag] |
93 | |
94 | ///\internal [loop_tag] |
95 | - for(;;) |
96 | + while(!terminate) |
97 | { |
98 | gl_animation.render_gl(); |
99 | rc = eglSwapBuffers(helper.the_display(), helper.the_surface()); |
100 | |
101 | === modified file 'examples/demo-inprocess-egl/inprocess_egl_client.h' |
102 | --- examples/demo-inprocess-egl/inprocess_egl_client.h 2013-04-01 16:45:07 +0000 |
103 | +++ examples/demo-inprocess-egl/inprocess_egl_client.h 2013-05-09 21:03:25 +0000 |
104 | @@ -24,6 +24,7 @@ |
105 | |
106 | namespace mir |
107 | { |
108 | +class MainLoop; |
109 | namespace graphics |
110 | { |
111 | class Platform; |
112 | @@ -40,7 +41,8 @@ |
113 | class InprocessEGLClient |
114 | { |
115 | public: |
116 | - InprocessEGLClient(std::shared_ptr<graphics::Platform> const& graphics_platform, |
117 | + InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop, |
118 | + std::shared_ptr<graphics::Platform> const& graphics_platform, |
119 | std::shared_ptr<shell::SurfaceFactory> const& surface_factory); |
120 | |
121 | protected: |
122 | @@ -50,9 +52,10 @@ |
123 | private: |
124 | std::shared_ptr<graphics::Platform> const graphics_platform; |
125 | std::shared_ptr<shell::SurfaceFactory> const surface_factory; |
126 | - |
127 | + |
128 | std::thread client_thread; |
129 | void thread_loop(); |
130 | + bool terminate; |
131 | }; |
132 | |
133 | } |
134 | |
135 | === removed directory 'include/server/mir/graphics/egl' |
136 | === removed file 'include/server/mir/graphics/egl/mesa_native_display.h' |
137 | --- include/server/mir/graphics/egl/mesa_native_display.h 2013-04-24 05:22:20 +0000 |
138 | +++ include/server/mir/graphics/egl/mesa_native_display.h 1970-01-01 00:00:00 +0000 |
139 | @@ -1,42 +0,0 @@ |
140 | -/* |
141 | - * Copyright © 2013 Canonical Ltd. |
142 | - * |
143 | - * This program is free software: you can redistribute it and/or modify it |
144 | - * under the terms of the GNU General Public License version 3, |
145 | - * as published by the Free Software Foundation. |
146 | - * |
147 | - * This program is distributed in the hope that it will be useful, |
148 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
149 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
150 | - * GNU General Public License for more details. |
151 | - * |
152 | - * You should have received a copy of the GNU General Public License |
153 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
154 | - * |
155 | - * Authored by: Robert Carr <robert.carr@canonical.com> |
156 | - */ |
157 | - |
158 | -#ifndef MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
159 | -#define MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
160 | - |
161 | -#include "mir_toolkit/mesa/native_display.h" |
162 | - |
163 | -#include <memory> |
164 | - |
165 | -namespace mir |
166 | -{ |
167 | -namespace graphics |
168 | -{ |
169 | -class Platform; |
170 | - |
171 | -namespace egl |
172 | -{ |
173 | -namespace mesa |
174 | -{ |
175 | -std::shared_ptr<MirMesaEGLNativeDisplay> create_native_display(std::shared_ptr<Platform> const& platform); |
176 | -} |
177 | -} |
178 | -} |
179 | -} // namespace mir |
180 | - |
181 | -#endif // MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
182 | |
183 | === added file 'include/server/mir/graphics/internal_client.h' |
184 | --- include/server/mir/graphics/internal_client.h 1970-01-01 00:00:00 +0000 |
185 | +++ include/server/mir/graphics/internal_client.h 2013-05-09 21:03:25 +0000 |
186 | @@ -0,0 +1,43 @@ |
187 | +/* |
188 | + * Copyright © 2013 Canonical Ltd. |
189 | + * |
190 | + * This program is free software: you can redistribute it and/or modify it |
191 | + * under the terms of the GNU General Public License version 3, |
192 | + * as published by the Free Software Foundation. |
193 | + * |
194 | + * This program is distributed in the hope that it will be useful, |
195 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
196 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
197 | + * GNU General Public License for more details. |
198 | + * |
199 | + * You should have received a copy of the GNU General Public License |
200 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
201 | + * |
202 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
203 | + */ |
204 | + |
205 | + |
206 | +#ifndef MIR_GRAPHICS_INTERNAL_CLIENT_H_ |
207 | +#define MIR_GRAPHICS_INTERNAL_CLIENT_H_ |
208 | + |
209 | +#include <EGL/egl.h> |
210 | + |
211 | +namespace mir |
212 | +{ |
213 | +namespace graphics |
214 | +{ |
215 | +class InternalClient |
216 | +{ |
217 | +public: |
218 | + virtual EGLNativeDisplayType egl_native_display() = 0; |
219 | + virtual EGLNativeWindowType egl_native_window() = 0; |
220 | +protected: |
221 | + InternalClient() = default; |
222 | + virtual ~InternalClient() = default; |
223 | + InternalClient(InternalClient const&) = delete; |
224 | + InternalClient& operator=(InternalClient const&) = delete; |
225 | +}; |
226 | +} |
227 | +} |
228 | + |
229 | +#endif /* MIR_GRAPHICS_INTERNAL_CLIENT_H_ */ |
230 | |
231 | === modified file 'include/server/mir/graphics/platform.h' |
232 | --- include/server/mir/graphics/platform.h 2013-04-24 05:22:20 +0000 |
233 | +++ include/server/mir/graphics/platform.h 2013-05-09 21:03:25 +0000 |
234 | @@ -20,12 +20,14 @@ |
235 | #ifndef MIR_GRAPHICS_PLATFORM_H_ |
236 | #define MIR_GRAPHICS_PLATFORM_H_ |
237 | |
238 | -#include <EGL/egl.h> |
239 | - |
240 | #include <memory> |
241 | |
242 | namespace mir |
243 | { |
244 | +namespace frontend |
245 | +{ |
246 | +class Surface; |
247 | +} |
248 | namespace compositor |
249 | { |
250 | class GraphicBufferAllocator; |
251 | @@ -39,7 +41,7 @@ |
252 | class Display; |
253 | struct PlatformIPCPackage; |
254 | class BufferInitializer; |
255 | - |
256 | +class InternalClient; |
257 | class DisplayReport; |
258 | |
259 | /// Interface to platform specific support for graphics operations. |
260 | @@ -54,8 +56,7 @@ |
261 | std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0; |
262 | virtual std::shared_ptr<Display> create_display() = 0; |
263 | virtual std::shared_ptr<PlatformIPCPackage> get_ipc_package() = 0; |
264 | - |
265 | - virtual EGLNativeDisplayType shell_egl_display() = 0; |
266 | + virtual std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&) = 0; |
267 | }; |
268 | |
269 | // Create and return a new graphics platform. |
270 | |
271 | === modified file 'include/shared/mir_toolkit/mesa/native_display.h' |
272 | --- include/shared/mir_toolkit/mesa/native_display.h 2013-05-03 22:53:42 +0000 |
273 | +++ include/shared/mir_toolkit/mesa/native_display.h 2013-05-09 21:03:25 +0000 |
274 | @@ -48,7 +48,16 @@ |
275 | void *context; |
276 | }; |
277 | |
278 | +typedef enum mir_display_type |
279 | +{ |
280 | + MIR_DISPLAY_TYPE_CLIENT, |
281 | + MIR_DISPLAY_TYPE_SERVER_INTERNAL |
282 | +} mir_display_type; |
283 | + |
284 | +mir_display_type mir_get_display_type(MirMesaEGLNativeDisplay* display); |
285 | + |
286 | int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display); |
287 | +int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display); |
288 | |
289 | #ifdef __cplusplus |
290 | } // extern "C" |
291 | |
292 | === added file 'include/test/mir_test_doubles/mock_interpreter_resource_cache.h' |
293 | --- include/test/mir_test_doubles/mock_interpreter_resource_cache.h 1970-01-01 00:00:00 +0000 |
294 | +++ include/test/mir_test_doubles/mock_interpreter_resource_cache.h 2013-05-09 21:03:25 +0000 |
295 | @@ -0,0 +1,37 @@ |
296 | +/* |
297 | + * Copyright © 2013 Canonical Ltd. |
298 | + * |
299 | + * This program is free software: you can redistribute it and/or modify it |
300 | + * under the terms of the GNU General Public License version 3, |
301 | + * as published by the Free Software Foundation. |
302 | + * |
303 | + * This program is distributed in the hope that it will be useful, |
304 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
305 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
306 | + * GNU General Public License for more details. |
307 | + * |
308 | + * You should have received a copy of the GNU General Public License |
309 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
310 | + * |
311 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
312 | + */ |
313 | +#ifndef MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_ |
314 | +#define MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_ |
315 | + |
316 | +#include "src/server/graphics/android/interpreter_resource_cache.h" |
317 | + |
318 | +namespace mir |
319 | +{ |
320 | +namespace test |
321 | +{ |
322 | +namespace doubles |
323 | +{ |
324 | +struct MockInterpreterResourceCache : public graphics::android::InterpreterResourceCache |
325 | +{ |
326 | + MOCK_METHOD2(store_buffer, void(std::shared_ptr<compositor::Buffer>const&, ANativeWindowBuffer*)); |
327 | + MOCK_METHOD1(retrieve_buffer, std::shared_ptr<compositor::Buffer>(ANativeWindowBuffer*)); |
328 | +}; |
329 | +} |
330 | +} |
331 | +} |
332 | +#endif /* MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_ */ |
333 | |
334 | === modified file 'include/test/mir_test_doubles/mock_swapper.h' |
335 | --- include/test/mir_test_doubles/mock_swapper.h 2013-05-02 16:29:48 +0000 |
336 | +++ include/test/mir_test_doubles/mock_swapper.h 2013-05-09 21:03:25 +0000 |
337 | @@ -32,6 +32,7 @@ |
338 | struct MockSwapper : public compositor::BufferSwapper |
339 | { |
340 | public: |
341 | + MockSwapper() {} |
342 | MockSwapper(std::shared_ptr<compositor::Buffer> buffer) |
343 | : default_buffer(buffer) |
344 | { |
345 | |
346 | === added file 'include/test/mir_test_doubles/stub_platform.h' |
347 | --- include/test/mir_test_doubles/stub_platform.h 1970-01-01 00:00:00 +0000 |
348 | +++ include/test/mir_test_doubles/stub_platform.h 2013-05-09 21:03:25 +0000 |
349 | @@ -0,0 +1,60 @@ |
350 | +/* |
351 | + * Copyright © 2013 Canonical Ltd. |
352 | + * |
353 | + * This program is free software: you can redistribute it and/or modify it |
354 | + * under the terms of the GNU General Public License version 3, |
355 | + * as published by the Free Software Foundation. |
356 | + * |
357 | + * This program is distributed in the hope that it will be useful, |
358 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
359 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
360 | + * GNU General Public License for more details. |
361 | + * |
362 | + * You should have received a copy of the GNU General Public License |
363 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
364 | + * |
365 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
366 | + */ |
367 | + |
368 | +#ifndef MIR_TEST_DOUBLES_STUB_PLATFORM_H_ |
369 | +#define MIR_TEST_DOUBLES_STUB_PLATFORM_H_ |
370 | + |
371 | +#include "mir/graphics/platform.h" |
372 | +#include "mir/graphics/platform_ipc_package.h" |
373 | +#include "null_display.h" |
374 | + |
375 | +namespace mir |
376 | +{ |
377 | +namespace test |
378 | +{ |
379 | +namespace doubles |
380 | +{ |
381 | +class StubPlatform : public graphics::Platform |
382 | +{ |
383 | + public: |
384 | + std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( |
385 | + const std::shared_ptr<graphics::BufferInitializer>& /*buffer_initializer*/) |
386 | + { |
387 | + return std::shared_ptr<compositor::GraphicBufferAllocator>(); |
388 | + } |
389 | + |
390 | + std::shared_ptr<graphics::Display> create_display() |
391 | + { |
392 | + return std::make_shared<NullDisplay>(); |
393 | + } |
394 | + |
395 | + std::shared_ptr<graphics::PlatformIPCPackage> get_ipc_package() |
396 | + { |
397 | + return std::make_shared<graphics::PlatformIPCPackage>(); |
398 | + } |
399 | + |
400 | + std::shared_ptr<graphics::InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&) |
401 | + { |
402 | + return std::shared_ptr<graphics::InternalClient>(); |
403 | + } |
404 | +}; |
405 | +} |
406 | +} |
407 | +} // namespace mir |
408 | + |
409 | +#endif // MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_ |
410 | |
411 | === modified file 'src/server/graphics/CMakeLists.txt' |
412 | --- src/server/graphics/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
413 | +++ src/server/graphics/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
414 | @@ -19,10 +19,6 @@ |
415 | null_display_report.cpp |
416 | ) |
417 | |
418 | -if (MIR_PLATFORM STREQUAL "gbm") |
419 | - add_subdirectory(egl/) |
420 | -endif() |
421 | - |
422 | add_library( |
423 | mirgraphics STATIC |
424 | |
425 | |
426 | === modified file 'src/server/graphics/android/CMakeLists.txt' |
427 | --- src/server/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000 |
428 | +++ src/server/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
429 | @@ -26,6 +26,9 @@ |
430 | default_framebuffer_factory.cpp |
431 | fb_simple_swapper.cpp |
432 | fb_device.cpp |
433 | + internal_client_window.cpp |
434 | + interpreter_cache.cpp |
435 | + internal_client.cpp |
436 | ) |
437 | |
438 | target_link_libraries( |
439 | |
440 | === modified file 'src/server/graphics/android/android_platform.cpp' |
441 | --- src/server/graphics/android/android_platform.cpp 2013-04-26 00:00:27 +0000 |
442 | +++ src/server/graphics/android/android_platform.cpp 2013-05-09 21:03:25 +0000 |
443 | @@ -23,6 +23,7 @@ |
444 | #include "android_display_allocator.h" |
445 | #include "android_display_factory.h" |
446 | #include "default_framebuffer_factory.h" |
447 | +#include "internal_client.h" |
448 | #include "mir/graphics/platform_ipc_package.h" |
449 | #include "mir/graphics/buffer_initializer.h" |
450 | #include "mir/compositor/buffer_id.h" |
451 | @@ -30,6 +31,7 @@ |
452 | namespace mg=mir::graphics; |
453 | namespace mga=mir::graphics::android; |
454 | namespace mc=mir::compositor; |
455 | +namespace mf=mir::frontend; |
456 | |
457 | mga::AndroidPlatform::AndroidPlatform(std::shared_ptr<mg::DisplayReport> const& display_report) |
458 | : display_report(display_report) |
459 | @@ -59,10 +61,10 @@ |
460 | return std::make_shared<mg::PlatformIPCPackage>(); |
461 | } |
462 | |
463 | -EGLNativeDisplayType mga::AndroidPlatform::shell_egl_display() |
464 | +std::shared_ptr<mg::InternalClient> mga::AndroidPlatform::create_internal_client( |
465 | + std::shared_ptr<mf::Surface> const& surface) |
466 | { |
467 | - // TODO: Implement |
468 | - return static_cast<EGLNativeDisplayType>(0); |
469 | + return std::make_shared<mga::InternalClient>(surface); |
470 | } |
471 | |
472 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& display_report) |
473 | |
474 | === modified file 'src/server/graphics/android/android_platform.h' |
475 | --- src/server/graphics/android/android_platform.h 2013-04-26 00:00:27 +0000 |
476 | +++ src/server/graphics/android/android_platform.h 2013-05-09 21:03:25 +0000 |
477 | @@ -38,9 +38,8 @@ |
478 | std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( |
479 | const std::shared_ptr<BufferInitializer>& buffer_initializer); |
480 | std::shared_ptr<Display> create_display(); |
481 | - std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
482 | - |
483 | - EGLNativeDisplayType shell_egl_display(); |
484 | + std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
485 | + std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&); |
486 | |
487 | private: |
488 | std::shared_ptr<DisplayReport> const display_report; |
489 | |
490 | === modified file 'src/server/graphics/android/default_framebuffer_factory.cpp' |
491 | --- src/server/graphics/android/default_framebuffer_factory.cpp 2013-05-06 17:11:28 +0000 |
492 | +++ src/server/graphics/android/default_framebuffer_factory.cpp 2013-05-09 21:03:25 +0000 |
493 | @@ -24,6 +24,7 @@ |
494 | #include "fb_simple_swapper.h" |
495 | #include "graphic_buffer_allocator.h" |
496 | #include "server_render_window.h" |
497 | +#include "interpreter_cache.h" |
498 | |
499 | #include <boost/throw_exception.hpp> |
500 | #include <stdexcept> |
501 | @@ -51,7 +52,8 @@ |
502 | } |
503 | |
504 | auto swapper = std::make_shared<mga::FBSimpleSwapper>(buffers); |
505 | - auto interpreter = std::make_shared<mga::ServerRenderWindow>(swapper, info_provider); |
506 | + auto cache = std::make_shared<mga::InterpreterCache>(); |
507 | + auto interpreter = std::make_shared<mga::ServerRenderWindow>(swapper, info_provider, cache); |
508 | return std::make_shared<mga::MirNativeWindow>(interpreter); |
509 | } |
510 | |
511 | |
512 | === added file 'src/server/graphics/android/internal_client.cpp' |
513 | --- src/server/graphics/android/internal_client.cpp 1970-01-01 00:00:00 +0000 |
514 | +++ src/server/graphics/android/internal_client.cpp 2013-05-09 21:03:25 +0000 |
515 | @@ -0,0 +1,42 @@ |
516 | +/* |
517 | + * Copyright © 2013 Canonical Ltd. |
518 | + * |
519 | + * This program is free software: you can redistribute it and/or modify it |
520 | + * under the terms of the GNU General Public License version 3, |
521 | + * as published by the Free Software Foundation. |
522 | + * |
523 | + * This program is distributed in the hope that it will be useful, |
524 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
525 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
526 | + * GNU General Public License for more details. |
527 | + * |
528 | + * You should have received a copy of the GNU General Public License |
529 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
530 | + * |
531 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
532 | + */ |
533 | + |
534 | +#include "internal_client.h" |
535 | +#include "interpreter_cache.h" |
536 | +#include "internal_client_window.h" |
537 | +#include "mir/graphics/android/mir_native_window.h" |
538 | + |
539 | +namespace mf=mir::frontend; |
540 | +namespace mga=mir::graphics::android; |
541 | + |
542 | +mga::InternalClient::InternalClient(std::shared_ptr<frontend::Surface> const& surface) |
543 | +{ |
544 | + auto cache = std::make_shared<mga::InterpreterCache>(); |
545 | + auto interpreter = std::make_shared<mga::InternalClientWindow>(surface, cache); |
546 | + client_window = std::make_shared<mga::MirNativeWindow>(interpreter); |
547 | +} |
548 | + |
549 | +EGLNativeDisplayType mga::InternalClient::egl_native_display() |
550 | +{ |
551 | + return EGL_DEFAULT_DISPLAY; |
552 | +} |
553 | + |
554 | +EGLNativeWindowType mga::InternalClient::egl_native_window() |
555 | +{ |
556 | + return client_window.get(); |
557 | +} |
558 | |
559 | === added file 'src/server/graphics/android/internal_client.h' |
560 | --- src/server/graphics/android/internal_client.h 1970-01-01 00:00:00 +0000 |
561 | +++ src/server/graphics/android/internal_client.h 2013-05-09 21:03:25 +0000 |
562 | @@ -0,0 +1,52 @@ |
563 | +/* |
564 | + * Copyright © 2013 Canonical Ltd. |
565 | + * |
566 | + * This program is free software: you can redistribute it and/or modify it |
567 | + * under the terms of the GNU General Public License version 3, |
568 | + * as published by the Free Software Foundation. |
569 | + * |
570 | + * This program is distributed in the hope that it will be useful, |
571 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
572 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
573 | + * GNU General Public License for more details. |
574 | + * |
575 | + * You should have received a copy of the GNU General Public License |
576 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
577 | + * |
578 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
579 | + */ |
580 | + |
581 | +#ifndef MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_ |
582 | +#define MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_ |
583 | + |
584 | +#include "mir/graphics/internal_client.h" |
585 | +#include <memory> |
586 | + |
587 | +namespace mir |
588 | +{ |
589 | +namespace frontend |
590 | +{ |
591 | +class Surface; |
592 | +} |
593 | +namespace graphics |
594 | +{ |
595 | +namespace android |
596 | +{ |
597 | + |
598 | +class MirNativeWindow; |
599 | +class InternalClient : public mir::graphics::InternalClient |
600 | +{ |
601 | +public: |
602 | + InternalClient(std::shared_ptr<frontend::Surface> const&); |
603 | + EGLNativeDisplayType egl_native_display(); |
604 | + EGLNativeWindowType egl_native_window(); |
605 | + |
606 | +private: |
607 | + std::shared_ptr<MirNativeWindow> client_window; |
608 | +}; |
609 | + |
610 | +} |
611 | +} |
612 | +} |
613 | + |
614 | +#endif /* MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_ */ |
615 | |
616 | === added file 'src/server/graphics/android/internal_client_window.cpp' |
617 | --- src/server/graphics/android/internal_client_window.cpp 1970-01-01 00:00:00 +0000 |
618 | +++ src/server/graphics/android/internal_client_window.cpp 2013-05-09 21:03:25 +0000 |
619 | @@ -0,0 +1,79 @@ |
620 | +/* |
621 | + * Copyright © 2013 Canonical Ltd. |
622 | + * |
623 | + * This program is free software: you can redistribute it and/or modify |
624 | + * it under the terms of the GNU General Public License version 3 as |
625 | + * published by the Free Software Foundation. |
626 | + * |
627 | + * This program is distributed in the hope that it will be useful, |
628 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
629 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
630 | + * GNU General Public License for more details. |
631 | + * |
632 | + * You should have received a copy of the GNU General Public License |
633 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
634 | + * |
635 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
636 | + */ |
637 | + |
638 | +#include "mir/frontend/surface.h" |
639 | +#include "mir/compositor/buffer.h" |
640 | +#include "internal_client_window.h" |
641 | +#include "interpreter_resource_cache.h" |
642 | +#include "android_format_conversion-inl.h" |
643 | + |
644 | +#include <boost/throw_exception.hpp> |
645 | +#include <stdexcept> |
646 | +namespace mga=mir::graphics::android; |
647 | +namespace geom=mir::geometry; |
648 | + |
649 | +mga::InternalClientWindow::InternalClientWindow(std::shared_ptr<frontend::Surface> const& surface, |
650 | + std::shared_ptr<InterpreterResourceCache> const& cache) |
651 | + : surface(surface), |
652 | + resource_cache(cache) |
653 | +{ |
654 | + format = mga::to_android_format(surface->pixel_format()); |
655 | +} |
656 | + |
657 | +ANativeWindowBuffer* mga::InternalClientWindow::driver_requests_buffer() |
658 | +{ |
659 | + surface->advance_client_buffer(); |
660 | + auto buffer = surface->client_buffer(); |
661 | + auto handle = buffer->native_buffer_handle().get(); |
662 | + resource_cache->store_buffer(buffer, handle); |
663 | + return handle; |
664 | +} |
665 | + |
666 | +void mga::InternalClientWindow::driver_returns_buffer(ANativeWindowBuffer* handle, |
667 | + std::shared_ptr<SyncObject> const&) |
668 | +{ |
669 | + resource_cache->retrieve_buffer(handle); |
670 | + /* here, the mc::TemporaryBuffer will destruct, triggering buffer advance */ |
671 | +} |
672 | + |
673 | +void mga::InternalClientWindow::dispatch_driver_request_format(int request_format) |
674 | +{ |
675 | + format = request_format; |
676 | +} |
677 | + |
678 | +int mga::InternalClientWindow::driver_requests_info(int key) const |
679 | +{ |
680 | + geom::Size size; |
681 | + switch(key) |
682 | + { |
683 | + case NATIVE_WINDOW_DEFAULT_WIDTH: |
684 | + case NATIVE_WINDOW_WIDTH: |
685 | + size = surface->size(); |
686 | + return size.width.as_uint32_t(); |
687 | + case NATIVE_WINDOW_DEFAULT_HEIGHT: |
688 | + case NATIVE_WINDOW_HEIGHT: |
689 | + size = surface->size(); |
690 | + return size.height.as_uint32_t(); |
691 | + case NATIVE_WINDOW_FORMAT: |
692 | + return format; |
693 | + case NATIVE_WINDOW_TRANSFORM_HINT: |
694 | + return 0; |
695 | + default: |
696 | + BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key)); |
697 | + } |
698 | +} |
699 | |
700 | === added file 'src/server/graphics/android/internal_client_window.h' |
701 | --- src/server/graphics/android/internal_client_window.h 1970-01-01 00:00:00 +0000 |
702 | +++ src/server/graphics/android/internal_client_window.h 2013-05-09 21:03:25 +0000 |
703 | @@ -0,0 +1,58 @@ |
704 | +/* |
705 | + * Copyright © 2013 Canonical Ltd. |
706 | + * |
707 | + * This program is free software: you can redistribute it and/or modify |
708 | + * it under the terms of the GNU General Public License version 3 as |
709 | + * published by the Free Software Foundation. |
710 | + * |
711 | + * This program is distributed in the hope that it will be useful, |
712 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
713 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
714 | + * GNU General Public License for more details. |
715 | + * |
716 | + * You should have received a copy of the GNU General Public License |
717 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
718 | + * |
719 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
720 | + */ |
721 | + |
722 | +#ifndef MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_ |
723 | +#define MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_ |
724 | + |
725 | +#include "mir/graphics/android/android_driver_interpreter.h" |
726 | +#include "mir/geometry/size.h" |
727 | +#include "mir/geometry/pixel_format.h" |
728 | + |
729 | +namespace mir |
730 | +{ |
731 | + |
732 | +namespace frontend |
733 | +{ |
734 | +class Surface; |
735 | +} |
736 | + |
737 | +namespace graphics |
738 | +{ |
739 | +namespace android |
740 | +{ |
741 | + |
742 | +class InterpreterResourceCache; |
743 | +class InternalClientWindow : public AndroidDriverInterpreter |
744 | +{ |
745 | +public: |
746 | + InternalClientWindow(std::shared_ptr<frontend::Surface> const&, |
747 | + std::shared_ptr<InterpreterResourceCache> const&); |
748 | + ANativeWindowBuffer* driver_requests_buffer(); |
749 | + void driver_returns_buffer(ANativeWindowBuffer*, std::shared_ptr<SyncObject> const&); |
750 | + void dispatch_driver_request_format(int); |
751 | + int driver_requests_info(int) const; |
752 | + |
753 | +private: |
754 | + std::shared_ptr<frontend::Surface> const surface; |
755 | + std::shared_ptr<InterpreterResourceCache> const resource_cache; |
756 | + int format; |
757 | +}; |
758 | +} |
759 | +} |
760 | +} |
761 | +#endif /* MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_ */ |
762 | |
763 | === added file 'src/server/graphics/android/interpreter_cache.cpp' |
764 | --- src/server/graphics/android/interpreter_cache.cpp 1970-01-01 00:00:00 +0000 |
765 | +++ src/server/graphics/android/interpreter_cache.cpp 2013-05-09 21:03:25 +0000 |
766 | @@ -0,0 +1,41 @@ |
767 | +/* |
768 | + * Copyright © 2013 Canonical Ltd. |
769 | + * |
770 | + * This program is free software: you can redistribute it and/or modify |
771 | + * it under the terms of the GNU General Public License version 3 as |
772 | + * published by the Free Software Foundation. |
773 | + * |
774 | + * This program is distributed in the hope that it will be useful, |
775 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
776 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
777 | + * GNU General Public License for more details. |
778 | + * |
779 | + * You should have received a copy of the GNU General Public License |
780 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
781 | + * |
782 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
783 | + */ |
784 | + |
785 | +#include "interpreter_cache.h" |
786 | +#include <boost/throw_exception.hpp> |
787 | +#include <stdexcept> |
788 | + |
789 | +namespace mga=mir::graphics::android; |
790 | +namespace mc=mir::compositor; |
791 | + |
792 | +void mga::InterpreterCache::store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key) |
793 | +{ |
794 | + buffers_in_driver[key] = buffer; |
795 | +} |
796 | + |
797 | +std::shared_ptr<mc::Buffer> mga::InterpreterCache::retrieve_buffer(ANativeWindowBuffer* returned_handle) |
798 | +{ |
799 | + auto buffer_it = buffers_in_driver.find(returned_handle); |
800 | + if (buffer_it == buffers_in_driver.end()) |
801 | + { |
802 | + BOOST_THROW_EXCEPTION(std::runtime_error("driver is returning buffers it never was given!")); |
803 | + } |
804 | + auto buffer_out = buffer_it->second; |
805 | + buffers_in_driver.erase(buffer_it); |
806 | + return buffer_out; |
807 | +} |
808 | |
809 | === added file 'src/server/graphics/android/interpreter_cache.h' |
810 | --- src/server/graphics/android/interpreter_cache.h 1970-01-01 00:00:00 +0000 |
811 | +++ src/server/graphics/android/interpreter_cache.h 2013-05-09 21:03:25 +0000 |
812 | @@ -0,0 +1,45 @@ |
813 | +/* |
814 | + * Copyright © 2013 Canonical Ltd. |
815 | + * |
816 | + * This program is free software: you can redistribute it and/or modify |
817 | + * it under the terms of the GNU General Public License version 3 as |
818 | + * published by the Free Software Foundation. |
819 | + * |
820 | + * This program is distributed in the hope that it will be useful, |
821 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
822 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
823 | + * GNU General Public License for more details. |
824 | + * |
825 | + * You should have received a copy of the GNU General Public License |
826 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
827 | + * |
828 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
829 | + */ |
830 | + |
831 | +#ifndef MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_ |
832 | +#define MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_ |
833 | + |
834 | +#include "interpreter_resource_cache.h" |
835 | +#include <unordered_map> |
836 | + |
837 | +namespace mir |
838 | +{ |
839 | +namespace graphics |
840 | +{ |
841 | +namespace android |
842 | +{ |
843 | +class InterpreterCache : public InterpreterResourceCache |
844 | +{ |
845 | +public: |
846 | + InterpreterCache() {} |
847 | + |
848 | + void store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key); |
849 | + std::shared_ptr<compositor::Buffer> retrieve_buffer(ANativeWindowBuffer* key); |
850 | + |
851 | +private: |
852 | + std::unordered_map<ANativeWindowBuffer*, std::shared_ptr<compositor::Buffer>> buffers_in_driver; |
853 | +}; |
854 | +} |
855 | +} |
856 | +} |
857 | +#endif /* MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_ */ |
858 | |
859 | === added file 'src/server/graphics/android/interpreter_resource_cache.h' |
860 | --- src/server/graphics/android/interpreter_resource_cache.h 1970-01-01 00:00:00 +0000 |
861 | +++ src/server/graphics/android/interpreter_resource_cache.h 2013-05-09 21:03:25 +0000 |
862 | @@ -0,0 +1,50 @@ |
863 | +/* |
864 | + * Copyright © 2013 Canonical Ltd. |
865 | + * |
866 | + * This program is free software: you can redistribute it and/or modify |
867 | + * it under the terms of the GNU General Public License version 3 as |
868 | + * published by the Free Software Foundation. |
869 | + * |
870 | + * This program is distributed in the hope that it will be useful, |
871 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
872 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
873 | + * GNU General Public License for more details. |
874 | + * |
875 | + * You should have received a copy of the GNU General Public License |
876 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
877 | + * |
878 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
879 | + */ |
880 | + |
881 | +#ifndef MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_ |
882 | +#define MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_ |
883 | +#include <system/window.h> |
884 | +#include <memory> |
885 | + |
886 | +namespace mir |
887 | +{ |
888 | +namespace compositor |
889 | +{ |
890 | +class Buffer; |
891 | +} |
892 | +namespace graphics |
893 | +{ |
894 | +namespace android |
895 | +{ |
896 | +class InterpreterResourceCache |
897 | +{ |
898 | +public: |
899 | + InterpreterResourceCache() {} |
900 | + |
901 | + virtual void store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key) = 0; |
902 | + virtual std::shared_ptr<compositor::Buffer> retrieve_buffer(ANativeWindowBuffer* key) = 0; |
903 | + |
904 | +protected: |
905 | + virtual ~InterpreterResourceCache() {} |
906 | + InterpreterResourceCache(const InterpreterResourceCache&) = delete; |
907 | + InterpreterResourceCache& operator=(const InterpreterResourceCache&) = delete; |
908 | +}; |
909 | +} |
910 | +} |
911 | +} |
912 | +#endif /* MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_ */ |
913 | |
914 | === modified file 'src/server/graphics/android/server_render_window.cpp' |
915 | --- src/server/graphics/android/server_render_window.cpp 2013-05-06 15:38:52 +0000 |
916 | +++ src/server/graphics/android/server_render_window.cpp 2013-05-09 21:03:25 +0000 |
917 | @@ -23,11 +23,11 @@ |
918 | #include "fb_swapper.h" |
919 | #include "buffer.h" |
920 | #include "android_format_conversion-inl.h" |
921 | +#include "interpreter_resource_cache.h" |
922 | |
923 | #include <boost/throw_exception.hpp> |
924 | #include <stdexcept> |
925 | |
926 | - |
927 | #include <thread> |
928 | #include <chrono> |
929 | namespace mc=mir::compositor; |
930 | @@ -35,9 +35,11 @@ |
931 | namespace geom=mir::geometry; |
932 | |
933 | mga::ServerRenderWindow::ServerRenderWindow(std::shared_ptr<mga::FBSwapper> const& swapper, |
934 | - std::shared_ptr<mga::DisplaySupportProvider> const& display_poster) |
935 | + std::shared_ptr<mga::DisplaySupportProvider> const& display_poster, |
936 | + std::shared_ptr<InterpreterResourceCache> const& cache) |
937 | : swapper(swapper), |
938 | poster(display_poster), |
939 | + resource_cache(cache), |
940 | format(mga::to_android_format(poster->display_format())) |
941 | { |
942 | } |
943 | @@ -46,22 +48,14 @@ |
944 | { |
945 | auto buffer = swapper->compositor_acquire(); |
946 | auto handle = buffer->native_buffer_handle().get(); |
947 | - buffers_in_driver[handle] = buffer; |
948 | - |
949 | + resource_cache->store_buffer(buffer, handle); |
950 | return handle; |
951 | } |
952 | |
953 | //sync object could be passed to hwc. we don't need to that yet though |
954 | void mga::ServerRenderWindow::driver_returns_buffer(ANativeWindowBuffer* returned_handle, std::shared_ptr<SyncObject> const&) |
955 | { |
956 | - auto buffer_it = buffers_in_driver.find(returned_handle); |
957 | - if (buffer_it == buffers_in_driver.end()) |
958 | - { |
959 | - BOOST_THROW_EXCEPTION(std::runtime_error("driver is returning buffers it never was given!")); |
960 | - } |
961 | - |
962 | - auto buffer = buffer_it->second; |
963 | - buffers_in_driver.erase(buffer_it); |
964 | + auto buffer = resource_cache->retrieve_buffer(returned_handle); |
965 | poster->set_next_frontbuffer(buffer); |
966 | swapper->compositor_release(buffer); |
967 | } |
968 | |
969 | === modified file 'src/server/graphics/android/server_render_window.h' |
970 | --- src/server/graphics/android/server_render_window.h 2013-05-06 15:38:52 +0000 |
971 | +++ src/server/graphics/android/server_render_window.h 2013-05-09 21:03:25 +0000 |
972 | @@ -42,11 +42,13 @@ |
973 | |
974 | class FBSwapper; |
975 | class DisplaySupportProvider; |
976 | +class InterpreterResourceCache; |
977 | class ServerRenderWindow : public AndroidDriverInterpreter |
978 | { |
979 | public: |
980 | ServerRenderWindow(std::shared_ptr<FBSwapper> const& swapper, |
981 | - std::shared_ptr<DisplaySupportProvider> const& display_poster); |
982 | + std::shared_ptr<DisplaySupportProvider> const& display_poster, |
983 | + std::shared_ptr<InterpreterResourceCache> const&); |
984 | |
985 | ANativeWindowBuffer* driver_requests_buffer(); |
986 | void driver_returns_buffer(ANativeWindowBuffer*, std::shared_ptr<SyncObject> const&); |
987 | @@ -56,8 +58,7 @@ |
988 | private: |
989 | std::shared_ptr<FBSwapper> const swapper; |
990 | std::shared_ptr<DisplaySupportProvider> const poster; |
991 | - |
992 | - std::unordered_map<ANativeWindowBuffer*, std::shared_ptr<compositor::Buffer>> buffers_in_driver; |
993 | + std::shared_ptr<InterpreterResourceCache> const resource_cache; |
994 | |
995 | int format; |
996 | }; |
997 | |
998 | === removed directory 'src/server/graphics/egl' |
999 | === removed file 'src/server/graphics/egl/CMakeLists.txt' |
1000 | --- src/server/graphics/egl/CMakeLists.txt 2013-03-27 00:11:32 +0000 |
1001 | +++ src/server/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1002 | @@ -1,10 +0,0 @@ |
1003 | -list( |
1004 | - APPEND GRAPHICS_SOURCES |
1005 | - ${CMAKE_CURRENT_SOURCE_DIR}/mesa_native_display.cpp |
1006 | -) |
1007 | - |
1008 | -set( |
1009 | - GRAPHICS_SOURCES |
1010 | - ${GRAPHICS_SOURCES} |
1011 | - PARENT_SCOPE |
1012 | -) |
1013 | \ No newline at end of file |
1014 | |
1015 | === modified file 'src/server/graphics/gbm/CMakeLists.txt' |
1016 | --- src/server/graphics/gbm/CMakeLists.txt 2013-04-30 21:38:41 +0000 |
1017 | +++ src/server/graphics/gbm/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
1018 | @@ -26,6 +26,8 @@ |
1019 | kms_output_container.cpp |
1020 | kms_page_flipper.cpp |
1021 | linux_virtual_terminal.cpp |
1022 | + internal_native_display.cpp |
1023 | + internal_client.cpp |
1024 | ) |
1025 | |
1026 | target_link_libraries( |
1027 | |
1028 | === modified file 'src/server/graphics/gbm/gbm_platform.cpp' |
1029 | --- src/server/graphics/gbm/gbm_platform.cpp 2013-04-24 05:22:20 +0000 |
1030 | +++ src/server/graphics/gbm/gbm_platform.cpp 2013-05-09 21:03:25 +0000 |
1031 | @@ -20,9 +20,10 @@ |
1032 | |
1033 | #include "gbm_buffer_allocator.h" |
1034 | #include "gbm_display.h" |
1035 | +#include "internal_client.h" |
1036 | +#include "internal_native_display.h" |
1037 | #include "linux_virtual_terminal.h" |
1038 | #include "mir/graphics/platform_ipc_package.h" |
1039 | -#include "mir/graphics/egl/mesa_native_display.h" |
1040 | |
1041 | #include <xf86drm.h> |
1042 | |
1043 | @@ -31,9 +32,7 @@ |
1044 | |
1045 | namespace mg = mir::graphics; |
1046 | namespace mgg = mg::gbm; |
1047 | -namespace mgeglm = mg::egl::mesa; |
1048 | namespace mc = mir::compositor; |
1049 | - |
1050 | namespace |
1051 | { |
1052 | |
1053 | @@ -76,15 +75,24 @@ |
1054 | |
1055 | } |
1056 | |
1057 | +std::shared_ptr<mgg::InternalNativeDisplay> mgg::GBMPlatform::internal_native_display; |
1058 | +bool mgg::GBMPlatform::internal_display_clients_present; |
1059 | mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener, |
1060 | std::shared_ptr<VirtualTerminal> const& vt) |
1061 | : listener{listener}, |
1062 | - vt{vt}, |
1063 | - native_display{0} |
1064 | + vt{vt} |
1065 | { |
1066 | drm.setup(); |
1067 | gbm.setup(drm); |
1068 | -} |
1069 | + internal_display_clients_present = false; |
1070 | +} |
1071 | + |
1072 | +mgg::GBMPlatform::~GBMPlatform() |
1073 | +{ |
1074 | + internal_native_display.reset(); |
1075 | + internal_display_clients_present = false; |
1076 | +} |
1077 | + |
1078 | |
1079 | std::shared_ptr<mc::GraphicBufferAllocator> mgg::GBMPlatform::create_buffer_allocator( |
1080 | const std::shared_ptr<mg::BufferInitializer>& buffer_initializer) |
1081 | @@ -110,13 +118,13 @@ |
1082 | drm.auth_magic(magic); |
1083 | } |
1084 | |
1085 | -EGLNativeDisplayType mgg::GBMPlatform::shell_egl_display() |
1086 | +std::shared_ptr<mg::InternalClient> mgg::GBMPlatform::create_internal_client( |
1087 | + std::shared_ptr<frontend::Surface> const& surface) |
1088 | { |
1089 | - if (native_display) |
1090 | - return reinterpret_cast<EGLNativeDisplayType>(native_display.get()); |
1091 | - native_display = mgeglm::create_native_display(this->shared_from_this()); |
1092 | - |
1093 | - return reinterpret_cast<EGLNativeDisplayType>(native_display.get()); |
1094 | + if (!internal_native_display) |
1095 | + internal_native_display = std::make_shared<mgg::InternalNativeDisplay>(get_ipc_package()); |
1096 | + internal_display_clients_present = true; |
1097 | + return std::make_shared<mgg::InternalClient>(internal_native_display, surface); |
1098 | } |
1099 | |
1100 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report) |
1101 | @@ -125,3 +133,21 @@ |
1102 | auto vt = std::make_shared<mgg::LinuxVirtualTerminal>(real_fops, report); |
1103 | return std::make_shared<mgg::GBMPlatform>(report, vt); |
1104 | } |
1105 | + |
1106 | +extern "C" |
1107 | +{ |
1108 | +int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display) |
1109 | +{ |
1110 | + return ((mgg::GBMPlatform::internal_display_clients_present) && |
1111 | + (display == mgg::GBMPlatform::internal_native_display.get())); |
1112 | +} |
1113 | + |
1114 | +/* TODO: this function is a bit fragile because libmirserver and libmirclient both have very different |
1115 | + * implementations and both have symbols for it. |
1116 | + * bug filed: lp:1177902 |
1117 | + */ |
1118 | +int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display) |
1119 | +{ |
1120 | + return mir_server_internal_display_is_valid(display); |
1121 | +} |
1122 | +} |
1123 | |
1124 | === modified file 'src/server/graphics/gbm/gbm_platform.h' |
1125 | --- src/server/graphics/gbm/gbm_platform.h 2013-04-24 05:22:20 +0000 |
1126 | +++ src/server/graphics/gbm/gbm_platform.h 2013-05-09 21:03:25 +0000 |
1127 | @@ -33,7 +33,7 @@ |
1128 | { |
1129 | |
1130 | class VirtualTerminal; |
1131 | - |
1132 | +class InternalNativeDisplay; |
1133 | class GBMPlatform : public Platform, |
1134 | public DRMAuthenticator, |
1135 | public std::enable_shared_from_this<GBMPlatform> |
1136 | @@ -41,14 +41,14 @@ |
1137 | public: |
1138 | explicit GBMPlatform(std::shared_ptr<DisplayReport> const& reporter, |
1139 | std::shared_ptr<VirtualTerminal> const& vt); |
1140 | + ~GBMPlatform(); |
1141 | |
1142 | /* From Platform */ |
1143 | std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( |
1144 | const std::shared_ptr<BufferInitializer>& buffer_initializer); |
1145 | std::shared_ptr<Display> create_display(); |
1146 | - std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
1147 | - |
1148 | - EGLNativeDisplayType shell_egl_display(); |
1149 | + std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
1150 | + std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&); |
1151 | |
1152 | /* From DRMAuthenticator */ |
1153 | void drm_auth_magic(drm_magic_t magic); |
1154 | @@ -59,8 +59,9 @@ |
1155 | std::shared_ptr<DisplayReport> const listener; |
1156 | std::shared_ptr<VirtualTerminal> const vt; |
1157 | |
1158 | -private: |
1159 | - std::shared_ptr<MirMesaEGLNativeDisplay> native_display; |
1160 | + //connection shared by all internal clients |
1161 | + static bool internal_display_clients_present; |
1162 | + static std::shared_ptr<InternalNativeDisplay> internal_native_display; |
1163 | }; |
1164 | |
1165 | } |
1166 | |
1167 | === added file 'src/server/graphics/gbm/internal_client.cpp' |
1168 | --- src/server/graphics/gbm/internal_client.cpp 1970-01-01 00:00:00 +0000 |
1169 | +++ src/server/graphics/gbm/internal_client.cpp 2013-05-09 21:03:25 +0000 |
1170 | @@ -0,0 +1,40 @@ |
1171 | +/* |
1172 | + * Copyright © 2013 Canonical Ltd. |
1173 | + * |
1174 | + * This program is free software: you can redistribute it and/or modify it |
1175 | + * under the terms of the GNU General Public License version 3, |
1176 | + * as published by the Free Software Foundation. |
1177 | + * |
1178 | + * This program is distributed in the hope that it will be useful, |
1179 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1180 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1181 | + * GNU General Public License for more details. |
1182 | + * |
1183 | + * You should have received a copy of the GNU General Public License |
1184 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1185 | + * |
1186 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1187 | + */ |
1188 | + |
1189 | +#include "internal_client.h" |
1190 | + |
1191 | +namespace mg=mir::graphics; |
1192 | +namespace mgg=mir::graphics::gbm; |
1193 | +namespace mf=mir::frontend; |
1194 | + |
1195 | +mgg::InternalClient::InternalClient(std::shared_ptr<MirMesaEGLNativeDisplay> const& native_display, |
1196 | + std::shared_ptr<mf::Surface> const& surface) |
1197 | + : native_display(native_display), |
1198 | + surface(surface) |
1199 | +{ |
1200 | +} |
1201 | + |
1202 | +EGLNativeDisplayType mgg::InternalClient::egl_native_display() |
1203 | +{ |
1204 | + return reinterpret_cast<EGLNativeDisplayType>(native_display.get()); |
1205 | +} |
1206 | + |
1207 | +EGLNativeWindowType mgg::InternalClient::egl_native_window() |
1208 | +{ |
1209 | + return reinterpret_cast<EGLNativeWindowType>(surface.get()); |
1210 | +} |
1211 | |
1212 | === added file 'src/server/graphics/gbm/internal_client.h' |
1213 | --- src/server/graphics/gbm/internal_client.h 1970-01-01 00:00:00 +0000 |
1214 | +++ src/server/graphics/gbm/internal_client.h 2013-05-09 21:03:25 +0000 |
1215 | @@ -0,0 +1,55 @@ |
1216 | +/* |
1217 | + * Copyright © 2013 Canonical Ltd. |
1218 | + * |
1219 | + * This program is free software: you can redistribute it and/or modify it |
1220 | + * under the terms of the GNU General Public License version 3, |
1221 | + * as published by the Free Software Foundation. |
1222 | + * |
1223 | + * This program is distributed in the hope that it will be useful, |
1224 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1225 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1226 | + * GNU General Public License for more details. |
1227 | + * |
1228 | + * You should have received a copy of the GNU General Public License |
1229 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1230 | + * |
1231 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1232 | + */ |
1233 | + |
1234 | +#ifndef MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_ |
1235 | +#define MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_ |
1236 | + |
1237 | +#include "mir/graphics/internal_client.h" |
1238 | +#include "internal_native_display.h" |
1239 | +#include <memory> |
1240 | + |
1241 | +namespace mir |
1242 | +{ |
1243 | +namespace frontend |
1244 | +{ |
1245 | +class Surface; |
1246 | +} |
1247 | +namespace graphics |
1248 | +{ |
1249 | +class Platform; |
1250 | +namespace gbm |
1251 | +{ |
1252 | + |
1253 | +class InternalClient : public mir::graphics::InternalClient |
1254 | +{ |
1255 | +public: |
1256 | + InternalClient(std::shared_ptr<MirMesaEGLNativeDisplay> const&, |
1257 | + std::shared_ptr<frontend::Surface> const&); |
1258 | + EGLNativeDisplayType egl_native_display(); |
1259 | + EGLNativeWindowType egl_native_window(); |
1260 | + |
1261 | +private: |
1262 | + std::shared_ptr<MirMesaEGLNativeDisplay> const native_display; |
1263 | + std::shared_ptr<frontend::Surface> const surface; |
1264 | +}; |
1265 | + |
1266 | +} |
1267 | +} |
1268 | +} |
1269 | + |
1270 | +#endif /* MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_ */ |
1271 | |
1272 | === renamed file 'src/server/graphics/egl/mesa_native_display.cpp' => 'src/server/graphics/gbm/internal_native_display.cpp' |
1273 | --- src/server/graphics/egl/mesa_native_display.cpp 2013-05-02 00:11:18 +0000 |
1274 | +++ src/server/graphics/gbm/internal_native_display.cpp 2013-05-09 21:03:25 +0000 |
1275 | @@ -16,8 +16,8 @@ |
1276 | * Authored by: Robert Carr <robert.carr@canonical.com> |
1277 | */ |
1278 | |
1279 | +#include "internal_native_display.h" |
1280 | #include "mir/display_server.h" |
1281 | -#include "mir/graphics/egl/mesa_native_display.h" |
1282 | #include "mir/graphics/platform_ipc_package.h" |
1283 | #include "mir/graphics/platform.h" |
1284 | #include "mir/frontend/surface.h" |
1285 | @@ -30,118 +30,71 @@ |
1286 | #include <set> |
1287 | |
1288 | namespace mg = mir::graphics; |
1289 | -namespace mgeglm = mg::egl::mesa; |
1290 | +namespace mgg = mir::graphics::gbm; |
1291 | namespace mf = mir::frontend; |
1292 | |
1293 | -std::mutex valid_displays_guard; |
1294 | -std::set<MirMesaEGLNativeDisplay*> valid_displays; |
1295 | - |
1296 | -namespace |
1297 | -{ |
1298 | -struct ShellMesaEGLNativeDisplay : MirMesaEGLNativeDisplay |
1299 | -{ |
1300 | -public: |
1301 | - ShellMesaEGLNativeDisplay(std::shared_ptr<mg::Platform> const& graphics_platform) |
1302 | - : graphics_platform(graphics_platform) |
1303 | - { |
1304 | - context = this; |
1305 | - this->display_get_platform = &ShellMesaEGLNativeDisplay::native_display_get_platform; |
1306 | - this->surface_get_current_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_get_current_buffer; |
1307 | - this->surface_get_parameters = &ShellMesaEGLNativeDisplay::native_display_surface_get_parameters; |
1308 | - this->surface_advance_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_advance_buffer; |
1309 | - } |
1310 | - |
1311 | - static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package) |
1312 | - { |
1313 | - auto native_disp = static_cast<ShellMesaEGLNativeDisplay*>(display); |
1314 | - if (!native_disp->platform_package) |
1315 | - native_disp->platform_package = native_disp->graphics_platform->get_ipc_package(); |
1316 | - package->data_items = native_disp->platform_package->ipc_data.size(); |
1317 | - for (int i = 0; i < package->data_items; i++) |
1318 | - { |
1319 | - package->data[i] = native_disp->platform_package->ipc_data[i]; |
1320 | - } |
1321 | - package->fd_items = native_disp->platform_package->ipc_fds.size(); |
1322 | - for (int i = 0; i < package->fd_items; i++) |
1323 | - { |
1324 | - package->fd[i] = native_disp->platform_package->ipc_fds[i]; |
1325 | - } |
1326 | - |
1327 | - } |
1328 | - |
1329 | - static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
1330 | - MirEGLNativeWindowType surface, |
1331 | - MirBufferPackage* package) |
1332 | - { |
1333 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
1334 | - |
1335 | - auto buffer = mir_surface->client_buffer(); |
1336 | - auto buffer_package = buffer->get_ipc_package(); |
1337 | - package->data_items = buffer_package->ipc_data.size(); |
1338 | - for (int i = 0; i < package->data_items; i++) |
1339 | - { |
1340 | - package->data[i] = buffer_package->ipc_data[i]; |
1341 | - } |
1342 | - package->fd_items = buffer_package->ipc_fds.size(); |
1343 | - for (int i = 0; i < package->fd_items; i++) |
1344 | - { |
1345 | - package->fd[i] = buffer_package->ipc_fds[i]; |
1346 | - } |
1347 | - package->stride = buffer_package->stride; |
1348 | - } |
1349 | - |
1350 | - static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */, |
1351 | +mgg::InternalNativeDisplay::InternalNativeDisplay(std::shared_ptr<mg::PlatformIPCPackage> const& platform_package) |
1352 | + : platform_package(platform_package) |
1353 | +{ |
1354 | + context = this; |
1355 | + this->display_get_platform = &InternalNativeDisplay::native_display_get_platform; |
1356 | + this->surface_get_current_buffer = &InternalNativeDisplay::native_display_surface_get_current_buffer; |
1357 | + this->surface_get_parameters = &InternalNativeDisplay::native_display_surface_get_parameters; |
1358 | + this->surface_advance_buffer = &InternalNativeDisplay::native_display_surface_advance_buffer; |
1359 | +} |
1360 | + |
1361 | +void mgg::InternalNativeDisplay::native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package) |
1362 | +{ |
1363 | + auto native_disp = static_cast<InternalNativeDisplay*>(display); |
1364 | + package->data_items = native_disp->platform_package->ipc_data.size(); |
1365 | + for (int i = 0; i < package->data_items; i++) |
1366 | + { |
1367 | + package->data[i] = native_disp->platform_package->ipc_data[i]; |
1368 | + } |
1369 | + package->fd_items = native_disp->platform_package->ipc_fds.size(); |
1370 | + for (int i = 0; i < package->fd_items; i++) |
1371 | + { |
1372 | + package->fd[i] = native_disp->platform_package->ipc_fds[i]; |
1373 | + } |
1374 | + |
1375 | +} |
1376 | + |
1377 | +void mgg::InternalNativeDisplay::native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay*, |
1378 | MirEGLNativeWindowType surface, |
1379 | - MirSurfaceParameters* parameters) |
1380 | - { |
1381 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
1382 | - |
1383 | - parameters->width = mir_surface->size().width.as_uint32_t(); |
1384 | - parameters->height = mir_surface->size().height.as_uint32_t(); |
1385 | - parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format()); |
1386 | - parameters->buffer_usage = mir_buffer_usage_hardware; |
1387 | - } |
1388 | - |
1389 | - static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, |
1390 | - MirEGLNativeWindowType surface) |
1391 | - { |
1392 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
1393 | - mir_surface->advance_client_buffer(); |
1394 | - } |
1395 | - |
1396 | -private: |
1397 | - std::shared_ptr<mg::Platform> graphics_platform; |
1398 | - std::shared_ptr<mg::PlatformIPCPackage> platform_package; |
1399 | -}; |
1400 | - |
1401 | -struct NativeDisplayDeleter |
1402 | -{ |
1403 | - void operator()(MirMesaEGLNativeDisplay* display) |
1404 | - { |
1405 | - std::unique_lock<std::mutex> lg(valid_displays_guard); |
1406 | - valid_displays.erase(display); |
1407 | - auto disp = static_cast<ShellMesaEGLNativeDisplay*>(display->context); |
1408 | - delete disp; |
1409 | - } |
1410 | -}; |
1411 | - |
1412 | -} |
1413 | - |
1414 | -extern "C" |
1415 | -{ |
1416 | -int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display) |
1417 | -{ |
1418 | - std::unique_lock<std::mutex> lg(valid_displays_guard); |
1419 | - return valid_displays.find(display) != valid_displays.end(); |
1420 | -} |
1421 | -} |
1422 | - |
1423 | -std::shared_ptr<MirMesaEGLNativeDisplay> mgeglm::create_native_display(std::shared_ptr<mg::Platform> const& platform) |
1424 | -{ |
1425 | - auto native_display = std::shared_ptr<ShellMesaEGLNativeDisplay>(new ShellMesaEGLNativeDisplay(platform), |
1426 | - NativeDisplayDeleter()); |
1427 | - std::unique_lock<std::mutex> lg(valid_displays_guard); |
1428 | - valid_displays.insert(native_display.get()); |
1429 | - |
1430 | - return native_display; |
1431 | + MirBufferPackage* package) |
1432 | +{ |
1433 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
1434 | + |
1435 | + auto buffer = mir_surface->client_buffer(); |
1436 | + auto buffer_package = buffer->get_ipc_package(); |
1437 | + package->data_items = buffer_package->ipc_data.size(); |
1438 | + for (int i = 0; i < package->data_items; i++) |
1439 | + { |
1440 | + package->data[i] = buffer_package->ipc_data[i]; |
1441 | + } |
1442 | + package->fd_items = buffer_package->ipc_fds.size(); |
1443 | + for (int i = 0; i < package->fd_items; i++) |
1444 | + { |
1445 | + package->fd[i] = buffer_package->ipc_fds[i]; |
1446 | + } |
1447 | + package->stride = buffer_package->stride; |
1448 | +} |
1449 | + |
1450 | +void mgg::InternalNativeDisplay::native_display_surface_get_parameters(MirMesaEGLNativeDisplay*, |
1451 | + MirEGLNativeWindowType surface, |
1452 | + MirSurfaceParameters* parameters) |
1453 | +{ |
1454 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
1455 | + |
1456 | + parameters->width = mir_surface->size().width.as_uint32_t(); |
1457 | + parameters->height = mir_surface->size().height.as_uint32_t(); |
1458 | + parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format()); |
1459 | + parameters->buffer_usage = mir_buffer_usage_hardware; |
1460 | +} |
1461 | + |
1462 | +void mgg::InternalNativeDisplay::native_display_surface_advance_buffer(MirMesaEGLNativeDisplay*, |
1463 | + MirEGLNativeWindowType surface) |
1464 | +{ |
1465 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
1466 | + mir_surface->advance_client_buffer(); |
1467 | } |
1468 | |
1469 | === added file 'src/server/graphics/gbm/internal_native_display.h' |
1470 | --- src/server/graphics/gbm/internal_native_display.h 1970-01-01 00:00:00 +0000 |
1471 | +++ src/server/graphics/gbm/internal_native_display.h 2013-05-09 21:03:25 +0000 |
1472 | @@ -0,0 +1,56 @@ |
1473 | + |
1474 | +/* |
1475 | + * Copyright © 2013 Canonical Ltd. |
1476 | + * |
1477 | + * This program is free software: you can redistribute it and/or modify it |
1478 | + * under the terms of the GNU General Public License version 3, |
1479 | + * as published by the Free Software Foundation. |
1480 | + * |
1481 | + * This program is distributed in the hope that it will be useful, |
1482 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1483 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1484 | + * GNU General Public License for more details. |
1485 | + * |
1486 | + * You should have received a copy of the GNU General Public License |
1487 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1488 | + * |
1489 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1490 | + * Kevin DuBois <kevin.dubois@canonical.com> |
1491 | + */ |
1492 | + |
1493 | +#ifndef MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_ |
1494 | +#define MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_ |
1495 | + |
1496 | +#include "mir_toolkit/mesa/native_display.h" |
1497 | +#include <memory> |
1498 | + |
1499 | +namespace mir |
1500 | +{ |
1501 | +namespace graphics |
1502 | +{ |
1503 | +struct PlatformIPCPackage; |
1504 | +namespace gbm |
1505 | +{ |
1506 | + |
1507 | +class InternalNativeDisplay : public MirMesaEGLNativeDisplay |
1508 | +{ |
1509 | +public: |
1510 | + InternalNativeDisplay(std::shared_ptr<PlatformIPCPackage> const& platform_package); |
1511 | + |
1512 | + static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package); |
1513 | + static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
1514 | + MirEGLNativeWindowType surface, |
1515 | + MirBufferPackage* package); |
1516 | + static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */, |
1517 | + MirEGLNativeWindowType surface, |
1518 | + MirSurfaceParameters* parameters); |
1519 | + static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, |
1520 | + MirEGLNativeWindowType surface); |
1521 | +private: |
1522 | + std::shared_ptr<PlatformIPCPackage> platform_package; |
1523 | +}; |
1524 | + |
1525 | +} |
1526 | +} |
1527 | +} |
1528 | +#endif /* MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_ */ |
1529 | |
1530 | === modified file 'tests/integration-tests/graphics/android/CMakeLists.txt' |
1531 | --- tests/integration-tests/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000 |
1532 | +++ tests/integration-tests/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
1533 | @@ -2,6 +2,7 @@ |
1534 | APPEND INTEGRATION_TESTS_SRCS |
1535 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_integration.cpp |
1536 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_integration.cpp |
1537 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp |
1538 | ) |
1539 | |
1540 | set( |
1541 | |
1542 | === added file 'tests/integration-tests/graphics/android/test_internal_client.cpp' |
1543 | --- tests/integration-tests/graphics/android/test_internal_client.cpp 1970-01-01 00:00:00 +0000 |
1544 | +++ tests/integration-tests/graphics/android/test_internal_client.cpp 2013-05-09 21:03:25 +0000 |
1545 | @@ -0,0 +1,132 @@ |
1546 | +/* |
1547 | + * Copyright © 2013 Canonical Ltd. |
1548 | + * |
1549 | + * This program is free software: you can redistribute it and/or modify |
1550 | + * it under the terms of the GNU General Public License version 3 as |
1551 | + * published by the Free Software Foundation. |
1552 | + * |
1553 | + * This program is distributed in the hope that it will be useful, |
1554 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1555 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1556 | + * GNU General Public License for more details. |
1557 | + * |
1558 | + * You should have received a copy of the GNU General Public License |
1559 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1560 | + * |
1561 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1562 | + */ |
1563 | + |
1564 | +#include "src/server/graphics/android/android_graphic_buffer_allocator.h" |
1565 | +#include "src/server/graphics/android/internal_client_window.h" |
1566 | +#include "src/server/graphics/android/interpreter_cache.h" |
1567 | +#include "mir/compositor/swapper_factory.h" |
1568 | +#include "mir/compositor/buffer_swapper.h" |
1569 | +#include "mir/compositor/buffer_bundle_manager.h" |
1570 | +#include "mir/graphics/buffer_initializer.h" |
1571 | +#include "mir/graphics/null_display_report.h" |
1572 | +#include "mir/graphics/android/mir_native_window.h" |
1573 | +#include "mir/graphics/platform.h" |
1574 | +#include "mir/graphics/internal_client.h" |
1575 | +#include "mir/surfaces/surface_stack.h" |
1576 | +#include "mir/surfaces/surface_controller.h" |
1577 | +#include "mir/shell/surface_source.h" |
1578 | +#include "mir/shell/surface.h" |
1579 | +#include "mir/frontend/surface_creation_parameters.h" |
1580 | +#include "mir/frontend/surface_id.h" |
1581 | +#include "mir/input/input_channel_factory.h" |
1582 | + |
1583 | +#include <EGL/egl.h> |
1584 | +#include <gtest/gtest.h> |
1585 | + |
1586 | +#include <GLES2/gl2.h> |
1587 | + |
1588 | + |
1589 | +namespace mg=mir::graphics; |
1590 | +namespace mga=mir::graphics::android; |
1591 | +namespace mc=mir::compositor; |
1592 | +namespace geom=mir::geometry; |
1593 | +namespace ms=mir::surfaces; |
1594 | +namespace msh=mir::shell; |
1595 | +namespace mf=mir::frontend; |
1596 | +namespace mi=mir::input; |
1597 | + |
1598 | +namespace |
1599 | +{ |
1600 | +class AndroidInternalClient : public ::testing::Test |
1601 | +{ |
1602 | +protected: |
1603 | + virtual void SetUp() |
1604 | + { |
1605 | + } |
1606 | +}; |
1607 | + |
1608 | +struct StubInputFactory : public mi::InputChannelFactory |
1609 | +{ |
1610 | + std::shared_ptr<mi::InputChannel> make_input_channel() |
1611 | + { |
1612 | + return std::shared_ptr<mi::InputChannel>(); |
1613 | + } |
1614 | +}; |
1615 | +} |
1616 | + |
1617 | +TEST_F(AndroidInternalClient, internal_client_creation_and_use) |
1618 | +{ |
1619 | + auto size = geom::Size{geom::Width{334}, |
1620 | + geom::Height{122}}; |
1621 | + auto pf = geom::PixelFormat::abgr_8888; |
1622 | + mf::SurfaceCreationParameters params; |
1623 | + params.name = std::string("test"); |
1624 | + params.size = size; |
1625 | + params.pixel_format = pf; |
1626 | + params.buffer_usage = mc::BufferUsage::hardware; |
1627 | + auto id = mf::SurfaceId{4458}; |
1628 | + |
1629 | + auto stub_input_factory = std::make_shared<StubInputFactory>(); |
1630 | + auto null_buffer_initializer = std::make_shared<mg::NullBufferInitializer>(); |
1631 | + auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer); |
1632 | + auto strategy = std::make_shared<mc::SwapperFactory>(allocator); |
1633 | + auto buffer_bundle_factory = std::make_shared<mc::BufferBundleManager>(strategy); |
1634 | + auto ss = std::make_shared<ms::SurfaceStack>(buffer_bundle_factory); |
1635 | + auto surface_controller = std::make_shared<ms::SurfaceController>(ss); |
1636 | + auto surface_source = std::make_shared<msh::SurfaceSource>(surface_controller, stub_input_factory); |
1637 | + auto mir_surface = surface_source->create_surface(params, id, std::shared_ptr<mir::events::EventSink>()); |
1638 | + |
1639 | + auto report = std::shared_ptr<mg::NullDisplayReport>(); |
1640 | + auto platform = mg::create_platform(report); |
1641 | + auto internal_client = platform->create_internal_client(mir_surface); |
1642 | + |
1643 | + int major, minor, n; |
1644 | + EGLContext egl_context; |
1645 | + EGLSurface egl_surface; |
1646 | + EGLConfig egl_config; |
1647 | + EGLint attribs[] = { |
1648 | + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
1649 | + EGL_RED_SIZE, 8, |
1650 | + EGL_GREEN_SIZE, 8, |
1651 | + EGL_BLUE_SIZE, 8, |
1652 | + EGL_ALPHA_SIZE, 8, |
1653 | + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
1654 | + EGL_NONE }; |
1655 | + EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; |
1656 | + |
1657 | + auto egl_display = eglGetDisplay(internal_client->egl_native_display()); |
1658 | + int rc = eglInitialize(egl_display, &major, &minor); |
1659 | + EXPECT_EQ(EGL_TRUE, rc); |
1660 | + |
1661 | + rc = eglChooseConfig(egl_display, attribs, &egl_config, 1, &n); |
1662 | + EXPECT_EQ(EGL_TRUE, rc); |
1663 | + |
1664 | + egl_surface = eglCreateWindowSurface(egl_display, egl_config, internal_client->egl_native_window(), NULL); |
1665 | + EXPECT_NE(EGL_NO_SURFACE, egl_surface); |
1666 | + |
1667 | + egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attribs); |
1668 | + EXPECT_NE(EGL_NO_CONTEXT, egl_context); |
1669 | + |
1670 | + rc = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); |
1671 | + EXPECT_EQ(EGL_TRUE, rc); |
1672 | + |
1673 | + glClearColor(1.0f, 0.0, 0.0, 1.0); |
1674 | + glClear(GL_COLOR_BUFFER_BIT); |
1675 | + rc = eglSwapBuffers(egl_display, egl_surface); |
1676 | + EXPECT_EQ(EGL_TRUE, rc); |
1677 | +} |
1678 | |
1679 | === modified file 'tests/integration-tests/graphics/gbm/test_buffer_integration.cpp' |
1680 | --- tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-04-24 05:22:20 +0000 |
1681 | +++ tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-05-09 21:03:25 +0000 |
1682 | @@ -100,9 +100,9 @@ |
1683 | return std::shared_ptr<mg::PlatformIPCPackage>(); |
1684 | } |
1685 | |
1686 | - EGLNativeDisplayType shell_egl_display() |
1687 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mir::frontend::Surface> const&) |
1688 | { |
1689 | - return static_cast<EGLNativeDisplayType>(0); |
1690 | + return std::shared_ptr<mg::InternalClient>(); |
1691 | } |
1692 | }; |
1693 | |
1694 | |
1695 | === modified file 'tests/integration-tests/test_display_info.cpp' |
1696 | --- tests/integration-tests/test_display_info.cpp 2013-04-24 05:22:20 +0000 |
1697 | +++ tests/integration-tests/test_display_info.cpp 2013-05-09 21:03:25 +0000 |
1698 | @@ -34,6 +34,7 @@ |
1699 | namespace mg = mir::graphics; |
1700 | namespace mc = mir::compositor; |
1701 | namespace geom = mir::geometry; |
1702 | +namespace mf = mir::frontend; |
1703 | namespace mtf = mir_test_framework; |
1704 | namespace mtd = mir::test::doubles; |
1705 | |
1706 | @@ -103,10 +104,11 @@ |
1707 | { |
1708 | return std::make_shared<mg::PlatformIPCPackage>(); |
1709 | } |
1710 | - EGLNativeDisplayType shell_egl_display() |
1711 | + |
1712 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&) |
1713 | { |
1714 | - return static_cast<EGLNativeDisplayType>(0); |
1715 | - } |
1716 | + return std::shared_ptr<mg::InternalClient>(); |
1717 | + } |
1718 | }; |
1719 | |
1720 | void connection_callback(MirConnection* connection, void* context) |
1721 | |
1722 | === modified file 'tests/integration-tests/test_drm_auth_magic.cpp' |
1723 | --- tests/integration-tests/test_drm_auth_magic.cpp 2013-04-24 05:22:20 +0000 |
1724 | +++ tests/integration-tests/test_drm_auth_magic.cpp 2013-05-09 21:03:25 +0000 |
1725 | @@ -80,9 +80,9 @@ |
1726 | return std::make_shared<mg::PlatformIPCPackage>(); |
1727 | } |
1728 | |
1729 | - EGLNativeDisplayType shell_egl_display() |
1730 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mir::frontend::Surface> const&) |
1731 | { |
1732 | - return static_cast<EGLNativeDisplayType>(0); |
1733 | + return std::shared_ptr<mg::InternalClient>(); |
1734 | } |
1735 | |
1736 | MOCK_METHOD1(drm_auth_magic, void(unsigned int)); |
1737 | |
1738 | === modified file 'tests/integration-tests/test_surfaceloop.cpp' |
1739 | --- tests/integration-tests/test_surfaceloop.cpp 2013-05-01 21:55:49 +0000 |
1740 | +++ tests/integration-tests/test_surfaceloop.cpp 2013-05-09 21:03:25 +0000 |
1741 | @@ -42,6 +42,7 @@ |
1742 | namespace mc = mir::compositor; |
1743 | namespace mg = mir::graphics; |
1744 | namespace geom = mir::geometry; |
1745 | +namespace mf = mir::frontend; |
1746 | namespace mtf = mir_test_framework; |
1747 | namespace mtd = mir::test::doubles; |
1748 | |
1749 | @@ -355,10 +356,10 @@ |
1750 | return std::make_shared<mg::PlatformIPCPackage>(); |
1751 | } |
1752 | |
1753 | - EGLNativeDisplayType shell_egl_display() |
1754 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&) |
1755 | { |
1756 | - return static_cast<EGLNativeDisplayType>(0); |
1757 | - } |
1758 | + return std::shared_ptr<mg::InternalClient>(); |
1759 | + } |
1760 | }; |
1761 | |
1762 | std::shared_ptr<mg::Platform> the_graphics_platform() |
1763 | @@ -487,9 +488,9 @@ |
1764 | return std::make_shared<mg::PlatformIPCPackage>(); |
1765 | } |
1766 | |
1767 | - EGLNativeDisplayType shell_egl_display() |
1768 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&) |
1769 | { |
1770 | - return (EGLNativeDisplayType) 0; |
1771 | + return std::shared_ptr<mg::InternalClient>(); |
1772 | } |
1773 | }; |
1774 | |
1775 | |
1776 | === modified file 'tests/mir_test_framework/testing_server_options.cpp' |
1777 | --- tests/mir_test_framework/testing_server_options.cpp 2013-05-02 04:17:41 +0000 |
1778 | +++ tests/mir_test_framework/testing_server_options.cpp 2013-05-09 21:03:25 +0000 |
1779 | @@ -119,9 +119,9 @@ |
1780 | return std::make_shared<mg::PlatformIPCPackage>(); |
1781 | } |
1782 | |
1783 | - EGLNativeDisplayType shell_egl_display() |
1784 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&) |
1785 | { |
1786 | - return (EGLNativeDisplayType) 0; |
1787 | + return std::shared_ptr<mg::InternalClient>(); |
1788 | } |
1789 | }; |
1790 | |
1791 | |
1792 | === modified file 'tests/unit-tests/client/gbm/test_gbm_client_platform.cpp' |
1793 | --- tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-04-24 05:22:20 +0000 |
1794 | +++ tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-05-09 21:03:25 +0000 |
1795 | @@ -40,6 +40,10 @@ |
1796 | EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(&surface), *native_window); |
1797 | } |
1798 | |
1799 | +/* TODO: mir_egl_mesa_display_is_valid is a bit fragile because libmirserver and libmirclient both have very |
1800 | + * different implementations and both have symbols for it. If the linking order of the test changes, |
1801 | + * specifically, if mir_egl_mesa_display_is_valid resolves into libmirserver, then this test will break. |
1802 | + */ |
1803 | TEST(GBMClientPlatformTest, egl_native_display_is_valid_until_released) |
1804 | { |
1805 | mtd::MockClientContext context; |
1806 | |
1807 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
1808 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-25 09:48:54 +0000 |
1809 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-05-09 21:03:25 +0000 |
1810 | @@ -33,6 +33,7 @@ |
1811 | #include "mir_test_doubles/mock_buffer.h" |
1812 | #include "mir_test_doubles/stub_session.h" |
1813 | #include "mir_test_doubles/stub_surface_builder.h" |
1814 | +#include "mir_test_doubles/stub_platform.h" |
1815 | #include "mir_test/fake_shared.h" |
1816 | #include "mir/events/event_sink.h" |
1817 | #include "mir/shell/surface.h" |
1818 | @@ -104,31 +105,6 @@ |
1819 | MOCK_METHOD0(supported_pixel_formats, std::vector<geom::PixelFormat>()); |
1820 | }; |
1821 | |
1822 | -class StubPlatform : public mg::Platform |
1823 | -{ |
1824 | - public: |
1825 | - std::shared_ptr<mc::GraphicBufferAllocator> create_buffer_allocator( |
1826 | - const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) |
1827 | - { |
1828 | - return std::shared_ptr<mc::GraphicBufferAllocator>(); |
1829 | - } |
1830 | - |
1831 | - std::shared_ptr<mg::Display> create_display() |
1832 | - { |
1833 | - return std::make_shared<mtd::NullDisplay>(); |
1834 | - } |
1835 | - |
1836 | - std::shared_ptr<mg::PlatformIPCPackage> get_ipc_package() |
1837 | - { |
1838 | - return std::make_shared<mg::PlatformIPCPackage>(); |
1839 | - } |
1840 | - |
1841 | - EGLNativeDisplayType shell_egl_display() |
1842 | - { |
1843 | - return static_cast<EGLNativeDisplayType>(0); |
1844 | - } |
1845 | -}; |
1846 | - |
1847 | class NullEventSink : public mir::events::EventSink |
1848 | { |
1849 | public: |
1850 | @@ -139,7 +115,7 @@ |
1851 | { |
1852 | SessionMediatorTest() |
1853 | : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()}, |
1854 | - graphics_platform{std::make_shared<StubPlatform>()}, |
1855 | + graphics_platform{std::make_shared<mtd::StubPlatform>()}, |
1856 | graphics_display{std::make_shared<mtd::NullDisplay>()}, |
1857 | buffer_allocator{std::make_shared<testing::NiceMock<MockGraphicBufferAllocator>>()}, |
1858 | report{std::make_shared<mf::NullSessionMediatorReport>()}, |
1859 | |
1860 | === modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' |
1861 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-25 09:48:54 +0000 |
1862 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-05-09 21:03:25 +0000 |
1863 | @@ -30,6 +30,7 @@ |
1864 | #include "mir_test_doubles/null_display.h" |
1865 | #include "mir_test_doubles/mock_session.h" |
1866 | #include "mir_test_doubles/stub_shell.h" |
1867 | +#include "mir_test_doubles/stub_platform.h" |
1868 | |
1869 | #include "mir/events/event_sink.h" |
1870 | |
1871 | @@ -62,31 +63,6 @@ |
1872 | } |
1873 | }; |
1874 | |
1875 | -class StubPlatform : public mg::Platform |
1876 | -{ |
1877 | - public: |
1878 | - std::shared_ptr<mc::GraphicBufferAllocator> create_buffer_allocator( |
1879 | - const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) |
1880 | - { |
1881 | - return std::shared_ptr<mc::GraphicBufferAllocator>(); |
1882 | - } |
1883 | - |
1884 | - std::shared_ptr<mg::Display> create_display() |
1885 | - { |
1886 | - return std::make_shared<mtd::NullDisplay>(); |
1887 | - } |
1888 | - |
1889 | - std::shared_ptr<mg::PlatformIPCPackage> get_ipc_package() |
1890 | - { |
1891 | - return std::make_shared<mg::PlatformIPCPackage>(); |
1892 | - } |
1893 | - |
1894 | - EGLNativeDisplayType shell_egl_display() |
1895 | - { |
1896 | - return static_cast<EGLNativeDisplayType>(0); |
1897 | - } |
1898 | -}; |
1899 | - |
1900 | class NullEventSink : public mir::events::EventSink |
1901 | { |
1902 | public: |
1903 | @@ -97,7 +73,7 @@ |
1904 | { |
1905 | SessionMediatorAndroidTest() |
1906 | : shell{std::make_shared<mtd::StubShell>()}, |
1907 | - graphics_platform{std::make_shared<StubPlatform>()}, |
1908 | + graphics_platform{std::make_shared<mtd::StubPlatform>()}, |
1909 | graphics_display{std::make_shared<mtd::NullDisplay>()}, |
1910 | buffer_allocator{std::make_shared<StubGraphicBufferAllocator>()}, |
1911 | report{std::make_shared<mf::NullSessionMediatorReport>()}, |
1912 | @@ -111,7 +87,7 @@ |
1913 | } |
1914 | |
1915 | std::shared_ptr<mtd::StubShell> const shell; |
1916 | - std::shared_ptr<StubPlatform> const graphics_platform; |
1917 | + std::shared_ptr<mtd::StubPlatform> const graphics_platform; |
1918 | std::shared_ptr<mg::Display> const graphics_display; |
1919 | std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator; |
1920 | std::shared_ptr<mf::SessionMediatorReport> const report; |
1921 | |
1922 | === modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp' |
1923 | --- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-25 09:48:54 +0000 |
1924 | +++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-05-09 21:03:25 +0000 |
1925 | @@ -83,9 +83,9 @@ |
1926 | return std::make_shared<mg::PlatformIPCPackage>(); |
1927 | } |
1928 | |
1929 | - EGLNativeDisplayType shell_egl_display() |
1930 | + std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&) |
1931 | { |
1932 | - return static_cast<EGLNativeDisplayType>(0); |
1933 | + return std::shared_ptr<mg::InternalClient>(); |
1934 | } |
1935 | |
1936 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); |
1937 | |
1938 | === modified file 'tests/unit-tests/graphics/CMakeLists.txt' |
1939 | --- tests/unit-tests/graphics/CMakeLists.txt 2013-04-24 05:22:20 +0000 |
1940 | +++ tests/unit-tests/graphics/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
1941 | @@ -11,7 +11,6 @@ |
1942 | |
1943 | if (MIR_PLATFORM STREQUAL "gbm") |
1944 | add_subdirectory(gbm/) |
1945 | -add_subdirectory(egl) |
1946 | endif() |
1947 | |
1948 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
1949 | |
1950 | === modified file 'tests/unit-tests/graphics/android/CMakeLists.txt' |
1951 | --- tests/unit-tests/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000 |
1952 | +++ tests/unit-tests/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
1953 | @@ -8,17 +8,20 @@ |
1954 | ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor.cpp |
1955 | ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor_native_win.cpp |
1956 | ${CMAKE_CURRENT_SOURCE_DIR}/test_android_buffer_allocator.cpp |
1957 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_gpu_display.cpp |
1958 | ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_device.cpp |
1959 | ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc10_device.cpp |
1960 | ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc11_device.cpp |
1961 | ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_display.cpp |
1962 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_gpu_display.cpp |
1963 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client_interpreter.cpp |
1964 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp |
1965 | ${CMAKE_CURRENT_SOURCE_DIR}/test_framebuffer_factory.cpp |
1966 | ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp |
1967 | ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp |
1968 | ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_layerlist.cpp |
1969 | ${CMAKE_CURRENT_SOURCE_DIR}/test_server_interpreter.cpp |
1970 | ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format.cpp |
1971 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_interpreter_buffer_cache.cpp |
1972 | ) |
1973 | |
1974 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
1975 | |
1976 | === added file 'tests/unit-tests/graphics/android/test_internal_client.cpp' |
1977 | --- tests/unit-tests/graphics/android/test_internal_client.cpp 1970-01-01 00:00:00 +0000 |
1978 | +++ tests/unit-tests/graphics/android/test_internal_client.cpp 2013-05-09 21:03:25 +0000 |
1979 | @@ -0,0 +1,87 @@ |
1980 | +/* |
1981 | + * Copyright © 2013 Canonical Ltd. |
1982 | + * |
1983 | + * This program is free software: you can redistribute it and/or modify |
1984 | + * it under the terms of the GNU General Public License version 3 as |
1985 | + * published by the Free Software Foundation. |
1986 | + * |
1987 | + * This program is distributed in the hope that it will be useful, |
1988 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1989 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1990 | + * GNU General Public License for more details. |
1991 | + * |
1992 | + * You should have received a copy of the GNU General Public License |
1993 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1994 | + * |
1995 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1996 | + */ |
1997 | + |
1998 | +#include "mir/frontend/surface.h" |
1999 | +#include "src/server/graphics/android/internal_client.h" |
2000 | +#include <system/window.h> |
2001 | +#include <gtest/gtest.h> |
2002 | + |
2003 | +namespace geom=mir::geometry; |
2004 | +namespace mc=mir::compositor; |
2005 | +namespace mga=mir::graphics::android; |
2006 | + |
2007 | +namespace |
2008 | +{ |
2009 | +class StubSurface : public mir::frontend::Surface |
2010 | +{ |
2011 | + void destroy() |
2012 | + { |
2013 | + } |
2014 | + void force_requests_to_complete() |
2015 | + { |
2016 | + } |
2017 | + geom::Size size() const |
2018 | + { |
2019 | + return geom::Size{geom::Width{4},geom::Height{2}}; |
2020 | + } |
2021 | + geom::PixelFormat pixel_format() const |
2022 | + { |
2023 | + return geom::PixelFormat::xbgr_8888; |
2024 | + } |
2025 | + void advance_client_buffer() |
2026 | + { |
2027 | + } |
2028 | + std::shared_ptr<mc::Buffer> client_buffer() const |
2029 | + { |
2030 | + return std::shared_ptr<mc::Buffer>(); |
2031 | + } |
2032 | + bool supports_input() const |
2033 | + { |
2034 | + return false; |
2035 | + } |
2036 | + int client_input_fd() const |
2037 | + { |
2038 | + return 5; |
2039 | + } |
2040 | + int configure(MirSurfaceAttrib, int) |
2041 | + { |
2042 | + return 218181; |
2043 | + } |
2044 | +}; |
2045 | +} |
2046 | + |
2047 | +TEST(InternalClient, native_display) |
2048 | +{ |
2049 | + auto surface = std::make_shared<StubSurface>(); |
2050 | + mga::InternalClient client(surface); |
2051 | + EXPECT_EQ(EGL_DEFAULT_DISPLAY, client.egl_native_display()); |
2052 | +} |
2053 | + |
2054 | +TEST(InternalClient, native_window) |
2055 | +{ |
2056 | + auto surface = std::make_shared<StubSurface>(); |
2057 | + mga::InternalClient client(surface); |
2058 | + ANativeWindow* native_window = static_cast<ANativeWindow*>(client.egl_native_window()); |
2059 | + |
2060 | + /* check for basic window sanity */ |
2061 | + ASSERT_NE(nullptr, native_window); |
2062 | + EXPECT_NE(nullptr, native_window->queueBuffer); |
2063 | + EXPECT_NE(nullptr, native_window->dequeueBuffer); |
2064 | + EXPECT_NE(nullptr, native_window->query); |
2065 | + EXPECT_NE(nullptr, native_window->perform); |
2066 | +} |
2067 | |
2068 | === added file 'tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp' |
2069 | --- tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 1970-01-01 00:00:00 +0000 |
2070 | +++ tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 2013-05-09 21:03:25 +0000 |
2071 | @@ -0,0 +1,149 @@ |
2072 | +/* |
2073 | + * Copyright © 2013 Canonical Ltd. |
2074 | + * |
2075 | + * This program is free software: you can redistribute it and/or modify |
2076 | + * it under the terms of the GNU General Public License version 3 as |
2077 | + * published by the Free Software Foundation. |
2078 | + * |
2079 | + * This program is distributed in the hope that it will be useful, |
2080 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2081 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2082 | + * GNU General Public License for more details. |
2083 | + * |
2084 | + * You should have received a copy of the GNU General Public License |
2085 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2086 | + * |
2087 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
2088 | + */ |
2089 | + |
2090 | +#include "src/server/graphics/android/internal_client_window.h" |
2091 | +#include "mir_test_doubles/mock_buffer.h" |
2092 | +#include "mir_test_doubles/mock_swapper.h" |
2093 | +#include "mir_test_doubles/mock_interpreter_resource_cache.h" |
2094 | +#include "mir/frontend/surface.h" |
2095 | + |
2096 | +#include <gtest/gtest.h> |
2097 | +#include <stdexcept> |
2098 | + |
2099 | +namespace mc=mir::compositor; |
2100 | +namespace mtd=mir::test::doubles; |
2101 | +namespace mga=mir::graphics::android; |
2102 | +namespace geom=mir::geometry; |
2103 | +namespace mf=mir::frontend; |
2104 | + |
2105 | +namespace |
2106 | +{ |
2107 | +struct MockSurface : public mf::Surface |
2108 | +{ |
2109 | + MOCK_METHOD0(destroy, void()); |
2110 | + MOCK_METHOD0(force_requests_to_complete, void()); |
2111 | + MOCK_CONST_METHOD0(size, geom::Size()); |
2112 | + MOCK_CONST_METHOD0(pixel_format, geom::PixelFormat()); |
2113 | + |
2114 | + MOCK_METHOD0(advance_client_buffer, void()); |
2115 | + MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer>()); |
2116 | + |
2117 | + MOCK_CONST_METHOD0(supports_input, bool()); |
2118 | + MOCK_CONST_METHOD0(client_input_fd, int()); |
2119 | + MOCK_METHOD2(configure, int(MirSurfaceAttrib, int)); |
2120 | +}; |
2121 | + |
2122 | +struct InternalClientWindow : public ::testing::Test |
2123 | +{ |
2124 | + void SetUp() |
2125 | + { |
2126 | + using namespace testing; |
2127 | + sz = geom::Size{geom::Width{4}, geom::Height{23}}; |
2128 | + pf = geom::PixelFormat::abgr_8888; |
2129 | + mock_cache = std::make_shared<mtd::MockInterpreterResourceCache>(); |
2130 | + mock_surface = std::make_shared<MockSurface>(); |
2131 | + mock_buffer = std::make_shared<mtd::MockBuffer>(); |
2132 | + stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2133 | + |
2134 | + ON_CALL(*mock_surface, client_buffer()) |
2135 | + .WillByDefault(Return(mock_buffer)); |
2136 | + ON_CALL(*mock_surface, pixel_format()) |
2137 | + .WillByDefault(Return(geom::PixelFormat::abgr_8888)); |
2138 | + ON_CALL(*mock_buffer, native_buffer_handle()) |
2139 | + .WillByDefault(Return(stub_anw)); |
2140 | + } |
2141 | + |
2142 | + std::shared_ptr<ANativeWindowBuffer> stub_anw; |
2143 | + std::shared_ptr<mtd::MockInterpreterResourceCache> mock_cache; |
2144 | + std::shared_ptr<MockSurface> mock_surface; |
2145 | + std::shared_ptr<mtd::MockBuffer> mock_buffer; |
2146 | + geom::Size sz; |
2147 | + geom::PixelFormat pf; |
2148 | +}; |
2149 | +} |
2150 | + |
2151 | +TEST_F(InternalClientWindow, driver_requests_buffer) |
2152 | +{ |
2153 | + using namespace testing; |
2154 | + EXPECT_CALL(*mock_surface, client_buffer()) |
2155 | + .Times(1); |
2156 | + EXPECT_CALL(*mock_buffer, native_buffer_handle()) |
2157 | + .Times(1); |
2158 | + std::shared_ptr<mc::Buffer> tmp = mock_buffer; |
2159 | + EXPECT_CALL(*mock_cache, store_buffer(tmp, stub_anw.get())) |
2160 | + .Times(1); |
2161 | + |
2162 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
2163 | + auto test_buffer = interpreter.driver_requests_buffer(); |
2164 | + EXPECT_EQ(stub_anw.get(), test_buffer); |
2165 | +} |
2166 | + |
2167 | +TEST_F(InternalClientWindow, driver_returns_buffer) |
2168 | +{ |
2169 | + using namespace testing; |
2170 | + std::shared_ptr<mga::SyncObject> fake_sync; |
2171 | + |
2172 | + EXPECT_CALL(*mock_cache, retrieve_buffer(stub_anw.get())) |
2173 | + .Times(1) |
2174 | + .WillOnce(Return(mock_buffer)); |
2175 | + |
2176 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
2177 | + auto test_bufferptr = interpreter.driver_requests_buffer(); |
2178 | + interpreter.driver_returns_buffer(test_bufferptr, fake_sync); |
2179 | +} |
2180 | + |
2181 | +TEST_F(InternalClientWindow, size_test) |
2182 | +{ |
2183 | + using namespace testing; |
2184 | + EXPECT_CALL(*mock_surface, size()) |
2185 | + .Times(2) |
2186 | + .WillOnce(Return(sz)) |
2187 | + .WillOnce(Return(sz)); |
2188 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
2189 | + |
2190 | + unsigned int rc_width = interpreter.driver_requests_info(NATIVE_WINDOW_WIDTH); |
2191 | + unsigned int rc_height = interpreter.driver_requests_info(NATIVE_WINDOW_HEIGHT); |
2192 | + |
2193 | + EXPECT_EQ(sz.width.as_uint32_t(), rc_width); |
2194 | + EXPECT_EQ(sz.height.as_uint32_t(), rc_height); |
2195 | +} |
2196 | + |
2197 | +TEST_F(InternalClientWindow, driver_default_format) |
2198 | +{ |
2199 | + using namespace testing; |
2200 | + EXPECT_CALL(*mock_surface, pixel_format()) |
2201 | + .Times(1); |
2202 | + |
2203 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
2204 | + |
2205 | + auto rc_format = interpreter.driver_requests_info(NATIVE_WINDOW_FORMAT); |
2206 | + EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, rc_format); |
2207 | +} |
2208 | + |
2209 | +TEST_F(InternalClientWindow, driver_sets_format) |
2210 | +{ |
2211 | + using namespace testing; |
2212 | + EXPECT_CALL(*mock_surface, pixel_format()) |
2213 | + .Times(AtLeast(1)) |
2214 | + .WillRepeatedly(Return(geom::PixelFormat::abgr_8888)); |
2215 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
2216 | + |
2217 | + interpreter.dispatch_driver_request_format(HAL_PIXEL_FORMAT_RGBA_8888); |
2218 | + auto rc_format = interpreter.driver_requests_info(NATIVE_WINDOW_FORMAT); |
2219 | + EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, rc_format); |
2220 | +} |
2221 | |
2222 | === added file 'tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp' |
2223 | --- tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp 1970-01-01 00:00:00 +0000 |
2224 | +++ tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp 2013-05-09 21:03:25 +0000 |
2225 | @@ -0,0 +1,86 @@ |
2226 | +/* |
2227 | + * Copyright © 2013 Canonical Ltd. |
2228 | + * |
2229 | + * This program is free software: you can redistribute it and/or modify |
2230 | + * it under the terms of the GNU General Public License version 3 as |
2231 | + * published by the Free Software Foundation. |
2232 | + * |
2233 | + * This program is distributed in the hope that it will be useful, |
2234 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2235 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2236 | + * GNU General Public License for more details. |
2237 | + * |
2238 | + * You should have received a copy of the GNU General Public License |
2239 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2240 | + * |
2241 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
2242 | + */ |
2243 | + |
2244 | +#include "src/server/graphics/android/interpreter_cache.h" |
2245 | +#include "mir_test_doubles/stub_buffer.h" |
2246 | + |
2247 | +#include <gtest/gtest.h> |
2248 | +#include <stdexcept> |
2249 | + |
2250 | +namespace mga=mir::graphics::android; |
2251 | +namespace mtd=mir::test::doubles; |
2252 | + |
2253 | +struct InterpreterResourceTest : public ::testing::Test |
2254 | +{ |
2255 | + void SetUp() |
2256 | + { |
2257 | + stub_buffer1 = std::make_shared<mtd::StubBuffer>(); |
2258 | + stub_buffer2 = std::make_shared<mtd::StubBuffer>(); |
2259 | + stub_buffer3 = std::make_shared<mtd::StubBuffer>(); |
2260 | + key1 = (ANativeWindowBuffer*)0x1; |
2261 | + key2 = (ANativeWindowBuffer*)0x2; |
2262 | + key3 = (ANativeWindowBuffer*)0x3; |
2263 | + } |
2264 | + |
2265 | + std::shared_ptr<mtd::StubBuffer> stub_buffer1; |
2266 | + std::shared_ptr<mtd::StubBuffer> stub_buffer2; |
2267 | + std::shared_ptr<mtd::StubBuffer> stub_buffer3; |
2268 | + ANativeWindowBuffer *key1; |
2269 | + ANativeWindowBuffer *key2; |
2270 | + ANativeWindowBuffer *key3; |
2271 | +}; |
2272 | + |
2273 | +TEST_F(InterpreterResourceTest, deposit_buffer) |
2274 | +{ |
2275 | + mga::InterpreterCache cache; |
2276 | + cache.store_buffer(stub_buffer1, key1); |
2277 | + |
2278 | + auto test_buffer = cache.retrieve_buffer(key1); |
2279 | + EXPECT_EQ(stub_buffer1, test_buffer); |
2280 | +} |
2281 | + |
2282 | +TEST_F(InterpreterResourceTest, deposit_many_buffers) |
2283 | +{ |
2284 | + mga::InterpreterCache cache; |
2285 | + cache.store_buffer(stub_buffer1, key1); |
2286 | + cache.store_buffer(stub_buffer2, key2); |
2287 | + cache.store_buffer(stub_buffer3, key3); |
2288 | + |
2289 | + EXPECT_EQ(stub_buffer3, cache.retrieve_buffer(key3)); |
2290 | + EXPECT_EQ(stub_buffer1, cache.retrieve_buffer(key1)); |
2291 | + EXPECT_EQ(stub_buffer2, cache.retrieve_buffer(key2)); |
2292 | +} |
2293 | + |
2294 | +TEST_F(InterpreterResourceTest, deposit_buffer_has_ownership) |
2295 | +{ |
2296 | + mga::InterpreterCache cache; |
2297 | + |
2298 | + auto use_count_before = stub_buffer1.use_count(); |
2299 | + cache.store_buffer(stub_buffer1, key1); |
2300 | + EXPECT_EQ(use_count_before+1, stub_buffer1.use_count()); |
2301 | + cache.retrieve_buffer(key1); |
2302 | + EXPECT_EQ(use_count_before, stub_buffer1.use_count()); |
2303 | +} |
2304 | + |
2305 | +TEST_F(InterpreterResourceTest, retreive_buffer_with_bad_key_throws) |
2306 | +{ |
2307 | + mga::InterpreterCache cache; |
2308 | + EXPECT_THROW({ |
2309 | + cache.retrieve_buffer(key1); |
2310 | + }, std::runtime_error); |
2311 | +} |
2312 | |
2313 | === modified file 'tests/unit-tests/graphics/android/test_server_interpreter.cpp' |
2314 | --- tests/unit-tests/graphics/android/test_server_interpreter.cpp 2013-05-02 15:50:37 +0000 |
2315 | +++ tests/unit-tests/graphics/android/test_server_interpreter.cpp 2013-05-09 21:03:25 +0000 |
2316 | @@ -21,6 +21,7 @@ |
2317 | |
2318 | #include "mir_test_doubles/mock_display_support_provider.h" |
2319 | #include "mir_test_doubles/mock_buffer.h" |
2320 | +#include "mir_test_doubles/mock_interpreter_resource_cache.h" |
2321 | |
2322 | #include <gtest/gtest.h> |
2323 | #include <gmock/gmock.h> |
2324 | @@ -45,7 +46,8 @@ |
2325 | ~MockFBSwapper() noexcept {} |
2326 | MOCK_METHOD0(compositor_acquire, std::shared_ptr<mc::Buffer>()); |
2327 | MOCK_METHOD1(compositor_release, void(std::shared_ptr<mc::Buffer> const& released_buffer)); |
2328 | -}; |
2329 | +}; |
2330 | + |
2331 | struct ServerRenderWindowTest : public ::testing::Test |
2332 | { |
2333 | virtual void SetUp() |
2334 | @@ -56,6 +58,7 @@ |
2335 | mock_buffer3 = std::make_shared<NiceMock<mtd::MockBuffer>>(); |
2336 | mock_swapper = std::make_shared<NiceMock<MockFBSwapper>>(); |
2337 | mock_display_poster = std::make_shared<NiceMock<mtd::MockDisplaySupportProvider>>(); |
2338 | + mock_cache = std::make_shared<mtd::MockInterpreterResourceCache>(); |
2339 | ON_CALL(*mock_display_poster, display_format()) |
2340 | .WillByDefault(Return(geom::PixelFormat::abgr_8888)); |
2341 | stub_sync = std::make_shared<StubFence>(); |
2342 | @@ -64,6 +67,7 @@ |
2343 | std::shared_ptr<mtd::MockBuffer> mock_buffer1; |
2344 | std::shared_ptr<mtd::MockBuffer> mock_buffer2; |
2345 | std::shared_ptr<mtd::MockBuffer> mock_buffer3; |
2346 | + std::shared_ptr<mtd::MockInterpreterResourceCache> mock_cache; |
2347 | std::shared_ptr<MockFBSwapper> mock_swapper; |
2348 | std::shared_ptr<mtd::MockDisplaySupportProvider> mock_display_poster; |
2349 | std::shared_ptr<StubFence> stub_sync; |
2350 | @@ -73,7 +77,7 @@ |
2351 | TEST_F(ServerRenderWindowTest, driver_wants_a_buffer) |
2352 | { |
2353 | using namespace testing; |
2354 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2355 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2356 | |
2357 | auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2358 | |
2359 | @@ -84,17 +88,22 @@ |
2360 | .Times(1) |
2361 | .WillOnce(Return(stub_anw)); |
2362 | |
2363 | + std::shared_ptr<mc::Buffer> tmp = mock_buffer1; |
2364 | + EXPECT_CALL(*mock_cache, store_buffer(tmp, stub_anw.get())) |
2365 | + .Times(1); |
2366 | + |
2367 | auto rc_buffer = render_window.driver_requests_buffer(); |
2368 | - |
2369 | EXPECT_EQ(stub_anw.get(), rc_buffer); |
2370 | } |
2371 | |
2372 | TEST_F(ServerRenderWindowTest, driver_is_done_with_a_buffer_properly) |
2373 | { |
2374 | using namespace testing; |
2375 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2376 | - |
2377 | auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2378 | + EXPECT_CALL(*mock_cache, retrieve_buffer(stub_anw.get())) |
2379 | + .Times(1) |
2380 | + .WillOnce(Return(mock_buffer1)); |
2381 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2382 | |
2383 | EXPECT_CALL(*mock_swapper, compositor_acquire()) |
2384 | .Times(1) |
2385 | @@ -116,74 +125,15 @@ |
2386 | testing::Mock::VerifyAndClearExpectations(mock_swapper.get()); |
2387 | } |
2388 | |
2389 | -/* note: in real usage, sync is enforced by the swapper class. we make use of the mock's non-blocking |
2390 | - to do the tests. */ |
2391 | -TEST_F(ServerRenderWindowTest, driver_is_done_with_a_few_buffers_properly) |
2392 | -{ |
2393 | - using namespace testing; |
2394 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2395 | - |
2396 | - auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2397 | - auto stub_anw2 = std::make_shared<ANativeWindowBuffer>(); |
2398 | - auto stub_anw3 = std::make_shared<ANativeWindowBuffer>(); |
2399 | - |
2400 | - EXPECT_CALL(*mock_swapper, compositor_acquire()) |
2401 | - .Times(3) |
2402 | - .WillOnce(Return(mock_buffer1)) |
2403 | - .WillOnce(Return(mock_buffer2)) |
2404 | - .WillOnce(Return(mock_buffer3)); |
2405 | - EXPECT_CALL(*mock_buffer1, native_buffer_handle()) |
2406 | - .Times(1) |
2407 | - .WillOnce(Return(stub_anw)); |
2408 | - EXPECT_CALL(*mock_buffer2, native_buffer_handle()) |
2409 | - .Times(1) |
2410 | - .WillOnce(Return(stub_anw2)); |
2411 | - EXPECT_CALL(*mock_buffer3, native_buffer_handle()) |
2412 | - .Times(1) |
2413 | - .WillOnce(Return(stub_anw3)); |
2414 | - |
2415 | - auto handle1 = render_window.driver_requests_buffer(); |
2416 | - auto handle2 = render_window.driver_requests_buffer(); |
2417 | - auto handle3 = render_window.driver_requests_buffer(); |
2418 | - testing::Mock::VerifyAndClearExpectations(mock_swapper.get()); |
2419 | - |
2420 | - std::shared_ptr<mc::Buffer> buf1 = mock_buffer1; |
2421 | - std::shared_ptr<mc::Buffer> buf2 = mock_buffer2; |
2422 | - std::shared_ptr<mc::Buffer> buf3 = mock_buffer3; |
2423 | - EXPECT_CALL(*mock_swapper, compositor_release(buf1)) |
2424 | - .Times(1); |
2425 | - EXPECT_CALL(*mock_swapper, compositor_release(buf2)) |
2426 | - .Times(1); |
2427 | - EXPECT_CALL(*mock_swapper, compositor_release(buf3)) |
2428 | - .Times(1); |
2429 | - |
2430 | - render_window.driver_returns_buffer(handle1, stub_sync); |
2431 | - render_window.driver_returns_buffer(handle2, stub_sync); |
2432 | - render_window.driver_returns_buffer(handle3, stub_sync); |
2433 | - testing::Mock::VerifyAndClearExpectations(mock_swapper.get()); |
2434 | -} |
2435 | - |
2436 | -TEST_F(ServerRenderWindowTest, throw_if_driver_returns_weird_buffer) |
2437 | -{ |
2438 | - using namespace testing; |
2439 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2440 | - |
2441 | - auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2442 | - |
2443 | - EXPECT_CALL(*mock_swapper, compositor_release(_)) |
2444 | - .Times(0); |
2445 | - |
2446 | - EXPECT_THROW({ |
2447 | - render_window.driver_returns_buffer(nullptr, stub_sync); |
2448 | - }, std::runtime_error); |
2449 | -} |
2450 | - |
2451 | TEST_F(ServerRenderWindowTest, driver_returns_buffer_posts_to_fb) |
2452 | { |
2453 | using namespace testing; |
2454 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2455 | + auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2456 | + EXPECT_CALL(*mock_cache, retrieve_buffer(_)) |
2457 | + .Times(1) |
2458 | + .WillOnce(Return(mock_buffer1)); |
2459 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2460 | |
2461 | - auto stub_anw = std::make_shared<ANativeWindowBuffer>(); |
2462 | mc::BufferID id{442}, returned_id; |
2463 | EXPECT_CALL(*mock_swapper, compositor_acquire()) |
2464 | .Times(1) |
2465 | @@ -209,7 +159,7 @@ |
2466 | .Times(1) |
2467 | .WillOnce(Return(geom::PixelFormat::abgr_8888)); |
2468 | |
2469 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2470 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2471 | |
2472 | EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, render_window.driver_requests_info(NATIVE_WINDOW_FORMAT)); |
2473 | } |
2474 | @@ -218,7 +168,7 @@ |
2475 | { |
2476 | using namespace testing; |
2477 | |
2478 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2479 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2480 | EXPECT_CALL(*mock_display_poster, display_format()) |
2481 | .Times(0); |
2482 | |
2483 | @@ -235,7 +185,7 @@ |
2484 | .Times(4) |
2485 | .WillRepeatedly(Return(test_size)); |
2486 | |
2487 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2488 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2489 | |
2490 | unsigned int rc_width = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_WIDTH); |
2491 | unsigned int rc_height = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_HEIGHT); |
2492 | @@ -252,7 +202,7 @@ |
2493 | { |
2494 | using namespace testing; |
2495 | |
2496 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2497 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2498 | |
2499 | EXPECT_EQ(0, render_window.driver_requests_info(NATIVE_WINDOW_TRANSFORM_HINT)); |
2500 | } |
2501 | @@ -260,7 +210,7 @@ |
2502 | TEST_F(ServerRenderWindowTest, driver_unknown_inquiry) |
2503 | { |
2504 | using namespace testing; |
2505 | - mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster); |
2506 | + mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache); |
2507 | |
2508 | EXPECT_THROW({ |
2509 | render_window.driver_requests_info(NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND); |
2510 | |
2511 | === removed directory 'tests/unit-tests/graphics/egl' |
2512 | === removed file 'tests/unit-tests/graphics/egl/CMakeLists.txt' |
2513 | --- tests/unit-tests/graphics/egl/CMakeLists.txt 2013-03-27 00:11:32 +0000 |
2514 | +++ tests/unit-tests/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2515 | @@ -1,6 +0,0 @@ |
2516 | -list(APPEND UNIT_TEST_SOURCES |
2517 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_mirserver_mesa_egl_native_display.cpp |
2518 | -) |
2519 | - |
2520 | -set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
2521 | - |
2522 | |
2523 | === modified file 'tests/unit-tests/graphics/gbm/CMakeLists.txt' |
2524 | --- tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-05-02 22:10:08 +0000 |
2525 | +++ tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-05-09 21:03:25 +0000 |
2526 | @@ -5,9 +5,11 @@ |
2527 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display.cpp |
2528 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_multi_monitor.cpp |
2529 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_configuration.cpp |
2530 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp |
2531 | ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_output.cpp |
2532 | ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_page_flipper.cpp |
2533 | ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp |
2534 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_display.cpp |
2535 | ) |
2536 | |
2537 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
2538 | |
2539 | === added file 'tests/unit-tests/graphics/gbm/internal_client.h' |
2540 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_platform.cpp' |
2541 | --- tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-02 22:10:08 +0000 |
2542 | +++ tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-09 21:03:25 +0000 |
2543 | @@ -19,7 +19,9 @@ |
2544 | #include "mir/graphics/platform_ipc_package.h" |
2545 | #include "mir/graphics/drm_authenticator.h" |
2546 | #include "src/server/graphics/gbm/gbm_platform.h" |
2547 | +#include "src/server/graphics/gbm/internal_client.h" |
2548 | #include "mir_test_doubles/null_virtual_terminal.h" |
2549 | +#include "mir_test_doubles/stub_surface.h" |
2550 | |
2551 | #include "mir/graphics/null_display_report.h" |
2552 | |
2553 | @@ -139,3 +141,21 @@ |
2554 | authenticator->drm_auth_magic(magic); |
2555 | }, std::runtime_error); |
2556 | } |
2557 | + |
2558 | +/* TODO: this function is a bit fragile because libmirserver and libmirclient both have very different |
2559 | + * implementations and both have symbols for it. If the linking order of the test changes, |
2560 | + * specifically, if mir_egl_mesa_display_is_valid resolves into libmirclient, then this test will break. |
2561 | + */ |
2562 | +TEST_F(GBMGraphicsPlatform, platform_provides_validation_of_display_for_internal_clients) |
2563 | +{ |
2564 | + auto stub_surface = std::make_shared<mtd::StubSurface>(); |
2565 | + MirMesaEGLNativeDisplay* native_display = nullptr; |
2566 | + EXPECT_EQ(0, mir_server_internal_display_is_valid(native_display)); |
2567 | + { |
2568 | + auto platform = create_platform(); |
2569 | + auto client = platform->create_internal_client(stub_surface); |
2570 | + native_display = reinterpret_cast<MirMesaEGLNativeDisplay*>(client->egl_native_display()); |
2571 | + EXPECT_EQ(1, mir_server_internal_display_is_valid(native_display)); |
2572 | + } |
2573 | + EXPECT_EQ(0, mir_server_internal_display_is_valid(native_display)); |
2574 | +} |
2575 | |
2576 | === added file 'tests/unit-tests/graphics/gbm/test_internal_client.cpp' |
2577 | --- tests/unit-tests/graphics/gbm/test_internal_client.cpp 1970-01-01 00:00:00 +0000 |
2578 | +++ tests/unit-tests/graphics/gbm/test_internal_client.cpp 2013-05-09 21:03:25 +0000 |
2579 | @@ -0,0 +1,43 @@ |
2580 | +/* |
2581 | + * Copyright © 2013 Canonical Ltd. |
2582 | + * |
2583 | + * This program is free software: you can redistribute it and/or modify |
2584 | + * it under the terms of the GNU General Public License version 3 as |
2585 | + * published by the Free Software Foundation. |
2586 | + * |
2587 | + * This program is distributed in the hope that it will be useful, |
2588 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2589 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2590 | + * GNU General Public License for more details. |
2591 | + * |
2592 | + * You should have received a copy of the GNU General Public License |
2593 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2594 | + * |
2595 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
2596 | + */ |
2597 | + |
2598 | +#include "mir/frontend/surface.h" |
2599 | +#include "mir_toolkit/mesa/native_display.h" |
2600 | +#include "src/server/graphics/gbm/internal_client.h" |
2601 | +#include "mir_test_doubles/stub_platform.h" |
2602 | +#include "mir_test_doubles/stub_surface.h" |
2603 | + |
2604 | +#include <gtest/gtest.h> |
2605 | + |
2606 | +namespace geom=mir::geometry; |
2607 | +namespace mc=mir::compositor; |
2608 | +namespace mgg=mir::graphics::gbm; |
2609 | +namespace mtd=mir::test::doubles; |
2610 | + |
2611 | +TEST(InternalClient, native_display) |
2612 | +{ |
2613 | + auto stub_window = std::make_shared<mtd::StubSurface>(); |
2614 | + auto stub_display = std::make_shared<MirMesaEGLNativeDisplay>(); |
2615 | + mgg::InternalClient client(stub_display, stub_window); |
2616 | + |
2617 | + auto native_display = client.egl_native_display(); |
2618 | + auto native_window = client.egl_native_window(); |
2619 | + |
2620 | + EXPECT_EQ(reinterpret_cast<EGLNativeDisplayType>(stub_display.get()), native_display); |
2621 | + EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(stub_window.get()), native_window); |
2622 | +} |
2623 | |
2624 | === renamed file 'tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp' => 'tests/unit-tests/graphics/gbm/test_internal_native_display.cpp' |
2625 | --- tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp 2013-04-23 08:17:12 +0000 |
2626 | +++ tests/unit-tests/graphics/gbm/test_internal_native_display.cpp 2013-05-09 21:03:25 +0000 |
2627 | @@ -15,7 +15,8 @@ |
2628 | * |
2629 | * Authored by: Robert Carr <robert.carr@canonical.com> |
2630 | */ |
2631 | -#include "mir/graphics/egl/mesa_native_display.h" |
2632 | + |
2633 | +#include "src/server/graphics/gbm/internal_native_display.h" |
2634 | #include "mir/graphics/platform.h" |
2635 | #include "mir/graphics/platform_ipc_package.h" |
2636 | #include "mir/compositor/buffer_ipc_package.h" |
2637 | @@ -31,7 +32,7 @@ |
2638 | #include <gmock/gmock.h> |
2639 | |
2640 | namespace mg = mir::graphics; |
2641 | -namespace mgeglm = mg::egl::mesa; |
2642 | +namespace mgg = mir::graphics::gbm; |
2643 | namespace mc = mir::compositor; |
2644 | namespace msh = mir::shell; |
2645 | namespace geom = mir::geometry; |
2646 | @@ -40,55 +41,44 @@ |
2647 | |
2648 | namespace |
2649 | { |
2650 | - |
2651 | -struct MockGraphicsPlatform : public mg::Platform |
2652 | -{ |
2653 | - MOCK_METHOD1(create_buffer_allocator, std::shared_ptr<mc::GraphicBufferAllocator>(std::shared_ptr<mg::BufferInitializer> const&)); |
2654 | - MOCK_METHOD0(create_display, std::shared_ptr<mg::Display>()); |
2655 | - MOCK_METHOD0(get_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>()); |
2656 | - MOCK_METHOD0(shell_egl_display, EGLNativeDisplayType()); |
2657 | -}; |
2658 | - |
2659 | -struct MirServerMesaEGLNativeDisplaySetup : public testing::Test |
2660 | -{ |
2661 | - MirServerMesaEGLNativeDisplaySetup() |
2662 | +struct InternalNativeDisplay : public testing::Test |
2663 | +{ |
2664 | + InternalNativeDisplay() |
2665 | + { |
2666 | + } |
2667 | + |
2668 | + void SetUp() |
2669 | { |
2670 | using namespace ::testing; |
2671 | |
2672 | - test_platform_package.ipc_data = {1, 2}; |
2673 | - test_platform_package.ipc_fds = {2, 3}; |
2674 | - |
2675 | - ON_CALL(mock_graphics_platform, get_ipc_package()) |
2676 | - .WillByDefault(Return(mt::fake_shared(test_platform_package))); |
2677 | + platform_package = std::make_shared<mg::PlatformIPCPackage>(); |
2678 | + platform_package->ipc_data = {1, 2}; |
2679 | + platform_package->ipc_fds = {2, 3}; |
2680 | } |
2681 | |
2682 | - // Test dependencies |
2683 | - MockGraphicsPlatform mock_graphics_platform; |
2684 | - |
2685 | - // Useful stub data |
2686 | - mg::PlatformIPCPackage test_platform_package; |
2687 | + std::shared_ptr<mg::PlatformIPCPackage> platform_package; |
2688 | }; |
2689 | |
2690 | MATCHER_P(PackageMatches, package, "") |
2691 | { |
2692 | - if (arg.data_items != static_cast<int>(package.ipc_data.size())) |
2693 | + if (arg.data_items != static_cast<int>(package->ipc_data.size())) |
2694 | return false; |
2695 | - for (uint i = 0; i < package.ipc_data.size(); i++) |
2696 | + for (uint i = 0; i < package->ipc_data.size(); i++) |
2697 | { |
2698 | - if (arg.data[i] != package.ipc_data[i]) return false; |
2699 | + if (arg.data[i] != package->ipc_data[i]) return false; |
2700 | } |
2701 | - if (arg.fd_items != static_cast<int>(package.ipc_fds.size())) |
2702 | + if (arg.fd_items != static_cast<int>(package->ipc_fds.size())) |
2703 | return false; |
2704 | - for (uint i = 0; i < package.ipc_fds.size(); i++) |
2705 | + for (uint i = 0; i < package->ipc_fds.size(); i++) |
2706 | { |
2707 | - if (arg.fd[i] != package.ipc_fds[i]) return false; |
2708 | + if (arg.fd[i] != package->ipc_fds[i]) return false; |
2709 | } |
2710 | return true; |
2711 | } |
2712 | |
2713 | MATCHER_P(StrideMatches, package, "") |
2714 | { |
2715 | - if (arg.stride != package.stride) |
2716 | + if (arg.stride != package->stride) |
2717 | { |
2718 | return false; |
2719 | } |
2720 | @@ -103,83 +93,62 @@ |
2721 | return false; |
2722 | return true; |
2723 | } |
2724 | - |
2725 | } |
2726 | |
2727 | -TEST_F(MirServerMesaEGLNativeDisplaySetup, display_get_platform_is_cached_platform_package) |
2728 | +TEST_F(InternalNativeDisplay, display_get_platform_matches_construction_platform) |
2729 | { |
2730 | using namespace ::testing; |
2731 | |
2732 | - EXPECT_CALL(mock_graphics_platform, get_ipc_package()).Times(1); |
2733 | - |
2734 | - auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
2735 | - |
2736 | - MirPlatformPackage package; |
2737 | - memset(&package, 0, sizeof(MirPlatformPackage)); |
2738 | - display->display_get_platform(display.get(), &package); |
2739 | - EXPECT_THAT(package, PackageMatches(test_platform_package)); |
2740 | - |
2741 | - MirPlatformPackage requeried_package; |
2742 | - // The package is cached to allow the package creator to control lifespan of fd members |
2743 | - // and so this should not trigger another call to get_ipc_package() |
2744 | - display->display_get_platform(display.get(), &requeried_package); |
2745 | - |
2746 | - EXPECT_FALSE(memcmp(&requeried_package.data, &package.data, sizeof(package.data[0])*package.data_items)); |
2747 | - EXPECT_FALSE(memcmp(&requeried_package.fd, &package.fd, sizeof(package.fd[0])*package.fd_items)); |
2748 | + mgg::InternalNativeDisplay native_display(platform_package); |
2749 | + |
2750 | + MirPlatformPackage test_package; |
2751 | + memset(&test_package, 0, sizeof(MirPlatformPackage)); |
2752 | + native_display.display_get_platform(&native_display, &test_package); |
2753 | + EXPECT_THAT(test_package, PackageMatches(platform_package)); |
2754 | } |
2755 | |
2756 | -TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_current_buffer) |
2757 | +TEST_F(InternalNativeDisplay, surface_get_current_buffer) |
2758 | { |
2759 | using namespace ::testing; |
2760 | |
2761 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
2762 | auto buffer = std::make_shared<mtd::MockBuffer>(geom::Size(), geom::Stride(), geom::PixelFormat()); |
2763 | |
2764 | - mc::BufferIPCPackage test_buffer_package; |
2765 | + auto test_buffer_package = std::make_shared<mc::BufferIPCPackage>(); |
2766 | |
2767 | - test_buffer_package.ipc_data = {1, 2}; |
2768 | - test_buffer_package.ipc_fds = {2, 3}; |
2769 | - test_buffer_package.stride = 77; |
2770 | + test_buffer_package->ipc_data = {1, 2}; |
2771 | + test_buffer_package->ipc_fds = {2, 3}; |
2772 | + test_buffer_package->stride = 77; |
2773 | |
2774 | - auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
2775 | + mgg::InternalNativeDisplay native_display(platform_package); |
2776 | |
2777 | EXPECT_CALL(surface, client_buffer()).Times(1) |
2778 | .WillOnce(Return(buffer)); |
2779 | EXPECT_CALL(*buffer, get_ipc_package()).Times(1) |
2780 | - .WillOnce(Return(mt::fake_shared(test_buffer_package))); |
2781 | + .WillOnce(Return(test_buffer_package)); |
2782 | |
2783 | MirBufferPackage buffer_package; |
2784 | memset(&buffer_package, 0, sizeof(MirBufferPackage)); |
2785 | - display->surface_get_current_buffer( |
2786 | - display.get(), static_cast<MirEGLNativeWindowType>(&surface), &buffer_package); |
2787 | + native_display.surface_get_current_buffer( |
2788 | + &native_display, static_cast<MirEGLNativeWindowType>(&surface), &buffer_package); |
2789 | EXPECT_THAT(buffer_package, AllOf(PackageMatches(test_buffer_package), StrideMatches(test_buffer_package))); |
2790 | } |
2791 | |
2792 | -TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_advance_buffer) |
2793 | +TEST_F(InternalNativeDisplay, surface_advance_buffer) |
2794 | { |
2795 | using namespace ::testing; |
2796 | |
2797 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
2798 | |
2799 | - auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
2800 | + mgg::InternalNativeDisplay native_display(platform_package); |
2801 | |
2802 | EXPECT_CALL(surface, advance_client_buffer()).Times(1); |
2803 | |
2804 | - display->surface_advance_buffer( |
2805 | - display.get(), static_cast<MirEGLNativeWindowType>(&surface)); |
2806 | -} |
2807 | - |
2808 | -TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable) |
2809 | -{ |
2810 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid); |
2811 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::abgr_8888), mir_pixel_format_abgr_8888); |
2812 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xbgr_8888), mir_pixel_format_xbgr_8888); |
2813 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::argb_8888), mir_pixel_format_argb_8888); |
2814 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888), mir_pixel_format_xrgb_8888); |
2815 | - EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::bgr_888), mir_pixel_format_bgr_888); |
2816 | -} |
2817 | - |
2818 | -TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_parameters) |
2819 | + native_display.surface_advance_buffer( |
2820 | + &native_display, static_cast<MirEGLNativeWindowType>(&surface)); |
2821 | +} |
2822 | + |
2823 | +TEST_F(InternalNativeDisplay, surface_get_parameters) |
2824 | { |
2825 | using namespace ::testing; |
2826 | |
2827 | @@ -187,7 +156,7 @@ |
2828 | geom::Height{29}}; |
2829 | geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888; |
2830 | |
2831 | - auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
2832 | + mgg::InternalNativeDisplay native_display(platform_package); |
2833 | |
2834 | mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
2835 | EXPECT_CALL(surface, size()).Times(AtLeast(1)).WillRepeatedly(Return(test_surface_size)); |
2836 | @@ -195,8 +164,8 @@ |
2837 | |
2838 | MirSurfaceParameters parameters; |
2839 | memset(¶meters, 0, sizeof(MirSurfaceParameters)); |
2840 | - display->surface_get_parameters( |
2841 | - display.get(), static_cast<MirEGLNativeWindowType>(&surface), ¶meters); |
2842 | + native_display.surface_get_parameters( |
2843 | + &native_display, static_cast<MirEGLNativeWindowType>(&surface), ¶meters); |
2844 | |
2845 | EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size)); |
2846 | EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888)); |
2847 | @@ -204,3 +173,13 @@ |
2848 | // TODO: What to do about buffer usage besides hardware? ~racarr |
2849 | EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware); |
2850 | } |
2851 | + |
2852 | +TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable) |
2853 | +{ |
2854 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid); |
2855 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::abgr_8888), mir_pixel_format_abgr_8888); |
2856 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xbgr_8888), mir_pixel_format_xbgr_8888); |
2857 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::argb_8888), mir_pixel_format_argb_8888); |
2858 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888), mir_pixel_format_xrgb_8888); |
2859 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::bgr_888), mir_pixel_format_bgr_888); |
2860 | +} |
FAILED: Continuous integration, rev:711 jenkins. qa.ubuntu. com/job/ mir-ci/ 567/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 662 jenkins. qa.ubuntu. com/job/ mir-clang- raring- amd64-build/ 545/console jenkins. qa.ubuntu. com/job/ mir-raring- amd64-ci/ 51 jenkins. qa.ubuntu. com/job/ mir-raring- amd64-ci/ 51/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-vm- ci-build/ ./distribution= precise, flavor= amd64/301
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 567/rebuild
http://