Merge lp:~kdub/mir/gbm-cleanup into lp:~mir-team/mir/trunk
- gbm-cleanup
- Merge into trunk
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Chris Halse Rogers | ||||
Proposed branch: | lp:~kdub/mir/gbm-cleanup | ||||
Merge into: | lp:~mir-team/mir/trunk | ||||
Diff against target: |
1141 lines (+631/-223) 22 files modified
debian/changelog (+6/-0) include/shared/mir_toolkit/mesa/native_display.h (+14/-18) src/client/CMakeLists.txt (+1/-0) src/client/gbm/gbm_client_platform.cpp (+25/-3) src/client/gbm/gbm_native_surface.cpp (+78/-0) src/client/gbm/gbm_native_surface.h (+42/-0) src/client/gbm/mesa_native_display_container.cpp (+4/-39) src/server/graphics/gbm/CMakeLists.txt (+1/-0) src/server/graphics/gbm/internal_client.cpp (+6/-1) src/server/graphics/gbm/internal_client.h (+2/-0) src/server/graphics/gbm/internal_native_display.cpp (+4/-36) src/server/graphics/gbm/internal_native_display.h (+2/-10) src/server/graphics/gbm/internal_native_surface.cpp (+77/-0) src/server/graphics/gbm/internal_native_surface.h (+62/-0) tests/unit-tests/client/gbm/CMakeLists.txt (+1/-0) tests/unit-tests/client/gbm/test_gbm_client_platform.cpp (+0/-11) tests/unit-tests/client/gbm/test_native_surface.cpp (+114/-0) tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp (+6/-0) tests/unit-tests/graphics/gbm/CMakeLists.txt (+1/-0) tests/unit-tests/graphics/gbm/test_internal_client.cpp (+15/-5) tests/unit-tests/graphics/gbm/test_internal_native_display.cpp (+0/-100) tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp (+170/-0) |
||||
To merge this branch: | bzr merge lp:~kdub/mir/gbm-cleanup | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandros Frantzis (community) | Approve | ||
Alan Griffiths | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+169306@code.launchpad.net |
Commit message
add hooks for eglSwapInterval in the gbm platform. Split the mesa EGLMesaNativeDi
Description of the change
we need some hooks in the driver to get eglSwapInterval
the patch for mesa has landed to (https:/
Kevin DuBois (kdub) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:728
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:729
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
+1 for any progress toward eglSwapInterval
Kevin DuBois (kdub) wrote : | # |
> +1 for any progress toward eglSwapInterval
> we'll only ever need support for a zero interval in clients. The server will
> probably always use interval 1... ?
right, thats the plan!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:729
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
Some of the TODO comments are overly terse, but generally seems to result in cleaner code.
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
Non-blocking nits:
495 + MirBufferPackage* package)
515 + MirSurfaceParam
Wrong alignment.
588 + static int set_swapinterva
589 + static int advance_
590 + MirBufferPackage* package);
591 +
592 + static int get_parameters_
593 + MirSurfaceParam
These could be private.
Kevin DuBois (kdub) wrote : | # |
since this is changing our header that mesa depends upon, changing mir version to 0.0.4
Chris Halse Rogers (raof) wrote : | # |
Superceded by https:/
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2013-05-15 00:37:34 +0000 |
3 | +++ debian/changelog 2013-06-18 01:07:24 +0000 |
4 | @@ -1,3 +1,9 @@ |
5 | +mir (0.0.4-0ubuntu1) raring; urgency=low |
6 | + |
7 | + * change mesa header to clean up the file and add swapinterval 0 hook |
8 | + |
9 | + -- Kevin DuBois <kevin.dubois@canonical.com> Mon, 17 Jun 2013 18:02:32 -0700 |
10 | + |
11 | mir (0.0.3-0ubuntu1) raring; urgency=low |
12 | |
13 | [ Bryce Harrington ] |
14 | |
15 | === modified file 'include/shared/mir_toolkit/mesa/native_display.h' |
16 | --- include/shared/mir_toolkit/mesa/native_display.h 2013-05-08 18:57:03 +0000 |
17 | +++ include/shared/mir_toolkit/mesa/native_display.h 2013-06-18 01:07:24 +0000 |
18 | @@ -21,6 +21,9 @@ |
19 | #include "mir_toolkit/mir_native_buffer.h" |
20 | #include "mir_toolkit/client_types.h" |
21 | |
22 | +#define MIR_MESA_TRUE 1 |
23 | +#define MIR_MESA_FALSE 0 |
24 | + |
25 | #ifdef __cplusplus |
26 | /** |
27 | * \addtogroup mir_toolkit |
28 | @@ -31,31 +34,24 @@ |
29 | #endif |
30 | |
31 | typedef struct MirMesaEGLNativeDisplay MirMesaEGLNativeDisplay; |
32 | +typedef struct MirMesaEGLNativeSurface MirMesaEGLNativeSurface; |
33 | |
34 | struct MirMesaEGLNativeDisplay |
35 | { |
36 | - void (*display_get_platform)(MirMesaEGLNativeDisplay* display, |
37 | + int (*display_get_platform)(MirMesaEGLNativeDisplay* display, |
38 | MirPlatformPackage* package); |
39 | - void (*surface_get_current_buffer)(MirMesaEGLNativeDisplay* display, |
40 | - MirEGLNativeWindowType surface, |
41 | - MirBufferPackage* buffer_package); |
42 | - void (*surface_get_parameters)(MirMesaEGLNativeDisplay* display, |
43 | - MirEGLNativeWindowType surface, |
44 | + void *context; |
45 | +}; |
46 | + |
47 | +struct MirMesaEGLNativeSurface |
48 | +{ |
49 | + int (*surface_set_swapinterval)(MirMesaEGLNativeSurface* surface, int interval); |
50 | + int (*surface_advance_buffer)(MirMesaEGLNativeSurface* surface, |
51 | + MirBufferPackage* buffer_package); |
52 | + int (*surface_get_parameters)(MirMesaEGLNativeSurface* surface, |
53 | MirSurfaceParameters* surface_parameters); |
54 | - void (*surface_advance_buffer)(MirMesaEGLNativeDisplay* display, |
55 | - MirEGLNativeWindowType surface); |
56 | - |
57 | - void *context; |
58 | }; |
59 | |
60 | -typedef enum mir_display_type |
61 | -{ |
62 | - MIR_DISPLAY_TYPE_CLIENT, |
63 | - MIR_DISPLAY_TYPE_SERVER_INTERNAL |
64 | -} mir_display_type; |
65 | - |
66 | -mir_display_type mir_get_display_type(MirMesaEGLNativeDisplay* display); |
67 | - |
68 | int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display); |
69 | int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display); |
70 | |
71 | |
72 | === modified file 'src/client/CMakeLists.txt' |
73 | --- src/client/CMakeLists.txt 2013-06-03 12:15:45 +0000 |
74 | +++ src/client/CMakeLists.txt 2013-06-18 01:07:24 +0000 |
75 | @@ -54,6 +54,7 @@ |
76 | gbm/gbm_client_buffer_factory.cpp |
77 | gbm/gbm_client_buffer.cpp |
78 | gbm/mesa_native_display_container.cpp |
79 | + gbm/gbm_native_surface.cpp |
80 | ${CLIENT_SOURCES} |
81 | ) |
82 | endif() |
83 | |
84 | === modified file 'src/client/gbm/gbm_client_platform.cpp' |
85 | --- src/client/gbm/gbm_client_platform.cpp 2013-05-03 21:59:56 +0000 |
86 | +++ src/client/gbm/gbm_client_platform.cpp 2013-06-18 01:07:24 +0000 |
87 | @@ -21,6 +21,7 @@ |
88 | #include "gbm_client_buffer_factory.h" |
89 | #include "mesa_native_display_container.h" |
90 | #include "drm_fd_handler.h" |
91 | +#include "gbm_native_surface.h" |
92 | #include "../mir_connection.h" |
93 | #include "../client_buffer_factory.h" |
94 | #include "../native_client_platform_factory.h" |
95 | @@ -129,11 +130,32 @@ |
96 | return std::make_shared<mclg::GBMClientBufferFactory>(drm_fd_handler); |
97 | } |
98 | |
99 | +namespace |
100 | +{ |
101 | +struct NativeWindowDeleter |
102 | +{ |
103 | + NativeWindowDeleter(mclg::GBMNativeSurface* window) |
104 | + : window(window) {} |
105 | + |
106 | + void operator()(EGLNativeWindowType* type) |
107 | + { |
108 | + delete type; |
109 | + delete window; |
110 | + } |
111 | + |
112 | +private: |
113 | + mclg::GBMNativeSurface* window; |
114 | +}; |
115 | +} |
116 | + |
117 | std::shared_ptr<EGLNativeWindowType> mclg::GBMClientPlatform::create_egl_native_window(ClientSurface* client_surface) |
118 | { |
119 | - auto window_type = std::make_shared<EGLNativeWindowType>(); |
120 | - *window_type = reinterpret_cast<EGLNativeWindowType>(client_surface); |
121 | - return window_type; |
122 | + //TODO: this is awkward on both android and gbm... |
123 | + auto gbm_window = new GBMNativeSurface(*client_surface); |
124 | + auto egl_native_window = new EGLNativeWindowType; |
125 | + *egl_native_window = gbm_window; |
126 | + NativeWindowDeleter deleter(gbm_window); |
127 | + return std::shared_ptr<EGLNativeWindowType>(egl_native_window, deleter); |
128 | } |
129 | |
130 | std::shared_ptr<EGLNativeDisplayType> mclg::GBMClientPlatform::create_egl_native_display() |
131 | |
132 | === added file 'src/client/gbm/gbm_native_surface.cpp' |
133 | --- src/client/gbm/gbm_native_surface.cpp 1970-01-01 00:00:00 +0000 |
134 | +++ src/client/gbm/gbm_native_surface.cpp 2013-06-18 01:07:24 +0000 |
135 | @@ -0,0 +1,78 @@ |
136 | +/* |
137 | + * Copyright © 2013 Canonical Ltd. |
138 | + * |
139 | + * This program is free software: you can redistribute it and/or modify it |
140 | + * under the terms of the GNU Lesser General Public License version 3, |
141 | + * as published by the Free Software Foundation. |
142 | + * |
143 | + * This program is distributed in the hope that it will be useful, |
144 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
145 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
146 | + * GNU Lesser General Public License for more details. |
147 | + * |
148 | + * You should have received a copy of the GNU Lesser General Public License |
149 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
150 | + * |
151 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
152 | + */ |
153 | + |
154 | +#include <cstring> |
155 | +#include "../client_buffer.h" |
156 | +#include "gbm_native_surface.h" |
157 | + |
158 | +namespace mclg=mir::client::gbm; |
159 | + |
160 | +namespace |
161 | +{ |
162 | +static int advance_buffer_static(MirMesaEGLNativeSurface* surface, |
163 | + MirBufferPackage* buffer_package) |
164 | +{ |
165 | + auto s = static_cast<mclg::GBMNativeSurface*>(surface); |
166 | + return s->advance_buffer(buffer_package); |
167 | +} |
168 | + |
169 | +static int get_parameters_static(MirMesaEGLNativeSurface* surface, |
170 | + MirSurfaceParameters* surface_parameters) |
171 | +{ |
172 | + auto s = static_cast<mclg::GBMNativeSurface*>(surface); |
173 | + return s->get_parameters(surface_parameters); |
174 | +} |
175 | + |
176 | +static int set_swapinterval_static(MirMesaEGLNativeSurface* surface, int interval) |
177 | +{ |
178 | + //TODO |
179 | + (void) surface; |
180 | + (void) interval; |
181 | + return MIR_MESA_TRUE; |
182 | +} |
183 | + |
184 | +static void buffer_advanced_callback(MirSurface* /* surface */, |
185 | + void* /* context */) |
186 | +{ |
187 | +} |
188 | +} |
189 | + |
190 | +mclg::GBMNativeSurface::GBMNativeSurface(ClientSurface& surface) |
191 | + : surface(surface) |
192 | +{ |
193 | + surface_advance_buffer = advance_buffer_static; |
194 | + surface_get_parameters = get_parameters_static; |
195 | + surface_set_swapinterval = set_swapinterval_static; |
196 | +} |
197 | + |
198 | +int mclg::GBMNativeSurface::advance_buffer(MirBufferPackage* buffer_package) |
199 | +{ |
200 | + mir_wait_for(surface.next_buffer(buffer_advanced_callback, NULL)); |
201 | + auto buffer = surface.get_current_buffer(); |
202 | + |
203 | + auto buffer_to_driver = buffer->native_buffer_handle(); |
204 | + memcpy(buffer_package, buffer_to_driver.get(), sizeof(MirBufferPackage)); |
205 | + return MIR_MESA_TRUE; |
206 | +} |
207 | + |
208 | +int mclg::GBMNativeSurface::get_parameters(MirSurfaceParameters* surface_parameters) |
209 | +{ |
210 | + auto params = surface.get_parameters(); |
211 | + memcpy(surface_parameters, ¶ms, sizeof(MirSurfaceParameters)); |
212 | + return MIR_MESA_TRUE; |
213 | +} |
214 | |
215 | === added file 'src/client/gbm/gbm_native_surface.h' |
216 | --- src/client/gbm/gbm_native_surface.h 1970-01-01 00:00:00 +0000 |
217 | +++ src/client/gbm/gbm_native_surface.h 2013-06-18 01:07:24 +0000 |
218 | @@ -0,0 +1,42 @@ |
219 | +/* |
220 | + * Copyright © 2013 Canonical Ltd. |
221 | + * |
222 | + * This program is free software: you can redistribute it and/or modify it |
223 | + * under the terms of the GNU Lesser General Public License version 3, |
224 | + * as published by the Free Software Foundation. |
225 | + * |
226 | + * This program is distributed in the hope that it will be useful, |
227 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
228 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
229 | + * GNU Lesser General Public License for more details. |
230 | + * |
231 | + * You should have received a copy of the GNU Lesser General Public License |
232 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
233 | + * |
234 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
235 | + */ |
236 | + |
237 | +#include "mir_toolkit/mesa/native_display.h" |
238 | +#include "../mir_client_surface.h" |
239 | + |
240 | +namespace mir |
241 | +{ |
242 | +namespace client |
243 | +{ |
244 | +namespace gbm |
245 | +{ |
246 | + |
247 | +class GBMNativeSurface : public MirMesaEGLNativeSurface |
248 | +{ |
249 | +public: |
250 | + explicit GBMNativeSurface(ClientSurface&); |
251 | + |
252 | + int advance_buffer(MirBufferPackage* buffer_package); |
253 | + int get_parameters(MirSurfaceParameters* surface_parameters); |
254 | +private: |
255 | + ClientSurface& surface; |
256 | +}; |
257 | + |
258 | +} |
259 | +} |
260 | +} |
261 | |
262 | === modified file 'src/client/gbm/mesa_native_display_container.cpp' |
263 | --- src/client/gbm/mesa_native_display_container.cpp 2013-06-06 08:36:17 +0000 |
264 | +++ src/client/gbm/mesa_native_display_container.cpp 2013-06-18 01:07:24 +0000 |
265 | @@ -33,42 +33,12 @@ |
266 | extern "C" |
267 | { |
268 | |
269 | -static void gbm_egl_display_get_platform(MirMesaEGLNativeDisplay* display, |
270 | +static int gbm_egl_display_get_platform(MirMesaEGLNativeDisplay* display, |
271 | MirPlatformPackage* package) |
272 | { |
273 | auto connection = static_cast<MirConnection*>(display->context); |
274 | - |
275 | mir_connection_get_platform(connection, package); |
276 | -} |
277 | - |
278 | -static void gbm_egl_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
279 | - MirEGLNativeWindowType surface, |
280 | - MirBufferPackage* buffer_package) |
281 | -{ |
282 | - MirSurface* ms = static_cast<MirSurface*>(surface); |
283 | - MirBufferPackage * current_package; |
284 | - mir_surface_get_current_buffer(ms, ¤t_package); |
285 | - memcpy(buffer_package, current_package, sizeof(MirBufferPackage)); |
286 | -} |
287 | - |
288 | -static void buffer_advanced_callback(MirSurface* /* surface */, |
289 | - void* /* context */) |
290 | -{ |
291 | -} |
292 | - |
293 | -static void gbm_egl_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, |
294 | - MirEGLNativeWindowType surface) |
295 | -{ |
296 | - MirSurface* ms = static_cast<MirSurface*>(surface); |
297 | - mir_wait_for(mir_surface_swap_buffers(ms, buffer_advanced_callback, nullptr)); |
298 | -} |
299 | - |
300 | -static void gbm_egl_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */, |
301 | - MirEGLNativeWindowType surface, |
302 | - MirSurfaceParameters* surface_parameters) |
303 | -{ |
304 | - MirSurface* ms = static_cast<MirSurface*>(surface); |
305 | - mir_surface_get_parameters(ms, surface_parameters); |
306 | + return MIR_MESA_TRUE; |
307 | } |
308 | |
309 | int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display) |
310 | @@ -99,8 +69,7 @@ |
311 | } |
312 | } |
313 | |
314 | -bool |
315 | -mclg::MesaNativeDisplayContainer::validate(MirEGLNativeDisplayType display) const |
316 | +bool mclg::MesaNativeDisplayContainer::validate(MirEGLNativeDisplayType display) const |
317 | { |
318 | std::lock_guard<std::mutex> lg(guard); |
319 | return (valid_displays.find(display) != valid_displays.end()); |
320 | @@ -111,9 +80,6 @@ |
321 | { |
322 | MirMesaEGLNativeDisplay* display = new MirMesaEGLNativeDisplay(); |
323 | display->display_get_platform = gbm_egl_display_get_platform; |
324 | - display->surface_get_current_buffer = gbm_egl_surface_get_current_buffer; |
325 | - display->surface_advance_buffer = gbm_egl_surface_advance_buffer; |
326 | - display->surface_get_parameters = gbm_egl_surface_get_parameters; |
327 | display->context = connection; |
328 | |
329 | std::lock_guard<std::mutex> lg(guard); |
330 | @@ -123,8 +89,7 @@ |
331 | return egl_display; |
332 | } |
333 | |
334 | -void |
335 | -mclg::MesaNativeDisplayContainer::release(MirEGLNativeDisplayType display) |
336 | +void mclg::MesaNativeDisplayContainer::release(MirEGLNativeDisplayType display) |
337 | { |
338 | std::lock_guard<std::mutex> lg(guard); |
339 | |
340 | |
341 | === modified file 'src/server/graphics/gbm/CMakeLists.txt' |
342 | --- src/server/graphics/gbm/CMakeLists.txt 2013-05-23 13:01:05 +0000 |
343 | +++ src/server/graphics/gbm/CMakeLists.txt 2013-06-18 01:07:24 +0000 |
344 | @@ -27,6 +27,7 @@ |
345 | kms_page_flipper.cpp |
346 | linux_virtual_terminal.cpp |
347 | internal_native_display.cpp |
348 | + internal_native_surface.cpp |
349 | internal_client.cpp |
350 | drm_close_threadsafe.cpp |
351 | ) |
352 | |
353 | === modified file 'src/server/graphics/gbm/internal_client.cpp' |
354 | --- src/server/graphics/gbm/internal_client.cpp 2013-05-14 16:45:25 +0000 |
355 | +++ src/server/graphics/gbm/internal_client.cpp 2013-06-18 01:07:24 +0000 |
356 | @@ -34,5 +34,10 @@ |
357 | |
358 | EGLNativeWindowType mgg::InternalClient::egl_native_window(std::shared_ptr<mf::Surface> const& surface) |
359 | { |
360 | - return reinterpret_cast<EGLNativeWindowType>(surface.get()); |
361 | + if (!client_window) |
362 | + { |
363 | + client_window = std::make_shared<mgg::InternalNativeSurface>(surface); |
364 | + } |
365 | + |
366 | + return client_window.get(); |
367 | } |
368 | |
369 | === modified file 'src/server/graphics/gbm/internal_client.h' |
370 | --- src/server/graphics/gbm/internal_client.h 2013-05-14 16:45:25 +0000 |
371 | +++ src/server/graphics/gbm/internal_client.h 2013-06-18 01:07:24 +0000 |
372 | @@ -21,6 +21,7 @@ |
373 | |
374 | #include "mir/graphics/internal_client.h" |
375 | #include "internal_native_display.h" |
376 | +#include "internal_native_surface.h" |
377 | #include <memory> |
378 | |
379 | namespace mir |
380 | @@ -44,6 +45,7 @@ |
381 | |
382 | private: |
383 | std::shared_ptr<MirMesaEGLNativeDisplay> const native_display; |
384 | + std::shared_ptr<MirMesaEGLNativeSurface> client_window; |
385 | }; |
386 | |
387 | } |
388 | |
389 | === modified file 'src/server/graphics/gbm/internal_native_display.cpp' |
390 | --- src/server/graphics/gbm/internal_native_display.cpp 2013-05-14 22:14:13 +0000 |
391 | +++ src/server/graphics/gbm/internal_native_display.cpp 2013-06-18 01:07:24 +0000 |
392 | @@ -38,23 +38,9 @@ |
393 | { |
394 | context = this; |
395 | this->display_get_platform = &InternalNativeDisplay::native_display_get_platform; |
396 | - this->surface_get_current_buffer = &InternalNativeDisplay::native_display_surface_get_current_buffer; |
397 | - this->surface_get_parameters = &InternalNativeDisplay::native_display_surface_get_parameters; |
398 | - this->surface_advance_buffer = &InternalNativeDisplay::native_display_surface_advance_buffer; |
399 | -} |
400 | - |
401 | -void mgg::InternalNativeDisplay::native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay*, |
402 | - MirEGLNativeWindowType surface, |
403 | - MirBufferPackage* package) |
404 | -{ |
405 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
406 | - |
407 | - auto buffer = mir_surface->client_buffer(); |
408 | - auto buffer_package = buffer->native_buffer_handle(); |
409 | - memcpy(package, buffer_package.get(), sizeof(MirBufferPackage)); |
410 | -} |
411 | - |
412 | -void mgg::InternalNativeDisplay::native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package) |
413 | +} |
414 | + |
415 | +int mgg::InternalNativeDisplay::native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package) |
416 | { |
417 | auto native_disp = static_cast<InternalNativeDisplay*>(display); |
418 | package->data_items = native_disp->platform_package->ipc_data.size(); |
419 | @@ -68,23 +54,5 @@ |
420 | package->fd[i] = native_disp->platform_package->ipc_fds[i]; |
421 | } |
422 | |
423 | -} |
424 | - |
425 | -void mgg::InternalNativeDisplay::native_display_surface_get_parameters(MirMesaEGLNativeDisplay*, |
426 | - MirEGLNativeWindowType surface, |
427 | - MirSurfaceParameters* parameters) |
428 | -{ |
429 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
430 | - |
431 | - parameters->width = mir_surface->size().width.as_uint32_t(); |
432 | - parameters->height = mir_surface->size().height.as_uint32_t(); |
433 | - parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format()); |
434 | - parameters->buffer_usage = mir_buffer_usage_hardware; |
435 | -} |
436 | - |
437 | -void mgg::InternalNativeDisplay::native_display_surface_advance_buffer(MirMesaEGLNativeDisplay*, |
438 | - MirEGLNativeWindowType surface) |
439 | -{ |
440 | - auto mir_surface = static_cast<mf::Surface*>(surface); |
441 | - mir_surface->advance_client_buffer(); |
442 | + return MIR_MESA_TRUE; |
443 | } |
444 | |
445 | === modified file 'src/server/graphics/gbm/internal_native_display.h' |
446 | --- src/server/graphics/gbm/internal_native_display.h 2013-05-09 20:58:30 +0000 |
447 | +++ src/server/graphics/gbm/internal_native_display.h 2013-06-18 01:07:24 +0000 |
448 | @@ -1,4 +1,3 @@ |
449 | - |
450 | /* |
451 | * Copyright © 2013 Canonical Ltd. |
452 | * |
453 | @@ -37,16 +36,9 @@ |
454 | public: |
455 | InternalNativeDisplay(std::shared_ptr<PlatformIPCPackage> const& platform_package); |
456 | |
457 | - static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package); |
458 | - static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
459 | - MirEGLNativeWindowType surface, |
460 | - MirBufferPackage* package); |
461 | - static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */, |
462 | - MirEGLNativeWindowType surface, |
463 | - MirSurfaceParameters* parameters); |
464 | - static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, |
465 | - MirEGLNativeWindowType surface); |
466 | private: |
467 | + static int native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package); |
468 | + |
469 | std::shared_ptr<PlatformIPCPackage> platform_package; |
470 | }; |
471 | |
472 | |
473 | === added file 'src/server/graphics/gbm/internal_native_surface.cpp' |
474 | --- src/server/graphics/gbm/internal_native_surface.cpp 1970-01-01 00:00:00 +0000 |
475 | +++ src/server/graphics/gbm/internal_native_surface.cpp 2013-06-18 01:07:24 +0000 |
476 | @@ -0,0 +1,77 @@ |
477 | +/* |
478 | + * Copyright © 2013 Canonical Ltd. |
479 | + * |
480 | + * This program is free software: you can redistribute it and/or modify it |
481 | + * under the terms of the GNU General Public License version 3, |
482 | + * as published by the Free Software Foundation. |
483 | + * |
484 | + * This program is distributed in the hope that it will be useful, |
485 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
486 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
487 | + * GNU General Public License for more details. |
488 | + * |
489 | + * You should have received a copy of the GNU General Public License |
490 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
491 | + * |
492 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
493 | + */ |
494 | + |
495 | +#include "mir/frontend/surface.h" |
496 | +#include "mir/compositor/buffer.h" |
497 | +#include "internal_native_surface.h" |
498 | +#include <cstring> |
499 | +namespace mgg = mir::graphics::gbm; |
500 | + |
501 | +mgg::InternalNativeSurface::InternalNativeSurface(std::shared_ptr<frontend::Surface> const& surface) |
502 | + : surface(surface) |
503 | +{ |
504 | + surface_advance_buffer = advance_buffer_static; |
505 | + surface_get_parameters = get_parameters_static; |
506 | + surface_set_swapinterval = set_swapinterval_static; |
507 | +} |
508 | + |
509 | +int mgg::InternalNativeSurface::advance_buffer_static( |
510 | + MirMesaEGLNativeSurface* surface, MirBufferPackage* package) |
511 | +{ |
512 | + auto native_surface = static_cast<mgg::InternalNativeSurface*>(surface); |
513 | + return native_surface->advance_buffer(package); |
514 | +} |
515 | + |
516 | +int mgg::InternalNativeSurface::advance_buffer(MirBufferPackage* package) |
517 | +{ |
518 | + /* TODO: kdub has a cleanup branch for the surface interface that will make this less ugly */ |
519 | + current_buffer.reset(); |
520 | + surface->advance_client_buffer(); |
521 | + current_buffer = surface->client_buffer(); |
522 | + |
523 | + auto buffer_package = current_buffer->native_buffer_handle(); |
524 | + memcpy(package, buffer_package.get(), sizeof(MirBufferPackage)); |
525 | + |
526 | + return MIR_MESA_TRUE; |
527 | +} |
528 | + |
529 | +int mgg::InternalNativeSurface::get_parameters_static( |
530 | + MirMesaEGLNativeSurface* surface, MirSurfaceParameters* parameters) |
531 | +{ |
532 | + auto native_surface = static_cast<mgg::InternalNativeSurface*>(surface); |
533 | + return native_surface->get_parameters(parameters); |
534 | +} |
535 | + |
536 | +int mgg::InternalNativeSurface::get_parameters(MirSurfaceParameters* parameters) |
537 | +{ |
538 | + auto size = surface->size(); |
539 | + parameters->width = size.width.as_uint32_t(); |
540 | + parameters->height = size.height.as_uint32_t(); |
541 | + parameters->pixel_format = static_cast<MirPixelFormat>(surface->pixel_format()); |
542 | + parameters->buffer_usage = mir_buffer_usage_hardware; |
543 | + |
544 | + return MIR_MESA_TRUE; |
545 | +} |
546 | + |
547 | +int mgg::InternalNativeSurface::set_swapinterval_static(MirMesaEGLNativeSurface* surface, int interval) |
548 | +{ |
549 | + //TODO: |
550 | + (void) surface; |
551 | + (void) interval; |
552 | + return MIR_MESA_TRUE; |
553 | +} |
554 | |
555 | === added file 'src/server/graphics/gbm/internal_native_surface.h' |
556 | --- src/server/graphics/gbm/internal_native_surface.h 1970-01-01 00:00:00 +0000 |
557 | +++ src/server/graphics/gbm/internal_native_surface.h 2013-06-18 01:07:24 +0000 |
558 | @@ -0,0 +1,62 @@ |
559 | +/* |
560 | + * Copyright © 2013 Canonical Ltd. |
561 | + * |
562 | + * This program is free software: you can redistribute it and/or modify it |
563 | + * under the terms of the GNU General Public License version 3, |
564 | + * as published by the Free Software Foundation. |
565 | + * |
566 | + * This program is distributed in the hope that it will be useful, |
567 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
568 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
569 | + * GNU General Public License for more details. |
570 | + * |
571 | + * You should have received a copy of the GNU General Public License |
572 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
573 | + * |
574 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
575 | + */ |
576 | + |
577 | +#ifndef MIR_GRAPHICS_GBM_INTERNAL_NATIVE_SURFACE_H_ |
578 | +#define MIR_GRAPHICS_GBM_INTERNAL_NATIVE_SURFACE_H_ |
579 | + |
580 | +#include "mir_toolkit/mesa/native_display.h" |
581 | +#include <memory> |
582 | + |
583 | +namespace mir |
584 | +{ |
585 | +namespace frontend |
586 | +{ |
587 | +class Surface; |
588 | +} |
589 | +namespace compositor |
590 | +{ |
591 | +class Buffer; |
592 | +} |
593 | +namespace graphics |
594 | +{ |
595 | +namespace gbm |
596 | +{ |
597 | + |
598 | +class InternalNativeSurface : public MirMesaEGLNativeSurface |
599 | +{ |
600 | +public: |
601 | + InternalNativeSurface(std::shared_ptr<frontend::Surface> const& surface); |
602 | + |
603 | + int advance_buffer(MirBufferPackage* package); |
604 | + int get_parameters(MirSurfaceParameters* parameters); |
605 | + |
606 | +private: |
607 | + static int set_swapinterval_static(MirMesaEGLNativeSurface* surface, int interval); |
608 | + static int advance_buffer_static(MirMesaEGLNativeSurface* surface, |
609 | + MirBufferPackage* package); |
610 | + static int get_parameters_static(MirMesaEGLNativeSurface* surface, |
611 | + MirSurfaceParameters* parameters); |
612 | + |
613 | + std::shared_ptr<frontend::Surface> surface; |
614 | + std::shared_ptr<compositor::Buffer> current_buffer; |
615 | +}; |
616 | + |
617 | +} |
618 | +} |
619 | +} |
620 | +#endif /* MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_ */ |
621 | |
622 | === modified file 'tests/unit-tests/client/gbm/CMakeLists.txt' |
623 | --- tests/unit-tests/client/gbm/CMakeLists.txt 2013-03-24 23:33:49 +0000 |
624 | +++ tests/unit-tests/client/gbm/CMakeLists.txt 2013-06-18 01:07:24 +0000 |
625 | @@ -19,6 +19,7 @@ |
626 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_client_buffer.cpp |
627 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_client_platform.cpp |
628 | ${CMAKE_CURRENT_SOURCE_DIR}/test_mesa_native_display_container.cpp |
629 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_native_surface.cpp |
630 | ) |
631 | |
632 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
633 | |
634 | === modified file 'tests/unit-tests/client/gbm/test_gbm_client_platform.cpp' |
635 | --- tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-05-08 17:52:49 +0000 |
636 | +++ tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-06-18 01:07:24 +0000 |
637 | @@ -29,17 +29,6 @@ |
638 | namespace mt = mir::test; |
639 | namespace mtd = mir::test::doubles; |
640 | |
641 | -TEST(GBMClientPlatformTest, egl_native_window_is_client_surface) |
642 | -{ |
643 | - mtd::MockClientContext context; |
644 | - mcl::NativeClientPlatformFactory factory; |
645 | - mtd::MockClientSurface surface; |
646 | - auto platform = factory.create_client_platform(&context); |
647 | - auto mock_client_surface = std::make_shared<mtd::MockClientSurface>(); |
648 | - auto native_window = platform->create_egl_native_window(&surface); |
649 | - EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(&surface), *native_window); |
650 | -} |
651 | - |
652 | /* TODO: mir_egl_mesa_display_is_valid is a bit fragile because libmirserver and libmirclient both have very |
653 | * different implementations and both have symbols for it. If the linking order of the test changes, |
654 | * specifically, if mir_egl_mesa_display_is_valid resolves into libmirserver, then this test will break. |
655 | |
656 | === added file 'tests/unit-tests/client/gbm/test_native_surface.cpp' |
657 | --- tests/unit-tests/client/gbm/test_native_surface.cpp 1970-01-01 00:00:00 +0000 |
658 | +++ tests/unit-tests/client/gbm/test_native_surface.cpp 2013-06-18 01:07:24 +0000 |
659 | @@ -0,0 +1,114 @@ |
660 | +/* |
661 | + * Copyright © 2013 Canonical Ltd. |
662 | + * |
663 | + * This program is free software: you can redistribute it and/or modify |
664 | + * it under the terms of the GNU General Public License version 3 as |
665 | + * published by the Free Software Foundation. |
666 | + * |
667 | + * This program is distributed in the hope that it will be useful, |
668 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
669 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
670 | + * GNU General Public License for more details. |
671 | + * |
672 | + * You should have received a copy of the GNU General Public License |
673 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
674 | + * |
675 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
676 | + */ |
677 | + |
678 | +#include "src/client/gbm/gbm_native_surface.h" |
679 | +#include "src/client/client_buffer.h" |
680 | +#include <gmock/gmock.h> |
681 | +#include <gtest/gtest.h> |
682 | + |
683 | +namespace mcl=mir::client; |
684 | +namespace mcl=mir::client; |
685 | +namespace mclg=mir::client::gbm; |
686 | +namespace geom=mir::geometry; |
687 | + |
688 | +namespace |
689 | +{ |
690 | + |
691 | +struct MockClientBuffer : public mcl::ClientBuffer |
692 | +{ |
693 | + MockClientBuffer() |
694 | + { |
695 | + ON_CALL(*this, native_buffer_handle()) |
696 | + .WillByDefault(testing::Return(std::make_shared<MirBufferPackage>())); |
697 | + } |
698 | + ~MockClientBuffer() noexcept {} |
699 | + |
700 | + MOCK_METHOD0(secure_for_cpu_write, std::shared_ptr<mcl::MemoryRegion>()); |
701 | + MOCK_CONST_METHOD0(size, geom::Size()); |
702 | + MOCK_CONST_METHOD0(stride, geom::Stride()); |
703 | + MOCK_CONST_METHOD0(pixel_format, geom::PixelFormat()); |
704 | + |
705 | + MOCK_CONST_METHOD0(age, uint32_t()); |
706 | + MOCK_METHOD0(mark_as_submitted, void()); |
707 | + MOCK_METHOD0(increment_age, void()); |
708 | + |
709 | + MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<MirNativeBuffer>()); |
710 | +}; |
711 | + |
712 | +struct MockMirSurface : public mcl::ClientSurface |
713 | +{ |
714 | + MockMirSurface(MirSurfaceParameters params) |
715 | + : params(params) |
716 | + { |
717 | + using namespace testing; |
718 | + ON_CALL(*this, get_parameters()) |
719 | + .WillByDefault(Return(params)); |
720 | + ON_CALL(*this, get_current_buffer()) |
721 | + .WillByDefault(Return( |
722 | + std::make_shared<NiceMock<MockClientBuffer>>())); |
723 | + } |
724 | + |
725 | + MOCK_CONST_METHOD0(get_parameters, MirSurfaceParameters()); |
726 | + MOCK_METHOD0(get_current_buffer, std::shared_ptr<mcl::ClientBuffer>()); |
727 | + MOCK_METHOD2(next_buffer, MirWaitHandle*(mir_surface_lifecycle_callback callback, void * context)); |
728 | + |
729 | + MirSurfaceParameters params; |
730 | +}; |
731 | +} |
732 | + |
733 | +class GBMInterpreterTest : public ::testing::Test |
734 | +{ |
735 | +public: |
736 | + virtual void SetUp() |
737 | + { |
738 | + using namespace testing; |
739 | + surf_params.width = 530; |
740 | + surf_params.height = 715; |
741 | + surf_params.pixel_format = mir_pixel_format_abgr_8888; |
742 | + |
743 | + buffer = std::make_shared<MirBufferPackage>(); |
744 | + } |
745 | + |
746 | + std::shared_ptr<MirBufferPackage> buffer; |
747 | + MirSurfaceParameters surf_params; |
748 | +}; |
749 | + |
750 | +TEST_F(GBMInterpreterTest, basic_parameters) |
751 | +{ |
752 | + testing::NiceMock<MockMirSurface> mock_surface{surf_params}; |
753 | + mclg::GBMNativeSurface interpreter(mock_surface); |
754 | + |
755 | + MirSurfaceParameters params; |
756 | + interpreter.surface_get_parameters(&interpreter, ¶ms); |
757 | +} |
758 | + |
759 | +TEST_F(GBMInterpreterTest, basic_advance) |
760 | +{ |
761 | + using namespace testing; |
762 | + testing::NiceMock<MockMirSurface> mock_surface{surf_params}; |
763 | + |
764 | + mclg::GBMNativeSurface interpreter(mock_surface); |
765 | + |
766 | + EXPECT_CALL(mock_surface, next_buffer(_,_)) |
767 | + .Times(1); |
768 | + EXPECT_CALL(mock_surface, get_current_buffer()) |
769 | + .Times(1); |
770 | + |
771 | + MirBufferPackage buffer_package; |
772 | + interpreter.surface_advance_buffer(&interpreter, &buffer_package); |
773 | +} |
774 | |
775 | === modified file 'tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp' |
776 | --- tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 2013-05-09 18:26:45 +0000 |
777 | +++ tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 2013-06-18 01:07:24 +0000 |
778 | @@ -147,3 +147,9 @@ |
779 | auto rc_format = interpreter.driver_requests_info(NATIVE_WINDOW_FORMAT); |
780 | EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, rc_format); |
781 | } |
782 | + |
783 | +TEST_F(InternalClientWindow, window_holds_buffer_resource_for_driver) |
784 | +{ |
785 | + mga::InternalClientWindow interpreter(mock_surface, mock_cache); |
786 | + |
787 | +} |
788 | |
789 | === modified file 'tests/unit-tests/graphics/gbm/CMakeLists.txt' |
790 | --- tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-05-08 17:26:17 +0000 |
791 | +++ tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-06-18 01:07:24 +0000 |
792 | @@ -10,6 +10,7 @@ |
793 | ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_page_flipper.cpp |
794 | ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp |
795 | ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_display.cpp |
796 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_surface.cpp |
797 | ) |
798 | |
799 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
800 | |
801 | === modified file 'tests/unit-tests/graphics/gbm/test_internal_client.cpp' |
802 | --- tests/unit-tests/graphics/gbm/test_internal_client.cpp 2013-05-14 16:45:25 +0000 |
803 | +++ tests/unit-tests/graphics/gbm/test_internal_client.cpp 2013-06-18 01:07:24 +0000 |
804 | @@ -19,6 +19,7 @@ |
805 | #include "mir/frontend/surface.h" |
806 | #include "mir_toolkit/mesa/native_display.h" |
807 | #include "src/server/graphics/gbm/internal_client.h" |
808 | +#include "src/server/graphics/gbm/internal_native_surface.h" |
809 | #include "mir_test_doubles/stub_platform.h" |
810 | #include "mir_test_doubles/stub_surface.h" |
811 | |
812 | @@ -29,15 +30,24 @@ |
813 | namespace mgg=mir::graphics::gbm; |
814 | namespace mtd=mir::test::doubles; |
815 | |
816 | -TEST(InternalClient, native_display) |
817 | +TEST(InternalClient, native_display_sanity) |
818 | { |
819 | - auto stub_window = std::make_shared<mtd::StubSurface>(); |
820 | auto stub_display = std::make_shared<MirMesaEGLNativeDisplay>(); |
821 | mgg::InternalClient client(stub_display); |
822 | |
823 | auto native_display = client.egl_native_display(); |
824 | - auto native_window = client.egl_native_window(stub_window); |
825 | - |
826 | EXPECT_EQ(reinterpret_cast<EGLNativeDisplayType>(stub_display.get()), native_display); |
827 | - EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(stub_window.get()), native_window); |
828 | +} |
829 | + |
830 | +TEST(InternalClient, native_surface_sanity) |
831 | +{ |
832 | + auto stub_display = std::make_shared<MirMesaEGLNativeDisplay>(); |
833 | + mgg::InternalClient client(stub_display); |
834 | + |
835 | + auto stub_window = std::make_shared<mtd::StubSurface>(); |
836 | + auto native_window = static_cast<mgg::InternalNativeSurface*>(client.egl_native_window(stub_window)); |
837 | + |
838 | + ASSERT_NE(nullptr, native_window->surface_advance_buffer); |
839 | + ASSERT_NE(nullptr, native_window->surface_get_parameters); |
840 | + ASSERT_NE(nullptr, native_window->surface_set_swapinterval); |
841 | } |
842 | |
843 | === modified file 'tests/unit-tests/graphics/gbm/test_internal_native_display.cpp' |
844 | --- tests/unit-tests/graphics/gbm/test_internal_native_display.cpp 2013-05-14 22:27:33 +0000 |
845 | +++ tests/unit-tests/graphics/gbm/test_internal_native_display.cpp 2013-06-18 01:07:24 +0000 |
846 | @@ -43,10 +43,6 @@ |
847 | |
848 | struct InternalNativeDisplay : public testing::Test |
849 | { |
850 | - InternalNativeDisplay() |
851 | - { |
852 | - } |
853 | - |
854 | void SetUp() |
855 | { |
856 | using namespace ::testing; |
857 | @@ -75,24 +71,6 @@ |
858 | } |
859 | return true; |
860 | } |
861 | - |
862 | -MATCHER_P(StrideMatches, package, "") |
863 | -{ |
864 | - if (arg.stride != package->stride) |
865 | - { |
866 | - return false; |
867 | - } |
868 | - return true; |
869 | -} |
870 | - |
871 | -MATCHER_P(ParametersHaveSize, size, "") |
872 | -{ |
873 | - if (static_cast<uint32_t>(arg.width) != size.width.as_uint32_t()) |
874 | - return false; |
875 | - if (static_cast<uint32_t>(arg.height) != size.height.as_uint32_t()) |
876 | - return false; |
877 | - return true; |
878 | -} |
879 | } |
880 | |
881 | TEST_F(InternalNativeDisplay, display_get_platform_matches_construction_platform) |
882 | @@ -107,84 +85,6 @@ |
883 | EXPECT_THAT(test_package, PackageMatches(platform_package)); |
884 | } |
885 | |
886 | -TEST_F(InternalNativeDisplay, surface_get_current_buffer) |
887 | -{ |
888 | - using namespace ::testing; |
889 | - |
890 | - mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
891 | - auto buffer = std::make_shared<mtd::MockBuffer>(geom::Size(), geom::Stride(), geom::PixelFormat()); |
892 | - |
893 | - auto test_buffer_package = std::make_shared<MirBufferPackage>(); |
894 | - |
895 | - test_buffer_package->data_items = 2; |
896 | - test_buffer_package->data[0] = 1; |
897 | - test_buffer_package->data[1] = 2; |
898 | - test_buffer_package->fd_items = 2; |
899 | - test_buffer_package->fd[0] = 3; |
900 | - test_buffer_package->fd[1] = 4; |
901 | - test_buffer_package->stride = 77; |
902 | - |
903 | - mgg::InternalNativeDisplay native_display(platform_package); |
904 | - |
905 | - EXPECT_CALL(*buffer, native_buffer_handle()) |
906 | - .WillOnce(Return(test_buffer_package)); |
907 | - EXPECT_CALL(surface, client_buffer()).Times(1) |
908 | - .WillOnce(Return(buffer)); |
909 | - |
910 | - MirBufferPackage buffer_package; |
911 | - memset(&buffer_package, 0, sizeof(MirBufferPackage)); |
912 | - native_display.surface_get_current_buffer( |
913 | - &native_display, static_cast<MirEGLNativeWindowType>(&surface), &buffer_package); |
914 | - |
915 | - EXPECT_EQ(test_buffer_package->data_items, buffer_package.data_items); |
916 | - EXPECT_EQ(test_buffer_package->data[0], buffer_package.data[0]); |
917 | - EXPECT_EQ(test_buffer_package->data[1], buffer_package.data[1]); |
918 | - EXPECT_EQ(test_buffer_package->fd_items, buffer_package.fd_items); |
919 | - EXPECT_EQ(test_buffer_package->fd[0], buffer_package.fd[0]); |
920 | - EXPECT_EQ(test_buffer_package->fd[1], buffer_package.fd[1]); |
921 | - EXPECT_EQ(test_buffer_package->stride, buffer_package.stride); |
922 | -} |
923 | - |
924 | -TEST_F(InternalNativeDisplay, surface_advance_buffer) |
925 | -{ |
926 | - using namespace ::testing; |
927 | - |
928 | - mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
929 | - |
930 | - mgg::InternalNativeDisplay native_display(platform_package); |
931 | - |
932 | - EXPECT_CALL(surface, advance_client_buffer()).Times(1); |
933 | - |
934 | - native_display.surface_advance_buffer( |
935 | - &native_display, static_cast<MirEGLNativeWindowType>(&surface)); |
936 | -} |
937 | - |
938 | -TEST_F(InternalNativeDisplay, surface_get_parameters) |
939 | -{ |
940 | - using namespace ::testing; |
941 | - |
942 | - geom::Size const test_surface_size = geom::Size{geom::Width{17}, |
943 | - geom::Height{29}}; |
944 | - geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888; |
945 | - |
946 | - mgg::InternalNativeDisplay native_display(platform_package); |
947 | - |
948 | - mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
949 | - EXPECT_CALL(surface, size()).Times(AtLeast(1)).WillRepeatedly(Return(test_surface_size)); |
950 | - EXPECT_CALL(surface, pixel_format()).Times(AtLeast(1)).WillRepeatedly(Return(test_pixel_format)); |
951 | - |
952 | - MirSurfaceParameters parameters; |
953 | - memset(¶meters, 0, sizeof(MirSurfaceParameters)); |
954 | - native_display.surface_get_parameters( |
955 | - &native_display, static_cast<MirEGLNativeWindowType>(&surface), ¶meters); |
956 | - |
957 | - EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size)); |
958 | - EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888)); |
959 | - |
960 | - // TODO: What to do about buffer usage besides hardware? ~racarr |
961 | - EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware); |
962 | -} |
963 | - |
964 | TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable) |
965 | { |
966 | EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid); |
967 | |
968 | === added file 'tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp' |
969 | --- tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp 1970-01-01 00:00:00 +0000 |
970 | +++ tests/unit-tests/graphics/gbm/test_internal_native_surface.cpp 2013-06-18 01:07:24 +0000 |
971 | @@ -0,0 +1,170 @@ |
972 | +/* |
973 | + * Copyright © 2013 Canonical Ltd. |
974 | + * |
975 | + * This program is free software: you can redistribute it and/or modify |
976 | + * it under the terms of the GNU General Public License version 3 as |
977 | + * published by the Free Software Foundation. |
978 | + * |
979 | + * This program is distributed in the hope that it will be useful, |
980 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
981 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
982 | + * GNU General Public License for more details. |
983 | + * |
984 | + * You should have received a copy of the GNU General Public License |
985 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
986 | + * |
987 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
988 | + */ |
989 | + |
990 | +#include "src/server/graphics/gbm/internal_native_surface.h" |
991 | +#include "mir/graphics/platform.h" |
992 | +#include "mir/graphics/platform_ipc_package.h" |
993 | +#include "mir/frontend/surface.h" |
994 | + |
995 | +#include "mir_toolkit/mesa/native_display.h" |
996 | + |
997 | +#include "mir_test/fake_shared.h" |
998 | +#include "mir_test_doubles/stub_surface_builder.h" |
999 | +#include "mir_test_doubles/mock_surface.h" |
1000 | +#include "mir_test_doubles/mock_buffer.h" |
1001 | + |
1002 | +#include <gtest/gtest.h> |
1003 | +#include <gmock/gmock.h> |
1004 | + |
1005 | +namespace mg = mir::graphics; |
1006 | +namespace mgg = mir::graphics::gbm; |
1007 | +namespace mc = mir::compositor; |
1008 | +namespace msh = mir::shell; |
1009 | +namespace geom = mir::geometry; |
1010 | +namespace mt = mir::test; |
1011 | +namespace mtd = mt::doubles; |
1012 | + |
1013 | +namespace |
1014 | +{ |
1015 | + |
1016 | + |
1017 | +class MockFrontendSurface : public mir::frontend::Surface |
1018 | +{ |
1019 | +public: |
1020 | + MOCK_METHOD0(destroy, void()); |
1021 | + MOCK_METHOD0(force_requests_to_complete, void()); |
1022 | + MOCK_CONST_METHOD0(size, geom::Size()); |
1023 | + MOCK_CONST_METHOD0(pixel_format, geom::PixelFormat()); |
1024 | + MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer>()); |
1025 | + MOCK_METHOD0(advance_client_buffer, void()); |
1026 | + MOCK_CONST_METHOD0(supports_input, bool()); |
1027 | + MOCK_CONST_METHOD0(client_input_fd, int()); |
1028 | + MOCK_METHOD2(configure, int(MirSurfaceAttrib, int)); |
1029 | +}; |
1030 | + |
1031 | +struct InternalNativeSurface : public testing::Test |
1032 | +{ |
1033 | + void SetUp() |
1034 | + { |
1035 | + using namespace ::testing; |
1036 | + mock_surface = std::make_shared<MockFrontendSurface>(); |
1037 | + } |
1038 | + |
1039 | + std::shared_ptr<MockFrontendSurface> mock_surface; |
1040 | +}; |
1041 | + |
1042 | +MATCHER_P(ParametersHaveSize, size, "") |
1043 | +{ |
1044 | + if (static_cast<uint32_t>(arg.width) != size.width.as_uint32_t()) |
1045 | + return false; |
1046 | + if (static_cast<uint32_t>(arg.height) != size.height.as_uint32_t()) |
1047 | + return false; |
1048 | + return true; |
1049 | +} |
1050 | +} |
1051 | + |
1052 | +TEST_F(InternalNativeSurface, surface_advance_buffer_packaging) |
1053 | +{ |
1054 | + using namespace ::testing; |
1055 | + |
1056 | + auto buffer = std::make_shared<mtd::MockBuffer>(); |
1057 | + |
1058 | + auto test_buffer_package = std::make_shared<MirBufferPackage>(); |
1059 | + test_buffer_package->data_items = 2; |
1060 | + test_buffer_package->data[0] = 1; |
1061 | + test_buffer_package->data[1] = 2; |
1062 | + test_buffer_package->fd_items = 2; |
1063 | + test_buffer_package->fd[0] = 3; |
1064 | + test_buffer_package->fd[1] = 4; |
1065 | + test_buffer_package->stride = 77; |
1066 | + |
1067 | + mgg::InternalNativeSurface native_surface(mock_surface); |
1068 | + |
1069 | + EXPECT_CALL(*buffer, native_buffer_handle()) |
1070 | + .WillOnce(Return(test_buffer_package)); |
1071 | + EXPECT_CALL(*mock_surface, client_buffer()) |
1072 | + .Times(1) |
1073 | + .WillOnce(Return(buffer)); |
1074 | + |
1075 | + MirBufferPackage buffer_package; |
1076 | + memset(&buffer_package, 0, sizeof(MirBufferPackage)); |
1077 | + native_surface.surface_advance_buffer(&native_surface, &buffer_package); |
1078 | + |
1079 | + EXPECT_EQ(test_buffer_package->data_items, buffer_package.data_items); |
1080 | + EXPECT_EQ(test_buffer_package->data[0], buffer_package.data[0]); |
1081 | + EXPECT_EQ(test_buffer_package->data[1], buffer_package.data[1]); |
1082 | + EXPECT_EQ(test_buffer_package->fd_items, buffer_package.fd_items); |
1083 | + EXPECT_EQ(test_buffer_package->fd[0], buffer_package.fd[0]); |
1084 | + EXPECT_EQ(test_buffer_package->fd[1], buffer_package.fd[1]); |
1085 | + EXPECT_EQ(test_buffer_package->stride, buffer_package.stride); |
1086 | +} |
1087 | + |
1088 | +TEST_F(InternalNativeSurface, surface_advance_buffer_secures_resource) |
1089 | +{ |
1090 | + using namespace ::testing; |
1091 | + mgg::InternalNativeSurface native_surface(mock_surface); |
1092 | + auto stub_buffer1 = std::make_shared<mtd::MockBuffer>(); |
1093 | + auto stub_buffer2 = std::make_shared<mtd::MockBuffer>(); |
1094 | + |
1095 | + auto test_buffer_package = std::make_shared<MirBufferPackage>(); |
1096 | + EXPECT_CALL(*stub_buffer1, native_buffer_handle()) |
1097 | + .WillOnce(Return(test_buffer_package)); |
1098 | + EXPECT_CALL(*stub_buffer2, native_buffer_handle()) |
1099 | + .WillOnce(Return(test_buffer_package)); |
1100 | + EXPECT_CALL(*mock_surface, client_buffer()) |
1101 | + .Times(2) |
1102 | + .WillOnce(Return(stub_buffer1)) |
1103 | + .WillOnce(Return(stub_buffer2)); |
1104 | + |
1105 | + auto use_count_1 = stub_buffer1.use_count(); |
1106 | + auto use_count_2 = stub_buffer2.use_count(); |
1107 | + |
1108 | + MirBufferPackage buffer_package; |
1109 | + native_surface.surface_advance_buffer(&native_surface, &buffer_package); |
1110 | + EXPECT_EQ(use_count_1 + 1, stub_buffer1.use_count()); |
1111 | + |
1112 | + native_surface.surface_advance_buffer(&native_surface, &buffer_package); |
1113 | + EXPECT_EQ(use_count_1, stub_buffer1.use_count()); |
1114 | + EXPECT_EQ(use_count_2 + 1, stub_buffer2.use_count()); |
1115 | +} |
1116 | + |
1117 | +TEST_F(InternalNativeSurface, surface_get_parameters) |
1118 | +{ |
1119 | + using namespace ::testing; |
1120 | + |
1121 | + geom::Size const test_surface_size = geom::Size{geom::Width{17}, |
1122 | + geom::Height{29}}; |
1123 | + geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888; |
1124 | + EXPECT_CALL(*mock_surface, size()) |
1125 | + .Times(1) |
1126 | + .WillOnce(Return(test_surface_size)); |
1127 | + EXPECT_CALL(*mock_surface, pixel_format()) |
1128 | + .Times(1) |
1129 | + .WillOnce(Return(test_pixel_format)); |
1130 | + |
1131 | + mgg::InternalNativeSurface native_surface(mock_surface); |
1132 | + |
1133 | + MirSurfaceParameters parameters; |
1134 | + memset(¶meters, 0, sizeof(MirSurfaceParameters)); |
1135 | + native_surface.surface_get_parameters(&native_surface, ¶meters); |
1136 | + |
1137 | + EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size)); |
1138 | + EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888)); |
1139 | + // TODO: What to do about buffer usage besides hardware? ~racarr |
1140 | + EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware); |
1141 | +} |
if you navigate over to github, you'll see the platform driver cleanup removes "mir_client_ library. h", so the driver doesn't have to worry about any ipc stuff.
also, @l46, note that gbm is 'inprocess egl/internal client' agnostic. (the driver doesn't care if ipc is involved or not, as long as it gets buffers)
the rough edges, (which hopefully are ok) are mesa/native_ display. h has some #defines, this is because this file must be C-compatible for mesa. platform. cpp has some awkwardness, this is what android does and is a pre-existing issue with this interface for acquiring a native window type on the client side.
1) Since mir_toolkit/
2) gbm_client_