Mir

Merge lp:~kdub/mir/fix-1661521-0.26.1 into lp:~mir-team/mir/0.26-old

Proposed by Kevin DuBois on 2017-02-03
Status: Merged
Merged at revision: 4011
Proposed branch: lp:~kdub/mir/fix-1661521-0.26.1
Merge into: lp:~mir-team/mir/0.26-old
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-0.26.1
Reviewer Review Type Date Requested Status
Mir development team 2017-02-03 Pending
Review via email: mp+316368@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

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

fix clang complaint

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/client/buffer_factory.cpp'
--- src/client/buffer_factory.cpp 2017-01-24 07:37:03 +0000
+++ src/client/buffer_factory.cpp 2017-02-03 19:56:51 +0000
@@ -34,8 +34,21 @@
34 native_buffer_factory(native_buffer_factory),34 native_buffer_factory(native_buffer_factory),
35 connection(connection),35 connection(connection),
36 size(size),36 size(size),
37 format(format),37 sw_request(SoftwareRequest{format, usage}),
38 usage(usage),38 cb(cb),
39 cb_context(cb_context)
40{
41}
42
43mcl::BufferFactory::AllocationRequest::AllocationRequest(
44 std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
45 MirConnection* connection,
46 geom::Size size, uint32_t native_format, uint32_t native_flags,
47 MirBufferCallback cb, void* cb_context) :
48 native_buffer_factory(native_buffer_factory),
49 connection(connection),
50 size(size),
51 native_request(NativeRequest{native_format, native_flags}),
39 cb(cb),52 cb(cb),
40 cb_context(cb_context)53 cb_context(cb_context)
41{54{
@@ -55,6 +68,20 @@
55 std::make_unique<AllocationRequest>(factory, connection, size, format, usage, cb, cb_context));68 std::make_unique<AllocationRequest>(factory, connection, size, format, usage, cb, cb_context));
56}69}
5770
71void mcl::BufferFactory::expect_buffer(
72 std::shared_ptr<mcl::ClientBufferFactory> const& factory,
73 MirConnection* connection,
74 geometry::Size size,
75 uint32_t native_format,
76 uint32_t native_flags,
77 MirBufferCallback cb,
78 void* cb_context)
79{
80 std::lock_guard<decltype(mutex)> lk(mutex);
81 allocation_requests.emplace_back(
82 std::make_unique<AllocationRequest>(factory, connection, size, native_format, native_flags, cb, cb_context));
83}
84
58std::unique_ptr<mcl::MirBuffer> mcl::BufferFactory::generate_buffer(mir::protobuf::Buffer const& buffer)85std::unique_ptr<mcl::MirBuffer> mcl::BufferFactory::generate_buffer(mir::protobuf::Buffer const& buffer)
59{86{
60 std::lock_guard<decltype(mutex)> lk(mutex);87 std::lock_guard<decltype(mutex)> lk(mutex);
@@ -76,13 +103,30 @@
76 }103 }
77 else104 else
78 {105 {
106 auto factory = (*request_it)->native_buffer_factory;
107 std::shared_ptr<mcl::ClientBuffer> client_buffer;
108 auto usage = mir_buffer_usage_hardware;
109 if ((*request_it)->native_request.is_set())
110 {
111 auto& req = (*request_it)->native_request.value();
112 client_buffer = factory->create_buffer(
113 mcl::protobuf_to_native_buffer(buffer), req.native_format, req.native_flags);
114 }
115 else if ((*request_it)->sw_request.is_set())
116 {
117 auto& req = (*request_it)->sw_request.value();
118 usage = req.usage;
119 client_buffer = factory->create_buffer(
120 mcl::protobuf_to_native_buffer(buffer), (*request_it)->size, req.format);
121 }
122 else
123 {
124 BOOST_THROW_EXCEPTION(std::logic_error("could not create buffer"));
125 }
126
79 b = std::make_unique<Buffer>(127 b = std::make_unique<Buffer>(
80 (*request_it)->cb, (*request_it)->cb_context,128 (*request_it)->cb, (*request_it)->cb_context, buffer.buffer_id(),
81 buffer.buffer_id(),129 client_buffer, (*request_it)->connection, usage);
82 (*request_it)->native_buffer_factory->create_buffer(
83 mcl::protobuf_to_native_buffer(buffer),
84 (*request_it)->size, (*request_it)->format),
85 (*request_it)->connection, (*request_it)->usage);
86 }130 }
87131
88 allocation_requests.erase(request_it);132 allocation_requests.erase(request_it);
89133
=== modified file 'src/client/buffer_factory.h'
--- src/client/buffer_factory.h 2017-01-24 07:37:03 +0000
+++ src/client/buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -20,6 +20,7 @@
20#define MIR_CLIENT_MIR_BUFFER_FACTORY_H20#define MIR_CLIENT_MIR_BUFFER_FACTORY_H
2121
22#include "mir/geometry/size.h"22#include "mir/geometry/size.h"
23#include "mir/optional_value.h"
23#include "mir_protobuf.pb.h"24#include "mir_protobuf.pb.h"
24#include "buffer.h"25#include "buffer.h"
25#include <mutex>26#include <mutex>
@@ -45,6 +46,14 @@
45 MirBufferUsage usage,46 MirBufferUsage usage,
46 MirBufferCallback cb,47 MirBufferCallback cb,
47 void* cb_context) = 0;48 void* cb_context) = 0;
49 virtual void expect_buffer(
50 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
51 MirConnection* connection,
52 geometry::Size size,
53 uint32_t native_format,
54 uint32_t native_flags,
55 MirBufferCallback cb,
56 void* cb_context) = 0;
48 virtual void cancel_requests_with_context(void*) = 0;57 virtual void cancel_requests_with_context(void*) = 0;
4958
50private:59private:
@@ -64,13 +73,34 @@
64 MirBufferUsage usage,73 MirBufferUsage usage,
65 MirBufferCallback cb,74 MirBufferCallback cb,
66 void* cb_context) override;75 void* cb_context) override;
76 void expect_buffer(
77 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
78 MirConnection* connection,
79 geometry::Size size,
80 uint32_t native_format,
81 uint32_t native_flags,
82 MirBufferCallback cb,
83 void* cb_context) override;
67 void cancel_requests_with_context(void*) override;84 void cancel_requests_with_context(void*) override;
6885
69private:86private:
70 std::mutex mutex;87 std::mutex mutex;
71 int error_id { -1 };88 int error_id { -1 };
89
72 struct AllocationRequest90 struct AllocationRequest
73 {91 {
92 struct NativeRequest
93 {
94 uint32_t native_format;
95 uint32_t native_flags;
96 };
97
98 struct SoftwareRequest
99 {
100 MirPixelFormat format;
101 MirBufferUsage usage;
102 };
103
74 AllocationRequest(104 AllocationRequest(
75 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,105 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
76 MirConnection* connection,106 MirConnection* connection,
@@ -79,12 +109,20 @@
79 MirBufferUsage usage,109 MirBufferUsage usage,
80 MirBufferCallback cb,110 MirBufferCallback cb,
81 void* cb_context);111 void* cb_context);
112 AllocationRequest(
113 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
114 MirConnection* connection,
115 geometry::Size size,
116 uint32_t native_format,
117 uint32_t native_flags,
118 MirBufferCallback cb,
119 void* cb_context);
82120
83 std::shared_ptr<ClientBufferFactory> const native_buffer_factory;121 std::shared_ptr<ClientBufferFactory> const native_buffer_factory;
84 MirConnection* connection;122 MirConnection* connection;
85 geometry::Size size;123 geometry::Size size;
86 MirPixelFormat format;124 optional_value<NativeRequest> native_request;
87 MirBufferUsage usage;125 optional_value<SoftwareRequest> sw_request;
88 MirBufferCallback cb;126 MirBufferCallback cb;
89 void* cb_context;127 void* cb_context;
90 };128 };
91129
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2017-02-02 19:38:06 +0000
+++ src/client/mir_connection.cpp 2017-02-03 19:56:51 +0000
@@ -1301,7 +1301,7 @@
1301 client_buffer_factory = platform->create_buffer_factory();1301 client_buffer_factory = platform->create_buffer_factory();
1302 buffer_factory->expect_buffer(1302 buffer_factory->expect_buffer(
1303 client_buffer_factory, this,1303 client_buffer_factory, this,
1304 size, mir_pixel_format_invalid, mir_buffer_usage_hardware,1304 size, native_format, native_flags,
1305 callback, context);1305 callback, context);
1306 server.allocate_buffers(&request, ignored.get(), gp::NewCallback(ignore));1306 server.allocate_buffers(&request, ignored.get(), gp::NewCallback(ignore));
1307}1307}
13081308
=== modified file 'src/include/client/mir/client_buffer_factory.h'
--- src/include/client/mir/client_buffer_factory.h 2015-02-22 07:46:25 +0000
+++ src/include/client/mir/client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -47,6 +47,8 @@
47 */47 */
48 virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,48 virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,
49 geometry::Size size, MirPixelFormat pf) = 0;49 geometry::Size size, MirPixelFormat pf) = 0;
50 virtual std::shared_ptr<ClientBuffer> create_buffer(std::shared_ptr<MirBufferPackage> const& package,
51 unsigned int native_pf, unsigned int native_flags) = 0;
5052
51protected:53protected:
52 ClientBufferFactory() = default;54 ClientBufferFactory() = default;
5355
=== modified file 'src/platforms/android/client/android_client_buffer_factory.cpp'
--- src/platforms/android/client/android_client_buffer_factory.cpp 2015-02-22 07:46:25 +0000
+++ src/platforms/android/client/android_client_buffer_factory.cpp 2017-02-03 19:56:51 +0000
@@ -18,12 +18,14 @@
18 */18 */
1919
20#include "android_client_buffer_factory.h"20#include "android_client_buffer_factory.h"
21#include "android_format_conversion-inl.h"
21#include "buffer_registrar.h"22#include "buffer_registrar.h"
22#include "buffer.h"23#include "buffer.h"
2324
24namespace mcl=mir::client;25namespace mcl=mir::client;
25namespace mcla=mir::client::android;26namespace mcla=mir::client::android;
26namespace geom=mir::geometry;27namespace geom=mir::geometry;
28namespace mga=mir::graphics::android;
2729
28mcla::AndroidClientBufferFactory::AndroidClientBufferFactory(30mcla::AndroidClientBufferFactory::AndroidClientBufferFactory(
29 std::shared_ptr<BufferRegistrar> const& buffer_registrar) :31 std::shared_ptr<BufferRegistrar> const& buffer_registrar) :
@@ -36,3 +38,10 @@
36 (void)size; // TODO: remove this unused parameter38 (void)size; // TODO: remove this unused parameter
37 return std::make_shared<mcla::Buffer>(registrar, *package, pf);39 return std::make_shared<mcla::Buffer>(registrar, *package, pf);
38}40}
41
42std::shared_ptr<mcl::ClientBuffer> mcla::AndroidClientBufferFactory::create_buffer(
43 std::shared_ptr<MirBufferPackage> const& package,
44 unsigned int native_pf, unsigned int)
45{
46 return std::make_shared<mcla::Buffer>(registrar, *package, mga::to_mir_format(native_pf));
47}
3948
=== modified file 'src/platforms/android/client/android_client_buffer_factory.h'
--- src/platforms/android/client/android_client_buffer_factory.h 2015-02-22 07:46:25 +0000
+++ src/platforms/android/client/android_client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -45,6 +45,9 @@
45 std::shared_ptr<MirBufferPackage> const& package,45 std::shared_ptr<MirBufferPackage> const& package,
46 geometry::Size size,46 geometry::Size size,
47 MirPixelFormat pf) override;47 MirPixelFormat pf) override;
48 std::shared_ptr<ClientBuffer> create_buffer(
49 std::shared_ptr<MirBufferPackage> const& package,
50 unsigned int native_pf, unsigned int native_flags) override;
48private:51private:
49 std::shared_ptr<BufferRegistrar> const registrar;52 std::shared_ptr<BufferRegistrar> const registrar;
50};53};
5154
=== modified file 'src/platforms/eglstream-kms/client/client_buffer_factory.cpp'
--- src/platforms/eglstream-kms/client/client_buffer_factory.cpp 2016-05-31 01:21:42 +0000
+++ src/platforms/eglstream-kms/client/client_buffer_factory.cpp 2017-02-03 19:56:51 +0000
@@ -19,6 +19,8 @@
1919
20#include "client_buffer_factory.h"20#include "client_buffer_factory.h"
21#include "client_buffer.h"21#include "client_buffer.h"
22#include <boost/throw_exception.hpp>
23#include <stdexcept>
2224
23namespace mcl=mir::client;25namespace mcl=mir::client;
24namespace mcle=mir::client::eglstream;26namespace mcle=mir::client::eglstream;
@@ -34,3 +36,11 @@
34 geometry::Size{package->width, package->height},36 geometry::Size{package->width, package->height},
35 pf);37 pf);
36}38}
39
40std::shared_ptr<mcl::ClientBuffer>
41mcle::ClientBufferFactory::create_buffer(
42 std::shared_ptr<MirBufferPackage> const&,
43 unsigned int, unsigned int)
44{
45 BOOST_THROW_EXCEPTION(std::runtime_error("no native buffers on eglstream platform"));
46}
3747
=== modified file 'src/platforms/eglstream-kms/client/client_buffer_factory.h'
--- src/platforms/eglstream-kms/client/client_buffer_factory.h 2016-05-31 01:21:42 +0000
+++ src/platforms/eglstream-kms/client/client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -36,7 +36,10 @@
3636
37 std::shared_ptr<client::ClientBuffer> create_buffer(37 std::shared_ptr<client::ClientBuffer> create_buffer(
38 std::shared_ptr<MirBufferPackage> const& package,38 std::shared_ptr<MirBufferPackage> const& package,
39 geometry::Size size, MirPixelFormat pf);39 geometry::Size size, MirPixelFormat pf) override;
40 std::shared_ptr<ClientBuffer> create_buffer(
41 std::shared_ptr<MirBufferPackage> const& package,
42 unsigned int native_pf, unsigned int native_flags) override;
40};43};
4144
42}45}
4346
=== modified file 'src/platforms/mesa/client/client_buffer.cpp'
--- src/platforms/mesa/client/client_buffer.cpp 2017-01-18 02:29:37 +0000
+++ src/platforms/mesa/client/client_buffer.cpp 2017-02-03 19:56:51 +0000
@@ -103,6 +103,9 @@
103 EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(creation_package->stride),103 EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(creation_package->stride),
104 EGL_NONE}104 EGL_NONE}
105{105{
106 if (pf == mir_pixel_format_invalid)
107 BOOST_THROW_EXCEPTION(std::invalid_argument("cannot create buffer with mir_pixel_format_invalid"));
108
106 if (package->fd_items != 1)109 if (package->fd_items != 1)
107 {110 {
108 BOOST_THROW_EXCEPTION(std::runtime_error(111 BOOST_THROW_EXCEPTION(std::runtime_error(
@@ -110,6 +113,27 @@
110 }113 }
111}114}
112115
116mclm::ClientBuffer::ClientBuffer(
117 std::shared_ptr<BufferFileOps> const& buffer_file_ops,
118 std::shared_ptr<MirBufferPackage> const& package,
119 geometry::Size size,
120 unsigned int native_pf, unsigned int /*native_flags*/) :
121 buffer_file_ops{buffer_file_ops},
122 creation_package{to_native_buffer(*package)},
123 rect({geom::Point{0, 0}, size}),
124 buffer_pf{mir::graphics::mesa::gbm_format_to_mir_format(native_pf)},
125 egl_image_attrs{
126 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
127 EGL_WIDTH, static_cast<const EGLint>(creation_package->width),
128 EGL_HEIGHT, static_cast<const EGLint>(creation_package->height),
129 EGL_LINUX_DRM_FOURCC_EXT, static_cast<const EGLint>(native_pf),
130 EGL_DMA_BUF_PLANE0_FD_EXT, creation_package->fd[0],
131 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
132 EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(creation_package->stride),
133 EGL_NONE}
134{
135}
136
113mclm::ClientBuffer::~ClientBuffer() noexcept137mclm::ClientBuffer::~ClientBuffer() noexcept
114{138{
115 // TODO (@raof): Error reporting? It should not be possible for this to fail; if it does,139 // TODO (@raof): Error reporting? It should not be possible for this to fail; if it does,
116140
=== modified file 'src/platforms/mesa/client/client_buffer.h'
--- src/platforms/mesa/client/client_buffer.h 2017-01-18 02:29:37 +0000
+++ src/platforms/mesa/client/client_buffer.h 2017-02-03 19:56:51 +0000
@@ -44,6 +44,10 @@
44 std::shared_ptr<MirBufferPackage> const& buffer_package,44 std::shared_ptr<MirBufferPackage> const& buffer_package,
45 geometry::Size size,45 geometry::Size size,
46 MirPixelFormat pf);46 MirPixelFormat pf);
47 ClientBuffer(std::shared_ptr<BufferFileOps> const& buffer_file_ops,
48 std::shared_ptr<MirBufferPackage> const& buffer_package,
49 geometry::Size size,
50 unsigned int native_pf, unsigned int native_flags);
4751
48 ~ClientBuffer() noexcept;52 ~ClientBuffer() noexcept;
4953
5054
=== modified file 'src/platforms/mesa/client/client_buffer_factory.cpp'
--- src/platforms/mesa/client/client_buffer_factory.cpp 2014-03-06 06:05:17 +0000
+++ src/platforms/mesa/client/client_buffer_factory.cpp 2017-02-03 19:56:51 +0000
@@ -42,3 +42,15 @@
42 geometry::Size{package->width, package->height},42 geometry::Size{package->width, package->height},
43 pf);43 pf);
44}44}
45
46std::shared_ptr<mcl::ClientBuffer>
47mclm::ClientBufferFactory::create_buffer(
48 std::shared_ptr<MirBufferPackage> const& package,
49 unsigned int native_pf, unsigned int native_flags)
50{
51 return std::make_shared<mclm::ClientBuffer>(
52 buffer_file_ops,
53 package,
54 geometry::Size{package->width, package->height},
55 native_pf, native_flags);
56}
4557
=== modified file 'src/platforms/mesa/client/client_buffer_factory.h'
--- src/platforms/mesa/client/client_buffer_factory.h 2015-02-22 07:46:25 +0000
+++ src/platforms/mesa/client/client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -39,6 +39,9 @@
39 std::shared_ptr<client::ClientBuffer> create_buffer(39 std::shared_ptr<client::ClientBuffer> create_buffer(
40 std::shared_ptr<MirBufferPackage> const& package,40 std::shared_ptr<MirBufferPackage> const& package,
41 geometry::Size size, MirPixelFormat pf);41 geometry::Size size, MirPixelFormat pf);
42 std::shared_ptr<client::ClientBuffer> create_buffer(
43 std::shared_ptr<MirBufferPackage> const& package,
44 unsigned int native_pf, unsigned int native_flags);
42private:45private:
43 std::shared_ptr<BufferFileOps> const buffer_file_ops;46 std::shared_ptr<BufferFileOps> const buffer_file_ops;
44};47};
4548
=== modified file 'tests/include/mir/test/doubles/mock_client_buffer_factory.h'
--- tests/include/mir/test/doubles/mock_client_buffer_factory.h 2015-06-17 05:20:42 +0000
+++ tests/include/mir/test/doubles/mock_client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -36,6 +36,8 @@
36 std::shared_ptr<client::ClientBuffer>(36 std::shared_ptr<client::ClientBuffer>(
37 std::shared_ptr<MirBufferPackage> const& /*package*/,37 std::shared_ptr<MirBufferPackage> const& /*package*/,
38 mir::geometry::Size /*size*/, MirPixelFormat /*pf*/));38 mir::geometry::Size /*size*/, MirPixelFormat /*pf*/));
39 MOCK_METHOD3(create_buffer, std::shared_ptr<client::ClientBuffer>(
40 std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t));
39};41};
40}42}
41}43}
4244
=== modified file 'tests/include/mir/test/doubles/stub_client_buffer_factory.h'
--- tests/include/mir/test/doubles/stub_client_buffer_factory.h 2016-08-09 13:02:44 +0000
+++ tests/include/mir/test/doubles/stub_client_buffer_factory.h 2017-02-03 19:56:51 +0000
@@ -37,6 +37,13 @@
37 {37 {
38 return std::make_shared<StubClientBuffer>(package, size, pf, nullptr);38 return std::make_shared<StubClientBuffer>(package, size, pf, nullptr);
39 }39 }
40
41 std::shared_ptr<client::ClientBuffer> create_buffer(
42 std::shared_ptr<MirBufferPackage> const& package, uint32_t, uint32_t)
43 {
44 return std::make_shared<StubClientBuffer>(
45 package, geometry::Size{package->width, package->height}, mir_pixel_format_abgr_8888, nullptr);
46 }
40};47};
4148
42}49}
4350
=== modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
--- tests/mir_test_framework/stub_client_platform_factory.cpp 2017-02-02 19:38:06 +0000
+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2017-02-03 19:56:51 +0000
@@ -138,6 +138,17 @@
138 return std::make_shared<mtd::StubClientBuffer>(package, size, pf,138 return std::make_shared<mtd::StubClientBuffer>(package, size, pf,
139 std::make_shared<mtf::NativeBuffer>(properties));139 std::make_shared<mtf::NativeBuffer>(properties));
140 }140 }
141
142 std::shared_ptr<mcl::ClientBuffer> create_buffer(
143 std::shared_ptr<MirBufferPackage> const& package, uint32_t, uint32_t) override
144 {
145 mir::graphics::BufferUsage usage = mir::graphics::BufferUsage::hardware;
146 geom::Size size {package->width, package->height};
147 auto pf = mir_pixel_format_abgr_8888;
148 mir::graphics::BufferProperties properties { size, pf, usage };
149 return std::make_shared<mtd::StubClientBuffer>(package, size, pf,
150 std::make_shared<mtf::NativeBuffer>(properties));
151 }
141 };152 };
142 return std::make_shared<StubPlatformBufferFactory>();153 return std::make_shared<StubPlatformBufferFactory>();
143}154}
144155
=== modified file 'tests/unit-tests/client/test_buffer_vault.cpp'
--- tests/unit-tests/client/test_buffer_vault.cpp 2017-01-18 02:29:37 +0000
+++ tests/unit-tests/client/test_buffer_vault.cpp 2017-02-03 19:56:51 +0000
@@ -49,7 +49,7 @@
49{49{
50 MockClientBufferFactory()50 MockClientBufferFactory()
51 {51 {
52 ON_CALL(*this, create_buffer(_,_,_))52 ON_CALL(*this, create_buffer(_,An<geom::Size>(),_))
53 .WillByDefault(Invoke([](53 .WillByDefault(Invoke([](
54 std::shared_ptr<MirBufferPackage> const&, geom::Size size, MirPixelFormat)54 std::shared_ptr<MirBufferPackage> const&, geom::Size size, MirPixelFormat)
55 {55 {
@@ -61,6 +61,8 @@
61 }61 }
62 MOCK_METHOD3(create_buffer, std::shared_ptr<mcl::ClientBuffer>(62 MOCK_METHOD3(create_buffer, std::shared_ptr<mcl::ClientBuffer>(
63 std::shared_ptr<MirBufferPackage> const&, geom::Size, MirPixelFormat));63 std::shared_ptr<MirBufferPackage> const&, geom::Size, MirPixelFormat));
64 MOCK_METHOD3(create_buffer, std::shared_ptr<mcl::ClientBuffer>(
65 std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t));
64};66};
6567
66struct MockServerRequests : mcl::ServerBufferRequests68struct MockServerRequests : mcl::ServerBufferRequests
@@ -272,7 +274,7 @@
272 ON_CALL(*mock_buffer, size())274 ON_CALL(*mock_buffer, size())
273 .WillByDefault(Return(size));275 .WillByDefault(Return(size));
274 EXPECT_CALL(*mock_buffer, increment_age());276 EXPECT_CALL(*mock_buffer, increment_age());
275 ON_CALL(mock_platform_factory, create_buffer(_,_,_))277 ON_CALL(mock_platform_factory, create_buffer(_,An<uint32_t>(),_))
276 .WillByDefault(Return(mock_buffer));278 .WillByDefault(Return(mock_buffer));
277 auto b1 = std::make_shared<mcl::Buffer>(279 auto b1 = std::make_shared<mcl::Buffer>(
278 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);280 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);
@@ -289,7 +291,7 @@
289 ON_CALL(*mock_buffer, size())291 ON_CALL(*mock_buffer, size())
290 .WillByDefault(Return(size));292 .WillByDefault(Return(size));
291 EXPECT_CALL(*mock_buffer, mark_as_submitted());293 EXPECT_CALL(*mock_buffer, mark_as_submitted());
292 ON_CALL(mock_platform_factory, create_buffer(_,_,_))294 ON_CALL(mock_platform_factory, create_buffer(_,An<uint32_t>(),_))
293 .WillByDefault(Return(mock_buffer));295 .WillByDefault(Return(mock_buffer));
294 auto b1 = std::make_shared<mcl::Buffer>(296 auto b1 = std::make_shared<mcl::Buffer>(
295 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);297 ignore, nullptr, package.buffer_id(), mock_buffer, nullptr, mir_buffer_usage_software);
296298
=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
--- tests/unit-tests/client/test_client_buffer_stream.cpp 2017-01-25 15:34:05 +0000
+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2017-02-03 19:56:51 +0000
@@ -167,7 +167,7 @@
167{167{
168 ClientBufferStream()168 ClientBufferStream()
169 {169 {
170 ON_CALL(mock_factory, create_buffer(_,_,_))170 ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
171 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));171 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));
172 }172 }
173173
@@ -305,7 +305,7 @@
305305
306TEST_F(ClientBufferStream, uses_buffer_message_from_server)306TEST_F(ClientBufferStream, uses_buffer_message_from_server)
307{307{
308 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))308 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
309 .WillOnce(Return(std::make_shared<mtd::NullClientBuffer>()));309 .WillOnce(Return(std::make_shared<mtd::NullClientBuffer>()));
310 mcl::BufferStream bs(310 mcl::BufferStream bs(
311 nullptr, nullptr, wait_handle, mock_protobuf_server,311 nullptr, nullptr, wait_handle, mock_protobuf_server,
@@ -382,10 +382,10 @@
382 auto protobuf_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);382 auto protobuf_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);
383 383
384 Sequence seq;384 Sequence seq;
385 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_1),_,_))385 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_1),An<geom::Size>(),_))
386 .InSequence(seq)386 .InSequence(seq)
387 .WillOnce(Return(client_buffer_1));387 .WillOnce(Return(client_buffer_1));
388 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_2),_,_))388 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_2),An<geom::Size>(),_))
389 .InSequence(seq)389 .InSequence(seq)
390 .WillOnce(Return(client_buffer_2));390 .WillOnce(Return(client_buffer_2));
391391
@@ -448,7 +448,7 @@
448 NiceMock<mtd::MockClientBuffer> mock_client_buffer;448 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
449 ON_CALL(mock_client_buffer, size())449 ON_CALL(mock_client_buffer, size())
450 .WillByDefault(Return(size));450 .WillByDefault(Return(size));
451 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))451 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
452 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));452 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
453453
454 mcl::BufferStream bs(454 mcl::BufferStream bs(
@@ -470,7 +470,7 @@
470 NiceMock<mtd::MockClientBuffer> mock_client_buffer;470 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
471 ON_CALL(mock_client_buffer, size())471 ON_CALL(mock_client_buffer, size())
472 .WillByDefault(Return(size));472 .WillByDefault(Return(size));
473 ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))473 ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
474 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));474 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
475 mcl::BufferStream bs(475 mcl::BufferStream bs(
476 nullptr, nullptr, wait_handle, mock_protobuf_server,476 nullptr, nullptr, wait_handle, mock_protobuf_server,
@@ -568,7 +568,7 @@
568 NiceMock<mtd::MockClientBuffer> second_mock_client_buffer;568 NiceMock<mtd::MockClientBuffer> second_mock_client_buffer;
569 ON_CALL(second_mock_client_buffer, size())569 ON_CALL(second_mock_client_buffer, size())
570 .WillByDefault(Return(size));570 .WillByDefault(Return(size));
571 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))571 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
572 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));572 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
573573
574 mcl::BufferStream bs(574 mcl::BufferStream bs(
@@ -582,7 +582,7 @@
582 another_buffer_package.set_buffer_id(id);582 another_buffer_package.set_buffer_id(id);
583 another_buffer_package.set_width(size.width.as_int());583 another_buffer_package.set_width(size.width.as_int());
584 another_buffer_package.set_height(size.height.as_int());584 another_buffer_package.set_height(size.height.as_int());
585 EXPECT_CALL(mock_factory, create_buffer(_,_,_))585 EXPECT_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
586 .WillOnce(Return(mt::fake_shared(second_mock_client_buffer)));586 .WillOnce(Return(mt::fake_shared(second_mock_client_buffer)));
587 EXPECT_CALL(mock_protobuf_server, submit_buffer(_,_,_))587 EXPECT_CALL(mock_protobuf_server, submit_buffer(_,_,_))
588 .WillOnce(mtd::RunProtobufClosure());588 .WillOnce(mtd::RunProtobufClosure());
@@ -599,7 +599,7 @@
599 NiceMock<mtd::MockClientBuffer> mock_client_buffer;599 NiceMock<mtd::MockClientBuffer> mock_client_buffer;
600 ON_CALL(mock_client_buffer, size())600 ON_CALL(mock_client_buffer, size())
601 .WillByDefault(Return(size));601 .WillByDefault(Return(size));
602 ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))602 ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),An<geom::Size>(),_))
603 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));603 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
604 ON_CALL(mock_protobuf_server, submit_buffer(_,_,_))604 ON_CALL(mock_protobuf_server, submit_buffer(_,_,_))
605 .WillByDefault(mtd::RunProtobufClosure());605 .WillByDefault(mtd::RunProtobufClosure());
@@ -741,7 +741,7 @@
741{741{
742 auto format = mir_pixel_format_bgr_888;742 auto format = mir_pixel_format_bgr_888;
743 response.set_pixel_format(format);743 response.set_pixel_format(format);
744 EXPECT_CALL(mock_factory, create_buffer(_,_,format))744 EXPECT_CALL(mock_factory, create_buffer(_,_,TypedEq<MirPixelFormat>(format)))
745 .WillRepeatedly(Return(std::make_shared<mtd::NullClientBuffer>()));745 .WillRepeatedly(Return(std::make_shared<mtd::NullClientBuffer>()));
746 mcl::BufferStream bs(746 mcl::BufferStream bs(
747 nullptr, nullptr, wait_handle, mock_protobuf_server,747 nullptr, nullptr, wait_handle, mock_protobuf_server,
@@ -755,7 +755,7 @@
755755
756TEST_F(ClientBufferStream, keeps_accurate_buffer_id)756TEST_F(ClientBufferStream, keeps_accurate_buffer_id)
757{757{
758 ON_CALL(mock_factory, create_buffer(_,_,_))758 ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
759 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>(size)));759 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>(size)));
760 mcl::BufferStream stream(760 mcl::BufferStream stream(
761 nullptr, nullptr, wait_handle, mock_protobuf_server,761 nullptr, nullptr, wait_handle, mock_protobuf_server,
762762
=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
--- tests/unit-tests/client/test_mir_connection.cpp 2017-02-02 19:38:06 +0000
+++ tests/unit-tests/client/test_mir_connection.cpp 2017-02-03 19:56:51 +0000
@@ -93,6 +93,12 @@
93 MirBufferUsage usage,93 MirBufferUsage usage,
94 MirBufferCallback cb,94 MirBufferCallback cb,
95 void* cb_context));95 void* cb_context));
96 MOCK_METHOD7(expect_buffer, void(
97 std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
98 MirConnection* connection,
99 geom::Size size, uint32_t, uint32_t,
100 MirBufferCallback cb,
101 void* cb_context));
96};102};
97103
98struct MockRpcChannel : public mir::client::rpc::MirBasicRpcChannel,104struct MockRpcChannel : public mir::client::rpc::MirBasicRpcChannel,
@@ -849,7 +855,7 @@
849 params->set_buffer_usage(usage);855 params->set_buffer_usage(usage);
850 params->set_pixel_format(format);856 params->set_pixel_format(format);
851 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));857 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));
852 EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, format, usage, nullptr, nullptr));858 EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, TypedEq<MirPixelFormat>(format), usage, nullptr, nullptr));
853859
854 connection->allocate_buffer(size, format, nullptr, nullptr);860 connection->allocate_buffer(size, format, nullptr, nullptr);
855}861}
@@ -869,7 +875,7 @@
869 params->set_native_format(native_format);875 params->set_native_format(native_format);
870 params->set_flags(native_flags);876 params->set_flags(native_flags);
871 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));877 EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));
872 EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, _, mir_buffer_usage_hardware, nullptr, nullptr));878 EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, TypedEq<uint32_t>(native_format), TypedEq<uint32_t>(native_flags), nullptr, nullptr));
873879
874 connection->allocate_buffer(size, native_format, native_flags, nullptr, nullptr);880 connection->allocate_buffer(size, native_format, native_flags, nullptr, nullptr);
875}881}
876882
=== modified file 'tests/unit-tests/client/test_protobuf_rpc_channel.cpp'
--- tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2017-01-24 07:55:14 +0000
+++ tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2017-02-03 19:56:51 +0000
@@ -688,6 +688,10 @@
688 MirConnection*,688 MirConnection*,
689 mir::geometry::Size, MirPixelFormat, MirBufferUsage,689 mir::geometry::Size, MirPixelFormat, MirBufferUsage,
690 MirBufferCallback, void*));690 MirBufferCallback, void*));
691 MOCK_METHOD7(expect_buffer, void(
692 std::shared_ptr<mcl::ClientBufferFactory> const&,
693 MirConnection*, mir::geometry::Size, uint32_t, uint32_t,
694 MirBufferCallback, void*));
691};695};
692696
693namespace697namespace
694698
=== modified file 'tests/unit-tests/client/test_screencast_stream.cpp'
--- tests/unit-tests/client/test_screencast_stream.cpp 2017-01-18 02:29:37 +0000
+++ tests/unit-tests/client/test_screencast_stream.cpp 2017-02-03 19:56:51 +0000
@@ -75,7 +75,7 @@
75{75{
76 ScreencastStream()76 ScreencastStream()
77 {77 {
78 ON_CALL(mock_factory, create_buffer(_,_,_))78 ON_CALL(mock_factory, create_buffer(_,An<geom::Size>(),_))
79 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));79 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>()));
80 }80 }
8181
@@ -170,6 +170,12 @@
170 return nullptr;170 return nullptr;
171 }171 }
172172
173 std::shared_ptr<mcl::ClientBuffer> create_buffer(
174 std::shared_ptr<MirBufferPackage> const&, uint32_t, uint32_t)
175 {
176 return create_buffer(nullptr, geom::Size{0,0}, mir_pixel_format_invalid);
177 }
178
173 void start_failing()179 void start_failing()
174 {180 {
175 fail = true;181 fail = true;
176182
=== modified file 'tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp'
--- tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp 2017-01-18 02:29:37 +0000
+++ tests/unit-tests/platforms/mesa/client/test_client_buffer.cpp 2017-02-03 19:56:51 +0000
@@ -217,3 +217,38 @@
217 EXPECT_THAT(egl_buffer, Eq(nullptr));217 EXPECT_THAT(egl_buffer, Eq(nullptr));
218 EXPECT_THAT(attrs, mir::test::doubles::AttrMatches(expected_image_attrs));218 EXPECT_THAT(attrs, mir::test::doubles::AttrMatches(expected_image_attrs));
219}219}
220
221//LP: #1661521
222TEST_F(MesaClientBufferTest, suggests_dma_import_with_native_format)
223{
224 auto format = GBM_FORMAT_ABGR8888;
225 static EGLint expected_image_attrs[] =
226 {
227 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
228 EGL_WIDTH, static_cast<const EGLint>(package->width),
229 EGL_HEIGHT, static_cast<const EGLint>(package->height),
230 EGL_LINUX_DRM_FOURCC_EXT, static_cast<const EGLint>(format),
231 EGL_DMA_BUF_PLANE0_FD_EXT, package->fd[0],
232 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
233 EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<const EGLint>(package->stride),
234 EGL_NONE
235 };
236
237 EGLenum type;
238 EGLClientBuffer egl_buffer;
239 EGLint* attrs;
240
241 mclg::ClientBuffer buffer(buffer_file_ops, package, size, format, 0);
242 buffer.egl_image_creation_parameters(&type, &egl_buffer, &attrs);
243
244 EXPECT_THAT(type, Eq(static_cast<EGLenum>(EGL_LINUX_DMA_BUF_EXT)));
245 EXPECT_THAT(egl_buffer, Eq(nullptr));
246 EXPECT_THAT(attrs, mir::test::doubles::AttrMatches(expected_image_attrs));
247}
248
249TEST_F(MesaClientBufferTest, invalid_pixel_format_throws)
250{
251 EXPECT_THROW({
252 mclg::ClientBuffer buffer(buffer_file_ops, package, size, mir_pixel_format_invalid);
253 }, std::invalid_argument);
254}

Subscribers

People subscribed via source and target branches