Mir

Merge lp:~afrantzis/mir/fix-android-desktop-build-lp-1276621 into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: kevin gunn
Approved revision: no longer in the source branch.
Merged at revision: 1375
Proposed branch: lp:~afrantzis/mir/fix-android-desktop-build-lp-1276621
Merge into: lp:mir
Diff against target: 233 lines (+35/-41)
10 files modified
include/test/mir_test_doubles/mock_fb_hal_device.h (+1/-3)
src/platform/graphics/android/android_alloc_adaptor.cpp (+1/-1)
src/platform/graphics/android/display_buffer.h (+0/-1)
src/platform/graphics/android/hwc_device.h (+0/-2)
src/platform/graphics/android/hwc_layers.cpp (+6/-2)
src/platform/graphics/android/internal_client_window.cpp (+6/-1)
src/platform/graphics/android/server_render_window.cpp (+6/-1)
tests/draw/android_graphics.cpp (+0/-22)
tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp (+1/-1)
tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp (+14/-7)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-android-desktop-build-lp-1276621
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+205159@code.launchpad.net

Commit message

android,tests: Fix android build and unit tests on desktop

Description of the change

android,tests: Fix android build and unit tests on desktop

Fixed issues with building the android backend on the desktop, both with g++ and clang++.

Also fixed some problems found while running the unit tests (for an android build) on the desktop.

To post a comment you must log in.
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 :

68 - memcpy(this, &layer, sizeof(HWCLayer));
69 + memcpy(static_cast<void*>(this),
70 + static_cast<void const*>(&layer),
71 + sizeof(HWCLayer));

NOt sure the casts add anything other than text

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

> 68 - memcpy(this, &layer, sizeof(HWCLayer));
> 69 + memcpy(static_cast<void*>(this),
> 70 + static_cast<void const*>(&layer),
> 71 + sizeof(HWCLayer));
>
> NOt sure the casts add anything other than text

Either way, this bit of code (copy/assign for this type) is hopefully going away soon.

Otherwise looks okay to me, thanks for the clean up!

review: Approve

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/mock_fb_hal_device.h'
2--- include/test/mir_test_doubles/mock_fb_hal_device.h 2014-01-13 06:12:33 +0000
3+++ include/test/mir_test_doubles/mock_fb_hal_device.h 2014-02-06 13:37:40 +0000
4@@ -37,7 +37,7 @@
5 MockFBHalDevice(unsigned int const width, unsigned int const height,
6 int const pf, int const numfbs)
7 : framebuffer_device_t({
8- empty_module,
9+ hw_device_t(),
10 0,
11 width,
12 height,
13@@ -86,8 +86,6 @@
14 MOCK_METHOD2(enableScreen_interface, int(struct framebuffer_device_t*, int));
15 MOCK_METHOD2(post_interface, int(struct framebuffer_device_t*, buffer_handle_t));
16 MOCK_METHOD2(setSwapInterval_interface, int(struct framebuffer_device_t*, int));
17-
18- hw_device_t empty_module;
19 };
20
21 }
22
23=== modified file 'src/platform/graphics/android/android_alloc_adaptor.cpp'
24--- src/platform/graphics/android/android_alloc_adaptor.cpp 2014-01-13 06:12:33 +0000
25+++ src/platform/graphics/android/android_alloc_adaptor.cpp 2014-02-06 13:37:40 +0000
26@@ -69,7 +69,7 @@
27 }
28
29 AndroidBufferHandleDeleter del1(alloc_dev);
30- std::shared_ptr<native_handle_t> handle(buf_handle, del1);
31+ std::shared_ptr<native_handle_t const> handle(buf_handle, del1);
32
33 auto ops = std::make_shared<mga::RealSyncFileOps>();
34 auto fence = std::make_shared<mga::SyncFence>(ops, -1);
35
36=== modified file 'src/platform/graphics/android/display_buffer.h'
37--- src/platform/graphics/android/display_buffer.h 2014-01-23 17:26:51 +0000
38+++ src/platform/graphics/android/display_buffer.h 2014-02-06 13:37:40 +0000
39@@ -61,7 +61,6 @@
40 std::shared_ptr<DisplayDevice> const display_device;
41 std::shared_ptr<ANativeWindow> const native_window;
42 GLContext gl_context;
43- bool prepared;
44 MirOrientation rotation;
45 };
46
47
48=== modified file 'src/platform/graphics/android/hwc_device.h'
49--- src/platform/graphics/android/hwc_device.h 2014-01-29 18:54:06 +0000
50+++ src/platform/graphics/android/hwc_device.h 2014-02-06 13:37:40 +0000
51@@ -51,8 +51,6 @@
52 LayerList layer_list;
53
54 std::shared_ptr<SyncFileOps> const sync_ops;
55- unsigned int primary_display_config;
56- MirPixelFormat fb_format;
57 static size_t const num_displays{3}; //primary, external, virtual
58 };
59
60
61=== modified file 'src/platform/graphics/android/hwc_layers.cpp'
62--- src/platform/graphics/android/hwc_layers.cpp 2014-01-24 21:50:21 +0000
63+++ src/platform/graphics/android/hwc_layers.cpp 2014-02-06 13:37:40 +0000
64@@ -30,14 +30,18 @@
65
66 mga::HWCLayer& mga::HWCLayer::operator=(HWCLayer const& layer)
67 {
68- memcpy(this, &layer, sizeof(HWCLayer));
69+ memcpy(static_cast<void*>(this),
70+ static_cast<void const*>(&layer),
71+ sizeof(HWCLayer));
72 this->visibleRegionScreen = {1, &this->visible_rect};
73 return *this;
74 }
75
76 mga::HWCLayer::HWCLayer(HWCLayer const& layer)
77 {
78- memcpy(this, &layer, sizeof(HWCLayer));
79+ memcpy(static_cast<void*>(this),
80+ static_cast<void const*>(&layer),
81+ sizeof(HWCLayer));
82 this->visibleRegionScreen = {1, &this->visible_rect};
83 }
84
85
86=== modified file 'src/platform/graphics/android/internal_client_window.cpp'
87--- src/platform/graphics/android/internal_client_window.cpp 2014-01-13 06:12:33 +0000
88+++ src/platform/graphics/android/internal_client_window.cpp 2014-02-06 13:37:40 +0000
89@@ -25,6 +25,7 @@
90
91 #include <boost/throw_exception.hpp>
92 #include <stdexcept>
93+#include <sstream>
94
95 namespace mg=mir::graphics;
96 namespace mga=mg::android;
97@@ -93,7 +94,11 @@
98 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
99 return 1;
100 default:
101- BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key));
102+ {
103+ std::stringstream sstream;
104+ sstream << "driver requests info we dont provide. key: " << key;
105+ BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
106+ }
107 }
108 }
109
110
111=== modified file 'src/platform/graphics/android/server_render_window.cpp'
112--- src/platform/graphics/android/server_render_window.cpp 2014-01-13 06:12:33 +0000
113+++ src/platform/graphics/android/server_render_window.cpp 2014-02-06 13:37:40 +0000
114@@ -28,6 +28,7 @@
115 #include <system/window.h>
116 #include <boost/throw_exception.hpp>
117 #include <stdexcept>
118+#include <sstream>
119
120 namespace mg=mir::graphics;
121 namespace mga=mir::graphics::android;
122@@ -81,7 +82,11 @@
123 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
124 return 1;
125 default:
126- BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key));
127+ {
128+ std::stringstream sstream;
129+ sstream << "driver requests info we dont provide. key: " << key;
130+ BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
131+ }
132 }
133 }
134
135
136=== modified file 'tests/draw/android_graphics.cpp'
137--- tests/draw/android_graphics.cpp 2014-01-13 06:12:33 +0000
138+++ tests/draw/android_graphics.cpp 2014-02-06 13:37:40 +0000
139@@ -48,28 +48,6 @@
140 gralloc_module_t *grmod;
141 native_handle_t const* handle;
142 };
143-
144-static const char* proc_dir = "/proc";
145-static const char* surface_flinger_executable_name = "surfaceflinger";
146-int surface_flinger_filter(const struct dirent* d)
147-{
148- if (fnmatch("[1-9]*", d->d_name, 0))
149- return 0;
150-
151- char path[256];
152- snprintf(path, sizeof(path), "%s/%s/cmdline", proc_dir, d->d_name);
153-
154- std::ifstream in(path);
155- std::string line;
156-
157- while(std::getline(in, line))
158- {
159- if (line.find(surface_flinger_executable_name) != std::string::npos)
160- return 1;
161- }
162-
163- return 0;
164-}
165 }
166
167 mtd::TestGrallocMapper::TestGrallocMapper()
168
169=== modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp'
170--- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2014-01-13 06:12:33 +0000
171+++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2014-02-06 13:37:40 +0000
172@@ -236,7 +236,7 @@
173
174 TEST_F(AdaptorICSTest, handle_has_version)
175 {
176- int version = 96; /* version value shared by JB and ICS */
177+ int version = sizeof(ANativeWindowBuffer); /* version value shared by JB and ICS */
178 auto native_handle = alloc_adaptor->alloc_buffer(size, pf, usage);
179 auto anwb = native_handle->anwb();
180 EXPECT_EQ(version, anwb->common.version);
181
182=== modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp'
183--- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2014-01-13 06:12:33 +0000
184+++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2014-02-06 13:37:40 +0000
185@@ -101,7 +101,8 @@
186 TEST_F(AndroidBufferBinding, buffer_makes_new_image_with_new_display)
187 {
188 using namespace testing;
189- EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);
190+ EGLDisplay second_fake_display =
191+ reinterpret_cast<EGLDisplay>(&second_fake_display);
192
193 /* return 1st fake display */
194 EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_))
195@@ -121,7 +122,8 @@
196 TEST_F(AndroidBufferBinding, buffer_frees_images_it_makes)
197 {
198 using namespace testing;
199- EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);
200+ EGLDisplay second_fake_display =
201+ reinterpret_cast<EGLDisplay>(&second_fake_display);
202
203 EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,_))
204 .Times(Exactly(2));
205@@ -141,9 +143,12 @@
206 using namespace testing;
207
208 EGLDisplay first_fake_display = mock_egl.fake_egl_display;
209- EGLImageKHR first_fake_egl_image = (EGLImageKHR) 0x84210;
210- EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);
211- EGLImageKHR second_fake_egl_image = (EGLImageKHR) 0x84211;
212+ EGLImageKHR first_fake_egl_image =
213+ reinterpret_cast<EGLImageKHR>(&first_fake_egl_image);
214+ EGLDisplay second_fake_display =
215+ reinterpret_cast<EGLDisplay>(&second_fake_display);
216+ EGLImageKHR second_fake_egl_image =
217+ reinterpret_cast<EGLImageKHR>(&second_fake_egl_image);
218
219 /* actual expectations */
220 EXPECT_CALL(mock_egl, eglDestroyImageKHR(first_fake_display, first_fake_egl_image))
221@@ -321,8 +326,10 @@
222 TEST_F(AndroidBufferBinding, buffer_binding_uses_right_image_after_display_swap)
223 {
224 using namespace testing;
225- EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);
226- EGLImageKHR second_fake_egl_image = (EGLImageKHR) 0x84211;
227+ EGLDisplay second_fake_display =
228+ reinterpret_cast<EGLDisplay>(&second_fake_display);
229+ EGLImageKHR second_fake_egl_image =
230+ reinterpret_cast<EGLImageKHR>(&second_fake_egl_image);
231
232 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))
233 .Times(Exactly(1));

Subscribers

People subscribed via source and target branches