Mir

Merge lp:~mir-team/mir/0.18.3 into lp:mir/0.18

Proposed by Kevin DuBois
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
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
=== modified file 'debian/changelog'
--- debian/changelog 2016-01-18 18:06:23 +0000
+++ debian/changelog 2016-01-25 17:04:59 +0000
@@ -1,4 +1,10 @@
1mir (0.18.1-0ubuntu1) UNRELEASED; urgency=medium1mir (0.18.2-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Add egl sync fences for devices that need it. (LP: #1517205)
4
5 -- Kevin DuBois <kevin.dubois@canonical.com> Mon, 25 Jan 2016 09:58:43 -0500
6
7mir (0.18.1-0ubuntu1) xenial; urgency=medium
28
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)
4 - No ABI changes. Bug fix release only.10 - No ABI changes. Bug fix release only.
511
=== modified file 'include/renderers/gl/mir/renderer/gl/texture_source.h'
--- include/renderers/gl/mir/renderer/gl/texture_source.h 2015-12-11 12:22:15 +0000
+++ include/renderers/gl/mir/renderer/gl/texture_source.h 2016-01-25 17:04:59 +0000
@@ -26,12 +26,22 @@
26namespace gl26namespace gl
27{27{
2828
29//FIXME: (kdub) we're not hiding the differences in texture upload approaches between our platforms
30// very well with this interface.
29class TextureSource31class TextureSource
30{32{
31public:33public:
32 virtual ~TextureSource() = default;34 virtual ~TextureSource() = default;
3335
36 // \warning deprecated, provided for convenience and legacy transition.
37 //will call bind() and then secure_for_render()
34 virtual void gl_bind_to_texture() = 0;38 virtual void gl_bind_to_texture() = 0;
39 //Uploads texture.
40 virtual void bind() = 0;
41 //add synchronization points to the command stream to ensure resources
42 //are present during the draw. Will not upload texture.
43 //should be called if an already uploaded texture is reused.
44 virtual void secure_for_render() = 0;
3545
36protected:46protected:
37 TextureSource() = default;47 TextureSource() = default;
3848
=== modified file 'src/common/graphics/android/CMakeLists.txt'
--- src/common/graphics/android/CMakeLists.txt 2015-12-11 12:22:15 +0000
+++ src/common/graphics/android/CMakeLists.txt 2016-01-25 17:04:59 +0000
@@ -1,5 +1,7 @@
1include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS})1include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS})
2include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps)2include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps)
3include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/include/platform)
4include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/src/include/platform)
35
4add_definitions( -DANDROID )6add_definitions( -DANDROID )
57
68
=== modified file 'src/common/graphics/android/android_native_buffer.cpp'
--- src/common/graphics/android/android_native_buffer.cpp 2015-12-11 12:22:15 +0000
+++ src/common/graphics/android/android_native_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -17,14 +17,17 @@
17 */17 */
1818
19#include "mir/graphics/android/android_native_buffer.h"19#include "mir/graphics/android/android_native_buffer.h"
20#include "mir/graphics/egl_sync_fence.h"
2021
21namespace mga=mir::graphics::android;22namespace mga=mir::graphics::android;
2223
23mga::AndroidNativeBuffer::AndroidNativeBuffer(24mga::AndroidNativeBuffer::AndroidNativeBuffer(
24 std::shared_ptr<ANativeWindowBuffer> const& anwb,25 std::shared_ptr<ANativeWindowBuffer> const& anwb,
26 std::shared_ptr<CommandStreamSync> const& cmdstream_sync,
25 std::shared_ptr<Fence> const& fence,27 std::shared_ptr<Fence> const& fence,
26 BufferAccess access)28 BufferAccess access)
27 : fence(fence),29 : cmdstream_sync(cmdstream_sync),
30 fence(fence),
28 access(access),31 access(access),
29 native_window_buffer(anwb)32 native_window_buffer(anwb)
30{33{
@@ -58,3 +61,14 @@
58{61{
59 return fence->copy_native_handle();62 return fence->copy_native_handle();
60}63}
64
65void mga::AndroidNativeBuffer::lock_for_gpu()
66{
67 cmdstream_sync->raise();
68}
69
70void mga::AndroidNativeBuffer::wait_for_unlock_by_gpu()
71{
72 using namespace std::chrono;
73 cmdstream_sync->wait_for(duration_cast<nanoseconds>(seconds(2)));
74}
6175
=== modified file 'src/gl/recently_used_cache.cpp'
--- src/gl/recently_used_cache.cpp 2015-12-11 12:22:15 +0000
+++ src/gl/recently_used_cache.cpp 2016-01-25 17:04:59 +0000
@@ -27,6 +27,7 @@
27namespace mg = mir::graphics;27namespace mg = mir::graphics;
28namespace mgl = mir::gl;28namespace mgl = mir::gl;
29namespace geom = mir::geometry;29namespace geom = mir::geometry;
30namespace mrgl = mir::renderer::gl;
3031
31std::shared_ptr<mgl::Texture> mgl::RecentlyUsedCache::load(mg::Renderable const& renderable)32std::shared_ptr<mgl::Texture> mgl::RecentlyUsedCache::load(mg::Renderable const& renderable)
32{33{
@@ -35,18 +36,18 @@
35 auto& texture = textures[renderable.id()];36 auto& texture = textures[renderable.id()];
36 texture.texture->bind();37 texture.texture->bind();
3738
39 auto const texture_source = dynamic_cast<mrgl::TextureSource*>(buffer->native_buffer_base());
40 if (!texture_source)
41 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
42
38 if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding))43 if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding))
39 {44 {
40 auto const texture_source =45 texture_source->bind();
41 dynamic_cast<mir::renderer::gl::TextureSource*>(
42 buffer->native_buffer_base());
43 if (!texture_source)
44 BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
45
46 texture_source->gl_bind_to_texture();
47 texture.resource = buffer;46 texture.resource = buffer;
48 texture.last_bound_buffer = buffer_id;47 texture.last_bound_buffer = buffer_id;
49 }48 }
49 texture_source->secure_for_render();
50
50 texture.valid_binding = true;51 texture.valid_binding = true;
51 texture.used = true;52 texture.used = true;
5253
5354
=== modified file 'src/include/common/mir/graphics/android/android_native_buffer.h'
--- src/include/common/mir/graphics/android/android_native_buffer.h 2015-12-11 12:22:15 +0000
+++ src/include/common/mir/graphics/android/android_native_buffer.h 2016-01-25 17:04:59 +0000
@@ -27,6 +27,7 @@
27{27{
28namespace graphics28namespace graphics
29{29{
30class CommandStreamSync;
30namespace android31namespace android
31{32{
32class Fence;33class Fence;
@@ -35,6 +36,7 @@
35{36{
36 AndroidNativeBuffer(37 AndroidNativeBuffer(
37 std::shared_ptr<ANativeWindowBuffer> const& handle,38 std::shared_ptr<ANativeWindowBuffer> const& handle,
39 std::shared_ptr<CommandStreamSync> const& cmdstream_sync,
38 std::shared_ptr<Fence> const& fence,40 std::shared_ptr<Fence> const& fence,
39 BufferAccess fence_access);41 BufferAccess fence_access);
4042
@@ -45,7 +47,11 @@
45 void ensure_available_for(BufferAccess);47 void ensure_available_for(BufferAccess);
46 void update_usage(NativeFence& merge_fd, BufferAccess);48 void update_usage(NativeFence& merge_fd, BufferAccess);
4749
50 void lock_for_gpu();
51 void wait_for_unlock_by_gpu();
52
48private:53private:
54 std::shared_ptr<CommandStreamSync> cmdstream_sync;
49 std::shared_ptr<Fence> fence;55 std::shared_ptr<Fence> fence;
50 BufferAccess access;56 BufferAccess access;
51 std::shared_ptr<ANativeWindowBuffer> native_window_buffer;57 std::shared_ptr<ANativeWindowBuffer> native_window_buffer;
5258
=== modified file 'src/include/common/mir/graphics/android/native_buffer.h'
--- src/include/common/mir/graphics/android/native_buffer.h 2015-12-11 12:22:15 +0000
+++ src/include/common/mir/graphics/android/native_buffer.h 2016-01-25 17:04:59 +0000
@@ -53,6 +53,9 @@
53 virtual void ensure_available_for(android::BufferAccess intent) = 0;53 virtual void ensure_available_for(android::BufferAccess intent) = 0;
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;
5555
56 virtual void lock_for_gpu() = 0;
57 virtual void wait_for_unlock_by_gpu() = 0;
58
56protected:59protected:
57 NativeBuffer() = default;60 NativeBuffer() = default;
58 NativeBuffer(NativeBuffer const&) = delete;61 NativeBuffer(NativeBuffer const&) = delete;
5962
=== modified file 'src/platform/symbols.map'
--- src/platform/symbols.map 2015-12-11 12:22:15 +0000
+++ src/platform/symbols.map 2016-01-25 17:04:59 +0000
@@ -219,6 +219,7 @@
219 vtable?for?mir::graphics::EventHandlerRegister;219 vtable?for?mir::graphics::EventHandlerRegister;
220 vtable?for?mir::graphics::GLConfig;220 vtable?for?mir::graphics::GLConfig;
221 vtable?for?mir::graphics::GLContext;221 vtable?for?mir::graphics::GLContext;
222 vtable?for?mir::graphics::NullCommandSync;
222 vtable?for?mir::graphics::GraphicBufferAllocator;223 vtable?for?mir::graphics::GraphicBufferAllocator;
223 vtable?for?mir::graphics::Platform;224 vtable?for?mir::graphics::Platform;
224 vtable?for?mir::graphics::PlatformIpcOperations;225 vtable?for?mir::graphics::PlatformIpcOperations;
@@ -237,6 +238,19 @@
237 mir::graphics::blue_channel_depth*;238 mir::graphics::blue_channel_depth*;
238 mir::graphics::contains_alpha*;239 mir::graphics::contains_alpha*;
239 mir::graphics::EGLExtensions::EGLExtensions*;240 mir::graphics::EGLExtensions::EGLExtensions*;
241 mir::graphics::EGLSyncExtensions::EGLSyncExtensions*;
242 mir::graphics::CommandStreamSync::?CommandStreamSync*;
243 mir::graphics::CommandStreamSync::CommandStreamSync*;
244 mir::graphics::CommandStreamSync::CommandStreamSync*;
245 mir::graphics::CommandStreamSync::operator*;
246 mir::graphics::NullCommandSync::?NullCommandSync*;
247 mir::graphics::NullCommandSync::NullCommandSync*;
248 mir::graphics::NullCommandSync::NullCommandSync*;
249 mir::graphics::NullCommandSync::operator*;
250 mir::graphics::EGLSyncFence::?EGLSyncFence*;
251 mir::graphics::EGLSyncFence::EGLSyncFence*;
252 mir::graphics::EGLSyncFence::EGLSyncFence*;
253 mir::graphics::EGLSyncFence::operator*;
240 mir::graphics::EGLContextStore::?EGLContextStore*;254 mir::graphics::EGLContextStore::?EGLContextStore*;
241 mir::graphics::EGLContextStore::EGLContextStore*;255 mir::graphics::EGLContextStore::EGLContextStore*;
242 mir::graphics::EGLContextStore::EGLContextStore*;256 mir::graphics::EGLContextStore::EGLContextStore*;
243257
=== modified file 'src/platforms/android/client/CMakeLists.txt'
--- src/platforms/android/client/CMakeLists.txt 2015-12-11 12:22:15 +0000
+++ src/platforms/android/client/CMakeLists.txt 2016-01-25 17:04:59 +0000
@@ -1,6 +1,8 @@
1include_directories(${client_common_include_dirs})1include_directories(${client_common_include_dirs})
2include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS})2include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS})
3include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps)3include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps)
4include_directories(${CMAKE_SOURCE_DIR}/include/platform)
5include_directories(${CMAKE_SOURCE_DIR}/src/include/platform)
46
5add_definitions(-DANDROID)7add_definitions(-DANDROID)
68
@@ -35,6 +37,7 @@
35 mirclient37 mirclient
36 client_platform_common38 client_platform_common
37 mirsharedandroid-static39 mirsharedandroid-static
40 mirplatform
38 ${LIBHARDWARE_LIBRARIES}41 ${LIBHARDWARE_LIBRARIES}
39)42)
4043
4144
=== modified file 'src/platforms/android/client/gralloc_registrar.cpp'
--- src/platforms/android/client/gralloc_registrar.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/client/gralloc_registrar.cpp 2016-01-25 17:04:59 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir/graphics/android/android_native_buffer.h"19#include "mir/graphics/android/android_native_buffer.h"
20#include "mir/graphics/android/sync_fence.h"20#include "mir/graphics/android/sync_fence.h"
21#include "mir/graphics/egl_sync_fence.h"
21#include "gralloc_registrar.h"22#include "gralloc_registrar.h"
22#include "mir/client_buffer.h"23#include "mir/client_buffer.h"
2324
@@ -82,7 +83,8 @@
82 anwb->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER;83 anwb->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER;
83 anwb->handle = handle.get();84 anwb->handle = handle.get();
8485
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
87 return std::make_shared<mga::AndroidNativeBuffer>(anwb, sync, fence, mga::BufferAccess::read);
86}88}
87}89}
88std::shared_ptr<mg::NativeBuffer> mcla::GrallocRegistrar::register_buffer(90std::shared_ptr<mg::NativeBuffer> mcla::GrallocRegistrar::register_buffer(
8991
=== modified file 'src/platforms/android/server/CMakeLists.txt'
--- src/platforms/android/server/CMakeLists.txt 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/CMakeLists.txt 2016-01-25 17:04:59 +0000
@@ -43,6 +43,7 @@
43 hwc_fallback_gl_renderer.cpp43 hwc_fallback_gl_renderer.cpp
44 ipc_operations.cpp44 ipc_operations.cpp
45 hwc_blanking_control.cpp45 hwc_blanking_control.cpp
46 egl_sync_factory.cpp
46)47)
4748
48add_library(mirplatformgraphicsandroid SHARED49add_library(mirplatformgraphicsandroid SHARED
4950
=== modified file 'src/platforms/android/server/android_alloc_adaptor.cpp'
--- src/platforms/android/server/android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000
@@ -20,7 +20,9 @@
20#include "mir/graphics/android/android_native_buffer.h"20#include "mir/graphics/android/android_native_buffer.h"
21#include "mir/graphics/android/sync_fence.h"21#include "mir/graphics/android/sync_fence.h"
22#include "mir/graphics/android/android_format_conversion-inl.h"22#include "mir/graphics/android/android_format_conversion-inl.h"
23#include "mir/graphics/egl_sync_fence.h"
23#include "android_alloc_adaptor.h"24#include "android_alloc_adaptor.h"
25#include "cmdstream_sync_factory.h"
24#include "device_quirks.h"26#include "device_quirks.h"
2527
26#include <boost/throw_exception.hpp>28#include <boost/throw_exception.hpp>
@@ -48,10 +50,13 @@
48};50};
49}51}
5052
51mga::AndroidAllocAdaptor::AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device,53mga::AndroidAllocAdaptor::AndroidAllocAdaptor(
52 std::shared_ptr<DeviceQuirks> const& quirks)54 std::shared_ptr<struct alloc_device_t> const& alloc_device,
53 : alloc_dev(alloc_device),55 std::shared_ptr<CommandStreamSyncFactory> const& sync_factory,
54 quirks(quirks)56 std::shared_ptr<DeviceQuirks> const& quirks) :
57 alloc_dev(alloc_device),
58 sync_factory(sync_factory),
59 quirks(quirks)
55{60{
56}61}
5762
@@ -94,7 +99,9 @@
94 anwb->format = format;99 anwb->format = format;
95 anwb->usage = usage_flag;100 anwb->usage = usage_flag;
96101
97 return std::make_shared<mga::AndroidNativeBuffer>(anwb, fence, mga::BufferAccess::read);102 return std::make_shared<mga::AndroidNativeBuffer>(anwb,
103 sync_factory->create_command_stream_sync(),
104 fence, mga::BufferAccess::read);
98}105}
99106
100int mga::AndroidAllocAdaptor::convert_to_android_usage(BufferUsage usage)107int mga::AndroidAllocAdaptor::convert_to_android_usage(BufferUsage usage)
101108
=== modified file 'src/platforms/android/server/android_alloc_adaptor.h'
--- src/platforms/android/server/android_alloc_adaptor.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/android_alloc_adaptor.h 2016-01-25 17:04:59 +0000
@@ -31,12 +31,15 @@
31namespace android31namespace android
32{32{
33class DeviceQuirks;33class DeviceQuirks;
34class CommandStreamSyncFactory;
3435
35class AndroidAllocAdaptor : public GraphicAllocAdaptor36class AndroidAllocAdaptor : public GraphicAllocAdaptor
36{37{
37public:38public:
38 explicit AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device,39 explicit AndroidAllocAdaptor(
39 std::shared_ptr<DeviceQuirks> const& quirks);40 std::shared_ptr<struct alloc_device_t> const& alloc_device,
41 std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory,
42 std::shared_ptr<DeviceQuirks> const& quirks);
40 std::shared_ptr<NativeBuffer> alloc_buffer(geometry::Size,43 std::shared_ptr<NativeBuffer> alloc_buffer(geometry::Size,
41 MirPixelFormat, BufferUsage usage);44 MirPixelFormat, BufferUsage usage);
4245
@@ -44,6 +47,7 @@
4447
45private:48private:
46 std::shared_ptr<struct alloc_device_t> alloc_dev;49 std::shared_ptr<struct alloc_device_t> alloc_dev;
50 std::shared_ptr<CommandStreamSyncFactory> const sync_factory;
47 std::shared_ptr<DeviceQuirks> const quirks;51 std::shared_ptr<DeviceQuirks> const quirks;
48 int convert_to_android_usage(BufferUsage usage);52 int convert_to_android_usage(BufferUsage usage);
49};53};
5054
=== modified file 'src/platforms/android/server/android_buffer_allocator.cpp'
--- src/platforms/android/server/android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000
@@ -19,12 +19,14 @@
1919
20#include "mir/graphics/platform.h"20#include "mir/graphics/platform.h"
21#include "mir/graphics/egl_extensions.h"21#include "mir/graphics/egl_extensions.h"
22#include "mir/graphics/egl_sync_fence.h"
22#include "mir/graphics/buffer_properties.h"23#include "mir/graphics/buffer_properties.h"
23#include "mir/graphics/android/sync_fence.h"24#include "mir/graphics/android/sync_fence.h"
24#include "mir/graphics/android/android_native_buffer.h"25#include "mir/graphics/android/android_native_buffer.h"
25#include "android_graphic_buffer_allocator.h"26#include "android_graphic_buffer_allocator.h"
26#include "android_alloc_adaptor.h"27#include "android_alloc_adaptor.h"
27#include "buffer.h"28#include "buffer.h"
29#include "cmdstream_sync_factory.h"
28#include "device_quirks.h"30#include "device_quirks.h"
2931
30#include <boost/throw_exception.hpp>32#include <boost/throw_exception.hpp>
@@ -50,8 +52,11 @@
5052
51}53}
5254
53mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks)55mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(
54 : egl_extensions(std::make_shared<mg::EGLExtensions>())56 std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory,
57 std::shared_ptr<DeviceQuirks> const& quirks)
58 : egl_extensions(std::make_shared<mg::EGLExtensions>()),
59 cmdstream_sync_factory(cmdstream_sync_factory)
55{60{
56 int err;61 int err;
5762
@@ -70,7 +75,7 @@
70 std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(75 std::shared_ptr<struct alloc_device_t> alloc_dev_ptr(
71 alloc_dev,76 alloc_dev,
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);
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));
74}79}
7580
76std::shared_ptr<mg::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer(81std::shared_ptr<mg::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer(
@@ -89,9 +94,10 @@
89 [](ANativeWindowBuffer* buffer){ buffer->common.decRef(&buffer->common); });94 [](ANativeWindowBuffer* buffer){ buffer->common.decRef(&buffer->common); });
90 anwb->common.incRef(&anwb->common);95 anwb->common.incRef(&anwb->common);
9196
97 //TODO: we should have an android platform function for accessing the fence.
92 auto native_handle = std::make_shared<mga::AndroidNativeBuffer>(98 auto native_handle = std::make_shared<mga::AndroidNativeBuffer>(
93 native_window_buffer,99 native_window_buffer,
94 //TODO: we should have an android platform function for accessing the fence.100 cmdstream_sync_factory->create_command_stream_sync(),
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()),
96 mga::BufferAccess::read);102 mga::BufferAccess::read);
97 return std::make_unique<Buffer>(103 return std::make_unique<Buffer>(
98104
=== modified file 'src/platforms/android/server/android_graphic_buffer_allocator.h'
--- src/platforms/android/server/android_graphic_buffer_allocator.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/android_graphic_buffer_allocator.h 2016-01-25 17:04:59 +0000
@@ -39,11 +39,14 @@
3939
40class GraphicAllocAdaptor;40class GraphicAllocAdaptor;
41class DeviceQuirks;41class DeviceQuirks;
42class CommandStreamSyncFactory;
4243
43class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator44class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator
44{45{
45public:46public:
46 AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks);47 AndroidGraphicBufferAllocator(
48 std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory,
49 std::shared_ptr<DeviceQuirks> const& quirks);
4750
48 std::shared_ptr<graphics::Buffer> alloc_buffer(51 std::shared_ptr<graphics::Buffer> alloc_buffer(
49 graphics::BufferProperties const& buffer_properties) override;52 graphics::BufferProperties const& buffer_properties) override;
@@ -61,6 +64,7 @@
61 const hw_module_t *hw_module;64 const hw_module_t *hw_module;
62 std::shared_ptr<GraphicAllocAdaptor> alloc_device;65 std::shared_ptr<GraphicAllocAdaptor> alloc_device;
63 std::shared_ptr<EGLExtensions> const egl_extensions;66 std::shared_ptr<EGLExtensions> const egl_extensions;
67 std::shared_ptr<CommandStreamSyncFactory> const cmdstream_sync_factory;
64};68};
6569
66}70}
6771
=== modified file 'src/platforms/android/server/buffer.cpp'
--- src/platforms/android/server/buffer.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/buffer.cpp 2016-01-25 17:04:59 +0000
@@ -74,6 +74,18 @@
74void mga::Buffer::gl_bind_to_texture()74void mga::Buffer::gl_bind_to_texture()
75{75{
76 std::unique_lock<std::mutex> lk(content_lock);76 std::unique_lock<std::mutex> lk(content_lock);
77 bind(lk);
78 secure_for_render(lk);
79}
80
81void mga::Buffer::bind()
82{
83 std::unique_lock<std::mutex> lk(content_lock);
84 bind(lk);
85}
86
87void mga::Buffer::bind(std::unique_lock<std::mutex> const&)
88{
77 native_buffer->ensure_available_for(mga::BufferAccess::read);89 native_buffer->ensure_available_for(mga::BufferAccess::read);
7890
79 DispContextPair current91 DispContextPair current
@@ -113,10 +125,6 @@
113 }125 }
114126
115 egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);127 egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
116
117 //TODO: we should make use of the android egl fence extension here to update the fence.
118 // if the extension is not available, we should pass out a token that the user
119 // will have to keep until the completion of the gl draw
120}128}
121129
122std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const130std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const
@@ -196,3 +204,14 @@
196{204{
197 return this;205 return this;
198}206}
207
208void mga::Buffer::secure_for_render()
209{
210 std::unique_lock<std::mutex> lk(content_lock);
211 secure_for_render(lk);
212}
213
214void mga::Buffer::secure_for_render(std::unique_lock<std::mutex> const&)
215{
216 native_buffer->lock_for_gpu();
217}
199218
=== modified file 'src/platforms/android/server/buffer.h'
--- src/platforms/android/server/buffer.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/buffer.h 2016-01-25 17:04:59 +0000
@@ -56,6 +56,10 @@
56 geometry::Stride stride() const override;56 geometry::Stride stride() const override;
57 MirPixelFormat pixel_format() const override;57 MirPixelFormat pixel_format() const override;
58 void gl_bind_to_texture() override;58 void gl_bind_to_texture() override;
59 void bind() override;
60 void secure_for_render() override;
61
62
59 //note, you will get the native representation of an android buffer, including63 //note, you will get the native representation of an android buffer, including
60 //the fences associated with the buffer. You must close these fences64 //the fences associated with the buffer. You must close these fences
61 std::shared_ptr<NativeBuffer> native_buffer_handle() const override;65 std::shared_ptr<NativeBuffer> native_buffer_handle() const override;
@@ -66,6 +70,8 @@
66 NativeBufferBase* native_buffer_base() override;70 NativeBufferBase* native_buffer_base() override;
6771
68private:72private:
73 void bind(std::unique_lock<std::mutex> const&);
74 void secure_for_render(std::unique_lock<std::mutex> const&);
69 gralloc_module_t const* hw_module;75 gralloc_module_t const* hw_module;
7076
71 typedef std::pair<EGLDisplay, EGLContext> DispContextPair;77 typedef std::pair<EGLDisplay, EGLContext> DispContextPair;
7278
=== added file 'src/platforms/android/server/cmdstream_sync_factory.h'
--- src/platforms/android/server/cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000
+++ src/platforms/android/server/cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_
20#define MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_
21
22#include <memory>
23namespace mir
24{
25namespace graphics
26{
27class CommandStreamSync;
28namespace android
29{
30class CommandStreamSyncFactory
31{
32public:
33 virtual ~CommandStreamSyncFactory() = default;
34 virtual std::unique_ptr<CommandStreamSync> create_command_stream_sync() = 0;
35protected:
36 CommandStreamSyncFactory() = default;
37 CommandStreamSyncFactory(CommandStreamSyncFactory const&) = delete;
38 CommandStreamSyncFactory& operator=(CommandStreamSyncFactory const&) = delete;
39};
40
41class EGLSyncFactory : public CommandStreamSyncFactory
42{
43 std::unique_ptr<CommandStreamSync> create_command_stream_sync() override;
44};
45}
46}
47}
48#endif /* MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ */
049
=== modified file 'src/platforms/android/server/device_quirks.cpp'
--- src/platforms/android/server/device_quirks.cpp 2015-11-30 18:29:57 +0000
+++ src/platforms/android/server/device_quirks.cpp 2016-01-25 17:04:59 +0000
@@ -62,7 +62,7 @@
6262
63bool clear_fb_context_fence_for(std::string const& device_name)63bool clear_fb_context_fence_for(std::string const& device_name)
64{64{
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";
66}66}
6767
68}68}
@@ -107,6 +107,12 @@
107 return clear_fb_context_fence_;107 return clear_fb_context_fence_;
108}108}
109109
110bool mga::DeviceQuirks::working_egl_sync() const
111{
112 //FIXME: this really should be all powervr devices.
113 return device_name != "mx4";
114}
115
110void mga::DeviceQuirks::add_options(boost::program_options::options_description& config)116void mga::DeviceQuirks::add_options(boost::program_options::options_description& config)
111{117{
112 config.add_options()118 config.add_options()
113119
=== modified file 'src/platforms/android/server/device_quirks.h'
--- src/platforms/android/server/device_quirks.h 2015-11-30 12:36:04 +0000
+++ src/platforms/android/server/device_quirks.h 2016-01-25 17:04:59 +0000
@@ -64,6 +64,7 @@
64 bool gralloc_cannot_be_closed_safely() const;64 bool gralloc_cannot_be_closed_safely() const;
65 int aligned_width(int width) const;65 int aligned_width(int width) const;
66 bool clear_fb_context_fence() const;66 bool clear_fb_context_fence() const;
67 bool working_egl_sync() const;
6768
68 static void add_options(boost::program_options::options_description& config);69 static void add_options(boost::program_options::options_description& config);
6970
7071
=== modified file 'src/platforms/android/server/display_buffer.cpp'
--- src/platforms/android/server/display_buffer.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/display_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -98,6 +98,9 @@
98void mga::DisplayBuffer::swap_buffers()98void mga::DisplayBuffer::swap_buffers()
99{99{
100 layer_list->update_list({}, offset_from_origin);100 layer_list->update_list({}, offset_from_origin);
101 //HWC 1.0 cannot call eglSwapBuffers() on the display context
102 if (display_device->can_swap_buffers())
103 gl_context.swap_buffers();
101}104}
102105
103MirOrientation mga::DisplayBuffer::orientation() const106MirOrientation mga::DisplayBuffer::orientation() const
104107
=== modified file 'src/platforms/android/server/display_component_factory.h'
--- src/platforms/android/server/display_component_factory.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/display_component_factory.h 2016-01-25 17:04:59 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_19#ifndef MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_
20#define MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_20#define MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_
2121
22#include "mir/graphics/egl_sync_fence.h"
22#include "display_device.h"23#include "display_device.h"
23#include "framebuffer_bundle.h"24#include "framebuffer_bundle.h"
24#include <memory>25#include <memory>
@@ -28,6 +29,7 @@
28namespace graphics29namespace graphics
29{30{
30class DisplayConfigurationOutput;31class DisplayConfigurationOutput;
32class CommandStreamSync;
31namespace android33namespace android
32{34{
33class HwcConfiguration;35class HwcConfiguration;
3436
=== modified file 'src/platforms/android/server/display_device.h'
--- src/platforms/android/server/display_device.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/display_device.h 2016-01-25 17:04:59 +0000
@@ -69,6 +69,8 @@
6969
70 virtual std::chrono::milliseconds recommended_sleep() const = 0;70 virtual std::chrono::milliseconds recommended_sleep() const = 0;
7171
72 virtual bool can_swap_buffers() const = 0;
73
72protected:74protected:
73 DisplayDevice() = default;75 DisplayDevice() = default;
74 DisplayDevice& operator=(DisplayDevice const&) = delete;76 DisplayDevice& operator=(DisplayDevice const&) = delete;
7577
=== added file 'src/platforms/android/server/egl_sync_factory.cpp'
--- src/platforms/android/server/egl_sync_factory.cpp 1970-01-01 00:00:00 +0000
+++ src/platforms/android/server/egl_sync_factory.cpp 2016-01-25 17:04:59 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "cmdstream_sync_factory.h"
20#include "mir/graphics/egl_sync_fence.h"
21namespace mg = mir::graphics;
22namespace mga = mir::graphics::android;
23
24std::unique_ptr<mg::CommandStreamSync> mga::EGLSyncFactory::create_command_stream_sync()
25{
26 try
27 {
28 return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>());
29 }
30 catch (std::runtime_error&)
31 {
32 return std::make_unique<NullCommandSync>();
33 }
34}
035
=== modified file 'src/platforms/android/server/fb_device.cpp'
--- src/platforms/android/server/fb_device.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/fb_device.cpp 2016-01-25 17:04:59 +0000
@@ -99,8 +99,6 @@
99 });99 });
100 if (primary_contents == contents.end()) return;100 if (primary_contents == contents.end()) return;
101 auto& context = primary_contents->context;101 auto& context = primary_contents->context;
102
103 context.swap_buffers();
104 auto const& buffer = context.last_rendered_buffer();102 auto const& buffer = context.last_rendered_buffer();
105 auto native_buffer = buffer->native_buffer_handle();103 auto native_buffer = buffer->native_buffer_handle();
106 native_buffer->ensure_available_for(mga::BufferAccess::read);104 native_buffer->ensure_available_for(mga::BufferAccess::read);
@@ -123,3 +121,8 @@
123{121{
124 return std::chrono::milliseconds::zero();122 return std::chrono::milliseconds::zero();
125}123}
124
125bool mga::FBDevice::can_swap_buffers() const
126{
127 return true;
128}
126129
=== modified file 'src/platforms/android/server/fb_device.h'
--- src/platforms/android/server/fb_device.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/fb_device.h 2016-01-25 17:04:59 +0000
@@ -52,6 +52,7 @@
52 bool compatible_renderlist(RenderableList const& renderlist) override;52 bool compatible_renderlist(RenderableList const& renderlist) override;
53 void commit(std::list<DisplayContents> const& contents) override;53 void commit(std::list<DisplayContents> const& contents) override;
54 std::chrono::milliseconds recommended_sleep() const override;54 std::chrono::milliseconds recommended_sleep() const override;
55 bool can_swap_buffers() const override;
5556
56private:57private:
57 std::shared_ptr<framebuffer_device_t> const fb_device;58 std::shared_ptr<framebuffer_device_t> const fb_device;
5859
=== modified file 'src/platforms/android/server/hal_component_factory.cpp'
--- src/platforms/android/server/hal_component_factory.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hal_component_factory.cpp 2016-01-25 17:04:59 +0000
@@ -46,7 +46,8 @@
46 res_factory(res_factory),46 res_factory(res_factory),
47 hwc_report(hwc_report),47 hwc_report(hwc_report),
48 force_backup_display(false),48 force_backup_display(false),
49 num_framebuffers{quirks->num_framebuffers()}49 num_framebuffers{quirks->num_framebuffers()},
50 working_egl_sync(quirks->working_egl_sync())
50{51{
51 try52 try
52 {53 {
@@ -65,6 +66,24 @@
65 }66 }
66}67}
6768
69std::unique_ptr<mg::CommandStreamSync> mga::HalComponentFactory::create_command_stream_sync()
70{
71 if (hwc_version == mga::HwcVersion::hwc10)
72 return std::make_unique<NullCommandSync>();
73
74 if (!working_egl_sync)
75 return std::make_unique<NullCommandSync>();
76
77 try
78 {
79 return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>());
80 }
81 catch (std::runtime_error&)
82 {
83 return std::make_unique<NullCommandSync>();
84 }
85}
86
68std::unique_ptr<mga::FramebufferBundle> mga::HalComponentFactory::create_framebuffers(mg::DisplayConfigurationOutput const& config)87std::unique_ptr<mga::FramebufferBundle> mga::HalComponentFactory::create_framebuffers(mg::DisplayConfigurationOutput const& config)
69{88{
70 return std::unique_ptr<mga::FramebufferBundle>(new mga::Framebuffers(89 return std::unique_ptr<mga::FramebufferBundle>(new mga::Framebuffers(
7190
=== modified file 'src/platforms/android/server/hal_component_factory.h'
--- src/platforms/android/server/hal_component_factory.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hal_component_factory.h 2016-01-25 17:04:59 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_19#ifndef MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_
20#define MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_20#define MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_
2121
22#include "cmdstream_sync_factory.h"
22#include "display_component_factory.h"23#include "display_component_factory.h"
23#include "display_resource_factory.h"24#include "display_resource_factory.h"
2425
@@ -39,7 +40,7 @@
3940
40//NOTE: this should be the only class that inspects the HWC version and assembles41//NOTE: this should be the only class that inspects the HWC version and assembles
41//the components accordingly42//the components accordingly
42class HalComponentFactory : public DisplayComponentFactory43class HalComponentFactory : public DisplayComponentFactory, public CommandStreamSyncFactory
43{44{
44public:45public:
45 HalComponentFactory(46 HalComponentFactory(
@@ -48,6 +49,7 @@
48 std::shared_ptr<HwcReport> const& hwc_report,49 std::shared_ptr<HwcReport> const& hwc_report,
49 std::shared_ptr<DeviceQuirks> const& quirks);50 std::shared_ptr<DeviceQuirks> const& quirks);
5051
52 std::unique_ptr<CommandStreamSync> create_command_stream_sync() override;
51 std::unique_ptr<FramebufferBundle> create_framebuffers(DisplayConfigurationOutput const&) override;53 std::unique_ptr<FramebufferBundle> create_framebuffers(DisplayConfigurationOutput const&) override;
52 std::unique_ptr<DisplayDevice> create_display_device() override;54 std::unique_ptr<DisplayDevice> create_display_device() override;
53 std::unique_ptr<HwcConfiguration> create_hwc_configuration() override;55 std::unique_ptr<HwcConfiguration> create_hwc_configuration() override;
@@ -61,6 +63,7 @@
61 std::shared_ptr<FramebufferBundle> framebuffers;63 std::shared_ptr<FramebufferBundle> framebuffers;
62 bool force_backup_display;64 bool force_backup_display;
63 size_t num_framebuffers;65 size_t num_framebuffers;
66 bool working_egl_sync;
6467
65 std::shared_ptr<HwcWrapper> hwc_wrapper;68 std::shared_ptr<HwcWrapper> hwc_wrapper;
66 std::shared_ptr<framebuffer_device_t> fb_native;69 std::shared_ptr<framebuffer_device_t> fb_native;
6770
=== modified file 'src/platforms/android/server/hwc_device.cpp'
--- src/platforms/android/server/hwc_device.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hwc_device.cpp 2016-01-25 17:04:59 +0000
@@ -106,13 +106,13 @@
106 if (content.list.needs_swapbuffers())106 if (content.list.needs_swapbuffers())
107 {107 {
108 auto rejected_renderables = content.list.rejected_renderables();108 auto rejected_renderables = content.list.rejected_renderables();
109 auto current_context = mir::raii::paired_calls(109 if (!rejected_renderables.empty())
110 [&]{ content.context.make_current(); },110 {
111 [&]{ content.context.release_current(); });111 auto current_context = mir::raii::paired_calls(
112 if (rejected_renderables.empty())112 [&]{ content.context.make_current(); },
113 content.context.swap_buffers();113 [&]{ content.context.release_current(); });
114 else
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);
115 }
116 content.list.setup_fb(content.context.last_rendered_buffer());116 content.list.setup_fb(content.context.last_rendered_buffer());
117 content.list.swap_occurred();117 content.list.swap_occurred();
118 purely_overlays = false;118 purely_overlays = false;
@@ -161,3 +161,8 @@
161{161{
162 onscreen_overlay_buffers.clear();162 onscreen_overlay_buffers.clear();
163}163}
164
165bool mga::HwcDevice::can_swap_buffers() const
166{
167 return true;
168}
164169
=== modified file 'src/platforms/android/server/hwc_device.h'
--- src/platforms/android/server/hwc_device.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hwc_device.h 2016-01-25 17:04:59 +0000
@@ -47,6 +47,7 @@
47 void commit(std::list<DisplayContents> const& contents) override;47 void commit(std::list<DisplayContents> const& contents) override;
48 void content_cleared() override;48 void content_cleared() override;
49 std::chrono::milliseconds recommended_sleep() const override;49 std::chrono::milliseconds recommended_sleep() const override;
50 bool can_swap_buffers() const override;
5051
51private:52private:
52 bool buffer_is_onscreen(Buffer const&) const;53 bool buffer_is_onscreen(Buffer const&) const;
5354
=== modified file 'src/platforms/android/server/hwc_fb_device.cpp'
--- src/platforms/android/server/hwc_fb_device.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hwc_fb_device.cpp 2016-01-25 17:04:59 +0000
@@ -118,3 +118,8 @@
118{118{
119 return std::chrono::milliseconds::zero();119 return std::chrono::milliseconds::zero();
120}120}
121
122bool mga::HwcFbDevice::can_swap_buffers() const
123{
124 return false;
125}
121126
=== modified file 'src/platforms/android/server/hwc_fb_device.h'
--- src/platforms/android/server/hwc_fb_device.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/hwc_fb_device.h 2016-01-25 17:04:59 +0000
@@ -44,6 +44,7 @@
44 bool compatible_renderlist(RenderableList const& renderlist) override;44 bool compatible_renderlist(RenderableList const& renderlist) override;
45 void commit(std::list<DisplayContents> const& contents) override;45 void commit(std::list<DisplayContents> const& contents) override;
46 std::chrono::milliseconds recommended_sleep() const override;46 std::chrono::milliseconds recommended_sleep() const override;
47 bool can_swap_buffers() const override;
4748
48private:49private:
49 void content_cleared() override;50 void content_cleared() override;
5051
=== modified file 'src/platforms/android/server/ipc_operations.cpp'
--- src/platforms/android/server/ipc_operations.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/ipc_operations.cpp 2016-01-25 17:04:59 +0000
@@ -32,6 +32,7 @@
32{32{
33 auto native_buffer = buffer.native_buffer_handle();33 auto native_buffer = buffer.native_buffer_handle();
3434
35 native_buffer->wait_for_unlock_by_gpu();
35 mir::Fd fence_fd(native_buffer->copy_fence());36 mir::Fd fence_fd(native_buffer->copy_fence());
36 if (fence_fd != mir::Fd::invalid)37 if (fence_fd != mir::Fd::invalid)
37 {38 {
3839
=== modified file 'src/platforms/android/server/platform.cpp'
--- src/platforms/android/server/platform.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/platform.cpp 2016-01-25 17:04:59 +0000
@@ -85,11 +85,13 @@
85mga::Platform::Platform(85mga::Platform::Platform(
86 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,86 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
87 std::shared_ptr<mga::DisplayComponentFactory> const& display_buffer_builder,87 std::shared_ptr<mga::DisplayComponentFactory> const& display_buffer_builder,
88 std::shared_ptr<CommandStreamSyncFactory> const& sync_factory,
88 std::shared_ptr<mg::DisplayReport> const& display_report,89 std::shared_ptr<mg::DisplayReport> const& display_report,
89 mga::OverlayOptimization overlay_option,90 mga::OverlayOptimization overlay_option,
90 std::shared_ptr<mga::DeviceQuirks> const& quirks) :91 std::shared_ptr<mga::DeviceQuirks> const& quirks) :
91 buffer_allocator(buffer_allocator),92 buffer_allocator(buffer_allocator),
92 display_buffer_builder(display_buffer_builder),93 display_buffer_builder(display_buffer_builder),
94 sync_factory(sync_factory),
93 display_report(display_report),95 display_report(display_report),
94 quirks(quirks),96 quirks(quirks),
95 overlay_option(overlay_option)97 overlay_option(overlay_option)
@@ -153,10 +155,13 @@
153 auto overlay_option = should_use_overlay_optimization(*options);155 auto overlay_option = should_use_overlay_optimization(*options);
154 hwc_report->report_overlay_optimization(overlay_option);156 hwc_report->report_overlay_optimization(overlay_option);
155 auto display_resource_factory = std::make_shared<mga::ResourceFactory>();157 auto display_resource_factory = std::make_shared<mga::ResourceFactory>();
156 auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks);158 auto sync_factory = std::make_shared<mga::EGLSyncFactory>();
159 auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks);
157 auto component_factory = std::make_shared<mga::HalComponentFactory>(160 auto component_factory = std::make_shared<mga::HalComponentFactory>(
158 buffer_allocator, display_resource_factory, hwc_report, quirks);161 buffer_allocator, display_resource_factory, hwc_report, quirks);
159 return mir::make_module_ptr<mga::Platform>(buffer_allocator, component_factory, display_report, overlay_option, quirks);162
163 return mir::make_module_ptr<mga::Platform>(
164 buffer_allocator, component_factory, component_factory, display_report, overlay_option, quirks);
160}165}
161166
162mir::UniqueModulePtr<mg::Platform> create_guest_platform(167mir::UniqueModulePtr<mg::Platform> create_guest_platform(
@@ -166,10 +171,11 @@
166 mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform);171 mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform);
167 //TODO: actually allow disabling quirks for guest platform172 //TODO: actually allow disabling quirks for guest platform
168 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});173 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});
174 auto sync_factory = std::make_shared<mga::EGLSyncFactory>();
169 //TODO: remove nullptr parameter once platform classes are sorted.175 //TODO: remove nullptr parameter once platform classes are sorted.
170 // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder176 // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder
171 auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks);177 auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks);
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);
173}179}
174180
175void add_graphics_platform_options(181void add_graphics_platform_options(
176182
=== modified file 'src/platforms/android/server/platform.h'
--- src/platforms/android/server/platform.h 2015-12-11 12:22:15 +0000
+++ src/platforms/android/server/platform.h 2016-01-25 17:04:59 +0000
@@ -33,6 +33,7 @@
33class GraphicBufferAllocator;33class GraphicBufferAllocator;
34class FramebufferFactory;34class FramebufferFactory;
35class DisplayComponentFactory;35class DisplayComponentFactory;
36class CommandStreamSyncFactory;
3637
37class Platform : public graphics::Platform38class Platform : public graphics::Platform
38{39{
@@ -40,6 +41,7 @@
40 Platform(41 Platform(
41 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,42 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
42 std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder,43 std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder,
44 std::shared_ptr<CommandStreamSyncFactory> const& sync_factory,
43 std::shared_ptr<DisplayReport> const& display_report,45 std::shared_ptr<DisplayReport> const& display_report,
44 OverlayOptimization overlay_option,46 OverlayOptimization overlay_option,
45 std::shared_ptr<DeviceQuirks> const& quirks);47 std::shared_ptr<DeviceQuirks> const& quirks);
@@ -55,6 +57,7 @@
55private:57private:
56 std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;58 std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;
57 std::shared_ptr<DisplayComponentFactory> const display_buffer_builder;59 std::shared_ptr<DisplayComponentFactory> const display_buffer_builder;
60 std::shared_ptr<CommandStreamSyncFactory> const sync_factory;
58 std::shared_ptr<DisplayReport> const display_report;61 std::shared_ptr<DisplayReport> const display_report;
59 std::shared_ptr<PlatformIpcOperations> const ipc_operations;62 std::shared_ptr<PlatformIpcOperations> const ipc_operations;
60 std::shared_ptr<DeviceQuirks> const quirks;63 std::shared_ptr<DeviceQuirks> const quirks;
6164
=== modified file 'src/platforms/mesa/server/common/gbm_buffer.cpp'
--- src/platforms/mesa/server/common/gbm_buffer.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/mesa/server/common/gbm_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -197,3 +197,12 @@
197{197{
198 return this;198 return this;
199}199}
200
201void mgm::GBMBuffer::secure_for_render()
202{
203}
204
205void mgm::GBMBuffer::bind()
206{
207 gl_bind_to_texture();
208}
200209
=== modified file 'src/platforms/mesa/server/common/gbm_buffer.h'
--- src/platforms/mesa/server/common/gbm_buffer.h 2015-12-11 12:22:15 +0000
+++ src/platforms/mesa/server/common/gbm_buffer.h 2016-01-25 17:04:59 +0000
@@ -67,6 +67,8 @@
67 virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;67 virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;
6868
69 virtual void gl_bind_to_texture() override;69 virtual void gl_bind_to_texture() override;
70 virtual void bind() override;
71 virtual void secure_for_render() override;
7072
71 void write(unsigned char const* pixels, size_t size) override;73 void write(unsigned char const* pixels, size_t size) override;
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;
7375
=== modified file 'src/platforms/mesa/server/common/shm_buffer.cpp'
--- src/platforms/mesa/server/common/shm_buffer.cpp 2015-12-11 12:22:15 +0000
+++ src/platforms/mesa/server/common/shm_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -176,3 +176,12 @@
176{176{
177 return this;177 return this;
178}178}
179
180void mgm::ShmBuffer::bind()
181{
182 gl_bind_to_texture();
183}
184
185void mgm::ShmBuffer::secure_for_render()
186{
187}
179188
=== modified file 'src/platforms/mesa/server/common/shm_buffer.h'
--- src/platforms/mesa/server/common/shm_buffer.h 2015-12-11 12:22:15 +0000
+++ src/platforms/mesa/server/common/shm_buffer.h 2016-01-25 17:04:59 +0000
@@ -51,6 +51,8 @@
51 MirPixelFormat pixel_format() const override;51 MirPixelFormat pixel_format() const override;
52 std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;52 std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override;
53 void gl_bind_to_texture() override;53 void gl_bind_to_texture() override;
54 void bind() override;
55 void secure_for_render() override;
54 void write(unsigned char const* data, size_t size) override;56 void write(unsigned char const* data, size_t size) override;
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;
56 NativeBufferBase* native_buffer_base() override;58 NativeBufferBase* native_buffer_base() override;
5759
=== modified file 'tests/include/mir/test/doubles/mock_android_native_buffer.h'
--- tests/include/mir/test/doubles/mock_android_native_buffer.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/mock_android_native_buffer.h 2016-01-25 17:04:59 +0000
@@ -57,6 +57,8 @@
57 MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess));57 MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess));
58 MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess));58 MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess));
5959
60 MOCK_METHOD0(lock_for_gpu, void());
61 MOCK_METHOD0(wait_for_unlock_by_gpu, void());
60 ANativeWindowBuffer stub_anwb;62 ANativeWindowBuffer stub_anwb;
61 native_handle_t native_handle;63 native_handle_t native_handle;
62};64};
6365
=== modified file 'tests/include/mir/test/doubles/mock_buffer.h'
--- tests/include/mir/test/doubles/mock_buffer.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/mock_buffer.h 2016-01-25 17:04:59 +0000
@@ -72,6 +72,7 @@
72 MOCK_METHOD2(write, void(unsigned char const*, size_t));72 MOCK_METHOD2(write, void(unsigned char const*, size_t));
73 MOCK_METHOD1(read, void(std::function<void(unsigned char const*)> const&));73 MOCK_METHOD1(read, void(std::function<void(unsigned char const*)> const&));
74 MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*());74 MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*());
75 MOCK_METHOD0(used_as_texture, void());
75};76};
7677
77}78}
7879
=== modified file 'tests/include/mir/test/doubles/mock_display_device.h'
--- tests/include/mir/test/doubles/mock_display_device.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/mock_display_device.h 2016-01-25 17:04:59 +0000
@@ -39,6 +39,8 @@
39 {39 {
40 ON_CALL(*this, compatible_renderlist(testing::_))40 ON_CALL(*this, compatible_renderlist(testing::_))
41 .WillByDefault(testing::Return(true));41 .WillByDefault(testing::Return(true));
42 ON_CALL(*this, can_swap_buffers())
43 .WillByDefault(testing::Return(true));
42 }44 }
43 ~MockDisplayDevice() noexcept {}45 ~MockDisplayDevice() noexcept {}
44 MOCK_METHOD0(content_cleared, void());46 MOCK_METHOD0(content_cleared, void());
@@ -46,6 +48,7 @@
46 MOCK_METHOD1(compatible_renderlist, bool(48 MOCK_METHOD1(compatible_renderlist, bool(
47 graphics::RenderableList const&));49 graphics::RenderableList const&));
48 MOCK_CONST_METHOD0(recommended_sleep, std::chrono::milliseconds());50 MOCK_CONST_METHOD0(recommended_sleep, std::chrono::milliseconds());
51 MOCK_CONST_METHOD0(can_swap_buffers, bool());
49};52};
50}53}
51}54}
5255
=== modified file 'tests/include/mir/test/doubles/mock_gl_buffer.h'
--- tests/include/mir/test/doubles/mock_gl_buffer.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/mock_gl_buffer.h 2016-01-25 17:04:59 +0000
@@ -36,6 +36,8 @@
36 using MockBuffer::MockBuffer;36 using MockBuffer::MockBuffer;
3737
38 MOCK_METHOD0(gl_bind_to_texture, void());38 MOCK_METHOD0(gl_bind_to_texture, void());
39 MOCK_METHOD0(secure_for_render, void());
40 MOCK_METHOD0(bind, void());
39};41};
4042
41}43}
4244
=== modified file 'tests/include/mir/test/doubles/stub_android_native_buffer.h'
--- tests/include/mir/test/doubles/stub_android_native_buffer.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/stub_android_native_buffer.h 2016-01-25 17:04:59 +0000
@@ -47,6 +47,9 @@
47 void ensure_available_for(graphics::android::BufferAccess) {}47 void ensure_available_for(graphics::android::BufferAccess) {}
48 void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {}48 void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {}
4949
50 void lock_for_gpu() {};
51 void wait_for_unlock_by_gpu() {};
52
50 ANativeWindowBuffer stub_anwb;53 ANativeWindowBuffer stub_anwb;
51 native_handle_t native_handle;54 native_handle_t native_handle;
52};55};
5356
=== added file 'tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h'
--- tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_
20#define MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_
21
22#include "src/platforms/android/server/cmdstream_sync_factory.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30struct StubCmdStreamSyncFactory : graphics::android::CommandStreamSyncFactory
31{
32 std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync() override
33 {
34 return std::make_unique<graphics::NullCommandSync>();
35 }
36};
37}
38}
39}
40
41#endif /* MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ */
042
=== modified file 'tests/include/mir/test/doubles/stub_display_builder.h'
--- tests/include/mir/test/doubles/stub_display_builder.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/stub_display_builder.h 2016-01-25 17:04:59 +0000
@@ -126,6 +126,11 @@
126 config = std::move(mock_config); 126 config = std::move(mock_config);
127 }127 }
128128
129 std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync()
130 {
131 return std::make_unique<graphics::NullCommandSync>();
132 }
133
129 geometry::Size sz;134 geometry::Size sz;
130 std::unique_ptr<graphics::android::HwcConfiguration> config;135 std::unique_ptr<graphics::android::HwcConfiguration> config;
131};136};
132137
=== modified file 'tests/include/mir/test/doubles/stub_gl_buffer.h'
--- tests/include/mir/test/doubles/stub_gl_buffer.h 2015-12-11 12:22:15 +0000
+++ tests/include/mir/test/doubles/stub_gl_buffer.h 2016-01-25 17:04:59 +0000
@@ -36,6 +36,8 @@
36 using StubBuffer::StubBuffer;36 using StubBuffer::StubBuffer;
3737
38 void gl_bind_to_texture() {}38 void gl_bind_to_texture() {}
39 void bind() {}
40 void secure_for_render() {}
39};41};
4042
41}43}
4244
=== modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp'
--- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2015-12-11 12:22:15 +0000
+++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2016-01-25 17:04:59 +0000
@@ -77,6 +77,9 @@
77 }77 }
78 }78 }
7979
80 void bind() override { gl_bind_to_texture(); }
81 void secure_for_render() override {}
82
80private:83private:
81 std::thread::id creation_thread_id;84 std::thread::id creation_thread_id;
82};85};
8386
=== modified file 'tests/unit-tests/gl/test_gl_texture_cache.cpp'
--- tests/unit-tests/gl/test_gl_texture_cache.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/gl/test_gl_texture_cache.cpp 2016-01-25 17:04:59 +0000
@@ -17,7 +17,7 @@
17 * Originally by: Daniel van Vugt <daniel.van.vugt@canonical.com>17 * Originally by: Daniel van Vugt <daniel.van.vugt@canonical.com>
18 */18 */
1919
20#include "mir/gl/recently_used_cache.h"20#include "src/gl/recently_used_cache.h"
21#include "mir/test/doubles/mock_gl_buffer.h"21#include "mir/test/doubles/mock_gl_buffer.h"
22#include "mir/test/doubles/mock_renderable.h"22#include "mir/test/doubles/mock_renderable.h"
23#include "mir/test/doubles/mock_gl.h"23#include "mir/test/doubles/mock_gl.h"
@@ -75,6 +75,7 @@
75 EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture));75 EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture));
76 EXPECT_CALL(*mock_buffer,gl_bind_to_texture())76 EXPECT_CALL(*mock_buffer,gl_bind_to_texture())
77 .Times(0);77 .Times(0);
78 EXPECT_CALL(*mock_buffer, used_as_texture());
7879
79 // Frame 3: Texture found in cache but refreshed with new buffer80 // Frame 3: Texture found in cache but refreshed with new buffer
80 EXPECT_CALL(*mock_buffer, id())81 EXPECT_CALL(*mock_buffer, id())
@@ -92,6 +93,7 @@
92 EXPECT_CALL(*mock_buffer, id())93 EXPECT_CALL(*mock_buffer, id())
93 .WillOnce(Return(mg::BufferID(456)));94 .WillOnce(Return(mg::BufferID(456)));
94 EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture));95 EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture));
96 EXPECT_CALL(*mock_buffer, used_as_texture());
9597
96 EXPECT_CALL(mock_gl, glDeleteTextures(1, Pointee(stub_texture)));98 EXPECT_CALL(mock_gl, glDeleteTextures(1, Pointee(stub_texture)));
9799
98100
=== modified file 'tests/unit-tests/gl/test_program_factory.cpp'
--- tests/unit-tests/gl/test_program_factory.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/gl/test_program_factory.cpp 2016-01-25 17:04:59 +0000
@@ -24,7 +24,7 @@
24#include <gtest/gtest.h>24#include <gtest/gtest.h>
25#include <gmock/gmock.h>25#include <gmock/gmock.h>
26#include <mir/geometry/rectangle.h>26#include <mir/geometry/rectangle.h>
27#include "src/gl/default_program_factory.h"27#include "mir/gl/default_program_factory.h"
28#include <mir/test/fake_shared.h>28#include <mir/test/fake_shared.h>
29#include <mir/test/doubles/mock_buffer.h>29#include <mir/test/doubles/mock_buffer.h>
30#include <mir/test/doubles/mock_renderable.h>30#include <mir/test/doubles/mock_renderable.h>
3131
=== modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp'
--- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000
@@ -17,11 +17,13 @@
17 */17 */
1818
19#include "src/platforms/android/server/android_alloc_adaptor.h"19#include "src/platforms/android/server/android_alloc_adaptor.h"
20#include "src/platforms/android/server/cmdstream_sync_factory.h"
20#include "src/platforms/android/server/device_quirks.h"21#include "src/platforms/android/server/device_quirks.h"
21#include "mir/graphics/android/native_buffer.h"22#include "mir/graphics/android/native_buffer.h"
2223
23#include "mir/test/doubles/mock_android_alloc_device.h"24#include "mir/test/doubles/mock_android_alloc_device.h"
24#include "mir/test/doubles/mock_alloc_adaptor.h"25#include "mir/test/doubles/mock_alloc_adaptor.h"
26#include "mir/test/doubles/mock_egl.h"
2527
26#include <gtest/gtest.h>28#include <gtest/gtest.h>
27#include <gmock/gmock.h>29#include <gmock/gmock.h>
@@ -32,7 +34,6 @@
32namespace geom = mir::geometry;34namespace geom = mir::geometry;
33namespace mtd = mir::test::doubles;35namespace mtd = mir::test::doubles;
3436
35
36class AdaptorICSTest : public ::testing::Test37class AdaptorICSTest : public ::testing::Test
37{38{
38public:39public:
@@ -48,13 +49,15 @@
48 mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocDevice>>();49 mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocDevice>>();
4950
50 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});51 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});
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);
5253
53 pf = mir_pixel_format_abgr_8888;54 pf = mir_pixel_format_abgr_8888;
54 size = geom::Size{300, 200};55 size = geom::Size{300, 200};
55 usage = mga::BufferUsage::use_hardware;56 usage = mga::BufferUsage::use_hardware;
56 }57 }
5758
59 mtd::MockEGL mock_egl;
60 std::shared_ptr<mga::CommandStreamSyncFactory> sync_factory{std::make_shared<mga::EGLSyncFactory>()};
58 std::shared_ptr<mtd::MockAllocDevice> mock_alloc_device;61 std::shared_ptr<mtd::MockAllocDevice> mock_alloc_device;
59 std::shared_ptr<mga::AndroidAllocAdaptor> alloc_adaptor;62 std::shared_ptr<mga::AndroidAllocAdaptor> alloc_adaptor;
6063
6164
=== modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp'
--- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000
@@ -23,6 +23,8 @@
23#include "mir/graphics/buffer.h"23#include "mir/graphics/buffer.h"
24#include "mir/graphics/android/native_buffer.h"24#include "mir/graphics/android/native_buffer.h"
2525
26#include "mir/test/doubles/stub_display_builder.h"
27#include "mir/test/doubles/stub_cmdstream_sync_factory.h"
26#include "mir/test/doubles/mock_egl.h"28#include "mir/test/doubles/mock_egl.h"
2729
28#include <hardware/gralloc.h>30#include <hardware/gralloc.h>
@@ -43,7 +45,9 @@
4345
44 testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;46 testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;
45 testing::NiceMock<mtd::MockEGL> mock_egl;47 testing::NiceMock<mtd::MockEGL> mock_egl;
46 mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})};48 mga::AndroidGraphicBufferAllocator allocator{
49 std::make_shared<mtd::StubCmdStreamSyncFactory>(),
50 std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})};
47};51};
4852
49TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module)53TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module)
@@ -54,7 +58,7 @@
54 .Times(1);58 .Times(1);
5559
56 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});60 auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{});
57 mga::AndroidGraphicBufferAllocator allocator{quirks};61 mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mtd::StubCmdStreamSyncFactory>(), quirks};
58}62}
5963
60TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats)64TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats)
6165
=== modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp'
--- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2016-01-25 17:04:59 +0000
@@ -289,7 +289,7 @@
289289
290290
291/* binding tests */291/* binding tests */
292TEST_F(AndroidBufferBinding, buffer_calls_binding_extension)292TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_and_notes_gpu_usage)
293{293{
294 using namespace testing;294 using namespace testing;
295 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))295 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))
@@ -298,11 +298,23 @@
298 buffer.gl_bind_to_texture();298 buffer.gl_bind_to_texture();
299}299}
300300
301TEST_F(AndroidBufferBinding, notes_gpu_usage_when_explicity_told)
302{
303 using namespace testing;
304 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))
305 .Times(0);
306 EXPECT_CALL(*mock_native_buffer, lock_for_gpu());
307 mga::Buffer buffer(gralloc, mock_native_buffer, extensions);
308 buffer.secure_for_render();
309}
310
301TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time)311TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time)
302{312{
303 using namespace testing;313 using namespace testing;
304 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))314 EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _))
305 .Times(Exactly(3));315 .Times(Exactly(3));
316 EXPECT_CALL(*mock_native_buffer, lock_for_gpu())
317 .Times(Exactly(3));
306318
307 mga::Buffer buffer(gralloc, mock_native_buffer, extensions);319 mga::Buffer buffer(gralloc, mock_native_buffer, extensions);
308 buffer.gl_bind_to_texture();320 buffer.gl_bind_to_texture();
309321
=== modified file 'tests/unit-tests/graphics/android/test_display_buffer.cpp'
--- tests/unit-tests/graphics/android/test_display_buffer.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_display_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -235,6 +235,21 @@
235 db.release_current();235 db.release_current();
236}236}
237237
238//In HWC 1.0 notably we cannot eglSwapBuffers on the fb context.
239TEST_F(DisplayBuffer, swaps_when_allowed)
240{
241 using namespace testing;
242 EXPECT_CALL(*mock_display_device, can_swap_buffers())
243 .Times(2)
244 .WillOnce(Return(true))
245 .WillOnce(Return(false));
246 EXPECT_CALL(mock_egl, eglSwapBuffers(dummy_display, mock_egl.fake_egl_surface))
247 .Times(1);
248
249 db.swap_buffers();
250 db.swap_buffers();
251}
252
238TEST_F(DisplayBuffer, notifies_list_that_content_is_cleared)253TEST_F(DisplayBuffer, notifies_list_that_content_is_cleared)
239{254{
240 EXPECT_CALL(*mock_display_device, content_cleared())255 EXPECT_CALL(*mock_display_device, content_cleared())
241256
=== modified file 'tests/unit-tests/graphics/android/test_display_hotplug.cpp'
--- tests/unit-tests/graphics/android/test_display_hotplug.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_display_hotplug.cpp 2016-01-25 17:04:59 +0000
@@ -103,6 +103,11 @@
103 new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, geom::Displacement{}));103 new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, geom::Displacement{}));
104 }104 }
105105
106 std::unique_ptr<mg::CommandStreamSync> create_command_stream_sync()
107 {
108 return nullptr;
109 }
110
106 StubHwcConfig stub_config;111 StubHwcConfig stub_config;
107 };112 };
108113
109114
=== modified file 'tests/unit-tests/graphics/android/test_fb_device.cpp'
--- tests/unit-tests/graphics/android/test_fb_device.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_fb_device.cpp 2016-01-25 17:04:59 +0000
@@ -72,6 +72,12 @@
72 mga::DisplayName primary{mga::DisplayName::primary};72 mga::DisplayName primary{mga::DisplayName::primary};
73};73};
7474
75TEST_F(FBDevice, reports_it_can_swap)
76{
77 mga::FBDevice fbdev(fb_hal_mock);
78 EXPECT_TRUE(fbdev.can_swap_buffers());
79}
80
75TEST_F(FBDevice, rejects_renderables)81TEST_F(FBDevice, rejects_renderables)
76{82{
77 mg::RenderableList renderlist83 mg::RenderableList renderlist
@@ -92,6 +98,8 @@
92 .WillOnce(Return(-1))98 .WillOnce(Return(-1))
93 .WillOnce(Return(0));99 .WillOnce(Return(0));
94100
101 EXPECT_CALL(mock_context, swap_buffers())
102 .Times(0);
95 mga::FBDevice fbdev(fb_hal_mock);103 mga::FBDevice fbdev(fb_hal_mock);
96 mga::DisplayContents content{primary, list, geom::Displacement{}, mock_context, stub_compositor};104 mga::DisplayContents content{primary, list, geom::Displacement{}, mock_context, stub_compositor};
97105
98106
=== modified file 'tests/unit-tests/graphics/android/test_hwc_device.cpp'
--- tests/unit-tests/graphics/android/test_hwc_device.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_hwc_device.cpp 2016-01-25 17:04:59 +0000
@@ -120,6 +120,12 @@
120};120};
121}121}
122122
123TEST_F(HwcDevice, reports_it_can_swap)
124{
125 mga::HwcDevice device(mock_device);
126 EXPECT_TRUE(device.can_swap_buffers());
127}
128
123TEST_F(HwcDevice, prepares_a_skip_and_target_layer_by_default)129TEST_F(HwcDevice, prepares_a_skip_and_target_layer_by_default)
124{130{
125 using namespace testing;131 using namespace testing;
@@ -174,7 +180,7 @@
174 device.commit({content});180 device.commit({content});
175}181}
176182
177TEST_F(HwcDevice, swaps_buffers_directly_when_no_renderables)183TEST_F(HwcDevice, does_not_swap_buffers_when_no_renderables)
178{184{
179 using namespace testing;185 using namespace testing;
180 mtd::MockRenderableListCompositor mock_compositor;186 mtd::MockRenderableListCompositor mock_compositor;
@@ -184,7 +190,8 @@
184190
185 EXPECT_CALL(mock_compositor, render(_,_,_))191 EXPECT_CALL(mock_compositor, render(_,_,_))
186 .Times(0);192 .Times(0);
187 EXPECT_CALL(mock_context, swap_buffers());193 EXPECT_CALL(mock_context, swap_buffers())
194 .Times(0);
188195
189 mga::LayerList list(layer_adapter, {}, geom::Displacement{});196 mga::LayerList list(layer_adapter, {}, geom::Displacement{});
190 mga::DisplayContents content{primary, list, offset, mock_context, mock_compositor};197 mga::DisplayContents content{primary, list, offset, mock_context, mock_compositor};
@@ -465,8 +472,6 @@
465 NiceMock<mtd::MockSwappingGLContext> mock_context;472 NiceMock<mtd::MockSwappingGLContext> mock_context;
466 ON_CALL(mock_context, last_rendered_buffer())473 ON_CALL(mock_context, last_rendered_buffer())
467 .WillByDefault(Return(stub_fb_buffer));474 .WillByDefault(Return(stub_fb_buffer));
468 EXPECT_CALL(mock_context, swap_buffers())
469 .Times(AtLeast(5));
470475
471 mga::LayerList list(layer_adapter, {}, geom::Displacement{});476 mga::LayerList list(layer_adapter, {}, geom::Displacement{});
472 mtd::MockRenderableListCompositor mock_compositor;477 mtd::MockRenderableListCompositor mock_compositor;
@@ -844,10 +849,6 @@
844849
845 InSequence seq;850 InSequence seq;
846 EXPECT_CALL(*mock_device, prepare(MatchesLists(expected_list, expected_list)));851 EXPECT_CALL(*mock_device, prepare(MatchesLists(expected_list, expected_list)));
847 EXPECT_CALL(mock_context1, make_current());
848 EXPECT_CALL(mock_context1, release_current());
849 EXPECT_CALL(mock_context2, make_current());
850 EXPECT_CALL(mock_context2, release_current());
851 EXPECT_CALL(*mock_device, set(MatchesLists(expected_list, expected_list)));852 EXPECT_CALL(*mock_device, set(MatchesLists(expected_list, expected_list)));
852853
853 mga::LayerList primary_list(layer_adapter, {}, geom::Displacement{});854 mga::LayerList primary_list(layer_adapter, {}, geom::Displacement{});
854855
=== modified file 'tests/unit-tests/graphics/android/test_hwc_fb_device.cpp'
--- tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2016-01-25 17:04:59 +0000
@@ -104,6 +104,12 @@
104};104};
105}105}
106106
107TEST_F(HwcFbDevice, reports_it_cannot_swap)
108{
109 mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device);
110 EXPECT_FALSE(device.can_swap_buffers());
111}
112
107TEST_F(HwcFbDevice, hwc10_subscribes_to_vsync_events)113TEST_F(HwcFbDevice, hwc10_subscribes_to_vsync_events)
108{114{
109 using namespace testing;115 using namespace testing;
110116
=== modified file 'tests/unit-tests/graphics/android/test_native_buffer.cpp'
--- tests/unit-tests/graphics/android/test_native_buffer.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_native_buffer.cpp 2016-01-25 17:04:59 +0000
@@ -17,25 +17,41 @@
17 */17 */
1818
19#include "mir/graphics/android/android_native_buffer.h"19#include "mir/graphics/android/android_native_buffer.h"
20#include "mir/graphics/egl_sync_fence.h"
20#include "mir/test/doubles/mock_fence.h"21#include "mir/test/doubles/mock_fence.h"
21#include <memory>22#include <memory>
22#include <gtest/gtest.h>23#include <gtest/gtest.h>
2324
24namespace mtd=mir::test::doubles;25namespace mtd=mir::test::doubles;
25namespace mga=mir::graphics::android;26namespace mga=mir::graphics::android;
27using namespace testing;
28
29namespace
30{
31struct MockCommandStreamSync : public mir::graphics::CommandStreamSync
32{
33 MOCK_METHOD0(raise, void());
34 MOCK_METHOD0(reset, void());
35 MOCK_METHOD1(wait_for, bool(std::chrono::nanoseconds));
36};
37}
2638
27struct NativeBuffer : public testing::Test39struct NativeBuffer : public testing::Test
28{40{
29 NativeBuffer() :41 NativeBuffer() :
30 a_native_window_buffer(std::make_shared<ANativeWindowBuffer>()),42 a_native_window_buffer(std::make_shared<ANativeWindowBuffer>()),
31 mock_fence(std::make_shared<testing::NiceMock<mtd::MockFence>>()),43 mock_fence(std::make_shared<testing::NiceMock<mtd::MockFence>>()),
32 fake_fd{48484}44 fake_fd{48484},
45 timeout{std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(2))},
46 mock_cmdstream_sync{std::make_shared<MockCommandStreamSync>()}
33 {47 {
34 }48 }
3549
36 std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer;50 std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer;
37 std::shared_ptr<mtd::MockFence> mock_fence;51 std::shared_ptr<mtd::MockFence> mock_fence;
38 int fake_fd;52 int fake_fd;
53 std::chrono::nanoseconds timeout;
54 std::shared_ptr<MockCommandStreamSync> mock_cmdstream_sync;
39};55};
4056
41TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks)57TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks)
@@ -88,7 +104,7 @@
88{104{
89 EXPECT_CALL(*mock_fence, wait())105 EXPECT_CALL(*mock_fence, wait())
90 .Times(0);106 .Times(0);
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);
92 buffer.ensure_available_for(mga::BufferAccess::read);108 buffer.ensure_available_for(mga::BufferAccess::read);
93}109}
94110
@@ -96,7 +112,7 @@
96{112{
97 EXPECT_CALL(*mock_fence, wait())113 EXPECT_CALL(*mock_fence, wait())
98 .Times(1);114 .Times(1);
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);
100 buffer.ensure_available_for(mga::BufferAccess::read);116 buffer.ensure_available_for(mga::BufferAccess::read);
101}117}
102118
@@ -104,7 +120,7 @@
104{120{
105 EXPECT_CALL(*mock_fence, wait())121 EXPECT_CALL(*mock_fence, wait())
106 .Times(1);122 .Times(1);
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);
108 buffer.ensure_available_for(mga::BufferAccess::write);124 buffer.ensure_available_for(mga::BufferAccess::write);
109}125}
110126
@@ -112,7 +128,7 @@
112{128{
113 EXPECT_CALL(*mock_fence, wait())129 EXPECT_CALL(*mock_fence, wait())
114 .Times(1);130 .Times(1);
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);
116 buffer.ensure_available_for(mga::BufferAccess::write);132 buffer.ensure_available_for(mga::BufferAccess::write);
117}133}
118134
@@ -120,7 +136,7 @@
120{136{
121 EXPECT_CALL(*mock_fence, merge_with(fake_fd))137 EXPECT_CALL(*mock_fence, merge_with(fake_fd))
122 .Times(1);138 .Times(1);
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);
124 buffer.update_usage(fake_fd, mga::BufferAccess::write);140 buffer.update_usage(fake_fd, mga::BufferAccess::write);
125}141}
126142
@@ -129,7 +145,7 @@
129 EXPECT_CALL(*mock_fence, wait())145 EXPECT_CALL(*mock_fence, wait())
130 .Times(3);146 .Times(3);
131147
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);
133 buffer.ensure_available_for(mga::BufferAccess::write);149 buffer.ensure_available_for(mga::BufferAccess::write);
134 buffer.ensure_available_for(mga::BufferAccess::read);150 buffer.ensure_available_for(mga::BufferAccess::read);
135151
@@ -137,3 +153,30 @@
137 buffer.ensure_available_for(mga::BufferAccess::write);153 buffer.ensure_available_for(mga::BufferAccess::write);
138 buffer.ensure_available_for(mga::BufferAccess::read);154 buffer.ensure_available_for(mga::BufferAccess::read);
139}155}
156
157TEST_F(NativeBuffer, raises_egl_fence)
158{
159 mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read);
160
161 EXPECT_CALL(*mock_cmdstream_sync, raise());
162 buffer.lock_for_gpu();
163}
164
165TEST_F(NativeBuffer, clears_egl_fence_successfully)
166{
167 mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read);
168 EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout))
169 .Times(1)
170 .WillOnce(Return(true));
171 buffer.wait_for_unlock_by_gpu();
172}
173
174//not really helpful to throw if the timeout fails
175TEST_F(NativeBuffer, ignores_clears_egl_fence_failure)
176{
177 mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read);
178 EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout))
179 .Times(1)
180 .WillOnce(Return(false));
181 buffer.wait_for_unlock_by_gpu();
182}
140183
=== modified file 'tests/unit-tests/graphics/android/test_platform.cpp'
--- tests/unit-tests/graphics/android/test_platform.cpp 2015-12-11 12:22:15 +0000
+++ tests/unit-tests/graphics/android/test_platform.cpp 2016-01-25 17:04:59 +0000
@@ -26,6 +26,7 @@
26#include "mir/test/doubles/mock_display_report.h"26#include "mir/test/doubles/mock_display_report.h"
27#include "mir/test/doubles/mock_egl.h"27#include "mir/test/doubles/mock_egl.h"
28#include "mir/test/doubles/stub_display_builder.h"28#include "mir/test/doubles/stub_display_builder.h"
29#include "mir/test/doubles/stub_cmdstream_sync_factory.h"
29#include "mir/test/doubles/fd_matcher.h"30#include "mir/test/doubles/fd_matcher.h"
30#include "mir/test/fake_shared.h"31#include "mir/test/fake_shared.h"
31#include "mir/test/doubles/mock_android_native_buffer.h"32#include "mir/test/doubles/mock_android_native_buffer.h"
@@ -54,6 +55,7 @@
54 using namespace testing;55 using namespace testing;
5556
56 stub_display_builder = std::make_shared<mtd::StubDisplayBuilder>();57 stub_display_builder = std::make_shared<mtd::StubDisplayBuilder>();
58 stub_sync_factory = std::make_shared<mtd::StubCmdStreamSyncFactory>();
57 stub_display_report = mr::null_display_report();59 stub_display_report = mr::null_display_report();
58 stride = geom::Stride(300*4);60 stride = geom::Stride(300*4);
5961
@@ -86,6 +88,7 @@
86 std::shared_ptr<mtd::MockAndroidNativeBuffer> native_buffer;88 std::shared_ptr<mtd::MockAndroidNativeBuffer> native_buffer;
87 std::shared_ptr<mtd::StubBufferAllocator> stub_buffer_allocator;89 std::shared_ptr<mtd::StubBufferAllocator> stub_buffer_allocator;
88 std::shared_ptr<mtd::StubDisplayBuilder> stub_display_builder;90 std::shared_ptr<mtd::StubDisplayBuilder> stub_display_builder;
91 std::shared_ptr<mtd::StubCmdStreamSyncFactory> stub_sync_factory;
89 std::shared_ptr<mtd::MockBuffer> mock_buffer;92 std::shared_ptr<mtd::MockBuffer> mock_buffer;
90 std::shared_ptr<native_handle_t> native_buffer_handle;93 std::shared_ptr<native_handle_t> native_buffer_handle;
91 std::shared_ptr<mg::DisplayReport> stub_display_report;94 std::shared_ptr<mg::DisplayReport> stub_display_report;
@@ -99,10 +102,12 @@
99{102{
100 using namespace ::testing;103 using namespace ::testing;
101 int fake_fence{333};104 int fake_fence{333};
105 EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu());
102 EXPECT_CALL(*native_buffer, copy_fence())106 EXPECT_CALL(*native_buffer, copy_fence())
103 .WillOnce(Return(fake_fence));107 .WillOnce(Return(fake_fence));
104108
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,
110 stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks);
106111
107 mtd::MockBufferIpcMessage mock_ipc_msg;112 mtd::MockBufferIpcMessage mock_ipc_msg;
108 int offset = 0;113 int offset = 0;
@@ -130,10 +135,12 @@
130TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_full_ipc_without_fence)135TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_full_ipc_without_fence)
131{136{
132 using namespace ::testing;137 using namespace ::testing;
138 EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu());
133 EXPECT_CALL(*native_buffer, copy_fence())139 EXPECT_CALL(*native_buffer, copy_fence())
134 .WillOnce(Return(-1));140 .WillOnce(Return(-1));
135141
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,
143 stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks);
137144
138 mtd::MockBufferIpcMessage mock_ipc_msg;145 mtd::MockBufferIpcMessage mock_ipc_msg;
139 int offset = 0;146 int offset = 0;
@@ -169,10 +176,12 @@
169TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_nested)176TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_nested)
170{177{
171 using namespace ::testing;178 using namespace ::testing;
179 EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu());
172 EXPECT_CALL(*native_buffer, copy_fence())180 EXPECT_CALL(*native_buffer, copy_fence())
173 .WillOnce(Return(-1));181 .WillOnce(Return(-1));
174182
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,
184 stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks);
176185
177 mtd::MockBufferIpcMessage mock_ipc_msg;186 mtd::MockBufferIpcMessage mock_ipc_msg;
178 int offset = 0;187 int offset = 0;
@@ -207,7 +216,8 @@
207 using namespace ::testing;216 using namespace ::testing;
208217
209 int fake_fence{33};218 int fake_fence{33};
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,
220 stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks);
211 auto ipc_ops = platform.make_ipc_operations();221 auto ipc_ops = platform.make_ipc_operations();
212222
213 mtd::MockBufferIpcMessage mock_ipc_msg;223 mtd::MockBufferIpcMessage mock_ipc_msg;
@@ -234,6 +244,7 @@
234 mga::Platform platform(244 mga::Platform platform(
235 std::make_shared<mtd::StubBufferAllocator>(),245 std::make_shared<mtd::StubBufferAllocator>(),
236 std::make_shared<mtd::StubDisplayBuilder>(),246 std::make_shared<mtd::StubDisplayBuilder>(),
247 std::make_shared<mtd::StubCmdStreamSyncFactory>(),
237 mr::null_display_report(),248 mr::null_display_report(),
238 mga::OverlayOptimization::enabled,249 mga::OverlayOptimization::enabled,
239 std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}));250 std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}));

Subscribers

People subscribed via source and target branches

to all changes: