Mir

Merge lp:~mir-team/mir/chain-simplification into lp:mir

Proposed by Kevin DuBois
Status: Rejected
Rejected by: Kevin DuBois
Proposed branch: lp:~mir-team/mir/chain-simplification
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/remove-unneeded-chain-functions
Diff against target: 2337 lines (+294/-1023)
45 files modified
playground/egldiamond_render_surface.c (+0/-1)
playground/mir_demo_client_chain_jumping_buffers.c (+19/-35)
playground/mir_demo_client_prerendered_frames.c (+1/-16)
playground/mir_egl_platform_shim.c (+1/-1)
src/client/CMakeLists.txt (+0/-3)
src/client/connection_surface_map.cpp (+0/-11)
src/client/connection_surface_map.h (+0/-3)
src/client/error_chain.cpp (+0/-63)
src/client/error_chain.h (+0/-51)
src/client/error_render_surface.cpp (+15/-5)
src/client/error_render_surface.h (+3/-1)
src/client/mir_buffer_api.cpp (+0/-2)
src/client/mir_connection.cpp (+2/-16)
src/client/mir_connection.h (+0/-4)
src/client/mir_presentation_chain.h (+0/-45)
src/client/mir_presentation_chain_api.cpp (+0/-88)
src/client/mir_render_surface.h (+10/-1)
src/client/mir_render_surface_api.cpp (+42/-15)
src/client/mir_surface_api.cpp (+0/-2)
src/client/presentation_chain.cpp (+0/-96)
src/client/presentation_chain.h (+0/-74)
src/client/render_surface.cpp (+55/-26)
src/client/render_surface.h (+15/-8)
src/client/rpc/mir_protobuf_rpc_channel.cpp (+0/-1)
src/client/symbols.map (+3/-6)
src/include/client/mir_toolkit/client_types_nbs.h (+0/-1)
src/include/client/mir_toolkit/extensions/android_buffer.h (+1/-1)
src/include/client/mir_toolkit/mir_buffer.h (+1/-1)
src/include/client/mir_toolkit/mir_buffer_private.h (+7/-7)
src/include/client/mir_toolkit/mir_presentation_chain.h (+0/-72)
src/include/client/mir_toolkit/mir_render_surface.h (+18/-14)
src/server/graphics/nested/display_buffer.cpp (+3/-3)
src/server/graphics/nested/display_buffer.h (+2/-2)
src/server/graphics/nested/host_chain.h (+0/-1)
src/server/graphics/nested/mir_client_host_connection.cpp (+4/-12)
tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp (+0/-1)
tests/acceptance-tests/staging/test_presentation_chain.cpp (+10/-20)
tests/acceptance-tests/staging/test_render_surface.cpp (+28/-107)
tests/include/mir/test/doubles/stub_host_connection.h (+0/-1)
tests/unit-tests/client/test_connection_resource_map.cpp (+3/-15)
tests/unit-tests/client/test_mir_connection.cpp (+0/-2)
tests/unit-tests/client/test_mir_render_surface.cpp (+35/-156)
tests/unit-tests/client/test_presentation_chain.cpp (+14/-26)
tests/unit-tests/client/test_protobuf_rpc_channel.cpp (+0/-4)
tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp (+2/-3)
To merge this branch: bzr merge lp:~mir-team/mir/chain-simplification
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Disapprove
Chris Halse Rogers Disapprove
Mir CI Bot continuous-integration Needs Fixing
Review via email: mp+313371@code.launchpad.net

Commit message

staged client api:
Eliminate MirPresentationChain, as there isn't enough of a distinction between MirRenderSurface and MirPresentationChain to have a difference.

This comment from Daniel got me thinking that the types are pretty much the same thing:
https://code.launchpad.net/~cemil-azizoglu/mir/create-chain-from-render-surface/+merge/312211/comments/810630
and unifying the types was pretty easy.

This makes use of the objects easier (see playground/ examples).
It has less types to think through
Less code
Reduces the wart of how you mir_render_surface_get_presentation_chain(), as they're the same thing

Description of the change

staged client api:
Eliminate MirPresentationChain, as there isn't enough of a distinction between MirRenderSurface and MirPresentationChain to have a difference.

This comment from Daniel got me thinking that the types are pretty much the same thing:
https://code.launchpad.net/~cemil-azizoglu/mir/create-chain-from-render-surface/+merge/312211/comments/810630
and unifying the types was pretty easy.

This makes use of the objects easier (see playground/ examples).
It has less types to think through
Less code
Reduces the wart of how you mir_render_surface_get_presentation_chain(), as they're the same thing

Reviewers notes:
A lot of the diff is removals of files or #includes of the removed files.

After the prereq branch (which gets rid of surely unneeded functions), there was a mere one-function difference between MirRenderSurface and MirPresentationChain, which was mir_presentation_chain_submit_buffer().

MirRenderSurface header now looks like:
https://bazaar.launchpad.net/~mir-team/mir/chain-simplification/view/head:/src/include/client/mir_toolkit/mir_render_surface.h

The last remaining wart in there (other than the name of course) is mir_render_surface_get_buffer_stream(), as it has 'hidden razorblades' about how to use it, as well as it uses MirBufferUsage (which is being deprecated). I have followup ideas on how to clean that up (including some of the other MP's)

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

FAILED: Continuous integration, rev:3893
https://mir-jenkins.ubuntu.com/job/mir-ci/2405/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3133/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3200
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3192
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3192
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3192
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3162/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3162/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3162/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/3162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3162/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/3162
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3162/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3162/console

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

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

Weak disapprove.

So, I think this is less typing in the uncommon case in return for higher complexity everywhere.

I don't think having more types makes the code more complex. I think having more types, each of which is conceptually atomic, makes the code *less* complex because the type gives you more information.

This makes the MirRenderSurface type more complex - it's no longer a generic handle to some sort of rendered content, it's now *sometimes* a generic handle to some sort of rendered content and *sometimes* a specific thing you can submit buffers to. You can't tell how it's being used without reading the code.

If we really want to rearrange how MirRenderSurface works we could call it MirContentSinkId or something, re-introduce the mir_connection_create_{buffer_stream,presentation_chain,eglstream}, and add mir_{buffer_stream,presentation_chain,eglstream}_bind_id($OBJECT, MirContentSinkId id).

Finally, this is optimising for the uncommon case. The majority of code that interacts with MirRenderSurface will just pass it to an EGL implementation¹ and go to town. The code that *doesn't* just pass it to an EGL implementation is going to associate it with a software-backed MirBufferStream and render to that.

This reduces the length of (unrepresentative) example code and driver code, but does not change expected real-world code.

¹: Or other hardware abstraction layer, like GStreamer.

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

> Weak disapprove.
>
> So, I think this is less typing in the uncommon case in return for higher
> complexity everywhere.
>
> I don't think having more types makes the code more complex. I think having
> more types, each of which is conceptually atomic, makes the code *less*
> complex because the type gives you more information.
>
> This makes the MirRenderSurface type more complex - it's no longer a generic
> handle to some sort of rendered content, it's now *sometimes* a generic handle
> to some sort of rendered content and *sometimes* a specific thing you can
> submit buffers to. You can't tell how it's being used without reading the
> code.

I agree that having more types reduces complexity (in terms of how complicated it is for a user to grasp the concept behind the type). If the types are conceptually different, then they need different types.

I think though that MirPresentationChain and MirRenderSurface are the same thing. They're the generic content. Its the "Surface".

MirBufferStream is pretty useless, if you discount legacy usage. Its built on top of MirBuffer+MirPresentationChain internally, and I see it as a helper class that we provide.

If MirBufferStream is useless/legacy, and everything wants to rally around MirPresentationChain [1], then I don't know if there's any value in segregating the parts the driver wants to use (MirPresentationChain) from the parts that the user uses (MirRenderSurface).

The added benefit for the user is that we don't have to construct a MirPresentationChain from a MirRenderSurface, and we don't have to explain externally why the user has to call a function to switch a MirRenderSurface to a MirPresentationChain.

I can get used to the way it is (so obviously won't be offended if MP is rejected), but still think that reducing the number of types and treating MirBufferStream as legacy makes for cleaner code for the user and driver to use.

[1]
MirPresentationChain needs some functions added to it to support the other 3 Vulkan submission modes, and perhaps multimedia-specific submissions (timestamps), but those can be done post 1.0 without ABI breakage.

>
> If we really want to rearrange how MirRenderSurface works we could call it
> MirContentSinkId or something, re-introduce the
> mir_connection_create_{buffer_stream,presentation_chain,eglstream}, and add
> mir_{buffer_stream,presentation_chain,eglstream}_bind_id($OBJECT,
> MirContentSinkId id).
>
A system of binding would also work, but might be too late to change too much of the naming given release?

> Finally, this is optimising for the uncommon case. The majority of code that
> interacts with MirRenderSurface will just pass it to an EGL implementation¹
> and go to town. The code that *doesn't* just pass it to an EGL implementation
> is going to associate it with a software-backed MirBufferStream and render to
> that.
>
> This reduces the length of (unrepresentative) example code and driver code,
> but does not change expected real-world code.

It does save a type conversion and a concern about how to clean up MirPresentationChain in the driver code.

> ¹: Or other hardware abstraction layer, like GStreamer.

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

> > Weak disapprove.
> >
> > So, I think this is less typing in the uncommon case in return for higher
> > complexity everywhere.
> >
> > I don't think having more types makes the code more complex. I think having
> > more types, each of which is conceptually atomic, makes the code *less*
> > complex because the type gives you more information.
> >
> > This makes the MirRenderSurface type more complex - it's no longer a generic
> > handle to some sort of rendered content, it's now *sometimes* a generic
> handle
> > to some sort of rendered content and *sometimes* a specific thing you can
> > submit buffers to. You can't tell how it's being used without reading the
> > code.
>
> I agree that having more types reduces complexity (in terms of how complicated
> it is for a user to grasp the concept behind the type). If the types are
> conceptually different, then they need different types.
>
> I think though that MirPresentationChain and MirRenderSurface are the same
> thing. They're the generic content. Its the "Surface".
>
> MirBufferStream is pretty useless, if you discount legacy usage. Its built on
> top of MirBuffer+MirPresentationChain internally, and I see it as a helper
> class that we provide.
>
> If MirBufferStream is useless/legacy, and everything wants to rally around
> MirPresentationChain [1], then I don't know if there's any value in
> segregating the parts the driver wants to use (MirPresentationChain) from the
> parts that the user uses (MirRenderSurface).

This might be our disconnect. Everything does not (and *cannot*) rally around MirPresentationChain. Specifically, the nvidia driver cannot support hardware-backed MirPresentationChain, and requires an EGLStream-backed MirRenderSurface.

I think MirBufferStream will be sufficiently useful to (software) clients for it to stick around, but even if we change the API to make its helper-code-on-top-of-MirPresentationChain nature explicit we still need to have PresentationChain-backed RenderSurfaces and EGLStream-backed RenderSurfaces.

Since MirPresentationChain cannot be the generic content abstraction, I think it makes sense to have a distinguished MirRenderSurface as the generic content abstraction.

> A system of binding would also work, but might be too late to change too much of the naming
> given release?

I don't think any of the current API has actually made it into a release yet, and *if* we think the bind-to-sink API is significantly better it'd be sensible to make the change before we do have a release with the API public.

I don't think that a binding API *is* significantly better, but others may have different opinions.

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

Going with the conviction that EGLStreams are the only way that we can support the NVidia driver, I agree with Chris.

Also, I believe there is value in having an external facing type such as MirRenderSurface that decouples clients from the underlying implementation.

I don't see what benefit a binding API would provide.

To move things along, I'll add my own 'Disapprove'.

review: Disapprove

Unmerged revisions

3893. By Kevin DuBois

fix unit tests

3892. By Kevin DuBois

remove more ifdefs

3891. By Kevin DuBois

all unit tests passing

3890. By Kevin DuBois

remove files

3889. By Kevin DuBois

remove get presentation chain

3888. By Kevin DuBois

unify the two types and get the tests to compile

3887. By Kevin DuBois

remove unneeded file

3886. By Kevin DuBois

chase the last pc function away

3885. By Kevin DuBois

whittle down to just one function on pc

3884. By Kevin DuBois

merge in other base

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'playground/egldiamond_render_surface.c'
2--- playground/egldiamond_render_surface.c 2016-12-14 06:27:05 +0000
3+++ playground/egldiamond_render_surface.c 2016-12-15 15:17:18 +0000
4@@ -21,7 +21,6 @@
5 #include "mir_toolkit/mir_client_library.h"
6 #include "mir_toolkit/mir_render_surface.h"
7 #include "mir_toolkit/mir_buffer.h"
8-#include "mir_toolkit/mir_presentation_chain.h"
9 #include "mir_egl_platform_shim.h"
10 #include "diamond.h"
11
12
13=== modified file 'playground/mir_demo_client_chain_jumping_buffers.c'
14--- playground/mir_demo_client_chain_jumping_buffers.c 2016-12-09 02:54:31 +0000
15+++ playground/mir_demo_client_chain_jumping_buffers.c 2016-12-15 15:17:18 +0000
16@@ -20,7 +20,6 @@
17 #include <mir_toolkit/mir_connection.h>
18 #include <mir_toolkit/mir_buffer_stream.h>
19 #include <mir_toolkit/mir_surface.h>
20-#include <mir_toolkit/mir_presentation_chain.h>
21 #include <mir_toolkit/mir_render_surface.h>
22 #include <mir_toolkit/mir_buffer.h>
23 #include <mir_toolkit/version.h>
24@@ -128,8 +127,8 @@
25 }
26
27
28- int const chain_width = width / 2;
29- int const chain_height = height / 2;
30+ int const rs_width = width / 2;
31+ int const rs_height = height / 2;
32
33 sigset_t signal_set;
34 sigemptyset(&signal_set);
35@@ -156,8 +155,8 @@
36 return -1;
37 }
38
39- unsigned int const num_chains = 4;
40- unsigned int const num_buffers = num_chains + 1;
41+ unsigned int const num_render_surfs = 4;
42+ unsigned int const num_buffers = num_render_surfs + 1;
43 unsigned int const fg[PALETTE_SIZE] = {
44 0xFF14BEA0,
45 0xFF000000,
46@@ -174,42 +173,27 @@
47 };
48 unsigned int spare_buffer = 0;
49
50- MirPresentationChain* chain[num_chains];
51- MirRenderSurface* render_surface[num_chains];
52- for(unsigned int i = 0u; i < num_chains; i++)
53+ MirRenderSurface* render_surface[num_render_surfs];
54+ for(unsigned int i = 0u; i < num_render_surfs; i++)
55 {
56- render_surface[i] = mir_connection_create_render_surface_sync(connection, chain_width, chain_height);
57+ render_surface[i] = mir_connection_create_render_surface_sync(connection, rs_width, rs_height);
58 if (!mir_render_surface_is_valid(render_surface[i]))
59 {
60 printf("could not create render surface\n");
61 return -1;
62 }
63-
64- chain[i] = mir_render_surface_get_presentation_chain(render_surface[i]);
65- if (!mir_presentation_chain_is_valid(chain[i]))
66- {
67- printf("could not create MirPresentationChain\n");
68-
69- // TODO this is a frig to pass smoke tests until we support NBS by default
70-#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
71- printf("This is currently an unreleased API - likely server support is switched off\n");
72- return 0;
73-#else
74- return -1;
75-#endif
76- }
77 }
78
79- //Arrange a 2x2 grid of chains within surface
80+ //Arrange a 2x2 grid of render_surfs within surface
81 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
82 mir_surface_spec_add_render_surface(
83- spec, render_surface[0], chain_width, chain_height, displacement_x, displacement_y);
84- mir_surface_spec_add_render_surface(
85- spec, render_surface[1], chain_width, chain_height, chain_width, displacement_y);
86- mir_surface_spec_add_render_surface(
87- spec, render_surface[2], chain_width, chain_height, displacement_x, chain_height);
88- mir_surface_spec_add_render_surface(
89- spec, render_surface[3], chain_width, chain_height, chain_width, chain_height);
90+ spec, render_surface[0], rs_width, rs_height, displacement_x, displacement_y);
91+ mir_surface_spec_add_render_surface(
92+ spec, render_surface[1], rs_width, rs_height, rs_width, displacement_y);
93+ mir_surface_spec_add_render_surface(
94+ spec, render_surface[2], rs_width, rs_height, displacement_x, rs_height);
95+ mir_surface_spec_add_render_surface(
96+ spec, render_surface[3], rs_width, rs_height, rs_width, rs_height);
97 MirSurface* surface = mir_surface_create_sync(spec);
98 mir_surface_spec_release(spec);
99
100@@ -239,7 +223,7 @@
101
102 while (rendering)
103 {
104- for(unsigned int i = 0u; i < num_chains; i++)
105+ for(unsigned int i = 0u; i < num_render_surfs; i++)
106 {
107 MirBuffer* b;
108 pthread_mutex_lock(&buffer_available[spare_buffer].lock);
109@@ -249,7 +233,7 @@
110 b = buffer_available[spare_buffer].buffer;
111 pthread_mutex_unlock(&buffer_available[spare_buffer].lock);
112
113- mir_presentation_chain_submit_buffer(chain[i], b);
114+ mir_render_surface_submit_buffer(render_surface[i], b);
115
116 //just looks like a blur if we don't slow things down
117 ualarm(500000, 0);
118@@ -257,14 +241,14 @@
119 sigwait(&signal_set, &sig);
120 if (!rendering) break;
121
122- if (++spare_buffer > num_chains)
123+ if (++spare_buffer > num_render_surfs)
124 spare_buffer = 0;
125 }
126 }
127
128 for (unsigned int i = 0u; i < num_buffers; i++)
129 mir_buffer_release(buffer_available[i].buffer);
130- for (unsigned int i = 0u; i < num_chains; i++)
131+ for (unsigned int i = 0u; i < num_render_surfs; i++)
132 mir_render_surface_release(render_surface[i]);
133 mir_surface_release_sync(surface);
134 mir_connection_release(connection);
135
136=== modified file 'playground/mir_demo_client_prerendered_frames.c'
137--- playground/mir_demo_client_prerendered_frames.c 2016-12-09 02:54:31 +0000
138+++ playground/mir_demo_client_prerendered_frames.c 2016-12-15 15:17:18 +0000
139@@ -20,7 +20,6 @@
140 #include <mir_toolkit/mir_connection.h>
141 #include <mir_toolkit/mir_buffer_stream.h>
142 #include <mir_toolkit/mir_surface.h>
143-#include <mir_toolkit/mir_presentation_chain.h>
144 #include <mir_toolkit/mir_render_surface.h>
145 #include <mir_toolkit/mir_buffer.h>
146 #include <mir_toolkit/version.h>
147@@ -154,20 +153,6 @@
148 return -1;
149 }
150
151- MirPresentationChain* chain = mir_render_surface_get_presentation_chain(render_surface);
152- if (!mir_presentation_chain_is_valid(chain))
153- {
154- printf("could not create MirPresentationChain\n");
155-
156-// TODO this is a frig to pass smoke tests until we support NBS by default
157-#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
158- printf("This is currently an unreleased API - likely server support is switched off\n");
159- return 0;
160-#else
161- return -1;
162-#endif
163- }
164-
165 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
166 mir_surface_spec_add_render_surface(
167 spec, render_surface, width, height, displacement_x, displacement_y);
168@@ -223,7 +208,7 @@
169 b = buffer_available[i].buffer;
170 pthread_mutex_unlock(&buffer_available[i].lock);
171
172- mir_presentation_chain_submit_buffer(chain, b);
173+ mir_render_surface_submit_buffer(render_surface, b);
174
175 if ((i == num_prerendered_frames - 1) || (i == 0))
176 inc *= -1;
177
178=== modified file 'playground/mir_egl_platform_shim.c'
179--- playground/mir_egl_platform_shim.c 2016-11-23 04:37:50 +0000
180+++ playground/mir_egl_platform_shim.c 2016-12-15 15:17:18 +0000
181@@ -31,7 +31,7 @@
182 MirConnection* connection; //EGLNativeDisplayType
183 MirRenderSurface* surface; //EGLNativeWindowType
184 MirBufferStream* stream; //the internal semantics a driver might want to use...
185- //could be MirPresentationChain as well
186+ //could be MirRenderSurface as well
187 int current_physical_width; //The driver is in charge of the physical width
188 int current_physical_height; //The driver is in charge of the physical height
189
190
191=== modified file 'src/client/CMakeLists.txt'
192--- src/client/CMakeLists.txt 2016-12-13 06:00:32 +0000
193+++ src/client/CMakeLists.txt 2016-12-15 15:17:18 +0000
194@@ -77,13 +77,10 @@
195 mir_buffer_stream_api.cpp
196 error_stream.cpp
197 error_render_surface.cpp
198- error_chain.cpp
199 buffer.cpp
200 error_buffer.cpp
201 mir_render_surface_api.cpp
202 render_surface.cpp
203- presentation_chain.cpp
204- mir_presentation_chain_api.cpp
205 mir_buffer_api.cpp
206 display_configuration_api.cpp
207 protobuf_to_native_buffer.cpp
208
209=== modified file 'src/client/connection_surface_map.cpp'
210--- src/client/connection_surface_map.cpp 2016-12-13 06:00:32 +0000
211+++ src/client/connection_surface_map.cpp 2016-12-15 15:17:18 +0000
212@@ -18,7 +18,6 @@
213
214 #include "connection_surface_map.h"
215 #include "mir_surface.h"
216-#include "presentation_chain.h"
217
218 #include <boost/throw_exception.hpp>
219 #include <sstream>
220@@ -70,22 +69,12 @@
221 streams[stream_id] = stream;
222 }
223
224-void mcl::ConnectionSurfaceMap::insert(
225- mf::BufferStreamId stream_id, std::shared_ptr<MirPresentationChain> const& chain)
226-{
227- std::lock_guard<decltype(stream_guard)> lk(stream_guard);
228- chains[stream_id] = chain;
229-}
230-
231 void mcl::ConnectionSurfaceMap::erase(mf::BufferStreamId stream_id)
232 {
233 std::lock_guard<decltype(stream_guard)> lk(stream_guard);
234 auto stream_it = streams.find(stream_id);
235- auto chain_it = chains.find(stream_id);
236 if (stream_it != streams.end())
237 streams.erase(stream_it);
238- if (chain_it != chains.end())
239- chains.erase(chain_it);
240 }
241
242 void mcl::ConnectionSurfaceMap::insert(int buffer_id, std::shared_ptr<mcl::MirBuffer> const& buffer)
243
244=== modified file 'src/client/connection_surface_map.h'
245--- src/client/connection_surface_map.h 2016-12-13 06:00:32 +0000
246+++ src/client/connection_surface_map.h 2016-12-15 15:17:18 +0000
247@@ -24,7 +24,6 @@
248 #include <shared_mutex>
249 #include <unordered_map>
250
251-class MirPresentationChain;
252 class MirRenderSurface;
253 namespace mir
254 {
255@@ -42,7 +41,6 @@
256 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override;
257
258 void insert(frontend::BufferStreamId stream_id, std::shared_ptr<MirBufferStream> const& chain);
259- void insert(frontend::BufferStreamId stream_id, std::shared_ptr<MirPresentationChain> const& chain);
260 void erase(frontend::BufferStreamId surface_id);
261
262 //TODO: should have a mf::BufferID
263@@ -58,7 +56,6 @@
264 std::unordered_map<frontend::SurfaceId, std::shared_ptr<MirSurface>> surfaces;
265 std::shared_timed_mutex mutable stream_guard;
266 std::unordered_map<frontend::BufferStreamId, std::shared_ptr<MirBufferStream>> streams;
267- std::unordered_map<frontend::BufferStreamId, std::shared_ptr<MirPresentationChain>> chains;
268 std::shared_timed_mutex mutable buffer_guard;
269 std::unordered_map<int, std::shared_ptr<MirBuffer>> buffers;
270 std::unordered_map<void*, std::shared_ptr<MirRenderSurface>> render_surfaces;
271
272=== removed file 'src/client/error_chain.cpp'
273--- src/client/error_chain.cpp 2016-11-09 02:30:14 +0000
274+++ src/client/error_chain.cpp 1970-01-01 00:00:00 +0000
275@@ -1,63 +0,0 @@
276-/*
277- * Copyright © 2016 Canonical Ltd.
278- *
279- * This program is free software: you can redistribute it and/or modify it
280- * under the terms of the GNU Lesser General Public License version 3,
281- * as published by the Free Software Foundation.
282- *
283- * This program is distributed in the hope that it will be useful,
284- * but WITHOUT ANY WARRANTY; without even the implied warranty of
285- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
286- * GNU Lesser General Public License for more details.
287- *
288- * You should have received a copy of the GNU Lesser General Public License
289- * along with this program. If not, see <http://www.gnu.org/licenses/>.
290- *
291- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
292- */
293-
294-#include "error_chain.h"
295-#include <boost/throw_exception.hpp>
296-
297-namespace mcl = mir::client;
298-namespace geom = mir::geometry;
299-
300-mcl::ErrorChain::ErrorChain(
301- MirConnection* connection,
302- int id,
303- std::string const& error_msg) :
304- connection_(connection),
305- stream_id(id),
306- error(error_msg)
307-{
308-}
309-
310-char const* mcl::ErrorChain::error_msg() const
311-{
312- return error.c_str();
313-}
314-
315-MirConnection* mcl::ErrorChain::connection() const
316-{
317- return connection_;
318-}
319-
320-int mcl::ErrorChain::rpc_id() const
321-{
322- return stream_id;
323-}
324-
325-void mcl::ErrorChain::submit_buffer(MirBuffer*)
326-{
327- BOOST_THROW_EXCEPTION(std::logic_error("Cannot submit: invalid MirPresentationChain"));
328-}
329-
330-void mcl::ErrorChain::set_queueing_mode()
331-{
332- BOOST_THROW_EXCEPTION(std::logic_error("Cannot set mode: invalid MirPresentationChain"));
333-}
334-
335-void mcl::ErrorChain::set_dropping_mode()
336-{
337- BOOST_THROW_EXCEPTION(std::logic_error("Cannot set mode: invalid MirPresentationChain"));
338-}
339
340=== removed file 'src/client/error_chain.h'
341--- src/client/error_chain.h 2016-11-09 02:30:14 +0000
342+++ src/client/error_chain.h 1970-01-01 00:00:00 +0000
343@@ -1,51 +0,0 @@
344-/*
345- * Copyright © 2016 Canonical Ltd.
346- *
347- * This program is free software: you can redistribute it and/or modify
348- * it under the terms of the GNU Lesser General Public License version 3 as
349- * published by the Free Software Foundation.
350- *
351- * This program is distributed in the hope that it will be useful,
352- * but WITHOUT ANY WARRANTY; without even the implied warranty of
353- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
354- * GNU Lesser General Public License for more details.
355- *
356- * You should have received a copy of the GNU Lesser General Public License
357- * along with this program. If not, see <http://www.gnu.org/licenses/>.
358- *
359- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
360- */
361-
362-#ifndef MIR_CLIENT_ERROR_CHAIN_H
363-#define MIR_CLIENT_ERROR_CHAIN_H
364-
365-#include "mir_presentation_chain.h"
366-#include <memory>
367-
368-namespace mir
369-{
370-namespace client
371-{
372-
373-class ErrorChain : public MirPresentationChain
374-{
375-public:
376- ErrorChain(
377- MirConnection* connection,
378- int id,
379- std::string const& error_msg);
380- void submit_buffer(MirBuffer* buffer) override;
381- MirConnection* connection() const override;
382- int rpc_id() const override;
383- char const* error_msg() const override;
384- void set_dropping_mode() override;
385- void set_queueing_mode() override;
386-private:
387- MirConnection* const connection_;
388- int const stream_id;
389- std::string const error;
390-};
391-
392-}
393-}
394-#endif /* MIR_CLIENT_ERROR_CHAIN_H */
395
396=== modified file 'src/client/error_render_surface.cpp'
397--- src/client/error_render_surface.cpp 2016-12-09 02:54:31 +0000
398+++ src/client/error_render_surface.cpp 2016-12-15 15:17:18 +0000
399@@ -62,12 +62,22 @@
400 BOOST_THROW_EXCEPTION(std::runtime_error(error));
401 }
402
403-MirPresentationChain* mcl::ErrorRenderSurface::get_presentation_chain()
404-{
405- BOOST_THROW_EXCEPTION(std::runtime_error(error));
406-}
407-
408 char const* mcl::ErrorRenderSurface::get_error_message() const
409 {
410 return error.c_str();
411 }
412+
413+void mcl::ErrorRenderSurface::submit_buffer(MirBuffer*)
414+{
415+ BOOST_THROW_EXCEPTION(std::runtime_error(error));
416+}
417+
418+void mcl::ErrorRenderSurface::set_dropping_mode()
419+{
420+ BOOST_THROW_EXCEPTION(std::runtime_error(error));
421+}
422+
423+void mcl::ErrorRenderSurface::set_queueing_mode()
424+{
425+ BOOST_THROW_EXCEPTION(std::runtime_error(error));
426+}
427
428=== modified file 'src/client/error_render_surface.h'
429--- src/client/error_render_surface.h 2016-12-09 02:54:31 +0000
430+++ src/client/error_render_surface.h 2016-12-15 15:17:18 +0000
431@@ -41,7 +41,9 @@
432 int width, int height,
433 MirPixelFormat format,
434 MirBufferUsage buffer_usage) override;
435- MirPresentationChain* get_presentation_chain() override;
436+ void submit_buffer(mir::client::MirBuffer* buffer) override;
437+ void set_dropping_mode() override;
438+ void set_queueing_mode() override;
439 private:
440 std::string const error;
441 MirConnection* const connection_;
442
443=== modified file 'src/client/mir_buffer_api.cpp'
444--- src/client/mir_buffer_api.cpp 2016-12-14 06:27:05 +0000
445+++ src/client/mir_buffer_api.cpp 2016-12-15 15:17:18 +0000
446@@ -16,10 +16,8 @@
447 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
448 */
449
450-#include "mir_toolkit/mir_presentation_chain.h"
451 #include "mir_toolkit/mir_buffer.h"
452 #include "mir_toolkit/mir_buffer_private.h"
453-#include "presentation_chain.h"
454 #include "mir_connection.h"
455 #include "buffer.h"
456 #include "mir/client_buffer.h"
457
458=== modified file 'src/client/mir_connection.cpp'
459--- src/client/mir_connection.cpp 2016-12-15 15:17:18 +0000
460+++ src/client/mir_connection.cpp 2016-12-15 15:17:18 +0000
461@@ -38,8 +38,6 @@
462 #include "perf_report.h"
463 #include "render_surface.h"
464 #include "error_render_surface.h"
465-#include "presentation_chain.h"
466-#include "error_chain.h"
467 #include "logging/perf_report.h"
468 #include "lttng/perf_report.h"
469 #include "buffer_factory.h"
470@@ -1172,19 +1170,6 @@
471 return display_configuration->take_snapshot();
472 }
473
474-std::shared_ptr<mcl::PresentationChain> MirConnection::create_presentation_chain_with_id(
475- MirRenderSurface* render_surface,
476- mir::protobuf::BufferStream const& a_protobuf_bs)
477-{
478- if (!client_buffer_factory)
479- client_buffer_factory = platform->create_buffer_factory();
480- auto chain = std::make_shared<mcl::PresentationChain>(
481- this, a_protobuf_bs.id().value(), server, client_buffer_factory, buffer_factory);
482-
483- surface_map->insert(render_surface->stream_id(), chain);
484- return chain;
485-}
486-
487 void MirConnection::allocate_buffer(
488 geom::Size size, MirPixelFormat format, MirBufferUsage usage,
489 mir_buffer_callback callback, void* context)
490@@ -1280,9 +1265,10 @@
491 {
492 auto rs = std::make_shared<mcl::RenderSurface>(
493 this,
494+ display_server(),
495 request->native_window,
496 platform,
497- protobuf_bs,
498+ mf::BufferStreamId{protobuf_bs->id().value()},
499 request->logical_size);
500 surface_map->insert(request->native_window.get(), rs);
501
502
503=== modified file 'src/client/mir_connection.h'
504--- src/client/mir_connection.h 2016-12-15 15:17:18 +0000
505+++ src/client/mir_connection.h 2016-12-15 15:17:18 +0000
506@@ -167,10 +167,6 @@
507 mir_buffer_stream_callback callback,
508 void *context);
509
510- std::shared_ptr<mir::client::PresentationChain> create_presentation_chain_with_id(
511- MirRenderSurface* render_surface,
512- mir::protobuf::BufferStream const& a_protobuf_bs);
513-
514 void release_consumer_stream(MirBufferStream*);
515
516 static bool is_valid(MirConnection *connection);
517
518=== removed file 'src/client/mir_presentation_chain.h'
519--- src/client/mir_presentation_chain.h 2016-11-22 03:42:44 +0000
520+++ src/client/mir_presentation_chain.h 1970-01-01 00:00:00 +0000
521@@ -1,45 +0,0 @@
522-/*
523- * Copyright © 2016 Canonical Ltd.
524- *
525- * This program is free software: you can redistribute it and/or modify
526- * it under the terms of the GNU Lesser General Public License version 3 as
527- * published by the Free Software Foundation.
528- *
529- * This program is distributed in the hope that it will be useful,
530- * but WITHOUT ANY WARRANTY; without even the implied warranty of
531- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
532- * GNU Lesser General Public License for more details.
533- *
534- * You should have received a copy of the GNU Lesser General Public License
535- * along with this program. If not, see <http://www.gnu.org/licenses/>.
536- *
537- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
538- */
539-
540-#ifndef MIR_CLIENT_MIR_PRESENTATION_CHAIN_H
541-#define MIR_CLIENT_MIR_PRESENTATION_CHAIN_H
542-
543-#include "mir/geometry/size.h"
544-#include "mir_toolkit/mir_presentation_chain.h"
545-#include "mir/mir_buffer.h"
546-
547-class MirPresentationChain
548-{
549-public:
550- virtual ~MirPresentationChain() = default;
551- virtual void submit_buffer(mir::client::MirBuffer* buffer) = 0;
552- virtual MirConnection* connection() const = 0;
553- virtual int rpc_id() const = 0;
554- virtual char const* error_msg() const = 0;
555-
556- //In the future, the only mode will be dropping
557- virtual void set_dropping_mode() = 0;
558- virtual void set_queueing_mode() = 0;
559-
560-protected:
561- MirPresentationChain(MirPresentationChain const&) = delete;
562- MirPresentationChain& operator=(MirPresentationChain const&) = delete;
563- MirPresentationChain() = default;
564-};
565-
566-#endif /* MIR_CLIENT_MIR_PRESENTATION_CHAIN_H */
567
568=== removed file 'src/client/mir_presentation_chain_api.cpp'
569--- src/client/mir_presentation_chain_api.cpp 2016-12-15 15:17:18 +0000
570+++ src/client/mir_presentation_chain_api.cpp 1970-01-01 00:00:00 +0000
571@@ -1,88 +0,0 @@
572-/*
573- * Copyright © 2016 Canonical Ltd.
574- *
575- * This program is free software: you can redistribute it and/or modify it
576- * under the terms of the GNU Lesser General Public License version 3,
577- * as published by the Free Software Foundation.
578- *
579- * This program is distributed in the hope that it will be useful,
580- * but WITHOUT ANY WARRANTY; without even the implied warranty of
581- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
582- * GNU Lesser General Public License for more details.
583- *
584- * You should have received a copy of the GNU Lesser General Public License
585- * along with this program. If not, see <http://www.gnu.org/licenses/>.
586- *
587- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
588- */
589-
590-#include "mir_toolkit/mir_presentation_chain.h"
591-#include "mir_toolkit/mir_buffer.h"
592-#include "mir_toolkit/mir_buffer_private.h"
593-#include "mir_connection.h"
594-#include "buffer.h"
595-#include "mir_presentation_chain.h"
596-#include "mir/uncaught.h"
597-#include "mir/require.h"
598-#include <stdexcept>
599-#include <boost/throw_exception.hpp>
600-namespace mcl = mir::client;
601-
602-//private NBS api under development
603-void mir_presentation_chain_submit_buffer(MirPresentationChain* chain, MirBuffer* b)
604-try
605-{
606- auto buffer = reinterpret_cast<mcl::MirBuffer*>(b);
607- mir::require(chain && buffer && mir_presentation_chain_is_valid(chain));
608- chain->submit_buffer(buffer);
609-}
610-catch (std::exception const& ex)
611-{
612- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
613-}
614-
615-bool mir_presentation_chain_is_valid(MirPresentationChain* chain)
616-try
617-{
618- mir::require(chain);
619- return mir_presentation_chain_get_error_message(chain) == std::string("");
620-}
621-catch (std::exception const& ex)
622-{
623- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
624- return false;
625-}
626-
627-char const *mir_presentation_chain_get_error_message(MirPresentationChain* chain)
628-try
629-{
630- mir::require(chain);
631- return chain->error_msg();
632-}
633-catch (std::exception const& ex)
634-{
635- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
636- return "error accessing error message";
637-}
638-
639-void mir_presentation_chain_set_queueing_mode(MirPresentationChain* chain)
640-try
641-{
642- mir::require(chain);
643- chain->set_queueing_mode();
644-}
645-catch (std::exception const& ex)
646-{
647- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
648-}
649-
650-void mir_presentation_chain_set_dropping_mode(MirPresentationChain* chain)
651-try
652-{
653- mir::require(chain);
654- chain->set_dropping_mode();
655-}
656-catch (std::exception const& ex)
657-{
658- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
659-}
660
661=== modified file 'src/client/mir_render_surface.h'
662--- src/client/mir_render_surface.h 2016-12-09 02:54:31 +0000
663+++ src/client/mir_render_surface.h 2016-12-15 15:17:18 +0000
664@@ -24,6 +24,13 @@
665 #include "mir/frontend/buffer_stream_id.h"
666 #include "mir/geometry/size.h"
667
668+namespace mir
669+{
670+namespace client
671+{
672+class MirBuffer;
673+}
674+}
675 class MirRenderSurface
676 {
677 public:
678@@ -36,8 +43,10 @@
679 int width, int height,
680 MirPixelFormat format,
681 MirBufferUsage buffer_usage) = 0;
682- virtual MirPresentationChain* get_presentation_chain() = 0;
683 virtual char const* get_error_message() const = 0;
684+ virtual void submit_buffer(mir::client::MirBuffer* buffer) = 0;
685+ virtual void set_dropping_mode() = 0;
686+ virtual void set_queueing_mode() = 0;
687 virtual ~MirRenderSurface() = default;
688 protected:
689 MirRenderSurface(MirRenderSurface const&) = delete;
690
691=== modified file 'src/client/mir_render_surface_api.cpp'
692--- src/client/mir_render_surface_api.cpp 2016-12-15 15:17:18 +0000
693+++ src/client/mir_render_surface_api.cpp 2016-12-15 15:17:18 +0000
694@@ -14,10 +14,12 @@
695 * along with this program. If not, see <http://www.gnu.org/licenses/>.
696 *
697 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>
698+ * Kevin DuBois <kevin.dubois@canonical.com>
699 */
700
701 #include "mir_connection.h"
702 #include "render_surface.h"
703+#include "mir_toolkit/mir_buffer_private.h"
704 #include "mir/uncaught.h"
705 #include "mir/require.h"
706 #include "connection_surface_map.h"
707@@ -191,21 +193,6 @@
708 return nullptr;
709 }
710
711-MirPresentationChain* mir_render_surface_get_presentation_chain(
712- MirRenderSurface* render_surface)
713-try
714-{
715- mir::require(render_surface);
716- auto connection = connection_map.connection(render_surface);
717- auto rs = connection->connection_surface_map()->render_surface(render_surface);
718- return rs->get_presentation_chain();
719-}
720-catch (std::exception const& ex)
721-{
722- MIR_LOG_UNCAUGHT_EXCEPTION(ex);
723- return nullptr;
724-}
725-
726 void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height)
727 {
728 mir::require(render_surface && width && height);
729@@ -233,3 +220,43 @@
730 auto rs = connection->connection_surface_map()->render_surface(surface);
731 spec->rendersurface_cursor = MirSurfaceSpec::RenderSurfaceCursor{rs->stream_id(), {hotspot_x, hotspot_y}};
732 }
733+
734+void mir_render_surface_set_queueing_mode(MirRenderSurface* render_surface)
735+try
736+{
737+ mir::require(render_surface);
738+ auto connection = connection_map.connection(render_surface);
739+ auto rs = connection->connection_surface_map()->render_surface(render_surface);
740+ rs->set_queueing_mode();
741+}
742+catch (std::exception const& ex)
743+{
744+ MIR_LOG_UNCAUGHT_EXCEPTION(ex);
745+}
746+
747+void mir_render_surface_set_dropping_mode(MirRenderSurface* render_surface)
748+try
749+{
750+ mir::require(render_surface);
751+ auto connection = connection_map.connection(render_surface);
752+ auto rs = connection->connection_surface_map()->render_surface(render_surface);
753+ rs->set_dropping_mode();
754+}
755+catch (std::exception const& ex)
756+{
757+ MIR_LOG_UNCAUGHT_EXCEPTION(ex);
758+}
759+
760+void mir_render_surface_submit_buffer(MirRenderSurface* render_surface, MirBuffer* b)
761+try
762+{
763+ mir::require(render_surface && b && mir_render_surface_is_valid(render_surface));
764+ auto connection = connection_map.connection(render_surface);
765+ auto rs = connection->connection_surface_map()->render_surface(render_surface);
766+ auto buffer = reinterpret_cast<mir::client::MirBuffer*>(b);
767+ rs->submit_buffer(buffer);
768+}
769+catch (std::exception const& ex)
770+{
771+ MIR_LOG_UNCAUGHT_EXCEPTION(ex);
772+}
773
774=== modified file 'src/client/mir_surface_api.cpp'
775--- src/client/mir_surface_api.cpp 2016-12-15 15:17:18 +0000
776+++ src/client/mir_surface_api.cpp 2016-12-15 15:17:18 +0000
777@@ -20,12 +20,10 @@
778
779 #include "mir_toolkit/mir_surface.h"
780 #include "mir_toolkit/mir_wait.h"
781-#include "mir_toolkit/mir_presentation_chain.h"
782 #include "mir/require.h"
783
784 #include "mir_connection.h"
785 #include "mir_surface.h"
786-#include "presentation_chain.h"
787 #include "render_surface.h"
788 #include "error_connections.h"
789 #include "connection_surface_map.h"
790
791=== removed file 'src/client/presentation_chain.cpp'
792--- src/client/presentation_chain.cpp 2016-12-09 02:54:31 +0000
793+++ src/client/presentation_chain.cpp 1970-01-01 00:00:00 +0000
794@@ -1,96 +0,0 @@
795-/*
796- * Copyright © 2016 Canonical Ltd.
797- *
798- * This program is free software: you can redistribute it and/or modify it
799- * under the terms of the GNU Lesser General Public License version 3,
800- * as published by the Free Software Foundation.
801- *
802- * This program is distributed in the hope that it will be useful,
803- * but WITHOUT ANY WARRANTY; without even the implied warranty of
804- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
805- * GNU Lesser General Public License for more details.
806- *
807- * You should have received a copy of the GNU Lesser General Public License
808- * along with this program. If not, see <http://www.gnu.org/licenses/>.
809- *
810- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
811- */
812-
813-#include "mir/client_buffer_factory.h"
814-#include "mir/client_buffer.h"
815-#include "rpc/mir_display_server.h"
816-#include "presentation_chain.h"
817-#include "protobuf_to_native_buffer.h"
818-#include "buffer_factory.h"
819-#include <boost/throw_exception.hpp>
820-#include <algorithm>
821-
822-namespace mcl = mir::client;
823-namespace geom = mir::geometry;
824-namespace mp = mir::protobuf;
825-namespace gp = google::protobuf;
826-
827-mcl::PresentationChain::PresentationChain(
828- MirConnection* connection,
829- int stream_id,
830- mir::client::rpc::DisplayServer& server,
831- std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
832- std::shared_ptr<mcl::AsyncBufferFactory> const& mir_buffer_factory) :
833- connection_(connection),
834- stream_id(stream_id),
835- server(server),
836- native_buffer_factory(native_buffer_factory),
837- mir_buffer_factory(mir_buffer_factory),
838- interval_config{server, frontend::BufferStreamId{stream_id}}
839-{
840-}
841-
842-//note: the caller of the mir::client::rpc::DisplayServer interface
843-// has to provide the object for the server to fill when we get a
844-// response, but we can't pass ownership of the response object to
845-// the server given the current interface, nor do we know when the
846-// server has been destroyed, so we have to allow for responses
847-// to complete after the PresentationChain object has been deleted.
848-// (mcl::BufferStream has a similar situation)
849-static void ignore_response(mp::Void* response)
850-{
851- delete response;
852-}
853-
854-void mcl::PresentationChain::submit_buffer(MirBuffer* buffer)
855-{
856- mp::BufferRequest request;
857- {
858- request.mutable_id()->set_value(stream_id);
859- request.mutable_buffer()->set_buffer_id(buffer->rpc_id());
860- buffer->submitted();
861- }
862-
863- auto ignored = new mp::Void;
864- server.submit_buffer(&request, ignored, gp::NewCallback(ignore_response, ignored));
865-}
866-
867-int mcl::PresentationChain::rpc_id() const
868-{
869- return stream_id;
870-}
871-
872-MirConnection* mcl::PresentationChain::connection() const
873-{
874- return connection_;
875-}
876-
877-char const* mcl::PresentationChain::error_msg() const
878-{
879- return "";
880-}
881-
882-void mcl::PresentationChain::set_dropping_mode()
883-{
884- mir_wait_for(interval_config.set_swap_interval(0));
885-}
886-
887-void mcl::PresentationChain::set_queueing_mode()
888-{
889- mir_wait_for(interval_config.set_swap_interval(1));
890-}
891
892=== removed file 'src/client/presentation_chain.h'
893--- src/client/presentation_chain.h 2016-11-09 02:30:14 +0000
894+++ src/client/presentation_chain.h 1970-01-01 00:00:00 +0000
895@@ -1,74 +0,0 @@
896-/*
897- * Copyright © 2016 Canonical Ltd.
898- *
899- * This program is free software: you can redistribute it and/or modify
900- * it under the terms of the GNU Lesser General Public License version 3 as
901- * published by the Free Software Foundation.
902- *
903- * This program is distributed in the hope that it will be useful,
904- * but WITHOUT ANY WARRANTY; without even the implied warranty of
905- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
906- * GNU Lesser General Public License for more details.
907- *
908- * You should have received a copy of the GNU Lesser General Public License
909- * along with this program. If not, see <http://www.gnu.org/licenses/>.
910- *
911- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
912- */
913-
914-#ifndef MIR_CLIENT_PRESENTATION_CHAIN_H
915-#define MIR_CLIENT_PRESENTATION_CHAIN_H
916-
917-#include "mir_presentation_chain.h"
918-#include "buffer_stream.h"
919-#include "mir/geometry/size.h"
920-#include "mir_toolkit/mir_presentation_chain.h"
921-#include "mir_protobuf.pb.h"
922-#include "buffer.h"
923-#include <mutex>
924-#include <memory>
925-
926-namespace mir
927-{
928-namespace client
929-{
930-class ClientBufferFactory;
931-class ClientBuffer;
932-class AsyncBufferFactory;
933-namespace rpc
934-{
935-class DisplayServer;
936-}
937-
938-class PresentationChain : public MirPresentationChain
939-{
940-public:
941- PresentationChain(
942- MirConnection* connection,
943- int rpc_id,
944- rpc::DisplayServer& server,
945- std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
946- std::shared_ptr<AsyncBufferFactory> const& mir_buffer_factory);
947- void submit_buffer(MirBuffer* buffer) override;
948- MirConnection* connection() const override;
949- int rpc_id() const override;
950- char const* error_msg() const override;
951- void set_dropping_mode() override;
952- void set_queueing_mode() override;
953-
954-private:
955-
956- MirConnection* const connection_;
957- int const stream_id;
958- rpc::DisplayServer& server;
959- std::shared_ptr<ClientBufferFactory> const native_buffer_factory;
960- std::shared_ptr<AsyncBufferFactory> const mir_buffer_factory;
961-
962- BufferStreamConfiguration interval_config;
963-
964- std::mutex mutex;
965- std::vector<std::unique_ptr<Buffer>> buffers;
966-};
967-}
968-}
969-#endif /* MIR_CLIENT_PRESENTATION_CHAIN_H */
970
971=== modified file 'src/client/render_surface.cpp'
972--- src/client/render_surface.cpp 2016-12-09 02:54:31 +0000
973+++ src/client/render_surface.cpp 2016-12-15 15:17:18 +0000
974@@ -15,11 +15,13 @@
975 *
976 * Authored by:
977 * Cemil Azizoglu <cemil.azizoglu@canonical.com>
978+ * Kevin DuBois <kevin.dubois@canonical.com>
979 */
980
981 #include "render_surface.h"
982 #include "buffer_stream.h"
983 #include "mir_wait_handle.h"
984+#include "mir/mir_buffer.h"
985 #include "rpc/mir_display_server.h"
986
987 #include "mir/client_platform.h"
988@@ -33,15 +35,18 @@
989
990 mcl::RenderSurface::RenderSurface(
991 MirConnection* const connection,
992+ mcl::rpc::DisplayServer& server,
993 std::shared_ptr<void> native_window,
994 std::shared_ptr<ClientPlatform> client_platform,
995- std::shared_ptr<mp::BufferStream> protobuf_bs,
996+ mf::BufferStreamId id,
997 geom::Size size) :
998 connection_(connection),
999+ server(server),
1000 wrapped_native_window(native_window),
1001 platform(client_platform),
1002- protobuf_bs(protobuf_bs),
1003- desired_size{size}
1004+ id(id),
1005+ desired_size{size},
1006+ interval_config(server, id)
1007 {
1008 }
1009
1010@@ -52,7 +57,7 @@
1011
1012 mf::BufferStreamId mcl::RenderSurface::stream_id() const
1013 {
1014- return mf::BufferStreamId(protobuf_bs->id().value());
1015+ return id;
1016 }
1017
1018 MirBufferStream* mcl::RenderSurface::get_buffer_stream(
1019@@ -60,15 +65,17 @@
1020 MirPixelFormat format,
1021 MirBufferUsage buffer_usage)
1022 {
1023- if (chain_from_id || stream_from_id)
1024+ if (submitting || stream_from_id)
1025 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
1026
1027- protobuf_bs->set_pixel_format(format);
1028- protobuf_bs->set_buffer_usage(buffer_usage);
1029+ mir::protobuf::BufferStream protobuf_bs;
1030+ protobuf_bs.mutable_id()->set_value(id.as_value());
1031+ protobuf_bs.set_pixel_format(format);
1032+ protobuf_bs.set_buffer_usage(buffer_usage);
1033 stream_from_id = connection_->create_client_buffer_stream_with_id(width,
1034 height,
1035 this,
1036- *protobuf_bs);
1037+ protobuf_bs);
1038 if (buffer_usage == mir_buffer_usage_hardware)
1039 {
1040 platform->use_egl_native_window(
1041@@ -78,19 +85,6 @@
1042 return stream_from_id.get();
1043 }
1044
1045-MirPresentationChain* mcl::RenderSurface::get_presentation_chain()
1046-{
1047- if (chain_from_id || stream_from_id)
1048- BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
1049-
1050- chain_from_id = connection_->create_presentation_chain_with_id(this,
1051- *protobuf_bs);
1052- //TODO: Figure out how to handle mir_buffer_usage_hardware once
1053- // EGL is made to support RSs.
1054-
1055- return reinterpret_cast<MirPresentationChain*>(chain_from_id.get());
1056-}
1057-
1058 geom::Size mcl::RenderSurface::size() const
1059 {
1060 std::lock_guard<decltype(size_mutex)> lk(size_mutex);
1061@@ -105,14 +99,49 @@
1062
1063 bool mcl::RenderSurface::valid() const
1064 {
1065- return protobuf_bs->has_id() && !protobuf_bs->has_error();
1066+ return true;
1067 }
1068
1069 char const* mcl::RenderSurface::get_error_message() const
1070 {
1071- if (protobuf_bs->has_error())
1072- {
1073- return protobuf_bs->error().c_str();
1074- }
1075 return "";
1076 }
1077+
1078+//note: the caller of the mir::client::rpc::DisplayServer interface
1079+// has to provide the object for the server to fill when we get a
1080+// response, but we can't pass ownership of the response object to
1081+// the server given the current interface, nor do we know when the
1082+// server has been destroyed, so we have to allow for responses
1083+// to complete after the PresentationChain object has been deleted.
1084+// (mcl::BufferStream has a similar situation)
1085+static void ignore_response(mp::Void* response)
1086+{
1087+ delete response;
1088+}
1089+
1090+void mcl::RenderSurface::submit_buffer(MirBuffer* buffer)
1091+{
1092+ if (stream_from_id)
1093+ BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
1094+
1095+ submitting = true;
1096+ mp::BufferRequest request;
1097+ {
1098+ request.mutable_id()->set_value(stream_id().as_value());
1099+ request.mutable_buffer()->set_buffer_id(buffer->rpc_id());
1100+ buffer->submitted();
1101+ }
1102+
1103+ auto ignored = new mp::Void;
1104+ server.submit_buffer(&request, ignored, google::protobuf::NewCallback(ignore_response, ignored));
1105+}
1106+
1107+void mcl::RenderSurface::set_dropping_mode()
1108+{
1109+ mir_wait_for(interval_config.set_swap_interval(0));
1110+}
1111+
1112+void mcl::RenderSurface::set_queueing_mode()
1113+{
1114+ mir_wait_for(interval_config.set_swap_interval(1));
1115+}
1116
1117=== modified file 'src/client/render_surface.h'
1118--- src/client/render_surface.h 2016-12-13 06:00:32 +0000
1119+++ src/client/render_surface.h 2016-12-15 15:17:18 +0000
1120@@ -22,6 +22,7 @@
1121
1122 #include "mir_connection.h"
1123 #include "mir_render_surface.h"
1124+#include "buffer_stream_configuration.h"
1125 #include "mir_toolkit/mir_render_surface.h"
1126 #include "mir_toolkit/client_types.h"
1127 #include "mir/frontend/surface_id.h"
1128@@ -43,11 +44,13 @@
1129 class RenderSurface : public MirRenderSurface
1130 {
1131 public:
1132- RenderSurface(MirConnection* const connection,
1133- std::shared_ptr<void> native_window,
1134- std::shared_ptr<ClientPlatform> client_platform,
1135- std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs,
1136- geometry::Size size);
1137+ RenderSurface(
1138+ MirConnection* const connection,
1139+ rpc::DisplayServer& server,
1140+ std::shared_ptr<void> native_window,
1141+ std::shared_ptr<ClientPlatform> client_platform,
1142+ frontend::BufferStreamId id,
1143+ geometry::Size size);
1144 MirConnection* connection() const override;
1145 mir::geometry::Size size() const override;
1146 void set_size(mir::geometry::Size) override;
1147@@ -58,18 +61,22 @@
1148 int width, int height,
1149 MirPixelFormat format,
1150 MirBufferUsage buffer_usage) override;
1151- MirPresentationChain* get_presentation_chain() override;
1152+ void submit_buffer(MirBuffer* buffer) override;
1153+ void set_dropping_mode() override;
1154+ void set_queueing_mode() override;
1155
1156 private:
1157 MirConnection* const connection_;
1158+ rpc::DisplayServer& server;
1159 std::shared_ptr<void> wrapped_native_window;
1160 std::shared_ptr<ClientPlatform> platform;
1161- std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs;
1162+ frontend::BufferStreamId id;
1163 std::shared_ptr<mir::client::BufferStream> stream_from_id;
1164- std::shared_ptr<mir::client::PresentationChain> chain_from_id;
1165
1166+ bool submitting = false;
1167 std::mutex mutable size_mutex;
1168 geometry::Size desired_size;
1169+ BufferStreamConfiguration interval_config;
1170 };
1171 }
1172 }
1173
1174=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
1175--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-12-13 06:00:32 +0000
1176+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-12-15 15:17:18 +0000
1177@@ -21,7 +21,6 @@
1178
1179 #include "../surface_map.h"
1180 #include "../buffer.h"
1181-#include "../presentation_chain.h"
1182 #include "../buffer_factory.h"
1183 #include "../mir_surface.h"
1184 #include "../display_configuration.h"
1185
1186=== modified file 'src/client/symbols.map'
1187--- src/client/symbols.map 2016-12-15 15:17:18 +0000
1188+++ src/client/symbols.map 2016-12-15 15:17:18 +0000
1189@@ -368,10 +368,8 @@
1190 mir_buffer_unmap;
1191 mir_buffer_set_callback;
1192 mir_buffer_release;
1193- mir_presentation_chain_is_valid;
1194- mir_presentation_chain_get_error_message;
1195 mir_connection_allocate_buffer;
1196- mir_presentation_chain_submit_buffer;
1197+ mir_render_surface_submit_buffer;
1198 mir_buffer_get_width;
1199 mir_buffer_get_height;
1200 mir_buffer_get_pixel_format;
1201@@ -382,7 +380,6 @@
1202 mir_connection_create_render_surface;
1203 mir_connection_create_render_surface_sync;
1204 mir_render_surface_get_buffer_stream;
1205- mir_render_surface_get_presentation_chain;
1206 mir_render_surface_is_valid;
1207 mir_render_surface_get_error_message;
1208 mir_render_surface_get_size;
1209@@ -393,8 +390,8 @@
1210 #private functions needed temporarily by nested passthrough
1211 #should not be published along with the rest of the NBS symbols
1212 mir_buffer_get_egl_image_parameters;
1213- mir_presentation_chain_set_queueing_mode;
1214- mir_presentation_chain_set_dropping_mode;
1215+ mir_render_surface_set_queueing_mode;
1216+ mir_render_surface_set_dropping_mode;
1217 local:
1218 *;
1219 } MIR_CLIENT_DETAIL_9v19;
1220
1221=== modified file 'src/include/client/mir_toolkit/client_types_nbs.h'
1222--- src/include/client/mir_toolkit/client_types_nbs.h 2016-12-15 15:17:18 +0000
1223+++ src/include/client/mir_toolkit/client_types_nbs.h 2016-12-15 15:17:18 +0000
1224@@ -29,7 +29,6 @@
1225 #endif
1226
1227 /* NOTE: this file will be rolled into mir_toolkit/client_types.h when made public. */
1228-typedef struct MirPresentationChain MirPresentationChain;
1229 typedef struct MirBuffer MirBuffer;
1230 typedef struct MirRenderSurface MirRenderSurface;
1231
1232
1233=== modified file 'src/include/client/mir_toolkit/extensions/android_buffer.h'
1234--- src/include/client/mir_toolkit/extensions/android_buffer.h 2016-11-30 18:00:03 +0000
1235+++ src/include/client/mir_toolkit/extensions/android_buffer.h 2016-12-15 15:17:18 +0000
1236@@ -34,7 +34,7 @@
1237 *
1238 * The callback will be called when the buffer is available for use.
1239 * It will be called once when created, and once per every
1240- * mir_presentation_chain_submit_buffer.
1241+ * mir_render_surface_submit_buffer.
1242 *
1243 * The buffer can be destroyed via mir_buffer_release().
1244 *
1245
1246=== modified file 'src/include/client/mir_toolkit/mir_buffer.h'
1247--- src/include/client/mir_toolkit/mir_buffer.h 2016-12-14 06:27:05 +0000
1248+++ src/include/client/mir_toolkit/mir_buffer.h 2016-12-15 15:17:18 +0000
1249@@ -34,7 +34,7 @@
1250 *
1251 * The callback will be called when the buffer is available for use.
1252 * It will be called once when created, and once per every
1253- * mir_presentation_chain_submit_buffer.
1254+ * mir_render_surface_submit_buffer.
1255 *
1256 * \param [in] connection The connection
1257 * \param [in] width Requested buffer width
1258
1259=== modified file 'src/include/client/mir_toolkit/mir_buffer_private.h'
1260--- src/include/client/mir_toolkit/mir_buffer_private.h 2016-11-11 07:56:09 +0000
1261+++ src/include/client/mir_toolkit/mir_buffer_private.h 2016-12-15 15:17:18 +0000
1262@@ -30,28 +30,28 @@
1263 extern "C" {
1264 #endif
1265
1266-/** Note: mir_presentation_chain{set_queueing,set_dropping}_mode are temporary
1267+/** Note: mir_render_surface{set_queueing,set_dropping}_mode are temporary
1268 * modes needed by the nested server to support swapinterval on passthrough
1269 * clients. Once frame notification signals are given to the client, we can
1270 * just have dropping mode.
1271 **/
1272
1273 /**
1274- * Set the MirPresentationChain to display all buffers for at least 1 frame
1275- * once submitted via mir_presentation_chain_submit_buffer.
1276+ * Set the MirRenderSurface to display all buffers for at least 1 frame
1277+ * once submitted via mir_render_surface_submit_buffer.
1278 *
1279 * \param [in] chain The chain
1280 **/
1281-void mir_presentation_chain_set_queueing_mode(MirPresentationChain* chain);
1282+void mir_render_surface_set_queueing_mode(MirRenderSurface* chain);
1283
1284 /**
1285- * Set the MirPresentationChain to return buffers held by the server
1286+ * Set the MirRenderSurface to return buffers held by the server
1287 * to the client at the earliest possible time when a new buffer is submitted
1288- * to mir_presentation_chain_submit_buffer.
1289+ * to mir_render_surface_submit_buffer.
1290 *
1291 * \param [in] chain The chain
1292 **/
1293-void mir_presentation_chain_set_dropping_mode(MirPresentationChain* chain);
1294+void mir_render_surface_set_dropping_mode(MirRenderSurface* chain);
1295
1296 /** Suggest parameters to use with EGLCreateImage for a given MirBuffer
1297 *
1298
1299=== removed file 'src/include/client/mir_toolkit/mir_presentation_chain.h'
1300--- src/include/client/mir_toolkit/mir_presentation_chain.h 2016-12-15 15:17:18 +0000
1301+++ src/include/client/mir_toolkit/mir_presentation_chain.h 1970-01-01 00:00:00 +0000
1302@@ -1,72 +0,0 @@
1303-/*
1304- * Copyright © 2016 Canonical Ltd.
1305- *
1306- * This program is free software: you can redistribute it and/or modify it
1307- * under the terms of the GNU Lesser General Public License version 3,
1308- * as published by the Free Software Foundation.
1309- *
1310- * This program is distributed in the hope that it will be useful,
1311- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1312- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313- * GNU Lesser General Public License for more details.
1314- *
1315- * You should have received a copy of the GNU Lesser General Public License
1316- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1317- *
1318- */
1319-
1320-#ifndef MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
1321-#define MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
1322-
1323-#include <mir_toolkit/client_types_nbs.h>
1324-
1325-#ifdef __cplusplus
1326-/**
1327- * \addtogroup mir_toolkit
1328- * @{
1329- */
1330-extern "C" {
1331-#endif
1332-
1333-/**
1334- * Test for a valid presentation chain
1335- *
1336- * \param [in] presentation_chain The presentation chain
1337- * \return True if the supplied presentation_chain is valid,
1338- * or false otherwise.
1339- */
1340-bool mir_presentation_chain_is_valid(MirPresentationChain* presentation_chain);
1341-
1342-/**
1343- * Retrieve a text description of the error. The returned string is owned by
1344- * the library and remains valid until the chain or the associated
1345- * connection has been released.
1346- * \param [in] presentation_chain The presentation chain
1347- * \return A text description of any error
1348- * resulting in an invalid chain, or the
1349- * empty string "" if the chain is valid.
1350- */
1351-char const *mir_presentation_chain_get_error_message(
1352- MirPresentationChain* presentation_chain);
1353-
1354-/** Submit a buffer to the server so the server can display it.
1355- *
1356- * The server will notify the client when the buffer is available again via
1357- * the callback registered during buffer creation.
1358- *
1359- * \warning: Once submitted, the buffer cannot be modified until the server
1360- * has returned it. There's no guarantee about how long a server
1361- * may hold the submitted buffer.
1362- *
1363- * \param [in] presentation_chain The presentation chain
1364- * \param [in] buffer The buffer to be submitted
1365- **/
1366-void mir_presentation_chain_submit_buffer(
1367- MirPresentationChain* presentation_chain, MirBuffer* buffer);
1368-
1369-#ifdef __cplusplus
1370-}
1371-/**@}*/
1372-#endif
1373-
1374-#endif // MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
1375
1376=== modified file 'src/include/client/mir_toolkit/mir_render_surface.h'
1377--- src/include/client/mir_toolkit/mir_render_surface.h 2016-12-13 06:00:32 +0000
1378+++ src/include/client/mir_toolkit/mir_render_surface.h 2016-12-15 15:17:18 +0000
1379@@ -125,9 +125,8 @@
1380 * \param [in] usage Requested buffer usage
1381 *
1382 * \return The buffer stream contained in the given render surface
1383- * or 'nullptr' if it, or
1384- * mir_render_surface_get_presentation_chain(), has already
1385- * been called once
1386+ * or 'nullptr' if mir_render_surface_submit_buffer()
1387+ * has already been called once.
1388 */
1389 MirBufferStream* mir_render_surface_get_buffer_stream(
1390 MirRenderSurface* render_surface,
1391@@ -136,17 +135,6 @@
1392 MirBufferUsage usage);
1393
1394 /**
1395- * Obtain the presentation chain backing a given render surface
1396- *
1397- * \return The chain contained in the given render surface
1398- * or 'nullptr' if it, or
1399- * mir_render_surface_get_buffer_stream(), has already
1400- * been called once
1401- */
1402-MirPresentationChain* mir_render_surface_get_presentation_chain(
1403- MirRenderSurface* render_surface);
1404-
1405-/**
1406 * Set the MirSurfaceSpec to display content contained in a render surface
1407 *
1408 * \warning: The initial call to mir_surface_spec_add_render_surface will set
1409@@ -181,6 +169,22 @@
1410 MirRenderSurface* render_surface,
1411 int hotspot_x, int hotspot_y);
1412
1413+/** Submit a buffer to the server so the server can display it.
1414+ *
1415+ * The server will notify the client when the buffer is available again via
1416+ * the callback registered during buffer creation.
1417+ *
1418+ * \note: this queues in the same way as VK_PRESENT_MODE_FIFO_KHR
1419+ * \warning: Once submitted, the buffer cannot be modified until the server
1420+ * has returned it. There's no guarantee about how long a server
1421+ * may hold the submitted buffer.
1422+ *
1423+ * \param [in] render_surface The presentation chain
1424+ * \param [in] buffer The buffer to be submitted
1425+ **/
1426+void mir_render_surface_submit_buffer(
1427+ MirRenderSurface* render_surface, MirBuffer* buffer);
1428+
1429 #ifdef __cplusplus
1430 }
1431 /**@}*/
1432
1433=== modified file 'src/server/graphics/nested/display_buffer.cpp'
1434--- src/server/graphics/nested/display_buffer.cpp 2016-11-16 13:24:41 +0000
1435+++ src/server/graphics/nested/display_buffer.cpp 2016-12-15 15:17:18 +0000
1436@@ -137,7 +137,7 @@
1437
1438 {
1439 std::unique_lock<std::mutex> lk(mutex);
1440- SubmissionInfo submission_info{native->client_handle(), host_chain->handle()};
1441+ SubmissionInfo submission_info{native->client_handle(), host_chain->rs()};
1442 auto submitted = submitted_buffers.find(submission_info);
1443 if ((submission_info != last_submitted) && (submitted != submitted_buffers.end()))
1444 BOOST_THROW_EXCEPTION(std::logic_error("cannot resubmit buffer that has not been returned by host server"));
1445@@ -155,7 +155,7 @@
1446
1447 native->on_ownership_notification(
1448 std::bind(&mgn::detail::DisplayBuffer::release_buffer, this,
1449- native->client_handle(), host_chain->handle()));
1450+ native->client_handle(), host_chain->rs()));
1451 host_chain->submit_buffer(*native);
1452
1453 if (content != BackingContent::chain)
1454@@ -168,7 +168,7 @@
1455 return true;
1456 }
1457
1458-void mgn::detail::DisplayBuffer::release_buffer(MirBuffer* b, MirPresentationChain *c)
1459+void mgn::detail::DisplayBuffer::release_buffer(MirBuffer* b, MirRenderSurface *c)
1460 {
1461 std::unique_lock<std::mutex> lk(mutex);
1462 auto buf = submitted_buffers.find(SubmissionInfo{b, c});
1463
1464=== modified file 'src/server/graphics/nested/display_buffer.h'
1465--- src/server/graphics/nested/display_buffer.h 2016-10-31 02:37:31 +0000
1466+++ src/server/graphics/nested/display_buffer.h 2016-12-15 15:17:18 +0000
1467@@ -93,11 +93,11 @@
1468 glm::mat4 const identity;
1469
1470 std::mutex mutex;
1471- typedef std::tuple<MirBuffer*, MirPresentationChain*> SubmissionInfo;
1472+ typedef std::tuple<MirBuffer*, MirRenderSurface*> SubmissionInfo;
1473 std::map<SubmissionInfo, std::shared_ptr<graphics::Buffer>> submitted_buffers;
1474 SubmissionInfo last_submitted { nullptr, nullptr };
1475
1476- void release_buffer(MirBuffer* b, MirPresentationChain* c);
1477+ void release_buffer(MirBuffer* b, MirRenderSurface* c);
1478 };
1479 }
1480 }
1481
1482=== modified file 'src/server/graphics/nested/host_chain.h'
1483--- src/server/graphics/nested/host_chain.h 2016-12-15 15:17:18 +0000
1484+++ src/server/graphics/nested/host_chain.h 2016-12-15 15:17:18 +0000
1485@@ -40,7 +40,6 @@
1486 virtual ~HostChain() = default;
1487 virtual void submit_buffer(NativeBuffer&) = 0;
1488 virtual void set_submission_mode(SubmissionMode mode) = 0;
1489- virtual MirPresentationChain* handle() = 0;
1490 virtual MirRenderSurface* rs() const = 0;
1491 protected:
1492 HostChain() = default;
1493
1494=== modified file 'src/server/graphics/nested/mir_client_host_connection.cpp'
1495--- src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-15 15:17:18 +0000
1496+++ src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-15 15:17:18 +0000
1497@@ -29,7 +29,6 @@
1498 #include "mir_toolkit/mir_buffer.h"
1499 #include "mir_toolkit/mir_extension_core.h"
1500 #include "mir_toolkit/mir_buffer_private.h"
1501-#include "mir_toolkit/mir_presentation_chain.h"
1502 #include "mir_toolkit/mir_render_surface.h"
1503 #include "mir_toolkit/extensions/fenced_buffers.h"
1504 #include "mir/raii.h"
1505@@ -505,8 +504,7 @@
1506 {
1507
1508 Chain(MirConnection* connection) :
1509- render_surface(mir_connection_create_render_surface_sync(connection, 0, 0)),
1510- chain(mir_render_surface_get_presentation_chain(render_surface))
1511+ render_surface(mir_connection_create_render_surface_sync(connection, 0, 0))
1512 {
1513 }
1514 ~Chain()
1515@@ -516,20 +514,15 @@
1516
1517 void submit_buffer(mgn::NativeBuffer& buffer) override
1518 {
1519- mir_presentation_chain_submit_buffer(chain, buffer.client_handle());
1520+ mir_render_surface_submit_buffer(render_surface, buffer.client_handle());
1521 }
1522
1523 void set_submission_mode(mgn::SubmissionMode mode) override
1524 {
1525 if (mode == mgn::SubmissionMode::queueing)
1526- mir_presentation_chain_set_queueing_mode(chain);
1527+ mir_render_surface_set_queueing_mode(render_surface);
1528 else
1529- mir_presentation_chain_set_dropping_mode(chain);
1530- }
1531-
1532- MirPresentationChain* handle() override
1533- {
1534- return chain;
1535+ mir_render_surface_set_dropping_mode(render_surface);
1536 }
1537
1538 MirRenderSurface* rs() const override
1539@@ -539,7 +532,6 @@
1540
1541 private:
1542 MirRenderSurface* const render_surface;
1543- MirPresentationChain* chain;
1544 };
1545
1546 std::unique_ptr<mgn::HostChain> mgn::MirClientHostConnection::create_chain() const
1547
1548=== modified file 'tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp'
1549--- tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp 2016-12-15 15:17:18 +0000
1550+++ tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp 2016-12-15 15:17:18 +0000
1551@@ -17,7 +17,6 @@
1552 */
1553
1554 #include "../buffer_stream_arrangement.h"
1555-#include "mir_toolkit/mir_presentation_chain.h"
1556 #include "mir_toolkit/mir_render_surface.h"
1557 #include <gmock/gmock.h>
1558
1559
1560=== modified file 'tests/acceptance-tests/staging/test_presentation_chain.cpp'
1561--- tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
1562+++ tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
1563@@ -17,7 +17,6 @@
1564 */
1565
1566 #include "mir_toolkit/mir_render_surface.h"
1567-#include "mir_toolkit/mir_presentation_chain.h"
1568 #include "mir_toolkit/mir_buffer.h"
1569
1570 #include "mir_toolkit/mir_client_library.h"
1571@@ -46,28 +45,21 @@
1572 Chain& operator=(Chain const&) = delete;
1573
1574 Chain(MirConnection* connection) :
1575- rs(mir_connection_create_render_surface_sync(connection, 0, 0)),
1576- chain(mir_render_surface_get_presentation_chain(rs))
1577+ rs(mir_connection_create_render_surface_sync(connection, 0, 0))
1578 {
1579 }
1580
1581- MirRenderSurface* content()
1582+ operator MirRenderSurface*()
1583 {
1584 return rs;
1585 }
1586
1587- operator MirPresentationChain*()
1588- {
1589- return chain;
1590- }
1591-
1592 ~Chain()
1593 {
1594 mir_render_surface_release(rs);
1595 }
1596 private:
1597 MirRenderSurface* rs;
1598- MirPresentationChain* chain;
1599 };
1600
1601 class SurfaceWithChain
1602@@ -118,7 +110,7 @@
1603 auto spec = mir_connection_create_spec_for_normal_surface(
1604 connection, size.width.as_int(), size.height.as_int(), pf);
1605 mir_surface_spec_add_render_surface(
1606- spec, chain.content(), size.width.as_int(), size.height.as_int(), 0, 0);
1607+ spec, chain, size.width.as_int(), size.height.as_int(), 0, 0);
1608 auto surface = mir_surface_create_sync(spec);
1609 mir_surface_spec_release(spec);
1610 return surface;
1611@@ -144,7 +136,7 @@
1612 mir_surface_spec_release(spec);
1613 spec = mir_create_surface_spec(connection);
1614 mir_surface_spec_add_render_surface(
1615- spec, chain.content(), size.width.as_int(), size.height.as_int(), 0, 0);
1616+ spec, chain, size.width.as_int(), size.height.as_int(), 0, 0);
1617 mir_surface_apply_spec(surface, spec);
1618 mir_surface_spec_release(spec);
1619 return surface;
1620@@ -310,7 +302,7 @@
1621
1622 for(auto i = 0u; i < num_iterations; i++)
1623 {
1624- mir_presentation_chain_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
1625+ mir_render_surface_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
1626 contexts[i % num_buffers].unavailable();
1627 if (i != 0)
1628 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;
1629@@ -339,7 +331,7 @@
1630
1631 for(auto i = 0u; i < num_iterations; i++)
1632 {
1633- mir_presentation_chain_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
1634+ mir_render_surface_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
1635 contexts[i % num_buffers].unavailable();
1636 if (i != 0)
1637 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;
1638@@ -360,7 +352,7 @@
1639
1640 ASSERT_TRUE(context.wait_for_buffer(10s));
1641 ASSERT_THAT(context.buffer(), Ne(nullptr));
1642- mir_presentation_chain_submit_buffer(surface.chain(), context.buffer());
1643+ mir_render_surface_submit_buffer(surface.chain(), context.buffer());
1644 mir_buffer_release(context.buffer());
1645 }
1646
1647@@ -383,10 +375,8 @@
1648 TEST_F(PresentationChain, destroying_a_chain_will_return_buffers_associated_with_chain)
1649 {
1650 auto rs_chain = mir_connection_create_render_surface_sync(connection, 1, 1);
1651- auto chain = mir_render_surface_get_presentation_chain(rs_chain);
1652 auto rs_stream = mir_connection_create_render_surface_sync(connection, 1, 1);
1653 auto stream = mir_render_surface_get_buffer_stream(rs_stream, 25, 12, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
1654- ASSERT_TRUE(mir_presentation_chain_is_valid(chain));
1655 ASSERT_TRUE(mir_render_surface_is_valid(rs_chain));
1656 ASSERT_TRUE(mir_render_surface_is_valid(rs_stream));
1657
1658@@ -408,7 +398,7 @@
1659 buffer_callback, &context);
1660 ASSERT_TRUE(context.wait_for_buffer(10s));
1661 context.unavailable();
1662- mir_presentation_chain_submit_buffer(chain, context.buffer());
1663+ mir_render_surface_submit_buffer(rs_chain, context.buffer());
1664
1665 spec = mir_connection_create_spec_for_changes(connection);
1666 mir_surface_spec_add_render_surface(spec, rs_stream, size.width.as_int(), size.height.as_int(), 0, 0);
1667@@ -498,9 +488,9 @@
1668
1669 mir_buffer_set_callback(context.buffer(), another_buffer_callback, &another_context);
1670
1671- mir_presentation_chain_submit_buffer(surface.chain(), context.buffer());
1672+ mir_render_surface_submit_buffer(surface.chain(), context.buffer());
1673 //flush the 1st buffer out
1674- mir_presentation_chain_submit_buffer(surface.chain(), second_buffer_context.buffer());
1675+ mir_render_surface_submit_buffer(surface.chain(), second_buffer_context.buffer());
1676
1677 ASSERT_TRUE(another_context.wait_for_buffer(10s));
1678 ASSERT_THAT(another_context.buffer(), Ne(nullptr));
1679
1680=== modified file 'tests/acceptance-tests/staging/test_render_surface.cpp'
1681--- tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-13 06:00:32 +0000
1682+++ tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-15 15:17:18 +0000
1683@@ -18,7 +18,7 @@
1684
1685 #include "mir_toolkit/mir_client_library.h"
1686 #include "mir_toolkit/mir_render_surface.h"
1687-#include "mir_toolkit/mir_presentation_chain.h"
1688+#include "mir_toolkit/mir_buffer.h"
1689
1690 #include "mir/geometry/size.h"
1691 #include "mir_test_framework/headless_in_process_server.h"
1692@@ -30,6 +30,7 @@
1693
1694 namespace mtf = mir_test_framework;
1695 namespace geom = mir::geometry;
1696+using namespace std::chrono_literals;
1697
1698 namespace
1699 {
1700@@ -192,127 +193,47 @@
1701 mir_connection_release(connection);
1702 }
1703
1704-TEST_F(RenderSurfaceTest, can_hand_out_presentation_chain)
1705-{
1706- auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1707-
1708- auto rs = mir_connection_create_render_surface_sync(
1709- connection, logical_size.width.as_int(), logical_size.height.as_int());
1710-
1711- auto pc = mir_render_surface_get_presentation_chain(rs);
1712-
1713- ASSERT_THAT(pc, NotNull());
1714- EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
1715-
1716- mir_render_surface_release(rs);
1717- mir_connection_release(connection);
1718-}
1719-
1720-TEST_F(RenderSurfaceTest, hands_out_presentation_chain_only_once)
1721-{
1722- auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1723-
1724- auto rs = mir_connection_create_render_surface_sync(
1725- connection, logical_size.width.as_int(), logical_size.height.as_int());
1726-
1727- auto pc = mir_render_surface_get_presentation_chain(rs);
1728-
1729- ASSERT_THAT(pc, NotNull());
1730- EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
1731-
1732- auto pc2 = mir_render_surface_get_presentation_chain(rs);
1733-
1734- EXPECT_THAT(pc2, Eq(nullptr));
1735-
1736- mir_render_surface_release(rs);
1737- mir_connection_release(connection);
1738-}
1739-
1740-TEST_F(RenderSurfaceTest, chain_can_be_constructed_after_surface_creation)
1741-{
1742- int const width{800}, height{600};
1743- MirPixelFormat const format{mir_pixel_format_abgr_8888};
1744-
1745- auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1746-
1747- auto rs = mir_connection_create_render_surface_sync(
1748- connection, logical_size.width.as_int(), logical_size.height.as_int());
1749- auto spec = mir_connection_create_spec_for_normal_surface(connection,
1750- width, height,
1751- format);
1752- mir_surface_spec_add_render_surface(spec, rs, width, height, 0, 0);
1753- auto surface = mir_surface_create_sync(spec);
1754- mir_surface_spec_release(spec);
1755- auto pc = mir_render_surface_get_presentation_chain(rs);
1756-
1757- EXPECT_THAT(surface, IsValid());
1758- EXPECT_THAT(mir_surface_get_buffer_stream(surface), Eq(nullptr));
1759- EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
1760-
1761- mir_render_surface_release(rs);
1762- mir_surface_release_sync(surface);
1763- mir_connection_release(connection);
1764-}
1765-
1766-TEST_F(RenderSurfaceTest, dont_have_to_release_presentation_chain)
1767-{
1768- auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1769-
1770- auto rs = mir_connection_create_render_surface_sync(
1771- connection, logical_size.width.as_int(), logical_size.height.as_int());
1772- auto pc = mir_render_surface_get_presentation_chain(rs);
1773-
1774- ASSERT_THAT(pc, NotNull());
1775- EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
1776-
1777- mir_render_surface_release(rs);
1778- mir_connection_release(connection);
1779-}
1780-
1781-TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_chain_handed_out)
1782+//FIXME?: create/release for MirBufferStream would eliminate any sort of gotchas
1783+// with using that API.
1784+TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_content_is_in_use)
1785 {
1786 auto physical_size = logical_size;
1787 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1788
1789+ struct Buffer
1790+ {
1791+ std::mutex mutex;
1792+ std::condition_variable cv;
1793+ MirBuffer* buffer = nullptr;
1794+ } buffer;
1795+
1796+ mir_connection_allocate_buffer(
1797+ connection,
1798+ 10, 10, mir_pixel_format_abgr_8888, mir_buffer_usage_software,
1799+ [](auto buffer, auto cxt) {
1800+ auto c = reinterpret_cast<Buffer*>(cxt);
1801+ std::unique_lock<decltype(c->mutex)> lk(c->mutex);
1802+ c->buffer = buffer;
1803+ c->cv.notify_all();
1804+ }, &buffer);
1805+
1806+ std::unique_lock<decltype(buffer.mutex)> lk(buffer.mutex);
1807+ EXPECT_TRUE(buffer.cv.wait_for(lk, 10s, [&] { return buffer.buffer; }));
1808+
1809 auto rs = mir_connection_create_render_surface_sync(
1810 connection, logical_size.width.as_int(), logical_size.height.as_int());
1811- auto pc = mir_render_surface_get_presentation_chain(rs);
1812+ EXPECT_TRUE(mir_render_surface_is_valid(rs));
1813
1814- ASSERT_THAT(pc, NotNull());
1815- EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
1816+ mir_render_surface_submit_buffer(rs, buffer.buffer);
1817
1818 auto bs = mir_render_surface_get_buffer_stream(
1819 rs,
1820 physical_size.width.as_int(), physical_size.height.as_int(),
1821 mir_pixel_format_abgr_8888,
1822 mir_buffer_usage_hardware);
1823-
1824 EXPECT_THAT(bs, Eq(nullptr));
1825
1826- mir_render_surface_release(rs);
1827- mir_connection_release(connection);
1828-}
1829-
1830-TEST_F(RenderSurfaceTest, excepts_on_chain_request_if_stream_handed_out)
1831-{
1832- auto physical_size = logical_size;
1833- auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
1834-
1835- auto rs = mir_connection_create_render_surface_sync(
1836- connection, logical_size.width.as_int(), logical_size.height.as_int());
1837- auto bs = mir_render_surface_get_buffer_stream(
1838- rs,
1839- physical_size.width.as_int(), physical_size.height.as_int(),
1840- mir_pixel_format_abgr_8888,
1841- mir_buffer_usage_hardware);
1842-
1843- ASSERT_THAT(bs, NotNull());
1844- EXPECT_TRUE(mir_buffer_stream_is_valid(bs));
1845-
1846- auto pc = mir_render_surface_get_presentation_chain(rs);
1847-
1848- EXPECT_THAT(pc, Eq(nullptr));
1849-
1850+ mir_buffer_release(buffer.buffer);
1851 mir_render_surface_release(rs);
1852 mir_connection_release(connection);
1853 }
1854
1855=== modified file 'tests/include/mir/test/doubles/stub_host_connection.h'
1856--- tests/include/mir/test/doubles/stub_host_connection.h 2016-12-15 15:17:18 +0000
1857+++ tests/include/mir/test/doubles/stub_host_connection.h 2016-12-15 15:17:18 +0000
1858@@ -123,7 +123,6 @@
1859 {
1860 MirRenderSurface* rs() const override { return nullptr; }
1861 void submit_buffer(graphics::nested::NativeBuffer&) override {}
1862- MirPresentationChain* handle() override { return nullptr; }
1863 void set_submission_mode(graphics::nested::SubmissionMode) override {}
1864 };
1865 return std::make_unique<NullHostChain>();
1866
1867=== modified file 'tests/unit-tests/client/test_connection_resource_map.cpp'
1868--- tests/unit-tests/client/test_connection_resource_map.cpp 2016-12-13 06:00:32 +0000
1869+++ tests/unit-tests/client/test_connection_resource_map.cpp 2016-12-15 15:17:18 +0000
1870@@ -18,7 +18,8 @@
1871
1872 #include "src/client/connection_surface_map.h"
1873 #include "src/client/mir_surface.h"
1874-#include "src/client/presentation_chain.h"
1875+#include "src/client/buffer.h"
1876+#include "mir/mir_buffer.h"
1877 #include "src/client/render_surface.h"
1878 #include "mir/test/doubles/mock_mir_buffer_stream.h"
1879 #include "mir/test/doubles/mock_protobuf_server.h"
1880@@ -42,10 +43,8 @@
1881 std::shared_ptr<mcl::Buffer> buffer {
1882 std::make_shared<mcl::Buffer>(buffer_cb, nullptr, 0, nullptr, nullptr, mir_buffer_usage_software) };
1883 mtd::MockProtobufServer mock_server;
1884- std::shared_ptr<mcl::PresentationChain> chain{ std::make_shared<mcl::PresentationChain>(
1885- nullptr, 0, mock_server, nullptr, nullptr) };
1886 std::shared_ptr<MirRenderSurface> render_surface { std::make_shared<mcl::RenderSurface>(
1887- nullptr, nullptr, nullptr, nullptr, mir::geometry::Size{0, 0}) };
1888+ nullptr, mock_server, nullptr, nullptr, mf::BufferStreamId{11}, mir::geometry::Size{0, 0}) };
1889
1890 mf::SurfaceId const surface_id{43};
1891 mf::BufferStreamId const stream_id{43};
1892@@ -79,17 +78,6 @@
1893 map.erase(stream_id);
1894 }
1895
1896-TEST_F(ConnectionResourceMap, holds_chain_reference)
1897-{
1898- using namespace testing;
1899- mcl::ConnectionSurfaceMap map;
1900- auto use_count = chain.use_count();
1901- map.insert(stream_id, chain);
1902- EXPECT_THAT(chain.use_count(), Gt(use_count));
1903- map.erase(stream_id);
1904- EXPECT_THAT(chain.use_count(), Eq(use_count));
1905-}
1906-
1907 TEST_F(ConnectionResourceMap, maps_buffers)
1908 {
1909 using namespace testing;
1910
1911=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
1912--- tests/unit-tests/client/test_mir_connection.cpp 2016-12-15 15:17:18 +0000
1913+++ tests/unit-tests/client/test_mir_connection.cpp 2016-12-15 15:17:18 +0000
1914@@ -24,7 +24,6 @@
1915 #include "src/client/mir_render_surface.h"
1916 #include "src/client/buffer_factory.h"
1917 #include "src/client/connection_surface_map.h"
1918-#include "src/client/presentation_chain.h"
1919
1920 #include "mir/client_platform.h"
1921 #include "mir/client_platform_factory.h"
1922@@ -33,7 +32,6 @@
1923 #include "mir/dispatch/dispatchable.h"
1924 #include "mir/events/event_builders.h"
1925 #include "mir/geometry/rectangle.h"
1926-#include "mir_toolkit/mir_presentation_chain.h"
1927 #include "mir_toolkit/mir_render_surface.h"
1928
1929 #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */
1930
1931=== modified file 'tests/unit-tests/client/test_mir_render_surface.cpp'
1932--- tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-13 06:00:32 +0000
1933+++ tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-15 15:17:18 +0000
1934@@ -28,6 +28,8 @@
1935
1936 #include "mir/test/fake_shared.h"
1937 #include "mir/test/doubles/stub_client_buffer_factory.h"
1938+#include "mir/test/doubles/mock_protobuf_server.h"
1939+#include "mir/test/doubles/mock_mir_buffer.h"
1940 #include "mir_protobuf.pb.h"
1941
1942 #include <sys/eventfd.h>
1943@@ -51,7 +53,6 @@
1944 if (context)
1945 *context = result;
1946 }
1947-
1948 struct RenderSurfaceCallback
1949 {
1950 static void created(MirRenderSurface* render_surface, void *client_context)
1951@@ -193,7 +194,11 @@
1952 std::shared_ptr<testing::NiceMock<MockClientPlatform>> const mock_platform;
1953 std::shared_ptr<testing::NiceMock<MockRpcChannel>> const mock_channel;
1954 TestConnectionConfiguration conf;
1955+ mtd::MockProtobufServer mock_server;
1956 std::shared_ptr<MirConnection> const connection;
1957+ mir::frontend::BufferStreamId rpc_id { 33 };
1958+ int id = 4;
1959+ MirConnection* conn{ reinterpret_cast<MirConnection*>(&id) };
1960 };
1961
1962 TEST_F(MirRenderSurfaceTest, render_surface_can_be_created_and_released)
1963@@ -249,29 +254,15 @@
1964
1965 TEST_F(MirRenderSurfaceTest, render_surface_returns_connection)
1966 {
1967- MirConnection* conn{ reinterpret_cast<MirConnection*>(0x12345678) };
1968-
1969- mcl::RenderSurface rs(
1970- conn, nullptr, nullptr, nullptr, {});
1971+ mcl::RenderSurface rs(conn, mock_server, nullptr, nullptr, rpc_id, {});
1972
1973 EXPECT_THAT(rs.connection(), Eq(conn));
1974 }
1975
1976 TEST_F(MirRenderSurfaceTest, render_surface_has_correct_id_before_content_creation)
1977 {
1978- MirConnection* conn{ reinterpret_cast<MirConnection*>(0x12345678) };
1979- auto id = 123;
1980-
1981- mp::BufferStream protobuf_bs;
1982- mp::BufferStreamId bs_id;
1983-
1984- bs_id.set_value(id);
1985- *protobuf_bs.mutable_id() = bs_id;
1986-
1987- mcl::RenderSurface rs(
1988- conn, nullptr, nullptr, mt::fake_shared(protobuf_bs), {});
1989-
1990- EXPECT_THAT(rs.stream_id().as_value(), Eq(id));
1991+ mcl::RenderSurface rs(conn, mock_server, nullptr, nullptr, rpc_id, {});
1992+ EXPECT_THAT(rs.stream_id(), Eq(rpc_id));
1993 }
1994
1995 TEST_F(MirRenderSurfaceTest, render_surface_can_create_buffer_stream)
1996@@ -287,8 +278,7 @@
1997
1998 auto native_window = mock_platform->create_egl_native_window(nullptr);
1999
2000- mcl::RenderSurface rs(
2001- connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {});
2002+ mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
2003
2004 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
2005 mir_buffer_usage_software);
2006@@ -296,34 +286,6 @@
2007 EXPECT_THAT(bs, NotNull());
2008 }
2009
2010-TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_buffer_stream_more_than_once)
2011-{
2012- connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2013- auto id = 123;
2014-
2015- mp::BufferStream protobuf_bs;
2016- mp::BufferStreamId bs_id;
2017-
2018- bs_id.set_value(id);
2019- *protobuf_bs.mutable_id() = bs_id;
2020-
2021- auto native_window = mock_platform->create_egl_native_window(nullptr);
2022-
2023- mcl::RenderSurface rs(
2024- connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
2025-
2026- EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));
2027-
2028- auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
2029- mir_buffer_usage_hardware);
2030-
2031- EXPECT_THROW(
2032- { rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
2033- mir_buffer_usage_hardware); },
2034- std::logic_error);
2035- EXPECT_THAT(bs, NotNull());
2036-}
2037-
2038 TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window)
2039 {
2040 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2041@@ -337,8 +299,7 @@
2042
2043 auto native_window = mock_platform->create_egl_native_window(nullptr);
2044
2045- mcl::RenderSurface rs(
2046- connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
2047+ mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
2048
2049 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));
2050
2051@@ -361,8 +322,7 @@
2052
2053 auto native_window = mock_platform->create_egl_native_window(nullptr);
2054
2055- mcl::RenderSurface rs(
2056- connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
2057+ mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
2058
2059 EXPECT_CALL(*mock_platform, use_egl_native_window(_,_)).Times(0);
2060
2061@@ -391,111 +351,30 @@
2062 EXPECT_THAT(callback.resulting_render_surface, Eq(render_surface));
2063
2064 auto rs = connection->connection_surface_map()->render_surface(callback.resulting_render_surface);
2065-
2066- EXPECT_THAT(rs->get_error_message(),
2067- StrEq("Error processing buffer stream response during render "
2068- "surface creation: no ID in response (disconnected?)"));
2069+ EXPECT_THAT(rs->get_error_message(), StrEq("Error creating MirRenderSurface: no ID in response"));
2070 EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid()));
2071 }
2072
2073-TEST_F(MirRenderSurfaceTest, render_surface_can_create_presentation_chain)
2074-{
2075- connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2076- auto id = 123;
2077-
2078- mp::BufferStream protobuf_bs;
2079- mp::BufferStreamId bs_id;
2080-
2081- bs_id.set_value(id);
2082- *protobuf_bs.mutable_id() = bs_id;
2083-
2084- auto native_window = mock_platform->create_egl_native_window(nullptr);
2085-
2086- mcl::RenderSurface rs(
2087- connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {});
2088-
2089- auto pc = rs.get_presentation_chain();
2090-
2091- EXPECT_THAT(pc, NotNull());
2092-}
2093-
2094-TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_presentation_chain_more_than_once)
2095-{
2096- connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2097- auto id = 123;
2098-
2099- mp::BufferStream protobuf_bs;
2100- mp::BufferStreamId bs_id;
2101-
2102- bs_id.set_value(id);
2103- *protobuf_bs.mutable_id() = bs_id;
2104-
2105- auto native_window = mock_platform->create_egl_native_window(nullptr);
2106-
2107- mcl::RenderSurface rs(
2108- connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
2109-
2110- auto pc = rs.get_presentation_chain();
2111- EXPECT_THAT(pc, NotNull());
2112-
2113- EXPECT_THROW(
2114- { rs.get_presentation_chain(); },
2115- std::logic_error);
2116-}
2117-
2118-TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_chain_after_stream)
2119-{
2120- connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2121- auto id = 123;
2122-
2123- mp::BufferStream protobuf_bs;
2124- mp::BufferStreamId bs_id;
2125-
2126- bs_id.set_value(id);
2127- *protobuf_bs.mutable_id() = bs_id;
2128-
2129- auto native_window = mock_platform->create_egl_native_window(nullptr);
2130-
2131- mcl::RenderSurface rs(connection.get(),
2132- native_window,
2133- mock_platform,
2134- mt::fake_shared(protobuf_bs),
2135- {});
2136-
2137- auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
2138- mir_buffer_usage_hardware);
2139-
2140- EXPECT_THAT(bs, NotNull());
2141- EXPECT_THROW(
2142- { rs.get_presentation_chain(); },
2143- std::logic_error);
2144-}
2145-
2146-TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_chain)
2147-{
2148- connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2149- auto id = 123;
2150-
2151- mp::BufferStream protobuf_bs;
2152- mp::BufferStreamId bs_id;
2153-
2154- bs_id.set_value(id);
2155- *protobuf_bs.mutable_id() = bs_id;
2156-
2157- auto native_window = mock_platform->create_egl_native_window(nullptr);
2158-
2159- mcl::RenderSurface rs(connection.get(),
2160- native_window,
2161- mock_platform,
2162- mt::fake_shared(protobuf_bs),
2163- {});
2164-
2165- auto pc = rs.get_presentation_chain();
2166-
2167- EXPECT_THAT(pc, NotNull());
2168- EXPECT_THROW(
2169- { rs.get_buffer_stream(2, 2,
2170- mir_pixel_format_abgr_8888,
2171- mir_buffer_usage_hardware); },
2172- std::logic_error);
2173+TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_submission)
2174+{
2175+ mtd::MockMirBuffer buffer;
2176+ connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2177+ auto native_window = mock_platform->create_egl_native_window(nullptr);
2178+ mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
2179+ rs.submit_buffer(&buffer);
2180+ EXPECT_THROW({
2181+ rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
2182+ }, std::logic_error);
2183+}
2184+
2185+TEST_F(MirRenderSurfaceTest, excepts_on_submission_after_creation_of_stream)
2186+{
2187+ mtd::MockMirBuffer buffer;
2188+ connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
2189+ auto native_window = mock_platform->create_egl_native_window(nullptr);
2190+ mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
2191+ rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
2192+ EXPECT_THROW({
2193+ rs.submit_buffer(&buffer);
2194+ }, std::logic_error);
2195 }
2196
2197=== modified file 'tests/unit-tests/client/test_presentation_chain.cpp'
2198--- tests/unit-tests/client/test_presentation_chain.cpp 2016-07-18 07:38:38 +0000
2199+++ tests/unit-tests/client/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
2200@@ -20,7 +20,7 @@
2201 #include "mir/test/doubles/stub_client_buffer_factory.h"
2202 #include "mir/test/doubles/mock_client_buffer.h"
2203 #include "mir/test/fake_shared.h"
2204-#include "src/client/presentation_chain.h"
2205+#include "src/client/render_surface.h"
2206 #include "src/client/buffer_factory.h"
2207 #include "mir/client_buffer_factory.h"
2208
2209@@ -36,16 +36,16 @@
2210
2211 namespace
2212 {
2213-struct PresentationChain : Test
2214+struct RenderSurface : Test
2215 {
2216- PresentationChain()
2217+ RenderSurface()
2218 {
2219 ipc_buf.set_width(size.width.as_int());
2220 ipc_buf.set_height(size.height.as_int());
2221 ipc_buf.set_buffer_id(buffer_id);
2222 }
2223
2224- int rpc_id { 33 };
2225+ mir::frontend::BufferStreamId rpc_id { 33 };
2226 MirConnection* connection {reinterpret_cast<MirConnection*>(this)};
2227 geom::Size size {100, 200};
2228 MirPixelFormat format = mir_pixel_format_abgr_8888;
2229@@ -71,53 +71,41 @@
2230
2231 }
2232
2233-TEST_F(PresentationChain, returns_associated_connection)
2234+TEST_F(RenderSurface, returns_associated_connection)
2235 {
2236- mcl::PresentationChain chain(
2237- connection, rpc_id, mock_server,
2238- std::make_shared<mtd::StubClientBufferFactory>(),
2239- std::make_shared<mcl::BufferFactory>());
2240+ mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
2241 EXPECT_THAT(chain.connection(), Eq(connection));
2242 }
2243
2244-TEST_F(PresentationChain, returns_associated_rpc_id)
2245+TEST_F(RenderSurface, returns_associated_stream_id)
2246 {
2247- mcl::PresentationChain chain(
2248- connection, rpc_id, mock_server,
2249- std::make_shared<mtd::StubClientBufferFactory>(),
2250- std::make_shared<mcl::BufferFactory>());
2251- EXPECT_THAT(chain.rpc_id(), Eq(rpc_id));
2252+ mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
2253+ EXPECT_THAT(chain.stream_id(), Eq(rpc_id));
2254 }
2255
2256-TEST_F(PresentationChain, submits_buffer_when_asked)
2257+TEST_F(RenderSurface, submits_buffer_when_asked)
2258 {
2259 mp::BufferRequest request;
2260- request.mutable_id()->set_value(rpc_id);
2261+ request.mutable_id()->set_value(rpc_id.as_value());
2262 request.mutable_buffer()->set_buffer_id(buffer_id);
2263
2264 EXPECT_CALL(mock_server, submit_buffer(BufferRequestMatches(request),_,_))
2265 .WillOnce(mtd::RunProtobufClosure());
2266
2267 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);
2268- mcl::PresentationChain chain(
2269- connection, rpc_id, mock_server,
2270- std::make_shared<mtd::StubClientBufferFactory>(),
2271- std::make_shared<mcl::BufferFactory>());
2272+ mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
2273
2274 buffer.received();
2275 chain.submit_buffer(&buffer);
2276 }
2277
2278-TEST_F(PresentationChain, double_submission_throws)
2279+TEST_F(RenderSurface, double_submission_throws)
2280 {
2281 EXPECT_CALL(mock_server, submit_buffer(_,_,_))
2282 .WillOnce(mtd::RunProtobufClosure());
2283
2284 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);
2285- mcl::PresentationChain chain(
2286- connection, rpc_id, mock_server,
2287- std::make_shared<mtd::StubClientBufferFactory>(),
2288- std::make_shared<mcl::BufferFactory>());
2289+ mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
2290
2291 buffer.received();
2292 chain.submit_buffer(&buffer);
2293
2294=== modified file 'tests/unit-tests/client/test_protobuf_rpc_channel.cpp'
2295--- tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2016-12-13 06:00:32 +0000
2296+++ tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2016-12-15 15:17:18 +0000
2297@@ -65,7 +65,6 @@
2298 void(std::function<void(MirBufferStream*)> const&));
2299 MOCK_CONST_METHOD1(buffer, std::shared_ptr<mcl::MirBuffer>(int));
2300 MOCK_METHOD2(insert, void(int, std::shared_ptr<mcl::MirBuffer> const&));
2301- MOCK_METHOD2(insert, void(mir::frontend::BufferStreamId, std::shared_ptr<MirPresentationChain> const&));
2302 MOCK_METHOD1(erase, void(int));
2303 };
2304
2305@@ -83,9 +82,6 @@
2306 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override
2307 {
2308 }
2309- void insert(mir::frontend::BufferStreamId, std::shared_ptr<MirPresentationChain> const&)
2310- {
2311- }
2312 std::shared_ptr<mcl::MirBuffer> buffer(int) const override
2313 {
2314 return nullptr;
2315
2316=== modified file 'tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp'
2317--- tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp 2016-12-15 15:17:18 +0000
2318+++ tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp 2016-12-15 15:17:18 +0000
2319@@ -93,7 +93,6 @@
2320 struct MockNestedChain : mgn::HostChain
2321 {
2322 MOCK_METHOD1(submit_buffer, void(mgn::NativeBuffer&));
2323- MOCK_METHOD0(handle, MirPresentationChain*());
2324 MOCK_METHOD1(set_submission_mode, void(mgn::SubmissionMode));
2325 MOCK_CONST_METHOD0(rs, MirRenderSurface*());
2326 };
2327@@ -317,8 +316,8 @@
2328 EXPECT_CALL(nested_buffer, on_ownership_notification(_))
2329 .Times(2);
2330 EXPECT_CALL(*mock_chain, submit_buffer(Ref(nested_buffer)));
2331- ON_CALL(*mock_chain, handle())
2332- .WillByDefault(Return(reinterpret_cast<MirPresentationChain*>(&fake_chain_handle)));
2333+ ON_CALL(*mock_chain, rs())
2334+ .WillByDefault(Return(reinterpret_cast<MirRenderSurface*>(&fake_chain_handle)));
2335 EXPECT_CALL(*mock_chain2, submit_buffer(Ref(nested_buffer)));
2336
2337 EXPECT_CALL(mock_host_connection, create_surface(_,_,_,_,_))

Subscribers

People subscribed via source and target branches