Merge lp:~cemil-azizoglu/mir/use_egl_native_window into lp:mir
- use_egl_native_window
- Merge into development-branch
Proposed by
Cemil Azizoglu
Status: | Superseded |
---|---|
Proposed branch: | lp:~cemil-azizoglu/mir/use_egl_native_window |
Merge into: | lp:mir |
Diff against target: |
649 lines (+210/-37) 24 files modified
.bzrignore (+1/-0) src/include/client/mir/client_platform.h (+2/-1) src/platforms/android/client/android_client_platform.cpp (+15/-4) src/platforms/android/client/android_client_platform.h (+2/-1) src/platforms/android/client/egl_native_surface_interpreter.h (+17/-0) src/platforms/android/common/mir_native_window.cpp (+6/-0) src/platforms/android/include/mir_native_window.h (+2/-1) src/platforms/eglstream-kms/client/client_platform.cpp (+5/-1) src/platforms/eglstream-kms/client/client_platform.h (+1/-0) src/platforms/mesa/client/client_platform.cpp (+7/-1) src/platforms/mesa/client/client_platform.h (+2/-1) src/platforms/mesa/client/native_surface.cpp (+19/-5) src/platforms/mesa/client/native_surface.h (+3/-2) src/platforms/mesa/include/native_buffer.h (+2/-0) tests/acceptance-tests/throwback/test_client_library_errors.cpp (+4/-0) tests/include/mir_test_framework/stub_client_platform_factory.h (+1/-0) tests/mir_test_framework/stub_client_platform_factory.cpp (+4/-0) tests/unit-tests/client/test_client_buffer_stream.cpp (+3/-0) tests/unit-tests/client/test_mir_connection.cpp (+1/-0) tests/unit-tests/platforms/android/CMakeLists.txt (+5/-0) tests/unit-tests/platforms/android/client/test_android_client_platform.cpp (+15/-0) tests/unit-tests/platforms/android/client/test_android_native_window.cpp (+16/-0) tests/unit-tests/platforms/mesa/client/test_client_platform.cpp (+14/-0) tests/unit-tests/platforms/mesa/client/test_native_surface.cpp (+63/-20) |
To merge this branch: | bzr merge lp:~cemil-azizoglu/mir/use_egl_native_window |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+304291@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-09-02.
Commit message
Description of the change
Introduce use_egl_
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2016-08-26 19:50:25 +0000 | |||
3 | +++ .bzrignore 2016-09-01 23:11:16 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | .idea | 1 | .idea |
6 | 2 | .project | 2 | .project |
7 | 3 | include/server/mir/version.h | 3 | include/server/mir/version.h |
8 | 4 | build-* | ||
9 | 4 | 5 | ||
10 | === modified file 'src/include/client/mir/client_platform.h' | |||
11 | --- src/include/client/mir/client_platform.h 2016-05-03 06:55:25 +0000 | |||
12 | +++ src/include/client/mir/client_platform.h 2016-09-01 23:11:16 +0000 | |||
13 | @@ -63,7 +63,8 @@ | |||
14 | 63 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; | 63 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; |
15 | 64 | // EGLNativeWindowType differs between platforms, so can't reasonably be used in the | 64 | // EGLNativeWindowType differs between platforms, so can't reasonably be used in the |
16 | 65 | // platform-independent interface. | 65 | // platform-independent interface. |
18 | 66 | virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) = 0; | 66 | virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) = 0; |
19 | 67 | virtual void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) = 0; | ||
20 | 67 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; | 68 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; |
21 | 68 | virtual MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const = 0; | 69 | virtual MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const = 0; |
22 | 69 | virtual MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const = 0; | 70 | virtual MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const = 0; |
23 | 70 | 71 | ||
24 | === modified file 'src/platforms/android/client/android_client_platform.cpp' | |||
25 | --- src/platforms/android/client/android_client_platform.cpp 2016-07-20 04:54:07 +0000 | |||
26 | +++ src/platforms/android/client/android_client_platform.cpp 2016-09-01 23:11:16 +0000 | |||
27 | @@ -57,7 +57,13 @@ | |||
28 | 57 | return std::make_shared<mcla::AndroidClientBufferFactory>(registrar); | 57 | return std::make_shared<mcla::AndroidClientBufferFactory>(registrar); |
29 | 58 | } | 58 | } |
30 | 59 | 59 | ||
32 | 60 | std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface *surface) | 60 | void mcla::AndroidClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) |
33 | 61 | { | ||
34 | 62 | auto anw = std::static_pointer_cast<mga::MirNativeWindow>(native_window); | ||
35 | 63 | anw->use_native_surface(std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface)); | ||
36 | 64 | } | ||
37 | 65 | |||
38 | 66 | std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface* surface) | ||
39 | 61 | { | 67 | { |
40 | 62 | auto log = getenv("MIR_CLIENT_ANDROID_WINDOW_REPORT"); | 68 | auto log = getenv("MIR_CLIENT_ANDROID_WINDOW_REPORT"); |
41 | 63 | std::shared_ptr<mga::NativeWindowReport> report; | 69 | std::shared_ptr<mga::NativeWindowReport> report; |
42 | @@ -67,9 +73,14 @@ | |||
43 | 67 | std::make_shared<mir::logging::DumbConsoleLogger>()); | 73 | std::make_shared<mir::logging::DumbConsoleLogger>()); |
44 | 68 | else | 74 | else |
45 | 69 | report = std::make_shared<mga::NullNativeWindowReport>(); | 75 | report = std::make_shared<mga::NullNativeWindowReport>(); |
49 | 70 | 76 | ||
50 | 71 | return std::make_shared<mga::MirNativeWindow>( | 77 | std::shared_ptr<mga::AndroidDriverInterpreter> surface_interpreter; |
51 | 72 | std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface), report); | 78 | if (surface) |
52 | 79 | surface_interpreter = std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface); | ||
53 | 80 | else | ||
54 | 81 | surface_interpreter = std::make_shared<mcla::ErrorDriverInterpreter>(); | ||
55 | 82 | |||
56 | 83 | return std::make_shared<mga::MirNativeWindow>(surface_interpreter, report); | ||
57 | 73 | } | 84 | } |
58 | 74 | 85 | ||
59 | 75 | std::shared_ptr<EGLNativeDisplayType> | 86 | std::shared_ptr<EGLNativeDisplayType> |
60 | 76 | 87 | ||
61 | === modified file 'src/platforms/android/client/android_client_platform.h' | |||
62 | --- src/platforms/android/client/android_client_platform.h 2016-05-03 06:55:25 +0000 | |||
63 | +++ src/platforms/android/client/android_client_platform.h 2016-09-01 23:11:16 +0000 | |||
64 | @@ -37,7 +37,8 @@ | |||
65 | 37 | void populate(MirPlatformPackage& package) const override; | 37 | void populate(MirPlatformPackage& package) const override; |
66 | 38 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | 38 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; |
67 | 39 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 39 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
69 | 40 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override; | 40 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override; |
70 | 41 | void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override; | ||
71 | 41 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 42 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
72 | 42 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; | 43 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; |
73 | 43 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; | 44 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; |
74 | 44 | 45 | ||
75 | === modified file 'src/platforms/android/client/egl_native_surface_interpreter.h' | |||
76 | --- src/platforms/android/client/egl_native_surface_interpreter.h 2016-01-29 08:18:22 +0000 | |||
77 | +++ src/platforms/android/client/egl_native_surface_interpreter.h 2016-09-01 23:11:16 +0000 | |||
78 | @@ -21,6 +21,7 @@ | |||
79 | 21 | 21 | ||
80 | 22 | #include "android_driver_interpreter.h" | 22 | #include "android_driver_interpreter.h" |
81 | 23 | #include "mir/egl_native_surface.h" | 23 | #include "mir/egl_native_surface.h" |
82 | 24 | #include <boost/throw_exception.hpp> | ||
83 | 24 | 25 | ||
84 | 25 | namespace mir | 26 | namespace mir |
85 | 26 | { | 27 | { |
86 | @@ -36,6 +37,22 @@ | |||
87 | 36 | namespace android | 37 | namespace android |
88 | 37 | { | 38 | { |
89 | 38 | 39 | ||
90 | 40 | class ErrorDriverInterpreter : public graphics::android::AndroidDriverInterpreter | ||
91 | 41 | { | ||
92 | 42 | public: | ||
93 | 43 | #define THROW_EXCEPTION \ | ||
94 | 44 | { \ | ||
95 | 45 | BOOST_THROW_EXCEPTION(std::logic_error("error: use_egl_native_window(...) has not yet been called"));\ | ||
96 | 46 | } | ||
97 | 47 | graphics::NativeBuffer* driver_requests_buffer() override THROW_EXCEPTION | ||
98 | 48 | void driver_returns_buffer(ANativeWindowBuffer*, int) override THROW_EXCEPTION | ||
99 | 49 | void dispatch_driver_request_format(int) override THROW_EXCEPTION | ||
100 | 50 | void dispatch_driver_request_buffer_count(unsigned int) override THROW_EXCEPTION | ||
101 | 51 | int driver_requests_info(int) const override THROW_EXCEPTION | ||
102 | 52 | void sync_to_display(bool) override THROW_EXCEPTION | ||
103 | 53 | #undef THROW_EXCEPTION | ||
104 | 54 | }; | ||
105 | 55 | |||
106 | 39 | class EGLNativeSurfaceInterpreter : public graphics::android::AndroidDriverInterpreter | 56 | class EGLNativeSurfaceInterpreter : public graphics::android::AndroidDriverInterpreter |
107 | 40 | { | 57 | { |
108 | 41 | public: | 58 | public: |
109 | 42 | 59 | ||
110 | === modified file 'src/platforms/android/common/mir_native_window.cpp' | |||
111 | --- src/platforms/android/common/mir_native_window.cpp 2016-07-20 04:54:07 +0000 | |||
112 | +++ src/platforms/android/common/mir_native_window.cpp 2016-09-01 23:11:16 +0000 | |||
113 | @@ -322,3 +322,9 @@ | |||
114 | 322 | MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e); | 322 | MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e); |
115 | 323 | return -1; | 323 | return -1; |
116 | 324 | } | 324 | } |
117 | 325 | |||
118 | 326 | void mga::MirNativeWindow::use_native_surface( | ||
119 | 327 | std::shared_ptr<AndroidDriverInterpreter> const& interpreter) | ||
120 | 328 | { | ||
121 | 329 | driver_interpreter = interpreter; | ||
122 | 330 | } | ||
123 | 325 | 331 | ||
124 | === modified file 'src/platforms/android/include/mir_native_window.h' | |||
125 | --- src/platforms/android/include/mir_native_window.h 2016-07-20 04:54:07 +0000 | |||
126 | +++ src/platforms/android/include/mir_native_window.h 2016-09-01 23:11:16 +0000 | |||
127 | @@ -50,8 +50,9 @@ | |||
128 | 50 | int cancelBuffer(struct ANativeWindowBuffer* buffer, int fence); | 50 | int cancelBuffer(struct ANativeWindowBuffer* buffer, int fence); |
129 | 51 | int cancelBufferDeprecated(struct ANativeWindowBuffer* buffer); | 51 | int cancelBufferDeprecated(struct ANativeWindowBuffer* buffer); |
130 | 52 | int setSwapInterval(int interval); | 52 | int setSwapInterval(int interval); |
131 | 53 | void use_native_surface(std::shared_ptr<AndroidDriverInterpreter> const& interpreter); | ||
132 | 53 | private: | 54 | private: |
134 | 54 | std::shared_ptr<AndroidDriverInterpreter> const driver_interpreter; | 55 | std::shared_ptr<AndroidDriverInterpreter> driver_interpreter; |
135 | 55 | std::shared_ptr<NativeWindowReport> const report; | 56 | std::shared_ptr<NativeWindowReport> const report; |
136 | 56 | std::shared_ptr<SyncFileOps> const sync_ops; | 57 | std::shared_ptr<SyncFileOps> const sync_ops; |
137 | 57 | std::vector<struct ANativeWindowBuffer*> cancelled_buffers; | 58 | std::vector<struct ANativeWindowBuffer*> cancelled_buffers; |
138 | 58 | 59 | ||
139 | === modified file 'src/platforms/eglstream-kms/client/client_platform.cpp' | |||
140 | --- src/platforms/eglstream-kms/client/client_platform.cpp 2016-08-03 12:27:57 +0000 | |||
141 | +++ src/platforms/eglstream-kms/client/client_platform.cpp 2016-09-01 23:11:16 +0000 | |||
142 | @@ -39,7 +39,11 @@ | |||
143 | 39 | return std::make_shared<mcle::ClientBufferFactory>(); | 39 | return std::make_shared<mcle::ClientBufferFactory>(); |
144 | 40 | } | 40 | } |
145 | 41 | 41 | ||
147 | 42 | std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*client_surface*/) | 42 | void mcle::ClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, EGLNativeSurface* /*surface*/) |
148 | 43 | { | ||
149 | 44 | } | ||
150 | 45 | |||
151 | 46 | std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*surface*/) | ||
152 | 43 | { | 47 | { |
153 | 44 | return nullptr; | 48 | return nullptr; |
154 | 45 | } | 49 | } |
155 | 46 | 50 | ||
156 | === modified file 'src/platforms/eglstream-kms/client/client_platform.h' | |||
157 | --- src/platforms/eglstream-kms/client/client_platform.h 2016-08-03 06:48:47 +0000 | |||
158 | +++ src/platforms/eglstream-kms/client/client_platform.h 2016-09-01 23:11:16 +0000 | |||
159 | @@ -37,6 +37,7 @@ | |||
160 | 37 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | 37 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; |
161 | 38 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 38 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
162 | 39 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override; | 39 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override; |
163 | 40 | void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override; | ||
164 | 40 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 41 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
165 | 41 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; | 42 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; |
166 | 42 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; | 43 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; |
167 | 43 | 44 | ||
168 | === modified file 'src/platforms/mesa/client/client_platform.cpp' | |||
169 | --- src/platforms/mesa/client/client_platform.cpp 2016-08-26 19:50:25 +0000 | |||
170 | +++ src/platforms/mesa/client/client_platform.cpp 2016-09-01 23:11:16 +0000 | |||
171 | @@ -74,9 +74,15 @@ | |||
172 | 74 | return std::make_shared<mclm::ClientBufferFactory>(buffer_file_ops); | 74 | return std::make_shared<mclm::ClientBufferFactory>(buffer_file_ops); |
173 | 75 | } | 75 | } |
174 | 76 | 76 | ||
175 | 77 | void mclm::ClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) | ||
176 | 78 | { | ||
177 | 79 | auto mnw = std::static_pointer_cast<NativeSurface>(native_window); | ||
178 | 80 | mnw->use_native_surface(surface); | ||
179 | 81 | } | ||
180 | 82 | |||
181 | 77 | std::shared_ptr<void> mclm::ClientPlatform::create_egl_native_window(EGLNativeSurface* client_surface) | 83 | std::shared_ptr<void> mclm::ClientPlatform::create_egl_native_window(EGLNativeSurface* client_surface) |
182 | 78 | { | 84 | { |
184 | 79 | return std::make_shared<NativeSurface>(*client_surface); | 85 | return std::make_shared<NativeSurface>(client_surface); |
185 | 80 | } | 86 | } |
186 | 81 | 87 | ||
187 | 82 | std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display() | 88 | std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display() |
188 | 83 | 89 | ||
189 | === modified file 'src/platforms/mesa/client/client_platform.h' | |||
190 | --- src/platforms/mesa/client/client_platform.h 2016-05-03 06:55:25 +0000 | |||
191 | +++ src/platforms/mesa/client/client_platform.h 2016-09-01 23:11:16 +0000 | |||
192 | @@ -45,7 +45,8 @@ | |||
193 | 45 | void populate(MirPlatformPackage& package) const override; | 45 | void populate(MirPlatformPackage& package) const override; |
194 | 46 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | 46 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; |
195 | 47 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 47 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
197 | 48 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override; | 48 | std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override; |
198 | 49 | void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override; | ||
199 | 49 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 50 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
200 | 50 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; | 51 | MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override; |
201 | 51 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; | 52 | MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override; |
202 | 52 | 53 | ||
203 | === modified file 'src/platforms/mesa/client/native_surface.cpp' | |||
204 | --- src/platforms/mesa/client/native_surface.cpp 2015-04-28 07:54:10 +0000 | |||
205 | +++ src/platforms/mesa/client/native_surface.cpp 2016-09-01 23:11:16 +0000 | |||
206 | @@ -27,6 +27,10 @@ | |||
207 | 27 | 27 | ||
208 | 28 | namespace mclm=mir::client::mesa; | 28 | namespace mclm=mir::client::mesa; |
209 | 29 | 29 | ||
210 | 30 | #define THROW_IF_NULL(s) \ | ||
211 | 31 | if (!(s)) \ | ||
212 | 32 | throw std::logic_error("error: use_egl_native_window(...) has not yet been called"); | ||
213 | 33 | |||
214 | 30 | namespace | 34 | namespace |
215 | 31 | { | 35 | { |
216 | 32 | static int advance_buffer_static(MirMesaEGLNativeSurface* surface, | 36 | static int advance_buffer_static(MirMesaEGLNativeSurface* surface, |
217 | @@ -50,7 +54,7 @@ | |||
218 | 50 | } | 54 | } |
219 | 51 | } | 55 | } |
220 | 52 | 56 | ||
222 | 53 | mclm::NativeSurface::NativeSurface(EGLNativeSurface& surface) | 57 | mclm::NativeSurface::NativeSurface(EGLNativeSurface* surface) |
223 | 54 | : starting(true), surface(surface) | 58 | : starting(true), surface(surface) |
224 | 55 | { | 59 | { |
225 | 56 | surface_advance_buffer = advance_buffer_static; | 60 | surface_advance_buffer = advance_buffer_static; |
226 | @@ -61,6 +65,8 @@ | |||
227 | 61 | int mclm::NativeSurface::advance_buffer(MirBufferPackage* buffer_package) | 65 | int mclm::NativeSurface::advance_buffer(MirBufferPackage* buffer_package) |
228 | 62 | try | 66 | try |
229 | 63 | { | 67 | { |
230 | 68 | THROW_IF_NULL(surface); | ||
231 | 69 | |||
232 | 64 | /* | 70 | /* |
233 | 65 | * At present dri2_create_mir_window_surface will trigger | 71 | * At present dri2_create_mir_window_surface will trigger |
234 | 66 | * mir_advance_colour_buffer which will land here. Since we're still | 72 | * mir_advance_colour_buffer which will land here. Since we're still |
235 | @@ -70,9 +76,9 @@ | |||
236 | 70 | if (starting) | 76 | if (starting) |
237 | 71 | starting = false; | 77 | starting = false; |
238 | 72 | else | 78 | else |
240 | 73 | surface.request_and_wait_for_next_buffer(); | 79 | surface->request_and_wait_for_next_buffer(); |
241 | 74 | 80 | ||
243 | 75 | auto buffer = surface.get_current_buffer(); | 81 | auto buffer = surface->get_current_buffer(); |
244 | 76 | 82 | ||
245 | 77 | auto buffer_to_driver = buffer->native_buffer_handle(); | 83 | auto buffer_to_driver = buffer->native_buffer_handle(); |
246 | 78 | memcpy(buffer_package, buffer_to_driver.get(), sizeof(MirBufferPackage)); | 84 | memcpy(buffer_package, buffer_to_driver.get(), sizeof(MirBufferPackage)); |
247 | @@ -87,7 +93,8 @@ | |||
248 | 87 | int mclm::NativeSurface::get_parameters(MirSurfaceParameters* surface_parameters) | 93 | int mclm::NativeSurface::get_parameters(MirSurfaceParameters* surface_parameters) |
249 | 88 | try | 94 | try |
250 | 89 | { | 95 | { |
252 | 90 | auto params = surface.get_parameters(); | 96 | THROW_IF_NULL(surface); |
253 | 97 | auto params = surface->get_parameters(); | ||
254 | 91 | memcpy(surface_parameters, ¶ms, sizeof(MirSurfaceParameters)); | 98 | memcpy(surface_parameters, ¶ms, sizeof(MirSurfaceParameters)); |
255 | 92 | return MIR_MESA_TRUE; | 99 | return MIR_MESA_TRUE; |
256 | 93 | } | 100 | } |
257 | @@ -100,10 +107,12 @@ | |||
258 | 100 | int mclm::NativeSurface::set_swapinterval(int interval) | 107 | int mclm::NativeSurface::set_swapinterval(int interval) |
259 | 101 | try | 108 | try |
260 | 102 | { | 109 | { |
261 | 110 | THROW_IF_NULL(surface); | ||
262 | 111 | |||
263 | 103 | if ((interval < 0) || (interval > 1)) | 112 | if ((interval < 0) || (interval > 1)) |
264 | 104 | return MIR_MESA_FALSE; | 113 | return MIR_MESA_FALSE; |
265 | 105 | 114 | ||
267 | 106 | surface.request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval); | 115 | surface->request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval); |
268 | 107 | return MIR_MESA_TRUE; | 116 | return MIR_MESA_TRUE; |
269 | 108 | } | 117 | } |
270 | 109 | catch (std::exception const& e) | 118 | catch (std::exception const& e) |
271 | @@ -111,3 +120,8 @@ | |||
272 | 111 | MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e); | 120 | MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e); |
273 | 112 | return MIR_MESA_FALSE; | 121 | return MIR_MESA_FALSE; |
274 | 113 | } | 122 | } |
275 | 123 | |||
276 | 124 | void mclm::NativeSurface::use_native_surface(EGLNativeSurface* native_surface) | ||
277 | 125 | { | ||
278 | 126 | surface = native_surface; | ||
279 | 127 | } | ||
280 | 114 | 128 | ||
281 | === modified file 'src/platforms/mesa/client/native_surface.h' | |||
282 | --- src/platforms/mesa/client/native_surface.h 2015-04-28 07:54:10 +0000 | |||
283 | +++ src/platforms/mesa/client/native_surface.h 2016-09-01 23:11:16 +0000 | |||
284 | @@ -32,15 +32,16 @@ | |||
285 | 32 | class NativeSurface : public MirMesaEGLNativeSurface | 32 | class NativeSurface : public MirMesaEGLNativeSurface |
286 | 33 | { | 33 | { |
287 | 34 | public: | 34 | public: |
289 | 35 | explicit NativeSurface(EGLNativeSurface&); | 35 | explicit NativeSurface(EGLNativeSurface*); |
290 | 36 | 36 | ||
291 | 37 | int advance_buffer(MirBufferPackage* buffer_package); | 37 | int advance_buffer(MirBufferPackage* buffer_package); |
292 | 38 | int get_parameters(MirSurfaceParameters* surface_parameters); | 38 | int get_parameters(MirSurfaceParameters* surface_parameters); |
293 | 39 | int set_swapinterval(int interval); | 39 | int set_swapinterval(int interval); |
294 | 40 | void use_native_surface(EGLNativeSurface* native_surface); | ||
295 | 40 | 41 | ||
296 | 41 | private: | 42 | private: |
297 | 42 | bool starting; | 43 | bool starting; |
299 | 43 | EGLNativeSurface& surface; | 44 | EGLNativeSurface* surface; |
300 | 44 | }; | 45 | }; |
301 | 45 | 46 | ||
302 | 46 | } | 47 | } |
303 | 47 | 48 | ||
304 | === modified file 'src/platforms/mesa/include/native_buffer.h' | |||
305 | --- src/platforms/mesa/include/native_buffer.h 2016-08-03 18:07:27 +0000 | |||
306 | +++ src/platforms/mesa/include/native_buffer.h 2016-09-01 23:11:16 +0000 | |||
307 | @@ -20,6 +20,8 @@ | |||
308 | 20 | #define MIR_GRAPHICS_MESA_NATIVE_BUFFER_H_ | 20 | #define MIR_GRAPHICS_MESA_NATIVE_BUFFER_H_ |
309 | 21 | 21 | ||
310 | 22 | #include <mir_toolkit/mir_native_buffer.h> | 22 | #include <mir_toolkit/mir_native_buffer.h> |
311 | 23 | |||
312 | 24 | #include <stdlib.h> | ||
313 | 23 | #include <gbm.h> | 25 | #include <gbm.h> |
314 | 24 | 26 | ||
315 | 25 | namespace mir | 27 | namespace mir |
316 | 26 | 28 | ||
317 | === modified file 'tests/acceptance-tests/throwback/test_client_library_errors.cpp' | |||
318 | --- tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-08-25 01:11:51 +0000 | |||
319 | +++ tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-09-01 23:11:16 +0000 | |||
320 | @@ -78,6 +78,10 @@ | |||
321 | 78 | dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context); | 78 | dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context); |
322 | 79 | } | 79 | } |
323 | 80 | 80 | ||
324 | 81 | void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/) override | ||
325 | 82 | { | ||
326 | 83 | } | ||
327 | 84 | |||
328 | 81 | std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override | 85 | std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override |
329 | 82 | { | 86 | { |
330 | 83 | if (should_fail<Method::create_egl_native_window, failure_set>()) | 87 | if (should_fail<Method::create_egl_native_window, failure_set>()) |
331 | 84 | 88 | ||
332 | === modified file 'tests/include/mir_test_framework/stub_client_platform_factory.h' | |||
333 | --- tests/include/mir_test_framework/stub_client_platform_factory.h 2016-08-12 18:41:22 +0000 | |||
334 | +++ tests/include/mir_test_framework/stub_client_platform_factory.h 2016-09-01 23:11:16 +0000 | |||
335 | @@ -33,6 +33,7 @@ | |||
336 | 33 | void populate(MirPlatformPackage& package) const override; | 33 | void populate(MirPlatformPackage& package) const override; |
337 | 34 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override; | 34 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override; |
338 | 35 | std::shared_ptr<mir::client::ClientBufferFactory> create_buffer_factory() override; | 35 | std::shared_ptr<mir::client::ClientBufferFactory> create_buffer_factory() override; |
339 | 36 | void use_egl_native_window(std::shared_ptr<void> native_window, mir::client::EGLNativeSurface* surface) override; | ||
340 | 36 | std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface* surface) override; | 37 | std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface* surface) override; |
341 | 37 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 38 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
342 | 38 | MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const override; | 39 | MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const override; |
343 | 39 | 40 | ||
344 | === modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp' | |||
345 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 2016-08-09 13:40:44 +0000 | |||
346 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2016-09-01 23:11:16 +0000 | |||
347 | @@ -71,6 +71,10 @@ | |||
348 | 71 | return std::make_shared<StubPlatformBufferFactory>(); | 71 | return std::make_shared<StubPlatformBufferFactory>(); |
349 | 72 | } | 72 | } |
350 | 73 | 73 | ||
351 | 74 | void mtf::StubClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/) | ||
352 | 75 | { | ||
353 | 76 | } | ||
354 | 77 | |||
355 | 74 | std::shared_ptr<void> mtf::StubClientPlatform::create_egl_native_window(mir::client::EGLNativeSurface* surface) | 78 | std::shared_ptr<void> mtf::StubClientPlatform::create_egl_native_window(mir::client::EGLNativeSurface* surface) |
356 | 75 | { | 79 | { |
357 | 76 | return std::shared_ptr<void>{surface, [](void*){}}; | 80 | return std::shared_ptr<void>{surface, [](void*){}}; |
358 | 77 | 81 | ||
359 | === modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp' | |||
360 | --- tests/unit-tests/client/test_client_buffer_stream.cpp 2016-08-10 10:43:39 +0000 | |||
361 | +++ tests/unit-tests/client/test_client_buffer_stream.cpp 2016-09-01 23:11:16 +0000 | |||
362 | @@ -71,6 +71,9 @@ | |||
363 | 71 | void populate(MirPlatformPackage& /* package */) const override | 71 | void populate(MirPlatformPackage& /* package */) const override |
364 | 72 | { | 72 | { |
365 | 73 | } | 73 | } |
366 | 74 | void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mcl::EGLNativeSurface* /*surface*/) override | ||
367 | 75 | { | ||
368 | 76 | } | ||
369 | 74 | std::shared_ptr<void> create_egl_native_window(mcl::EGLNativeSurface * /* surface */) override | 77 | std::shared_ptr<void> create_egl_native_window(mcl::EGLNativeSurface * /* surface */) override |
370 | 75 | { | 78 | { |
371 | 76 | return mt::fake_shared(egl_native_window); | 79 | return mt::fake_shared(egl_native_window); |
372 | 77 | 80 | ||
373 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' | |||
374 | --- tests/unit-tests/client/test_mir_connection.cpp 2016-06-28 12:18:18 +0000 | |||
375 | +++ tests/unit-tests/client/test_mir_connection.cpp 2016-09-01 23:11:16 +0000 | |||
376 | @@ -206,6 +206,7 @@ | |||
377 | 206 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); | 206 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); |
378 | 207 | MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*)); | 207 | MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*)); |
379 | 208 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); | 208 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); |
380 | 209 | MOCK_METHOD2(use_egl_native_window, void(std::shared_ptr<void>, mcl::EGLNativeSurface*)); | ||
381 | 209 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<void>(mcl::EGLNativeSurface*)); | 210 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<void>(mcl::EGLNativeSurface*)); |
382 | 210 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); | 211 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); |
383 | 211 | MOCK_CONST_METHOD2(get_egl_pixel_format, | 212 | MOCK_CONST_METHOD2(get_egl_pixel_format, |
384 | 212 | 213 | ||
385 | === modified file 'tests/unit-tests/platforms/android/CMakeLists.txt' | |||
386 | --- tests/unit-tests/platforms/android/CMakeLists.txt 2016-08-05 15:32:58 +0000 | |||
387 | +++ tests/unit-tests/platforms/android/CMakeLists.txt 2016-09-01 23:11:16 +0000 | |||
388 | @@ -4,6 +4,11 @@ | |||
389 | 4 | ${ANDROID_HEADERS_INCLUDE_DIRS} | 4 | ${ANDROID_HEADERS_INCLUDE_DIRS} |
390 | 5 | ${PROJECT_SOURCE_DIR}/src/platforms/android/include | 5 | ${PROJECT_SOURCE_DIR}/src/platforms/android/include |
391 | 6 | ) | 6 | ) |
392 | 7 | |||
393 | 8 | set( | ||
394 | 9 | ANDROID_UNIT_TEST_SOURCES | ||
395 | 10 | ) | ||
396 | 11 | |||
397 | 7 | add_subdirectory("server") | 12 | add_subdirectory("server") |
398 | 8 | add_subdirectory("client") | 13 | add_subdirectory("client") |
399 | 9 | 14 | ||
400 | 10 | 15 | ||
401 | === modified file 'tests/unit-tests/platforms/android/client/test_android_client_platform.cpp' | |||
402 | --- tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-01-29 08:18:22 +0000 | |||
403 | +++ tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-09-01 23:11:16 +0000 | |||
404 | @@ -16,6 +16,7 @@ | |||
405 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
406 | 17 | */ | 17 | */ |
407 | 18 | 18 | ||
408 | 19 | #include "mir_native_window.h" | ||
409 | 19 | #include "mir/client_platform.h" | 20 | #include "mir/client_platform.h" |
410 | 20 | #include "mir/test/doubles/mock_client_context.h" | 21 | #include "mir/test/doubles/mock_client_context.h" |
411 | 21 | #include "mir/test/doubles/mock_egl_native_surface.h" | 22 | #include "mir/test/doubles/mock_egl_native_surface.h" |
412 | @@ -59,6 +60,20 @@ | |||
413 | 59 | EXPECT_NE(nullptr, egl_native_window); | 60 | EXPECT_NE(nullptr, egl_native_window); |
414 | 60 | } | 61 | } |
415 | 61 | 62 | ||
416 | 63 | TEST_F(AndroidClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface) | ||
417 | 64 | { | ||
418 | 65 | auto egl_native_window = platform->create_egl_native_window(nullptr); | ||
419 | 66 | EXPECT_NE(nullptr, egl_native_window); | ||
420 | 67 | } | ||
421 | 68 | |||
422 | 69 | TEST_F(AndroidClientPlatformTest, error_interpreter_used_with_null_native_surface) | ||
423 | 70 | { | ||
424 | 71 | auto egl_native_window = platform->create_egl_native_window(nullptr); | ||
425 | 72 | auto native_window = reinterpret_cast<mir::graphics::android::MirNativeWindow*>(egl_native_window.get()); | ||
426 | 73 | ANativeWindow& window = *native_window; | ||
427 | 74 | EXPECT_EQ(window.setSwapInterval(&window, 1), -1); | ||
428 | 75 | } | ||
429 | 76 | |||
430 | 62 | TEST_F(AndroidClientPlatformTest, egl_pixel_format_asks_the_driver) | 77 | TEST_F(AndroidClientPlatformTest, egl_pixel_format_asks_the_driver) |
431 | 63 | { | 78 | { |
432 | 64 | auto const d = reinterpret_cast<EGLDisplay>(0x1234); | 79 | auto const d = reinterpret_cast<EGLDisplay>(0x1234); |
433 | 65 | 80 | ||
434 | === modified file 'tests/unit-tests/platforms/android/client/test_android_native_window.cpp' | |||
435 | --- tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-08-24 02:09:08 +0000 | |||
436 | +++ tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-09-01 23:11:16 +0000 | |||
437 | @@ -73,6 +73,22 @@ | |||
438 | 73 | 73 | ||
439 | 74 | } | 74 | } |
440 | 75 | 75 | ||
441 | 76 | TEST_F(AndroidNativeWindowTest, use_native_surface_call_replaces_existing_interpreter) | ||
442 | 77 | { | ||
443 | 78 | std::shared_ptr<MockAndroidDriverInterpreter> const new_driver_interpreter = | ||
444 | 79 | std::make_shared<NiceMock<MockAndroidDriverInterpreter>>(); | ||
445 | 80 | |||
446 | 81 | // Test that the call goes to the new interpreter instead of the old one | ||
447 | 82 | EXPECT_CALL(*mock_driver_interpreter, sync_to_display(true)) | ||
448 | 83 | .Times(0); | ||
449 | 84 | |||
450 | 85 | EXPECT_CALL(*new_driver_interpreter, sync_to_display(true)) | ||
451 | 86 | .Times(1); | ||
452 | 87 | |||
453 | 88 | mir_native_window.use_native_surface(new_driver_interpreter); | ||
454 | 89 | window.setSwapInterval(&window, 1); | ||
455 | 90 | } | ||
456 | 91 | |||
457 | 76 | TEST_F(AndroidNativeWindowTest, native_window_swapinterval) | 92 | TEST_F(AndroidNativeWindowTest, native_window_swapinterval) |
458 | 77 | { | 93 | { |
459 | 78 | ASSERT_NE(nullptr, window.setSwapInterval); | 94 | ASSERT_NE(nullptr, window.setSwapInterval); |
460 | 79 | 95 | ||
461 | === modified file 'tests/unit-tests/platforms/mesa/client/test_client_platform.cpp' | |||
462 | --- tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-05-26 03:59:12 +0000 | |||
463 | +++ tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-09-01 23:11:16 +0000 | |||
464 | @@ -22,6 +22,7 @@ | |||
465 | 22 | #include "src/platforms/mesa/client/mesa_native_display_container.h" | 22 | #include "src/platforms/mesa/client/mesa_native_display_container.h" |
466 | 23 | #include "mir_test_framework/client_platform_factory.h" | 23 | #include "mir_test_framework/client_platform_factory.h" |
467 | 24 | #include "mir/test/doubles/mock_egl.h" | 24 | #include "mir/test/doubles/mock_egl.h" |
468 | 25 | #include "mir/test/doubles/mock_egl_native_surface.h" | ||
469 | 25 | 26 | ||
470 | 26 | #include "mir_toolkit/mir_client_library.h" | 27 | #include "mir_toolkit/mir_client_library.h" |
471 | 27 | #include "mir_toolkit/mesa/native_display.h" | 28 | #include "mir_toolkit/mesa/native_display.h" |
472 | @@ -155,3 +156,16 @@ | |||
473 | 155 | EXPECT_EQ(mir_pixel_format_xrgb_8888, platform->get_egl_pixel_format(d, c)); | 156 | EXPECT_EQ(mir_pixel_format_xrgb_8888, platform->get_egl_pixel_format(d, c)); |
474 | 156 | EXPECT_EQ(mir_pixel_format_invalid, platform->get_egl_pixel_format(d, c)); | 157 | EXPECT_EQ(mir_pixel_format_invalid, platform->get_egl_pixel_format(d, c)); |
475 | 157 | } | 158 | } |
476 | 159 | |||
477 | 160 | TEST_F(MesaClientPlatformTest, egl_native_window_is_set) | ||
478 | 161 | { | ||
479 | 162 | testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface; | ||
480 | 163 | auto egl_native_window = platform->create_egl_native_window(&mock_surface); | ||
481 | 164 | EXPECT_NE(nullptr, egl_native_window); | ||
482 | 165 | } | ||
483 | 166 | |||
484 | 167 | TEST_F(MesaClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface) | ||
485 | 168 | { | ||
486 | 169 | auto egl_native_window = platform->create_egl_native_window(nullptr); | ||
487 | 170 | EXPECT_NE(nullptr, egl_native_window); | ||
488 | 171 | } | ||
489 | 158 | 172 | ||
490 | === modified file 'tests/unit-tests/platforms/mesa/client/test_native_surface.cpp' | |||
491 | --- tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-05-03 06:55:25 +0000 | |||
492 | +++ tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-09-01 23:11:16 +0000 | |||
493 | @@ -16,18 +16,20 @@ | |||
494 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
495 | 17 | */ | 17 | */ |
496 | 18 | 18 | ||
497 | 19 | #include "src/platforms/mesa/include/native_buffer.h" | ||
498 | 19 | #include "src/platforms/mesa/client/native_surface.h" | 20 | #include "src/platforms/mesa/client/native_surface.h" |
499 | 20 | #include "mir/client_buffer.h" | 21 | #include "mir/client_buffer.h" |
500 | 21 | #include "mir/test/doubles/mock_egl_native_surface.h" | 22 | #include "mir/test/doubles/mock_egl_native_surface.h" |
501 | 22 | #include "mir/test/doubles/mock_client_buffer.h" | 23 | #include "mir/test/doubles/mock_client_buffer.h" |
503 | 23 | 24 | #include "mir/test/fake_shared.h" | |
504 | 24 | #include <gmock/gmock.h> | 25 | #include <gmock/gmock.h> |
505 | 25 | #include <gtest/gtest.h> | 26 | #include <gtest/gtest.h> |
506 | 26 | 27 | ||
511 | 27 | namespace mtd=mir::test::doubles; | 28 | namespace mt=mir::test; |
512 | 28 | namespace mcl=mir::client; | 29 | namespace mtd=mt::doubles; |
513 | 29 | namespace mcl=mir::client; | 30 | namespace mcl=mir::client; |
514 | 30 | namespace mclg=mir::client::mesa; | 31 | namespace mg=mir::graphics; |
515 | 32 | namespace mclg=mcl::mesa; | ||
516 | 31 | namespace geom=mir::geometry; | 33 | namespace geom=mir::geometry; |
517 | 32 | 34 | ||
518 | 33 | class MesaClientNativeSurfaceTest : public ::testing::Test | 35 | class MesaClientNativeSurfaceTest : public ::testing::Test |
519 | @@ -44,18 +46,24 @@ | |||
520 | 44 | .WillByDefault(Return(surf_params)); | 46 | .WillByDefault(Return(surf_params)); |
521 | 45 | ON_CALL(mock_surface, get_current_buffer()) | 47 | ON_CALL(mock_surface, get_current_buffer()) |
522 | 46 | .WillByDefault(Return( | 48 | .WillByDefault(Return( |
524 | 47 | std::make_shared<NiceMock<mtd::MockClientBuffer>>())); | 49 | mt::fake_shared(mock_buffer))); |
525 | 50 | ON_CALL(mock_buffer, native_buffer_handle()) | ||
526 | 51 | .WillByDefault(Return( | ||
527 | 52 | mt::fake_shared(native_buffer))); | ||
528 | 48 | } | 53 | } |
529 | 49 | 54 | ||
530 | 50 | MirSurfaceParameters surf_params; | 55 | MirSurfaceParameters surf_params; |
531 | 56 | const char* error_msg = "thrown as part of test"; | ||
532 | 57 | mg::NativeBuffer native_buffer; | ||
533 | 58 | testing::NiceMock<mtd::MockClientBuffer> mock_buffer; | ||
534 | 51 | testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface; | 59 | testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface; |
536 | 52 | mclg::NativeSurface native_surface{mock_surface}; | 60 | mclg::NativeSurface native_surface{&mock_surface}; |
537 | 53 | }; | 61 | }; |
538 | 54 | 62 | ||
539 | 55 | TEST_F(MesaClientNativeSurfaceTest, basic_parameters) | 63 | TEST_F(MesaClientNativeSurfaceTest, basic_parameters) |
540 | 56 | { | 64 | { |
541 | 57 | MirSurfaceParameters params; | 65 | MirSurfaceParameters params; |
543 | 58 | native_surface.surface_get_parameters(&native_surface, ¶ms); | 66 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_get_parameters(&native_surface, ¶ms)); |
544 | 59 | EXPECT_EQ(surf_params.width, params.width); | 67 | EXPECT_EQ(surf_params.width, params.width); |
545 | 60 | EXPECT_EQ(surf_params.height, params.height); | 68 | EXPECT_EQ(surf_params.height, params.height); |
546 | 61 | EXPECT_EQ(surf_params.pixel_format, params.pixel_format); | 69 | EXPECT_EQ(surf_params.pixel_format, params.pixel_format); |
547 | @@ -72,7 +80,7 @@ | |||
548 | 72 | EXPECT_CALL(mock_surface, get_current_buffer()) | 80 | EXPECT_CALL(mock_surface, get_current_buffer()) |
549 | 73 | .Times(1); | 81 | .Times(1); |
550 | 74 | 82 | ||
552 | 75 | native_surface.surface_advance_buffer(&native_surface, &buffer_package); | 83 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package)); |
553 | 76 | } | 84 | } |
554 | 77 | 85 | ||
555 | 78 | TEST_F(MesaClientNativeSurfaceTest, basic_advance) | 86 | TEST_F(MesaClientNativeSurfaceTest, basic_advance) |
556 | @@ -88,8 +96,8 @@ | |||
557 | 88 | EXPECT_CALL(mock_surface, get_current_buffer()) | 96 | EXPECT_CALL(mock_surface, get_current_buffer()) |
558 | 89 | .Times(1); | 97 | .Times(1); |
559 | 90 | 98 | ||
562 | 91 | native_surface.surface_advance_buffer(&native_surface, &buffer_package); | 99 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package)); |
563 | 92 | native_surface.surface_advance_buffer(&native_surface, &buffer_package); | 100 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package)); |
564 | 93 | } | 101 | } |
565 | 94 | 102 | ||
566 | 95 | TEST_F(MesaClientNativeSurfaceTest, swapinterval_request) | 103 | TEST_F(MesaClientNativeSurfaceTest, swapinterval_request) |
567 | @@ -102,8 +110,8 @@ | |||
568 | 102 | EXPECT_CALL(mock_surface, request_and_wait_for_configure(mir_surface_attrib_swapinterval,1)) | 110 | EXPECT_CALL(mock_surface, request_and_wait_for_configure(mir_surface_attrib_swapinterval,1)) |
569 | 103 | .InSequence(seq); | 111 | .InSequence(seq); |
570 | 104 | 112 | ||
573 | 105 | native_surface.set_swapinterval(0); | 113 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.set_swapinterval(0)); |
574 | 106 | native_surface.set_swapinterval(1); | 114 | EXPECT_EQ(MIR_MESA_TRUE, native_surface.set_swapinterval(1)); |
575 | 107 | } | 115 | } |
576 | 108 | 116 | ||
577 | 109 | TEST_F(MesaClientNativeSurfaceTest, swapinterval_unsupported_request) | 117 | TEST_F(MesaClientNativeSurfaceTest, swapinterval_unsupported_request) |
578 | @@ -119,10 +127,10 @@ | |||
579 | 119 | using namespace testing; | 127 | using namespace testing; |
580 | 120 | 128 | ||
581 | 121 | EXPECT_CALL(mock_surface, get_current_buffer()) | 129 | EXPECT_CALL(mock_surface, get_current_buffer()) |
583 | 122 | .WillOnce(Throw(std::runtime_error(""))); | 130 | .WillOnce(Throw(std::runtime_error(error_msg))); |
584 | 123 | 131 | ||
585 | 124 | MirBufferPackage buffer_package; | 132 | MirBufferPackage buffer_package; |
587 | 125 | EXPECT_THAT(native_surface.advance_buffer(&buffer_package), Eq(MIR_MESA_FALSE)); | 133 | EXPECT_EQ(MIR_MESA_FALSE, native_surface.advance_buffer(&buffer_package)); |
588 | 126 | } | 134 | } |
589 | 127 | 135 | ||
590 | 128 | TEST_F(MesaClientNativeSurfaceTest, returns_error_on_get_parameters_failure) | 136 | TEST_F(MesaClientNativeSurfaceTest, returns_error_on_get_parameters_failure) |
591 | @@ -130,10 +138,10 @@ | |||
592 | 130 | using namespace testing; | 138 | using namespace testing; |
593 | 131 | 139 | ||
594 | 132 | EXPECT_CALL(mock_surface, get_parameters()) | 140 | EXPECT_CALL(mock_surface, get_parameters()) |
596 | 133 | .WillOnce(Throw(std::runtime_error(""))); | 141 | .WillOnce(Throw(std::runtime_error(error_msg))); |
597 | 134 | 142 | ||
598 | 135 | MirSurfaceParameters surface_params; | 143 | MirSurfaceParameters surface_params; |
600 | 136 | EXPECT_THAT(native_surface.get_parameters(&surface_params), Eq(MIR_MESA_FALSE)); | 144 | EXPECT_EQ(MIR_MESA_FALSE, native_surface.get_parameters(&surface_params)); |
601 | 137 | } | 145 | } |
602 | 138 | 146 | ||
603 | 139 | TEST_F(MesaClientNativeSurfaceTest, returns_error_on_set_swap_interval_failure) | 147 | TEST_F(MesaClientNativeSurfaceTest, returns_error_on_set_swap_interval_failure) |
604 | @@ -141,7 +149,42 @@ | |||
605 | 141 | using namespace testing; | 149 | using namespace testing; |
606 | 142 | 150 | ||
607 | 143 | EXPECT_CALL(mock_surface, request_and_wait_for_configure(_,_)) | 151 | EXPECT_CALL(mock_surface, request_and_wait_for_configure(_,_)) |
611 | 144 | .WillOnce(Throw(std::runtime_error(""))); | 152 | .WillOnce(Throw(std::runtime_error(error_msg))); |
612 | 145 | 153 | ||
613 | 146 | EXPECT_THAT(native_surface.set_swapinterval(0), Eq(MIR_MESA_FALSE)); | 154 | EXPECT_EQ(MIR_MESA_FALSE, native_surface.set_swapinterval(0)); |
614 | 155 | } | ||
615 | 156 | |||
616 | 157 | TEST_F(MesaClientNativeSurfaceTest, null_native_surface_returns_error) | ||
617 | 158 | { | ||
618 | 159 | using namespace testing; | ||
619 | 160 | |||
620 | 161 | MirSurfaceParameters params; | ||
621 | 162 | MirBufferPackage buffer_package; | ||
622 | 163 | |||
623 | 164 | mclg::NativeSurface null_native_surface{nullptr}; | ||
624 | 165 | |||
625 | 166 | EXPECT_EQ(MIR_MESA_FALSE, | ||
626 | 167 | null_native_surface.surface_get_parameters(&null_native_surface, ¶ms)); | ||
627 | 168 | EXPECT_EQ(MIR_MESA_FALSE, | ||
628 | 169 | null_native_surface.surface_advance_buffer(&null_native_surface, &buffer_package)); | ||
629 | 170 | EXPECT_EQ(MIR_MESA_FALSE, | ||
630 | 171 | null_native_surface.surface_set_swapinterval(&null_native_surface, 1)); | ||
631 | 172 | } | ||
632 | 173 | |||
633 | 174 | TEST_F(MesaClientNativeSurfaceTest, native_surface_after_null_returns_success) | ||
634 | 175 | { | ||
635 | 176 | using namespace testing; | ||
636 | 177 | |||
637 | 178 | MirSurfaceParameters params; | ||
638 | 179 | MirBufferPackage buffer_package; | ||
639 | 180 | |||
640 | 181 | mclg::NativeSurface native_surface{nullptr}; | ||
641 | 182 | |||
642 | 183 | native_surface.use_native_surface(&mock_surface); | ||
643 | 184 | EXPECT_EQ(MIR_MESA_TRUE, | ||
644 | 185 | native_surface.surface_get_parameters(&native_surface, ¶ms)); | ||
645 | 186 | EXPECT_EQ(MIR_MESA_TRUE, | ||
646 | 187 | native_surface.surface_advance_buffer(&native_surface, &buffer_package)); | ||
647 | 188 | EXPECT_EQ(MIR_MESA_TRUE, | ||
648 | 189 | native_surface.surface_set_swapinterval(&native_surface, 1)); | ||
649 | 147 | } | 190 | } |