Status: | Superseded |
---|---|
Proposed branch: | lp:~mir-team/mir/0.18.3 |
Merge into: | lp:mir/0.18 |
Diff against target: |
1674 lines (+513/-67) 60 files modified
debian/changelog (+7/-1) include/renderers/gl/mir/renderer/gl/texture_source.h (+10/-0) src/common/graphics/android/CMakeLists.txt (+2/-0) src/common/graphics/android/android_native_buffer.cpp (+15/-1) src/gl/recently_used_cache.cpp (+8/-7) src/include/common/mir/graphics/android/android_native_buffer.h (+6/-0) src/include/common/mir/graphics/android/native_buffer.h (+3/-0) src/platform/symbols.map (+14/-0) src/platforms/android/client/CMakeLists.txt (+3/-0) src/platforms/android/client/gralloc_registrar.cpp (+3/-1) src/platforms/android/server/CMakeLists.txt (+1/-0) src/platforms/android/server/android_alloc_adaptor.cpp (+12/-5) src/platforms/android/server/android_alloc_adaptor.h (+6/-2) src/platforms/android/server/android_buffer_allocator.cpp (+10/-4) src/platforms/android/server/android_graphic_buffer_allocator.h (+5/-1) src/platforms/android/server/buffer.cpp (+23/-4) src/platforms/android/server/buffer.h (+6/-0) src/platforms/android/server/cmdstream_sync_factory.h (+48/-0) src/platforms/android/server/device_quirks.cpp (+7/-1) src/platforms/android/server/device_quirks.h (+1/-0) src/platforms/android/server/display_buffer.cpp (+3/-0) src/platforms/android/server/display_component_factory.h (+2/-0) src/platforms/android/server/display_device.h (+2/-0) src/platforms/android/server/egl_sync_factory.cpp (+34/-0) src/platforms/android/server/fb_device.cpp (+5/-2) src/platforms/android/server/fb_device.h (+1/-0) src/platforms/android/server/hal_component_factory.cpp (+20/-1) src/platforms/android/server/hal_component_factory.h (+4/-1) src/platforms/android/server/hwc_device.cpp (+11/-6) src/platforms/android/server/hwc_device.h (+1/-0) src/platforms/android/server/hwc_fb_device.cpp (+5/-0) src/platforms/android/server/hwc_fb_device.h (+1/-0) src/platforms/android/server/ipc_operations.cpp (+1/-0) src/platforms/android/server/platform.cpp (+10/-4) src/platforms/android/server/platform.h (+3/-0) src/platforms/mesa/server/common/gbm_buffer.cpp (+9/-0) src/platforms/mesa/server/common/gbm_buffer.h (+2/-0) src/platforms/mesa/server/common/shm_buffer.cpp (+9/-0) src/platforms/mesa/server/common/shm_buffer.h (+2/-0) tests/include/mir/test/doubles/mock_android_native_buffer.h (+2/-0) tests/include/mir/test/doubles/mock_buffer.h (+1/-0) tests/include/mir/test/doubles/mock_display_device.h (+3/-0) tests/include/mir/test/doubles/mock_gl_buffer.h (+2/-0) tests/include/mir/test/doubles/stub_android_native_buffer.h (+3/-0) tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h (+41/-0) tests/include/mir/test/doubles/stub_display_builder.h (+5/-0) tests/include/mir/test/doubles/stub_gl_buffer.h (+2/-0) tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+3/-0) tests/unit-tests/gl/test_gl_texture_cache.cpp (+3/-1) tests/unit-tests/gl/test_program_factory.cpp (+1/-1) tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp (+5/-2) tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+6/-2) tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp (+13/-1) tests/unit-tests/graphics/android/test_display_buffer.cpp (+15/-0) tests/unit-tests/graphics/android/test_display_hotplug.cpp (+5/-0) tests/unit-tests/graphics/android/test_fb_device.cpp (+8/-0) tests/unit-tests/graphics/android/test_hwc_device.cpp (+9/-8) tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+6/-0) tests/unit-tests/graphics/android/test_native_buffer.cpp (+50/-7) tests/unit-tests/graphics/android/test_platform.cpp (+15/-4) |
To merge this branch: | bzr merge lp:~mir-team/mir/0.18.3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+283845@code.launchpad.net |
Commit message
MP for Temporary silo to address lp: #1517205
Description of the change
MP for Temporary silo to address lp: #1517205
To post a comment you must log in.
Unmerged revisions
- 3197. By Kevin DuBois
-
add quirk to clear fence for another device during FB GL rendering
- 3196. By Kevin DuBois
-
disable eglsync on mx4 due to driver problem necessitating gles3.0
- 3195. By Kevin DuBois
-
bump changelog to 0.18.2
- 3194. By Kevin DuBois
-
reintroduce sync fences
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2016-01-18 18:06:23 +0000 | |||
3 | +++ debian/changelog 2016-01-25 17:04:59 +0000 | |||
4 | @@ -1,4 +1,10 @@ | |||
6 | 1 | mir (0.18.1-0ubuntu1) UNRELEASED; urgency=medium | 1 | mir (0.18.2-0ubuntu1) UNRELEASED; urgency=medium |
7 | 2 | |||
8 | 3 | * Add egl sync fences for devices that need it. (LP: #1517205) | ||
9 | 4 | |||
10 | 5 | -- Kevin DuBois <kevin.dubois@canonical.com> Mon, 25 Jan 2016 09:58:43 -0500 | ||
11 | 6 | |||
12 | 7 | mir (0.18.1-0ubuntu1) xenial; urgency=medium | ||
13 | 2 | 8 | ||
14 | 3 | * New upstream release 0.18.1 (https://launchpad.net/mir/+milestone/0.18.1) | 9 | * New upstream release 0.18.1 (https://launchpad.net/mir/+milestone/0.18.1) |
15 | 4 | - No ABI changes. Bug fix release only. | 10 | - No ABI changes. Bug fix release only. |
16 | 5 | 11 | ||
17 | === modified file 'include/renderers/gl/mir/renderer/gl/texture_source.h' | |||
18 | --- include/renderers/gl/mir/renderer/gl/texture_source.h 2015-12-11 12:22:15 +0000 | |||
19 | +++ include/renderers/gl/mir/renderer/gl/texture_source.h 2016-01-25 17:04:59 +0000 | |||
20 | @@ -26,12 +26,22 @@ | |||
21 | 26 | namespace gl | 26 | namespace gl |
22 | 27 | { | 27 | { |
23 | 28 | 28 | ||
24 | 29 | //FIXME: (kdub) we're not hiding the differences in texture upload approaches between our platforms | ||
25 | 30 | // very well with this interface. | ||
26 | 29 | class TextureSource | 31 | class TextureSource |
27 | 30 | { | 32 | { |
28 | 31 | public: | 33 | public: |
29 | 32 | virtual ~TextureSource() = default; | 34 | virtual ~TextureSource() = default; |
30 | 33 | 35 | ||
31 | 36 | // \warning deprecated, provided for convenience and legacy transition. | ||
32 | 37 | //will call bind() and then secure_for_render() | ||
33 | 34 | virtual void gl_bind_to_texture() = 0; | 38 | virtual void gl_bind_to_texture() = 0; |
34 | 39 | //Uploads texture. | ||
35 | 40 | virtual void bind() = 0; | ||
36 | 41 | //add synchronization points to the command stream to ensure resources | ||
37 | 42 | //are present during the draw. Will not upload texture. | ||
38 | 43 | //should be called if an already uploaded texture is reused. | ||
39 | 44 | virtual void secure_for_render() = 0; | ||
40 | 35 | 45 | ||
41 | 36 | protected: | 46 | protected: |
42 | 37 | TextureSource() = default; | 47 | TextureSource() = default; |
43 | 38 | 48 | ||
44 | === modified file 'src/common/graphics/android/CMakeLists.txt' | |||
45 | --- src/common/graphics/android/CMakeLists.txt 2015-12-11 12:22:15 +0000 | |||
46 | +++ src/common/graphics/android/CMakeLists.txt 2016-01-25 17:04:59 +0000 | |||
47 | @@ -1,5 +1,7 @@ | |||
48 | 1 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) | 1 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
49 | 2 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) | 2 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) |
50 | 3 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/include/platform) | ||
51 | 4 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/src/include/platform) | ||
52 | 3 | 5 | ||
53 | 4 | add_definitions( -DANDROID ) | 6 | add_definitions( -DANDROID ) |
54 | 5 | 7 | ||
55 | 6 | 8 | ||
56 | === modified file 'src/common/graphics/android/android_native_buffer.cpp' | |||
57 | --- src/common/graphics/android/android_native_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
58 | +++ src/common/graphics/android/android_native_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
59 | @@ -17,14 +17,17 @@ | |||
60 | 17 | */ | 17 | */ |
61 | 18 | 18 | ||
62 | 19 | #include "mir/graphics/android/android_native_buffer.h" | 19 | #include "mir/graphics/android/android_native_buffer.h" |
63 | 20 | #include "mir/graphics/egl_sync_fence.h" | ||
64 | 20 | 21 | ||
65 | 21 | namespace mga=mir::graphics::android; | 22 | namespace mga=mir::graphics::android; |
66 | 22 | 23 | ||
67 | 23 | mga::AndroidNativeBuffer::AndroidNativeBuffer( | 24 | mga::AndroidNativeBuffer::AndroidNativeBuffer( |
68 | 24 | std::shared_ptr<ANativeWindowBuffer> const& anwb, | 25 | std::shared_ptr<ANativeWindowBuffer> const& anwb, |
69 | 26 | std::shared_ptr<CommandStreamSync> const& cmdstream_sync, | ||
70 | 25 | std::shared_ptr<Fence> const& fence, | 27 | std::shared_ptr<Fence> const& fence, |
71 | 26 | BufferAccess access) | 28 | BufferAccess access) |
73 | 27 | : fence(fence), | 29 | : cmdstream_sync(cmdstream_sync), |
74 | 30 | fence(fence), | ||
75 | 28 | access(access), | 31 | access(access), |
76 | 29 | native_window_buffer(anwb) | 32 | native_window_buffer(anwb) |
77 | 30 | { | 33 | { |
78 | @@ -58,3 +61,14 @@ | |||
79 | 58 | { | 61 | { |
80 | 59 | return fence->copy_native_handle(); | 62 | return fence->copy_native_handle(); |
81 | 60 | } | 63 | } |
82 | 64 | |||
83 | 65 | void mga::AndroidNativeBuffer::lock_for_gpu() | ||
84 | 66 | { | ||
85 | 67 | cmdstream_sync->raise(); | ||
86 | 68 | } | ||
87 | 69 | |||
88 | 70 | void mga::AndroidNativeBuffer::wait_for_unlock_by_gpu() | ||
89 | 71 | { | ||
90 | 72 | using namespace std::chrono; | ||
91 | 73 | cmdstream_sync->wait_for(duration_cast<nanoseconds>(seconds(2))); | ||
92 | 74 | } | ||
93 | 61 | 75 | ||
94 | === modified file 'src/gl/recently_used_cache.cpp' | |||
95 | --- src/gl/recently_used_cache.cpp 2015-12-11 12:22:15 +0000 | |||
96 | +++ src/gl/recently_used_cache.cpp 2016-01-25 17:04:59 +0000 | |||
97 | @@ -27,6 +27,7 @@ | |||
98 | 27 | namespace mg = mir::graphics; | 27 | namespace mg = mir::graphics; |
99 | 28 | namespace mgl = mir::gl; | 28 | namespace mgl = mir::gl; |
100 | 29 | namespace geom = mir::geometry; | 29 | namespace geom = mir::geometry; |
101 | 30 | namespace mrgl = mir::renderer::gl; | ||
102 | 30 | 31 | ||
103 | 31 | std::shared_ptr<mgl::Texture> mgl::RecentlyUsedCache::load(mg::Renderable const& renderable) | 32 | std::shared_ptr<mgl::Texture> mgl::RecentlyUsedCache::load(mg::Renderable const& renderable) |
104 | 32 | { | 33 | { |
105 | @@ -35,18 +36,18 @@ | |||
106 | 35 | auto& texture = textures[renderable.id()]; | 36 | auto& texture = textures[renderable.id()]; |
107 | 36 | texture.texture->bind(); | 37 | texture.texture->bind(); |
108 | 37 | 38 | ||
109 | 39 | auto const texture_source = dynamic_cast<mrgl::TextureSource*>(buffer->native_buffer_base()); | ||
110 | 40 | if (!texture_source) | ||
111 | 41 | BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); | ||
112 | 42 | |||
113 | 38 | if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding)) | 43 | if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding)) |
114 | 39 | { | 44 | { |
122 | 40 | auto const texture_source = | 45 | texture_source->bind(); |
116 | 41 | dynamic_cast<mir::renderer::gl::TextureSource*>( | ||
117 | 42 | buffer->native_buffer_base()); | ||
118 | 43 | if (!texture_source) | ||
119 | 44 | BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); | ||
120 | 45 | |||
121 | 46 | texture_source->gl_bind_to_texture(); | ||
123 | 47 | texture.resource = buffer; | 46 | texture.resource = buffer; |
124 | 48 | texture.last_bound_buffer = buffer_id; | 47 | texture.last_bound_buffer = buffer_id; |
125 | 49 | } | 48 | } |
126 | 49 | texture_source->secure_for_render(); | ||
127 | 50 | |||
128 | 50 | texture.valid_binding = true; | 51 | texture.valid_binding = true; |
129 | 51 | texture.used = true; | 52 | texture.used = true; |
130 | 52 | 53 | ||
131 | 53 | 54 | ||
132 | === modified file 'src/include/common/mir/graphics/android/android_native_buffer.h' | |||
133 | --- src/include/common/mir/graphics/android/android_native_buffer.h 2015-12-11 12:22:15 +0000 | |||
134 | +++ src/include/common/mir/graphics/android/android_native_buffer.h 2016-01-25 17:04:59 +0000 | |||
135 | @@ -27,6 +27,7 @@ | |||
136 | 27 | { | 27 | { |
137 | 28 | namespace graphics | 28 | namespace graphics |
138 | 29 | { | 29 | { |
139 | 30 | class CommandStreamSync; | ||
140 | 30 | namespace android | 31 | namespace android |
141 | 31 | { | 32 | { |
142 | 32 | class Fence; | 33 | class Fence; |
143 | @@ -35,6 +36,7 @@ | |||
144 | 35 | { | 36 | { |
145 | 36 | AndroidNativeBuffer( | 37 | AndroidNativeBuffer( |
146 | 37 | std::shared_ptr<ANativeWindowBuffer> const& handle, | 38 | std::shared_ptr<ANativeWindowBuffer> const& handle, |
147 | 39 | std::shared_ptr<CommandStreamSync> const& cmdstream_sync, | ||
148 | 38 | std::shared_ptr<Fence> const& fence, | 40 | std::shared_ptr<Fence> const& fence, |
149 | 39 | BufferAccess fence_access); | 41 | BufferAccess fence_access); |
150 | 40 | 42 | ||
151 | @@ -45,7 +47,11 @@ | |||
152 | 45 | void ensure_available_for(BufferAccess); | 47 | void ensure_available_for(BufferAccess); |
153 | 46 | void update_usage(NativeFence& merge_fd, BufferAccess); | 48 | void update_usage(NativeFence& merge_fd, BufferAccess); |
154 | 47 | 49 | ||
155 | 50 | void lock_for_gpu(); | ||
156 | 51 | void wait_for_unlock_by_gpu(); | ||
157 | 52 | |||
158 | 48 | private: | 53 | private: |
159 | 54 | std::shared_ptr<CommandStreamSync> cmdstream_sync; | ||
160 | 49 | std::shared_ptr<Fence> fence; | 55 | std::shared_ptr<Fence> fence; |
161 | 50 | BufferAccess access; | 56 | BufferAccess access; |
162 | 51 | std::shared_ptr<ANativeWindowBuffer> native_window_buffer; | 57 | std::shared_ptr<ANativeWindowBuffer> native_window_buffer; |
163 | 52 | 58 | ||
164 | === modified file 'src/include/common/mir/graphics/android/native_buffer.h' | |||
165 | --- src/include/common/mir/graphics/android/native_buffer.h 2015-12-11 12:22:15 +0000 | |||
166 | +++ src/include/common/mir/graphics/android/native_buffer.h 2016-01-25 17:04:59 +0000 | |||
167 | @@ -53,6 +53,9 @@ | |||
168 | 53 | virtual void ensure_available_for(android::BufferAccess intent) = 0; | 53 | virtual void ensure_available_for(android::BufferAccess intent) = 0; |
169 | 54 | virtual void update_usage(android::NativeFence& fence, android::BufferAccess current_usage) = 0; | 54 | virtual void update_usage(android::NativeFence& fence, android::BufferAccess current_usage) = 0; |
170 | 55 | 55 | ||
171 | 56 | virtual void lock_for_gpu() = 0; | ||
172 | 57 | virtual void wait_for_unlock_by_gpu() = 0; | ||
173 | 58 | |||
174 | 56 | protected: | 59 | protected: |
175 | 57 | NativeBuffer() = default; | 60 | NativeBuffer() = default; |
176 | 58 | NativeBuffer(NativeBuffer const&) = delete; | 61 | NativeBuffer(NativeBuffer const&) = delete; |
177 | 59 | 62 | ||
178 | === modified file 'src/platform/symbols.map' | |||
179 | --- src/platform/symbols.map 2015-12-11 12:22:15 +0000 | |||
180 | +++ src/platform/symbols.map 2016-01-25 17:04:59 +0000 | |||
181 | @@ -219,6 +219,7 @@ | |||
182 | 219 | vtable?for?mir::graphics::EventHandlerRegister; | 219 | vtable?for?mir::graphics::EventHandlerRegister; |
183 | 220 | vtable?for?mir::graphics::GLConfig; | 220 | vtable?for?mir::graphics::GLConfig; |
184 | 221 | vtable?for?mir::graphics::GLContext; | 221 | vtable?for?mir::graphics::GLContext; |
185 | 222 | vtable?for?mir::graphics::NullCommandSync; | ||
186 | 222 | vtable?for?mir::graphics::GraphicBufferAllocator; | 223 | vtable?for?mir::graphics::GraphicBufferAllocator; |
187 | 223 | vtable?for?mir::graphics::Platform; | 224 | vtable?for?mir::graphics::Platform; |
188 | 224 | vtable?for?mir::graphics::PlatformIpcOperations; | 225 | vtable?for?mir::graphics::PlatformIpcOperations; |
189 | @@ -237,6 +238,19 @@ | |||
190 | 237 | mir::graphics::blue_channel_depth*; | 238 | mir::graphics::blue_channel_depth*; |
191 | 238 | mir::graphics::contains_alpha*; | 239 | mir::graphics::contains_alpha*; |
192 | 239 | mir::graphics::EGLExtensions::EGLExtensions*; | 240 | mir::graphics::EGLExtensions::EGLExtensions*; |
193 | 241 | mir::graphics::EGLSyncExtensions::EGLSyncExtensions*; | ||
194 | 242 | mir::graphics::CommandStreamSync::?CommandStreamSync*; | ||
195 | 243 | mir::graphics::CommandStreamSync::CommandStreamSync*; | ||
196 | 244 | mir::graphics::CommandStreamSync::CommandStreamSync*; | ||
197 | 245 | mir::graphics::CommandStreamSync::operator*; | ||
198 | 246 | mir::graphics::NullCommandSync::?NullCommandSync*; | ||
199 | 247 | mir::graphics::NullCommandSync::NullCommandSync*; | ||
200 | 248 | mir::graphics::NullCommandSync::NullCommandSync*; | ||
201 | 249 | mir::graphics::NullCommandSync::operator*; | ||
202 | 250 | mir::graphics::EGLSyncFence::?EGLSyncFence*; | ||
203 | 251 | mir::graphics::EGLSyncFence::EGLSyncFence*; | ||
204 | 252 | mir::graphics::EGLSyncFence::EGLSyncFence*; | ||
205 | 253 | mir::graphics::EGLSyncFence::operator*; | ||
206 | 240 | mir::graphics::EGLContextStore::?EGLContextStore*; | 254 | mir::graphics::EGLContextStore::?EGLContextStore*; |
207 | 241 | mir::graphics::EGLContextStore::EGLContextStore*; | 255 | mir::graphics::EGLContextStore::EGLContextStore*; |
208 | 242 | mir::graphics::EGLContextStore::EGLContextStore*; | 256 | mir::graphics::EGLContextStore::EGLContextStore*; |
209 | 243 | 257 | ||
210 | === modified file 'src/platforms/android/client/CMakeLists.txt' | |||
211 | --- src/platforms/android/client/CMakeLists.txt 2015-12-11 12:22:15 +0000 | |||
212 | +++ src/platforms/android/client/CMakeLists.txt 2016-01-25 17:04:59 +0000 | |||
213 | @@ -1,6 +1,8 @@ | |||
214 | 1 | include_directories(${client_common_include_dirs}) | 1 | include_directories(${client_common_include_dirs}) |
215 | 2 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) | 2 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
216 | 3 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) | 3 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) |
217 | 4 | include_directories(${CMAKE_SOURCE_DIR}/include/platform) | ||
218 | 5 | include_directories(${CMAKE_SOURCE_DIR}/src/include/platform) | ||
219 | 4 | 6 | ||
220 | 5 | add_definitions(-DANDROID) | 7 | add_definitions(-DANDROID) |
221 | 6 | 8 | ||
222 | @@ -35,6 +37,7 @@ | |||
223 | 35 | mirclient | 37 | mirclient |
224 | 36 | client_platform_common | 38 | client_platform_common |
225 | 37 | mirsharedandroid-static | 39 | mirsharedandroid-static |
226 | 40 | mirplatform | ||
227 | 38 | ${LIBHARDWARE_LIBRARIES} | 41 | ${LIBHARDWARE_LIBRARIES} |
228 | 39 | ) | 42 | ) |
229 | 40 | 43 | ||
230 | 41 | 44 | ||
231 | === modified file 'src/platforms/android/client/gralloc_registrar.cpp' | |||
232 | --- src/platforms/android/client/gralloc_registrar.cpp 2015-12-11 12:22:15 +0000 | |||
233 | +++ src/platforms/android/client/gralloc_registrar.cpp 2016-01-25 17:04:59 +0000 | |||
234 | @@ -18,6 +18,7 @@ | |||
235 | 18 | 18 | ||
236 | 19 | #include "mir/graphics/android/android_native_buffer.h" | 19 | #include "mir/graphics/android/android_native_buffer.h" |
237 | 20 | #include "mir/graphics/android/sync_fence.h" | 20 | #include "mir/graphics/android/sync_fence.h" |
238 | 21 | #include "mir/graphics/egl_sync_fence.h" | ||
239 | 21 | #include "gralloc_registrar.h" | 22 | #include "gralloc_registrar.h" |
240 | 22 | #include "mir/client_buffer.h" | 23 | #include "mir/client_buffer.h" |
241 | 23 | 24 | ||
242 | @@ -82,7 +83,8 @@ | |||
243 | 82 | anwb->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER; | 83 | anwb->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER; |
244 | 83 | anwb->handle = handle.get(); | 84 | anwb->handle = handle.get(); |
245 | 84 | 85 | ||
247 | 85 | return std::make_shared<mga::AndroidNativeBuffer>(anwb, fence, mga::BufferAccess::read); | 86 | auto sync = std::make_shared<mg::NullCommandSync>(); //no need for eglsync client side |
248 | 87 | return std::make_shared<mga::AndroidNativeBuffer>(anwb, sync, fence, mga::BufferAccess::read); | ||
249 | 86 | } | 88 | } |
250 | 87 | } | 89 | } |
251 | 88 | std::shared_ptr<mg::NativeBuffer> mcla::GrallocRegistrar::register_buffer( | 90 | std::shared_ptr<mg::NativeBuffer> mcla::GrallocRegistrar::register_buffer( |
252 | 89 | 91 | ||
253 | === modified file 'src/platforms/android/server/CMakeLists.txt' | |||
254 | --- src/platforms/android/server/CMakeLists.txt 2015-12-11 12:22:15 +0000 | |||
255 | +++ src/platforms/android/server/CMakeLists.txt 2016-01-25 17:04:59 +0000 | |||
256 | @@ -43,6 +43,7 @@ | |||
257 | 43 | hwc_fallback_gl_renderer.cpp | 43 | hwc_fallback_gl_renderer.cpp |
258 | 44 | ipc_operations.cpp | 44 | ipc_operations.cpp |
259 | 45 | hwc_blanking_control.cpp | 45 | hwc_blanking_control.cpp |
260 | 46 | egl_sync_factory.cpp | ||
261 | 46 | ) | 47 | ) |
262 | 47 | 48 | ||
263 | 48 | add_library(mirplatformgraphicsandroid SHARED | 49 | add_library(mirplatformgraphicsandroid SHARED |
264 | 49 | 50 | ||
265 | === modified file 'src/platforms/android/server/android_alloc_adaptor.cpp' | |||
266 | --- src/platforms/android/server/android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000 | |||
267 | +++ src/platforms/android/server/android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000 | |||
268 | @@ -20,7 +20,9 @@ | |||
269 | 20 | #include "mir/graphics/android/android_native_buffer.h" | 20 | #include "mir/graphics/android/android_native_buffer.h" |
270 | 21 | #include "mir/graphics/android/sync_fence.h" | 21 | #include "mir/graphics/android/sync_fence.h" |
271 | 22 | #include "mir/graphics/android/android_format_conversion-inl.h" | 22 | #include "mir/graphics/android/android_format_conversion-inl.h" |
272 | 23 | #include "mir/graphics/egl_sync_fence.h" | ||
273 | 23 | #include "android_alloc_adaptor.h" | 24 | #include "android_alloc_adaptor.h" |
274 | 25 | #include "cmdstream_sync_factory.h" | ||
275 | 24 | #include "device_quirks.h" | 26 | #include "device_quirks.h" |
276 | 25 | 27 | ||
277 | 26 | #include <boost/throw_exception.hpp> | 28 | #include <boost/throw_exception.hpp> |
278 | @@ -48,10 +50,13 @@ | |||
279 | 48 | }; | 50 | }; |
280 | 49 | } | 51 | } |
281 | 50 | 52 | ||
286 | 51 | mga::AndroidAllocAdaptor::AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device, | 53 | mga::AndroidAllocAdaptor::AndroidAllocAdaptor( |
287 | 52 | std::shared_ptr<DeviceQuirks> const& quirks) | 54 | std::shared_ptr<struct alloc_device_t> const& alloc_device, |
288 | 53 | : alloc_dev(alloc_device), | 55 | std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, |
289 | 54 | quirks(quirks) | 56 | std::shared_ptr<DeviceQuirks> const& quirks) : |
290 | 57 | alloc_dev(alloc_device), | ||
291 | 58 | sync_factory(sync_factory), | ||
292 | 59 | quirks(quirks) | ||
293 | 55 | { | 60 | { |
294 | 56 | } | 61 | } |
295 | 57 | 62 | ||
296 | @@ -94,7 +99,9 @@ | |||
297 | 94 | anwb->format = format; | 99 | anwb->format = format; |
298 | 95 | anwb->usage = usage_flag; | 100 | anwb->usage = usage_flag; |
299 | 96 | 101 | ||
301 | 97 | return std::make_shared<mga::AndroidNativeBuffer>(anwb, fence, mga::BufferAccess::read); | 102 | return std::make_shared<mga::AndroidNativeBuffer>(anwb, |
302 | 103 | sync_factory->create_command_stream_sync(), | ||
303 | 104 | fence, mga::BufferAccess::read); | ||
304 | 98 | } | 105 | } |
305 | 99 | 106 | ||
306 | 100 | int mga::AndroidAllocAdaptor::convert_to_android_usage(BufferUsage usage) | 107 | int mga::AndroidAllocAdaptor::convert_to_android_usage(BufferUsage usage) |
307 | 101 | 108 | ||
308 | === modified file 'src/platforms/android/server/android_alloc_adaptor.h' | |||
309 | --- src/platforms/android/server/android_alloc_adaptor.h 2015-12-11 12:22:15 +0000 | |||
310 | +++ src/platforms/android/server/android_alloc_adaptor.h 2016-01-25 17:04:59 +0000 | |||
311 | @@ -31,12 +31,15 @@ | |||
312 | 31 | namespace android | 31 | namespace android |
313 | 32 | { | 32 | { |
314 | 33 | class DeviceQuirks; | 33 | class DeviceQuirks; |
315 | 34 | class CommandStreamSyncFactory; | ||
316 | 34 | 35 | ||
317 | 35 | class AndroidAllocAdaptor : public GraphicAllocAdaptor | 36 | class AndroidAllocAdaptor : public GraphicAllocAdaptor |
318 | 36 | { | 37 | { |
319 | 37 | public: | 38 | public: |
322 | 38 | explicit AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device, | 39 | explicit AndroidAllocAdaptor( |
323 | 39 | std::shared_ptr<DeviceQuirks> const& quirks); | 40 | std::shared_ptr<struct alloc_device_t> const& alloc_device, |
324 | 41 | std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, | ||
325 | 42 | std::shared_ptr<DeviceQuirks> const& quirks); | ||
326 | 40 | std::shared_ptr<NativeBuffer> alloc_buffer(geometry::Size, | 43 | std::shared_ptr<NativeBuffer> alloc_buffer(geometry::Size, |
327 | 41 | MirPixelFormat, BufferUsage usage); | 44 | MirPixelFormat, BufferUsage usage); |
328 | 42 | 45 | ||
329 | @@ -44,6 +47,7 @@ | |||
330 | 44 | 47 | ||
331 | 45 | private: | 48 | private: |
332 | 46 | std::shared_ptr<struct alloc_device_t> alloc_dev; | 49 | std::shared_ptr<struct alloc_device_t> alloc_dev; |
333 | 50 | std::shared_ptr<CommandStreamSyncFactory> const sync_factory; | ||
334 | 47 | std::shared_ptr<DeviceQuirks> const quirks; | 51 | std::shared_ptr<DeviceQuirks> const quirks; |
335 | 48 | int convert_to_android_usage(BufferUsage usage); | 52 | int convert_to_android_usage(BufferUsage usage); |
336 | 49 | }; | 53 | }; |
337 | 50 | 54 | ||
338 | === modified file 'src/platforms/android/server/android_buffer_allocator.cpp' | |||
339 | --- src/platforms/android/server/android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000 | |||
340 | +++ src/platforms/android/server/android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000 | |||
341 | @@ -19,12 +19,14 @@ | |||
342 | 19 | 19 | ||
343 | 20 | #include "mir/graphics/platform.h" | 20 | #include "mir/graphics/platform.h" |
344 | 21 | #include "mir/graphics/egl_extensions.h" | 21 | #include "mir/graphics/egl_extensions.h" |
345 | 22 | #include "mir/graphics/egl_sync_fence.h" | ||
346 | 22 | #include "mir/graphics/buffer_properties.h" | 23 | #include "mir/graphics/buffer_properties.h" |
347 | 23 | #include "mir/graphics/android/sync_fence.h" | 24 | #include "mir/graphics/android/sync_fence.h" |
348 | 24 | #include "mir/graphics/android/android_native_buffer.h" | 25 | #include "mir/graphics/android/android_native_buffer.h" |
349 | 25 | #include "android_graphic_buffer_allocator.h" | 26 | #include "android_graphic_buffer_allocator.h" |
350 | 26 | #include "android_alloc_adaptor.h" | 27 | #include "android_alloc_adaptor.h" |
351 | 27 | #include "buffer.h" | 28 | #include "buffer.h" |
352 | 29 | #include "cmdstream_sync_factory.h" | ||
353 | 28 | #include "device_quirks.h" | 30 | #include "device_quirks.h" |
354 | 29 | 31 | ||
355 | 30 | #include <boost/throw_exception.hpp> | 32 | #include <boost/throw_exception.hpp> |
356 | @@ -50,8 +52,11 @@ | |||
357 | 50 | 52 | ||
358 | 51 | } | 53 | } |
359 | 52 | 54 | ||
362 | 53 | mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks) | 55 | mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator( |
363 | 54 | : egl_extensions(std::make_shared<mg::EGLExtensions>()) | 56 | std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, |
364 | 57 | std::shared_ptr<DeviceQuirks> const& quirks) | ||
365 | 58 | : egl_extensions(std::make_shared<mg::EGLExtensions>()), | ||
366 | 59 | cmdstream_sync_factory(cmdstream_sync_factory) | ||
367 | 55 | { | 60 | { |
368 | 56 | int err; | 61 | int err; |
369 | 57 | 62 | ||
370 | @@ -70,7 +75,7 @@ | |||
371 | 70 | std::shared_ptr<struct alloc_device_t> alloc_dev_ptr( | 75 | std::shared_ptr<struct alloc_device_t> alloc_dev_ptr( |
372 | 71 | alloc_dev, | 76 | alloc_dev, |
373 | 72 | quirks->gralloc_cannot_be_closed_safely() ? null_alloc_dev_deleter : alloc_dev_deleter); | 77 | quirks->gralloc_cannot_be_closed_safely() ? null_alloc_dev_deleter : alloc_dev_deleter); |
375 | 73 | alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, quirks)); | 78 | alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, cmdstream_sync_factory, quirks)); |
376 | 74 | } | 79 | } |
377 | 75 | 80 | ||
378 | 76 | std::shared_ptr<mg::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer( | 81 | std::shared_ptr<mg::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer( |
379 | @@ -89,9 +94,10 @@ | |||
380 | 89 | [](ANativeWindowBuffer* buffer){ buffer->common.decRef(&buffer->common); }); | 94 | [](ANativeWindowBuffer* buffer){ buffer->common.decRef(&buffer->common); }); |
381 | 90 | anwb->common.incRef(&anwb->common); | 95 | anwb->common.incRef(&anwb->common); |
382 | 91 | 96 | ||
383 | 97 | //TODO: we should have an android platform function for accessing the fence. | ||
384 | 92 | auto native_handle = std::make_shared<mga::AndroidNativeBuffer>( | 98 | auto native_handle = std::make_shared<mga::AndroidNativeBuffer>( |
385 | 93 | native_window_buffer, | 99 | native_window_buffer, |
387 | 94 | //TODO: we should have an android platform function for accessing the fence. | 100 | cmdstream_sync_factory->create_command_stream_sync(), |
388 | 95 | std::make_shared<mga::SyncFence>(std::make_shared<mga::RealSyncFileOps>(), mir::Fd()), | 101 | std::make_shared<mga::SyncFence>(std::make_shared<mga::RealSyncFileOps>(), mir::Fd()), |
389 | 96 | mga::BufferAccess::read); | 102 | mga::BufferAccess::read); |
390 | 97 | return std::make_unique<Buffer>( | 103 | return std::make_unique<Buffer>( |
391 | 98 | 104 | ||
392 | === modified file 'src/platforms/android/server/android_graphic_buffer_allocator.h' | |||
393 | --- src/platforms/android/server/android_graphic_buffer_allocator.h 2015-12-11 12:22:15 +0000 | |||
394 | +++ src/platforms/android/server/android_graphic_buffer_allocator.h 2016-01-25 17:04:59 +0000 | |||
395 | @@ -39,11 +39,14 @@ | |||
396 | 39 | 39 | ||
397 | 40 | class GraphicAllocAdaptor; | 40 | class GraphicAllocAdaptor; |
398 | 41 | class DeviceQuirks; | 41 | class DeviceQuirks; |
399 | 42 | class CommandStreamSyncFactory; | ||
400 | 42 | 43 | ||
401 | 43 | class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator | 44 | class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator |
402 | 44 | { | 45 | { |
403 | 45 | public: | 46 | public: |
405 | 46 | AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks); | 47 | AndroidGraphicBufferAllocator( |
406 | 48 | std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, | ||
407 | 49 | std::shared_ptr<DeviceQuirks> const& quirks); | ||
408 | 47 | 50 | ||
409 | 48 | std::shared_ptr<graphics::Buffer> alloc_buffer( | 51 | std::shared_ptr<graphics::Buffer> alloc_buffer( |
410 | 49 | graphics::BufferProperties const& buffer_properties) override; | 52 | graphics::BufferProperties const& buffer_properties) override; |
411 | @@ -61,6 +64,7 @@ | |||
412 | 61 | const hw_module_t *hw_module; | 64 | const hw_module_t *hw_module; |
413 | 62 | std::shared_ptr<GraphicAllocAdaptor> alloc_device; | 65 | std::shared_ptr<GraphicAllocAdaptor> alloc_device; |
414 | 63 | std::shared_ptr<EGLExtensions> const egl_extensions; | 66 | std::shared_ptr<EGLExtensions> const egl_extensions; |
415 | 67 | std::shared_ptr<CommandStreamSyncFactory> const cmdstream_sync_factory; | ||
416 | 64 | }; | 68 | }; |
417 | 65 | 69 | ||
418 | 66 | } | 70 | } |
419 | 67 | 71 | ||
420 | === modified file 'src/platforms/android/server/buffer.cpp' | |||
421 | --- src/platforms/android/server/buffer.cpp 2015-12-11 12:22:15 +0000 | |||
422 | +++ src/platforms/android/server/buffer.cpp 2016-01-25 17:04:59 +0000 | |||
423 | @@ -74,6 +74,18 @@ | |||
424 | 74 | void mga::Buffer::gl_bind_to_texture() | 74 | void mga::Buffer::gl_bind_to_texture() |
425 | 75 | { | 75 | { |
426 | 76 | std::unique_lock<std::mutex> lk(content_lock); | 76 | std::unique_lock<std::mutex> lk(content_lock); |
427 | 77 | bind(lk); | ||
428 | 78 | secure_for_render(lk); | ||
429 | 79 | } | ||
430 | 80 | |||
431 | 81 | void mga::Buffer::bind() | ||
432 | 82 | { | ||
433 | 83 | std::unique_lock<std::mutex> lk(content_lock); | ||
434 | 84 | bind(lk); | ||
435 | 85 | } | ||
436 | 86 | |||
437 | 87 | void mga::Buffer::bind(std::unique_lock<std::mutex> const&) | ||
438 | 88 | { | ||
439 | 77 | native_buffer->ensure_available_for(mga::BufferAccess::read); | 89 | native_buffer->ensure_available_for(mga::BufferAccess::read); |
440 | 78 | 90 | ||
441 | 79 | DispContextPair current | 91 | DispContextPair current |
442 | @@ -113,10 +125,6 @@ | |||
443 | 113 | } | 125 | } |
444 | 114 | 126 | ||
445 | 115 | egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); | 127 | egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); |
446 | 116 | |||
447 | 117 | //TODO: we should make use of the android egl fence extension here to update the fence. | ||
448 | 118 | // if the extension is not available, we should pass out a token that the user | ||
449 | 119 | // will have to keep until the completion of the gl draw | ||
450 | 120 | } | 128 | } |
451 | 121 | 129 | ||
452 | 122 | std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const | 130 | std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const |
453 | @@ -196,3 +204,14 @@ | |||
454 | 196 | { | 204 | { |
455 | 197 | return this; | 205 | return this; |
456 | 198 | } | 206 | } |
457 | 207 | |||
458 | 208 | void mga::Buffer::secure_for_render() | ||
459 | 209 | { | ||
460 | 210 | std::unique_lock<std::mutex> lk(content_lock); | ||
461 | 211 | secure_for_render(lk); | ||
462 | 212 | } | ||
463 | 213 | |||
464 | 214 | void mga::Buffer::secure_for_render(std::unique_lock<std::mutex> const&) | ||
465 | 215 | { | ||
466 | 216 | native_buffer->lock_for_gpu(); | ||
467 | 217 | } | ||
468 | 199 | 218 | ||
469 | === modified file 'src/platforms/android/server/buffer.h' | |||
470 | --- src/platforms/android/server/buffer.h 2015-12-11 12:22:15 +0000 | |||
471 | +++ src/platforms/android/server/buffer.h 2016-01-25 17:04:59 +0000 | |||
472 | @@ -56,6 +56,10 @@ | |||
473 | 56 | geometry::Stride stride() const override; | 56 | geometry::Stride stride() const override; |
474 | 57 | MirPixelFormat pixel_format() const override; | 57 | MirPixelFormat pixel_format() const override; |
475 | 58 | void gl_bind_to_texture() override; | 58 | void gl_bind_to_texture() override; |
476 | 59 | void bind() override; | ||
477 | 60 | void secure_for_render() override; | ||
478 | 61 | |||
479 | 62 | |||
480 | 59 | //note, you will get the native representation of an android buffer, including | 63 | //note, you will get the native representation of an android buffer, including |
481 | 60 | //the fences associated with the buffer. You must close these fences | 64 | //the fences associated with the buffer. You must close these fences |
482 | 61 | std::shared_ptr<NativeBuffer> native_buffer_handle() const override; | 65 | std::shared_ptr<NativeBuffer> native_buffer_handle() const override; |
483 | @@ -66,6 +70,8 @@ | |||
484 | 66 | NativeBufferBase* native_buffer_base() override; | 70 | NativeBufferBase* native_buffer_base() override; |
485 | 67 | 71 | ||
486 | 68 | private: | 72 | private: |
487 | 73 | void bind(std::unique_lock<std::mutex> const&); | ||
488 | 74 | void secure_for_render(std::unique_lock<std::mutex> const&); | ||
489 | 69 | gralloc_module_t const* hw_module; | 75 | gralloc_module_t const* hw_module; |
490 | 70 | 76 | ||
491 | 71 | typedef std::pair<EGLDisplay, EGLContext> DispContextPair; | 77 | typedef std::pair<EGLDisplay, EGLContext> DispContextPair; |
492 | 72 | 78 | ||
493 | === added file 'src/platforms/android/server/cmdstream_sync_factory.h' | |||
494 | --- src/platforms/android/server/cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000 | |||
495 | +++ src/platforms/android/server/cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000 | |||
496 | @@ -0,0 +1,48 @@ | |||
497 | 1 | /* | ||
498 | 2 | * Copyright © 2015 Canonical Ltd. | ||
499 | 3 | * | ||
500 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
501 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
502 | 6 | * as published by the Free Software Foundation. | ||
503 | 7 | * | ||
504 | 8 | * This program is distributed in the hope that it will be useful, | ||
505 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
506 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
507 | 11 | * GNU Lesser General Public License for more details. | ||
508 | 12 | * | ||
509 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
510 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
511 | 15 | * | ||
512 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | ||
513 | 17 | */ | ||
514 | 18 | |||
515 | 19 | #ifndef MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ | ||
516 | 20 | #define MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ | ||
517 | 21 | |||
518 | 22 | #include <memory> | ||
519 | 23 | namespace mir | ||
520 | 24 | { | ||
521 | 25 | namespace graphics | ||
522 | 26 | { | ||
523 | 27 | class CommandStreamSync; | ||
524 | 28 | namespace android | ||
525 | 29 | { | ||
526 | 30 | class CommandStreamSyncFactory | ||
527 | 31 | { | ||
528 | 32 | public: | ||
529 | 33 | virtual ~CommandStreamSyncFactory() = default; | ||
530 | 34 | virtual std::unique_ptr<CommandStreamSync> create_command_stream_sync() = 0; | ||
531 | 35 | protected: | ||
532 | 36 | CommandStreamSyncFactory() = default; | ||
533 | 37 | CommandStreamSyncFactory(CommandStreamSyncFactory const&) = delete; | ||
534 | 38 | CommandStreamSyncFactory& operator=(CommandStreamSyncFactory const&) = delete; | ||
535 | 39 | }; | ||
536 | 40 | |||
537 | 41 | class EGLSyncFactory : public CommandStreamSyncFactory | ||
538 | 42 | { | ||
539 | 43 | std::unique_ptr<CommandStreamSync> create_command_stream_sync() override; | ||
540 | 44 | }; | ||
541 | 45 | } | ||
542 | 46 | } | ||
543 | 47 | } | ||
544 | 48 | #endif /* MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ */ | ||
545 | 0 | 49 | ||
546 | === modified file 'src/platforms/android/server/device_quirks.cpp' | |||
547 | --- src/platforms/android/server/device_quirks.cpp 2015-11-30 18:29:57 +0000 | |||
548 | +++ src/platforms/android/server/device_quirks.cpp 2016-01-25 17:04:59 +0000 | |||
549 | @@ -62,7 +62,7 @@ | |||
550 | 62 | 62 | ||
551 | 63 | bool clear_fb_context_fence_for(std::string const& device_name) | 63 | bool clear_fb_context_fence_for(std::string const& device_name) |
552 | 64 | { | 64 | { |
554 | 65 | return device_name == "krillin" || device_name == "mx4" || device_name == "manta"; | 65 | return device_name == "krillin" || device_name == "mx4" || device_name == "manta" || device_name =="Aquaris_M10_FHD"; |
555 | 66 | } | 66 | } |
556 | 67 | 67 | ||
557 | 68 | } | 68 | } |
558 | @@ -107,6 +107,12 @@ | |||
559 | 107 | return clear_fb_context_fence_; | 107 | return clear_fb_context_fence_; |
560 | 108 | } | 108 | } |
561 | 109 | 109 | ||
562 | 110 | bool mga::DeviceQuirks::working_egl_sync() const | ||
563 | 111 | { | ||
564 | 112 | //FIXME: this really should be all powervr devices. | ||
565 | 113 | return device_name != "mx4"; | ||
566 | 114 | } | ||
567 | 115 | |||
568 | 110 | void mga::DeviceQuirks::add_options(boost::program_options::options_description& config) | 116 | void mga::DeviceQuirks::add_options(boost::program_options::options_description& config) |
569 | 111 | { | 117 | { |
570 | 112 | config.add_options() | 118 | config.add_options() |
571 | 113 | 119 | ||
572 | === modified file 'src/platforms/android/server/device_quirks.h' | |||
573 | --- src/platforms/android/server/device_quirks.h 2015-11-30 12:36:04 +0000 | |||
574 | +++ src/platforms/android/server/device_quirks.h 2016-01-25 17:04:59 +0000 | |||
575 | @@ -64,6 +64,7 @@ | |||
576 | 64 | bool gralloc_cannot_be_closed_safely() const; | 64 | bool gralloc_cannot_be_closed_safely() const; |
577 | 65 | int aligned_width(int width) const; | 65 | int aligned_width(int width) const; |
578 | 66 | bool clear_fb_context_fence() const; | 66 | bool clear_fb_context_fence() const; |
579 | 67 | bool working_egl_sync() const; | ||
580 | 67 | 68 | ||
581 | 68 | static void add_options(boost::program_options::options_description& config); | 69 | static void add_options(boost::program_options::options_description& config); |
582 | 69 | 70 | ||
583 | 70 | 71 | ||
584 | === modified file 'src/platforms/android/server/display_buffer.cpp' | |||
585 | --- src/platforms/android/server/display_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
586 | +++ src/platforms/android/server/display_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
587 | @@ -98,6 +98,9 @@ | |||
588 | 98 | void mga::DisplayBuffer::swap_buffers() | 98 | void mga::DisplayBuffer::swap_buffers() |
589 | 99 | { | 99 | { |
590 | 100 | layer_list->update_list({}, offset_from_origin); | 100 | layer_list->update_list({}, offset_from_origin); |
591 | 101 | //HWC 1.0 cannot call eglSwapBuffers() on the display context | ||
592 | 102 | if (display_device->can_swap_buffers()) | ||
593 | 103 | gl_context.swap_buffers(); | ||
594 | 101 | } | 104 | } |
595 | 102 | 105 | ||
596 | 103 | MirOrientation mga::DisplayBuffer::orientation() const | 106 | MirOrientation mga::DisplayBuffer::orientation() const |
597 | 104 | 107 | ||
598 | === modified file 'src/platforms/android/server/display_component_factory.h' | |||
599 | --- src/platforms/android/server/display_component_factory.h 2015-12-11 12:22:15 +0000 | |||
600 | +++ src/platforms/android/server/display_component_factory.h 2016-01-25 17:04:59 +0000 | |||
601 | @@ -19,6 +19,7 @@ | |||
602 | 19 | #ifndef MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ | 19 | #ifndef MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ |
603 | 20 | #define MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ | 20 | #define MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ |
604 | 21 | 21 | ||
605 | 22 | #include "mir/graphics/egl_sync_fence.h" | ||
606 | 22 | #include "display_device.h" | 23 | #include "display_device.h" |
607 | 23 | #include "framebuffer_bundle.h" | 24 | #include "framebuffer_bundle.h" |
608 | 24 | #include <memory> | 25 | #include <memory> |
609 | @@ -28,6 +29,7 @@ | |||
610 | 28 | namespace graphics | 29 | namespace graphics |
611 | 29 | { | 30 | { |
612 | 30 | class DisplayConfigurationOutput; | 31 | class DisplayConfigurationOutput; |
613 | 32 | class CommandStreamSync; | ||
614 | 31 | namespace android | 33 | namespace android |
615 | 32 | { | 34 | { |
616 | 33 | class HwcConfiguration; | 35 | class HwcConfiguration; |
617 | 34 | 36 | ||
618 | === modified file 'src/platforms/android/server/display_device.h' | |||
619 | --- src/platforms/android/server/display_device.h 2015-12-11 12:22:15 +0000 | |||
620 | +++ src/platforms/android/server/display_device.h 2016-01-25 17:04:59 +0000 | |||
621 | @@ -69,6 +69,8 @@ | |||
622 | 69 | 69 | ||
623 | 70 | virtual std::chrono::milliseconds recommended_sleep() const = 0; | 70 | virtual std::chrono::milliseconds recommended_sleep() const = 0; |
624 | 71 | 71 | ||
625 | 72 | virtual bool can_swap_buffers() const = 0; | ||
626 | 73 | |||
627 | 72 | protected: | 74 | protected: |
628 | 73 | DisplayDevice() = default; | 75 | DisplayDevice() = default; |
629 | 74 | DisplayDevice& operator=(DisplayDevice const&) = delete; | 76 | DisplayDevice& operator=(DisplayDevice const&) = delete; |
630 | 75 | 77 | ||
631 | === added file 'src/platforms/android/server/egl_sync_factory.cpp' | |||
632 | --- src/platforms/android/server/egl_sync_factory.cpp 1970-01-01 00:00:00 +0000 | |||
633 | +++ src/platforms/android/server/egl_sync_factory.cpp 2016-01-25 17:04:59 +0000 | |||
634 | @@ -0,0 +1,34 @@ | |||
635 | 1 | /* | ||
636 | 2 | * Copyright © 2015 Canonical Ltd. | ||
637 | 3 | * | ||
638 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
639 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
640 | 6 | * as published by the Free Software Foundation. | ||
641 | 7 | * | ||
642 | 8 | * This program is distributed in the hope that it will be useful, | ||
643 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
644 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
645 | 11 | * GNU Lesser General Public License for more details. | ||
646 | 12 | * | ||
647 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
648 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
649 | 15 | * | ||
650 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | ||
651 | 17 | */ | ||
652 | 18 | |||
653 | 19 | #include "cmdstream_sync_factory.h" | ||
654 | 20 | #include "mir/graphics/egl_sync_fence.h" | ||
655 | 21 | namespace mg = mir::graphics; | ||
656 | 22 | namespace mga = mir::graphics::android; | ||
657 | 23 | |||
658 | 24 | std::unique_ptr<mg::CommandStreamSync> mga::EGLSyncFactory::create_command_stream_sync() | ||
659 | 25 | { | ||
660 | 26 | try | ||
661 | 27 | { | ||
662 | 28 | return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>()); | ||
663 | 29 | } | ||
664 | 30 | catch (std::runtime_error&) | ||
665 | 31 | { | ||
666 | 32 | return std::make_unique<NullCommandSync>(); | ||
667 | 33 | } | ||
668 | 34 | } | ||
669 | 0 | 35 | ||
670 | === modified file 'src/platforms/android/server/fb_device.cpp' | |||
671 | --- src/platforms/android/server/fb_device.cpp 2015-12-11 12:22:15 +0000 | |||
672 | +++ src/platforms/android/server/fb_device.cpp 2016-01-25 17:04:59 +0000 | |||
673 | @@ -99,8 +99,6 @@ | |||
674 | 99 | }); | 99 | }); |
675 | 100 | if (primary_contents == contents.end()) return; | 100 | if (primary_contents == contents.end()) return; |
676 | 101 | auto& context = primary_contents->context; | 101 | auto& context = primary_contents->context; |
677 | 102 | |||
678 | 103 | context.swap_buffers(); | ||
679 | 104 | auto const& buffer = context.last_rendered_buffer(); | 102 | auto const& buffer = context.last_rendered_buffer(); |
680 | 105 | auto native_buffer = buffer->native_buffer_handle(); | 103 | auto native_buffer = buffer->native_buffer_handle(); |
681 | 106 | native_buffer->ensure_available_for(mga::BufferAccess::read); | 104 | native_buffer->ensure_available_for(mga::BufferAccess::read); |
682 | @@ -123,3 +121,8 @@ | |||
683 | 123 | { | 121 | { |
684 | 124 | return std::chrono::milliseconds::zero(); | 122 | return std::chrono::milliseconds::zero(); |
685 | 125 | } | 123 | } |
686 | 124 | |||
687 | 125 | bool mga::FBDevice::can_swap_buffers() const | ||
688 | 126 | { | ||
689 | 127 | return true; | ||
690 | 128 | } | ||
691 | 126 | 129 | ||
692 | === modified file 'src/platforms/android/server/fb_device.h' | |||
693 | --- src/platforms/android/server/fb_device.h 2015-12-11 12:22:15 +0000 | |||
694 | +++ src/platforms/android/server/fb_device.h 2016-01-25 17:04:59 +0000 | |||
695 | @@ -52,6 +52,7 @@ | |||
696 | 52 | bool compatible_renderlist(RenderableList const& renderlist) override; | 52 | bool compatible_renderlist(RenderableList const& renderlist) override; |
697 | 53 | void commit(std::list<DisplayContents> const& contents) override; | 53 | void commit(std::list<DisplayContents> const& contents) override; |
698 | 54 | std::chrono::milliseconds recommended_sleep() const override; | 54 | std::chrono::milliseconds recommended_sleep() const override; |
699 | 55 | bool can_swap_buffers() const override; | ||
700 | 55 | 56 | ||
701 | 56 | private: | 57 | private: |
702 | 57 | std::shared_ptr<framebuffer_device_t> const fb_device; | 58 | std::shared_ptr<framebuffer_device_t> const fb_device; |
703 | 58 | 59 | ||
704 | === modified file 'src/platforms/android/server/hal_component_factory.cpp' | |||
705 | --- src/platforms/android/server/hal_component_factory.cpp 2015-12-11 12:22:15 +0000 | |||
706 | +++ src/platforms/android/server/hal_component_factory.cpp 2016-01-25 17:04:59 +0000 | |||
707 | @@ -46,7 +46,8 @@ | |||
708 | 46 | res_factory(res_factory), | 46 | res_factory(res_factory), |
709 | 47 | hwc_report(hwc_report), | 47 | hwc_report(hwc_report), |
710 | 48 | force_backup_display(false), | 48 | force_backup_display(false), |
712 | 49 | num_framebuffers{quirks->num_framebuffers()} | 49 | num_framebuffers{quirks->num_framebuffers()}, |
713 | 50 | working_egl_sync(quirks->working_egl_sync()) | ||
714 | 50 | { | 51 | { |
715 | 51 | try | 52 | try |
716 | 52 | { | 53 | { |
717 | @@ -65,6 +66,24 @@ | |||
718 | 65 | } | 66 | } |
719 | 66 | } | 67 | } |
720 | 67 | 68 | ||
721 | 69 | std::unique_ptr<mg::CommandStreamSync> mga::HalComponentFactory::create_command_stream_sync() | ||
722 | 70 | { | ||
723 | 71 | if (hwc_version == mga::HwcVersion::hwc10) | ||
724 | 72 | return std::make_unique<NullCommandSync>(); | ||
725 | 73 | |||
726 | 74 | if (!working_egl_sync) | ||
727 | 75 | return std::make_unique<NullCommandSync>(); | ||
728 | 76 | |||
729 | 77 | try | ||
730 | 78 | { | ||
731 | 79 | return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>()); | ||
732 | 80 | } | ||
733 | 81 | catch (std::runtime_error&) | ||
734 | 82 | { | ||
735 | 83 | return std::make_unique<NullCommandSync>(); | ||
736 | 84 | } | ||
737 | 85 | } | ||
738 | 86 | |||
739 | 68 | std::unique_ptr<mga::FramebufferBundle> mga::HalComponentFactory::create_framebuffers(mg::DisplayConfigurationOutput const& config) | 87 | std::unique_ptr<mga::FramebufferBundle> mga::HalComponentFactory::create_framebuffers(mg::DisplayConfigurationOutput const& config) |
740 | 69 | { | 88 | { |
741 | 70 | return std::unique_ptr<mga::FramebufferBundle>(new mga::Framebuffers( | 89 | return std::unique_ptr<mga::FramebufferBundle>(new mga::Framebuffers( |
742 | 71 | 90 | ||
743 | === modified file 'src/platforms/android/server/hal_component_factory.h' | |||
744 | --- src/platforms/android/server/hal_component_factory.h 2015-12-11 12:22:15 +0000 | |||
745 | +++ src/platforms/android/server/hal_component_factory.h 2016-01-25 17:04:59 +0000 | |||
746 | @@ -19,6 +19,7 @@ | |||
747 | 19 | #ifndef MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ | 19 | #ifndef MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ |
748 | 20 | #define MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ | 20 | #define MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ |
749 | 21 | 21 | ||
750 | 22 | #include "cmdstream_sync_factory.h" | ||
751 | 22 | #include "display_component_factory.h" | 23 | #include "display_component_factory.h" |
752 | 23 | #include "display_resource_factory.h" | 24 | #include "display_resource_factory.h" |
753 | 24 | 25 | ||
754 | @@ -39,7 +40,7 @@ | |||
755 | 39 | 40 | ||
756 | 40 | //NOTE: this should be the only class that inspects the HWC version and assembles | 41 | //NOTE: this should be the only class that inspects the HWC version and assembles |
757 | 41 | //the components accordingly | 42 | //the components accordingly |
759 | 42 | class HalComponentFactory : public DisplayComponentFactory | 43 | class HalComponentFactory : public DisplayComponentFactory, public CommandStreamSyncFactory |
760 | 43 | { | 44 | { |
761 | 44 | public: | 45 | public: |
762 | 45 | HalComponentFactory( | 46 | HalComponentFactory( |
763 | @@ -48,6 +49,7 @@ | |||
764 | 48 | std::shared_ptr<HwcReport> const& hwc_report, | 49 | std::shared_ptr<HwcReport> const& hwc_report, |
765 | 49 | std::shared_ptr<DeviceQuirks> const& quirks); | 50 | std::shared_ptr<DeviceQuirks> const& quirks); |
766 | 50 | 51 | ||
767 | 52 | std::unique_ptr<CommandStreamSync> create_command_stream_sync() override; | ||
768 | 51 | std::unique_ptr<FramebufferBundle> create_framebuffers(DisplayConfigurationOutput const&) override; | 53 | std::unique_ptr<FramebufferBundle> create_framebuffers(DisplayConfigurationOutput const&) override; |
769 | 52 | std::unique_ptr<DisplayDevice> create_display_device() override; | 54 | std::unique_ptr<DisplayDevice> create_display_device() override; |
770 | 53 | std::unique_ptr<HwcConfiguration> create_hwc_configuration() override; | 55 | std::unique_ptr<HwcConfiguration> create_hwc_configuration() override; |
771 | @@ -61,6 +63,7 @@ | |||
772 | 61 | std::shared_ptr<FramebufferBundle> framebuffers; | 63 | std::shared_ptr<FramebufferBundle> framebuffers; |
773 | 62 | bool force_backup_display; | 64 | bool force_backup_display; |
774 | 63 | size_t num_framebuffers; | 65 | size_t num_framebuffers; |
775 | 66 | bool working_egl_sync; | ||
776 | 64 | 67 | ||
777 | 65 | std::shared_ptr<HwcWrapper> hwc_wrapper; | 68 | std::shared_ptr<HwcWrapper> hwc_wrapper; |
778 | 66 | std::shared_ptr<framebuffer_device_t> fb_native; | 69 | std::shared_ptr<framebuffer_device_t> fb_native; |
779 | 67 | 70 | ||
780 | === modified file 'src/platforms/android/server/hwc_device.cpp' | |||
781 | --- src/platforms/android/server/hwc_device.cpp 2015-12-11 12:22:15 +0000 | |||
782 | +++ src/platforms/android/server/hwc_device.cpp 2016-01-25 17:04:59 +0000 | |||
783 | @@ -106,13 +106,13 @@ | |||
784 | 106 | if (content.list.needs_swapbuffers()) | 106 | if (content.list.needs_swapbuffers()) |
785 | 107 | { | 107 | { |
786 | 108 | auto rejected_renderables = content.list.rejected_renderables(); | 108 | auto rejected_renderables = content.list.rejected_renderables(); |
793 | 109 | auto current_context = mir::raii::paired_calls( | 109 | if (!rejected_renderables.empty()) |
794 | 110 | [&]{ content.context.make_current(); }, | 110 | { |
795 | 111 | [&]{ content.context.release_current(); }); | 111 | auto current_context = mir::raii::paired_calls( |
796 | 112 | if (rejected_renderables.empty()) | 112 | [&]{ content.context.make_current(); }, |
797 | 113 | content.context.swap_buffers(); | 113 | [&]{ content.context.release_current(); }); |
792 | 114 | else | ||
798 | 115 | content.compositor.render(std::move(rejected_renderables), content.list_offset, content.context); | 114 | content.compositor.render(std::move(rejected_renderables), content.list_offset, content.context); |
799 | 115 | } | ||
800 | 116 | content.list.setup_fb(content.context.last_rendered_buffer()); | 116 | content.list.setup_fb(content.context.last_rendered_buffer()); |
801 | 117 | content.list.swap_occurred(); | 117 | content.list.swap_occurred(); |
802 | 118 | purely_overlays = false; | 118 | purely_overlays = false; |
803 | @@ -161,3 +161,8 @@ | |||
804 | 161 | { | 161 | { |
805 | 162 | onscreen_overlay_buffers.clear(); | 162 | onscreen_overlay_buffers.clear(); |
806 | 163 | } | 163 | } |
807 | 164 | |||
808 | 165 | bool mga::HwcDevice::can_swap_buffers() const | ||
809 | 166 | { | ||
810 | 167 | return true; | ||
811 | 168 | } | ||
812 | 164 | 169 | ||
813 | === modified file 'src/platforms/android/server/hwc_device.h' | |||
814 | --- src/platforms/android/server/hwc_device.h 2015-12-11 12:22:15 +0000 | |||
815 | +++ src/platforms/android/server/hwc_device.h 2016-01-25 17:04:59 +0000 | |||
816 | @@ -47,6 +47,7 @@ | |||
817 | 47 | void commit(std::list<DisplayContents> const& contents) override; | 47 | void commit(std::list<DisplayContents> const& contents) override; |
818 | 48 | void content_cleared() override; | 48 | void content_cleared() override; |
819 | 49 | std::chrono::milliseconds recommended_sleep() const override; | 49 | std::chrono::milliseconds recommended_sleep() const override; |
820 | 50 | bool can_swap_buffers() const override; | ||
821 | 50 | 51 | ||
822 | 51 | private: | 52 | private: |
823 | 52 | bool buffer_is_onscreen(Buffer const&) const; | 53 | bool buffer_is_onscreen(Buffer const&) const; |
824 | 53 | 54 | ||
825 | === modified file 'src/platforms/android/server/hwc_fb_device.cpp' | |||
826 | --- src/platforms/android/server/hwc_fb_device.cpp 2015-12-11 12:22:15 +0000 | |||
827 | +++ src/platforms/android/server/hwc_fb_device.cpp 2016-01-25 17:04:59 +0000 | |||
828 | @@ -118,3 +118,8 @@ | |||
829 | 118 | { | 118 | { |
830 | 119 | return std::chrono::milliseconds::zero(); | 119 | return std::chrono::milliseconds::zero(); |
831 | 120 | } | 120 | } |
832 | 121 | |||
833 | 122 | bool mga::HwcFbDevice::can_swap_buffers() const | ||
834 | 123 | { | ||
835 | 124 | return false; | ||
836 | 125 | } | ||
837 | 121 | 126 | ||
838 | === modified file 'src/platforms/android/server/hwc_fb_device.h' | |||
839 | --- src/platforms/android/server/hwc_fb_device.h 2015-12-11 12:22:15 +0000 | |||
840 | +++ src/platforms/android/server/hwc_fb_device.h 2016-01-25 17:04:59 +0000 | |||
841 | @@ -44,6 +44,7 @@ | |||
842 | 44 | bool compatible_renderlist(RenderableList const& renderlist) override; | 44 | bool compatible_renderlist(RenderableList const& renderlist) override; |
843 | 45 | void commit(std::list<DisplayContents> const& contents) override; | 45 | void commit(std::list<DisplayContents> const& contents) override; |
844 | 46 | std::chrono::milliseconds recommended_sleep() const override; | 46 | std::chrono::milliseconds recommended_sleep() const override; |
845 | 47 | bool can_swap_buffers() const override; | ||
846 | 47 | 48 | ||
847 | 48 | private: | 49 | private: |
848 | 49 | void content_cleared() override; | 50 | void content_cleared() override; |
849 | 50 | 51 | ||
850 | === modified file 'src/platforms/android/server/ipc_operations.cpp' | |||
851 | --- src/platforms/android/server/ipc_operations.cpp 2015-12-11 12:22:15 +0000 | |||
852 | +++ src/platforms/android/server/ipc_operations.cpp 2016-01-25 17:04:59 +0000 | |||
853 | @@ -32,6 +32,7 @@ | |||
854 | 32 | { | 32 | { |
855 | 33 | auto native_buffer = buffer.native_buffer_handle(); | 33 | auto native_buffer = buffer.native_buffer_handle(); |
856 | 34 | 34 | ||
857 | 35 | native_buffer->wait_for_unlock_by_gpu(); | ||
858 | 35 | mir::Fd fence_fd(native_buffer->copy_fence()); | 36 | mir::Fd fence_fd(native_buffer->copy_fence()); |
859 | 36 | if (fence_fd != mir::Fd::invalid) | 37 | if (fence_fd != mir::Fd::invalid) |
860 | 37 | { | 38 | { |
861 | 38 | 39 | ||
862 | === modified file 'src/platforms/android/server/platform.cpp' | |||
863 | --- src/platforms/android/server/platform.cpp 2015-12-11 12:22:15 +0000 | |||
864 | +++ src/platforms/android/server/platform.cpp 2016-01-25 17:04:59 +0000 | |||
865 | @@ -85,11 +85,13 @@ | |||
866 | 85 | mga::Platform::Platform( | 85 | mga::Platform::Platform( |
867 | 86 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, | 86 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
868 | 87 | std::shared_ptr<mga::DisplayComponentFactory> const& display_buffer_builder, | 87 | std::shared_ptr<mga::DisplayComponentFactory> const& display_buffer_builder, |
869 | 88 | std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, | ||
870 | 88 | std::shared_ptr<mg::DisplayReport> const& display_report, | 89 | std::shared_ptr<mg::DisplayReport> const& display_report, |
871 | 89 | mga::OverlayOptimization overlay_option, | 90 | mga::OverlayOptimization overlay_option, |
872 | 90 | std::shared_ptr<mga::DeviceQuirks> const& quirks) : | 91 | std::shared_ptr<mga::DeviceQuirks> const& quirks) : |
873 | 91 | buffer_allocator(buffer_allocator), | 92 | buffer_allocator(buffer_allocator), |
874 | 92 | display_buffer_builder(display_buffer_builder), | 93 | display_buffer_builder(display_buffer_builder), |
875 | 94 | sync_factory(sync_factory), | ||
876 | 93 | display_report(display_report), | 95 | display_report(display_report), |
877 | 94 | quirks(quirks), | 96 | quirks(quirks), |
878 | 95 | overlay_option(overlay_option) | 97 | overlay_option(overlay_option) |
879 | @@ -153,10 +155,13 @@ | |||
880 | 153 | auto overlay_option = should_use_overlay_optimization(*options); | 155 | auto overlay_option = should_use_overlay_optimization(*options); |
881 | 154 | hwc_report->report_overlay_optimization(overlay_option); | 156 | hwc_report->report_overlay_optimization(overlay_option); |
882 | 155 | auto display_resource_factory = std::make_shared<mga::ResourceFactory>(); | 157 | auto display_resource_factory = std::make_shared<mga::ResourceFactory>(); |
884 | 156 | auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks); | 158 | auto sync_factory = std::make_shared<mga::EGLSyncFactory>(); |
885 | 159 | auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks); | ||
886 | 157 | auto component_factory = std::make_shared<mga::HalComponentFactory>( | 160 | auto component_factory = std::make_shared<mga::HalComponentFactory>( |
887 | 158 | buffer_allocator, display_resource_factory, hwc_report, quirks); | 161 | buffer_allocator, display_resource_factory, hwc_report, quirks); |
889 | 159 | return mir::make_module_ptr<mga::Platform>(buffer_allocator, component_factory, display_report, overlay_option, quirks); | 162 | |
890 | 163 | return mir::make_module_ptr<mga::Platform>( | ||
891 | 164 | buffer_allocator, component_factory, component_factory, display_report, overlay_option, quirks); | ||
892 | 160 | } | 165 | } |
893 | 161 | 166 | ||
894 | 162 | mir::UniqueModulePtr<mg::Platform> create_guest_platform( | 167 | mir::UniqueModulePtr<mg::Platform> create_guest_platform( |
895 | @@ -166,10 +171,11 @@ | |||
896 | 166 | mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform); | 171 | mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform); |
897 | 167 | //TODO: actually allow disabling quirks for guest platform | 172 | //TODO: actually allow disabling quirks for guest platform |
898 | 168 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); | 173 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
899 | 174 | auto sync_factory = std::make_shared<mga::EGLSyncFactory>(); | ||
900 | 169 | //TODO: remove nullptr parameter once platform classes are sorted. | 175 | //TODO: remove nullptr parameter once platform classes are sorted. |
901 | 170 | // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder | 176 | // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder |
904 | 171 | auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks); | 177 | auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks); |
905 | 172 | return mir::make_module_ptr<mga::Platform>(buffer_allocator, nullptr, display_report, mga::OverlayOptimization::disabled, quirks); | 178 | return mir::make_module_ptr<mga::Platform>(buffer_allocator, nullptr, sync_factory, display_report, mga::OverlayOptimization::disabled, quirks); |
906 | 173 | } | 179 | } |
907 | 174 | 180 | ||
908 | 175 | void add_graphics_platform_options( | 181 | void add_graphics_platform_options( |
909 | 176 | 182 | ||
910 | === modified file 'src/platforms/android/server/platform.h' | |||
911 | --- src/platforms/android/server/platform.h 2015-12-11 12:22:15 +0000 | |||
912 | +++ src/platforms/android/server/platform.h 2016-01-25 17:04:59 +0000 | |||
913 | @@ -33,6 +33,7 @@ | |||
914 | 33 | class GraphicBufferAllocator; | 33 | class GraphicBufferAllocator; |
915 | 34 | class FramebufferFactory; | 34 | class FramebufferFactory; |
916 | 35 | class DisplayComponentFactory; | 35 | class DisplayComponentFactory; |
917 | 36 | class CommandStreamSyncFactory; | ||
918 | 36 | 37 | ||
919 | 37 | class Platform : public graphics::Platform | 38 | class Platform : public graphics::Platform |
920 | 38 | { | 39 | { |
921 | @@ -40,6 +41,7 @@ | |||
922 | 40 | Platform( | 41 | Platform( |
923 | 41 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, | 42 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
924 | 42 | std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder, | 43 | std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder, |
925 | 44 | std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, | ||
926 | 43 | std::shared_ptr<DisplayReport> const& display_report, | 45 | std::shared_ptr<DisplayReport> const& display_report, |
927 | 44 | OverlayOptimization overlay_option, | 46 | OverlayOptimization overlay_option, |
928 | 45 | std::shared_ptr<DeviceQuirks> const& quirks); | 47 | std::shared_ptr<DeviceQuirks> const& quirks); |
929 | @@ -55,6 +57,7 @@ | |||
930 | 55 | private: | 57 | private: |
931 | 56 | std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator; | 58 | std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator; |
932 | 57 | std::shared_ptr<DisplayComponentFactory> const display_buffer_builder; | 59 | std::shared_ptr<DisplayComponentFactory> const display_buffer_builder; |
933 | 60 | std::shared_ptr<CommandStreamSyncFactory> const sync_factory; | ||
934 | 58 | std::shared_ptr<DisplayReport> const display_report; | 61 | std::shared_ptr<DisplayReport> const display_report; |
935 | 59 | std::shared_ptr<PlatformIpcOperations> const ipc_operations; | 62 | std::shared_ptr<PlatformIpcOperations> const ipc_operations; |
936 | 60 | std::shared_ptr<DeviceQuirks> const quirks; | 63 | std::shared_ptr<DeviceQuirks> const quirks; |
937 | 61 | 64 | ||
938 | === modified file 'src/platforms/mesa/server/common/gbm_buffer.cpp' | |||
939 | --- src/platforms/mesa/server/common/gbm_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
940 | +++ src/platforms/mesa/server/common/gbm_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
941 | @@ -197,3 +197,12 @@ | |||
942 | 197 | { | 197 | { |
943 | 198 | return this; | 198 | return this; |
944 | 199 | } | 199 | } |
945 | 200 | |||
946 | 201 | void mgm::GBMBuffer::secure_for_render() | ||
947 | 202 | { | ||
948 | 203 | } | ||
949 | 204 | |||
950 | 205 | void mgm::GBMBuffer::bind() | ||
951 | 206 | { | ||
952 | 207 | gl_bind_to_texture(); | ||
953 | 208 | } | ||
954 | 200 | 209 | ||
955 | === modified file 'src/platforms/mesa/server/common/gbm_buffer.h' | |||
956 | --- src/platforms/mesa/server/common/gbm_buffer.h 2015-12-11 12:22:15 +0000 | |||
957 | +++ src/platforms/mesa/server/common/gbm_buffer.h 2016-01-25 17:04:59 +0000 | |||
958 | @@ -67,6 +67,8 @@ | |||
959 | 67 | virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; | 67 | virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; |
960 | 68 | 68 | ||
961 | 69 | virtual void gl_bind_to_texture() override; | 69 | virtual void gl_bind_to_texture() override; |
962 | 70 | virtual void bind() override; | ||
963 | 71 | virtual void secure_for_render() override; | ||
964 | 70 | 72 | ||
965 | 71 | void write(unsigned char const* pixels, size_t size) override; | 73 | void write(unsigned char const* pixels, size_t size) override; |
966 | 72 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; | 74 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; |
967 | 73 | 75 | ||
968 | === modified file 'src/platforms/mesa/server/common/shm_buffer.cpp' | |||
969 | --- src/platforms/mesa/server/common/shm_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
970 | +++ src/platforms/mesa/server/common/shm_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
971 | @@ -176,3 +176,12 @@ | |||
972 | 176 | { | 176 | { |
973 | 177 | return this; | 177 | return this; |
974 | 178 | } | 178 | } |
975 | 179 | |||
976 | 180 | void mgm::ShmBuffer::bind() | ||
977 | 181 | { | ||
978 | 182 | gl_bind_to_texture(); | ||
979 | 183 | } | ||
980 | 184 | |||
981 | 185 | void mgm::ShmBuffer::secure_for_render() | ||
982 | 186 | { | ||
983 | 187 | } | ||
984 | 179 | 188 | ||
985 | === modified file 'src/platforms/mesa/server/common/shm_buffer.h' | |||
986 | --- src/platforms/mesa/server/common/shm_buffer.h 2015-12-11 12:22:15 +0000 | |||
987 | +++ src/platforms/mesa/server/common/shm_buffer.h 2016-01-25 17:04:59 +0000 | |||
988 | @@ -51,6 +51,8 @@ | |||
989 | 51 | MirPixelFormat pixel_format() const override; | 51 | MirPixelFormat pixel_format() const override; |
990 | 52 | std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; | 52 | std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; |
991 | 53 | void gl_bind_to_texture() override; | 53 | void gl_bind_to_texture() override; |
992 | 54 | void bind() override; | ||
993 | 55 | void secure_for_render() override; | ||
994 | 54 | void write(unsigned char const* data, size_t size) override; | 56 | void write(unsigned char const* data, size_t size) override; |
995 | 55 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; | 57 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; |
996 | 56 | NativeBufferBase* native_buffer_base() override; | 58 | NativeBufferBase* native_buffer_base() override; |
997 | 57 | 59 | ||
998 | === modified file 'tests/include/mir/test/doubles/mock_android_native_buffer.h' | |||
999 | --- tests/include/mir/test/doubles/mock_android_native_buffer.h 2015-12-11 12:22:15 +0000 | |||
1000 | +++ tests/include/mir/test/doubles/mock_android_native_buffer.h 2016-01-25 17:04:59 +0000 | |||
1001 | @@ -57,6 +57,8 @@ | |||
1002 | 57 | MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess)); | 57 | MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess)); |
1003 | 58 | MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess)); | 58 | MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess)); |
1004 | 59 | 59 | ||
1005 | 60 | MOCK_METHOD0(lock_for_gpu, void()); | ||
1006 | 61 | MOCK_METHOD0(wait_for_unlock_by_gpu, void()); | ||
1007 | 60 | ANativeWindowBuffer stub_anwb; | 62 | ANativeWindowBuffer stub_anwb; |
1008 | 61 | native_handle_t native_handle; | 63 | native_handle_t native_handle; |
1009 | 62 | }; | 64 | }; |
1010 | 63 | 65 | ||
1011 | === modified file 'tests/include/mir/test/doubles/mock_buffer.h' | |||
1012 | --- tests/include/mir/test/doubles/mock_buffer.h 2015-12-11 12:22:15 +0000 | |||
1013 | +++ tests/include/mir/test/doubles/mock_buffer.h 2016-01-25 17:04:59 +0000 | |||
1014 | @@ -72,6 +72,7 @@ | |||
1015 | 72 | MOCK_METHOD2(write, void(unsigned char const*, size_t)); | 72 | MOCK_METHOD2(write, void(unsigned char const*, size_t)); |
1016 | 73 | MOCK_METHOD1(read, void(std::function<void(unsigned char const*)> const&)); | 73 | MOCK_METHOD1(read, void(std::function<void(unsigned char const*)> const&)); |
1017 | 74 | MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*()); | 74 | MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*()); |
1018 | 75 | MOCK_METHOD0(used_as_texture, void()); | ||
1019 | 75 | }; | 76 | }; |
1020 | 76 | 77 | ||
1021 | 77 | } | 78 | } |
1022 | 78 | 79 | ||
1023 | === modified file 'tests/include/mir/test/doubles/mock_display_device.h' | |||
1024 | --- tests/include/mir/test/doubles/mock_display_device.h 2015-12-11 12:22:15 +0000 | |||
1025 | +++ tests/include/mir/test/doubles/mock_display_device.h 2016-01-25 17:04:59 +0000 | |||
1026 | @@ -39,6 +39,8 @@ | |||
1027 | 39 | { | 39 | { |
1028 | 40 | ON_CALL(*this, compatible_renderlist(testing::_)) | 40 | ON_CALL(*this, compatible_renderlist(testing::_)) |
1029 | 41 | .WillByDefault(testing::Return(true)); | 41 | .WillByDefault(testing::Return(true)); |
1030 | 42 | ON_CALL(*this, can_swap_buffers()) | ||
1031 | 43 | .WillByDefault(testing::Return(true)); | ||
1032 | 42 | } | 44 | } |
1033 | 43 | ~MockDisplayDevice() noexcept {} | 45 | ~MockDisplayDevice() noexcept {} |
1034 | 44 | MOCK_METHOD0(content_cleared, void()); | 46 | MOCK_METHOD0(content_cleared, void()); |
1035 | @@ -46,6 +48,7 @@ | |||
1036 | 46 | MOCK_METHOD1(compatible_renderlist, bool( | 48 | MOCK_METHOD1(compatible_renderlist, bool( |
1037 | 47 | graphics::RenderableList const&)); | 49 | graphics::RenderableList const&)); |
1038 | 48 | MOCK_CONST_METHOD0(recommended_sleep, std::chrono::milliseconds()); | 50 | MOCK_CONST_METHOD0(recommended_sleep, std::chrono::milliseconds()); |
1039 | 51 | MOCK_CONST_METHOD0(can_swap_buffers, bool()); | ||
1040 | 49 | }; | 52 | }; |
1041 | 50 | } | 53 | } |
1042 | 51 | } | 54 | } |
1043 | 52 | 55 | ||
1044 | === modified file 'tests/include/mir/test/doubles/mock_gl_buffer.h' | |||
1045 | --- tests/include/mir/test/doubles/mock_gl_buffer.h 2015-12-11 12:22:15 +0000 | |||
1046 | +++ tests/include/mir/test/doubles/mock_gl_buffer.h 2016-01-25 17:04:59 +0000 | |||
1047 | @@ -36,6 +36,8 @@ | |||
1048 | 36 | using MockBuffer::MockBuffer; | 36 | using MockBuffer::MockBuffer; |
1049 | 37 | 37 | ||
1050 | 38 | MOCK_METHOD0(gl_bind_to_texture, void()); | 38 | MOCK_METHOD0(gl_bind_to_texture, void()); |
1051 | 39 | MOCK_METHOD0(secure_for_render, void()); | ||
1052 | 40 | MOCK_METHOD0(bind, void()); | ||
1053 | 39 | }; | 41 | }; |
1054 | 40 | 42 | ||
1055 | 41 | } | 43 | } |
1056 | 42 | 44 | ||
1057 | === modified file 'tests/include/mir/test/doubles/stub_android_native_buffer.h' | |||
1058 | --- tests/include/mir/test/doubles/stub_android_native_buffer.h 2015-12-11 12:22:15 +0000 | |||
1059 | +++ tests/include/mir/test/doubles/stub_android_native_buffer.h 2016-01-25 17:04:59 +0000 | |||
1060 | @@ -47,6 +47,9 @@ | |||
1061 | 47 | void ensure_available_for(graphics::android::BufferAccess) {} | 47 | void ensure_available_for(graphics::android::BufferAccess) {} |
1062 | 48 | void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {} | 48 | void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {} |
1063 | 49 | 49 | ||
1064 | 50 | void lock_for_gpu() {}; | ||
1065 | 51 | void wait_for_unlock_by_gpu() {}; | ||
1066 | 52 | |||
1067 | 50 | ANativeWindowBuffer stub_anwb; | 53 | ANativeWindowBuffer stub_anwb; |
1068 | 51 | native_handle_t native_handle; | 54 | native_handle_t native_handle; |
1069 | 52 | }; | 55 | }; |
1070 | 53 | 56 | ||
1071 | === added file 'tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h' | |||
1072 | --- tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000 | |||
1073 | +++ tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000 | |||
1074 | @@ -0,0 +1,41 @@ | |||
1075 | 1 | /* | ||
1076 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1077 | 3 | * | ||
1078 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1079 | 5 | * under the terms of the GNU General Public License version 3, | ||
1080 | 6 | * as published by the Free Software Foundation. | ||
1081 | 7 | * | ||
1082 | 8 | * This program is distributed in the hope that it will be useful, | ||
1083 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1084 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1085 | 11 | * GNU General Public License for more details. | ||
1086 | 12 | * | ||
1087 | 13 | * You should have received a copy of the GNU General Public License | ||
1088 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1089 | 15 | * | ||
1090 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | ||
1091 | 17 | */ | ||
1092 | 18 | |||
1093 | 19 | #ifndef MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ | ||
1094 | 20 | #define MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ | ||
1095 | 21 | |||
1096 | 22 | #include "src/platforms/android/server/cmdstream_sync_factory.h" | ||
1097 | 23 | |||
1098 | 24 | namespace mir | ||
1099 | 25 | { | ||
1100 | 26 | namespace test | ||
1101 | 27 | { | ||
1102 | 28 | namespace doubles | ||
1103 | 29 | { | ||
1104 | 30 | struct StubCmdStreamSyncFactory : graphics::android::CommandStreamSyncFactory | ||
1105 | 31 | { | ||
1106 | 32 | std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync() override | ||
1107 | 33 | { | ||
1108 | 34 | return std::make_unique<graphics::NullCommandSync>(); | ||
1109 | 35 | } | ||
1110 | 36 | }; | ||
1111 | 37 | } | ||
1112 | 38 | } | ||
1113 | 39 | } | ||
1114 | 40 | |||
1115 | 41 | #endif /* MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ */ | ||
1116 | 0 | 42 | ||
1117 | === modified file 'tests/include/mir/test/doubles/stub_display_builder.h' | |||
1118 | --- tests/include/mir/test/doubles/stub_display_builder.h 2015-12-11 12:22:15 +0000 | |||
1119 | +++ tests/include/mir/test/doubles/stub_display_builder.h 2016-01-25 17:04:59 +0000 | |||
1120 | @@ -126,6 +126,11 @@ | |||
1121 | 126 | config = std::move(mock_config); | 126 | config = std::move(mock_config); |
1122 | 127 | } | 127 | } |
1123 | 128 | 128 | ||
1124 | 129 | std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync() | ||
1125 | 130 | { | ||
1126 | 131 | return std::make_unique<graphics::NullCommandSync>(); | ||
1127 | 132 | } | ||
1128 | 133 | |||
1129 | 129 | geometry::Size sz; | 134 | geometry::Size sz; |
1130 | 130 | std::unique_ptr<graphics::android::HwcConfiguration> config; | 135 | std::unique_ptr<graphics::android::HwcConfiguration> config; |
1131 | 131 | }; | 136 | }; |
1132 | 132 | 137 | ||
1133 | === modified file 'tests/include/mir/test/doubles/stub_gl_buffer.h' | |||
1134 | --- tests/include/mir/test/doubles/stub_gl_buffer.h 2015-12-11 12:22:15 +0000 | |||
1135 | +++ tests/include/mir/test/doubles/stub_gl_buffer.h 2016-01-25 17:04:59 +0000 | |||
1136 | @@ -36,6 +36,8 @@ | |||
1137 | 36 | using StubBuffer::StubBuffer; | 36 | using StubBuffer::StubBuffer; |
1138 | 37 | 37 | ||
1139 | 38 | void gl_bind_to_texture() {} | 38 | void gl_bind_to_texture() {} |
1140 | 39 | void bind() {} | ||
1141 | 40 | void secure_for_render() {} | ||
1142 | 39 | }; | 41 | }; |
1143 | 40 | 42 | ||
1144 | 41 | } | 43 | } |
1145 | 42 | 44 | ||
1146 | === modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp' | |||
1147 | --- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2015-12-11 12:22:15 +0000 | |||
1148 | +++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2016-01-25 17:04:59 +0000 | |||
1149 | @@ -77,6 +77,9 @@ | |||
1150 | 77 | } | 77 | } |
1151 | 78 | } | 78 | } |
1152 | 79 | 79 | ||
1153 | 80 | void bind() override { gl_bind_to_texture(); } | ||
1154 | 81 | void secure_for_render() override {} | ||
1155 | 82 | |||
1156 | 80 | private: | 83 | private: |
1157 | 81 | std::thread::id creation_thread_id; | 84 | std::thread::id creation_thread_id; |
1158 | 82 | }; | 85 | }; |
1159 | 83 | 86 | ||
1160 | === modified file 'tests/unit-tests/gl/test_gl_texture_cache.cpp' | |||
1161 | --- tests/unit-tests/gl/test_gl_texture_cache.cpp 2015-12-11 12:22:15 +0000 | |||
1162 | +++ tests/unit-tests/gl/test_gl_texture_cache.cpp 2016-01-25 17:04:59 +0000 | |||
1163 | @@ -17,7 +17,7 @@ | |||
1164 | 17 | * Originally by: Daniel van Vugt <daniel.van.vugt@canonical.com> | 17 | * Originally by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1165 | 18 | */ | 18 | */ |
1166 | 19 | 19 | ||
1168 | 20 | #include "mir/gl/recently_used_cache.h" | 20 | #include "src/gl/recently_used_cache.h" |
1169 | 21 | #include "mir/test/doubles/mock_gl_buffer.h" | 21 | #include "mir/test/doubles/mock_gl_buffer.h" |
1170 | 22 | #include "mir/test/doubles/mock_renderable.h" | 22 | #include "mir/test/doubles/mock_renderable.h" |
1171 | 23 | #include "mir/test/doubles/mock_gl.h" | 23 | #include "mir/test/doubles/mock_gl.h" |
1172 | @@ -75,6 +75,7 @@ | |||
1173 | 75 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); | 75 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); |
1174 | 76 | EXPECT_CALL(*mock_buffer,gl_bind_to_texture()) | 76 | EXPECT_CALL(*mock_buffer,gl_bind_to_texture()) |
1175 | 77 | .Times(0); | 77 | .Times(0); |
1176 | 78 | EXPECT_CALL(*mock_buffer, used_as_texture()); | ||
1177 | 78 | 79 | ||
1178 | 79 | // Frame 3: Texture found in cache but refreshed with new buffer | 80 | // Frame 3: Texture found in cache but refreshed with new buffer |
1179 | 80 | EXPECT_CALL(*mock_buffer, id()) | 81 | EXPECT_CALL(*mock_buffer, id()) |
1180 | @@ -92,6 +93,7 @@ | |||
1181 | 92 | EXPECT_CALL(*mock_buffer, id()) | 93 | EXPECT_CALL(*mock_buffer, id()) |
1182 | 93 | .WillOnce(Return(mg::BufferID(456))); | 94 | .WillOnce(Return(mg::BufferID(456))); |
1183 | 94 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); | 95 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); |
1184 | 96 | EXPECT_CALL(*mock_buffer, used_as_texture()); | ||
1185 | 95 | 97 | ||
1186 | 96 | EXPECT_CALL(mock_gl, glDeleteTextures(1, Pointee(stub_texture))); | 98 | EXPECT_CALL(mock_gl, glDeleteTextures(1, Pointee(stub_texture))); |
1187 | 97 | 99 | ||
1188 | 98 | 100 | ||
1189 | === modified file 'tests/unit-tests/gl/test_program_factory.cpp' | |||
1190 | --- tests/unit-tests/gl/test_program_factory.cpp 2015-12-11 12:22:15 +0000 | |||
1191 | +++ tests/unit-tests/gl/test_program_factory.cpp 2016-01-25 17:04:59 +0000 | |||
1192 | @@ -24,7 +24,7 @@ | |||
1193 | 24 | #include <gtest/gtest.h> | 24 | #include <gtest/gtest.h> |
1194 | 25 | #include <gmock/gmock.h> | 25 | #include <gmock/gmock.h> |
1195 | 26 | #include <mir/geometry/rectangle.h> | 26 | #include <mir/geometry/rectangle.h> |
1197 | 27 | #include "src/gl/default_program_factory.h" | 27 | #include "mir/gl/default_program_factory.h" |
1198 | 28 | #include <mir/test/fake_shared.h> | 28 | #include <mir/test/fake_shared.h> |
1199 | 29 | #include <mir/test/doubles/mock_buffer.h> | 29 | #include <mir/test/doubles/mock_buffer.h> |
1200 | 30 | #include <mir/test/doubles/mock_renderable.h> | 30 | #include <mir/test/doubles/mock_renderable.h> |
1201 | 31 | 31 | ||
1202 | === modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp' | |||
1203 | --- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000 | |||
1204 | +++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000 | |||
1205 | @@ -17,11 +17,13 @@ | |||
1206 | 17 | */ | 17 | */ |
1207 | 18 | 18 | ||
1208 | 19 | #include "src/platforms/android/server/android_alloc_adaptor.h" | 19 | #include "src/platforms/android/server/android_alloc_adaptor.h" |
1209 | 20 | #include "src/platforms/android/server/cmdstream_sync_factory.h" | ||
1210 | 20 | #include "src/platforms/android/server/device_quirks.h" | 21 | #include "src/platforms/android/server/device_quirks.h" |
1211 | 21 | #include "mir/graphics/android/native_buffer.h" | 22 | #include "mir/graphics/android/native_buffer.h" |
1212 | 22 | 23 | ||
1213 | 23 | #include "mir/test/doubles/mock_android_alloc_device.h" | 24 | #include "mir/test/doubles/mock_android_alloc_device.h" |
1214 | 24 | #include "mir/test/doubles/mock_alloc_adaptor.h" | 25 | #include "mir/test/doubles/mock_alloc_adaptor.h" |
1215 | 26 | #include "mir/test/doubles/mock_egl.h" | ||
1216 | 25 | 27 | ||
1217 | 26 | #include <gtest/gtest.h> | 28 | #include <gtest/gtest.h> |
1218 | 27 | #include <gmock/gmock.h> | 29 | #include <gmock/gmock.h> |
1219 | @@ -32,7 +34,6 @@ | |||
1220 | 32 | namespace geom = mir::geometry; | 34 | namespace geom = mir::geometry; |
1221 | 33 | namespace mtd = mir::test::doubles; | 35 | namespace mtd = mir::test::doubles; |
1222 | 34 | 36 | ||
1223 | 35 | |||
1224 | 36 | class AdaptorICSTest : public ::testing::Test | 37 | class AdaptorICSTest : public ::testing::Test |
1225 | 37 | { | 38 | { |
1226 | 38 | public: | 39 | public: |
1227 | @@ -48,13 +49,15 @@ | |||
1228 | 48 | mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocDevice>>(); | 49 | mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocDevice>>(); |
1229 | 49 | 50 | ||
1230 | 50 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); | 51 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
1232 | 51 | alloc_adaptor = std::make_shared<mga::AndroidAllocAdaptor>(mock_alloc_device, quirks); | 52 | alloc_adaptor = std::make_shared<mga::AndroidAllocAdaptor>(mock_alloc_device, sync_factory, quirks); |
1233 | 52 | 53 | ||
1234 | 53 | pf = mir_pixel_format_abgr_8888; | 54 | pf = mir_pixel_format_abgr_8888; |
1235 | 54 | size = geom::Size{300, 200}; | 55 | size = geom::Size{300, 200}; |
1236 | 55 | usage = mga::BufferUsage::use_hardware; | 56 | usage = mga::BufferUsage::use_hardware; |
1237 | 56 | } | 57 | } |
1238 | 57 | 58 | ||
1239 | 59 | mtd::MockEGL mock_egl; | ||
1240 | 60 | std::shared_ptr<mga::CommandStreamSyncFactory> sync_factory{std::make_shared<mga::EGLSyncFactory>()}; | ||
1241 | 58 | std::shared_ptr<mtd::MockAllocDevice> mock_alloc_device; | 61 | std::shared_ptr<mtd::MockAllocDevice> mock_alloc_device; |
1242 | 59 | std::shared_ptr<mga::AndroidAllocAdaptor> alloc_adaptor; | 62 | std::shared_ptr<mga::AndroidAllocAdaptor> alloc_adaptor; |
1243 | 60 | 63 | ||
1244 | 61 | 64 | ||
1245 | === modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp' | |||
1246 | --- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000 | |||
1247 | +++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000 | |||
1248 | @@ -23,6 +23,8 @@ | |||
1249 | 23 | #include "mir/graphics/buffer.h" | 23 | #include "mir/graphics/buffer.h" |
1250 | 24 | #include "mir/graphics/android/native_buffer.h" | 24 | #include "mir/graphics/android/native_buffer.h" |
1251 | 25 | 25 | ||
1252 | 26 | #include "mir/test/doubles/stub_display_builder.h" | ||
1253 | 27 | #include "mir/test/doubles/stub_cmdstream_sync_factory.h" | ||
1254 | 26 | #include "mir/test/doubles/mock_egl.h" | 28 | #include "mir/test/doubles/mock_egl.h" |
1255 | 27 | 29 | ||
1256 | 28 | #include <hardware/gralloc.h> | 30 | #include <hardware/gralloc.h> |
1257 | @@ -43,7 +45,9 @@ | |||
1258 | 43 | 45 | ||
1259 | 44 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; | 46 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; |
1260 | 45 | testing::NiceMock<mtd::MockEGL> mock_egl; | 47 | testing::NiceMock<mtd::MockEGL> mock_egl; |
1262 | 46 | mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})}; | 48 | mga::AndroidGraphicBufferAllocator allocator{ |
1263 | 49 | std::make_shared<mtd::StubCmdStreamSyncFactory>(), | ||
1264 | 50 | std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})}; | ||
1265 | 47 | }; | 51 | }; |
1266 | 48 | 52 | ||
1267 | 49 | TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module) | 53 | TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module) |
1268 | @@ -54,7 +58,7 @@ | |||
1269 | 54 | .Times(1); | 58 | .Times(1); |
1270 | 55 | 59 | ||
1271 | 56 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); | 60 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
1273 | 57 | mga::AndroidGraphicBufferAllocator allocator{quirks}; | 61 | mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mtd::StubCmdStreamSyncFactory>(), quirks}; |
1274 | 58 | } | 62 | } |
1275 | 59 | 63 | ||
1276 | 60 | TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats) | 64 | TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats) |
1277 | 61 | 65 | ||
1278 | === modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp' | |||
1279 | --- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2015-12-11 12:22:15 +0000 | |||
1280 | +++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2016-01-25 17:04:59 +0000 | |||
1281 | @@ -289,7 +289,7 @@ | |||
1282 | 289 | 289 | ||
1283 | 290 | 290 | ||
1284 | 291 | /* binding tests */ | 291 | /* binding tests */ |
1286 | 292 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension) | 292 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_and_notes_gpu_usage) |
1287 | 293 | { | 293 | { |
1288 | 294 | using namespace testing; | 294 | using namespace testing; |
1289 | 295 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) | 295 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1290 | @@ -298,11 +298,23 @@ | |||
1291 | 298 | buffer.gl_bind_to_texture(); | 298 | buffer.gl_bind_to_texture(); |
1292 | 299 | } | 299 | } |
1293 | 300 | 300 | ||
1294 | 301 | TEST_F(AndroidBufferBinding, notes_gpu_usage_when_explicity_told) | ||
1295 | 302 | { | ||
1296 | 303 | using namespace testing; | ||
1297 | 304 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) | ||
1298 | 305 | .Times(0); | ||
1299 | 306 | EXPECT_CALL(*mock_native_buffer, lock_for_gpu()); | ||
1300 | 307 | mga::Buffer buffer(gralloc, mock_native_buffer, extensions); | ||
1301 | 308 | buffer.secure_for_render(); | ||
1302 | 309 | } | ||
1303 | 310 | |||
1304 | 301 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time) | 311 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time) |
1305 | 302 | { | 312 | { |
1306 | 303 | using namespace testing; | 313 | using namespace testing; |
1307 | 304 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) | 314 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1308 | 305 | .Times(Exactly(3)); | 315 | .Times(Exactly(3)); |
1309 | 316 | EXPECT_CALL(*mock_native_buffer, lock_for_gpu()) | ||
1310 | 317 | .Times(Exactly(3)); | ||
1311 | 306 | 318 | ||
1312 | 307 | mga::Buffer buffer(gralloc, mock_native_buffer, extensions); | 319 | mga::Buffer buffer(gralloc, mock_native_buffer, extensions); |
1313 | 308 | buffer.gl_bind_to_texture(); | 320 | buffer.gl_bind_to_texture(); |
1314 | 309 | 321 | ||
1315 | === modified file 'tests/unit-tests/graphics/android/test_display_buffer.cpp' | |||
1316 | --- tests/unit-tests/graphics/android/test_display_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
1317 | +++ tests/unit-tests/graphics/android/test_display_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
1318 | @@ -235,6 +235,21 @@ | |||
1319 | 235 | db.release_current(); | 235 | db.release_current(); |
1320 | 236 | } | 236 | } |
1321 | 237 | 237 | ||
1322 | 238 | //In HWC 1.0 notably we cannot eglSwapBuffers on the fb context. | ||
1323 | 239 | TEST_F(DisplayBuffer, swaps_when_allowed) | ||
1324 | 240 | { | ||
1325 | 241 | using namespace testing; | ||
1326 | 242 | EXPECT_CALL(*mock_display_device, can_swap_buffers()) | ||
1327 | 243 | .Times(2) | ||
1328 | 244 | .WillOnce(Return(true)) | ||
1329 | 245 | .WillOnce(Return(false)); | ||
1330 | 246 | EXPECT_CALL(mock_egl, eglSwapBuffers(dummy_display, mock_egl.fake_egl_surface)) | ||
1331 | 247 | .Times(1); | ||
1332 | 248 | |||
1333 | 249 | db.swap_buffers(); | ||
1334 | 250 | db.swap_buffers(); | ||
1335 | 251 | } | ||
1336 | 252 | |||
1337 | 238 | TEST_F(DisplayBuffer, notifies_list_that_content_is_cleared) | 253 | TEST_F(DisplayBuffer, notifies_list_that_content_is_cleared) |
1338 | 239 | { | 254 | { |
1339 | 240 | EXPECT_CALL(*mock_display_device, content_cleared()) | 255 | EXPECT_CALL(*mock_display_device, content_cleared()) |
1340 | 241 | 256 | ||
1341 | === modified file 'tests/unit-tests/graphics/android/test_display_hotplug.cpp' | |||
1342 | --- tests/unit-tests/graphics/android/test_display_hotplug.cpp 2015-12-11 12:22:15 +0000 | |||
1343 | +++ tests/unit-tests/graphics/android/test_display_hotplug.cpp 2016-01-25 17:04:59 +0000 | |||
1344 | @@ -103,6 +103,11 @@ | |||
1345 | 103 | new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, geom::Displacement{})); | 103 | new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, geom::Displacement{})); |
1346 | 104 | } | 104 | } |
1347 | 105 | 105 | ||
1348 | 106 | std::unique_ptr<mg::CommandStreamSync> create_command_stream_sync() | ||
1349 | 107 | { | ||
1350 | 108 | return nullptr; | ||
1351 | 109 | } | ||
1352 | 110 | |||
1353 | 106 | StubHwcConfig stub_config; | 111 | StubHwcConfig stub_config; |
1354 | 107 | }; | 112 | }; |
1355 | 108 | 113 | ||
1356 | 109 | 114 | ||
1357 | === modified file 'tests/unit-tests/graphics/android/test_fb_device.cpp' | |||
1358 | --- tests/unit-tests/graphics/android/test_fb_device.cpp 2015-12-11 12:22:15 +0000 | |||
1359 | +++ tests/unit-tests/graphics/android/test_fb_device.cpp 2016-01-25 17:04:59 +0000 | |||
1360 | @@ -72,6 +72,12 @@ | |||
1361 | 72 | mga::DisplayName primary{mga::DisplayName::primary}; | 72 | mga::DisplayName primary{mga::DisplayName::primary}; |
1362 | 73 | }; | 73 | }; |
1363 | 74 | 74 | ||
1364 | 75 | TEST_F(FBDevice, reports_it_can_swap) | ||
1365 | 76 | { | ||
1366 | 77 | mga::FBDevice fbdev(fb_hal_mock); | ||
1367 | 78 | EXPECT_TRUE(fbdev.can_swap_buffers()); | ||
1368 | 79 | } | ||
1369 | 80 | |||
1370 | 75 | TEST_F(FBDevice, rejects_renderables) | 81 | TEST_F(FBDevice, rejects_renderables) |
1371 | 76 | { | 82 | { |
1372 | 77 | mg::RenderableList renderlist | 83 | mg::RenderableList renderlist |
1373 | @@ -92,6 +98,8 @@ | |||
1374 | 92 | .WillOnce(Return(-1)) | 98 | .WillOnce(Return(-1)) |
1375 | 93 | .WillOnce(Return(0)); | 99 | .WillOnce(Return(0)); |
1376 | 94 | 100 | ||
1377 | 101 | EXPECT_CALL(mock_context, swap_buffers()) | ||
1378 | 102 | .Times(0); | ||
1379 | 95 | mga::FBDevice fbdev(fb_hal_mock); | 103 | mga::FBDevice fbdev(fb_hal_mock); |
1380 | 96 | mga::DisplayContents content{primary, list, geom::Displacement{}, mock_context, stub_compositor}; | 104 | mga::DisplayContents content{primary, list, geom::Displacement{}, mock_context, stub_compositor}; |
1381 | 97 | 105 | ||
1382 | 98 | 106 | ||
1383 | === modified file 'tests/unit-tests/graphics/android/test_hwc_device.cpp' | |||
1384 | --- tests/unit-tests/graphics/android/test_hwc_device.cpp 2015-12-11 12:22:15 +0000 | |||
1385 | +++ tests/unit-tests/graphics/android/test_hwc_device.cpp 2016-01-25 17:04:59 +0000 | |||
1386 | @@ -120,6 +120,12 @@ | |||
1387 | 120 | }; | 120 | }; |
1388 | 121 | } | 121 | } |
1389 | 122 | 122 | ||
1390 | 123 | TEST_F(HwcDevice, reports_it_can_swap) | ||
1391 | 124 | { | ||
1392 | 125 | mga::HwcDevice device(mock_device); | ||
1393 | 126 | EXPECT_TRUE(device.can_swap_buffers()); | ||
1394 | 127 | } | ||
1395 | 128 | |||
1396 | 123 | TEST_F(HwcDevice, prepares_a_skip_and_target_layer_by_default) | 129 | TEST_F(HwcDevice, prepares_a_skip_and_target_layer_by_default) |
1397 | 124 | { | 130 | { |
1398 | 125 | using namespace testing; | 131 | using namespace testing; |
1399 | @@ -174,7 +180,7 @@ | |||
1400 | 174 | device.commit({content}); | 180 | device.commit({content}); |
1401 | 175 | } | 181 | } |
1402 | 176 | 182 | ||
1404 | 177 | TEST_F(HwcDevice, swaps_buffers_directly_when_no_renderables) | 183 | TEST_F(HwcDevice, does_not_swap_buffers_when_no_renderables) |
1405 | 178 | { | 184 | { |
1406 | 179 | using namespace testing; | 185 | using namespace testing; |
1407 | 180 | mtd::MockRenderableListCompositor mock_compositor; | 186 | mtd::MockRenderableListCompositor mock_compositor; |
1408 | @@ -184,7 +190,8 @@ | |||
1409 | 184 | 190 | ||
1410 | 185 | EXPECT_CALL(mock_compositor, render(_,_,_)) | 191 | EXPECT_CALL(mock_compositor, render(_,_,_)) |
1411 | 186 | .Times(0); | 192 | .Times(0); |
1413 | 187 | EXPECT_CALL(mock_context, swap_buffers()); | 193 | EXPECT_CALL(mock_context, swap_buffers()) |
1414 | 194 | .Times(0); | ||
1415 | 188 | 195 | ||
1416 | 189 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); | 196 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); |
1417 | 190 | mga::DisplayContents content{primary, list, offset, mock_context, mock_compositor}; | 197 | mga::DisplayContents content{primary, list, offset, mock_context, mock_compositor}; |
1418 | @@ -465,8 +472,6 @@ | |||
1419 | 465 | NiceMock<mtd::MockSwappingGLContext> mock_context; | 472 | NiceMock<mtd::MockSwappingGLContext> mock_context; |
1420 | 466 | ON_CALL(mock_context, last_rendered_buffer()) | 473 | ON_CALL(mock_context, last_rendered_buffer()) |
1421 | 467 | .WillByDefault(Return(stub_fb_buffer)); | 474 | .WillByDefault(Return(stub_fb_buffer)); |
1422 | 468 | EXPECT_CALL(mock_context, swap_buffers()) | ||
1423 | 469 | .Times(AtLeast(5)); | ||
1424 | 470 | 475 | ||
1425 | 471 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); | 476 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); |
1426 | 472 | mtd::MockRenderableListCompositor mock_compositor; | 477 | mtd::MockRenderableListCompositor mock_compositor; |
1427 | @@ -844,10 +849,6 @@ | |||
1428 | 844 | 849 | ||
1429 | 845 | InSequence seq; | 850 | InSequence seq; |
1430 | 846 | EXPECT_CALL(*mock_device, prepare(MatchesLists(expected_list, expected_list))); | 851 | EXPECT_CALL(*mock_device, prepare(MatchesLists(expected_list, expected_list))); |
1431 | 847 | EXPECT_CALL(mock_context1, make_current()); | ||
1432 | 848 | EXPECT_CALL(mock_context1, release_current()); | ||
1433 | 849 | EXPECT_CALL(mock_context2, make_current()); | ||
1434 | 850 | EXPECT_CALL(mock_context2, release_current()); | ||
1435 | 851 | EXPECT_CALL(*mock_device, set(MatchesLists(expected_list, expected_list))); | 852 | EXPECT_CALL(*mock_device, set(MatchesLists(expected_list, expected_list))); |
1436 | 852 | 853 | ||
1437 | 853 | mga::LayerList primary_list(layer_adapter, {}, geom::Displacement{}); | 854 | mga::LayerList primary_list(layer_adapter, {}, geom::Displacement{}); |
1438 | 854 | 855 | ||
1439 | === modified file 'tests/unit-tests/graphics/android/test_hwc_fb_device.cpp' | |||
1440 | --- tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2015-12-11 12:22:15 +0000 | |||
1441 | +++ tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2016-01-25 17:04:59 +0000 | |||
1442 | @@ -104,6 +104,12 @@ | |||
1443 | 104 | }; | 104 | }; |
1444 | 105 | } | 105 | } |
1445 | 106 | 106 | ||
1446 | 107 | TEST_F(HwcFbDevice, reports_it_cannot_swap) | ||
1447 | 108 | { | ||
1448 | 109 | mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device); | ||
1449 | 110 | EXPECT_FALSE(device.can_swap_buffers()); | ||
1450 | 111 | } | ||
1451 | 112 | |||
1452 | 107 | TEST_F(HwcFbDevice, hwc10_subscribes_to_vsync_events) | 113 | TEST_F(HwcFbDevice, hwc10_subscribes_to_vsync_events) |
1453 | 108 | { | 114 | { |
1454 | 109 | using namespace testing; | 115 | using namespace testing; |
1455 | 110 | 116 | ||
1456 | === modified file 'tests/unit-tests/graphics/android/test_native_buffer.cpp' | |||
1457 | --- tests/unit-tests/graphics/android/test_native_buffer.cpp 2015-12-11 12:22:15 +0000 | |||
1458 | +++ tests/unit-tests/graphics/android/test_native_buffer.cpp 2016-01-25 17:04:59 +0000 | |||
1459 | @@ -17,25 +17,41 @@ | |||
1460 | 17 | */ | 17 | */ |
1461 | 18 | 18 | ||
1462 | 19 | #include "mir/graphics/android/android_native_buffer.h" | 19 | #include "mir/graphics/android/android_native_buffer.h" |
1463 | 20 | #include "mir/graphics/egl_sync_fence.h" | ||
1464 | 20 | #include "mir/test/doubles/mock_fence.h" | 21 | #include "mir/test/doubles/mock_fence.h" |
1465 | 21 | #include <memory> | 22 | #include <memory> |
1466 | 22 | #include <gtest/gtest.h> | 23 | #include <gtest/gtest.h> |
1467 | 23 | 24 | ||
1468 | 24 | namespace mtd=mir::test::doubles; | 25 | namespace mtd=mir::test::doubles; |
1469 | 25 | namespace mga=mir::graphics::android; | 26 | namespace mga=mir::graphics::android; |
1470 | 27 | using namespace testing; | ||
1471 | 28 | |||
1472 | 29 | namespace | ||
1473 | 30 | { | ||
1474 | 31 | struct MockCommandStreamSync : public mir::graphics::CommandStreamSync | ||
1475 | 32 | { | ||
1476 | 33 | MOCK_METHOD0(raise, void()); | ||
1477 | 34 | MOCK_METHOD0(reset, void()); | ||
1478 | 35 | MOCK_METHOD1(wait_for, bool(std::chrono::nanoseconds)); | ||
1479 | 36 | }; | ||
1480 | 37 | } | ||
1481 | 26 | 38 | ||
1482 | 27 | struct NativeBuffer : public testing::Test | 39 | struct NativeBuffer : public testing::Test |
1483 | 28 | { | 40 | { |
1484 | 29 | NativeBuffer() : | 41 | NativeBuffer() : |
1485 | 30 | a_native_window_buffer(std::make_shared<ANativeWindowBuffer>()), | 42 | a_native_window_buffer(std::make_shared<ANativeWindowBuffer>()), |
1486 | 31 | mock_fence(std::make_shared<testing::NiceMock<mtd::MockFence>>()), | 43 | mock_fence(std::make_shared<testing::NiceMock<mtd::MockFence>>()), |
1488 | 32 | fake_fd{48484} | 44 | fake_fd{48484}, |
1489 | 45 | timeout{std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(2))}, | ||
1490 | 46 | mock_cmdstream_sync{std::make_shared<MockCommandStreamSync>()} | ||
1491 | 33 | { | 47 | { |
1492 | 34 | } | 48 | } |
1493 | 35 | 49 | ||
1494 | 36 | std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer; | 50 | std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer; |
1495 | 37 | std::shared_ptr<mtd::MockFence> mock_fence; | 51 | std::shared_ptr<mtd::MockFence> mock_fence; |
1496 | 38 | int fake_fd; | 52 | int fake_fd; |
1497 | 53 | std::chrono::nanoseconds timeout; | ||
1498 | 54 | std::shared_ptr<MockCommandStreamSync> mock_cmdstream_sync; | ||
1499 | 39 | }; | 55 | }; |
1500 | 40 | 56 | ||
1501 | 41 | TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks) | 57 | TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks) |
1502 | @@ -88,7 +104,7 @@ | |||
1503 | 88 | { | 104 | { |
1504 | 89 | EXPECT_CALL(*mock_fence, wait()) | 105 | EXPECT_CALL(*mock_fence, wait()) |
1505 | 90 | .Times(0); | 106 | .Times(0); |
1507 | 91 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); | 107 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1508 | 92 | buffer.ensure_available_for(mga::BufferAccess::read); | 108 | buffer.ensure_available_for(mga::BufferAccess::read); |
1509 | 93 | } | 109 | } |
1510 | 94 | 110 | ||
1511 | @@ -96,7 +112,7 @@ | |||
1512 | 96 | { | 112 | { |
1513 | 97 | EXPECT_CALL(*mock_fence, wait()) | 113 | EXPECT_CALL(*mock_fence, wait()) |
1514 | 98 | .Times(1); | 114 | .Times(1); |
1516 | 99 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::write); | 115 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::write); |
1517 | 100 | buffer.ensure_available_for(mga::BufferAccess::read); | 116 | buffer.ensure_available_for(mga::BufferAccess::read); |
1518 | 101 | } | 117 | } |
1519 | 102 | 118 | ||
1520 | @@ -104,7 +120,7 @@ | |||
1521 | 104 | { | 120 | { |
1522 | 105 | EXPECT_CALL(*mock_fence, wait()) | 121 | EXPECT_CALL(*mock_fence, wait()) |
1523 | 106 | .Times(1); | 122 | .Times(1); |
1525 | 107 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); | 123 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1526 | 108 | buffer.ensure_available_for(mga::BufferAccess::write); | 124 | buffer.ensure_available_for(mga::BufferAccess::write); |
1527 | 109 | } | 125 | } |
1528 | 110 | 126 | ||
1529 | @@ -112,7 +128,7 @@ | |||
1530 | 112 | { | 128 | { |
1531 | 113 | EXPECT_CALL(*mock_fence, wait()) | 129 | EXPECT_CALL(*mock_fence, wait()) |
1532 | 114 | .Times(1); | 130 | .Times(1); |
1534 | 115 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::write); | 131 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::write); |
1535 | 116 | buffer.ensure_available_for(mga::BufferAccess::write); | 132 | buffer.ensure_available_for(mga::BufferAccess::write); |
1536 | 117 | } | 133 | } |
1537 | 118 | 134 | ||
1538 | @@ -120,7 +136,7 @@ | |||
1539 | 120 | { | 136 | { |
1540 | 121 | EXPECT_CALL(*mock_fence, merge_with(fake_fd)) | 137 | EXPECT_CALL(*mock_fence, merge_with(fake_fd)) |
1541 | 122 | .Times(1); | 138 | .Times(1); |
1543 | 123 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); | 139 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1544 | 124 | buffer.update_usage(fake_fd, mga::BufferAccess::write); | 140 | buffer.update_usage(fake_fd, mga::BufferAccess::write); |
1545 | 125 | } | 141 | } |
1546 | 126 | 142 | ||
1547 | @@ -129,7 +145,7 @@ | |||
1548 | 129 | EXPECT_CALL(*mock_fence, wait()) | 145 | EXPECT_CALL(*mock_fence, wait()) |
1549 | 130 | .Times(3); | 146 | .Times(3); |
1550 | 131 | 147 | ||
1552 | 132 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); | 148 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1553 | 133 | buffer.ensure_available_for(mga::BufferAccess::write); | 149 | buffer.ensure_available_for(mga::BufferAccess::write); |
1554 | 134 | buffer.ensure_available_for(mga::BufferAccess::read); | 150 | buffer.ensure_available_for(mga::BufferAccess::read); |
1555 | 135 | 151 | ||
1556 | @@ -137,3 +153,30 @@ | |||
1557 | 137 | buffer.ensure_available_for(mga::BufferAccess::write); | 153 | buffer.ensure_available_for(mga::BufferAccess::write); |
1558 | 138 | buffer.ensure_available_for(mga::BufferAccess::read); | 154 | buffer.ensure_available_for(mga::BufferAccess::read); |
1559 | 139 | } | 155 | } |
1560 | 156 | |||
1561 | 157 | TEST_F(NativeBuffer, raises_egl_fence) | ||
1562 | 158 | { | ||
1563 | 159 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); | ||
1564 | 160 | |||
1565 | 161 | EXPECT_CALL(*mock_cmdstream_sync, raise()); | ||
1566 | 162 | buffer.lock_for_gpu(); | ||
1567 | 163 | } | ||
1568 | 164 | |||
1569 | 165 | TEST_F(NativeBuffer, clears_egl_fence_successfully) | ||
1570 | 166 | { | ||
1571 | 167 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); | ||
1572 | 168 | EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout)) | ||
1573 | 169 | .Times(1) | ||
1574 | 170 | .WillOnce(Return(true)); | ||
1575 | 171 | buffer.wait_for_unlock_by_gpu(); | ||
1576 | 172 | } | ||
1577 | 173 | |||
1578 | 174 | //not really helpful to throw if the timeout fails | ||
1579 | 175 | TEST_F(NativeBuffer, ignores_clears_egl_fence_failure) | ||
1580 | 176 | { | ||
1581 | 177 | mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); | ||
1582 | 178 | EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout)) | ||
1583 | 179 | .Times(1) | ||
1584 | 180 | .WillOnce(Return(false)); | ||
1585 | 181 | buffer.wait_for_unlock_by_gpu(); | ||
1586 | 182 | } | ||
1587 | 140 | 183 | ||
1588 | === modified file 'tests/unit-tests/graphics/android/test_platform.cpp' | |||
1589 | --- tests/unit-tests/graphics/android/test_platform.cpp 2015-12-11 12:22:15 +0000 | |||
1590 | +++ tests/unit-tests/graphics/android/test_platform.cpp 2016-01-25 17:04:59 +0000 | |||
1591 | @@ -26,6 +26,7 @@ | |||
1592 | 26 | #include "mir/test/doubles/mock_display_report.h" | 26 | #include "mir/test/doubles/mock_display_report.h" |
1593 | 27 | #include "mir/test/doubles/mock_egl.h" | 27 | #include "mir/test/doubles/mock_egl.h" |
1594 | 28 | #include "mir/test/doubles/stub_display_builder.h" | 28 | #include "mir/test/doubles/stub_display_builder.h" |
1595 | 29 | #include "mir/test/doubles/stub_cmdstream_sync_factory.h" | ||
1596 | 29 | #include "mir/test/doubles/fd_matcher.h" | 30 | #include "mir/test/doubles/fd_matcher.h" |
1597 | 30 | #include "mir/test/fake_shared.h" | 31 | #include "mir/test/fake_shared.h" |
1598 | 31 | #include "mir/test/doubles/mock_android_native_buffer.h" | 32 | #include "mir/test/doubles/mock_android_native_buffer.h" |
1599 | @@ -54,6 +55,7 @@ | |||
1600 | 54 | using namespace testing; | 55 | using namespace testing; |
1601 | 55 | 56 | ||
1602 | 56 | stub_display_builder = std::make_shared<mtd::StubDisplayBuilder>(); | 57 | stub_display_builder = std::make_shared<mtd::StubDisplayBuilder>(); |
1603 | 58 | stub_sync_factory = std::make_shared<mtd::StubCmdStreamSyncFactory>(); | ||
1604 | 57 | stub_display_report = mr::null_display_report(); | 59 | stub_display_report = mr::null_display_report(); |
1605 | 58 | stride = geom::Stride(300*4); | 60 | stride = geom::Stride(300*4); |
1606 | 59 | 61 | ||
1607 | @@ -86,6 +88,7 @@ | |||
1608 | 86 | std::shared_ptr<mtd::MockAndroidNativeBuffer> native_buffer; | 88 | std::shared_ptr<mtd::MockAndroidNativeBuffer> native_buffer; |
1609 | 87 | std::shared_ptr<mtd::StubBufferAllocator> stub_buffer_allocator; | 89 | std::shared_ptr<mtd::StubBufferAllocator> stub_buffer_allocator; |
1610 | 88 | std::shared_ptr<mtd::StubDisplayBuilder> stub_display_builder; | 90 | std::shared_ptr<mtd::StubDisplayBuilder> stub_display_builder; |
1611 | 91 | std::shared_ptr<mtd::StubCmdStreamSyncFactory> stub_sync_factory; | ||
1612 | 89 | std::shared_ptr<mtd::MockBuffer> mock_buffer; | 92 | std::shared_ptr<mtd::MockBuffer> mock_buffer; |
1613 | 90 | std::shared_ptr<native_handle_t> native_buffer_handle; | 93 | std::shared_ptr<native_handle_t> native_buffer_handle; |
1614 | 91 | std::shared_ptr<mg::DisplayReport> stub_display_report; | 94 | std::shared_ptr<mg::DisplayReport> stub_display_report; |
1615 | @@ -99,10 +102,12 @@ | |||
1616 | 99 | { | 102 | { |
1617 | 100 | using namespace ::testing; | 103 | using namespace ::testing; |
1618 | 101 | int fake_fence{333}; | 104 | int fake_fence{333}; |
1619 | 105 | EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); | ||
1620 | 102 | EXPECT_CALL(*native_buffer, copy_fence()) | 106 | EXPECT_CALL(*native_buffer, copy_fence()) |
1621 | 103 | .WillOnce(Return(fake_fence)); | 107 | .WillOnce(Return(fake_fence)); |
1622 | 104 | 108 | ||
1624 | 105 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); | 109 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1625 | 110 | stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); | ||
1626 | 106 | 111 | ||
1627 | 107 | mtd::MockBufferIpcMessage mock_ipc_msg; | 112 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1628 | 108 | int offset = 0; | 113 | int offset = 0; |
1629 | @@ -130,10 +135,12 @@ | |||
1630 | 130 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_full_ipc_without_fence) | 135 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_full_ipc_without_fence) |
1631 | 131 | { | 136 | { |
1632 | 132 | using namespace ::testing; | 137 | using namespace ::testing; |
1633 | 138 | EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); | ||
1634 | 133 | EXPECT_CALL(*native_buffer, copy_fence()) | 139 | EXPECT_CALL(*native_buffer, copy_fence()) |
1635 | 134 | .WillOnce(Return(-1)); | 140 | .WillOnce(Return(-1)); |
1636 | 135 | 141 | ||
1638 | 136 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); | 142 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1639 | 143 | stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); | ||
1640 | 137 | 144 | ||
1641 | 138 | mtd::MockBufferIpcMessage mock_ipc_msg; | 145 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1642 | 139 | int offset = 0; | 146 | int offset = 0; |
1643 | @@ -169,10 +176,12 @@ | |||
1644 | 169 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_nested) | 176 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_nested) |
1645 | 170 | { | 177 | { |
1646 | 171 | using namespace ::testing; | 178 | using namespace ::testing; |
1647 | 179 | EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); | ||
1648 | 172 | EXPECT_CALL(*native_buffer, copy_fence()) | 180 | EXPECT_CALL(*native_buffer, copy_fence()) |
1649 | 173 | .WillOnce(Return(-1)); | 181 | .WillOnce(Return(-1)); |
1650 | 174 | 182 | ||
1652 | 175 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); | 183 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1653 | 184 | stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); | ||
1654 | 176 | 185 | ||
1655 | 177 | mtd::MockBufferIpcMessage mock_ipc_msg; | 186 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1656 | 178 | int offset = 0; | 187 | int offset = 0; |
1657 | @@ -207,7 +216,8 @@ | |||
1658 | 207 | using namespace ::testing; | 216 | using namespace ::testing; |
1659 | 208 | 217 | ||
1660 | 209 | int fake_fence{33}; | 218 | int fake_fence{33}; |
1662 | 210 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); | 219 | mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1663 | 220 | stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); | ||
1664 | 211 | auto ipc_ops = platform.make_ipc_operations(); | 221 | auto ipc_ops = platform.make_ipc_operations(); |
1665 | 212 | 222 | ||
1666 | 213 | mtd::MockBufferIpcMessage mock_ipc_msg; | 223 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1667 | @@ -234,6 +244,7 @@ | |||
1668 | 234 | mga::Platform platform( | 244 | mga::Platform platform( |
1669 | 235 | std::make_shared<mtd::StubBufferAllocator>(), | 245 | std::make_shared<mtd::StubBufferAllocator>(), |
1670 | 236 | std::make_shared<mtd::StubDisplayBuilder>(), | 246 | std::make_shared<mtd::StubDisplayBuilder>(), |
1671 | 247 | std::make_shared<mtd::StubCmdStreamSyncFactory>(), | ||
1672 | 237 | mr::null_display_report(), | 248 | mr::null_display_report(), |
1673 | 238 | mga::OverlayOptimization::enabled, | 249 | mga::OverlayOptimization::enabled, |
1674 | 239 | std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})); | 250 | std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})); |