Mir

Merge lp:~cemil-azizoglu/mir/use_egl_native_window into lp:mir

Proposed by Cemil Azizoglu
Status: Superseded
Proposed branch: lp:~cemil-azizoglu/mir/use_egl_native_window
Merge into: lp:mir
Diff against target: 649 lines (+210/-37)
24 files modified
.bzrignore (+1/-0)
src/include/client/mir/client_platform.h (+2/-1)
src/platforms/android/client/android_client_platform.cpp (+15/-4)
src/platforms/android/client/android_client_platform.h (+2/-1)
src/platforms/android/client/egl_native_surface_interpreter.h (+17/-0)
src/platforms/android/common/mir_native_window.cpp (+6/-0)
src/platforms/android/include/mir_native_window.h (+2/-1)
src/platforms/eglstream-kms/client/client_platform.cpp (+5/-1)
src/platforms/eglstream-kms/client/client_platform.h (+1/-0)
src/platforms/mesa/client/client_platform.cpp (+7/-1)
src/platforms/mesa/client/client_platform.h (+2/-1)
src/platforms/mesa/client/native_surface.cpp (+19/-5)
src/platforms/mesa/client/native_surface.h (+3/-2)
src/platforms/mesa/include/native_buffer.h (+2/-0)
tests/acceptance-tests/throwback/test_client_library_errors.cpp (+4/-0)
tests/include/mir_test_framework/stub_client_platform_factory.h (+1/-0)
tests/mir_test_framework/stub_client_platform_factory.cpp (+4/-0)
tests/unit-tests/client/test_client_buffer_stream.cpp (+3/-0)
tests/unit-tests/client/test_mir_connection.cpp (+1/-0)
tests/unit-tests/platforms/android/CMakeLists.txt (+5/-0)
tests/unit-tests/platforms/android/client/test_android_client_platform.cpp (+15/-0)
tests/unit-tests/platforms/android/client/test_android_native_window.cpp (+16/-0)
tests/unit-tests/platforms/mesa/client/test_client_platform.cpp (+14/-0)
tests/unit-tests/platforms/mesa/client/test_native_surface.cpp (+63/-20)
To merge this branch: bzr merge lp:~cemil-azizoglu/mir/use_egl_native_window
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+304291@code.launchpad.net

This proposal has been superseded by a proposal from 2016-09-02.

Description of the change

Introduce use_egl_native_window()

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-08-26 19:50:25 +0000
+++ .bzrignore 2016-09-01 23:11:16 +0000
@@ -1,3 +1,4 @@
1.idea1.idea
2.project2.project
3include/server/mir/version.h3include/server/mir/version.h
4build-*
45
=== modified file 'src/include/client/mir/client_platform.h'
--- src/include/client/mir/client_platform.h 2016-05-03 06:55:25 +0000
+++ src/include/client/mir/client_platform.h 2016-09-01 23:11:16 +0000
@@ -63,7 +63,8 @@
63 virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0;63 virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0;
64 // EGLNativeWindowType differs between platforms, so can't reasonably be used in the64 // EGLNativeWindowType differs between platforms, so can't reasonably be used in the
65 // platform-independent interface.65 // platform-independent interface.
66 virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) = 0;66 virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) = 0;
67 virtual void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) = 0;
67 virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0;68 virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0;
68 virtual MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const = 0;69 virtual MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const = 0;
69 virtual MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const = 0;70 virtual MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const = 0;
7071
=== modified file 'src/platforms/android/client/android_client_platform.cpp'
--- src/platforms/android/client/android_client_platform.cpp 2016-07-20 04:54:07 +0000
+++ src/platforms/android/client/android_client_platform.cpp 2016-09-01 23:11:16 +0000
@@ -57,7 +57,13 @@
57 return std::make_shared<mcla::AndroidClientBufferFactory>(registrar);57 return std::make_shared<mcla::AndroidClientBufferFactory>(registrar);
58}58}
5959
60std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface *surface)60void mcla::AndroidClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface)
61{
62 auto anw = std::static_pointer_cast<mga::MirNativeWindow>(native_window);
63 anw->use_native_surface(std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface));
64}
65
66std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface* surface)
61{67{
62 auto log = getenv("MIR_CLIENT_ANDROID_WINDOW_REPORT");68 auto log = getenv("MIR_CLIENT_ANDROID_WINDOW_REPORT");
63 std::shared_ptr<mga::NativeWindowReport> report;69 std::shared_ptr<mga::NativeWindowReport> report;
@@ -67,9 +73,14 @@
67 std::make_shared<mir::logging::DumbConsoleLogger>());73 std::make_shared<mir::logging::DumbConsoleLogger>());
68 else74 else
69 report = std::make_shared<mga::NullNativeWindowReport>();75 report = std::make_shared<mga::NullNativeWindowReport>();
70 76
71 return std::make_shared<mga::MirNativeWindow>(77 std::shared_ptr<mga::AndroidDriverInterpreter> surface_interpreter;
72 std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface), report);78 if (surface)
79 surface_interpreter = std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface);
80 else
81 surface_interpreter = std::make_shared<mcla::ErrorDriverInterpreter>();
82
83 return std::make_shared<mga::MirNativeWindow>(surface_interpreter, report);
73}84}
7485
75std::shared_ptr<EGLNativeDisplayType>86std::shared_ptr<EGLNativeDisplayType>
7687
=== modified file 'src/platforms/android/client/android_client_platform.h'
--- src/platforms/android/client/android_client_platform.h 2016-05-03 06:55:25 +0000
+++ src/platforms/android/client/android_client_platform.h 2016-09-01 23:11:16 +0000
@@ -37,7 +37,8 @@
37 void populate(MirPlatformPackage& package) const override;37 void populate(MirPlatformPackage& package) const override;
38 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;38 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
39 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;39 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
40 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;40 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override;
41 void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
41 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;42 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
42 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;43 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
43 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;44 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
4445
=== modified file 'src/platforms/android/client/egl_native_surface_interpreter.h'
--- src/platforms/android/client/egl_native_surface_interpreter.h 2016-01-29 08:18:22 +0000
+++ src/platforms/android/client/egl_native_surface_interpreter.h 2016-09-01 23:11:16 +0000
@@ -21,6 +21,7 @@
2121
22#include "android_driver_interpreter.h"22#include "android_driver_interpreter.h"
23#include "mir/egl_native_surface.h"23#include "mir/egl_native_surface.h"
24#include <boost/throw_exception.hpp>
2425
25namespace mir26namespace mir
26{27{
@@ -36,6 +37,22 @@
36namespace android37namespace android
37{38{
3839
40class ErrorDriverInterpreter : public graphics::android::AndroidDriverInterpreter
41{
42public:
43#define THROW_EXCEPTION \
44{ \
45 BOOST_THROW_EXCEPTION(std::logic_error("error: use_egl_native_window(...) has not yet been called"));\
46}
47 graphics::NativeBuffer* driver_requests_buffer() override THROW_EXCEPTION
48 void driver_returns_buffer(ANativeWindowBuffer*, int) override THROW_EXCEPTION
49 void dispatch_driver_request_format(int) override THROW_EXCEPTION
50 void dispatch_driver_request_buffer_count(unsigned int) override THROW_EXCEPTION
51 int driver_requests_info(int) const override THROW_EXCEPTION
52 void sync_to_display(bool) override THROW_EXCEPTION
53#undef THROW_EXCEPTION
54};
55
39class EGLNativeSurfaceInterpreter : public graphics::android::AndroidDriverInterpreter56class EGLNativeSurfaceInterpreter : public graphics::android::AndroidDriverInterpreter
40{57{
41public:58public:
4259
=== modified file 'src/platforms/android/common/mir_native_window.cpp'
--- src/platforms/android/common/mir_native_window.cpp 2016-07-20 04:54:07 +0000
+++ src/platforms/android/common/mir_native_window.cpp 2016-09-01 23:11:16 +0000
@@ -322,3 +322,9 @@
322 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);322 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);
323 return -1;323 return -1;
324}324}
325
326void mga::MirNativeWindow::use_native_surface(
327 std::shared_ptr<AndroidDriverInterpreter> const& interpreter)
328{
329 driver_interpreter = interpreter;
330}
325331
=== modified file 'src/platforms/android/include/mir_native_window.h'
--- src/platforms/android/include/mir_native_window.h 2016-07-20 04:54:07 +0000
+++ src/platforms/android/include/mir_native_window.h 2016-09-01 23:11:16 +0000
@@ -50,8 +50,9 @@
50 int cancelBuffer(struct ANativeWindowBuffer* buffer, int fence);50 int cancelBuffer(struct ANativeWindowBuffer* buffer, int fence);
51 int cancelBufferDeprecated(struct ANativeWindowBuffer* buffer);51 int cancelBufferDeprecated(struct ANativeWindowBuffer* buffer);
52 int setSwapInterval(int interval);52 int setSwapInterval(int interval);
53 void use_native_surface(std::shared_ptr<AndroidDriverInterpreter> const& interpreter);
53private:54private:
54 std::shared_ptr<AndroidDriverInterpreter> const driver_interpreter;55 std::shared_ptr<AndroidDriverInterpreter> driver_interpreter;
55 std::shared_ptr<NativeWindowReport> const report;56 std::shared_ptr<NativeWindowReport> const report;
56 std::shared_ptr<SyncFileOps> const sync_ops;57 std::shared_ptr<SyncFileOps> const sync_ops;
57 std::vector<struct ANativeWindowBuffer*> cancelled_buffers;58 std::vector<struct ANativeWindowBuffer*> cancelled_buffers;
5859
=== modified file 'src/platforms/eglstream-kms/client/client_platform.cpp'
--- src/platforms/eglstream-kms/client/client_platform.cpp 2016-08-03 12:27:57 +0000
+++ src/platforms/eglstream-kms/client/client_platform.cpp 2016-09-01 23:11:16 +0000
@@ -39,7 +39,11 @@
39 return std::make_shared<mcle::ClientBufferFactory>();39 return std::make_shared<mcle::ClientBufferFactory>();
40}40}
4141
42std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*client_surface*/)42void mcle::ClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, EGLNativeSurface* /*surface*/)
43{
44}
45
46std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*surface*/)
43{47{
44 return nullptr;48 return nullptr;
45}49}
4650
=== modified file 'src/platforms/eglstream-kms/client/client_platform.h'
--- src/platforms/eglstream-kms/client/client_platform.h 2016-08-03 06:48:47 +0000
+++ src/platforms/eglstream-kms/client/client_platform.h 2016-09-01 23:11:16 +0000
@@ -37,6 +37,7 @@
37 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;37 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
38 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;38 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
39 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;39 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;
40 void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
40 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;41 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
41 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;42 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
42 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;43 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
4344
=== modified file 'src/platforms/mesa/client/client_platform.cpp'
--- src/platforms/mesa/client/client_platform.cpp 2016-08-26 19:50:25 +0000
+++ src/platforms/mesa/client/client_platform.cpp 2016-09-01 23:11:16 +0000
@@ -74,9 +74,15 @@
74 return std::make_shared<mclm::ClientBufferFactory>(buffer_file_ops);74 return std::make_shared<mclm::ClientBufferFactory>(buffer_file_ops);
75}75}
7676
77void mclm::ClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface)
78{
79 auto mnw = std::static_pointer_cast<NativeSurface>(native_window);
80 mnw->use_native_surface(surface);
81}
82
77std::shared_ptr<void> mclm::ClientPlatform::create_egl_native_window(EGLNativeSurface* client_surface)83std::shared_ptr<void> mclm::ClientPlatform::create_egl_native_window(EGLNativeSurface* client_surface)
78{84{
79 return std::make_shared<NativeSurface>(*client_surface);85 return std::make_shared<NativeSurface>(client_surface);
80}86}
8187
82std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display()88std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display()
8389
=== modified file 'src/platforms/mesa/client/client_platform.h'
--- src/platforms/mesa/client/client_platform.h 2016-05-03 06:55:25 +0000
+++ src/platforms/mesa/client/client_platform.h 2016-09-01 23:11:16 +0000
@@ -45,7 +45,8 @@
45 void populate(MirPlatformPackage& package) const override;45 void populate(MirPlatformPackage& package) const override;
46 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;46 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
47 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;47 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
48 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;48 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override;
49 void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
49 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;50 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
50 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;51 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
51 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;52 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
5253
=== modified file 'src/platforms/mesa/client/native_surface.cpp'
--- src/platforms/mesa/client/native_surface.cpp 2015-04-28 07:54:10 +0000
+++ src/platforms/mesa/client/native_surface.cpp 2016-09-01 23:11:16 +0000
@@ -27,6 +27,10 @@
2727
28namespace mclm=mir::client::mesa;28namespace mclm=mir::client::mesa;
2929
30#define THROW_IF_NULL(s) \
31 if (!(s)) \
32 throw std::logic_error("error: use_egl_native_window(...) has not yet been called");
33
30namespace34namespace
31{35{
32static int advance_buffer_static(MirMesaEGLNativeSurface* surface,36static int advance_buffer_static(MirMesaEGLNativeSurface* surface,
@@ -50,7 +54,7 @@
50}54}
51}55}
5256
53mclm::NativeSurface::NativeSurface(EGLNativeSurface& surface)57mclm::NativeSurface::NativeSurface(EGLNativeSurface* surface)
54 : starting(true), surface(surface)58 : starting(true), surface(surface)
55{59{
56 surface_advance_buffer = advance_buffer_static;60 surface_advance_buffer = advance_buffer_static;
@@ -61,6 +65,8 @@
61int mclm::NativeSurface::advance_buffer(MirBufferPackage* buffer_package)65int mclm::NativeSurface::advance_buffer(MirBufferPackage* buffer_package)
62try66try
63{67{
68 THROW_IF_NULL(surface);
69
64 /*70 /*
65 * At present dri2_create_mir_window_surface will trigger71 * At present dri2_create_mir_window_surface will trigger
66 * mir_advance_colour_buffer which will land here. Since we're still72 * mir_advance_colour_buffer which will land here. Since we're still
@@ -70,9 +76,9 @@
70 if (starting)76 if (starting)
71 starting = false;77 starting = false;
72 else78 else
73 surface.request_and_wait_for_next_buffer();79 surface->request_and_wait_for_next_buffer();
7480
75 auto buffer = surface.get_current_buffer();81 auto buffer = surface->get_current_buffer();
7682
77 auto buffer_to_driver = buffer->native_buffer_handle();83 auto buffer_to_driver = buffer->native_buffer_handle();
78 memcpy(buffer_package, buffer_to_driver.get(), sizeof(MirBufferPackage));84 memcpy(buffer_package, buffer_to_driver.get(), sizeof(MirBufferPackage));
@@ -87,7 +93,8 @@
87int mclm::NativeSurface::get_parameters(MirSurfaceParameters* surface_parameters)93int mclm::NativeSurface::get_parameters(MirSurfaceParameters* surface_parameters)
88try94try
89{95{
90 auto params = surface.get_parameters();96 THROW_IF_NULL(surface);
97 auto params = surface->get_parameters();
91 memcpy(surface_parameters, &params, sizeof(MirSurfaceParameters));98 memcpy(surface_parameters, &params, sizeof(MirSurfaceParameters));
92 return MIR_MESA_TRUE;99 return MIR_MESA_TRUE;
93}100}
@@ -100,10 +107,12 @@
100int mclm::NativeSurface::set_swapinterval(int interval)107int mclm::NativeSurface::set_swapinterval(int interval)
101try108try
102{109{
110 THROW_IF_NULL(surface);
111
103 if ((interval < 0) || (interval > 1))112 if ((interval < 0) || (interval > 1))
104 return MIR_MESA_FALSE;113 return MIR_MESA_FALSE;
105114
106 surface.request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval);115 surface->request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval);
107 return MIR_MESA_TRUE;116 return MIR_MESA_TRUE;
108}117}
109catch (std::exception const& e)118catch (std::exception const& e)
@@ -111,3 +120,8 @@
111 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);120 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);
112 return MIR_MESA_FALSE;121 return MIR_MESA_FALSE;
113}122}
123
124void mclm::NativeSurface::use_native_surface(EGLNativeSurface* native_surface)
125{
126 surface = native_surface;
127}
114128
=== modified file 'src/platforms/mesa/client/native_surface.h'
--- src/platforms/mesa/client/native_surface.h 2015-04-28 07:54:10 +0000
+++ src/platforms/mesa/client/native_surface.h 2016-09-01 23:11:16 +0000
@@ -32,15 +32,16 @@
32class NativeSurface : public MirMesaEGLNativeSurface32class NativeSurface : public MirMesaEGLNativeSurface
33{33{
34public:34public:
35 explicit NativeSurface(EGLNativeSurface&);35 explicit NativeSurface(EGLNativeSurface*);
3636
37 int advance_buffer(MirBufferPackage* buffer_package);37 int advance_buffer(MirBufferPackage* buffer_package);
38 int get_parameters(MirSurfaceParameters* surface_parameters);38 int get_parameters(MirSurfaceParameters* surface_parameters);
39 int set_swapinterval(int interval);39 int set_swapinterval(int interval);
40 void use_native_surface(EGLNativeSurface* native_surface);
4041
41private:42private:
42 bool starting;43 bool starting;
43 EGLNativeSurface& surface;44 EGLNativeSurface* surface;
44};45};
4546
46}47}
4748
=== modified file 'src/platforms/mesa/include/native_buffer.h'
--- src/platforms/mesa/include/native_buffer.h 2016-08-03 18:07:27 +0000
+++ src/platforms/mesa/include/native_buffer.h 2016-09-01 23:11:16 +0000
@@ -20,6 +20,8 @@
20#define MIR_GRAPHICS_MESA_NATIVE_BUFFER_H_20#define MIR_GRAPHICS_MESA_NATIVE_BUFFER_H_
2121
22#include <mir_toolkit/mir_native_buffer.h>22#include <mir_toolkit/mir_native_buffer.h>
23
24#include <stdlib.h>
23#include <gbm.h>25#include <gbm.h>
2426
25namespace mir27namespace mir
2628
=== modified file 'tests/acceptance-tests/throwback/test_client_library_errors.cpp'
--- tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-08-25 01:11:51 +0000
+++ tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-09-01 23:11:16 +0000
@@ -78,6 +78,10 @@
78 dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context);78 dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context);
79 }79 }
8080
81 void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/) override
82 {
83 }
84
81 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override85 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override
82 {86 {
83 if (should_fail<Method::create_egl_native_window, failure_set>())87 if (should_fail<Method::create_egl_native_window, failure_set>())
8488
=== modified file 'tests/include/mir_test_framework/stub_client_platform_factory.h'
--- tests/include/mir_test_framework/stub_client_platform_factory.h 2016-08-12 18:41:22 +0000
+++ tests/include/mir_test_framework/stub_client_platform_factory.h 2016-09-01 23:11:16 +0000
@@ -33,6 +33,7 @@
33 void populate(MirPlatformPackage& package) const override;33 void populate(MirPlatformPackage& package) const override;
34 MirPlatformMessage* platform_operation(MirPlatformMessage const*) override;34 MirPlatformMessage* platform_operation(MirPlatformMessage const*) override;
35 std::shared_ptr<mir::client::ClientBufferFactory> create_buffer_factory() override;35 std::shared_ptr<mir::client::ClientBufferFactory> create_buffer_factory() override;
36 void use_egl_native_window(std::shared_ptr<void> native_window, mir::client::EGLNativeSurface* surface) override;
36 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface* surface) override;37 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface* surface) override;
37 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;38 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
38 MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const override;39 MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const override;
3940
=== modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
--- tests/mir_test_framework/stub_client_platform_factory.cpp 2016-08-09 13:40:44 +0000
+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2016-09-01 23:11:16 +0000
@@ -71,6 +71,10 @@
71 return std::make_shared<StubPlatformBufferFactory>();71 return std::make_shared<StubPlatformBufferFactory>();
72}72}
7373
74void mtf::StubClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/)
75{
76}
77
74std::shared_ptr<void> mtf::StubClientPlatform::create_egl_native_window(mir::client::EGLNativeSurface* surface)78std::shared_ptr<void> mtf::StubClientPlatform::create_egl_native_window(mir::client::EGLNativeSurface* surface)
75{79{
76 return std::shared_ptr<void>{surface, [](void*){}};80 return std::shared_ptr<void>{surface, [](void*){}};
7781
=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
--- tests/unit-tests/client/test_client_buffer_stream.cpp 2016-08-10 10:43:39 +0000
+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2016-09-01 23:11:16 +0000
@@ -71,6 +71,9 @@
71 void populate(MirPlatformPackage& /* package */) const override71 void populate(MirPlatformPackage& /* package */) const override
72 {72 {
73 }73 }
74 void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mcl::EGLNativeSurface* /*surface*/) override
75 {
76 }
74 std::shared_ptr<void> create_egl_native_window(mcl::EGLNativeSurface * /* surface */) override77 std::shared_ptr<void> create_egl_native_window(mcl::EGLNativeSurface * /* surface */) override
75 {78 {
76 return mt::fake_shared(egl_native_window);79 return mt::fake_shared(egl_native_window);
7780
=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
--- tests/unit-tests/client/test_mir_connection.cpp 2016-06-28 12:18:18 +0000
+++ tests/unit-tests/client/test_mir_connection.cpp 2016-09-01 23:11:16 +0000
@@ -206,6 +206,7 @@
206 MOCK_CONST_METHOD0(platform_type, MirPlatformType());206 MOCK_CONST_METHOD0(platform_type, MirPlatformType());
207 MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*));207 MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*));
208 MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>());208 MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>());
209 MOCK_METHOD2(use_egl_native_window, void(std::shared_ptr<void>, mcl::EGLNativeSurface*));
209 MOCK_METHOD1(create_egl_native_window, std::shared_ptr<void>(mcl::EGLNativeSurface*));210 MOCK_METHOD1(create_egl_native_window, std::shared_ptr<void>(mcl::EGLNativeSurface*));
210 MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>());211 MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>());
211 MOCK_CONST_METHOD2(get_egl_pixel_format,212 MOCK_CONST_METHOD2(get_egl_pixel_format,
212213
=== modified file 'tests/unit-tests/platforms/android/CMakeLists.txt'
--- tests/unit-tests/platforms/android/CMakeLists.txt 2016-08-05 15:32:58 +0000
+++ tests/unit-tests/platforms/android/CMakeLists.txt 2016-09-01 23:11:16 +0000
@@ -4,6 +4,11 @@
4 ${ANDROID_HEADERS_INCLUDE_DIRS}4 ${ANDROID_HEADERS_INCLUDE_DIRS}
5 ${PROJECT_SOURCE_DIR}/src/platforms/android/include5 ${PROJECT_SOURCE_DIR}/src/platforms/android/include
6)6)
7
8set(
9 ANDROID_UNIT_TEST_SOURCES
10)
11
7add_subdirectory("server")12add_subdirectory("server")
8add_subdirectory("client")13add_subdirectory("client")
914
1015
=== modified file 'tests/unit-tests/platforms/android/client/test_android_client_platform.cpp'
--- tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-01-29 08:18:22 +0000
+++ tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-09-01 23:11:16 +0000
@@ -16,6 +16,7 @@
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */17 */
1818
19#include "mir_native_window.h"
19#include "mir/client_platform.h"20#include "mir/client_platform.h"
20#include "mir/test/doubles/mock_client_context.h"21#include "mir/test/doubles/mock_client_context.h"
21#include "mir/test/doubles/mock_egl_native_surface.h"22#include "mir/test/doubles/mock_egl_native_surface.h"
@@ -59,6 +60,20 @@
59 EXPECT_NE(nullptr, egl_native_window);60 EXPECT_NE(nullptr, egl_native_window);
60}61}
6162
63TEST_F(AndroidClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface)
64{
65 auto egl_native_window = platform->create_egl_native_window(nullptr);
66 EXPECT_NE(nullptr, egl_native_window);
67}
68
69TEST_F(AndroidClientPlatformTest, error_interpreter_used_with_null_native_surface)
70{
71 auto egl_native_window = platform->create_egl_native_window(nullptr);
72 auto native_window = reinterpret_cast<mir::graphics::android::MirNativeWindow*>(egl_native_window.get());
73 ANativeWindow& window = *native_window;
74 EXPECT_EQ(window.setSwapInterval(&window, 1), -1);
75}
76
62TEST_F(AndroidClientPlatformTest, egl_pixel_format_asks_the_driver)77TEST_F(AndroidClientPlatformTest, egl_pixel_format_asks_the_driver)
63{78{
64 auto const d = reinterpret_cast<EGLDisplay>(0x1234);79 auto const d = reinterpret_cast<EGLDisplay>(0x1234);
6580
=== modified file 'tests/unit-tests/platforms/android/client/test_android_native_window.cpp'
--- tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-08-24 02:09:08 +0000
+++ tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-09-01 23:11:16 +0000
@@ -73,6 +73,22 @@
7373
74}74}
7575
76TEST_F(AndroidNativeWindowTest, use_native_surface_call_replaces_existing_interpreter)
77{
78 std::shared_ptr<MockAndroidDriverInterpreter> const new_driver_interpreter =
79 std::make_shared<NiceMock<MockAndroidDriverInterpreter>>();
80
81 // Test that the call goes to the new interpreter instead of the old one
82 EXPECT_CALL(*mock_driver_interpreter, sync_to_display(true))
83 .Times(0);
84
85 EXPECT_CALL(*new_driver_interpreter, sync_to_display(true))
86 .Times(1);
87
88 mir_native_window.use_native_surface(new_driver_interpreter);
89 window.setSwapInterval(&window, 1);
90}
91
76TEST_F(AndroidNativeWindowTest, native_window_swapinterval)92TEST_F(AndroidNativeWindowTest, native_window_swapinterval)
77{93{
78 ASSERT_NE(nullptr, window.setSwapInterval);94 ASSERT_NE(nullptr, window.setSwapInterval);
7995
=== modified file 'tests/unit-tests/platforms/mesa/client/test_client_platform.cpp'
--- tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-05-26 03:59:12 +0000
+++ tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-09-01 23:11:16 +0000
@@ -22,6 +22,7 @@
22#include "src/platforms/mesa/client/mesa_native_display_container.h"22#include "src/platforms/mesa/client/mesa_native_display_container.h"
23#include "mir_test_framework/client_platform_factory.h"23#include "mir_test_framework/client_platform_factory.h"
24#include "mir/test/doubles/mock_egl.h"24#include "mir/test/doubles/mock_egl.h"
25#include "mir/test/doubles/mock_egl_native_surface.h"
2526
26#include "mir_toolkit/mir_client_library.h"27#include "mir_toolkit/mir_client_library.h"
27#include "mir_toolkit/mesa/native_display.h"28#include "mir_toolkit/mesa/native_display.h"
@@ -155,3 +156,16 @@
155 EXPECT_EQ(mir_pixel_format_xrgb_8888, platform->get_egl_pixel_format(d, c));156 EXPECT_EQ(mir_pixel_format_xrgb_8888, platform->get_egl_pixel_format(d, c));
156 EXPECT_EQ(mir_pixel_format_invalid, platform->get_egl_pixel_format(d, c));157 EXPECT_EQ(mir_pixel_format_invalid, platform->get_egl_pixel_format(d, c));
157}158}
159
160TEST_F(MesaClientPlatformTest, egl_native_window_is_set)
161{
162 testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface;
163 auto egl_native_window = platform->create_egl_native_window(&mock_surface);
164 EXPECT_NE(nullptr, egl_native_window);
165}
166
167TEST_F(MesaClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface)
168{
169 auto egl_native_window = platform->create_egl_native_window(nullptr);
170 EXPECT_NE(nullptr, egl_native_window);
171}
158172
=== modified file 'tests/unit-tests/platforms/mesa/client/test_native_surface.cpp'
--- tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-05-03 06:55:25 +0000
+++ tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-09-01 23:11:16 +0000
@@ -16,18 +16,20 @@
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */17 */
1818
19#include "src/platforms/mesa/include/native_buffer.h"
19#include "src/platforms/mesa/client/native_surface.h"20#include "src/platforms/mesa/client/native_surface.h"
20#include "mir/client_buffer.h"21#include "mir/client_buffer.h"
21#include "mir/test/doubles/mock_egl_native_surface.h"22#include "mir/test/doubles/mock_egl_native_surface.h"
22#include "mir/test/doubles/mock_client_buffer.h"23#include "mir/test/doubles/mock_client_buffer.h"
2324#include "mir/test/fake_shared.h"
24#include <gmock/gmock.h>25#include <gmock/gmock.h>
25#include <gtest/gtest.h>26#include <gtest/gtest.h>
2627
27namespace mtd=mir::test::doubles;28namespace mt=mir::test;
28namespace mcl=mir::client;29namespace mtd=mt::doubles;
29namespace mcl=mir::client;30namespace mcl=mir::client;
30namespace mclg=mir::client::mesa;31namespace mg=mir::graphics;
32namespace mclg=mcl::mesa;
31namespace geom=mir::geometry;33namespace geom=mir::geometry;
3234
33class MesaClientNativeSurfaceTest : public ::testing::Test35class MesaClientNativeSurfaceTest : public ::testing::Test
@@ -44,18 +46,24 @@
44 .WillByDefault(Return(surf_params));46 .WillByDefault(Return(surf_params));
45 ON_CALL(mock_surface, get_current_buffer())47 ON_CALL(mock_surface, get_current_buffer())
46 .WillByDefault(Return(48 .WillByDefault(Return(
47 std::make_shared<NiceMock<mtd::MockClientBuffer>>()));49 mt::fake_shared(mock_buffer)));
50 ON_CALL(mock_buffer, native_buffer_handle())
51 .WillByDefault(Return(
52 mt::fake_shared(native_buffer)));
48 }53 }
4954
50 MirSurfaceParameters surf_params;55 MirSurfaceParameters surf_params;
56 const char* error_msg = "thrown as part of test";
57 mg::NativeBuffer native_buffer;
58 testing::NiceMock<mtd::MockClientBuffer> mock_buffer;
51 testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface;59 testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface;
52 mclg::NativeSurface native_surface{mock_surface};60 mclg::NativeSurface native_surface{&mock_surface};
53};61};
5462
55TEST_F(MesaClientNativeSurfaceTest, basic_parameters)63TEST_F(MesaClientNativeSurfaceTest, basic_parameters)
56{64{
57 MirSurfaceParameters params;65 MirSurfaceParameters params;
58 native_surface.surface_get_parameters(&native_surface, &params);66 EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_get_parameters(&native_surface, &params));
59 EXPECT_EQ(surf_params.width, params.width);67 EXPECT_EQ(surf_params.width, params.width);
60 EXPECT_EQ(surf_params.height, params.height);68 EXPECT_EQ(surf_params.height, params.height);
61 EXPECT_EQ(surf_params.pixel_format, params.pixel_format);69 EXPECT_EQ(surf_params.pixel_format, params.pixel_format);
@@ -72,7 +80,7 @@
72 EXPECT_CALL(mock_surface, get_current_buffer())80 EXPECT_CALL(mock_surface, get_current_buffer())
73 .Times(1);81 .Times(1);
7482
75 native_surface.surface_advance_buffer(&native_surface, &buffer_package);83 EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package));
76}84}
7785
78TEST_F(MesaClientNativeSurfaceTest, basic_advance)86TEST_F(MesaClientNativeSurfaceTest, basic_advance)
@@ -88,8 +96,8 @@
88 EXPECT_CALL(mock_surface, get_current_buffer())96 EXPECT_CALL(mock_surface, get_current_buffer())
89 .Times(1);97 .Times(1);
9098
91 native_surface.surface_advance_buffer(&native_surface, &buffer_package);99 EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package));
92 native_surface.surface_advance_buffer(&native_surface, &buffer_package);100 EXPECT_EQ(MIR_MESA_TRUE, native_surface.surface_advance_buffer(&native_surface, &buffer_package));
93}101}
94102
95TEST_F(MesaClientNativeSurfaceTest, swapinterval_request)103TEST_F(MesaClientNativeSurfaceTest, swapinterval_request)
@@ -102,8 +110,8 @@
102 EXPECT_CALL(mock_surface, request_and_wait_for_configure(mir_surface_attrib_swapinterval,1))110 EXPECT_CALL(mock_surface, request_and_wait_for_configure(mir_surface_attrib_swapinterval,1))
103 .InSequence(seq);111 .InSequence(seq);
104112
105 native_surface.set_swapinterval(0);113 EXPECT_EQ(MIR_MESA_TRUE, native_surface.set_swapinterval(0));
106 native_surface.set_swapinterval(1);114 EXPECT_EQ(MIR_MESA_TRUE, native_surface.set_swapinterval(1));
107}115}
108116
109TEST_F(MesaClientNativeSurfaceTest, swapinterval_unsupported_request)117TEST_F(MesaClientNativeSurfaceTest, swapinterval_unsupported_request)
@@ -119,10 +127,10 @@
119 using namespace testing;127 using namespace testing;
120128
121 EXPECT_CALL(mock_surface, get_current_buffer())129 EXPECT_CALL(mock_surface, get_current_buffer())
122 .WillOnce(Throw(std::runtime_error("")));130 .WillOnce(Throw(std::runtime_error(error_msg)));
123131
124 MirBufferPackage buffer_package;132 MirBufferPackage buffer_package;
125 EXPECT_THAT(native_surface.advance_buffer(&buffer_package), Eq(MIR_MESA_FALSE));133 EXPECT_EQ(MIR_MESA_FALSE, native_surface.advance_buffer(&buffer_package));
126}134}
127135
128TEST_F(MesaClientNativeSurfaceTest, returns_error_on_get_parameters_failure)136TEST_F(MesaClientNativeSurfaceTest, returns_error_on_get_parameters_failure)
@@ -130,10 +138,10 @@
130 using namespace testing;138 using namespace testing;
131139
132 EXPECT_CALL(mock_surface, get_parameters())140 EXPECT_CALL(mock_surface, get_parameters())
133 .WillOnce(Throw(std::runtime_error("")));141 .WillOnce(Throw(std::runtime_error(error_msg)));
134142
135 MirSurfaceParameters surface_params;143 MirSurfaceParameters surface_params;
136 EXPECT_THAT(native_surface.get_parameters(&surface_params), Eq(MIR_MESA_FALSE));144 EXPECT_EQ(MIR_MESA_FALSE, native_surface.get_parameters(&surface_params));
137}145}
138146
139TEST_F(MesaClientNativeSurfaceTest, returns_error_on_set_swap_interval_failure)147TEST_F(MesaClientNativeSurfaceTest, returns_error_on_set_swap_interval_failure)
@@ -141,7 +149,42 @@
141 using namespace testing;149 using namespace testing;
142150
143 EXPECT_CALL(mock_surface, request_and_wait_for_configure(_,_))151 EXPECT_CALL(mock_surface, request_and_wait_for_configure(_,_))
144 .WillOnce(Throw(std::runtime_error("")));152 .WillOnce(Throw(std::runtime_error(error_msg)));
145153
146 EXPECT_THAT(native_surface.set_swapinterval(0), Eq(MIR_MESA_FALSE));154 EXPECT_EQ(MIR_MESA_FALSE, native_surface.set_swapinterval(0));
155}
156
157TEST_F(MesaClientNativeSurfaceTest, null_native_surface_returns_error)
158{
159 using namespace testing;
160
161 MirSurfaceParameters params;
162 MirBufferPackage buffer_package;
163
164 mclg::NativeSurface null_native_surface{nullptr};
165
166 EXPECT_EQ(MIR_MESA_FALSE,
167 null_native_surface.surface_get_parameters(&null_native_surface, &params));
168 EXPECT_EQ(MIR_MESA_FALSE,
169 null_native_surface.surface_advance_buffer(&null_native_surface, &buffer_package));
170 EXPECT_EQ(MIR_MESA_FALSE,
171 null_native_surface.surface_set_swapinterval(&null_native_surface, 1));
172}
173
174TEST_F(MesaClientNativeSurfaceTest, native_surface_after_null_returns_success)
175{
176 using namespace testing;
177
178 MirSurfaceParameters params;
179 MirBufferPackage buffer_package;
180
181 mclg::NativeSurface native_surface{nullptr};
182
183 native_surface.use_native_surface(&mock_surface);
184 EXPECT_EQ(MIR_MESA_TRUE,
185 native_surface.surface_get_parameters(&native_surface, &params));
186 EXPECT_EQ(MIR_MESA_TRUE,
187 native_surface.surface_advance_buffer(&native_surface, &buffer_package));
188 EXPECT_EQ(MIR_MESA_TRUE,
189 native_surface.surface_set_swapinterval(&native_surface, 1));
147}190}

Subscribers

People subscribed via source and target branches