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
=== modified file 'include/test/mir_test_doubles/mock_fb_hal_device.h'
--- include/test/mir_test_doubles/mock_fb_hal_device.h 2014-01-13 06:12:33 +0000
+++ include/test/mir_test_doubles/mock_fb_hal_device.h 2014-02-06 13:37:40 +0000
@@ -37,7 +37,7 @@
37 MockFBHalDevice(unsigned int const width, unsigned int const height,37 MockFBHalDevice(unsigned int const width, unsigned int const height,
38 int const pf, int const numfbs)38 int const pf, int const numfbs)
39 : framebuffer_device_t({39 : framebuffer_device_t({
40 empty_module,40 hw_device_t(),
41 0,41 0,
42 width,42 width,
43 height,43 height,
@@ -86,8 +86,6 @@
86 MOCK_METHOD2(enableScreen_interface, int(struct framebuffer_device_t*, int));86 MOCK_METHOD2(enableScreen_interface, int(struct framebuffer_device_t*, int));
87 MOCK_METHOD2(post_interface, int(struct framebuffer_device_t*, buffer_handle_t));87 MOCK_METHOD2(post_interface, int(struct framebuffer_device_t*, buffer_handle_t));
88 MOCK_METHOD2(setSwapInterval_interface, int(struct framebuffer_device_t*, int));88 MOCK_METHOD2(setSwapInterval_interface, int(struct framebuffer_device_t*, int));
89
90 hw_device_t empty_module;
91};89};
9290
93}91}
9492
=== modified file 'src/platform/graphics/android/android_alloc_adaptor.cpp'
--- src/platform/graphics/android/android_alloc_adaptor.cpp 2014-01-13 06:12:33 +0000
+++ src/platform/graphics/android/android_alloc_adaptor.cpp 2014-02-06 13:37:40 +0000
@@ -69,7 +69,7 @@
69 }69 }
7070
71 AndroidBufferHandleDeleter del1(alloc_dev);71 AndroidBufferHandleDeleter del1(alloc_dev);
72 std::shared_ptr<native_handle_t> handle(buf_handle, del1);72 std::shared_ptr<native_handle_t const> handle(buf_handle, del1);
7373
74 auto ops = std::make_shared<mga::RealSyncFileOps>();74 auto ops = std::make_shared<mga::RealSyncFileOps>();
75 auto fence = std::make_shared<mga::SyncFence>(ops, -1);75 auto fence = std::make_shared<mga::SyncFence>(ops, -1);
7676
=== modified file 'src/platform/graphics/android/display_buffer.h'
--- src/platform/graphics/android/display_buffer.h 2014-01-23 17:26:51 +0000
+++ src/platform/graphics/android/display_buffer.h 2014-02-06 13:37:40 +0000
@@ -61,7 +61,6 @@
61 std::shared_ptr<DisplayDevice> const display_device;61 std::shared_ptr<DisplayDevice> const display_device;
62 std::shared_ptr<ANativeWindow> const native_window;62 std::shared_ptr<ANativeWindow> const native_window;
63 GLContext gl_context;63 GLContext gl_context;
64 bool prepared;
65 MirOrientation rotation;64 MirOrientation rotation;
66};65};
6766
6867
=== modified file 'src/platform/graphics/android/hwc_device.h'
--- src/platform/graphics/android/hwc_device.h 2014-01-29 18:54:06 +0000
+++ src/platform/graphics/android/hwc_device.h 2014-02-06 13:37:40 +0000
@@ -51,8 +51,6 @@
51 LayerList layer_list;51 LayerList layer_list;
5252
53 std::shared_ptr<SyncFileOps> const sync_ops;53 std::shared_ptr<SyncFileOps> const sync_ops;
54 unsigned int primary_display_config;
55 MirPixelFormat fb_format;
56 static size_t const num_displays{3}; //primary, external, virtual54 static size_t const num_displays{3}; //primary, external, virtual
57};55};
5856
5957
=== modified file 'src/platform/graphics/android/hwc_layers.cpp'
--- src/platform/graphics/android/hwc_layers.cpp 2014-01-24 21:50:21 +0000
+++ src/platform/graphics/android/hwc_layers.cpp 2014-02-06 13:37:40 +0000
@@ -30,14 +30,18 @@
3030
31mga::HWCLayer& mga::HWCLayer::operator=(HWCLayer const& layer)31mga::HWCLayer& mga::HWCLayer::operator=(HWCLayer const& layer)
32{32{
33 memcpy(this, &layer, sizeof(HWCLayer));33 memcpy(static_cast<void*>(this),
34 static_cast<void const*>(&layer),
35 sizeof(HWCLayer));
34 this->visibleRegionScreen = {1, &this->visible_rect};36 this->visibleRegionScreen = {1, &this->visible_rect};
35 return *this;37 return *this;
36}38}
3739
38mga::HWCLayer::HWCLayer(HWCLayer const& layer)40mga::HWCLayer::HWCLayer(HWCLayer const& layer)
39{41{
40 memcpy(this, &layer, sizeof(HWCLayer));42 memcpy(static_cast<void*>(this),
43 static_cast<void const*>(&layer),
44 sizeof(HWCLayer));
41 this->visibleRegionScreen = {1, &this->visible_rect};45 this->visibleRegionScreen = {1, &this->visible_rect};
42}46}
4347
4448
=== modified file 'src/platform/graphics/android/internal_client_window.cpp'
--- src/platform/graphics/android/internal_client_window.cpp 2014-01-13 06:12:33 +0000
+++ src/platform/graphics/android/internal_client_window.cpp 2014-02-06 13:37:40 +0000
@@ -25,6 +25,7 @@
2525
26#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
27#include <stdexcept>27#include <stdexcept>
28#include <sstream>
2829
29namespace mg=mir::graphics;30namespace mg=mir::graphics;
30namespace mga=mg::android;31namespace mga=mg::android;
@@ -93,7 +94,11 @@
93 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:94 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
94 return 1;95 return 1;
95 default:96 default:
96 BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key));97 {
98 std::stringstream sstream;
99 sstream << "driver requests info we dont provide. key: " << key;
100 BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
101 }
97 }102 }
98}103}
99104
100105
=== modified file 'src/platform/graphics/android/server_render_window.cpp'
--- src/platform/graphics/android/server_render_window.cpp 2014-01-13 06:12:33 +0000
+++ src/platform/graphics/android/server_render_window.cpp 2014-02-06 13:37:40 +0000
@@ -28,6 +28,7 @@
28#include <system/window.h>28#include <system/window.h>
29#include <boost/throw_exception.hpp>29#include <boost/throw_exception.hpp>
30#include <stdexcept>30#include <stdexcept>
31#include <sstream>
3132
32namespace mg=mir::graphics;33namespace mg=mir::graphics;
33namespace mga=mir::graphics::android;34namespace mga=mir::graphics::android;
@@ -81,7 +82,11 @@
81 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:82 case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
82 return 1;83 return 1;
83 default:84 default:
84 BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key));85 {
86 std::stringstream sstream;
87 sstream << "driver requests info we dont provide. key: " << key;
88 BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
89 }
85 }90 }
86}91}
8792
8893
=== modified file 'tests/draw/android_graphics.cpp'
--- tests/draw/android_graphics.cpp 2014-01-13 06:12:33 +0000
+++ tests/draw/android_graphics.cpp 2014-02-06 13:37:40 +0000
@@ -48,28 +48,6 @@
48 gralloc_module_t *grmod;48 gralloc_module_t *grmod;
49 native_handle_t const* handle;49 native_handle_t const* handle;
50};50};
51
52static const char* proc_dir = "/proc";
53static const char* surface_flinger_executable_name = "surfaceflinger";
54int surface_flinger_filter(const struct dirent* d)
55{
56 if (fnmatch("[1-9]*", d->d_name, 0))
57 return 0;
58
59 char path[256];
60 snprintf(path, sizeof(path), "%s/%s/cmdline", proc_dir, d->d_name);
61
62 std::ifstream in(path);
63 std::string line;
64
65 while(std::getline(in, line))
66 {
67 if (line.find(surface_flinger_executable_name) != std::string::npos)
68 return 1;
69 }
70
71 return 0;
72}
73}51}
7452
75mtd::TestGrallocMapper::TestGrallocMapper()53mtd::TestGrallocMapper::TestGrallocMapper()
7654
=== modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp'
--- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2014-01-13 06:12:33 +0000
+++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2014-02-06 13:37:40 +0000
@@ -236,7 +236,7 @@
236236
237TEST_F(AdaptorICSTest, handle_has_version)237TEST_F(AdaptorICSTest, handle_has_version)
238{238{
239 int version = 96; /* version value shared by JB and ICS */239 int version = sizeof(ANativeWindowBuffer); /* version value shared by JB and ICS */
240 auto native_handle = alloc_adaptor->alloc_buffer(size, pf, usage);240 auto native_handle = alloc_adaptor->alloc_buffer(size, pf, usage);
241 auto anwb = native_handle->anwb();241 auto anwb = native_handle->anwb();
242 EXPECT_EQ(version, anwb->common.version);242 EXPECT_EQ(version, anwb->common.version);
243243
=== modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp'
--- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2014-01-13 06:12:33 +0000
+++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2014-02-06 13:37:40 +0000
@@ -101,7 +101,8 @@
101TEST_F(AndroidBufferBinding, buffer_makes_new_image_with_new_display)101TEST_F(AndroidBufferBinding, buffer_makes_new_image_with_new_display)
102{102{
103 using namespace testing;103 using namespace testing;
104 EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);104 EGLDisplay second_fake_display =
105 reinterpret_cast<EGLDisplay>(&second_fake_display);
105106
106 /* return 1st fake display */107 /* return 1st fake display */
107 EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_))108 EXPECT_CALL(mock_egl, eglCreateImageKHR(_,_,_,_,_))
@@ -121,7 +122,8 @@
121TEST_F(AndroidBufferBinding, buffer_frees_images_it_makes)122TEST_F(AndroidBufferBinding, buffer_frees_images_it_makes)
122{123{
123 using namespace testing;124 using namespace testing;
124 EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);125 EGLDisplay second_fake_display =
126 reinterpret_cast<EGLDisplay>(&second_fake_display);
125127
126 EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,_))128 EXPECT_CALL(mock_egl, eglDestroyImageKHR(_,_))
127 .Times(Exactly(2));129 .Times(Exactly(2));
@@ -141,9 +143,12 @@
141 using namespace testing;143 using namespace testing;
142144
143 EGLDisplay first_fake_display = mock_egl.fake_egl_display;145 EGLDisplay first_fake_display = mock_egl.fake_egl_display;
144 EGLImageKHR first_fake_egl_image = (EGLImageKHR) 0x84210;146 EGLImageKHR first_fake_egl_image =
145 EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);147 reinterpret_cast<EGLImageKHR>(&first_fake_egl_image);
146 EGLImageKHR second_fake_egl_image = (EGLImageKHR) 0x84211;148 EGLDisplay second_fake_display =
149 reinterpret_cast<EGLDisplay>(&second_fake_display);
150 EGLImageKHR second_fake_egl_image =
151 reinterpret_cast<EGLImageKHR>(&second_fake_egl_image);
147152
148 /* actual expectations */153 /* actual expectations */
149 EXPECT_CALL(mock_egl, eglDestroyImageKHR(first_fake_display, first_fake_egl_image))154 EXPECT_CALL(mock_egl, eglDestroyImageKHR(first_fake_display, first_fake_egl_image))
@@ -321,8 +326,10 @@
321TEST_F(AndroidBufferBinding, buffer_binding_uses_right_image_after_display_swap)326TEST_F(AndroidBufferBinding, buffer_binding_uses_right_image_after_display_swap)
322{327{
323 using namespace testing;328 using namespace testing;
324 EGLDisplay second_fake_display = (EGLDisplay) ((int)mock_egl.fake_egl_display +1);329 EGLDisplay second_fake_display =
325 EGLImageKHR second_fake_egl_image = (EGLImageKHR) 0x84211;330 reinterpret_cast<EGLDisplay>(&second_fake_display);
331 EGLImageKHR second_fake_egl_image =
332 reinterpret_cast<EGLImageKHR>(&second_fake_egl_image);
326333
327 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))334 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))
328 .Times(Exactly(1));335 .Times(Exactly(1));

Subscribers

People subscribed via source and target branches