Mir

Merge lp:~cemil-azizoglu/mir/create-chain-from-render-surface into lp:mir

Proposed by Cemil Azizoglu
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 3868
Proposed branch: lp:~cemil-azizoglu/mir/create-chain-from-render-surface
Merge into: lp:mir
Prerequisite: lp:~cemil-azizoglu/mir/separate_out_render_surface_tests
Diff against target: 822 lines (+404/-57)
15 files modified
playground/mir_demo_client_chain_jumping_buffers.c (+19/-10)
playground/mir_demo_client_prerendered_frames.c (+12/-4)
src/client/error_render_surface.cpp (+11/-4)
src/client/error_render_surface.h (+1/-0)
src/client/error_stream.cpp (+14/-12)
src/client/mir_connection.cpp (+13/-0)
src/client/mir_connection.h (+4/-0)
src/client/mir_render_surface.h (+1/-0)
src/client/mir_render_surface_api.cpp (+15/-0)
src/client/render_surface.cpp (+25/-13)
src/client/render_surface.h (+3/-0)
src/client/symbols.map (+1/-0)
src/include/client/mir_toolkit/mir_render_surface.h (+14/-2)
tests/acceptance-tests/staging/test_render_surface.cpp (+158/-2)
tests/unit-tests/client/test_mir_render_surface.cpp (+113/-10)
To merge this branch: bzr merge lp:~cemil-azizoglu/mir/create-chain-from-render-surface
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+312211@code.launchpad.net

This proposal supersedes a proposal from 2016-11-30.

Commit message

Get presentation chain from a render surface.

Description of the change

Get presentation chain from a render surface.

I also modified the two presentation chain examples in the playground to use render surfaces.

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

PASSED: Continuous integration, rev:3856
https://mir-jenkins.ubuntu.com/job/mir-ci/2295/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2982
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3047
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3039
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3039
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3039
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3011/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/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3011/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3011/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/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3011/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/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3011/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/3011
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3011/artifact/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:3857
https://mir-jenkins.ubuntu.com/job/mir-ci/2302/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2996
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3061
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3053
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3053
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3053
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3025/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/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3025/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3025/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/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3025/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/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3025/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/3025
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3025/artifact/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:3858
https://mir-jenkins.ubuntu.com/job/mir-ci/2303/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2998
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3063
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3055
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3055
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3055
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3027/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/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3027/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3027/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/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3027/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/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3027/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/3027
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3027/artifact/output/*zip*/output.zip

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

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

(just repeating myself from email chain)
The signature looks good to me. I think its more straightforward internally and for the client if MirRenderSurface doesn't have one-time factory-like methods (the _get_ ones), but rather there are create/destroy (discussed in email chain). So, I guess on this point, I'm 'needs info' about if we're going to use create/destroy as opposed to get (and can wait for the email chain to figure that out).
Like, the function is described as
+ * Obtain the presentation chain backing a given render surface
but what's really going on is an object is created that has the same lifetime as MirRenderSurface, and it precludes the use of mir_render_surface_get_buffer_stream

prior problem, may as well fix in this MP:
121: + throw std::runtime_error(error);
Recently popped up in one of my MP's I guess the 'standard mir' way is to use BOOST_THROW_EXCEPTION instead of just throw:
https://code.launchpad.net/~mir-team/mir/mesa-auth-extensions/+merge/312045

needs info:
+ EXPECT_THAT(bs2, Eq(nullptr));
Returning an "error object" would seem more appropriate to the mir client api?

needs fixing:
+ auto determine_physical_size = [](MirRenderSurface* rs) -> geom::Size
+ {
+ int width = -1;
+ int height = -1;
+ mir_render_surface_get_size(rs, &width, &height);
+ return {width, height};
+ };
repeated code, and not really needed. The client is not required to create its buffers (or bufferstreams) based from the logical size that the rs has.

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

Just to clarify, the create/destroy vs get is probably for a followup mp, not part of the 'needs fixing'

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

> (just repeating myself from email chain)
> The signature looks good to me. I think its more straightforward internally
> and for the client if MirRenderSurface doesn't have one-time factory-like
> methods (the _get_ ones), but rather there are create/destroy (discussed in
> email chain). So, I guess on this point, I'm 'needs info' about if we're going
> to use create/destroy as opposed to get (and can wait for the email chain to
> figure that out).
> Like, the function is described as
> + * Obtain the presentation chain backing a given render surface
> but what's really going on is an object is created that has the same lifetime
> as MirRenderSurface, and it precludes the use of
> mir_render_surface_get_buffer_stream

Ack, will wait for the outcome of the discussion.

>
> prior problem, may as well fix in this MP:
> 121: + throw std::runtime_error(error);
> Recently popped up in one of my MP's I guess the 'standard mir' way is to use
> BOOST_THROW_EXCEPTION instead of just throw:
> https://code.launchpad.net/~mir-team/mir/mesa-auth-extensions/+merge/312045

Fixed, also fixed those in error_stream.cpp

>
> needs info:
> + EXPECT_THAT(bs2, Eq(nullptr));
> Returning an "error object" would seem more appropriate to the mir client api?
>

Though seemingly innocent, this will require a bunch of superfluous code changes for not much return (due to the throw coming from render_surface.cpp, not mir_connection.cpp where the error stream code is, along with necessary constructs like the surface_map). There are also other cases where we return nullptr (e.g. in buffer_stream_api.cpp, so it's not totally inconsistent). We can more easily do this once, the render surfaces become the authoritative way to obtain content (as opposed to being able to do that through MirConnection, too).

> needs fixing:
> + auto determine_physical_size = [](MirRenderSurface* rs) -> geom::Size
> + {
> + int width = -1;
> + int height = -1;
> + mir_render_surface_get_size(rs, &width, &height);
> + return {width, height};
> + };
> repeated code, and not really needed. The client is not required to create its
> buffers (or bufferstreams) based from the logical size that the rs has.

Fixed.

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

PASSED: Continuous integration, rev:3859
https://mir-jenkins.ubuntu.com/job/mir-ci/2305/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3000
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3065
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3057
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3057
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3057
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3029/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/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3029/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3029/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/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3029/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/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3029/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/3029
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3029/artifact/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:3860
https://mir-jenkins.ubuntu.com/job/mir-ci/2306/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3001
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3066
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3058
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3058
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3058
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3030/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/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3030/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3030/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/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3030/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/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3030/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/3030
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3030/artifact/output/*zip*/output.zip

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

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

Did anyone else notice how many related client objects we have now?...

  MirSurface
  MirBufferStream
  MirPresentationChain
  MirRenderSurface

Surely someone who understands what these all are could try and reduce the number? (and shorten their names)

Revision history for this message
Chris Halse Rogers (raof) wrote :

Of course we could collapse those all into one type, just like we could collapse *all* Mir types into void*.

But each of those types relates to a thing with distinct properties and uses, so the only way you'll reduce the number of types is by conflating two concepts.

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

> > (just repeating myself from email chain)
> > The signature looks good to me. I think its more straightforward internally
> > and for the client if MirRenderSurface doesn't have one-time factory-like
> > methods (the _get_ ones), but rather there are create/destroy (discussed in
> > email chain). So, I guess on this point, I'm 'needs info' about if we're
> going
> > to use create/destroy as opposed to get (and can wait for the email chain to
> > figure that out).
> > Like, the function is described as
> > + * Obtain the presentation chain backing a given render surface
> > but what's really going on is an object is created that has the same
> lifetime
> > as MirRenderSurface, and it precludes the use of
> > mir_render_surface_get_buffer_stream
>
> Ack, will wait for the outcome of the discussion.
>

Sure, would even be happy to spike the idea.

> >
> > prior problem, may as well fix in this MP:
> > 121: + throw std::runtime_error(error);
> > Recently popped up in one of my MP's I guess the 'standard mir' way is to
> use
> > BOOST_THROW_EXCEPTION instead of just throw:
> > https://code.launchpad.net/~mir-team/mir/mesa-auth-extensions/+merge/312045
>
> Fixed, also fixed those in error_stream.cpp
>
> >
> > needs info:
> > + EXPECT_THAT(bs2, Eq(nullptr));
> > Returning an "error object" would seem more appropriate to the mir client
> api?
> >
>
> Though seemingly innocent, this will require a bunch of superfluous code
> changes for not much return (due to the throw coming from render_surface.cpp,
> not mir_connection.cpp where the error stream code is, along with necessary
> constructs like the surface_map). There are also other cases where we return
> nullptr (e.g. in buffer_stream_api.cpp, so it's not totally inconsistent). We
> can more easily do this once, the render surfaces become the authoritative way
> to obtain content (as opposed to being able to do that through MirConnection,
> too).
>

So sounds like something that we will do, once its easier to move the code in src/client. The MirConnection object particularly needs a cleanup to make this easier.

> > needs fixing:
> > + auto determine_physical_size = [](MirRenderSurface* rs) -> geom::Size
> > + {
> > + int width = -1;
> > + int height = -1;
> > + mir_render_surface_get_size(rs, &width, &height);
> > + return {width, height};
> > + };
> > repeated code, and not really needed. The client is not required to create
> its
> > buffers (or bufferstreams) based from the logical size that the rs has.
>
> Fixed.

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

> Did anyone else notice how many related client objects we have now?...
>
> MirSurface
> MirBufferStream
> MirPresentationChain
> MirRenderSurface
>
> Surely someone who understands what these all are could try and reduce the
> number? (and shorten their names)

As Chris mentioned, they have different purposes, so they have different names.
As talked about before, the names might be off, but they're hard to move.

MirSurface -> the window, contains input, graphics, etc
MirRenderSurface-> the graphics content
MirPresentationChain -> a buffer-based submission
MirBufferStream -> the legacy type, with swap-based submissions

Now, I think that MirRenderSurface and MirPresentationChain are pretty darn close as far as what they are, and possibly could be consolidated. This gives small benefit in my estimation though, and makes the MirBufferStream usage stranger.

MirBufferStream is largely a helper object provided for legacy/convenience reasons. It is built internally on MirPresentationChain+MirBuffers these days.

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

+ //TODO: Figure out how to handle mir_buffer_usage_hardware once
+ // EGL is made to support RSs.
+

I think its also valuable (in terms of saving work) to figure out how to chase the MirBufferUsage field out of MirBufferStream.

(in the same line as https://code.launchpad.net/~mir-team/mir/android-buffer-alloc-extension/+merge/312293)

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

> + //TODO: Figure out how to handle mir_buffer_usage_hardware once
> + // EGL is made to support RSs.
> +
>
> I think its also valuable (in terms of saving work) to figure out how to chase
> the MirBufferUsage field out of MirBufferStream.
>
> (in the same line as https://code.launchpad.net/~mir-team/mir/android-buffer-
> alloc-extension/+merge/312293)

oh, and maybe not in this MP, as its a bit of a separate discussion ^_^

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'playground/mir_demo_client_chain_jumping_buffers.c'
--- playground/mir_demo_client_chain_jumping_buffers.c 2016-11-16 12:50:00 +0000
+++ playground/mir_demo_client_chain_jumping_buffers.c 2016-12-01 23:49:58 +0000
@@ -21,6 +21,7 @@
21#include <mir_toolkit/mir_buffer_stream.h>21#include <mir_toolkit/mir_buffer_stream.h>
22#include <mir_toolkit/mir_surface.h>22#include <mir_toolkit/mir_surface.h>
23#include <mir_toolkit/mir_presentation_chain.h>23#include <mir_toolkit/mir_presentation_chain.h>
24#include <mir_toolkit/mir_render_surface.h>
24#include <mir_toolkit/mir_buffer.h>25#include <mir_toolkit/mir_buffer.h>
25#include <mir_toolkit/version.h>26#include <mir_toolkit/version.h>
26#include <sys/types.h>27#include <sys/types.h>
@@ -174,9 +175,17 @@
174 unsigned int spare_buffer = 0;175 unsigned int spare_buffer = 0;
175176
176 MirPresentationChain* chain[num_chains];177 MirPresentationChain* chain[num_chains];
178 MirRenderSurface* render_surface[num_chains];
177 for(unsigned int i = 0u; i < num_chains; i++)179 for(unsigned int i = 0u; i < num_chains; i++)
178 {180 {
179 chain[i] = mir_connection_create_presentation_chain_sync(connection);181 render_surface[i] = mir_connection_create_render_surface_sync(connection, chain_width, chain_height);
182 if (!mir_render_surface_is_valid(render_surface[i]))
183 {
184 printf("could not create render surface\n");
185 return -1;
186 }
187
188 chain[i] = mir_render_surface_get_presentation_chain(render_surface[i]);
180 if (!mir_presentation_chain_is_valid(chain[i]))189 if (!mir_presentation_chain_is_valid(chain[i]))
181 {190 {
182 printf("could not create MirPresentationChain\n");191 printf("could not create MirPresentationChain\n");
@@ -193,14 +202,14 @@
193202
194 //Arrange a 2x2 grid of chains within surface203 //Arrange a 2x2 grid of chains within surface
195 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);204 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
196 mir_surface_spec_add_presentation_chain(205 mir_surface_spec_add_render_surface(
197 spec, chain_width, chain_height, displacement_x, displacement_y, chain[0]);206 spec, render_surface[0], chain_width, chain_height, displacement_x, displacement_y);
198 mir_surface_spec_add_presentation_chain(207 mir_surface_spec_add_render_surface(
199 spec, chain_width, chain_height, chain_width, displacement_y, chain[1]);208 spec, render_surface[1], chain_width, chain_height, chain_width, displacement_y);
200 mir_surface_spec_add_presentation_chain(209 mir_surface_spec_add_render_surface(
201 spec, chain_width, chain_height, displacement_x, chain_height, chain[2]);210 spec, render_surface[2], chain_width, chain_height, displacement_x, chain_height);
202 mir_surface_spec_add_presentation_chain(211 mir_surface_spec_add_render_surface(
203 spec, chain_width, chain_height, chain_width, chain_height, chain[3]);212 spec, render_surface[3], chain_width, chain_height, chain_width, chain_height);
204 MirSurface* surface = mir_surface_create_sync(spec);213 MirSurface* surface = mir_surface_create_sync(spec);
205 mir_surface_spec_release(spec);214 mir_surface_spec_release(spec);
206215
@@ -256,7 +265,7 @@
256 for (unsigned int i = 0u; i < num_buffers; i++)265 for (unsigned int i = 0u; i < num_buffers; i++)
257 mir_buffer_release(buffer_available[i].buffer);266 mir_buffer_release(buffer_available[i].buffer);
258 for (unsigned int i = 0u; i < num_chains; i++)267 for (unsigned int i = 0u; i < num_chains; i++)
259 mir_presentation_chain_release(chain[i]);268 mir_render_surface_release(render_surface[i]);
260 mir_surface_release_sync(surface);269 mir_surface_release_sync(surface);
261 mir_connection_release(connection);270 mir_connection_release(connection);
262 return 0;271 return 0;
263272
=== modified file 'playground/mir_demo_client_prerendered_frames.c'
--- playground/mir_demo_client_prerendered_frames.c 2016-11-16 12:50:00 +0000
+++ playground/mir_demo_client_prerendered_frames.c 2016-12-01 23:49:58 +0000
@@ -21,6 +21,7 @@
21#include <mir_toolkit/mir_buffer_stream.h>21#include <mir_toolkit/mir_buffer_stream.h>
22#include <mir_toolkit/mir_surface.h>22#include <mir_toolkit/mir_surface.h>
23#include <mir_toolkit/mir_presentation_chain.h>23#include <mir_toolkit/mir_presentation_chain.h>
24#include <mir_toolkit/mir_render_surface.h>
24#include <mir_toolkit/mir_buffer.h>25#include <mir_toolkit/mir_buffer.h>
25#include <mir_toolkit/version.h>26#include <mir_toolkit/version.h>
26#include <sys/types.h>27#include <sys/types.h>
@@ -146,7 +147,14 @@
146 return -1;147 return -1;
147 }148 }
148149
149 MirPresentationChain* chain = mir_connection_create_presentation_chain_sync(connection);150 MirRenderSurface* render_surface = mir_connection_create_render_surface_sync(connection, width, height);
151 if (!mir_render_surface_is_valid(render_surface))
152 {
153 printf("could not create a render surface\n");
154 return -1;
155 }
156
157 MirPresentationChain* chain = mir_render_surface_get_presentation_chain(render_surface);
150 if (!mir_presentation_chain_is_valid(chain))158 if (!mir_presentation_chain_is_valid(chain))
151 {159 {
152 printf("could not create MirPresentationChain\n");160 printf("could not create MirPresentationChain\n");
@@ -161,8 +169,8 @@
161 }169 }
162170
163 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);171 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
164 mir_surface_spec_add_presentation_chain(172 mir_surface_spec_add_render_surface(
165 spec, width, height, displacement_x, displacement_y, chain);173 spec, render_surface, width, height, displacement_x, displacement_y);
166 MirSurface* surface = mir_surface_create_sync(spec);174 MirSurface* surface = mir_surface_create_sync(spec);
167 if (!mir_surface_is_valid(surface))175 if (!mir_surface_is_valid(surface))
168 {176 {
@@ -224,7 +232,7 @@
224232
225 for (i = 0u; i < num_prerendered_frames; i++)233 for (i = 0u; i < num_prerendered_frames; i++)
226 mir_buffer_release(buffer_available[i].buffer);234 mir_buffer_release(buffer_available[i].buffer);
227 mir_presentation_chain_release(chain);235 mir_render_surface_release(render_surface);
228 mir_surface_release_sync(surface);236 mir_surface_release_sync(surface);
229 mir_connection_release(connection);237 mir_connection_release(connection);
230 return 0;238 return 0;
231239
=== modified file 'src/client/error_render_surface.cpp'
--- src/client/error_render_surface.cpp 2016-11-22 18:44:52 +0000
+++ src/client/error_render_surface.cpp 2016-12-01 23:49:58 +0000
@@ -18,6 +18,8 @@
1818
19#include "error_render_surface.h"19#include "error_render_surface.h"
2020
21#include <boost/throw_exception.hpp>
22
21namespace mcl = mir::client;23namespace mcl = mir::client;
2224
23mcl::ErrorRenderSurface::ErrorRenderSurface(25mcl::ErrorRenderSurface::ErrorRenderSurface(
@@ -34,17 +36,17 @@
3436
35mir::frontend::BufferStreamId mcl::ErrorRenderSurface::stream_id() const37mir::frontend::BufferStreamId mcl::ErrorRenderSurface::stream_id() const
36{38{
37 throw std::runtime_error(error);39 BOOST_THROW_EXCEPTION(std::runtime_error(error));
38}40}
3941
40mir::geometry::Size mcl::ErrorRenderSurface::size() const42mir::geometry::Size mcl::ErrorRenderSurface::size() const
41{43{
42 throw std::runtime_error(error);44 BOOST_THROW_EXCEPTION(std::runtime_error(error));
43}45}
4446
45void mcl::ErrorRenderSurface::set_size(mir::geometry::Size /*size*/)47void mcl::ErrorRenderSurface::set_size(mir::geometry::Size /*size*/)
46{48{
47 throw std::runtime_error(error);49 BOOST_THROW_EXCEPTION(std::runtime_error(error));
48}50}
4951
50bool mcl::ErrorRenderSurface::valid() const52bool mcl::ErrorRenderSurface::valid() const
@@ -57,7 +59,12 @@
57 MirPixelFormat /*format*/,59 MirPixelFormat /*format*/,
58 MirBufferUsage /*buffer_usage*/)60 MirBufferUsage /*buffer_usage*/)
59{61{
60 throw std::runtime_error(error);62 BOOST_THROW_EXCEPTION(std::runtime_error(error));
63}
64
65MirPresentationChain* mcl::ErrorRenderSurface::get_presentation_chain()
66{
67 BOOST_THROW_EXCEPTION(std::runtime_error(error));
61}68}
6269
63char const* mcl::ErrorRenderSurface::get_error_message() const70char const* mcl::ErrorRenderSurface::get_error_message() const
6471
=== modified file 'src/client/error_render_surface.h'
--- src/client/error_render_surface.h 2016-11-22 18:44:52 +0000
+++ src/client/error_render_surface.h 2016-12-01 23:49:58 +0000
@@ -41,6 +41,7 @@
41 int width, int height,41 int width, int height,
42 MirPixelFormat format,42 MirPixelFormat format,
43 MirBufferUsage buffer_usage) override;43 MirBufferUsage buffer_usage) override;
44 MirPresentationChain* get_presentation_chain() override;
44private:45private:
45 std::string const error;46 std::string const error;
46 MirConnection* const connection_;47 MirConnection* const connection_;
4748
=== modified file 'src/client/error_stream.cpp'
--- src/client/error_stream.cpp 2016-11-14 21:59:19 +0000
+++ src/client/error_stream.cpp 2016-12-01 23:49:58 +0000
@@ -18,6 +18,8 @@
1818
19#include "error_stream.h"19#include "error_stream.h"
2020
21#include <boost/throw_exception.hpp>
22
21namespace mcl = mir::client;23namespace mcl = mir::client;
2224
23mcl::ErrorStream::ErrorStream(25mcl::ErrorStream::ErrorStream(
@@ -57,53 +59,53 @@
5759
58MirSurfaceParameters mcl::ErrorStream::get_parameters() const60MirSurfaceParameters mcl::ErrorStream::get_parameters() const
59{61{
60 throw std::runtime_error(error);62 BOOST_THROW_EXCEPTION(std::runtime_error(error));
61}63}
62std::shared_ptr<mcl::ClientBuffer> mcl::ErrorStream::get_current_buffer()64std::shared_ptr<mcl::ClientBuffer> mcl::ErrorStream::get_current_buffer()
63{65{
64 throw std::runtime_error(error);66 BOOST_THROW_EXCEPTION(std::runtime_error(error));
65}67}
66uint32_t mcl::ErrorStream::get_current_buffer_id()68uint32_t mcl::ErrorStream::get_current_buffer_id()
67{69{
68 throw std::runtime_error(error);70 BOOST_THROW_EXCEPTION(std::runtime_error(error));
69}71}
70EGLNativeWindowType mcl::ErrorStream::egl_native_window()72EGLNativeWindowType mcl::ErrorStream::egl_native_window()
71{73{
72 throw std::runtime_error(error);74 BOOST_THROW_EXCEPTION(std::runtime_error(error));
73}75}
74MirWaitHandle* mcl::ErrorStream::next_buffer(std::function<void()> const&)76MirWaitHandle* mcl::ErrorStream::next_buffer(std::function<void()> const&)
75{77{
76 throw std::runtime_error(error);78 BOOST_THROW_EXCEPTION(std::runtime_error(error));
77}79}
78std::shared_ptr<mcl::MemoryRegion> mcl::ErrorStream::secure_for_cpu_write()80std::shared_ptr<mcl::MemoryRegion> mcl::ErrorStream::secure_for_cpu_write()
79{81{
80 throw std::runtime_error(error);82 BOOST_THROW_EXCEPTION(std::runtime_error(error));
81}83}
8284
83int mcl::ErrorStream::swap_interval() const85int mcl::ErrorStream::swap_interval() const
84{86{
85 throw std::runtime_error(error);87 BOOST_THROW_EXCEPTION(std::runtime_error(error));
86}88}
87MirWaitHandle* mcl::ErrorStream::set_swap_interval(int)89MirWaitHandle* mcl::ErrorStream::set_swap_interval(int)
88{90{
89 throw std::runtime_error(error);91 BOOST_THROW_EXCEPTION(std::runtime_error(error));
90}92}
91MirNativeBuffer* mcl::ErrorStream::get_current_buffer_package()93MirNativeBuffer* mcl::ErrorStream::get_current_buffer_package()
92{94{
93 throw std::runtime_error(error);95 BOOST_THROW_EXCEPTION(std::runtime_error(error));
94}96}
95MirPlatformType mcl::ErrorStream::platform_type()97MirPlatformType mcl::ErrorStream::platform_type()
96{98{
97 throw std::runtime_error(error);99 BOOST_THROW_EXCEPTION(std::runtime_error(error));
98}100}
99MirWaitHandle* mcl::ErrorStream::set_scale(float)101MirWaitHandle* mcl::ErrorStream::set_scale(float)
100{102{
101 throw std::runtime_error(error);103 BOOST_THROW_EXCEPTION(std::runtime_error(error));
102}104}
103105
104mir::geometry::Size mcl::ErrorStream::size() const106mir::geometry::Size mcl::ErrorStream::size() const
105{107{
106 throw std::runtime_error(error);108 BOOST_THROW_EXCEPTION(std::runtime_error(error));
107}109}
108110
109void mcl::ErrorStream::buffer_available(mir::protobuf::Buffer const&) {}111void mcl::ErrorStream::buffer_available(mir::protobuf::Buffer const&) {}
110112
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2016-11-30 09:18:39 +0000
+++ src/client/mir_connection.cpp 2016-12-01 23:49:58 +0000
@@ -1172,6 +1172,19 @@
1172 return display_configuration->take_snapshot();1172 return display_configuration->take_snapshot();
1173}1173}
11741174
1175std::shared_ptr<mcl::PresentationChain> MirConnection::create_presentation_chain_with_id(
1176 MirRenderSurface* render_surface,
1177 mir::protobuf::BufferStream const& a_protobuf_bs)
1178{
1179 if (!client_buffer_factory)
1180 client_buffer_factory = platform->create_buffer_factory();
1181 auto chain = std::make_shared<mcl::PresentationChain>(
1182 this, a_protobuf_bs.id().value(), server, client_buffer_factory, buffer_factory);
1183
1184 surface_map->insert(render_surface->stream_id(), chain);
1185 return chain;
1186}
1187
1175void MirConnection::create_presentation_chain(1188void MirConnection::create_presentation_chain(
1176 mir_presentation_chain_callback callback,1189 mir_presentation_chain_callback callback,
1177 void *context)1190 void *context)
11781191
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2016-11-30 09:02:39 +0000
+++ src/client/mir_connection.h 2016-12-01 23:49:58 +0000
@@ -66,6 +66,7 @@
66class AsyncBufferFactory;66class AsyncBufferFactory;
67class MirBuffer;67class MirBuffer;
68class BufferStream;68class BufferStream;
69class PresentationChain;
6970
70namespace rpc71namespace rpc
71{72{
@@ -169,6 +170,9 @@
169 void create_presentation_chain(170 void create_presentation_chain(
170 mir_presentation_chain_callback callback,171 mir_presentation_chain_callback callback,
171 void *context);172 void *context);
173 std::shared_ptr<mir::client::PresentationChain> create_presentation_chain_with_id(
174 MirRenderSurface* render_surface,
175 mir::protobuf::BufferStream const& a_protobuf_bs);
172 void release_presentation_chain(MirPresentationChain* context);176 void release_presentation_chain(MirPresentationChain* context);
173177
174 void release_consumer_stream(MirBufferStream*);178 void release_consumer_stream(MirBufferStream*);
175179
=== modified file 'src/client/mir_render_surface.h'
--- src/client/mir_render_surface.h 2016-11-22 18:44:52 +0000
+++ src/client/mir_render_surface.h 2016-12-01 23:49:58 +0000
@@ -36,6 +36,7 @@
36 int width, int height,36 int width, int height,
37 MirPixelFormat format,37 MirPixelFormat format,
38 MirBufferUsage buffer_usage) = 0;38 MirBufferUsage buffer_usage) = 0;
39 virtual MirPresentationChain* get_presentation_chain() = 0;
39 virtual char const* get_error_message() const = 0;40 virtual char const* get_error_message() const = 0;
40 virtual ~MirRenderSurface() = default;41 virtual ~MirRenderSurface() = default;
41protected:42protected:
4243
=== modified file 'src/client/mir_render_surface_api.cpp'
--- src/client/mir_render_surface_api.cpp 2016-11-29 14:18:01 +0000
+++ src/client/mir_render_surface_api.cpp 2016-12-01 23:49:58 +0000
@@ -189,6 +189,21 @@
189 return nullptr;189 return nullptr;
190}190}
191191
192MirPresentationChain* mir_render_surface_get_presentation_chain(
193 MirRenderSurface* render_surface)
194try
195{
196 mir::require(render_surface);
197 auto connection = connection_map.connection(static_cast<void*>(render_surface));
198 auto rs = connection->connection_surface_map()->render_surface(render_surface);
199 return rs->get_presentation_chain();
200}
201catch (std::exception const& ex)
202{
203 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
204 return nullptr;
205}
206
192void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height)207void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height)
193{208{
194 mir::require(render_surface && width && height);209 mir::require(render_surface && width && height);
195210
=== modified file 'src/client/render_surface.cpp'
--- src/client/render_surface.cpp 2016-11-30 09:18:39 +0000
+++ src/client/render_surface.cpp 2016-12-01 23:49:58 +0000
@@ -27,7 +27,6 @@
27#include <boost/throw_exception.hpp>27#include <boost/throw_exception.hpp>
2828
29namespace mcl = mir::client;29namespace mcl = mir::client;
30namespace mclr = mcl::rpc;
31namespace geom = mir::geometry;30namespace geom = mir::geometry;
32namespace mp = mir::protobuf;31namespace mp = mir::protobuf;
33namespace mf = mir::frontend;32namespace mf = mir::frontend;
@@ -61,24 +60,37 @@
61 MirPixelFormat format,60 MirPixelFormat format,
62 MirBufferUsage buffer_usage)61 MirBufferUsage buffer_usage)
63{62{
64 if (!stream_from_id)63 if (chain_from_id || stream_from_id)
64 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
65
66 protobuf_bs->set_pixel_format(format);
67 protobuf_bs->set_buffer_usage(buffer_usage);
68 stream_from_id = connection_->create_client_buffer_stream_with_id(width,
69 height,
70 this,
71 *protobuf_bs);
72 if (buffer_usage == mir_buffer_usage_hardware)
65 {73 {
66 protobuf_bs->set_pixel_format(format);74 platform->use_egl_native_window(
67 protobuf_bs->set_buffer_usage(buffer_usage);75 wrapped_native_window, dynamic_cast<EGLNativeSurface*>(stream_from_id.get()));
68 stream_from_id = connection_->create_client_buffer_stream_with_id(width,
69 height,
70 this,
71 *protobuf_bs);
72 if (buffer_usage == mir_buffer_usage_hardware)
73 {
74 platform->use_egl_native_window(
75 wrapped_native_window, dynamic_cast<EGLNativeSurface*>(stream_from_id.get()));
76 }
77 }76 }
7877
79 return stream_from_id.get();78 return stream_from_id.get();
80}79}
8180
81MirPresentationChain* mcl::RenderSurface::get_presentation_chain()
82{
83 if (chain_from_id || stream_from_id)
84 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
85
86 chain_from_id = connection_->create_presentation_chain_with_id(this,
87 *protobuf_bs);
88 //TODO: Figure out how to handle mir_buffer_usage_hardware once
89 // EGL is made to support RSs.
90
91 return reinterpret_cast<MirPresentationChain*>(chain_from_id.get());
92}
93
82geom::Size mcl::RenderSurface::size() const94geom::Size mcl::RenderSurface::size() const
83{95{
84 std::lock_guard<decltype(size_mutex)> lk(size_mutex);96 std::lock_guard<decltype(size_mutex)> lk(size_mutex);
8597
=== modified file 'src/client/render_surface.h'
--- src/client/render_surface.h 2016-11-22 18:44:52 +0000
+++ src/client/render_surface.h 2016-12-01 23:49:58 +0000
@@ -39,6 +39,7 @@
39{39{
40class ClientPlatform;40class ClientPlatform;
41class BufferStream;41class BufferStream;
42class PresentationChain;
42class RenderSurface : public MirRenderSurface43class RenderSurface : public MirRenderSurface
43{44{
44public:45public:
@@ -57,6 +58,7 @@
57 int width, int height,58 int width, int height,
58 MirPixelFormat format,59 MirPixelFormat format,
59 MirBufferUsage buffer_usage) override;60 MirBufferUsage buffer_usage) override;
61 MirPresentationChain* get_presentation_chain() override;
6062
61private:63private:
62 MirConnection* const connection_;64 MirConnection* const connection_;
@@ -64,6 +66,7 @@
64 std::shared_ptr<ClientPlatform> platform;66 std::shared_ptr<ClientPlatform> platform;
65 std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs;67 std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs;
66 std::shared_ptr<mir::client::BufferStream> stream_from_id;68 std::shared_ptr<mir::client::BufferStream> stream_from_id;
69 std::shared_ptr<mir::client::PresentationChain> chain_from_id;
6770
68 std::mutex mutable size_mutex;71 std::mutex mutable size_mutex;
69 geometry::Size desired_size;72 geometry::Size desired_size;
7073
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2016-12-01 18:48:07 +0000
+++ src/client/symbols.map 2016-12-01 23:49:58 +0000
@@ -390,6 +390,7 @@
390 mir_connection_create_render_surface;390 mir_connection_create_render_surface;
391 mir_connection_create_render_surface_sync;391 mir_connection_create_render_surface_sync;
392 mir_render_surface_get_buffer_stream;392 mir_render_surface_get_buffer_stream;
393 mir_render_surface_get_presentation_chain;
393 mir_render_surface_is_valid;394 mir_render_surface_is_valid;
394 mir_render_surface_get_error_message;395 mir_render_surface_get_error_message;
395 mir_render_surface_get_size;396 mir_render_surface_get_size;
396397
=== modified file 'src/include/client/mir_toolkit/mir_render_surface.h'
--- src/include/client/mir_toolkit/mir_render_surface.h 2016-11-29 14:18:01 +0000
+++ src/include/client/mir_toolkit/mir_render_surface.h 2016-12-01 23:49:58 +0000
@@ -125,6 +125,9 @@
125 * \param [in] usage Requested buffer usage125 * \param [in] usage Requested buffer usage
126 *126 *
127 * \return The buffer stream contained in the given render surface127 * \return The buffer stream contained in the given render surface
128 * or 'nullptr' if it, or
129 * mir_render_surface_get_presentation_chain(), has already
130 * been called once
128 */131 */
129MirBufferStream* mir_render_surface_get_buffer_stream(132MirBufferStream* mir_render_surface_get_buffer_stream(
130 MirRenderSurface* render_surface,133 MirRenderSurface* render_surface,
@@ -133,13 +136,22 @@
133 MirBufferUsage usage);136 MirBufferUsage usage);
134137
135/**138/**
139 * Obtain the presentation chain backing a given render surface
140 *
141 * \return The chain contained in the given render surface
142 * or 'nullptr' if it, or
143 * mir_render_surface_get_buffer_stream(), has already
144 * been called once
145 */
146MirPresentationChain* mir_render_surface_get_presentation_chain(
147 MirRenderSurface* render_surface);
148
149/**
136 * Set the MirSurfaceSpec to display content contained in a render surface150 * Set the MirSurfaceSpec to display content contained in a render surface
137 *151 *
138 * \warning: The initial call to mir_surface_spec_add_render_surface will set152 * \warning: The initial call to mir_surface_spec_add_render_surface will set
139 * the bottom-most content, and subsequent calls will stack the153 * the bottom-most content, and subsequent calls will stack the
140 * content on top.154 * content on top.
141 * \warning: It's an error to call this function with a render surface
142 * that holds no content.
143 *155 *
144 * \param spec The surface_spec to be updated156 * \param spec The surface_spec to be updated
145 * \param render_surface The render surface containing the content to be displayed157 * \param render_surface The render surface containing the content to be displayed
146158
=== modified file 'tests/acceptance-tests/staging/test_render_surface.cpp'
--- tests/acceptance-tests/staging/test_render_surface.cpp 2016-11-29 22:59:26 +0000
+++ tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-01 23:49:58 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_render_surface.h"20#include "mir_toolkit/mir_render_surface.h"
21#include "mir_toolkit/mir_presentation_chain.h"
2122
22#include "mir/geometry/size.h"23#include "mir/geometry/size.h"
23#include "mir_test_framework/headless_in_process_server.h"24#include "mir_test_framework/headless_in_process_server.h"
@@ -57,7 +58,7 @@
57 mir_connection_release(connection);58 mir_connection_release(connection);
58}59}
5960
60TEST_F(RenderSurfaceTest, can_hand_out_buffer_streams)61TEST_F(RenderSurfaceTest, can_hand_out_buffer_stream)
61{62{
62 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);63 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
6364
@@ -86,6 +87,36 @@
86 mir_connection_release(connection);87 mir_connection_release(connection);
87}88}
8889
90TEST_F(RenderSurfaceTest, hands_out_buffer_stream_only_once)
91{
92 auto physical_size = logical_size;
93 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
94
95 auto rs = mir_connection_create_render_surface_sync(
96 connection, logical_size.width.as_int(), logical_size.height.as_int());
97
98 auto bs = mir_render_surface_get_buffer_stream(
99 rs,
100 physical_size.width.as_int(), physical_size.height.as_int(),
101 mir_pixel_format_abgr_8888,
102 mir_buffer_usage_hardware);
103
104 ASSERT_THAT(bs, NotNull());
105 EXPECT_TRUE(mir_buffer_stream_is_valid(bs));
106 EXPECT_THAT(mir_buffer_stream_get_error_message(bs), StrEq(""));
107
108 auto bs2 = mir_render_surface_get_buffer_stream(
109 rs,
110 physical_size.width.as_int(), physical_size.height.as_int(),
111 mir_pixel_format_abgr_8888,
112 mir_buffer_usage_hardware);
113
114 EXPECT_THAT(bs2, Eq(nullptr));
115
116 mir_render_surface_release(rs);
117 mir_connection_release(connection);
118}
119
89TEST_F(RenderSurfaceTest, dont_have_to_release_buffer_stream)120TEST_F(RenderSurfaceTest, dont_have_to_release_buffer_stream)
90{121{
91 auto physical_size = logical_size;122 auto physical_size = logical_size;
@@ -131,7 +162,7 @@
131 mir_connection_release(connection);162 mir_connection_release(connection);
132}163}
133164
134TEST_F(RenderSurfaceTest, content_can_be_constructed_after_surface_creation)165TEST_F(RenderSurfaceTest, stream_can_be_constructed_after_surface_creation)
135{166{
136 int const width{800}, height{600};167 int const width{800}, height{600};
137 MirPixelFormat const format{mir_pixel_format_abgr_8888};168 MirPixelFormat const format{mir_pixel_format_abgr_8888};
@@ -160,3 +191,128 @@
160 mir_surface_release_sync(surface);191 mir_surface_release_sync(surface);
161 mir_connection_release(connection);192 mir_connection_release(connection);
162}193}
194
195TEST_F(RenderSurfaceTest, can_hand_out_presentation_chain)
196{
197 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
198
199 auto rs = mir_connection_create_render_surface_sync(
200 connection, logical_size.width.as_int(), logical_size.height.as_int());
201
202 auto pc = mir_render_surface_get_presentation_chain(rs);
203
204 ASSERT_THAT(pc, NotNull());
205 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
206
207 mir_render_surface_release(rs);
208 mir_connection_release(connection);
209}
210
211TEST_F(RenderSurfaceTest, hands_out_presentation_chain_only_once)
212{
213 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
214
215 auto rs = mir_connection_create_render_surface_sync(
216 connection, logical_size.width.as_int(), logical_size.height.as_int());
217
218 auto pc = mir_render_surface_get_presentation_chain(rs);
219
220 ASSERT_THAT(pc, NotNull());
221 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
222
223 auto pc2 = mir_render_surface_get_presentation_chain(rs);
224
225 EXPECT_THAT(pc2, Eq(nullptr));
226
227 mir_render_surface_release(rs);
228 mir_connection_release(connection);
229}
230
231TEST_F(RenderSurfaceTest, chain_can_be_constructed_after_surface_creation)
232{
233 int const width{800}, height{600};
234 MirPixelFormat const format{mir_pixel_format_abgr_8888};
235
236 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
237
238 auto rs = mir_connection_create_render_surface_sync(
239 connection, logical_size.width.as_int(), logical_size.height.as_int());
240 auto spec = mir_connection_create_spec_for_normal_surface(connection,
241 width, height,
242 format);
243 mir_surface_spec_add_render_surface(spec, rs, width, height, 0, 0);
244 auto surface = mir_surface_create_sync(spec);
245 mir_surface_spec_release(spec);
246 auto pc = mir_render_surface_get_presentation_chain(rs);
247
248 EXPECT_THAT(surface, IsValid());
249 EXPECT_THAT(mir_surface_get_buffer_stream(surface), Eq(nullptr));
250 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
251
252 mir_render_surface_release(rs);
253 mir_surface_release_sync(surface);
254 mir_connection_release(connection);
255}
256
257TEST_F(RenderSurfaceTest, dont_have_to_release_presentation_chain)
258{
259 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
260
261 auto rs = mir_connection_create_render_surface_sync(
262 connection, logical_size.width.as_int(), logical_size.height.as_int());
263 auto pc = mir_render_surface_get_presentation_chain(rs);
264
265 ASSERT_THAT(pc, NotNull());
266 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
267
268 mir_render_surface_release(rs);
269 mir_connection_release(connection);
270}
271
272TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_chain_handed_out)
273{
274 auto physical_size = logical_size;
275 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
276
277 auto rs = mir_connection_create_render_surface_sync(
278 connection, logical_size.width.as_int(), logical_size.height.as_int());
279 auto pc = mir_render_surface_get_presentation_chain(rs);
280
281 ASSERT_THAT(pc, NotNull());
282 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
283
284 auto bs = mir_render_surface_get_buffer_stream(
285 rs,
286 physical_size.width.as_int(), physical_size.height.as_int(),
287 mir_pixel_format_abgr_8888,
288 mir_buffer_usage_hardware);
289
290 EXPECT_THAT(bs, Eq(nullptr));
291
292 mir_render_surface_release(rs);
293 mir_connection_release(connection);
294}
295
296TEST_F(RenderSurfaceTest, excepts_on_chain_request_if_stream_handed_out)
297{
298 auto physical_size = logical_size;
299 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
300
301 auto rs = mir_connection_create_render_surface_sync(
302 connection, logical_size.width.as_int(), logical_size.height.as_int());
303 auto bs = mir_render_surface_get_buffer_stream(
304 rs,
305 physical_size.width.as_int(), physical_size.height.as_int(),
306 mir_pixel_format_abgr_8888,
307 mir_buffer_usage_hardware);
308
309 ASSERT_THAT(bs, NotNull());
310 EXPECT_TRUE(mir_buffer_stream_is_valid(bs));
311
312 auto pc = mir_render_surface_get_presentation_chain(rs);
313
314 EXPECT_THAT(pc, Eq(nullptr));
315
316 mir_render_surface_release(rs);
317 mir_connection_release(connection);
318}
163319
=== modified file 'tests/unit-tests/client/test_mir_render_surface.cpp'
--- tests/unit-tests/client/test_mir_render_surface.cpp 2016-11-30 16:58:48 +0000
+++ tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-01 23:49:58 +0000
@@ -298,7 +298,7 @@
298 EXPECT_THAT(bs, NotNull());298 EXPECT_THAT(bs, NotNull());
299}299}
300300
301TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_more_than_once_returns_same_object)301TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_buffer_stream_more_than_once)
302{302{
303 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();303 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
304 auto id = 123;304 auto id = 123;
@@ -316,15 +316,14 @@
316316
317 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));317 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));
318318
319 auto bs1 = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,319 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
320 mir_buffer_usage_hardware);320 mir_buffer_usage_hardware);
321321
322 auto bs2 = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,322 EXPECT_THROW(
323 mir_buffer_usage_hardware);323 { rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
324324 mir_buffer_usage_hardware); },
325 EXPECT_THAT(bs1, NotNull());325 std::logic_error);
326 EXPECT_THAT(bs2, NotNull());326 EXPECT_THAT(bs, NotNull());
327 EXPECT_THAT(bs1, Eq(bs2));
328}327}
329328
330TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window)329TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window)
@@ -394,10 +393,114 @@
394393
395 EXPECT_TRUE(callback.invoked);394 EXPECT_TRUE(callback.invoked);
396 EXPECT_THAT(callback.resulting_render_surface, NotNull());395 EXPECT_THAT(callback.resulting_render_surface, NotNull());
396
397 auto rs = connection->connection_surface_map()->render_surface(397 auto rs = connection->connection_surface_map()->render_surface(
398 static_cast<void*>(callback.resulting_render_surface));398 static_cast<void*>(callback.resulting_render_surface));
399
399 EXPECT_THAT(rs->get_error_message(),400 EXPECT_THAT(rs->get_error_message(),
400 StrEq("Error processing buffer stream response during render "401 StrEq("Error processing buffer stream response during render "
401 "surface creation: no ID in response (disconnected?)"));402 "surface creation: no ID in response (disconnected?)"));
402 EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid()));403 EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid()));
403}404}
405
406TEST_F(MirRenderSurfaceTest, render_surface_can_create_presentation_chain)
407{
408 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
409 auto id = 123;
410
411 mp::BufferStream protobuf_bs;
412 mp::BufferStreamId bs_id;
413
414 bs_id.set_value(id);
415 *protobuf_bs.mutable_id() = bs_id;
416
417 auto native_window = mock_platform->create_egl_native_window(nullptr);
418
419 mcl::RenderSurface rs(
420 connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {});
421
422 auto pc = rs.get_presentation_chain();
423
424 EXPECT_THAT(pc, NotNull());
425}
426
427TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_presentation_chain_more_than_once)
428{
429 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
430 auto id = 123;
431
432 mp::BufferStream protobuf_bs;
433 mp::BufferStreamId bs_id;
434
435 bs_id.set_value(id);
436 *protobuf_bs.mutable_id() = bs_id;
437
438 auto native_window = mock_platform->create_egl_native_window(nullptr);
439
440 mcl::RenderSurface rs(
441 connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
442
443 auto pc = rs.get_presentation_chain();
444 EXPECT_THAT(pc, NotNull());
445
446 EXPECT_THROW(
447 { rs.get_presentation_chain(); },
448 std::logic_error);
449}
450
451TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_chain_after_stream)
452{
453 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
454 auto id = 123;
455
456 mp::BufferStream protobuf_bs;
457 mp::BufferStreamId bs_id;
458
459 bs_id.set_value(id);
460 *protobuf_bs.mutable_id() = bs_id;
461
462 auto native_window = mock_platform->create_egl_native_window(nullptr);
463
464 mcl::RenderSurface rs(connection.get(),
465 native_window,
466 mock_platform,
467 mt::fake_shared(protobuf_bs),
468 {});
469
470 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
471 mir_buffer_usage_hardware);
472
473 EXPECT_THAT(bs, NotNull());
474 EXPECT_THROW(
475 { rs.get_presentation_chain(); },
476 std::logic_error);
477}
478
479TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_chain)
480{
481 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
482 auto id = 123;
483
484 mp::BufferStream protobuf_bs;
485 mp::BufferStreamId bs_id;
486
487 bs_id.set_value(id);
488 *protobuf_bs.mutable_id() = bs_id;
489
490 auto native_window = mock_platform->create_egl_native_window(nullptr);
491
492 mcl::RenderSurface rs(connection.get(),
493 native_window,
494 mock_platform,
495 mt::fake_shared(protobuf_bs),
496 {});
497
498 auto pc = rs.get_presentation_chain();
499
500 EXPECT_THAT(pc, NotNull());
501 EXPECT_THROW(
502 { rs.get_buffer_stream(2, 2,
503 mir_pixel_format_abgr_8888,
504 mir_buffer_usage_hardware); },
505 std::logic_error);
506}

Subscribers

People subscribed via source and target branches