Mir

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

Proposed by Cemil Azizoglu
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3751
Proposed branch: lp:~cemil-azizoglu/mir/use_egl_native_window
Merge into: lp:mir
Prerequisite: lp:~cemil-azizoglu/mir/fix-mesa-native-surface-tests
Diff against target: 527 lines (+181/-18)
23 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)
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 (+36/-1)
To merge this branch: bzr merge lp:~cemil-azizoglu/mir/use_egl_native_window
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Chris Halse Rogers Approve
Kevin DuBois (community) Abstain
Review via email: mp+304726@code.launchpad.net

This proposal supersedes a proposal from 2016-08-29.

Commit message

Currently, in order to create an egl native window, we need an EGLNativeSurface*. I.e.

virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) = 0;

Sometimes, as in the case of 'render surfaces', we do not have a native surface at the time when we want to create the native window. In that case, we should still be able to create it without one (i.e. with a nullptr), and "install" the native surface later, before it's needed. This is what this MP does.

Description of the change

Currently, in order to create an egl native window, we need an EGLNativeSurface*. I.e.

virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) = 0;

Sometimes, as in the case of 'render surfaces', we do not have a native surface at the time when we want to create the native window. In that case, we should still be able to create it without one (i.e. with a nullptr), and "install" the native surface later, before it's needed. This is what this MP does.

Background
----------
A native window is normally created as part of a buffer stream, where the buffer stream *is* the native surface, therefore it's always available when create_egl_native_window() is called. Render surfaces are what is passed to eglCreateNativeWindow() therefore they need to be "native windows". When a render surface is created, however, it doesn't have a backing native surface (BS, or PC, or anything else). Thus it has to be created without one. Later, use_egl_native_window() must be called to introduce a backing native surface, so rendering could proceed.

Usage
-----
To see how it's used, you can take a look at the (WiP) mir render surface implementation :

https://code.launchpad.net/~cemil-azizoglu/mir/mir-render-surface-v3/+merge/304536

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3686
https://mir-jenkins.ubuntu.com/job/mir-ci/1615/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2023
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2084
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2049/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2049/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2049/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2049/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2049/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2049
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2049/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1615/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3687
https://mir-jenkins.ubuntu.com/job/mir-ci/1627/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/2037/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2099
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2090
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2090
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2090
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2063/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2063
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2063/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2063
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2063/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2063
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2063/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2063
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2063/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2063
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2063/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1627/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

Along the line of the comment here,
https://code.launchpad.net/~cemil-azizoglu/mir/mir-render-surface-v3/+merge/304536/comments/786976

use_egl_native_window() doesn't seem to line up with what we can actually tell the all platforms to do. (and we have to have ErrorDriverInterpreter as a workaround, we can't actually tell android what native window to use). We only have the advantage of telling the mesa platform what type to use as its native window.

So I guess I'm still mostly stuck on trying to understand the comment I made in the RFC for the headers, which has to do with the interfaces we're providing.

review: Needs Information
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

> Along the line of the comment here,
> https://code.launchpad.net/~cemil-azizoglu/mir/mir-render-
> surface-v3/+merge/304536/comments/786976
>
> use_egl_native_window() doesn't seem to line up with what we can actually tell
> the all platforms to do. (and we have to have ErrorDriverInterpreter as a
> workaround, we can't actually tell android what native window to use). We only
> have the advantage of telling the mesa platform what type to use as its native
> window.
>
> So I guess I'm still mostly stuck on trying to understand the comment I made
> in the RFC for the headers, which has to do with the interfaces we're
> providing.

We need the native window handle before we are able to use it (by installing a driver interpreter, for instance). This MP breaks the assumption that "we must have everything in place before we can create a native window".

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3687
https://mir-jenkins.ubuntu.com/job/mir-ci/1651/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2066
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2128
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2119
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2119
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2119
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2094
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2094/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2094
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2094/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2094
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2094/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2094
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2094/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2094
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2094/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1651/rebuild

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

Had a lengthy IRC conversation about the RenderSurface header yesterday. Seems that the confusion that remains is left around the question "Should a MirBufferStream and MirPresentationChain be created from a MirRenderSurface?". (the internal structuring depends on this question).

I say that it should not, but we have 3rd type here in MirRenderSurface. (which is effectively just EGLNativeWindowSurface).

The MirRenderSurface, MirBufferStream and MirPresentationChain fill different needs to the users:
1) MirRenderSurface gives the user an EGLNativeWindowSurface, regardless of underlying driver interfaces.
2) MirPresentationChain gives a fine-grained buffer submission option for those building technologies like multimedia, nested passthrough, vulkan, etc.
3) MirBufferStream gives stream-like semantics. Its value is a bit dubious, imo, legacy reasons are the strongest reason this is still around.

Creating types 2) and 3) /from/ type 1) don't make sense, because the user can start doing crazy things like:
auto rs = create_render_surface();
auto bs = create_bs_from_rs(rs);
auto pc = create_pc_from_rs(rs);

swap_buffer(bs)
submit_buffer(pc);
eglSwapBuffers();
submit_buffer(pc);

It also forces us into internal 2step initialization pretzels (esp for android and EGLStreams), because we start having to force platforms to reinterpret what MirRenderSurface is... (we have to tell them to "use_egl_native_window" after creation, instead of just creating what the user wanted in the first place).

The instinct to have one "MirRenderSurface thing is good. But I think that mf::BufferStreamId is really the concept that's being looked for. All 3 client-facing concepts are represented by mf::BufferStreamId in the end.

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

> The instinct to have one "MirRenderSurface thing is good. But I think that
> mf::BufferStreamId is really the concept that's being looked for. All 3
> client-facing concepts are represented by mf::BufferStreamId in the end.

And this fits in well, esp in light of how multiple surfaces are arranged in MirSurfaceSpec.

If you add
void mir_surface_spec_add_render_surface(MirSurfaceSpec*, MirRenderSurface*, int width, int height, int displacement_x, int displacement_y);

to the two functions for BS and PC:
http://bazaar.launchpad.net/~mir-team/mir/development-branch/view/head:/src/include/client/mir_toolkit/mir_presentation_chain.h#L122

then if a user wanted to make a multi-content MirSurface, this would be easy to do both from the client api perspective, and from Mir's perspective internally.

Client perspective:
EG, making a french/italian/mexican/etc 3-bar-style-flag from the 3 components:

int bar_height = 200, bar_width = 200;
int full_width = 3 * bar_width, full_height = bar_height;
MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, full_width, full_height, format);
MirPresentationChain* chain = mir_connection_create_presentation_chain_sync(connection);
MirBufferStream* stream = mir_connection_create_buffer_stream(connection, bar_width, bar_height, format, usage);
MirRenderSurface* rs = mir_connection_create_render_surface_sync(connection);
mir_surface_spec_add_presentation_chain(spec, bar_width, bar_height, 0, 0, chain);
mir_surface_spec_add_buffer_stream(spec, bar_width, 0, stream)
mir_surface_spec_add_render_surface(spec, rs, bar_width, bar_height, 2*bar_width, 0);
MirSurface* surface = mir_surface_create_sync(spec);

Mir's internal perspective:
mir_surface_spec_add_* will just add mf::BufferStreamId to the request. The server doesn't have to know what sort of client construct is present, as its all boiled down to NBS rpc transactions.

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

Alright, I think we've gotten to the bottom of this in the email chain.

We really need a shim EGL platform to adapt EGL_KHR_mir_platform to EGL_KHR_android_platform. This adaptation should be done in the shim, not within the android client platform.

I'd prefer a shim-layer to be proposed instead of this, just on the basis of it having 2-step initialization, deferred errors from ErrorDriverInterpreter and introducing temporary confusion about MirRenderSurface (which sparked all that email discussion)

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

> Alright, I think we've gotten to the bottom of this in the email chain.
>
> We really need a shim EGL platform to adapt EGL_KHR_mir_platform to
> EGL_KHR_android_platform. This adaptation should be done in the shim, not
> within the android client platform.
>
> I'd prefer a shim-layer to be proposed instead of this, just on the basis of
> it having 2-step initialization, deferred errors from ErrorDriverInterpreter
> and introducing temporary confusion about MirRenderSurface (which sparked all
> that email discussion)

I'd rather tackle the shim idea after we have MirRenderSurface merged in, since it is internal refactoring, and only affects Android. Whereas, this is blocking Mesa upstreaming.

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

> I'd rather tackle the shim idea after we have MirRenderSurface merged in,
> since it is internal refactoring, and only affects Android. Whereas, this is
> blocking Mesa upstreaming.

It's also blocking Vulkan Mir support.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3702
https://mir-jenkins.ubuntu.com/job/mir-ci/1707/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2136
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2198
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2189
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2189
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2189
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2164
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2164/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2164
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2164/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2164
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2164/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2164
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2164/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2164
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2164/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1707/rebuild

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

The initialization that's happening is still two step, because we don't know at creation time what we're creating. In the email chain, that was explained that this is the transition strategy we've decided to take for defining our own platform type... I suppose abstain from me.

review: Abstain
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3703
https://mir-jenkins.ubuntu.com/job/mir-ci/1755/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2202
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2265
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2256
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2256
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2256
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2230
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2230/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2230
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2230/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2230
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2230/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2230
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2230/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2230
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2230/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1755/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3704
https://mir-jenkins.ubuntu.com/job/mir-ci/1845/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2327
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2390
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2382
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2382
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2382
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2356/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2356/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2356/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2356/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2356/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2356
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2356/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1845/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3705
https://mir-jenkins.ubuntu.com/job/mir-ci/1890/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/2394/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2457
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2449
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2449
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2449
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2423
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2423/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2423
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2423/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2423
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2423/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2423/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2423/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2423
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2423/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2423
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2423/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1890/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

I'm OK with this; this scaffolding will be removed once the Android EGL shim is implemented.

I'm not sure that it wouldn't be faster and easier to do the Android EGL thing first, but you're the one doing the coding :).

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Looks like an infra problem. Rekicking.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3705
https://mir-jenkins.ubuntu.com/job/mir-ci/1898/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2409
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2472
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2464
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2464
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2464
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2438/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2438/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2438/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2438/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2438/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2438
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2438/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1898/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Five weeks and no strong opposing opinions. Just land it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2016-08-26 19:50:25 +0000
3+++ .bzrignore 2016-10-04 20:14:55 +0000
4@@ -1,3 +1,4 @@
5 .idea
6 .project
7 include/server/mir/version.h
8+build-*
9
10=== modified file 'src/include/client/mir/client_platform.h'
11--- src/include/client/mir/client_platform.h 2016-05-03 06:55:25 +0000
12+++ src/include/client/mir/client_platform.h 2016-10-04 20:14:55 +0000
13@@ -63,7 +63,8 @@
14 virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0;
15 // EGLNativeWindowType differs between platforms, so can't reasonably be used in the
16 // platform-independent interface.
17- virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) = 0;
18+ virtual std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) = 0;
19+ virtual void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) = 0;
20 virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0;
21 virtual MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const = 0;
22 virtual MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const = 0;
23
24=== modified file 'src/platforms/android/client/android_client_platform.cpp'
25--- src/platforms/android/client/android_client_platform.cpp 2016-09-19 04:16:15 +0000
26+++ src/platforms/android/client/android_client_platform.cpp 2016-10-04 20:14:55 +0000
27@@ -57,7 +57,13 @@
28 return std::make_shared<mcla::AndroidClientBufferFactory>(registrar);
29 }
30
31-std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface *surface)
32+void mcla::AndroidClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface)
33+{
34+ auto anw = std::static_pointer_cast<mga::MirNativeWindow>(native_window);
35+ anw->use_native_surface(std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface));
36+}
37+
38+std::shared_ptr<void> mcla::AndroidClientPlatform::create_egl_native_window(EGLNativeSurface* surface)
39 {
40 auto log = getenv("MIR_CLIENT_ANDROID_WINDOW_REPORT");
41 std::shared_ptr<mga::NativeWindowReport> report;
42@@ -67,9 +73,14 @@
43 std::make_shared<mir::logging::DumbConsoleLogger>());
44 else
45 report = std::make_shared<mga::NullNativeWindowReport>();
46-
47- return std::make_shared<mga::MirNativeWindow>(
48- std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface), report);
49+
50+ std::shared_ptr<mga::AndroidDriverInterpreter> surface_interpreter;
51+ if (surface)
52+ surface_interpreter = std::make_shared<mcla::EGLNativeSurfaceInterpreter>(*surface);
53+ else
54+ surface_interpreter = std::make_shared<mcla::ErrorDriverInterpreter>();
55+
56+ return std::make_shared<mga::MirNativeWindow>(surface_interpreter, report);
57 }
58
59 std::shared_ptr<EGLNativeDisplayType>
60
61=== modified file 'src/platforms/android/client/android_client_platform.h'
62--- src/platforms/android/client/android_client_platform.h 2016-05-03 06:55:25 +0000
63+++ src/platforms/android/client/android_client_platform.h 2016-10-04 20:14:55 +0000
64@@ -37,7 +37,8 @@
65 void populate(MirPlatformPackage& package) const override;
66 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
67 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
68- std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;
69+ std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override;
70+ void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
71 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
72 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
73 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
74
75=== modified file 'src/platforms/android/client/egl_native_surface_interpreter.h'
76--- src/platforms/android/client/egl_native_surface_interpreter.h 2016-09-19 04:16:15 +0000
77+++ src/platforms/android/client/egl_native_surface_interpreter.h 2016-10-04 20:14:55 +0000
78@@ -21,6 +21,7 @@
79
80 #include "android_driver_interpreter.h"
81 #include "mir/egl_native_surface.h"
82+#include <boost/throw_exception.hpp>
83
84 namespace mir
85 {
86@@ -36,6 +37,22 @@
87 namespace android
88 {
89
90+class ErrorDriverInterpreter : public graphics::android::AndroidDriverInterpreter
91+{
92+public:
93+#define THROW_EXCEPTION \
94+{ \
95+ BOOST_THROW_EXCEPTION(std::logic_error("error: use_egl_native_window(...) has not yet been called"));\
96+}
97+ graphics::android::NativeBuffer* driver_requests_buffer() override THROW_EXCEPTION
98+ void driver_returns_buffer(ANativeWindowBuffer*, int) override THROW_EXCEPTION
99+ void dispatch_driver_request_format(int) override THROW_EXCEPTION
100+ void dispatch_driver_request_buffer_count(unsigned int) override THROW_EXCEPTION
101+ int driver_requests_info(int) const override THROW_EXCEPTION
102+ void sync_to_display(bool) override THROW_EXCEPTION
103+#undef THROW_EXCEPTION
104+};
105+
106 class EGLNativeSurfaceInterpreter : public graphics::android::AndroidDriverInterpreter
107 {
108 public:
109
110=== modified file 'src/platforms/android/common/mir_native_window.cpp'
111--- src/platforms/android/common/mir_native_window.cpp 2016-07-20 04:54:07 +0000
112+++ src/platforms/android/common/mir_native_window.cpp 2016-10-04 20:14:55 +0000
113@@ -322,3 +322,9 @@
114 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);
115 return -1;
116 }
117+
118+void mga::MirNativeWindow::use_native_surface(
119+ std::shared_ptr<AndroidDriverInterpreter> const& interpreter)
120+{
121+ driver_interpreter = interpreter;
122+}
123
124=== modified file 'src/platforms/android/include/mir_native_window.h'
125--- src/platforms/android/include/mir_native_window.h 2016-07-20 04:54:07 +0000
126+++ src/platforms/android/include/mir_native_window.h 2016-10-04 20:14:55 +0000
127@@ -50,8 +50,9 @@
128 int cancelBuffer(struct ANativeWindowBuffer* buffer, int fence);
129 int cancelBufferDeprecated(struct ANativeWindowBuffer* buffer);
130 int setSwapInterval(int interval);
131+ void use_native_surface(std::shared_ptr<AndroidDriverInterpreter> const& interpreter);
132 private:
133- std::shared_ptr<AndroidDriverInterpreter> const driver_interpreter;
134+ std::shared_ptr<AndroidDriverInterpreter> driver_interpreter;
135 std::shared_ptr<NativeWindowReport> const report;
136 std::shared_ptr<SyncFileOps> const sync_ops;
137 std::vector<struct ANativeWindowBuffer*> cancelled_buffers;
138
139=== modified file 'src/platforms/eglstream-kms/client/client_platform.cpp'
140--- src/platforms/eglstream-kms/client/client_platform.cpp 2016-09-19 04:16:15 +0000
141+++ src/platforms/eglstream-kms/client/client_platform.cpp 2016-10-04 20:14:55 +0000
142@@ -39,7 +39,11 @@
143 return std::make_shared<mcle::ClientBufferFactory>();
144 }
145
146-std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*client_surface*/)
147+void mcle::ClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, EGLNativeSurface* /*surface*/)
148+{
149+}
150+
151+std::shared_ptr<void> mcle::ClientPlatform::create_egl_native_window(EGLNativeSurface* /*surface*/)
152 {
153 return nullptr;
154 }
155
156=== modified file 'src/platforms/eglstream-kms/client/client_platform.h'
157--- src/platforms/eglstream-kms/client/client_platform.h 2016-08-03 06:48:47 +0000
158+++ src/platforms/eglstream-kms/client/client_platform.h 2016-10-04 20:14:55 +0000
159@@ -37,6 +37,7 @@
160 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
161 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
162 std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;
163+ void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
164 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
165 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
166 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
167
168=== modified file 'src/platforms/mesa/client/client_platform.cpp'
169--- src/platforms/mesa/client/client_platform.cpp 2016-09-19 04:16:15 +0000
170+++ src/platforms/mesa/client/client_platform.cpp 2016-10-04 20:14:55 +0000
171@@ -76,9 +76,15 @@
172 return std::make_shared<mclm::ClientBufferFactory>(buffer_file_ops);
173 }
174
175+void mclm::ClientPlatform::use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface)
176+{
177+ auto mnw = std::static_pointer_cast<NativeSurface>(native_window);
178+ mnw->use_native_surface(surface);
179+}
180+
181 std::shared_ptr<void> mclm::ClientPlatform::create_egl_native_window(EGLNativeSurface* client_surface)
182 {
183- return std::make_shared<NativeSurface>(*client_surface);
184+ return std::make_shared<NativeSurface>(client_surface);
185 }
186
187 std::shared_ptr<EGLNativeDisplayType> mclm::ClientPlatform::create_egl_native_display()
188
189=== modified file 'src/platforms/mesa/client/client_platform.h'
190--- src/platforms/mesa/client/client_platform.h 2016-05-03 06:55:25 +0000
191+++ src/platforms/mesa/client/client_platform.h 2016-10-04 20:14:55 +0000
192@@ -45,7 +45,8 @@
193 void populate(MirPlatformPackage& package) const override;
194 MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override;
195 std::shared_ptr<ClientBufferFactory> create_buffer_factory() override;
196- std::shared_ptr<void> create_egl_native_window(EGLNativeSurface *surface) override;
197+ std::shared_ptr<void> create_egl_native_window(EGLNativeSurface* surface) override;
198+ void use_egl_native_window(std::shared_ptr<void> native_window, EGLNativeSurface* surface) override;
199 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
200 MirNativeBuffer* convert_native_buffer(graphics::NativeBuffer*) const override;
201 MirPixelFormat get_egl_pixel_format(EGLDisplay, EGLConfig) const override;
202
203=== modified file 'src/platforms/mesa/client/native_surface.cpp'
204--- src/platforms/mesa/client/native_surface.cpp 2016-09-19 04:16:15 +0000
205+++ src/platforms/mesa/client/native_surface.cpp 2016-10-04 20:14:55 +0000
206@@ -28,6 +28,10 @@
207
208 namespace mclm=mir::client::mesa;
209
210+#define THROW_IF_NULL(s) \
211+ if (!(s)) \
212+ throw std::logic_error("error: use_egl_native_window(...) has not yet been called");
213+
214 namespace
215 {
216 static int advance_buffer_static(MirMesaEGLNativeSurface* surface,
217@@ -51,7 +55,7 @@
218 }
219 }
220
221-mclm::NativeSurface::NativeSurface(EGLNativeSurface& surface)
222+mclm::NativeSurface::NativeSurface(EGLNativeSurface* surface)
223 : starting(true), surface(surface)
224 {
225 surface_advance_buffer = advance_buffer_static;
226@@ -62,6 +66,8 @@
227 int mclm::NativeSurface::advance_buffer(MirBufferPackage* buffer_package)
228 try
229 {
230+ THROW_IF_NULL(surface);
231+
232 /*
233 * At present dri2_create_mir_window_surface will trigger
234 * mir_advance_colour_buffer which will land here. Since we're still
235@@ -71,9 +77,9 @@
236 if (starting)
237 starting = false;
238 else
239- surface.request_and_wait_for_next_buffer();
240+ surface->request_and_wait_for_next_buffer();
241
242- auto buffer = surface.get_current_buffer();
243+ auto buffer = surface->get_current_buffer();
244
245 auto buffer_to_driver = std::dynamic_pointer_cast<mir::graphics::mesa::NativeBuffer>(
246 buffer->native_buffer_handle());
247@@ -91,7 +97,8 @@
248 int mclm::NativeSurface::get_parameters(MirSurfaceParameters* surface_parameters)
249 try
250 {
251- auto params = surface.get_parameters();
252+ THROW_IF_NULL(surface);
253+ auto params = surface->get_parameters();
254 memcpy(surface_parameters, &params, sizeof(MirSurfaceParameters));
255 return MIR_MESA_TRUE;
256 }
257@@ -104,10 +111,12 @@
258 int mclm::NativeSurface::set_swapinterval(int interval)
259 try
260 {
261+ THROW_IF_NULL(surface);
262+
263 if ((interval < 0) || (interval > 1))
264 return MIR_MESA_FALSE;
265
266- surface.request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval);
267+ surface->request_and_wait_for_configure(mir_surface_attrib_swapinterval, interval);
268 return MIR_MESA_TRUE;
269 }
270 catch (std::exception const& e)
271@@ -115,3 +124,8 @@
272 MIR_LOG_DRIVER_BOUNDARY_EXCEPTION(e);
273 return MIR_MESA_FALSE;
274 }
275+
276+void mclm::NativeSurface::use_native_surface(EGLNativeSurface* native_surface)
277+{
278+ surface = native_surface;
279+}
280
281=== modified file 'src/platforms/mesa/client/native_surface.h'
282--- src/platforms/mesa/client/native_surface.h 2015-04-28 07:54:10 +0000
283+++ src/platforms/mesa/client/native_surface.h 2016-10-04 20:14:55 +0000
284@@ -32,15 +32,16 @@
285 class NativeSurface : public MirMesaEGLNativeSurface
286 {
287 public:
288- explicit NativeSurface(EGLNativeSurface&);
289+ explicit NativeSurface(EGLNativeSurface*);
290
291 int advance_buffer(MirBufferPackage* buffer_package);
292 int get_parameters(MirSurfaceParameters* surface_parameters);
293 int set_swapinterval(int interval);
294+ void use_native_surface(EGLNativeSurface* native_surface);
295
296 private:
297 bool starting;
298- EGLNativeSurface& surface;
299+ EGLNativeSurface* surface;
300 };
301
302 }
303
304=== modified file 'tests/acceptance-tests/throwback/test_client_library_errors.cpp'
305--- tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-08-25 01:11:51 +0000
306+++ tests/acceptance-tests/throwback/test_client_library_errors.cpp 2016-10-04 20:14:55 +0000
307@@ -78,6 +78,10 @@
308 dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context);
309 }
310
311+ void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/) override
312+ {
313+ }
314+
315 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override
316 {
317 if (should_fail<Method::create_egl_native_window, failure_set>())
318
319=== modified file 'tests/include/mir_test_framework/stub_client_platform_factory.h'
320--- tests/include/mir_test_framework/stub_client_platform_factory.h 2016-08-12 18:41:22 +0000
321+++ tests/include/mir_test_framework/stub_client_platform_factory.h 2016-10-04 20:14:55 +0000
322@@ -33,6 +33,7 @@
323 void populate(MirPlatformPackage& package) const override;
324 MirPlatformMessage* platform_operation(MirPlatformMessage const*) override;
325 std::shared_ptr<mir::client::ClientBufferFactory> create_buffer_factory() override;
326+ void use_egl_native_window(std::shared_ptr<void> native_window, mir::client::EGLNativeSurface* surface) override;
327 std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface* surface) override;
328 std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override;
329 MirNativeBuffer* convert_native_buffer(mir::graphics::NativeBuffer* buf) const override;
330
331=== modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp'
332--- tests/mir_test_framework/stub_client_platform_factory.cpp 2016-09-19 04:16:15 +0000
333+++ tests/mir_test_framework/stub_client_platform_factory.cpp 2016-10-04 20:14:55 +0000
334@@ -71,6 +71,10 @@
335 return std::make_shared<StubPlatformBufferFactory>();
336 }
337
338+void mtf::StubClientPlatform::use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/)
339+{
340+}
341+
342 std::shared_ptr<void> mtf::StubClientPlatform::create_egl_native_window(mir::client::EGLNativeSurface* surface)
343 {
344 return std::shared_ptr<void>{surface, [](void*){}};
345
346=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
347--- tests/unit-tests/client/test_client_buffer_stream.cpp 2016-08-10 10:43:39 +0000
348+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2016-10-04 20:14:55 +0000
349@@ -71,6 +71,9 @@
350 void populate(MirPlatformPackage& /* package */) const override
351 {
352 }
353+ void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mcl::EGLNativeSurface* /*surface*/) override
354+ {
355+ }
356 std::shared_ptr<void> create_egl_native_window(mcl::EGLNativeSurface * /* surface */) override
357 {
358 return mt::fake_shared(egl_native_window);
359
360=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
361--- tests/unit-tests/client/test_mir_connection.cpp 2016-09-22 12:20:33 +0000
362+++ tests/unit-tests/client/test_mir_connection.cpp 2016-10-04 20:14:55 +0000
363@@ -206,6 +206,7 @@
364 MOCK_CONST_METHOD0(platform_type, MirPlatformType());
365 MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*));
366 MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>());
367+ MOCK_METHOD2(use_egl_native_window, void(std::shared_ptr<void>, mcl::EGLNativeSurface*));
368 MOCK_METHOD1(create_egl_native_window, std::shared_ptr<void>(mcl::EGLNativeSurface*));
369 MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>());
370 MOCK_CONST_METHOD2(get_egl_pixel_format,
371
372=== modified file 'tests/unit-tests/platforms/android/CMakeLists.txt'
373--- tests/unit-tests/platforms/android/CMakeLists.txt 2016-08-05 15:32:58 +0000
374+++ tests/unit-tests/platforms/android/CMakeLists.txt 2016-10-04 20:14:55 +0000
375@@ -4,6 +4,11 @@
376 ${ANDROID_HEADERS_INCLUDE_DIRS}
377 ${PROJECT_SOURCE_DIR}/src/platforms/android/include
378 )
379+
380+set(
381+ ANDROID_UNIT_TEST_SOURCES
382+)
383+
384 add_subdirectory("server")
385 add_subdirectory("client")
386
387
388=== modified file 'tests/unit-tests/platforms/android/client/test_android_client_platform.cpp'
389--- tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-01-29 08:18:22 +0000
390+++ tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-10-04 20:14:55 +0000
391@@ -16,6 +16,7 @@
392 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
393 */
394
395+#include "mir_native_window.h"
396 #include "mir/client_platform.h"
397 #include "mir/test/doubles/mock_client_context.h"
398 #include "mir/test/doubles/mock_egl_native_surface.h"
399@@ -59,6 +60,20 @@
400 EXPECT_NE(nullptr, egl_native_window);
401 }
402
403+TEST_F(AndroidClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface)
404+{
405+ auto egl_native_window = platform->create_egl_native_window(nullptr);
406+ EXPECT_NE(nullptr, egl_native_window);
407+}
408+
409+TEST_F(AndroidClientPlatformTest, error_interpreter_used_with_null_native_surface)
410+{
411+ auto egl_native_window = platform->create_egl_native_window(nullptr);
412+ auto native_window = reinterpret_cast<mir::graphics::android::MirNativeWindow*>(egl_native_window.get());
413+ ANativeWindow& window = *native_window;
414+ EXPECT_EQ(window.setSwapInterval(&window, 1), -1);
415+}
416+
417 TEST_F(AndroidClientPlatformTest, egl_pixel_format_asks_the_driver)
418 {
419 auto const d = reinterpret_cast<EGLDisplay>(0x1234);
420
421=== modified file 'tests/unit-tests/platforms/android/client/test_android_native_window.cpp'
422--- tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-09-19 04:16:15 +0000
423+++ tests/unit-tests/platforms/android/client/test_android_native_window.cpp 2016-10-04 20:14:55 +0000
424@@ -73,6 +73,22 @@
425
426 }
427
428+TEST_F(AndroidNativeWindowTest, use_native_surface_call_replaces_existing_interpreter)
429+{
430+ std::shared_ptr<MockAndroidDriverInterpreter> const new_driver_interpreter =
431+ std::make_shared<NiceMock<MockAndroidDriverInterpreter>>();
432+
433+ // Test that the call goes to the new interpreter instead of the old one
434+ EXPECT_CALL(*mock_driver_interpreter, sync_to_display(true))
435+ .Times(0);
436+
437+ EXPECT_CALL(*new_driver_interpreter, sync_to_display(true))
438+ .Times(1);
439+
440+ mir_native_window.use_native_surface(new_driver_interpreter);
441+ window.setSwapInterval(&window, 1);
442+}
443+
444 TEST_F(AndroidNativeWindowTest, native_window_swapinterval)
445 {
446 ASSERT_NE(nullptr, window.setSwapInterval);
447
448=== modified file 'tests/unit-tests/platforms/mesa/client/test_client_platform.cpp'
449--- tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-05-26 03:59:12 +0000
450+++ tests/unit-tests/platforms/mesa/client/test_client_platform.cpp 2016-10-04 20:14:55 +0000
451@@ -22,6 +22,7 @@
452 #include "src/platforms/mesa/client/mesa_native_display_container.h"
453 #include "mir_test_framework/client_platform_factory.h"
454 #include "mir/test/doubles/mock_egl.h"
455+#include "mir/test/doubles/mock_egl_native_surface.h"
456
457 #include "mir_toolkit/mir_client_library.h"
458 #include "mir_toolkit/mesa/native_display.h"
459@@ -155,3 +156,16 @@
460 EXPECT_EQ(mir_pixel_format_xrgb_8888, platform->get_egl_pixel_format(d, c));
461 EXPECT_EQ(mir_pixel_format_invalid, platform->get_egl_pixel_format(d, c));
462 }
463+
464+TEST_F(MesaClientPlatformTest, egl_native_window_is_set)
465+{
466+ testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface;
467+ auto egl_native_window = platform->create_egl_native_window(&mock_surface);
468+ EXPECT_NE(nullptr, egl_native_window);
469+}
470+
471+TEST_F(MesaClientPlatformTest, egl_native_window_can_be_set_with_null_native_surface)
472+{
473+ auto egl_native_window = platform->create_egl_native_window(nullptr);
474+ EXPECT_NE(nullptr, egl_native_window);
475+}
476
477=== modified file 'tests/unit-tests/platforms/mesa/client/test_native_surface.cpp'
478--- tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-09-19 04:16:15 +0000
479+++ tests/unit-tests/platforms/mesa/client/test_native_surface.cpp 2016-10-04 20:14:55 +0000
480@@ -57,7 +57,7 @@
481 mg::mesa::NativeBuffer native_buffer;
482 testing::NiceMock<mtd::MockClientBuffer> mock_buffer;
483 testing::NiceMock<mtd::MockEGLNativeSurface> mock_surface;
484- mclg::NativeSurface native_surface{mock_surface};
485+ mclg::NativeSurface native_surface{&mock_surface};
486 };
487
488 TEST_F(MesaClientNativeSurfaceTest, basic_parameters)
489@@ -153,3 +153,38 @@
490
491 EXPECT_EQ(MIR_MESA_FALSE, native_surface.set_swapinterval(0));
492 }
493+
494+TEST_F(MesaClientNativeSurfaceTest, null_native_surface_returns_error)
495+{
496+ using namespace testing;
497+
498+ MirSurfaceParameters params;
499+ MirBufferPackage buffer_package;
500+
501+ mclg::NativeSurface null_native_surface{nullptr};
502+
503+ EXPECT_EQ(MIR_MESA_FALSE,
504+ null_native_surface.surface_get_parameters(&null_native_surface, &params));
505+ EXPECT_EQ(MIR_MESA_FALSE,
506+ null_native_surface.surface_advance_buffer(&null_native_surface, &buffer_package));
507+ EXPECT_EQ(MIR_MESA_FALSE,
508+ null_native_surface.surface_set_swapinterval(&null_native_surface, 1));
509+}
510+
511+TEST_F(MesaClientNativeSurfaceTest, native_surface_after_null_returns_success)
512+{
513+ using namespace testing;
514+
515+ MirSurfaceParameters params;
516+ MirBufferPackage buffer_package;
517+
518+ mclg::NativeSurface native_surface{nullptr};
519+
520+ native_surface.use_native_surface(&mock_surface);
521+ EXPECT_EQ(MIR_MESA_TRUE,
522+ native_surface.surface_get_parameters(&native_surface, &params));
523+ EXPECT_EQ(MIR_MESA_TRUE,
524+ native_surface.surface_advance_buffer(&native_surface, &buffer_package));
525+ EXPECT_EQ(MIR_MESA_TRUE,
526+ native_surface.surface_set_swapinterval(&native_surface, 1));
527+}

Subscribers

People subscribed via source and target branches