Merge lp:~kdub/mir/android-egl-extensions into lp:~mir-team/mir/trunk
- android-egl-extensions
- Merge into trunk
Proposed by
Kevin DuBois
Status: | Merged |
---|---|
Approved by: | Kevin DuBois |
Approved revision: | no longer in the source branch. |
Merged at revision: | 745 |
Proposed branch: | lp:~kdub/mir/android-egl-extensions |
Merge into: | lp:~mir-team/mir/trunk |
Prerequisite: | lp:~mir-team/mir/saucy-android |
Diff against target: |
1220 lines (+348/-258) 21 files modified
examples/demo_client_accelerated.cpp (+0/-3) include/server/mir/graphics/egl_extensions.h (+43/-0) include/test/mir_test_doubles/mock_egl.h (+4/-1) include/test/mir_test_doubles/mock_gl.h (+0/-5) src/server/graphics/CMakeLists.txt (+1/-0) src/server/graphics/android/android_buffer_allocator.cpp (+5/-2) src/server/graphics/android/android_graphic_buffer_allocator.h (+2/-0) src/server/graphics/android/buffer.cpp (+10/-20) src/server/graphics/android/buffer.h (+4/-3) src/server/graphics/egl_extensions.cpp (+42/-0) src/server/graphics/gbm/gbm_buffer_allocator.cpp (+4/-39) src/server/graphics/gbm/gbm_buffer_allocator.h (+1/-2) tests/mir_test_doubles/mock_egl.cpp (+38/-10) tests/mir_test_doubles/mock_gl.cpp (+0/-9) tests/unit-tests/graphics/CMakeLists.txt (+1/-0) tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+2/-0) tests/unit-tests/graphics/android/test_buffer.cpp (+10/-21) tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp (+105/-95) tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp (+1/-10) tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp (+0/-38) tests/unit-tests/graphics/test_egl_extensions.cpp (+75/-0) |
To merge this branch: | bzr merge lp:~kdub/mir/android-egl-extensions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Carr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+169533@code.launchpad.net |
Commit message
Android was accessing the egl extension functions directly instead of using eglGetProcAddress() to get them. This caused linking problems. Re-use gbm code that uses eglGetProgAddress so android uses the extensions correctly
fixes: lp:1189938
Description of the change
Android was accessing the egl extension functions directly instead of using eglGetProcAddress() to get them. This caused linking problems. Re-use gbm code that uses eglGetProgAddress so android uses the extensions correctly
fixes: lp:1189938
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote : | # |
switching to approve, since its blocking saucy progress, and should be pretty non-controversial :)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'examples/demo_client_accelerated.cpp' |
2 | --- examples/demo_client_accelerated.cpp 2013-06-13 06:00:21 +0000 |
3 | +++ examples/demo_client_accelerated.cpp 2013-06-14 20:23:35 +0000 |
4 | @@ -127,9 +127,6 @@ |
5 | gl_animation.render_gl(); |
6 | rc = eglSwapBuffers(disp, egl_surface); |
7 | assert(rc == EGL_TRUE); |
8 | - |
9 | - usleep(167);//60fps |
10 | - |
11 | gl_animation.step(); |
12 | } |
13 | |
14 | |
15 | === added file 'include/server/mir/graphics/egl_extensions.h' |
16 | --- include/server/mir/graphics/egl_extensions.h 1970-01-01 00:00:00 +0000 |
17 | +++ include/server/mir/graphics/egl_extensions.h 2013-06-14 20:23:35 +0000 |
18 | @@ -0,0 +1,43 @@ |
19 | +/* |
20 | + * Copyright © 2013 Canonical Ltd. |
21 | + * |
22 | + * This program is free software: you can redistribute it and/or modify it |
23 | + * under the terms of the GNU General Public License version 3, |
24 | + * as published by the Free Software Foundation. |
25 | + * |
26 | + * This program is distributed in the hope that it will be useful, |
27 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
28 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
29 | + * GNU General Public License for more details. |
30 | + * |
31 | + * You should have received a copy of the GNU General Public License |
32 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
33 | + * |
34 | + * Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> |
35 | + */ |
36 | + |
37 | +#ifndef MIR_GRAPHICS_EGL_EXTENSIONS_H_ |
38 | +#define MIR_GRAPHICS_EGL_EXTENSIONS_H_ |
39 | + |
40 | +#define GL_GLEXT_PROTOTYPES |
41 | +#define EGL_EGLEXT_PROTOTYPES |
42 | +#include <EGL/egl.h> |
43 | +#include <EGL/eglext.h> |
44 | +#include <GLES2/gl2.h> |
45 | +#include <GLES2/gl2ext.h> |
46 | + |
47 | +namespace mir |
48 | +{ |
49 | +namespace graphics |
50 | +{ |
51 | +struct EGLExtensions |
52 | +{ |
53 | + EGLExtensions(); |
54 | + PFNEGLCREATEIMAGEKHRPROC const eglCreateImageKHR; |
55 | + PFNEGLDESTROYIMAGEKHRPROC const eglDestroyImageKHR; |
56 | + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC const glEGLImageTargetTexture2DOES; |
57 | +}; |
58 | +} |
59 | +} |
60 | + |
61 | +#endif /* MIR_GRAPHICS_EGL_EXTENSIONS_H_ */ |
62 | |
63 | === modified file 'include/test/mir_test_doubles/mock_egl.h' |
64 | --- include/test/mir_test_doubles/mock_egl.h 2013-05-20 15:55:48 +0000 |
65 | +++ include/test/mir_test_doubles/mock_egl.h 2013-06-14 20:23:35 +0000 |
66 | @@ -25,6 +25,9 @@ |
67 | #define EGL_EGLEXT_PROTOTYPES |
68 | #include <EGL/egl.h> |
69 | #include <EGL/eglext.h> |
70 | +//for GL extensions |
71 | +#include <GLES2/gl2.h> |
72 | +#include <GLES2/gl2ext.h> |
73 | |
74 | namespace mir |
75 | { |
76 | @@ -84,9 +87,9 @@ |
77 | |
78 | MOCK_METHOD0(eglGetError, EGLint (void)); |
79 | |
80 | - /* extensions */ |
81 | MOCK_METHOD5(eglCreateImageKHR, EGLImageKHR(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*)); |
82 | MOCK_METHOD2(eglDestroyImageKHR,EGLBoolean(EGLDisplay, EGLImageKHR)); |
83 | + MOCK_METHOD2(glEGLImageTargetTexture2DOES, void(GLenum, GLeglImageOES)); |
84 | |
85 | EGLDisplay fake_egl_display; |
86 | EGLConfig* fake_configs; |
87 | |
88 | === modified file 'include/test/mir_test_doubles/mock_gl.h' |
89 | --- include/test/mir_test_doubles/mock_gl.h 2013-05-20 15:55:48 +0000 |
90 | +++ include/test/mir_test_doubles/mock_gl.h 2013-06-14 20:23:35 +0000 |
91 | @@ -20,11 +20,7 @@ |
92 | #define MIR_TEST_DOUBLES_MOCK_GL_H_ |
93 | |
94 | #include <gmock/gmock.h> |
95 | - |
96 | -#define GL_GLEXT_PROTOTYPES |
97 | -#define EGL_EGLEXT_PROTOTYPES |
98 | #include <GLES2/gl2.h> |
99 | -#include <GLES2/gl2ext.h> |
100 | |
101 | namespace mir |
102 | { |
103 | @@ -40,7 +36,6 @@ |
104 | ~MockGL(); |
105 | void silence_uninteresting(); |
106 | |
107 | - MOCK_METHOD2(glEGLImageTargetTexture2DOES, void(GLenum, GLeglImageOES)); |
108 | MOCK_METHOD1(glGetString, const GLubyte*(GLenum)); |
109 | MOCK_METHOD1(glUseProgram, void (GLuint)); |
110 | MOCK_METHOD1(glEnable, void (GLenum)); |
111 | |
112 | === modified file 'src/server/graphics/CMakeLists.txt' |
113 | --- src/server/graphics/CMakeLists.txt 2013-05-08 17:22:54 +0000 |
114 | +++ src/server/graphics/CMakeLists.txt 2013-06-14 20:23:35 +0000 |
115 | @@ -15,6 +15,7 @@ |
116 | GRAPHICS_SOURCES |
117 | |
118 | gl_renderer.cpp |
119 | + egl_extensions.cpp |
120 | display_configuration.cpp |
121 | null_display_report.cpp |
122 | ) |
123 | |
124 | === modified file 'src/server/graphics/android/android_buffer_allocator.cpp' |
125 | --- src/server/graphics/android/android_buffer_allocator.cpp 2013-05-01 22:05:55 +0000 |
126 | +++ src/server/graphics/android/android_buffer_allocator.cpp 2013-06-14 20:23:35 +0000 |
127 | @@ -19,6 +19,7 @@ |
128 | |
129 | #include "mir/graphics/platform.h" |
130 | #include "mir/graphics/buffer_initializer.h" |
131 | +#include "mir/graphics/egl_extensions.h" |
132 | #include "mir/compositor/buffer_properties.h" |
133 | #include "android_graphic_buffer_allocator.h" |
134 | #include "android_alloc_adaptor.h" |
135 | @@ -47,7 +48,8 @@ |
136 | |
137 | mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator( |
138 | std::shared_ptr<BufferInitializer> const& buffer_initializer) |
139 | - : buffer_initializer{buffer_initializer} |
140 | + : buffer_initializer(buffer_initializer), |
141 | + egl_extensions(std::make_shared<mg::EGLExtensions>()) |
142 | { |
143 | int err; |
144 | |
145 | @@ -78,7 +80,8 @@ |
146 | std::shared_ptr<mga::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer_platform( |
147 | geom::Size sz, geom::PixelFormat pf, mga::BufferUsage use) |
148 | { |
149 | - auto buffer = std::make_shared<Buffer>(alloc_device, sz, pf, use); |
150 | + auto native_handle = alloc_device->alloc_buffer(sz, pf, use); |
151 | + auto buffer = std::make_shared<Buffer>(native_handle, egl_extensions); |
152 | (*buffer_initializer)(*buffer); |
153 | return buffer; |
154 | } |
155 | |
156 | === modified file 'src/server/graphics/android/android_graphic_buffer_allocator.h' |
157 | --- src/server/graphics/android/android_graphic_buffer_allocator.h 2013-05-24 15:51:37 +0000 |
158 | +++ src/server/graphics/android/android_graphic_buffer_allocator.h 2013-06-14 20:23:35 +0000 |
159 | @@ -32,6 +32,7 @@ |
160 | { |
161 | |
162 | class BufferInitializer; |
163 | +class EGLExtensions; |
164 | |
165 | namespace android |
166 | { |
167 | @@ -58,6 +59,7 @@ |
168 | const hw_module_t *hw_module; |
169 | std::shared_ptr<GraphicAllocAdaptor> alloc_device; |
170 | std::shared_ptr<BufferInitializer> const buffer_initializer; |
171 | + std::shared_ptr<EGLExtensions> const egl_extensions; |
172 | }; |
173 | |
174 | } |
175 | |
176 | === modified file 'src/server/graphics/android/buffer.cpp' |
177 | --- src/server/graphics/android/buffer.cpp 2013-06-12 09:36:20 +0000 |
178 | +++ src/server/graphics/android/buffer.cpp 2013-06-14 20:23:35 +0000 |
179 | @@ -17,9 +17,9 @@ |
180 | * Kevin DuBois <kevin.dubois@canonical.com> |
181 | */ |
182 | |
183 | +#include "mir/graphics/egl_extensions.h" |
184 | +#include "android_format_conversion-inl.h" |
185 | #include "buffer.h" |
186 | -#include "graphic_alloc_adaptor.h" |
187 | -#include "android_format_conversion-inl.h" |
188 | |
189 | #include <system/window.h> |
190 | #include <GLES2/gl2.h> |
191 | @@ -32,19 +32,11 @@ |
192 | namespace mga=mir::graphics::android; |
193 | namespace geom=mir::geometry; |
194 | |
195 | -mga::Buffer::Buffer(const std::shared_ptr<GraphicAllocAdaptor>& alloc_device, |
196 | - geom::Size size, geom::PixelFormat pf, mga::BufferUsage use) |
197 | +mga::Buffer::Buffer(std::shared_ptr<ANativeWindowBuffer> const& buffer_handle, |
198 | + std::shared_ptr<mg::EGLExtensions> const& extensions) |
199 | + : native_buffer(buffer_handle), |
200 | + egl_extensions(extensions) |
201 | { |
202 | - if (!alloc_device) |
203 | - BOOST_THROW_EXCEPTION(std::runtime_error("No allocation device for graphics buffer")); |
204 | - |
205 | - native_buffer = alloc_device->alloc_buffer(size, pf, use); |
206 | - |
207 | - //TODO: we could make the native buffer itself a constructor dependency and move creation |
208 | - // failures to the factory |
209 | - if (!native_buffer.get()) |
210 | - BOOST_THROW_EXCEPTION(std::runtime_error("Graphics buffer allocation failed")); |
211 | - |
212 | } |
213 | |
214 | mga::Buffer::~Buffer() |
215 | @@ -52,7 +44,7 @@ |
216 | std::map<EGLDisplay,EGLImageKHR>::iterator it; |
217 | for(it = egl_image_map.begin(); it != egl_image_map.end(); it++) |
218 | { |
219 | - eglDestroyImageKHR(it->first, it->second); |
220 | + egl_extensions->eglDestroyImageKHR(it->first, it->second); |
221 | } |
222 | } |
223 | |
224 | @@ -82,14 +74,14 @@ |
225 | } |
226 | static const EGLint image_attrs[] = |
227 | { |
228 | - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, |
229 | + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, |
230 | EGL_NONE |
231 | }; |
232 | EGLImageKHR image; |
233 | auto it = egl_image_map.find(disp); |
234 | if (it == egl_image_map.end()) |
235 | { |
236 | - image = eglCreateImageKHR(disp, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, |
237 | + image = egl_extensions->eglCreateImageKHR(disp, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, |
238 | native_buffer.get(), image_attrs); |
239 | if (image == EGL_NO_IMAGE_KHR) |
240 | { |
241 | @@ -102,9 +94,7 @@ |
242 | image = it->second; |
243 | } |
244 | |
245 | - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); |
246 | - |
247 | - return; |
248 | + egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); |
249 | } |
250 | |
251 | std::shared_ptr<ANativeWindowBuffer> mga::Buffer::native_buffer_handle() const |
252 | |
253 | === modified file 'src/server/graphics/android/buffer.h' |
254 | --- src/server/graphics/android/buffer.h 2013-06-04 14:23:56 +0000 |
255 | +++ src/server/graphics/android/buffer.h 2013-06-14 20:23:35 +0000 |
256 | @@ -34,15 +34,15 @@ |
257 | { |
258 | namespace graphics |
259 | { |
260 | +struct EGLExtensions; |
261 | namespace android |
262 | { |
263 | |
264 | -class GraphicAllocAdaptor; |
265 | class Buffer: public compositor::BufferBasic |
266 | { |
267 | public: |
268 | - Buffer(const std::shared_ptr<GraphicAllocAdaptor>& device, |
269 | - geometry::Size size, geometry::PixelFormat pf, BufferUsage use); |
270 | + Buffer(std::shared_ptr<ANativeWindowBuffer> const& buffer_handle, |
271 | + std::shared_ptr<EGLExtensions> const& extensions); |
272 | ~Buffer(); |
273 | |
274 | geometry::Size size() const; |
275 | @@ -55,6 +55,7 @@ |
276 | std::map<EGLDisplay,EGLImageKHR> egl_image_map; |
277 | |
278 | std::shared_ptr<ANativeWindowBuffer> native_buffer; |
279 | + std::shared_ptr<EGLExtensions> egl_extensions; |
280 | }; |
281 | |
282 | } |
283 | |
284 | === added file 'src/server/graphics/egl_extensions.cpp' |
285 | --- src/server/graphics/egl_extensions.cpp 1970-01-01 00:00:00 +0000 |
286 | +++ src/server/graphics/egl_extensions.cpp 2013-06-14 20:23:35 +0000 |
287 | @@ -0,0 +1,42 @@ |
288 | +/* |
289 | + * Copyright © 2013 Canonical Ltd. |
290 | + * |
291 | + * This program is free software: you can redistribute it and/or modify it |
292 | + * under the terms of the GNU General Public License version 3, |
293 | + * as published by the Free Software Foundation. |
294 | + * |
295 | + * This program is distributed in the hope that it will be useful, |
296 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
297 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
298 | + * GNU General Public License for more details. |
299 | + * |
300 | + * You should have received a copy of the GNU General Public License |
301 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
302 | + * |
303 | + * Authored by: |
304 | + * Kevin DuBois <kevin.dubois@canonical.com> |
305 | + */ |
306 | + |
307 | +#include "mir/graphics/egl_extensions.h" |
308 | +#include <boost/throw_exception.hpp> |
309 | +#include <stdexcept> |
310 | + |
311 | +namespace mg=mir::graphics; |
312 | + |
313 | +mg::EGLExtensions::EGLExtensions() |
314 | + : eglCreateImageKHR{ |
315 | + reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>( |
316 | + eglGetProcAddress("eglCreateImageKHR"))}, |
317 | + eglDestroyImageKHR{ |
318 | + reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>( |
319 | + eglGetProcAddress("eglDestroyImageKHR"))}, |
320 | + glEGLImageTargetTexture2DOES{ |
321 | + reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>( |
322 | + eglGetProcAddress("glEGLImageTargetTexture2DOES"))} |
323 | +{ |
324 | + if (!eglCreateImageKHR || !eglDestroyImageKHR) |
325 | + BOOST_THROW_EXCEPTION(std::runtime_error("EGL implementation doesn't support EGLImage")); |
326 | + |
327 | + if (!glEGLImageTargetTexture2DOES) |
328 | + BOOST_THROW_EXCEPTION(std::runtime_error("GLES2 implementation doesn't support updating a texture from an EGLImage")); |
329 | +} |
330 | |
331 | === modified file 'src/server/graphics/gbm/gbm_buffer_allocator.cpp' |
332 | --- src/server/graphics/gbm/gbm_buffer_allocator.cpp 2013-04-29 23:59:18 +0000 |
333 | +++ src/server/graphics/gbm/gbm_buffer_allocator.cpp 2013-06-14 20:23:35 +0000 |
334 | @@ -22,6 +22,7 @@ |
335 | #include "gbm_platform.h" |
336 | #include "buffer_texture_binder.h" |
337 | #include "mir/graphics/buffer_initializer.h" |
338 | +#include "mir/graphics/egl_extensions.h" |
339 | #include "mir/compositor/buffer_properties.h" |
340 | #include <boost/throw_exception.hpp> |
341 | |
342 | @@ -39,42 +40,6 @@ |
343 | namespace mc = mir::compositor; |
344 | namespace geom = mir::geometry; |
345 | |
346 | -namespace mir |
347 | -{ |
348 | -namespace graphics |
349 | -{ |
350 | -namespace gbm |
351 | -{ |
352 | - |
353 | -struct EGLExtensions |
354 | -{ |
355 | - EGLExtensions() |
356 | - : eglCreateImageKHR{ |
357 | - reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>( |
358 | - eglGetProcAddress("eglCreateImageKHR"))}, |
359 | - eglDestroyImageKHR{ |
360 | - reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>( |
361 | - eglGetProcAddress("eglDestroyImageKHR"))}, |
362 | - glEGLImageTargetTexture2DOES{ |
363 | - reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>( |
364 | - eglGetProcAddress("glEGLImageTargetTexture2DOES"))} |
365 | - { |
366 | - if (!eglCreateImageKHR || !eglDestroyImageKHR) |
367 | - BOOST_THROW_EXCEPTION(std::runtime_error("EGL implementation doesn't support EGLImage")); |
368 | - |
369 | - if (!glEGLImageTargetTexture2DOES) |
370 | - BOOST_THROW_EXCEPTION(std::runtime_error("GLES2 implementation doesn't support updating a texture from an EGLImage")); |
371 | - } |
372 | - |
373 | - PFNEGLCREATEIMAGEKHRPROC const eglCreateImageKHR; |
374 | - PFNEGLDESTROYIMAGEKHRPROC const eglDestroyImageKHR; |
375 | - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC const glEGLImageTargetTexture2DOES; |
376 | -}; |
377 | - |
378 | -} |
379 | -} |
380 | -} |
381 | - |
382 | namespace |
383 | { |
384 | |
385 | @@ -82,7 +47,7 @@ |
386 | { |
387 | public: |
388 | EGLImageBufferTextureBinder(std::shared_ptr<gbm_bo> const& gbm_bo, |
389 | - std::shared_ptr<mgg::EGLExtensions> const& egl_extensions) |
390 | + std::shared_ptr<mg::EGLExtensions> const& egl_extensions) |
391 | : bo{gbm_bo}, egl_extensions{egl_extensions}, egl_image{EGL_NO_IMAGE_KHR} |
392 | { |
393 | } |
394 | @@ -125,7 +90,7 @@ |
395 | } |
396 | |
397 | std::shared_ptr<gbm_bo> const bo; |
398 | - std::shared_ptr<mgg::EGLExtensions> const egl_extensions; |
399 | + std::shared_ptr<mg::EGLExtensions> const egl_extensions; |
400 | EGLDisplay egl_display; |
401 | EGLImageKHR egl_image; |
402 | }; |
403 | @@ -146,7 +111,7 @@ |
404 | const std::shared_ptr<BufferInitializer>& buffer_initializer) |
405 | : platform(platform), |
406 | buffer_initializer(buffer_initializer), |
407 | - egl_extensions(std::make_shared<EGLExtensions>()) |
408 | + egl_extensions(std::make_shared<mg::EGLExtensions>()) |
409 | { |
410 | assert(buffer_initializer.get() != 0); |
411 | } |
412 | |
413 | === modified file 'src/server/graphics/gbm/gbm_buffer_allocator.h' |
414 | --- src/server/graphics/gbm/gbm_buffer_allocator.h 2013-04-24 05:22:20 +0000 |
415 | +++ src/server/graphics/gbm/gbm_buffer_allocator.h 2013-06-14 20:23:35 +0000 |
416 | @@ -29,12 +29,11 @@ |
417 | namespace graphics |
418 | { |
419 | class BufferInitializer; |
420 | +struct EGLExtensions; |
421 | |
422 | namespace gbm |
423 | { |
424 | - |
425 | class GBMPlatform; |
426 | -struct EGLExtensions; |
427 | |
428 | class GBMBufferAllocator: public compositor::GraphicBufferAllocator |
429 | { |
430 | |
431 | === modified file 'tests/mir_test_doubles/mock_egl.cpp' |
432 | --- tests/mir_test_doubles/mock_egl.cpp 2013-05-20 15:55:48 +0000 |
433 | +++ tests/mir_test_doubles/mock_egl.cpp 2013-06-14 20:23:35 +0000 |
434 | @@ -38,6 +38,13 @@ |
435 | }; |
436 | EGLint config_size = 4; |
437 | |
438 | +/* We prefix GL/EGL extensions with "extension_" so code under test has to get their function |
439 | + ptrs with eglGetProcAddress */ |
440 | +EGLImageKHR extension_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, |
441 | + EGLClientBuffer buffer, const EGLint *attrib_list); |
442 | +EGLBoolean extension_eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); |
443 | +void extension_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); |
444 | + |
445 | /* EGL{Surface,Display,Config,Context} are all opaque types, so we can put whatever |
446 | we want in them for testing */ |
447 | mtd::MockEGL::MockEGL() |
448 | @@ -100,6 +107,14 @@ |
449 | |
450 | ON_CALL(*this, eglCreateImageKHR(_,_,_,_,_)) |
451 | .WillByDefault(Return(fake_egl_image)); |
452 | + |
453 | + typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
454 | + ON_CALL(*this, eglGetProcAddress(StrEq("eglCreateImageKHR"))) |
455 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(extension_eglCreateImageKHR))); |
456 | + ON_CALL(*this, eglGetProcAddress(StrEq("eglDestroyImageKHR"))) |
457 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(extension_eglDestroyImageKHR))); |
458 | + ON_CALL(*this, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
459 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(extension_glEGLImageTargetTexture2DOES))); |
460 | } |
461 | |
462 | mtd::MockEGL::~MockEGL() |
463 | @@ -146,13 +161,21 @@ |
464 | .Times(AtLeast(0)); |
465 | } |
466 | |
467 | -#define CHECK_GLOBAL_MOCK(rettype) \ |
468 | - if (!global_mock_egl) \ |
469 | - { \ |
470 | - using namespace ::testing; \ |
471 | +#define CHECK_GLOBAL_MOCK(rettype) \ |
472 | + if (!global_mock_egl) \ |
473 | + { \ |
474 | + using namespace ::testing; \ |
475 | ADD_FAILURE_AT(__FILE__,__LINE__); \ |
476 | - rettype type = (rettype) 0; \ |
477 | - return type; \ |
478 | + rettype type = (rettype) 0; \ |
479 | + return type; \ |
480 | + } |
481 | + |
482 | +#define CHECK_GLOBAL_VOID_MOCK() \ |
483 | + if (!global_mock_egl) \ |
484 | + { \ |
485 | + using namespace ::testing; \ |
486 | + ADD_FAILURE_AT(__FILE__,__LINE__); \ |
487 | + return; \ |
488 | } |
489 | |
490 | EGLint eglGetError (void) |
491 | @@ -338,15 +361,20 @@ |
492 | } |
493 | |
494 | /* extensions */ |
495 | -EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) |
496 | +EGLImageKHR extension_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) |
497 | { |
498 | CHECK_GLOBAL_MOCK(EGLImageKHR) |
499 | - return global_mock_egl->eglCreateImageKHR ( dpy, ctx, target, buffer, attrib_list); |
500 | + return global_mock_egl->eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); |
501 | } |
502 | |
503 | -EGLBoolean eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image) |
504 | +EGLBoolean extension_eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image) |
505 | { |
506 | CHECK_GLOBAL_MOCK(EGLBoolean) |
507 | - return global_mock_egl->eglDestroyImageKHR ( dpy, image); |
508 | + return global_mock_egl->eglDestroyImageKHR(dpy, image); |
509 | } |
510 | |
511 | +void extension_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) |
512 | +{ |
513 | + CHECK_GLOBAL_VOID_MOCK(); |
514 | + global_mock_egl->glEGLImageTargetTexture2DOES(target, image); |
515 | +} |
516 | |
517 | === modified file 'tests/mir_test_doubles/mock_gl.cpp' |
518 | --- tests/mir_test_doubles/mock_gl.cpp 2013-05-20 15:55:48 +0000 |
519 | +++ tests/mir_test_doubles/mock_gl.cpp 2013-06-14 20:23:35 +0000 |
520 | @@ -58,12 +58,6 @@ |
521 | return type; \ |
522 | } |
523 | |
524 | -void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) |
525 | -{ |
526 | - CHECK_GLOBAL_VOID_MOCK(); |
527 | - global_mock_gl->glEGLImageTargetTexture2DOES(target, image); |
528 | -} |
529 | - |
530 | const GLubyte* glGetString(GLenum name) |
531 | { |
532 | CHECK_GLOBAL_MOCK(const GLubyte*); |
533 | @@ -270,7 +264,4 @@ |
534 | |
535 | void mtd::MockGL::silence_uninteresting() |
536 | { |
537 | - using namespace testing; |
538 | - EXPECT_CALL(*this, glEGLImageTargetTexture2DOES(_,_)) |
539 | - .Times(AtLeast(0)); |
540 | } |
541 | |
542 | === modified file 'tests/unit-tests/graphics/CMakeLists.txt' |
543 | --- tests/unit-tests/graphics/CMakeLists.txt 2013-06-12 10:27:50 +0000 |
544 | +++ tests/unit-tests/graphics/CMakeLists.txt 2013-06-14 20:23:35 +0000 |
545 | @@ -2,6 +2,7 @@ |
546 | ${CMAKE_CURRENT_SOURCE_DIR}/test_graphics_platform.cpp |
547 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_renderer.cpp |
548 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display_configuration.cpp |
549 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_egl_extensions.cpp |
550 | ${CMAKE_CURRENT_SOURCE_DIR}/test_display.cpp |
551 | ) |
552 | |
553 | |
554 | === modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp' |
555 | --- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2013-05-24 15:51:37 +0000 |
556 | +++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2013-06-14 20:23:35 +0000 |
557 | @@ -22,6 +22,7 @@ |
558 | #include "mir/compositor/buffer_properties.h" |
559 | |
560 | #include "mir_test_doubles/mock_buffer_initializer.h" |
561 | +#include "mir_test_doubles/mock_egl.h" |
562 | |
563 | #include <hardware/gralloc.h> |
564 | #include <gtest/gtest.h> |
565 | @@ -42,6 +43,7 @@ |
566 | |
567 | std::shared_ptr<mg::BufferInitializer> const null_buffer_initializer; |
568 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; |
569 | + mtd::MockEGL mock_egl; |
570 | }; |
571 | |
572 | TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module) |
573 | |
574 | === modified file 'tests/unit-tests/graphics/android/test_buffer.cpp' |
575 | --- tests/unit-tests/graphics/android/test_buffer.cpp 2013-06-12 09:36:20 +0000 |
576 | +++ tests/unit-tests/graphics/android/test_buffer.cpp 2013-06-14 20:23:35 +0000 |
577 | @@ -16,8 +16,9 @@ |
578 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
579 | */ |
580 | |
581 | +#include "mir/graphics/egl_extensions.h" |
582 | #include "src/server/graphics/android/buffer.h" |
583 | -#include "mir_test_doubles/mock_alloc_adaptor.h" |
584 | +#include "mir_test_doubles/mock_egl.h" |
585 | |
586 | #include <hardware/gralloc.h> |
587 | #include <gtest/gtest.h> |
588 | @@ -42,37 +43,25 @@ |
589 | mock_buffer_handle->stride = 46; |
590 | mock_buffer_handle->format = HAL_PIXEL_FORMAT_RGBA_8888; |
591 | |
592 | - mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocAdaptor>>(); |
593 | - ON_CALL(*mock_alloc_device, alloc_buffer(_,_,_)) |
594 | - .WillByDefault(Return(mock_buffer_handle)); |
595 | - |
596 | default_use = mga::BufferUsage::use_hardware; |
597 | pf = geom::PixelFormat::abgr_8888; |
598 | size = geom::Size{geom::Width{300}, geom::Height{200}}; |
599 | + extensions = std::make_shared<mg::EGLExtensions>(); |
600 | } |
601 | |
602 | - std::shared_ptr<mtd::MockAllocAdaptor> mock_alloc_device; |
603 | + mtd::MockEGL mock_egl; |
604 | std::shared_ptr<ANativeWindowBuffer> mock_buffer_handle; |
605 | geom::PixelFormat pf; |
606 | geom::Size size; |
607 | mga::BufferUsage default_use; |
608 | + std::shared_ptr<mg::EGLExtensions> extensions; |
609 | }; |
610 | |
611 | - |
612 | -TEST_F(AndroidGraphicBufferBasic, basic_allocation_uses_alloc_device) |
613 | -{ |
614 | - using namespace testing; |
615 | - |
616 | - EXPECT_CALL(*mock_alloc_device, alloc_buffer(size, pf, default_use)); |
617 | - mga::Buffer buffer(mock_alloc_device, size, pf, default_use); |
618 | -} |
619 | - |
620 | TEST_F(AndroidGraphicBufferBasic, size_query_test) |
621 | { |
622 | using namespace testing; |
623 | |
624 | - EXPECT_CALL(*mock_alloc_device, alloc_buffer(_,_,_)); |
625 | - mga::Buffer buffer(mock_alloc_device, size, pf, default_use); |
626 | + mga::Buffer buffer(mock_buffer_handle, extensions); |
627 | |
628 | geom::Size expected_size{geom::Width{mock_buffer_handle->width}, |
629 | geom::Height{mock_buffer_handle->height}}; |
630 | @@ -83,15 +72,15 @@ |
631 | { |
632 | using namespace testing; |
633 | |
634 | - mga::Buffer buffer(mock_alloc_device, size, pf, default_use); |
635 | + mga::Buffer buffer(mock_buffer_handle, extensions); |
636 | EXPECT_EQ(geom::PixelFormat::abgr_8888, buffer.pixel_format()); |
637 | } |
638 | |
639 | -TEST_F(AndroidGraphicBufferBasic, queries_native_window_for_native_handle) |
640 | +TEST_F(AndroidGraphicBufferBasic, returns_native_buffer_when_asked) |
641 | { |
642 | using namespace testing; |
643 | |
644 | - mga::Buffer buffer(mock_alloc_device, size, pf, default_use); |
645 | + mga::Buffer buffer(mock_buffer_handle, extensions); |
646 | EXPECT_EQ(mock_buffer_handle, buffer.native_buffer_handle()); |
647 | } |
648 | |
649 | @@ -101,6 +90,6 @@ |
650 | |
651 | geom::Stride expected_stride{mock_buffer_handle->stride * |
652 | geom::bytes_per_pixel(pf)}; |
653 | - mga::Buffer buffer(mock_alloc_device, size, pf, default_use); |
654 | + mga::Buffer buffer(mock_buffer_handle, extensions); |
655 | EXPECT_EQ(expected_stride, buffer.stride()); |
656 | } |
657 | |
658 | === modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp' |
659 | --- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2013-05-22 16:23:40 +0000 |
660 | +++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2013-06-14 20:23:35 +0000 |
661 | @@ -17,11 +17,10 @@ |
662 | */ |
663 | |
664 | #include "src/server/graphics/android/buffer.h" |
665 | - |
666 | -#include "mir_test_doubles/mock_alloc_adaptor.h" |
667 | -#include "mir_test_doubles/mock_gl.h" |
668 | #include "mir_test_doubles/mock_egl.h" |
669 | +#include "mir/graphics/egl_extensions.h" |
670 | |
671 | +#include <system/window.h> |
672 | #include <stdexcept> |
673 | #include <gtest/gtest.h> |
674 | |
675 | @@ -39,16 +38,11 @@ |
676 | using namespace testing; |
677 | |
678 | stub_buffer = std::make_shared<ANativeWindowBuffer>(); |
679 | - mock_alloc_dev = std::make_shared<NiceMock<mtd::MockAllocAdaptor>>(); |
680 | - ON_CALL(*mock_alloc_dev, alloc_buffer(_,_,_)) |
681 | - .WillByDefault(Return(stub_buffer)); |
682 | - |
683 | size = geom::Size{geom::Width{300}, geom::Height{220}}; |
684 | pf = geom::PixelFormat::abgr_8888; |
685 | - buffer = std::make_shared<mga::Buffer>(mock_alloc_dev, size, pf, mga::BufferUsage::use_hardware); |
686 | + extensions = std::make_shared<mg::EGLExtensions>(); |
687 | |
688 | mock_egl.silence_uninteresting(); |
689 | - mock_gl.silence_uninteresting(); |
690 | }; |
691 | virtual void TearDown() |
692 | { |
693 | @@ -58,10 +52,9 @@ |
694 | geom::Size size; |
695 | geom::PixelFormat pf; |
696 | |
697 | + mtd::MockEGL mock_egl; |
698 | + std::shared_ptr<mg::EGLExtensions> extensions; |
699 | std::shared_ptr<mga::Buffer> buffer; |
700 | - mtd::MockGL mock_gl; |
701 | - mtd::MockEGL mock_egl; |
702 | - std::shared_ptr<mtd::MockAllocAdaptor> mock_alloc_dev; |
703 | std::shared_ptr<ANativeWindowBuffer> stub_buffer; |
704 | }; |
705 | |
706 | @@ -69,29 +62,32 @@ |
707 | { |
708 | using namespace testing; |
709 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
710 | - .Times(Exactly(1)); |
711 | + .Times(Exactly(1)); |
712 | |
713 | - buffer->bind_to_texture(); |
714 | + mga::Buffer buffer(stub_buffer, extensions); |
715 | + buffer.bind_to_texture(); |
716 | } |
717 | |
718 | TEST_F(AndroidBufferBinding, buffer_creates_image_on_first_bind) |
719 | { |
720 | using namespace testing; |
721 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
722 | - .Times(Exactly(1)); |
723 | + .Times(Exactly(1)); |
724 | |
725 | - buffer->bind_to_texture(); |
726 | + mga::Buffer buffer(stub_buffer, extensions); |
727 | + buffer.bind_to_texture(); |
728 | } |
729 | |
730 | TEST_F(AndroidBufferBinding, buffer_only_makes_one_image_per_display) |
731 | { |
732 | using namespace testing; |
733 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
734 | - .Times(Exactly(1)); |
735 | + .Times(Exactly(1)); |
736 | |
737 | - buffer->bind_to_texture(); |
738 | - buffer->bind_to_texture(); |
739 | - buffer->bind_to_texture(); |
740 | + mga::Buffer buffer(stub_buffer, extensions); |
741 | + buffer.bind_to_texture(); |
742 | + buffer.bind_to_texture(); |
743 | + buffer.bind_to_texture(); |
744 | } |
745 | |
746 | TEST_F(AndroidBufferBinding, buffer_makes_new_image_with_new_display) |
747 | @@ -101,16 +97,17 @@ |
748 | |
749 | /* return 1st fake display */ |
750 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
751 | - .Times(Exactly(2)); |
752 | + .Times(Exactly(2)); |
753 | |
754 | - buffer->bind_to_texture(); |
755 | + mga::Buffer buffer(stub_buffer, extensions); |
756 | + buffer.bind_to_texture(); |
757 | |
758 | /* return 2nd fake display */ |
759 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
760 | - .Times(Exactly(1)) |
761 | - .WillOnce(Return(second_fake_display)); |
762 | + .Times(Exactly(1)) |
763 | + .WillOnce(Return(second_fake_display)); |
764 | |
765 | - buffer->bind_to_texture(); |
766 | + buffer.bind_to_texture(); |
767 | } |
768 | |
769 | TEST_F(AndroidBufferBinding, buffer_frees_images_it_makes) |
770 | @@ -119,15 +116,16 @@ |
771 | EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1); |
772 | |
773 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,_)) |
774 | - .Times(Exactly(2)); |
775 | + .Times(Exactly(2)); |
776 | |
777 | - buffer->bind_to_texture(); |
778 | + mga::Buffer buffer(stub_buffer, extensions); |
779 | + buffer.bind_to_texture(); |
780 | |
781 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
782 | - .Times(Exactly(1)) |
783 | - .WillOnce(Return(second_fake_display)); |
784 | + .Times(Exactly(1)) |
785 | + .WillOnce(Return(second_fake_display)); |
786 | |
787 | - buffer->bind_to_texture(); |
788 | + buffer.bind_to_texture(); |
789 | } |
790 | |
791 | TEST_F(AndroidBufferBinding, buffer_frees_images_it_makes_with_proper_args) |
792 | @@ -141,29 +139,30 @@ |
793 | |
794 | /* actual expectations */ |
795 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(first_fake_display, first_fake_egl_image)) |
796 | - .Times(Exactly(1)); |
797 | + .Times(Exactly(1)); |
798 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(second_fake_display, second_fake_egl_image)) |
799 | - .Times(Exactly(1)); |
800 | + .Times(Exactly(1)); |
801 | |
802 | /* manipulate mock to return 1st set */ |
803 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
804 | - .Times(Exactly(1)) |
805 | - .WillOnce(Return(first_fake_display)); |
806 | + .Times(Exactly(1)) |
807 | + .WillOnce(Return(first_fake_display)); |
808 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
809 | - .Times(Exactly(1)) |
810 | - .WillOnce(Return((first_fake_egl_image))); |
811 | + .Times(Exactly(1)) |
812 | + .WillOnce(Return((first_fake_egl_image))); |
813 | |
814 | - buffer->bind_to_texture(); |
815 | + mga::Buffer buffer(stub_buffer, extensions); |
816 | + buffer.bind_to_texture(); |
817 | |
818 | /* manipulate mock to return 2nd set */ |
819 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
820 | - .Times(Exactly(1)) |
821 | - .WillOnce(Return(second_fake_display)); |
822 | + .Times(Exactly(1)) |
823 | + .WillOnce(Return(second_fake_display)); |
824 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
825 | - .Times(Exactly(1)) |
826 | - .WillOnce(Return((second_fake_egl_image))); |
827 | + .Times(Exactly(1)) |
828 | + .WillOnce(Return((second_fake_egl_image))); |
829 | |
830 | - buffer->bind_to_texture(); |
831 | + buffer.bind_to_texture(); |
832 | } |
833 | |
834 | TEST_F(AndroidBufferBinding, buffer_uses_current_display) |
835 | @@ -172,12 +171,13 @@ |
836 | EGLDisplay fake_display = (EGLDisplay) 0x32298; |
837 | |
838 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
839 | - .Times(Exactly(1)) |
840 | - .WillOnce(Return(fake_display)); |
841 | + .Times(Exactly(1)) |
842 | + .WillOnce(Return(fake_display)); |
843 | |
844 | EXPECT_CALL(mock_egl, eglCreateImageKHR(fake_display,_,_,_,_)) |
845 | - .Times(Exactly(1)); |
846 | - buffer->bind_to_texture(); |
847 | + .Times(Exactly(1)); |
848 | + mga::Buffer buffer(stub_buffer, extensions); |
849 | + buffer.bind_to_texture(); |
850 | } |
851 | |
852 | TEST_F(AndroidBufferBinding, buffer_specifies_no_context) |
853 | @@ -185,8 +185,9 @@ |
854 | using namespace testing; |
855 | |
856 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_, EGL_NO_CONTEXT,_,_,_)) |
857 | - .Times(Exactly(1)); |
858 | - buffer->bind_to_texture(); |
859 | + .Times(Exactly(1)); |
860 | + mga::Buffer buffer(stub_buffer, extensions); |
861 | + buffer.bind_to_texture(); |
862 | } |
863 | |
864 | TEST_F(AndroidBufferBinding, buffer_sets_egl_native_buffer_android) |
865 | @@ -194,8 +195,9 @@ |
866 | using namespace testing; |
867 | |
868 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,EGL_NATIVE_BUFFER_ANDROID,_,_)) |
869 | - .Times(Exactly(1)); |
870 | - buffer->bind_to_texture(); |
871 | + .Times(Exactly(1)); |
872 | + mga::Buffer buffer(stub_buffer, extensions); |
873 | + buffer.bind_to_texture(); |
874 | } |
875 | |
876 | TEST_F(AndroidBufferBinding, buffer_sets_anw_buffer_to_provided_anw) |
877 | @@ -203,8 +205,9 @@ |
878 | using namespace testing; |
879 | |
880 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,stub_buffer.get(),_)) |
881 | - .Times(Exactly(1)); |
882 | - buffer->bind_to_texture(); |
883 | + .Times(Exactly(1)); |
884 | + mga::Buffer buffer(stub_buffer, extensions); |
885 | + buffer.bind_to_texture(); |
886 | } |
887 | |
888 | TEST_F(AndroidBufferBinding, buffer_sets_proper_attributes) |
889 | @@ -214,11 +217,11 @@ |
890 | const EGLint* attrs; |
891 | |
892 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
893 | - .Times(Exactly(1)) |
894 | - .WillOnce(DoAll( |
895 | - SaveArg<4>(&attrs), |
896 | - Return(mock_egl.fake_egl_image))); |
897 | - buffer->bind_to_texture(); |
898 | + .Times(Exactly(1)) |
899 | + .WillOnce(DoAll(SaveArg<4>(&attrs), |
900 | + Return(mock_egl.fake_egl_image))); |
901 | + mga::Buffer buffer(stub_buffer, extensions); |
902 | + buffer.bind_to_texture(); |
903 | |
904 | /* note: this should not segfault. if it does, the attributes were set wrong */ |
905 | EXPECT_EQ(attrs[0], EGL_IMAGE_PRESERVED_KHR); |
906 | @@ -232,31 +235,33 @@ |
907 | using namespace testing; |
908 | EGLImageKHR fake_egl_image = (EGLImageKHR) 0x84210; |
909 | EXPECT_CALL(mock_egl, eglCreateImageKHR(mock_egl.fake_egl_display,_,_,_,_)) |
910 | - .Times(Exactly(1)) |
911 | - .WillOnce(Return((fake_egl_image))); |
912 | + .Times(Exactly(1)) |
913 | + .WillOnce(Return((fake_egl_image))); |
914 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(mock_egl.fake_egl_display, fake_egl_image)) |
915 | - .Times(Exactly(1)); |
916 | + .Times(Exactly(1)); |
917 | |
918 | - buffer->bind_to_texture(); |
919 | + mga::Buffer buffer(stub_buffer, extensions); |
920 | + buffer.bind_to_texture(); |
921 | } |
922 | |
923 | TEST_F(AndroidBufferBinding, buffer_image_creation_failure_does_not_save) |
924 | { |
925 | using namespace testing; |
926 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
927 | - .Times(Exactly(2)) |
928 | - .WillRepeatedly(Return((EGL_NO_IMAGE_KHR))); |
929 | + .Times(Exactly(2)) |
930 | + .WillRepeatedly(Return((EGL_NO_IMAGE_KHR))); |
931 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,_)) |
932 | - .Times(Exactly(0)); |
933 | + .Times(Exactly(0)); |
934 | |
935 | + mga::Buffer buffer(stub_buffer, extensions); |
936 | EXPECT_THROW( |
937 | { |
938 | - buffer->bind_to_texture(); |
939 | + buffer.bind_to_texture(); |
940 | }, std::runtime_error); |
941 | |
942 | EXPECT_THROW( |
943 | { |
944 | - buffer->bind_to_texture(); |
945 | + buffer.bind_to_texture(); |
946 | }, std::runtime_error); |
947 | } |
948 | |
949 | @@ -264,12 +269,13 @@ |
950 | { |
951 | using namespace testing; |
952 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
953 | - .Times(Exactly(1)) |
954 | - .WillRepeatedly(Return((EGL_NO_IMAGE_KHR))); |
955 | + .Times(Exactly(1)) |
956 | + .WillRepeatedly(Return((EGL_NO_IMAGE_KHR))); |
957 | |
958 | + mga::Buffer buffer(stub_buffer, extensions); |
959 | EXPECT_THROW( |
960 | { |
961 | - buffer->bind_to_texture(); |
962 | + buffer.bind_to_texture(); |
963 | }, std::runtime_error); |
964 | } |
965 | |
966 | @@ -278,37 +284,40 @@ |
967 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension) |
968 | { |
969 | using namespace testing; |
970 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_, _)) |
971 | - .Times(Exactly(1)); |
972 | - buffer->bind_to_texture(); |
973 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
974 | + .Times(Exactly(1)); |
975 | + mga::Buffer buffer(stub_buffer, extensions); |
976 | + buffer.bind_to_texture(); |
977 | } |
978 | |
979 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time) |
980 | { |
981 | using namespace testing; |
982 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_, _)) |
983 | - .Times(Exactly(3)); |
984 | - |
985 | - buffer->bind_to_texture(); |
986 | - buffer->bind_to_texture(); |
987 | - buffer->bind_to_texture(); |
988 | - |
989 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
990 | + .Times(Exactly(3)); |
991 | + |
992 | + mga::Buffer buffer(stub_buffer, extensions); |
993 | + buffer.bind_to_texture(); |
994 | + buffer.bind_to_texture(); |
995 | + buffer.bind_to_texture(); |
996 | } |
997 | |
998 | TEST_F(AndroidBufferBinding, buffer_binding_specifies_gl_texture_2d) |
999 | { |
1000 | using namespace testing; |
1001 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, _)) |
1002 | - .Times(Exactly(1)); |
1003 | - buffer->bind_to_texture(); |
1004 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, _)) |
1005 | + .Times(Exactly(1)); |
1006 | + mga::Buffer buffer(stub_buffer, extensions); |
1007 | + buffer.bind_to_texture(); |
1008 | } |
1009 | |
1010 | TEST_F(AndroidBufferBinding, buffer_binding_uses_right_image) |
1011 | { |
1012 | using namespace testing; |
1013 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_, mock_egl.fake_egl_image)) |
1014 | - .Times(Exactly(1)); |
1015 | - buffer->bind_to_texture(); |
1016 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, mock_egl.fake_egl_image)) |
1017 | + .Times(Exactly(1)); |
1018 | + mga::Buffer buffer(stub_buffer, extensions); |
1019 | + buffer.bind_to_texture(); |
1020 | } |
1021 | |
1022 | TEST_F(AndroidBufferBinding, buffer_binding_uses_right_image_after_display_swap) |
1023 | @@ -317,17 +326,18 @@ |
1024 | EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1); |
1025 | EGLImageKHR second_fake_egl_image = (EGLImageKHR) 0x84211; |
1026 | |
1027 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_, _)) |
1028 | - .Times(Exactly(1)); |
1029 | - buffer->bind_to_texture(); |
1030 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1031 | + .Times(Exactly(1)); |
1032 | + mga::Buffer buffer(stub_buffer, extensions); |
1033 | + buffer.bind_to_texture(); |
1034 | |
1035 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_, second_fake_egl_image)) |
1036 | - .Times(Exactly(1)); |
1037 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, second_fake_egl_image)) |
1038 | + .Times(Exactly(1)); |
1039 | EXPECT_CALL(mock_egl, eglGetCurrentDisplay()) |
1040 | - .Times(Exactly(1)) |
1041 | - .WillOnce(Return(second_fake_display)); |
1042 | + .Times(Exactly(1)) |
1043 | + .WillOnce(Return(second_fake_display)); |
1044 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
1045 | - .Times(Exactly(1)) |
1046 | - .WillOnce(Return((second_fake_egl_image))); |
1047 | - buffer->bind_to_texture(); |
1048 | + .Times(Exactly(1)) |
1049 | + .WillOnce(Return((second_fake_egl_image))); |
1050 | + buffer.bind_to_texture(); |
1051 | } |
1052 | |
1053 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp' |
1054 | --- tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp 2013-05-22 06:30:39 +0000 |
1055 | +++ tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp 2013-06-14 20:23:35 +0000 |
1056 | @@ -69,15 +69,6 @@ |
1057 | ON_CALL(mock_gbm, gbm_bo_get_stride(_)) |
1058 | .WillByDefault(Return(stride.as_uint32_t())); |
1059 | |
1060 | - typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1061 | - |
1062 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglCreateImageKHR"))) |
1063 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(eglCreateImageKHR))); |
1064 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglDestroyImageKHR"))) |
1065 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(eglDestroyImageKHR))); |
1066 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1067 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); |
1068 | - |
1069 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>(), |
1070 | std::make_shared<mtd::NullVirtualTerminal>()); |
1071 | null_init = std::make_shared<mg::NullBufferInitializer>(); |
1072 | @@ -218,7 +209,7 @@ |
1073 | EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_)) |
1074 | .Times(Exactly(1)); |
1075 | |
1076 | - EXPECT_CALL(mock_gl, glEGLImageTargetTexture2DOES(_,mock_egl.fake_egl_image)) |
1077 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_,mock_egl.fake_egl_image)) |
1078 | .Times(Exactly(1)); |
1079 | |
1080 | EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,mock_egl.fake_egl_image)) |
1081 | |
1082 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp' |
1083 | --- tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-05-20 15:55:48 +0000 |
1084 | +++ tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-06-14 20:23:35 +0000 |
1085 | @@ -1,4 +1,3 @@ |
1086 | - |
1087 | /* |
1088 | * Copyright © 2012 Canonical Ltd. |
1089 | * |
1090 | @@ -59,15 +58,6 @@ |
1091 | ON_CALL(mock_gbm, gbm_bo_get_handle(_)) |
1092 | .WillByDefault(Return(mock_gbm.fake_gbm.bo_handle)); |
1093 | |
1094 | - typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1095 | - |
1096 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglCreateImageKHR"))) |
1097 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(eglCreateImageKHR))); |
1098 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglDestroyImageKHR"))) |
1099 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(eglDestroyImageKHR))); |
1100 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1101 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); |
1102 | - |
1103 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>(), |
1104 | std::make_shared<mtd::NullVirtualTerminal>()); |
1105 | mock_buffer_initializer = std::make_shared<testing::NiceMock<mtd::MockBufferInitializer>>(); |
1106 | @@ -227,34 +217,6 @@ |
1107 | }, std::runtime_error); |
1108 | } |
1109 | |
1110 | -TEST_F(GBMBufferAllocatorTest, constructor_throws_if_egl_image_not_supported) |
1111 | -{ |
1112 | - using namespace testing; |
1113 | - typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1114 | - |
1115 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglCreateImageKHR"))) |
1116 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1117 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglDestroyImageKHR"))) |
1118 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1119 | - |
1120 | - EXPECT_THROW({ |
1121 | - mgg::GBMBufferAllocator allocator(platform, mock_buffer_initializer); |
1122 | - }, std::runtime_error); |
1123 | -} |
1124 | - |
1125 | -TEST_F(GBMBufferAllocatorTest, constructor_throws_if_gl_oes_egl_image_not_supported) |
1126 | -{ |
1127 | - using namespace testing; |
1128 | - typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1129 | - |
1130 | - ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1131 | - .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1132 | - |
1133 | - EXPECT_THROW({ |
1134 | - mgg::GBMBufferAllocator allocator(platform, mock_buffer_initializer); |
1135 | - }, std::runtime_error); |
1136 | -} |
1137 | - |
1138 | TEST_F(GBMBufferAllocatorTest, supported_pixel_formats_contain_common_formats) |
1139 | { |
1140 | auto supported_pixel_formats = allocator->supported_pixel_formats(); |
1141 | |
1142 | === added file 'tests/unit-tests/graphics/test_egl_extensions.cpp' |
1143 | --- tests/unit-tests/graphics/test_egl_extensions.cpp 1970-01-01 00:00:00 +0000 |
1144 | +++ tests/unit-tests/graphics/test_egl_extensions.cpp 2013-06-14 20:23:35 +0000 |
1145 | @@ -0,0 +1,75 @@ |
1146 | +/* |
1147 | + * Copyright © 2013 Canonical Ltd. |
1148 | + * |
1149 | + * This program is free software: you can redistribute it and/or modify it |
1150 | + * under the terms of the GNU General Public License version 3, |
1151 | + * as published by the Free Software Foundation. |
1152 | + * |
1153 | + * This program is distributed in the hope that it will be useful, |
1154 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1155 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1156 | + * GNU General Public License for more details. |
1157 | + * |
1158 | + * You should have received a copy of the GNU General Public License |
1159 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1160 | + * |
1161 | + * Authored by: |
1162 | + * Kevin DuBois <kevin.dubois@canonical.com> |
1163 | + */ |
1164 | + |
1165 | +#include "mir/graphics/egl_extensions.h" |
1166 | +#include "mir_test_doubles/mock_egl.h" |
1167 | +#include <stdexcept> |
1168 | + |
1169 | +#include <gtest/gtest.h> |
1170 | +#include <gmock/gmock.h> |
1171 | + |
1172 | +namespace mg = mir::graphics; |
1173 | +namespace mtd = mir::test::doubles; |
1174 | + |
1175 | +class EGLExtensionsTest : public ::testing::Test |
1176 | +{ |
1177 | +protected: |
1178 | + virtual void SetUp() |
1179 | + { |
1180 | + } |
1181 | + |
1182 | + testing::NiceMock<mtd::MockEGL> mock_egl; |
1183 | +}; |
1184 | + |
1185 | +TEST_F(EGLExtensionsTest, constructor_throws_if_egl_image_not_supported) |
1186 | +{ |
1187 | + using namespace testing; |
1188 | + typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1189 | + |
1190 | + ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglCreateImageKHR"))) |
1191 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1192 | + ON_CALL(mock_egl, eglGetProcAddress(StrEq("eglDestroyImageKHR"))) |
1193 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1194 | + |
1195 | + EXPECT_THROW({ |
1196 | + mg::EGLExtensions extensions; |
1197 | + }, std::runtime_error); |
1198 | +} |
1199 | + |
1200 | +TEST_F(EGLExtensionsTest, constructor_throws_if_gl_oes_egl_image_not_supported) |
1201 | +{ |
1202 | + using namespace testing; |
1203 | + typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t; |
1204 | + |
1205 | + ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1206 | + .WillByDefault(Return(reinterpret_cast<func_ptr_t>(0))); |
1207 | + |
1208 | + EXPECT_THROW({ |
1209 | + mg::EGLExtensions extensions; |
1210 | + }, std::runtime_error); |
1211 | +} |
1212 | + |
1213 | +TEST_F(EGLExtensionsTest, success_has_sane_function_hooks) |
1214 | +{ |
1215 | + mg::EGLExtensions extensions; |
1216 | + EXPECT_NE(nullptr, extensions.eglCreateImageKHR); |
1217 | + EXPECT_NE(nullptr, extensions.eglDestroyImageKHR); |
1218 | + EXPECT_NE(nullptr, extensions.glEGLImageTargetTexture2DOES); |
1219 | +} |
1220 | + |
PASSED: Continuous integration, rev:761 jenkins. qa.ubuntu. com/job/ mir-ci/ 740/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 920 jenkins. qa.ubuntu. com/job/ mir-clang- raring- amd64-build/ 802 jenkins. qa.ubuntu. com/job/ mir-raring- amd64-ci/ 225 jenkins. qa.ubuntu. com/job/ mir-raring- amd64-ci/ 225/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-vm- ci-build/ ./distribution= quantal, flavor= amd64/426
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 740/rebuild
http://