Mir

Merge lp:~afrantzis/mir/mesa-native-platform-fix-buffer-ipc-package into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1439
Proposed branch: lp:~afrantzis/mir/mesa-native-platform-fix-buffer-ipc-package
Merge into: lp:mir
Diff against target: 153 lines (+78/-4)
3 files modified
include/test/mir_test_doubles/stub_buffer.h (+16/-4)
src/platform/graphics/mesa/native_platform.cpp (+2/-0)
tests/unit-tests/graphics/mesa/test_native_platform.cpp (+60/-0)
To merge this branch: bzr merge lp:~afrantzis/mir/mesa-native-platform-fix-buffer-ipc-package
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Kevin DuBois (community) Approve
Review via email: mp+208382@code.launchpad.net

Commit message

mesa: Correctly pack buffer IPC package in NativePlatform

Description of the change

mesa: Correctly pack buffer IPC package in NativePlatform

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looks good to me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/test/mir_test_doubles/stub_buffer.h'
2--- include/test/mir_test_doubles/stub_buffer.h 2014-01-29 03:18:46 +0000
3+++ include/test/mir_test_doubles/stub_buffer.h 2014-02-26 14:41:36 +0000
4@@ -39,20 +39,31 @@
5 {
6 public:
7 StubBuffer()
8- : buf_size{0, 0},
9- buf_pixel_format{mir_pixel_format_abgr_8888}
10+ : StubBuffer{
11+ graphics::BufferProperties{
12+ geometry::Size{},
13+ mir_pixel_format_abgr_8888,
14+ graphics::BufferUsage::hardware}}
15+
16 {
17 }
18
19 StubBuffer(graphics::BufferProperties const& properties)
20+ : StubBuffer{properties, geometry::Stride{}}
21+ {
22+ }
23+
24+ StubBuffer(graphics::BufferProperties const& properties,
25+ geometry::Stride stride)
26 : buf_size{properties.size},
27- buf_pixel_format{properties.format}
28+ buf_pixel_format{properties.format},
29+ buf_stride{stride}
30 {
31 }
32
33 virtual geometry::Size size() const { return buf_size; }
34
35- virtual geometry::Stride stride() const { return geometry::Stride(); }
36+ virtual geometry::Stride stride() const { return buf_stride; }
37
38 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }
39
40@@ -70,6 +81,7 @@
41
42 geometry::Size const buf_size;
43 MirPixelFormat const buf_pixel_format;
44+ geometry::Stride const buf_stride;
45 };
46 }
47 }
48
49=== modified file 'src/platform/graphics/mesa/native_platform.cpp'
50--- src/platform/graphics/mesa/native_platform.cpp 2014-01-13 06:12:33 +0000
51+++ src/platform/graphics/mesa/native_platform.cpp 2014-02-26 14:41:36 +0000
52@@ -98,6 +98,8 @@
53 }
54
55 packer->pack_stride(buffer->stride());
56+ packer->pack_flags(native_handle->flags);
57+ packer->pack_size(buffer->size());
58 }
59
60 extern "C" std::shared_ptr<mg::NativePlatform> create_native_platform(std::shared_ptr<mg::DisplayReport> const& /*report*/)
61
62=== modified file 'tests/unit-tests/graphics/mesa/test_native_platform.cpp'
63--- tests/unit-tests/graphics/mesa/test_native_platform.cpp 2014-01-13 06:12:33 +0000
64+++ tests/unit-tests/graphics/mesa/test_native_platform.cpp 2014-02-26 14:41:36 +0000
65@@ -18,10 +18,13 @@
66
67 #include "mir/graphics/nested_context.h"
68 #include "src/platform/graphics/mesa/native_platform.h"
69+#include "mir/graphics/buffer_properties.h"
70
71 #include "mir_test/fake_shared.h"
72 #include "mir_test_doubles/mock_drm.h"
73 #include "mir_test_doubles/mock_gbm.h"
74+#include "mir_test_doubles/stub_buffer.h"
75+#include "mir_test_doubles/mock_buffer_packer.h"
76
77 #include <gtest/gtest.h>
78 #include <gmock/gmock.h>
79@@ -30,6 +33,7 @@
80 namespace mgm = mir::graphics::mesa;
81 namespace mt = mir::test;
82 namespace mtd = mir::test::doubles;
83+namespace geom = mir::geometry;
84
85 namespace
86 {
87@@ -41,6 +45,39 @@
88 MOCK_METHOD1(drm_set_gbm_device, void(struct gbm_device*));
89 };
90
91+class StubBuffer : public mtd::StubBuffer
92+{
93+public:
94+ StubBuffer()
95+ : mtd::StubBuffer{
96+ mg::BufferProperties{
97+ geom::Size{123, 456},
98+ mir_pixel_format_abgr_8888,
99+ mg::BufferUsage::software},
100+ geom::Stride{4390}},
101+ native_buffer{std::make_shared<mg::NativeBuffer>()}
102+ {
103+ native_buffer->data_items = 4;
104+ native_buffer->fd_items = 2;
105+ for(auto i = 0; i < native_buffer->data_items; i++)
106+ native_buffer->data[i] = i;
107+ for(auto i = 0; i < native_buffer->fd_items; i++)
108+ native_buffer->fd[i] = i;
109+ native_buffer->width = buf_size.width.as_int();
110+ native_buffer->height = buf_size.height.as_int();
111+ native_buffer->flags = 0x66;
112+ native_buffer->stride = buf_stride.as_int();
113+ }
114+
115+ std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override
116+ {
117+ return native_buffer;
118+ }
119+
120+private:
121+ std::shared_ptr<mg::NativeBuffer> native_buffer;
122+};
123+
124 class MesaNativePlatformTest : public ::testing::Test
125 {
126 public:
127@@ -82,3 +119,26 @@
128
129 native.initialize(mt::fake_shared(mock_nested_context));
130 }
131+
132+TEST_F(MesaNativePlatformTest, packs_buffer_ipc_package_correctly)
133+{
134+ using namespace testing;
135+
136+ StubBuffer const stub_buffer;
137+ mtd::MockPacker mock_packer;
138+ auto const native_buffer = stub_buffer.native_buffer_handle();
139+
140+ for(auto i = 0; i < native_buffer->fd_items; i++)
141+ EXPECT_CALL(mock_packer, pack_fd(native_buffer->fd[i]));
142+
143+ for(auto i = 0; i < native_buffer->data_items; i++)
144+ EXPECT_CALL(mock_packer, pack_data(native_buffer->data[i]));
145+
146+ EXPECT_CALL(mock_packer, pack_stride(stub_buffer.stride()));
147+ EXPECT_CALL(mock_packer, pack_flags(native_buffer->flags));
148+ EXPECT_CALL(mock_packer, pack_size(stub_buffer.size()));
149+
150+ mgm::NativePlatform native;
151+
152+ native.fill_ipc_package(&mock_packer, &stub_buffer);
153+}

Subscribers

People subscribed via source and target branches