Mir

Merge lp:~kdub/mir/fix-1661521 into lp:mir

Proposed by Kevin DuBois on 2017-02-03
Status: Merged
Approved by: Daniel van Vugt on 2017-02-06
Approved revision: 4013
Merged at revision: 4015
Proposed branch: lp:~kdub/mir/fix-1661521
Merge into: lp:mir
Diff against target: 682 lines (+254/-29)
21 files modified
src/client/buffer_factory.cpp (+52/-8)
src/client/buffer_factory.h (+40/-2)
src/client/mir_connection.cpp (+1/-1)
src/include/client/mir/client_buffer_factory.h (+2/-0)
src/platforms/android/client/android_client_buffer_factory.cpp (+9/-0)
src/platforms/android/client/android_client_buffer_factory.h (+3/-0)
src/platforms/eglstream-kms/client/client_buffer_factory.cpp (+10/-0)
src/platforms/eglstream-kms/client/client_buffer_factory.h (+4/-1)
src/platforms/mesa/client/client_buffer.cpp (+24/-0)
src/platforms/mesa/client/client_buffer.h (+4/-0)
src/platforms/mesa/client/client_buffer_factory.cpp (+12/-0)
src/platforms/mesa/client/client_buffer_factory.h (+3/-0)
tests/include/mir/test/doubles/mock_client_buffer_factory.h (+2/-0)
tests/include/mir/test/doubles/stub_client_buffer_factory.h (+7/-0)
tests/mir_test_framework/stub_client_platform_factory.cpp (+11/-0)
tests/unit-tests/client/test_buffer_vault.cpp (+5/-3)
tests/unit-tests/client/test_client_buffer_stream.cpp (+11/-11)
tests/unit-tests/client/test_mir_connection.cpp (+8/-2)
tests/unit-tests/client/test_protobuf_rpc_channel.cpp (+4/-0)
tests/unit-tests/client/test_screencast_stream.cpp (+7/-1)
tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp (+35/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-1661521
Reviewer Review Type Date Requested Status
Chris Halse Rogers 2017-02-03 Approve on 2017-02-06
Mir CI Bot continuous-integration Approve on 2017-02-03
Review via email: mp+316369@code.launchpad.net

Commit message

Make sure native format is properly communicated all the way from client through nested to host and back again. The native format was getting lost, resulting in a failed EGL buffer mapping, resulting in black nested clients.

fixes: LP: #1661521

Description of the change

Make sure native format is properly communicated all the way from client through nested to host and back again. The native format was getting lost, resulting in a failed EGL buffer mapping, resulting in black nested clients.

fixes: LP: #1661521

tested on mesa against the bug of course, as well as m10.

To post a comment you must log in.
lp:~kdub/mir/fix-1661521 updated on 2017-02-03
4013. By Kevin DuBois on 2017-02-03

fix clang complaint

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4012
https://mir-jenkins.ubuntu.com/job/mir-ci/2937/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3888/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3967
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3957
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3957
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3957
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3915/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3915
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3915/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3915/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3915
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3915/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3915
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3915/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3915
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3915/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2937/rebuild

review: Needs Fixing (continuous-integration)
Cemil Azizoglu (cemil-azizoglu) wrote :
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4013
https://mir-jenkins.ubuntu.com/job/mir-ci/2938/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3889
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3968
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3958
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3958
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3958
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3916/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2938/rebuild

review: Approve (continuous-integration)
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4012
https://mir-jenkins.ubuntu.com/job/mir-ci/2940/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3891
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3970
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3960
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3960
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3960
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3918/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3918/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3918/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3918/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3918/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3918
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3918/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2940/rebuild

review: Approve (continuous-integration)
Chris Halse Rogers (raof) wrote :

A couple of style-guide nits (const EGLint vs EGLint const), but LGTM otherwise.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/buffer_factory.cpp'
2--- src/client/buffer_factory.cpp 2017-01-30 08:13:20 +0000
3+++ src/client/buffer_factory.cpp 2017-02-03 19:56:19 +0000
4@@ -34,8 +34,21 @@
5 native_buffer_factory(native_buffer_factory),
6 connection(connection),
7 size(size),
8- format(format),
9- usage(usage),
10+ sw_request(SoftwareRequest{format, usage}),
11+ cb(cb),
12+ cb_context(cb_context)
13+{
14+}
15+
16+mcl::BufferFactory::AllocationRequest::AllocationRequest(
17+ std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
18+ MirConnection* connection,
19+ geom::Size size, uint32_t native_format, uint32_t native_flags,
20+ MirBufferCallback cb, void* cb_context) :
21+ native_buffer_factory(native_buffer_factory),
22+ connection(connection),
23+ size(size),
24+ native_request(NativeRequest{native_format, native_flags}),
25 cb(cb),
26 cb_context(cb_context)
27 {
28@@ -55,6 +68,20 @@
29 std::make_unique<AllocationRequest>(factory, connection, size, format, usage, cb, cb_context));
30 }
31
32+void mcl::BufferFactory::expect_buffer(
33+ std::shared_ptr<mcl::ClientBufferFactory> const& factory,
34+ MirConnection* connection,
35+ geometry::Size size,
36+ uint32_t native_format,
37+ uint32_t native_flags,
38+ MirBufferCallback cb,
39+ void* cb_context)
40+{
41+ std::lock_guard<decltype(mutex)> lk(mutex);
42+ allocation_requests.emplace_back(
43+ std::make_unique<AllocationRequest>(factory, connection, size, native_format, native_flags, cb, cb_context));
44+}
45+
46 std::unique_ptr<mcl::MirBuffer> mcl::BufferFactory::generate_buffer(mir::protobuf::Buffer const& buffer)
47 {
48 std::lock_guard<decltype(mutex)> lk(mutex);
49@@ -76,13 +103,30 @@
50 }
51 else
52 {
53+ auto factory = (*request_it)->native_buffer_factory;
54+ std::shared_ptr<mcl::ClientBuffer> client_buffer;
55+ auto usage = mir_buffer_usage_hardware;
56+ if ((*request_it)->native_request.is_set())
57+ {
58+ auto& req = (*request_it)->native_request.value();
59+ client_buffer = factory->create_buffer(
60+ mcl::protobuf_to_native_buffer(buffer), req.native_format, req.native_flags);
61+ }
62+ else if ((*request_it)->sw_request.is_set())
63+ {
64+ auto& req = (*request_it)->sw_request.value();
65+ usage = req.usage;
66+ client_buffer = factory->create_buffer(
67+ mcl::protobuf_to_native_buffer(buffer), (*request_it)->size, req.format);
68+ }
69+ else
70+ {
71+ BOOST_THROW_EXCEPTION(std::logic_error("could not create buffer"));
72+ }
73+
74 b = std::make_unique<Buffer>(
75- (*request_it)->cb, (*request_it)->cb_context,
76- buffer.buffer_id(),
77- (*request_it)->native_buffer_factory->create_buffer(
78- mcl::protobuf_to_native_buffer(buffer),
79- (*request_it)->size, (*request_it)->format),
80- (*request_it)->connection, (*request_it)->usage);
81+ (*request_it)->cb, (*request_it)->cb_context, buffer.buffer_id(),
82+ client_buffer, (*request_it)->connection, usage);
83 }
84
85 allocation_requests.erase(request_it);
86
87=== modified file 'src/client/buffer_factory.h'
88--- src/client/buffer_factory.h 2017-01-24 07:37:03 +0000
89+++ src/client/buffer_factory.h 2017-02-03 19:56:19 +0000
90@@ -20,6 +20,7 @@
91 #define MIR_CLIENT_MIR_BUFFER_FACTORY_H
92
93 #include "mir/geometry/size.h"
94+#include "mir/optional_value.h"
95 #include "mir_protobuf.pb.h"
96 #include "buffer.h"
97 #include <mutex>
98@@ -45,6 +46,14 @@
99 MirBufferUsage usage,
100 MirBufferCallback cb,
101 void* cb_context) = 0;
102+ virtual void expect_buffer(
103+ std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
104+ MirConnection* connection,
105+ geometry::Size size,
106+ uint32_t native_format,
107+ uint32_t native_flags,
108+ MirBufferCallback cb,
109+ void* cb_context) = 0;
110 virtual void cancel_requests_with_context(void*) = 0;
111
112 private:
113@@ -64,13 +73,34 @@
114 MirBufferUsage usage,
115 MirBufferCallback cb,
116 void* cb_context) override;
117+ void expect_buffer(
118+ std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
119+ MirConnection* connection,
120+ geometry::Size size,
121+ uint32_t native_format,
122+ uint32_t native_flags,
123+ MirBufferCallback cb,
124+ void* cb_context) override;
125 void cancel_requests_with_context(void*) override;
126
127 private:
128 std::mutex mutex;
129 int error_id { -1 };
130+
131 struct AllocationRequest
132 {
133+ struct NativeRequest
134+ {
135+ uint32_t native_format;
136+ uint32_t native_flags;
137+ };
138+
139+ struct SoftwareRequest
140+ {
141+ MirPixelFormat format;
142+ MirBufferUsage usage;
143+ };
144+
145 AllocationRequest(
146 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
147 MirConnection* connection,
148@@ -79,12 +109,20 @@
149 MirBufferUsage usage,
150 MirBufferCallback cb,
151 void* cb_context);
152+ AllocationRequest(
153+ std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
154+ MirConnection* connection,
155+ geometry::Size size,
156+ uint32_t native_format,
157+ uint32_t native_flags,
158+ MirBufferCallback cb,
159+ void* cb_context);
160
161 std::shared_ptr<ClientBufferFactory> const native_buffer_factory;
162 MirConnection* connection;
163 geometry::Size size;
164- MirPixelFormat format;
165- MirBufferUsage usage;
166+ optional_value<NativeRequest> native_request;
167+ optional_value<SoftwareRequest> sw_request;
168 MirBufferCallback cb;
169 void* cb_context;
170 };
171
172=== modified file 'src/client/mir_connection.cpp'
173--- src/client/mir_connection.cpp 2017-02-03 07:58:20 +0000
174+++ src/client/mir_connection.cpp 2017-02-03 19:56:19 +0000
175@@ -1304,7 +1304,7 @@
176 client_buffer_factory = platform->create_buffer_factory();
177 buffer_factory->expect_buffer(
178 client_buffer_factory, this,
179- size, mir_pixel_format_invalid, mir_buffer_usage_hardware,
180+ size, native_format, native_flags,
181 callback, context);
182 server.allocate_buffers(&request, ignored.get(), gp::NewCallback(ignore));
183 }
184
185=== modified file 'src/include/client/mir/client_buffer_factory.h'
186--- src/include/client/mir/client_buffer_factory.h 2015-02-22 07:46:25 +0000
187+++ src/include/client/mir/client_buffer_factory.h 2017-02-03 19:56:19 +0000
188@@ -47,6 +47,8 @@
189 */
190 virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,
191 geometry::Size size, MirPixelFormat pf) = 0;
192+ virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,
193+ unsigned int native_pf, unsigned int native_flags) = 0;
194
195 protected:
196 ClientBufferFactory() = default;
197
198=== modified file 'src/platforms/android/client/android_client_buffer_factory.cpp'
199--- src/platforms/android/client/android_client_buffer_factory.cpp 2015-02-22 07:46:25 +0000
200+++ src/platforms/android/client/android_client_buffer_factory.cpp 2017-02-03 19:56:19 +0000
201@@ -18,12 +18,14 @@
202 */
203
204 #include "android_client_buffer_factory.h"
205+#include "android_format_conversion-inl.h"
206 #include "buffer_registrar.h"
207 #include "buffer.h"
208
209 namespace mcl=mir::client;
210 namespace mcla=mir::client::android;
211 namespace geom=mir::geometry;
212+namespace mga=mir::graphics::android;
213
214 mcla::AndroidClientBufferFactory::AndroidClientBufferFactory(
215 std::shared_ptr<BufferRegistrar> const& buffer_registrar) :
216@@ -36,3 +38,10 @@
217 (void)size; // TODO: remove this unused parameter
218 return std::make_shared<mcla::Buffer>(registrar, *package, pf);
219 }
220+
221+std::shared_ptr<mcl::ClientBuffer> mcla::AndroidClientBufferFactory::create_buffer(
222+ std::shared_ptr<MirBufferPackage> const& package,
223+ unsigned int native_pf, unsigned int)
224+{
225+ return std::make_shared<mcla::Buffer>(registrar, *package, mga::to_mir_format(native_pf));
226+}
227
228=== modified file 'src/platforms/android/client/android_client_buffer_factory.h'
229--- src/platforms/android/client/android_client_buffer_factory.h 2015-02-22 07:46:25 +0000
230+++ src/platforms/android/client/android_client_buffer_factory.h 2017-02-03 19:56:19 +0000
231@@ -45,6 +45,9 @@
232 std::shared_ptr<MirBufferPackage> const& package,
233 geometry::Size size,
234 MirPixelFormat pf) override;
235+ std::shared_ptr<ClientBuffer> create_buffer(
236+ std::shared_ptr<MirBufferPackage> const& package,
237+ unsigned int native_pf, unsigned int native_flags) override;
238 private:
239 std::shared_ptr<BufferRegistrar> const registrar;
240 };
241
242=== modified file 'src/platforms/eglstream-kms/client/client_buffer_factory.cpp'
243--- src/platforms/eglstream-kms/client/client_buffer_factory.cpp 2016-05-31 01:21:42 +0000
244+++ src/platforms/eglstream-kms/client/client_buffer_factory.cpp 2017-02-03 19:56:19 +0000
245@@ -19,6 +19,8 @@
246
247 #include "client_buffer_factory.h"
248 #include "client_buffer.h"
249+#include <boost/throw_exception.hpp>
250+#include <stdexcept>
251
252 namespace mcl=mir::client;
253 namespace mcle=mir::client::eglstream;
254@@ -34,3 +36,11 @@
255 geometry::Size{package->width, package->height},
256 pf);
257 }
258+
259+std::shared_ptr<mcl::ClientBuffer>
260+mcle::ClientBufferFactory::create_buffer(
261+ std::shared_ptr<MirBufferPackage> const&,
262+ unsigned int, unsigned int)
263+{
264+ BOOST_THROW_EXCEPTION(std::runtime_error("no native buffers on eglstream platform"));
265+}
266
267=== modified file 'src/platforms/eglstream-kms/client/client_buffer_factory.h'
268--- src/platforms/eglstream-kms/client/client_buffer_factory.h 2016-05-31 01:21:42 +0000
269+++ src/platforms/eglstream-kms/client/client_buffer_factory.h 2017-02-03 19:56:19 +0000
270@@ -36,7 +36,10 @@
271
272 std::shared_ptr<client::ClientBuffer> create_buffer(
273 std::shared_ptr<MirBufferPackage> const& package,
274- geometry::Size size, MirPixelFormat pf);
275+ geometry::Size size, MirPixelFormat pf) override;
276+ std::shared_ptr<ClientBuffer> create_buffer(
277+ std::shared_ptr<MirBufferPackage> const& package,
278+ unsigned int native_pf, unsigned int native_flags) override;
279 };
280
281 }
282
283=== modified file 'src/platforms/mesa/client/client_buffer.cpp'
284--- src/platforms/mesa/client/client_buffer.cpp 2017-01-18 02:29:37 +0000
285+++ src/platforms/mesa/client/client_buffer.cpp 2017-02-03 19:56:19 +0000
286@@ -103,6 +103,9 @@
287 EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(creation_package->stride),
288 EGL_NONE}
289 {
290+ if (pf == mir_pixel_format_invalid)
291+ BOOST_THROW_EXCEPTION(std::invalid_argument("cannot create buffer with mir_pixel_format_invalid"));
292+
293 if (package->fd_items != 1)
294 {
295 BOOST_THROW_EXCEPTION(std::runtime_error(
296@@ -110,6 +113,27 @@
297 }
298 }
299
300+mclm::ClientBuffer::ClientBuffer(
301+ std::shared_ptr<BufferFileOps> const& buffer_file_ops,
302+ std::shared_ptr<MirBufferPackage> const& package,
303+ geometry::Size size,
304+ unsigned int native_pf, unsigned int /*native_flags*/) :
305+ buffer_file_ops{buffer_file_ops},
306+ creation_package{to_native_buffer(*package)},
307+ rect({geom::Point{0, 0}, size}),
308+ buffer_pf{mir::graphics::mesa::gbm_format_to_mir_format(native_pf)},
309+ egl_image_attrs{
310+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
311+ EGL_WIDTH, static_cast<const EGLint>(creation_package->width),
312+ EGL_HEIGHT, static_cast<const EGLint>(creation_package->height),
313+ EGL_LINUX_DRM_FOURCC_EXT, static_cast<const EGLint>(native_pf),
314+ EGL_DMA_BUF_PLANE0_FD_EXT, creation_package->fd[0],
315+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
316+ EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(creation_package->stride),
317+ EGL_NONE}
318+{
319+}
320+
321 mclm::ClientBuffer::~ClientBuffer() noexcept
322 {
323 // TODO (@raof): Error reporting? It should not be possible for this to fail; if it does,
324
325=== modified file 'src/platforms/mesa/client/client_buffer.h'
326--- src/platforms/mesa/client/client_buffer.h 2017-01-18 02:29:37 +0000
327+++ src/platforms/mesa/client/client_buffer.h 2017-02-03 19:56:19 +0000
328@@ -44,6 +44,10 @@
329 std::shared_ptr<MirBufferPackage> const& buffer_package,
330 geometry::Size size,
331 MirPixelFormat pf);
332+ ClientBuffer(std::shared_ptr<BufferFileOps> const& buffer_file_ops,
333+ std::shared_ptr<MirBufferPackage> const& buffer_package,
334+ geometry::Size size,
335+ unsigned int native_pf, unsigned int native_flags);
336
337 ~ClientBuffer() noexcept;
338
339
340=== modified file 'src/platforms/mesa/client/client_buffer_factory.cpp'
341--- src/platforms/mesa/client/client_buffer_factory.cpp 2014-03-06 06:05:17 +0000
342+++ src/platforms/mesa/client/client_buffer_factory.cpp 2017-02-03 19:56:19 +0000
343@@ -42,3 +42,15 @@
344 geometry::Size{package->width, package->height},
345 pf);
346 }
347+
348+std::shared_ptr<mcl::ClientBuffer>
349+mclm::ClientBufferFactory::create_buffer(
350+ std::shared_ptr<MirBufferPackage> const& package,
351+ unsigned int native_pf, unsigned int native_flags)
352+{
353+ return std::make_shared<mclm::ClientBuffer>(
354+ buffer_file_ops,
355+ package,
356+ geometry::Size{package->width, package->height},
357+ native_pf, native_flags);
358+}
359
360=== modified file 'src/platforms/mesa/client/client_buffer_factory.h'
361--- src/platforms/mesa/client/client_buffer_factory.h 2015-02-22 07:46:25 +0000
362+++ src/platforms/mesa/client/client_buffer_factory.h 2017-02-03 19:56:19 +0000
363@@ -39,6 +39,9 @@
364 std::shared_ptr<client::ClientBuffer> create_buffer(
365 std::shared_ptr<MirBufferPackage> const& package,
366 geometry::Size size, MirPixelFormat pf);
367+ std::shared_ptr<client::ClientBuffer> create_buffer(
368+ std::shared_ptr<MirBufferPackage> const& package,
369+ unsigned int native_pf, unsigned int native_flags);
370 private:
371 std::shared_ptr<BufferFileOps> const buffer_file_ops;
372 };
373
374=== modified file 'tests/include/mir/test/doubles/mock_client_buffer_factory.h'
375--- tests/include/mir/test/doubles/mock_client_buffer_factory.h 2015-06-17 05:20:42 +0000
376+++ tests/include/mir/test/doubles/mock_client_buffer_factory.h 2017-02-03 19:56:19 +0000
377@@ -36,6 +36,8 @@
378 std::shared_ptr<client::ClientBuffer>(
379 std::shared_ptr<MirBufferPackage> const& /*package*/,
380 mir::geometry::Size /*size*/, MirPixelFormat /*pf*/));
381+ MOCK_METHOD3(create_buffer, std::shared_ptr<client::ClientBuffer>(
382+ std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t));
383 };
384 }
385 }
386
387=== modified file 'tests/include/mir/test/doubles/stub_client_buffer_factory.h'
388--- tests/include/mir/test/doubles/stub_client_buffer_factory.h 2016-08-09 13:02:44 +0000
389+++ tests/include/mir/test/doubles/stub_client_buffer_factory.h 2017-02-03 19:56:19 +0000
390@@ -37,6 +37,13 @@
391 {
392 return std::make_shared<StubClientBuffer>(package, size, pf, nullptr);
393 }
394+
395+ std::shared_ptr<client::ClientBuffer> create_buffer(
396+ std::shared_ptr<MirBufferPackage> const& package, uint32_t, uint32_t)
397+ {
398+ return std::make_shared<StubClientBuffer>(
399+ package, geometry::Size{package->width, package->height}, mir_pixel_format_abgr_8888, nullptr);
400+ }
401 };
402
403 }
404
405=== modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
406--- tests/mir_test_framework/stub_client_platform_factory.cpp 2017-02-01 22:28:16 +0000
407+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2017-02-03 19:56:19 +0000
408@@ -138,6 +138,17 @@
409 return std::make_shared<mtd::StubClientBuffer>(package, size, pf,
410 std::make_shared<mtf::NativeBuffer>(properties));
411 }
412+
413+ std::shared_ptr<mcl::ClientBuffer> create_buffer(
414+ std::shared_ptr<MirBufferPackage> const& package, uint32_t, uint32_t) override
415+ {
416+ mir::graphics::BufferUsage usage = mir::graphics::BufferUsage::hardware;
417+ geom::Size size {package->width, package->height};
418+ auto pf = mir_pixel_format_abgr_8888;
419+ mir::graphics::BufferProperties properties { size, pf, usage };
420+ return std::make_shared<mtd::StubClientBuffer>(package, size, pf,
421+ std::make_shared<mtf::NativeBuffer>(properties));
422+ }
423 };
424 return std::make_shared<StubPlatformBufferFactory>();
425 }
426
427=== modified file 'tests/unit-tests/client/test_buffer_vault.cpp'
428--- tests/unit-tests/client/test_buffer_vault.cpp 2017-01-18 02:29:37 +0000
429+++ tests/unit-tests/client/test_buffer_vault.cpp 2017-02-03 19:56:19 +0000
430@@ -49,7 +49,7 @@
431 {
432 MockClientBufferFactory()
433 {
434- ON_CALL(*this, create_buffer(_,_,_))
435+ ON_CALL(*this, create_buffer(_,An<geom::Size>(),_))
436 .WillByDefault(Invoke([](
437 std::shared_ptr<MirBufferPackage> const&, geom::Size size, MirPixelFormat)
438 {
439@@ -61,6 +61,8 @@
440 }
441 MOCK_METHOD3(create_buffer, std::shared_ptr<mcl::ClientBuffer>(
442 std::shared_ptr<MirBufferPackage> const&, geom::Size, MirPixelFormat));
443+ MOCK_METHOD3(create_buffer, std::shared_ptr<mcl::ClientBuffer>(
444+ std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t));
445 };
446
447 struct MockServerRequests : mcl::ServerBufferRequests
448@@ -272,7 +274,7 @@
449 ON_CALL(*mock_buffer, size())
450 .WillByDefault(Return(size));
451 EXPECT_CALL(*mock_buffer, increment_age());
452- ON_CALL(mock_platform_factory, create_buffer(_,_,_))
453+ ON_CALL(mock_platform_factory, create_buffer(_,An<uint32_t>(),_))
454 .WillByDefault(Return(mock_buffer));
455 auto b1 = std::make_shared<mcl::Buffer>(
456 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);
457@@ -289,7 +291,7 @@
458 ON_CALL(*mock_buffer, size())
459 .WillByDefault(Return(size));
460 EXPECT_CALL(*mock_buffer, mark_as_submitted());
461- ON_CALL(mock_platform_factory, create_buffer(_,_,_))
462+ ON_CALL(mock_platform_factory, create_buffer(_,An<uint32_t>(),_))
463 .WillByDefault(Return(mock_buffer));
464 auto b1 = std::make_shared<mcl::Buffer>(
465 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);
466
467=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
468--- tests/unit-tests/client/test_client_buffer_stream.cpp 2017-01-30 08:13:20 +0000
469+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2017-02-03 19:56:19 +0000
470@@ -167,7 +167,7 @@
471 {
472 ClientBufferStream()
473 {
474- ON_CALL(mock_factory, create_buffer(_,_,_))
475+ ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
476 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));
477 }
478
479@@ -305,7 +305,7 @@
480
481 TEST_F(ClientBufferStream, uses_buffer_message_from_server)
482 {
483- EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
484+ EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
485 .WillOnce(Return(std::make_shared<mtd::NullClientBuffer>()));
486 mcl::BufferStream bs(
487 nullptr, nullptr, wait_handle, mock_protobuf_server,
488@@ -382,10 +382,10 @@
489 auto protobuf_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);
490
491 Sequence seq;
492- EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_1),_,_))
493+ EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_1),An<geom::Size>(),_))
494 .InSequence(seq)
495 .WillOnce(Return(client_buffer_1));
496- EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_2),_,_))
497+ EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_2),An<geom::Size>(),_))
498 .InSequence(seq)
499 .WillOnce(Return(client_buffer_2));
500
501@@ -448,7 +448,7 @@
502 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
503 ON_CALL(mock_client_buffer, size())
504 .WillByDefault(Return(size));
505- EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
506+ EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
507 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
508
509 mcl::BufferStream bs(
510@@ -470,7 +470,7 @@
511 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
512 ON_CALL(mock_client_buffer, size())
513 .WillByDefault(Return(size));
514- ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
515+ ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
516 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
517 mcl::BufferStream bs(
518 nullptr, nullptr, wait_handle, mock_protobuf_server,
519@@ -568,7 +568,7 @@
520 NiceMock<mtd::MockClientBuffer> second_mock_client_buffer;
521 ON_CALL(second_mock_client_buffer, size())
522 .WillByDefault(Return(size));
523- EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
524+ EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
525 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
526
527 mcl::BufferStream bs(
528@@ -582,7 +582,7 @@
529 another_buffer_package.set_buffer_id(id);
530 another_buffer_package.set_width(size.width.as_int());
531 another_buffer_package.set_height(size.height.as_int());
532- EXPECT_CALL(mock_factory, create_buffer(_,_,_))
533+ EXPECT_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
534 .WillOnce(Return(mt::fake_shared(second_mock_client_buffer)));
535 EXPECT_CALL(mock_protobuf_server, submit_buffer(_,_,_))
536 .WillOnce(mtd::RunProtobufClosure());
537@@ -599,7 +599,7 @@
538 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
539 ON_CALL(mock_client_buffer, size())
540 .WillByDefault(Return(size));
541- ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
542+ ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
543 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
544 ON_CALL(mock_protobuf_server, submit_buffer(_,_,_))
545 .WillByDefault(mtd::RunProtobufClosure());
546@@ -741,7 +741,7 @@
547 {
548 auto format = mir_pixel_format_bgr_888;
549 response.set_pixel_format(format);
550- EXPECT_CALL(mock_factory, create_buffer(_,_,format))
551+ EXPECT_CALL(mock_factory, create_buffer(_,_,TypedEq<MirPixelFormat>(format)))
552 .WillRepeatedly(Return(std::make_shared<mtd::NullClientBuffer>()));
553 mcl::BufferStream bs(
554 nullptr, nullptr, wait_handle, mock_protobuf_server,
555@@ -755,7 +755,7 @@
556
557 TEST_F(ClientBufferStream, keeps_accurate_buffer_id)
558 {
559- ON_CALL(mock_factory, create_buffer(_,_,_))
560+ ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
561 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>(size)));
562 mcl::BufferStream stream(
563 nullptr, nullptr, wait_handle, mock_protobuf_server,
564
565=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
566--- tests/unit-tests/client/test_mir_connection.cpp 2017-02-02 14:35:43 +0000
567+++ tests/unit-tests/client/test_mir_connection.cpp 2017-02-03 19:56:19 +0000
568@@ -93,6 +93,12 @@
569 MirBufferUsage usage,
570 MirBufferCallback cb,
571 void* cb_context));
572+ MOCK_METHOD7(expect_buffer, void(
573+ std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
574+ MirConnection* connection,
575+ geom::Size size, uint32_t, uint32_t,
576+ MirBufferCallback cb,
577+ void* cb_context));
578 };
579
580 struct MockRpcChannel : public mir::client::rpc::MirBasicRpcChannel,
581@@ -849,7 +855,7 @@
582 params->set_buffer_usage(usage);
583 params->set_pixel_format(format);
584 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));
585- EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, format, usage, nullptr, nullptr));
586+ EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, TypedEq<MirPixelFormat>(format), usage, nullptr, nullptr));
587
588 connection->allocate_buffer(size, format, nullptr, nullptr);
589 }
590@@ -869,7 +875,7 @@
591 params->set_native_format(native_format);
592 params->set_flags(native_flags);
593 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));
594- EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, _, mir_buffer_usage_hardware, nullptr, nullptr));
595+ EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, TypedEq<uint32_t>(native_format), TypedEq<uint32_t>(native_flags), nullptr, nullptr));
596
597 connection->allocate_buffer(size, native_format, native_flags, nullptr, nullptr);
598 }
599
600=== modified file 'tests/unit-tests/client/test_protobuf_rpc_channel.cpp'
601--- tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2017-01-24 07:55:14 +0000
602+++ tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2017-02-03 19:56:19 +0000
603@@ -688,6 +688,10 @@
604 MirConnection*,
605 mir::geometry::Size, MirPixelFormat, MirBufferUsage,
606 MirBufferCallback, void*));
607+ MOCK_METHOD7(expect_buffer, void(
608+ std::shared_ptr<mcl::ClientBufferFactory> const&,
609+ MirConnection*, mir::geometry::Size, uint32_t, uint32_t,
610+ MirBufferCallback, void*));
611 };
612
613 namespace
614
615=== modified file 'tests/unit-tests/client/test_screencast_stream.cpp'
616--- tests/unit-tests/client/test_screencast_stream.cpp 2017-01-18 02:29:37 +0000
617+++ tests/unit-tests/client/test_screencast_stream.cpp 2017-02-03 19:56:19 +0000
618@@ -75,7 +75,7 @@
619 {
620 ScreencastStream()
621 {
622- ON_CALL(mock_factory, create_buffer(_,_,_))
623+ ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
624 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));
625 }
626
627@@ -170,6 +170,12 @@
628 return nullptr;
629 }
630
631+ std::shared_ptr<mcl::ClientBuffer> create_buffer(
632+ std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t)
633+ {
634+ return create_buffer(nullptr, geom::Size{0,0}, mir_pixel_format_invalid);
635+ }
636+
637 void start_failing()
638 {
639 fail = true;
640
641=== modified file 'tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp'
642--- tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp 2017-01-18 02:29:37 +0000
643+++ tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp 2017-02-03 19:56:19 +0000
644@@ -217,3 +217,38 @@
645 EXPECT_THAT(egl_buffer, Eq(nullptr));
646 EXPECT_THAT(attrs, mir::test::doubles::AttrMatches(expected_image_attrs));
647 }
648+
649+//LP: #1661521
650+TEST_F(MesaClientBufferTest, suggests_dma_import_with_native_format)
651+{
652+ auto format = GBM_FORMAT_ABGR8888;
653+ static EGLint expected_image_attrs[] =
654+ {
655+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
656+ EGL_WIDTH, static_cast<const EGLint>(package->width),
657+ EGL_HEIGHT, static_cast<const EGLint>(package->height),
658+ EGL_LINUX_DRM_FOURCC_EXT, static_cast<const EGLint>(format),
659+ EGL_DMA_BUF_PLANE0_FD_EXT, package->fd[0],
660+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
661+ EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(package->stride),
662+ EGL_NONE
663+ };
664+
665+ EGLenum type;
666+ EGLClientBuffer egl_buffer;
667+ EGLint* attrs;
668+
669+ mclg::ClientBuffer buffer(buffer_file_ops, package, size, format, 0);
670+ buffer.egl_image_creation_parameters(&type, &egl_buffer, &attrs);
671+
672+ EXPECT_THAT(type, Eq(static_cast<EGLenum>(EGL_LINUX_DMA_BUF_EXT)));
673+ EXPECT_THAT(egl_buffer, Eq(nullptr));
674+ EXPECT_THAT(attrs, mir::test::doubles::AttrMatches(expected_image_attrs));
675+}
676+
677+TEST_F(MesaClientBufferTest, invalid_pixel_format_throws)
678+{
679+ EXPECT_THROW({
680+ mclg::ClientBuffer buffer(buffer_file_ops, package, size, mir_pixel_format_invalid);
681+ }, std::invalid_argument);
682+}

Subscribers

People subscribed via source and target branches