Mir

Merge lp:~vanvugt/mir/fix-1116452 into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 737
Proposed branch: lp:~vanvugt/mir/fix-1116452
Merge into: lp:~mir-team/mir/trunk
Diff against target: 73 lines (+15/-4)
5 files modified
include/shared/mir/geometry/pixel_format.h (+6/-0)
src/client/android/android_client_buffer.cpp (+2/-1)
src/server/graphics/android/buffer.cpp (+2/-1)
tests/unit-tests/client/android/test_client_android_buffer.cpp (+3/-1)
tests/unit-tests/graphics/android/test_buffer.cpp (+2/-1)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1116452
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Alexandros Frantzis (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+168889@code.launchpad.net

Commit message

Resolve the two differing interpretations of "stride" which were causing
software surfaces to be distorted on Android. (LP: #1116452)

Just make sure that "stride" in any Android structure is a number of pixels
and in Mir types it is always a number of bytes.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Instead of using base types perhaps we should be using boost.Units. "Scaled Base Units" solves this conversion problem and give us type safety.

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 :

Looks sensible. Not sure how to test all the possible cases though.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

It would be cleaner if the translation from pixel to byte units was done inside the android subystem in the server, which is the source of the stride values.

mga::AndroidBuffer::stride() seems like a good place to perform the translation.

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> It would be cleaner if the translation from pixel to byte units was done
> inside the android subystem in the server, which is the source of the stride
> values.
>
> mga::AndroidBuffer::stride() seems like a good place to perform the
> translation.

Sorry, misread the diff. Looks good.

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

seems ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/shared/mir/geometry/pixel_format.h'
2--- include/shared/mir/geometry/pixel_format.h 2013-04-24 05:22:20 +0000
3+++ include/shared/mir/geometry/pixel_format.h 2013-06-12 09:48:51 +0000
4@@ -36,6 +36,12 @@
5 xrgb_8888,
6 bgr_888
7 };
8+
9+static inline size_t bytes_per_pixel(PixelFormat fmt)
10+{
11+ return (fmt == PixelFormat::bgr_888) ? 3 : 4;
12+}
13+
14 }
15 }
16
17
18=== modified file 'src/client/android/android_client_buffer.cpp'
19--- src/client/android/android_client_buffer.cpp 2013-05-03 22:53:42 +0000
20+++ src/client/android/android_client_buffer.cpp 2013-06-12 09:48:51 +0000
21@@ -48,7 +48,8 @@
22 {
23 native_window_buffer->height = static_cast<int32_t>(rect.size.height.as_uint32_t());
24 native_window_buffer->width = static_cast<int32_t>(rect.size.width.as_uint32_t());
25- native_window_buffer->stride = creation_package->stride;
26+ native_window_buffer->stride = creation_package->stride /
27+ geom::bytes_per_pixel(buffer_pf);
28 native_window_buffer->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER;
29
30 native_window_buffer->handle = native_handle.get();
31
32=== modified file 'src/server/graphics/android/buffer.cpp'
33--- src/server/graphics/android/buffer.cpp 2013-06-04 14:23:56 +0000
34+++ src/server/graphics/android/buffer.cpp 2013-06-12 09:48:51 +0000
35@@ -65,7 +65,8 @@
36
37 geom::Stride mga::Buffer::stride() const
38 {
39- return geom::Stride{native_buffer->stride};
40+ return geom::Stride{native_buffer->stride *
41+ geom::bytes_per_pixel(pixel_format())};
42 }
43
44 geom::PixelFormat mga::Buffer::pixel_format() const
45
46=== modified file 'tests/unit-tests/client/android/test_client_android_buffer.cpp'
47--- tests/unit-tests/client/android/test_client_android_buffer.cpp 2013-05-02 19:05:14 +0000
48+++ tests/unit-tests/client/android/test_client_android_buffer.cpp 2013-06-12 09:48:51 +0000
49@@ -320,7 +320,9 @@
50
51 auto native_handle = buffer->native_buffer_handle();
52 ASSERT_NE(nullptr, native_handle);
53- EXPECT_EQ(static_cast<int32_t>(stride.as_uint32_t()), native_handle->stride);
54+ int32_t const expected_stride_in_pixels =
55+ static_cast<int32_t>(stride.as_uint32_t() / geom::bytes_per_pixel(pf));
56+ EXPECT_EQ(expected_stride_in_pixels, native_handle->stride);
57 }
58
59 TEST_F(ClientAndroidBufferTest, buffer_packs_anativewindowbuffer_refcounters_set)
60
61=== modified file 'tests/unit-tests/graphics/android/test_buffer.cpp'
62--- tests/unit-tests/graphics/android/test_buffer.cpp 2013-05-21 21:43:25 +0000
63+++ tests/unit-tests/graphics/android/test_buffer.cpp 2013-06-12 09:48:51 +0000
64@@ -99,7 +99,8 @@
65 {
66 using namespace testing;
67
68- geom::Stride expected_stride{mock_buffer_handle->stride};
69+ geom::Stride expected_stride{mock_buffer_handle->stride *
70+ geom::bytes_per_pixel(pf)};
71 mga::Buffer buffer(mock_alloc_device, size, pf, default_use);
72 EXPECT_EQ(expected_stride, buffer.stride());
73 }

Subscribers

People subscribed via source and target branches