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