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
=== modified file 'playground/egldiamond_render_surface.c'
--- playground/egldiamond_render_surface.c 2016-12-14 06:27:05 +0000
+++ playground/egldiamond_render_surface.c 2016-12-15 15:17:18 +0000
@@ -21,7 +21,6 @@
21#include "mir_toolkit/mir_client_library.h"21#include "mir_toolkit/mir_client_library.h"
22#include "mir_toolkit/mir_render_surface.h"22#include "mir_toolkit/mir_render_surface.h"
23#include "mir_toolkit/mir_buffer.h"23#include "mir_toolkit/mir_buffer.h"
24#include "mir_toolkit/mir_presentation_chain.h"
25#include "mir_egl_platform_shim.h"24#include "mir_egl_platform_shim.h"
26#include "diamond.h"25#include "diamond.h"
2726
2827
=== modified file 'playground/mir_demo_client_chain_jumping_buffers.c'
--- playground/mir_demo_client_chain_jumping_buffers.c 2016-12-09 02:54:31 +0000
+++ playground/mir_demo_client_chain_jumping_buffers.c 2016-12-15 15:17:18 +0000
@@ -20,7 +20,6 @@
20#include <mir_toolkit/mir_connection.h>20#include <mir_toolkit/mir_connection.h>
21#include <mir_toolkit/mir_buffer_stream.h>21#include <mir_toolkit/mir_buffer_stream.h>
22#include <mir_toolkit/mir_surface.h>22#include <mir_toolkit/mir_surface.h>
23#include <mir_toolkit/mir_presentation_chain.h>
24#include <mir_toolkit/mir_render_surface.h>23#include <mir_toolkit/mir_render_surface.h>
25#include <mir_toolkit/mir_buffer.h>24#include <mir_toolkit/mir_buffer.h>
26#include <mir_toolkit/version.h>25#include <mir_toolkit/version.h>
@@ -128,8 +127,8 @@
128 }127 }
129128
130129
131 int const chain_width = width / 2;130 int const rs_width = width / 2;
132 int const chain_height = height / 2;131 int const rs_height = height / 2;
133132
134 sigset_t signal_set;133 sigset_t signal_set;
135 sigemptyset(&signal_set);134 sigemptyset(&signal_set);
@@ -156,8 +155,8 @@
156 return -1;155 return -1;
157 }156 }
158157
159 unsigned int const num_chains = 4;158 unsigned int const num_render_surfs = 4;
160 unsigned int const num_buffers = num_chains + 1;159 unsigned int const num_buffers = num_render_surfs + 1;
161 unsigned int const fg[PALETTE_SIZE] = {160 unsigned int const fg[PALETTE_SIZE] = {
162 0xFF14BEA0,161 0xFF14BEA0,
163 0xFF000000,162 0xFF000000,
@@ -174,42 +173,27 @@
174 };173 };
175 unsigned int spare_buffer = 0;174 unsigned int spare_buffer = 0;
176175
177 MirPresentationChain* chain[num_chains];176 MirRenderSurface* render_surface[num_render_surfs];
178 MirRenderSurface* render_surface[num_chains];177 for(unsigned int i = 0u; i < num_render_surfs; i++)
179 for(unsigned int i = 0u; i < num_chains; i++)
180 {178 {
181 render_surface[i] = mir_connection_create_render_surface_sync(connection, chain_width, chain_height);179 render_surface[i] = mir_connection_create_render_surface_sync(connection, rs_width, rs_height);
182 if (!mir_render_surface_is_valid(render_surface[i]))180 if (!mir_render_surface_is_valid(render_surface[i]))
183 {181 {
184 printf("could not create render surface\n");182 printf("could not create render surface\n");
185 return -1;183 return -1;
186 }184 }
187
188 chain[i] = mir_render_surface_get_presentation_chain(render_surface[i]);
189 if (!mir_presentation_chain_is_valid(chain[i]))
190 {
191 printf("could not create MirPresentationChain\n");
192
193 // TODO this is a frig to pass smoke tests until we support NBS by default
194#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
195 printf("This is currently an unreleased API - likely server support is switched off\n");
196 return 0;
197#else
198 return -1;
199#endif
200 }
201 }185 }
202186
203 //Arrange a 2x2 grid of chains within surface187 //Arrange a 2x2 grid of render_surfs within surface
204 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);188 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
205 mir_surface_spec_add_render_surface(189 mir_surface_spec_add_render_surface(
206 spec, render_surface[0], chain_width, chain_height, displacement_x, displacement_y);190 spec, render_surface[0], rs_width, rs_height, displacement_x, displacement_y);
207 mir_surface_spec_add_render_surface(191 mir_surface_spec_add_render_surface(
208 spec, render_surface[1], chain_width, chain_height, chain_width, displacement_y);192 spec, render_surface[1], rs_width, rs_height, rs_width, displacement_y);
209 mir_surface_spec_add_render_surface(193 mir_surface_spec_add_render_surface(
210 spec, render_surface[2], chain_width, chain_height, displacement_x, chain_height);194 spec, render_surface[2], rs_width, rs_height, displacement_x, rs_height);
211 mir_surface_spec_add_render_surface(195 mir_surface_spec_add_render_surface(
212 spec, render_surface[3], chain_width, chain_height, chain_width, chain_height);196 spec, render_surface[3], rs_width, rs_height, rs_width, rs_height);
213 MirSurface* surface = mir_surface_create_sync(spec);197 MirSurface* surface = mir_surface_create_sync(spec);
214 mir_surface_spec_release(spec);198 mir_surface_spec_release(spec);
215199
@@ -239,7 +223,7 @@
239223
240 while (rendering)224 while (rendering)
241 {225 {
242 for(unsigned int i = 0u; i < num_chains; i++)226 for(unsigned int i = 0u; i < num_render_surfs; i++)
243 {227 {
244 MirBuffer* b;228 MirBuffer* b;
245 pthread_mutex_lock(&buffer_available[spare_buffer].lock);229 pthread_mutex_lock(&buffer_available[spare_buffer].lock);
@@ -249,7 +233,7 @@
249 b = buffer_available[spare_buffer].buffer;233 b = buffer_available[spare_buffer].buffer;
250 pthread_mutex_unlock(&buffer_available[spare_buffer].lock);234 pthread_mutex_unlock(&buffer_available[spare_buffer].lock);
251235
252 mir_presentation_chain_submit_buffer(chain[i], b);236 mir_render_surface_submit_buffer(render_surface[i], b);
253237
254 //just looks like a blur if we don't slow things down238 //just looks like a blur if we don't slow things down
255 ualarm(500000, 0);239 ualarm(500000, 0);
@@ -257,14 +241,14 @@
257 sigwait(&signal_set, &sig);241 sigwait(&signal_set, &sig);
258 if (!rendering) break;242 if (!rendering) break;
259243
260 if (++spare_buffer > num_chains)244 if (++spare_buffer > num_render_surfs)
261 spare_buffer = 0;245 spare_buffer = 0;
262 }246 }
263 }247 }
264248
265 for (unsigned int i = 0u; i < num_buffers; i++)249 for (unsigned int i = 0u; i < num_buffers; i++)
266 mir_buffer_release(buffer_available[i].buffer);250 mir_buffer_release(buffer_available[i].buffer);
267 for (unsigned int i = 0u; i < num_chains; i++)251 for (unsigned int i = 0u; i < num_render_surfs; i++)
268 mir_render_surface_release(render_surface[i]);252 mir_render_surface_release(render_surface[i]);
269 mir_surface_release_sync(surface);253 mir_surface_release_sync(surface);
270 mir_connection_release(connection);254 mir_connection_release(connection);
271255
=== modified file 'playground/mir_demo_client_prerendered_frames.c'
--- playground/mir_demo_client_prerendered_frames.c 2016-12-09 02:54:31 +0000
+++ playground/mir_demo_client_prerendered_frames.c 2016-12-15 15:17:18 +0000
@@ -20,7 +20,6 @@
20#include <mir_toolkit/mir_connection.h>20#include <mir_toolkit/mir_connection.h>
21#include <mir_toolkit/mir_buffer_stream.h>21#include <mir_toolkit/mir_buffer_stream.h>
22#include <mir_toolkit/mir_surface.h>22#include <mir_toolkit/mir_surface.h>
23#include <mir_toolkit/mir_presentation_chain.h>
24#include <mir_toolkit/mir_render_surface.h>23#include <mir_toolkit/mir_render_surface.h>
25#include <mir_toolkit/mir_buffer.h>24#include <mir_toolkit/mir_buffer.h>
26#include <mir_toolkit/version.h>25#include <mir_toolkit/version.h>
@@ -154,20 +153,6 @@
154 return -1;153 return -1;
155 }154 }
156155
157 MirPresentationChain* chain = mir_render_surface_get_presentation_chain(render_surface);
158 if (!mir_presentation_chain_is_valid(chain))
159 {
160 printf("could not create MirPresentationChain\n");
161
162// TODO this is a frig to pass smoke tests until we support NBS by default
163#if (MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 3, 0))
164 printf("This is currently an unreleased API - likely server support is switched off\n");
165 return 0;
166#else
167 return -1;
168#endif
169 }
170
171 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);156 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
172 mir_surface_spec_add_render_surface(157 mir_surface_spec_add_render_surface(
173 spec, render_surface, width, height, displacement_x, displacement_y);158 spec, render_surface, width, height, displacement_x, displacement_y);
@@ -223,7 +208,7 @@
223 b = buffer_available[i].buffer;208 b = buffer_available[i].buffer;
224 pthread_mutex_unlock(&buffer_available[i].lock);209 pthread_mutex_unlock(&buffer_available[i].lock);
225210
226 mir_presentation_chain_submit_buffer(chain, b);211 mir_render_surface_submit_buffer(render_surface, b);
227212
228 if ((i == num_prerendered_frames - 1) || (i == 0))213 if ((i == num_prerendered_frames - 1) || (i == 0))
229 inc *= -1; 214 inc *= -1;
230215
=== modified file 'playground/mir_egl_platform_shim.c'
--- playground/mir_egl_platform_shim.c 2016-11-23 04:37:50 +0000
+++ playground/mir_egl_platform_shim.c 2016-12-15 15:17:18 +0000
@@ -31,7 +31,7 @@
31 MirConnection* connection; //EGLNativeDisplayType31 MirConnection* connection; //EGLNativeDisplayType
32 MirRenderSurface* surface; //EGLNativeWindowType32 MirRenderSurface* surface; //EGLNativeWindowType
33 MirBufferStream* stream; //the internal semantics a driver might want to use...33 MirBufferStream* stream; //the internal semantics a driver might want to use...
34 //could be MirPresentationChain as well34 //could be MirRenderSurface as well
35 int current_physical_width; //The driver is in charge of the physical width35 int current_physical_width; //The driver is in charge of the physical width
36 int current_physical_height; //The driver is in charge of the physical height36 int current_physical_height; //The driver is in charge of the physical height
3737
3838
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2016-12-13 06:00:32 +0000
+++ src/client/CMakeLists.txt 2016-12-15 15:17:18 +0000
@@ -77,13 +77,10 @@
77 mir_buffer_stream_api.cpp77 mir_buffer_stream_api.cpp
78 error_stream.cpp78 error_stream.cpp
79 error_render_surface.cpp79 error_render_surface.cpp
80 error_chain.cpp
81 buffer.cpp80 buffer.cpp
82 error_buffer.cpp81 error_buffer.cpp
83 mir_render_surface_api.cpp82 mir_render_surface_api.cpp
84 render_surface.cpp83 render_surface.cpp
85 presentation_chain.cpp
86 mir_presentation_chain_api.cpp
87 mir_buffer_api.cpp84 mir_buffer_api.cpp
88 display_configuration_api.cpp85 display_configuration_api.cpp
89 protobuf_to_native_buffer.cpp86 protobuf_to_native_buffer.cpp
9087
=== modified file 'src/client/connection_surface_map.cpp'
--- src/client/connection_surface_map.cpp 2016-12-13 06:00:32 +0000
+++ src/client/connection_surface_map.cpp 2016-12-15 15:17:18 +0000
@@ -18,7 +18,6 @@
1818
19#include "connection_surface_map.h"19#include "connection_surface_map.h"
20#include "mir_surface.h"20#include "mir_surface.h"
21#include "presentation_chain.h"
2221
23#include <boost/throw_exception.hpp>22#include <boost/throw_exception.hpp>
24#include <sstream>23#include <sstream>
@@ -70,22 +69,12 @@
70 streams[stream_id] = stream;69 streams[stream_id] = stream;
71}70}
7271
73void mcl::ConnectionSurfaceMap::insert(
74 mf::BufferStreamId stream_id, std::shared_ptr<MirPresentationChain> const& chain)
75{
76 std::lock_guard<decltype(stream_guard)> lk(stream_guard);
77 chains[stream_id] = chain;
78}
79
80void mcl::ConnectionSurfaceMap::erase(mf::BufferStreamId stream_id)72void mcl::ConnectionSurfaceMap::erase(mf::BufferStreamId stream_id)
81{73{
82 std::lock_guard<decltype(stream_guard)> lk(stream_guard);74 std::lock_guard<decltype(stream_guard)> lk(stream_guard);
83 auto stream_it = streams.find(stream_id);75 auto stream_it = streams.find(stream_id);
84 auto chain_it = chains.find(stream_id);
85 if (stream_it != streams.end())76 if (stream_it != streams.end())
86 streams.erase(stream_it);77 streams.erase(stream_it);
87 if (chain_it != chains.end())
88 chains.erase(chain_it);
89}78}
9079
91void mcl::ConnectionSurfaceMap::insert(int buffer_id, std::shared_ptr<mcl::MirBuffer> const& buffer)80void mcl::ConnectionSurfaceMap::insert(int buffer_id, std::shared_ptr<mcl::MirBuffer> const& buffer)
9281
=== modified file 'src/client/connection_surface_map.h'
--- src/client/connection_surface_map.h 2016-12-13 06:00:32 +0000
+++ src/client/connection_surface_map.h 2016-12-15 15:17:18 +0000
@@ -24,7 +24,6 @@
24#include <shared_mutex>24#include <shared_mutex>
25#include <unordered_map>25#include <unordered_map>
2626
27class MirPresentationChain;
28class MirRenderSurface;27class MirRenderSurface;
29namespace mir28namespace mir
30{29{
@@ -42,7 +41,6 @@
42 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override;41 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override;
4342
44 void insert(frontend::BufferStreamId stream_id, std::shared_ptr<MirBufferStream> const& chain);43 void insert(frontend::BufferStreamId stream_id, std::shared_ptr<MirBufferStream> const& chain);
45 void insert(frontend::BufferStreamId stream_id, std::shared_ptr<MirPresentationChain> const& chain);
46 void erase(frontend::BufferStreamId surface_id);44 void erase(frontend::BufferStreamId surface_id);
4745
48 //TODO: should have a mf::BufferID46 //TODO: should have a mf::BufferID
@@ -58,7 +56,6 @@
58 std::unordered_map<frontend::SurfaceId, std::shared_ptr<MirSurface>> surfaces;56 std::unordered_map<frontend::SurfaceId, std::shared_ptr<MirSurface>> surfaces;
59 std::shared_timed_mutex mutable stream_guard;57 std::shared_timed_mutex mutable stream_guard;
60 std::unordered_map<frontend::BufferStreamId, std::shared_ptr<MirBufferStream>> streams;58 std::unordered_map<frontend::BufferStreamId, std::shared_ptr<MirBufferStream>> streams;
61 std::unordered_map<frontend::BufferStreamId, std::shared_ptr<MirPresentationChain>> chains;
62 std::shared_timed_mutex mutable buffer_guard;59 std::shared_timed_mutex mutable buffer_guard;
63 std::unordered_map<int, std::shared_ptr<MirBuffer>> buffers;60 std::unordered_map<int, std::shared_ptr<MirBuffer>> buffers;
64 std::unordered_map<void*, std::shared_ptr<MirRenderSurface>> render_surfaces;61 std::unordered_map<void*, std::shared_ptr<MirRenderSurface>> render_surfaces;
6562
=== removed file 'src/client/error_chain.cpp'
--- src/client/error_chain.cpp 2016-11-09 02:30:14 +0000
+++ src/client/error_chain.cpp 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "error_chain.h"
20#include <boost/throw_exception.hpp>
21
22namespace mcl = mir::client;
23namespace geom = mir::geometry;
24
25mcl::ErrorChain::ErrorChain(
26 MirConnection* connection,
27 int id,
28 std::string const& error_msg) :
29 connection_(connection),
30 stream_id(id),
31 error(error_msg)
32{
33}
34
35char const* mcl::ErrorChain::error_msg() const
36{
37 return error.c_str();
38}
39
40MirConnection* mcl::ErrorChain::connection() const
41{
42 return connection_;
43}
44
45int mcl::ErrorChain::rpc_id() const
46{
47 return stream_id;
48}
49
50void mcl::ErrorChain::submit_buffer(MirBuffer*)
51{
52 BOOST_THROW_EXCEPTION(std::logic_error("Cannot submit: invalid MirPresentationChain"));
53}
54
55void mcl::ErrorChain::set_queueing_mode()
56{
57 BOOST_THROW_EXCEPTION(std::logic_error("Cannot set mode: invalid MirPresentationChain"));
58}
59
60void mcl::ErrorChain::set_dropping_mode()
61{
62 BOOST_THROW_EXCEPTION(std::logic_error("Cannot set mode: invalid MirPresentationChain"));
63}
640
=== removed file 'src/client/error_chain.h'
--- src/client/error_chain.h 2016-11-09 02:30:14 +0000
+++ src/client/error_chain.h 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_ERROR_CHAIN_H
20#define MIR_CLIENT_ERROR_CHAIN_H
21
22#include "mir_presentation_chain.h"
23#include <memory>
24
25namespace mir
26{
27namespace client
28{
29
30class ErrorChain : public MirPresentationChain
31{
32public:
33 ErrorChain(
34 MirConnection* connection,
35 int id,
36 std::string const& error_msg);
37 void submit_buffer(MirBuffer* buffer) override;
38 MirConnection* connection() const override;
39 int rpc_id() const override;
40 char const* error_msg() const override;
41 void set_dropping_mode() override;
42 void set_queueing_mode() override;
43private:
44 MirConnection* const connection_;
45 int const stream_id;
46 std::string const error;
47};
48
49}
50}
51#endif /* MIR_CLIENT_ERROR_CHAIN_H */
520
=== modified file 'src/client/error_render_surface.cpp'
--- src/client/error_render_surface.cpp 2016-12-09 02:54:31 +0000
+++ src/client/error_render_surface.cpp 2016-12-15 15:17:18 +0000
@@ -62,12 +62,22 @@
62 BOOST_THROW_EXCEPTION(std::runtime_error(error));62 BOOST_THROW_EXCEPTION(std::runtime_error(error));
63}63}
6464
65MirPresentationChain* mcl::ErrorRenderSurface::get_presentation_chain()
66{
67 BOOST_THROW_EXCEPTION(std::runtime_error(error));
68}
69
70char const* mcl::ErrorRenderSurface::get_error_message() const65char const* mcl::ErrorRenderSurface::get_error_message() const
71{66{
72 return error.c_str();67 return error.c_str();
73}68}
69
70void mcl::ErrorRenderSurface::submit_buffer(MirBuffer*)
71{
72 BOOST_THROW_EXCEPTION(std::runtime_error(error));
73}
74
75void mcl::ErrorRenderSurface::set_dropping_mode()
76{
77 BOOST_THROW_EXCEPTION(std::runtime_error(error));
78}
79
80void mcl::ErrorRenderSurface::set_queueing_mode()
81{
82 BOOST_THROW_EXCEPTION(std::runtime_error(error));
83}
7484
=== modified file 'src/client/error_render_surface.h'
--- src/client/error_render_surface.h 2016-12-09 02:54:31 +0000
+++ src/client/error_render_surface.h 2016-12-15 15:17:18 +0000
@@ -41,7 +41,9 @@
41 int width, int height,41 int width, int height,
42 MirPixelFormat format,42 MirPixelFormat format,
43 MirBufferUsage buffer_usage) override;43 MirBufferUsage buffer_usage) override;
44 MirPresentationChain* get_presentation_chain() override;44 void submit_buffer(mir::client::MirBuffer* buffer) override;
45 void set_dropping_mode() override;
46 void set_queueing_mode() override;
45private:47private:
46 std::string const error;48 std::string const error;
47 MirConnection* const connection_;49 MirConnection* const connection_;
4850
=== modified file 'src/client/mir_buffer_api.cpp'
--- src/client/mir_buffer_api.cpp 2016-12-14 06:27:05 +0000
+++ src/client/mir_buffer_api.cpp 2016-12-15 15:17:18 +0000
@@ -16,10 +16,8 @@
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */17 */
1818
19#include "mir_toolkit/mir_presentation_chain.h"
20#include "mir_toolkit/mir_buffer.h"19#include "mir_toolkit/mir_buffer.h"
21#include "mir_toolkit/mir_buffer_private.h"20#include "mir_toolkit/mir_buffer_private.h"
22#include "presentation_chain.h"
23#include "mir_connection.h"21#include "mir_connection.h"
24#include "buffer.h"22#include "buffer.h"
25#include "mir/client_buffer.h"23#include "mir/client_buffer.h"
2624
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2016-12-15 15:17:18 +0000
+++ src/client/mir_connection.cpp 2016-12-15 15:17:18 +0000
@@ -38,8 +38,6 @@
38#include "perf_report.h"38#include "perf_report.h"
39#include "render_surface.h"39#include "render_surface.h"
40#include "error_render_surface.h"40#include "error_render_surface.h"
41#include "presentation_chain.h"
42#include "error_chain.h"
43#include "logging/perf_report.h"41#include "logging/perf_report.h"
44#include "lttng/perf_report.h"42#include "lttng/perf_report.h"
45#include "buffer_factory.h"43#include "buffer_factory.h"
@@ -1172,19 +1170,6 @@
1172 return display_configuration->take_snapshot();1170 return display_configuration->take_snapshot();
1173}1171}
11741172
1175std::shared_ptr<mcl::PresentationChain> MirConnection::create_presentation_chain_with_id(
1176 MirRenderSurface* render_surface,
1177 mir::protobuf::BufferStream const& a_protobuf_bs)
1178{
1179 if (!client_buffer_factory)
1180 client_buffer_factory = platform->create_buffer_factory();
1181 auto chain = std::make_shared<mcl::PresentationChain>(
1182 this, a_protobuf_bs.id().value(), server, client_buffer_factory, buffer_factory);
1183
1184 surface_map->insert(render_surface->stream_id(), chain);
1185 return chain;
1186}
1187
1188void MirConnection::allocate_buffer(1173void MirConnection::allocate_buffer(
1189 geom::Size size, MirPixelFormat format, MirBufferUsage usage,1174 geom::Size size, MirPixelFormat format, MirBufferUsage usage,
1190 mir_buffer_callback callback, void* context)1175 mir_buffer_callback callback, void* context)
@@ -1280,9 +1265,10 @@
1280 {1265 {
1281 auto rs = std::make_shared<mcl::RenderSurface>(1266 auto rs = std::make_shared<mcl::RenderSurface>(
1282 this,1267 this,
1268 display_server(),
1283 request->native_window,1269 request->native_window,
1284 platform,1270 platform,
1285 protobuf_bs,1271 mf::BufferStreamId{protobuf_bs->id().value()},
1286 request->logical_size);1272 request->logical_size);
1287 surface_map->insert(request->native_window.get(), rs);1273 surface_map->insert(request->native_window.get(), rs);
12881274
12891275
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2016-12-15 15:17:18 +0000
+++ src/client/mir_connection.h 2016-12-15 15:17:18 +0000
@@ -167,10 +167,6 @@
167 mir_buffer_stream_callback callback,167 mir_buffer_stream_callback callback,
168 void *context);168 void *context);
169169
170 std::shared_ptr<mir::client::PresentationChain> create_presentation_chain_with_id(
171 MirRenderSurface* render_surface,
172 mir::protobuf::BufferStream const& a_protobuf_bs);
173
174 void release_consumer_stream(MirBufferStream*);170 void release_consumer_stream(MirBufferStream*);
175171
176 static bool is_valid(MirConnection *connection);172 static bool is_valid(MirConnection *connection);
177173
=== removed file 'src/client/mir_presentation_chain.h'
--- src/client/mir_presentation_chain.h 2016-11-22 03:42:44 +0000
+++ src/client/mir_presentation_chain.h 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_MIR_PRESENTATION_CHAIN_H
20#define MIR_CLIENT_MIR_PRESENTATION_CHAIN_H
21
22#include "mir/geometry/size.h"
23#include "mir_toolkit/mir_presentation_chain.h"
24#include "mir/mir_buffer.h"
25
26class MirPresentationChain
27{
28public:
29 virtual ~MirPresentationChain() = default;
30 virtual void submit_buffer(mir::client::MirBuffer* buffer) = 0;
31 virtual MirConnection* connection() const = 0;
32 virtual int rpc_id() const = 0;
33 virtual char const* error_msg() const = 0;
34
35 //In the future, the only mode will be dropping
36 virtual void set_dropping_mode() = 0;
37 virtual void set_queueing_mode() = 0;
38
39protected:
40 MirPresentationChain(MirPresentationChain const&) = delete;
41 MirPresentationChain& operator=(MirPresentationChain const&) = delete;
42 MirPresentationChain() = default;
43};
44
45#endif /* MIR_CLIENT_MIR_PRESENTATION_CHAIN_H */
460
=== removed file 'src/client/mir_presentation_chain_api.cpp'
--- src/client/mir_presentation_chain_api.cpp 2016-12-15 15:17:18 +0000
+++ src/client/mir_presentation_chain_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,88 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir_toolkit/mir_presentation_chain.h"
20#include "mir_toolkit/mir_buffer.h"
21#include "mir_toolkit/mir_buffer_private.h"
22#include "mir_connection.h"
23#include "buffer.h"
24#include "mir_presentation_chain.h"
25#include "mir/uncaught.h"
26#include "mir/require.h"
27#include <stdexcept>
28#include <boost/throw_exception.hpp>
29namespace mcl = mir::client;
30
31//private NBS api under development
32void mir_presentation_chain_submit_buffer(MirPresentationChain* chain, MirBuffer* b)
33try
34{
35 auto buffer = reinterpret_cast<mcl::MirBuffer*>(b);
36 mir::require(chain && buffer && mir_presentation_chain_is_valid(chain));
37 chain->submit_buffer(buffer);
38}
39catch (std::exception const& ex)
40{
41 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
42}
43
44bool mir_presentation_chain_is_valid(MirPresentationChain* chain)
45try
46{
47 mir::require(chain);
48 return mir_presentation_chain_get_error_message(chain) == std::string("");
49}
50catch (std::exception const& ex)
51{
52 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
53 return false;
54}
55
56char const *mir_presentation_chain_get_error_message(MirPresentationChain* chain)
57try
58{
59 mir::require(chain);
60 return chain->error_msg();
61}
62catch (std::exception const& ex)
63{
64 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
65 return "error accessing error message";
66}
67
68void mir_presentation_chain_set_queueing_mode(MirPresentationChain* chain)
69try
70{
71 mir::require(chain);
72 chain->set_queueing_mode();
73}
74catch (std::exception const& ex)
75{
76 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
77}
78
79void mir_presentation_chain_set_dropping_mode(MirPresentationChain* chain)
80try
81{
82 mir::require(chain);
83 chain->set_dropping_mode();
84}
85catch (std::exception const& ex)
86{
87 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
88}
890
=== modified file 'src/client/mir_render_surface.h'
--- src/client/mir_render_surface.h 2016-12-09 02:54:31 +0000
+++ src/client/mir_render_surface.h 2016-12-15 15:17:18 +0000
@@ -24,6 +24,13 @@
24#include "mir/frontend/buffer_stream_id.h"24#include "mir/frontend/buffer_stream_id.h"
25#include "mir/geometry/size.h"25#include "mir/geometry/size.h"
2626
27namespace mir
28{
29namespace client
30{
31class MirBuffer;
32}
33}
27class MirRenderSurface34class MirRenderSurface
28{35{
29public:36public:
@@ -36,8 +43,10 @@
36 int width, int height,43 int width, int height,
37 MirPixelFormat format,44 MirPixelFormat format,
38 MirBufferUsage buffer_usage) = 0;45 MirBufferUsage buffer_usage) = 0;
39 virtual MirPresentationChain* get_presentation_chain() = 0;
40 virtual char const* get_error_message() const = 0;46 virtual char const* get_error_message() const = 0;
47 virtual void submit_buffer(mir::client::MirBuffer* buffer) = 0;
48 virtual void set_dropping_mode() = 0;
49 virtual void set_queueing_mode() = 0;
41 virtual ~MirRenderSurface() = default;50 virtual ~MirRenderSurface() = default;
42protected:51protected:
43 MirRenderSurface(MirRenderSurface const&) = delete;52 MirRenderSurface(MirRenderSurface const&) = delete;
4453
=== modified file 'src/client/mir_render_surface_api.cpp'
--- src/client/mir_render_surface_api.cpp 2016-12-15 15:17:18 +0000
+++ src/client/mir_render_surface_api.cpp 2016-12-15 15:17:18 +0000
@@ -14,10 +14,12 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>16 * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com>
17 * Kevin DuBois <kevin.dubois@canonical.com>
17 */18 */
1819
19#include "mir_connection.h"20#include "mir_connection.h"
20#include "render_surface.h"21#include "render_surface.h"
22#include "mir_toolkit/mir_buffer_private.h"
21#include "mir/uncaught.h"23#include "mir/uncaught.h"
22#include "mir/require.h"24#include "mir/require.h"
23#include "connection_surface_map.h"25#include "connection_surface_map.h"
@@ -191,21 +193,6 @@
191 return nullptr;193 return nullptr;
192}194}
193195
194MirPresentationChain* mir_render_surface_get_presentation_chain(
195 MirRenderSurface* render_surface)
196try
197{
198 mir::require(render_surface);
199 auto connection = connection_map.connection(render_surface);
200 auto rs = connection->connection_surface_map()->render_surface(render_surface);
201 return rs->get_presentation_chain();
202}
203catch (std::exception const& ex)
204{
205 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
206 return nullptr;
207}
208
209void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height)196void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height)
210{197{
211 mir::require(render_surface && width && height);198 mir::require(render_surface && width && height);
@@ -233,3 +220,43 @@
233 auto rs = connection->connection_surface_map()->render_surface(surface);220 auto rs = connection->connection_surface_map()->render_surface(surface);
234 spec->rendersurface_cursor = MirSurfaceSpec::RenderSurfaceCursor{rs->stream_id(), {hotspot_x, hotspot_y}};221 spec->rendersurface_cursor = MirSurfaceSpec::RenderSurfaceCursor{rs->stream_id(), {hotspot_x, hotspot_y}};
235}222}
223
224void mir_render_surface_set_queueing_mode(MirRenderSurface* render_surface)
225try
226{
227 mir::require(render_surface);
228 auto connection = connection_map.connection(render_surface);
229 auto rs = connection->connection_surface_map()->render_surface(render_surface);
230 rs->set_queueing_mode();
231}
232catch (std::exception const& ex)
233{
234 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
235}
236
237void mir_render_surface_set_dropping_mode(MirRenderSurface* render_surface)
238try
239{
240 mir::require(render_surface);
241 auto connection = connection_map.connection(render_surface);
242 auto rs = connection->connection_surface_map()->render_surface(render_surface);
243 rs->set_dropping_mode();
244}
245catch (std::exception const& ex)
246{
247 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
248}
249
250void mir_render_surface_submit_buffer(MirRenderSurface* render_surface, MirBuffer* b)
251try
252{
253 mir::require(render_surface && b && mir_render_surface_is_valid(render_surface));
254 auto connection = connection_map.connection(render_surface);
255 auto rs = connection->connection_surface_map()->render_surface(render_surface);
256 auto buffer = reinterpret_cast<mir::client::MirBuffer*>(b);
257 rs->submit_buffer(buffer);
258}
259catch (std::exception const& ex)
260{
261 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
262}
236263
=== modified file 'src/client/mir_surface_api.cpp'
--- src/client/mir_surface_api.cpp 2016-12-15 15:17:18 +0000
+++ src/client/mir_surface_api.cpp 2016-12-15 15:17:18 +0000
@@ -20,12 +20,10 @@
2020
21#include "mir_toolkit/mir_surface.h"21#include "mir_toolkit/mir_surface.h"
22#include "mir_toolkit/mir_wait.h"22#include "mir_toolkit/mir_wait.h"
23#include "mir_toolkit/mir_presentation_chain.h"
24#include "mir/require.h"23#include "mir/require.h"
2524
26#include "mir_connection.h"25#include "mir_connection.h"
27#include "mir_surface.h"26#include "mir_surface.h"
28#include "presentation_chain.h"
29#include "render_surface.h"27#include "render_surface.h"
30#include "error_connections.h"28#include "error_connections.h"
31#include "connection_surface_map.h"29#include "connection_surface_map.h"
3230
=== removed file 'src/client/presentation_chain.cpp'
--- src/client/presentation_chain.cpp 2016-12-09 02:54:31 +0000
+++ src/client/presentation_chain.cpp 1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir/client_buffer_factory.h"
20#include "mir/client_buffer.h"
21#include "rpc/mir_display_server.h"
22#include "presentation_chain.h"
23#include "protobuf_to_native_buffer.h"
24#include "buffer_factory.h"
25#include <boost/throw_exception.hpp>
26#include <algorithm>
27
28namespace mcl = mir::client;
29namespace geom = mir::geometry;
30namespace mp = mir::protobuf;
31namespace gp = google::protobuf;
32
33mcl::PresentationChain::PresentationChain(
34 MirConnection* connection,
35 int stream_id,
36 mir::client::rpc::DisplayServer& server,
37 std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
38 std::shared_ptr<mcl::AsyncBufferFactory> const& mir_buffer_factory) :
39 connection_(connection),
40 stream_id(stream_id),
41 server(server),
42 native_buffer_factory(native_buffer_factory),
43 mir_buffer_factory(mir_buffer_factory),
44 interval_config{server, frontend::BufferStreamId{stream_id}}
45{
46}
47
48//note: the caller of the mir::client::rpc::DisplayServer interface
49// has to provide the object for the server to fill when we get a
50// response, but we can't pass ownership of the response object to
51// the server given the current interface, nor do we know when the
52// server has been destroyed, so we have to allow for responses
53// to complete after the PresentationChain object has been deleted.
54// (mcl::BufferStream has a similar situation)
55static void ignore_response(mp::Void* response)
56{
57 delete response;
58}
59
60void mcl::PresentationChain::submit_buffer(MirBuffer* buffer)
61{
62 mp::BufferRequest request;
63 {
64 request.mutable_id()->set_value(stream_id);
65 request.mutable_buffer()->set_buffer_id(buffer->rpc_id());
66 buffer->submitted();
67 }
68
69 auto ignored = new mp::Void;
70 server.submit_buffer(&request, ignored, gp::NewCallback(ignore_response, ignored));
71}
72
73int mcl::PresentationChain::rpc_id() const
74{
75 return stream_id;
76}
77
78MirConnection* mcl::PresentationChain::connection() const
79{
80 return connection_;
81}
82
83char const* mcl::PresentationChain::error_msg() const
84{
85 return "";
86}
87
88void mcl::PresentationChain::set_dropping_mode()
89{
90 mir_wait_for(interval_config.set_swap_interval(0));
91}
92
93void mcl::PresentationChain::set_queueing_mode()
94{
95 mir_wait_for(interval_config.set_swap_interval(1));
96}
970
=== removed file 'src/client/presentation_chain.h'
--- src/client/presentation_chain.h 2016-11-09 02:30:14 +0000
+++ src/client/presentation_chain.h 1970-01-01 00:00:00 +0000
@@ -1,74 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_PRESENTATION_CHAIN_H
20#define MIR_CLIENT_PRESENTATION_CHAIN_H
21
22#include "mir_presentation_chain.h"
23#include "buffer_stream.h"
24#include "mir/geometry/size.h"
25#include "mir_toolkit/mir_presentation_chain.h"
26#include "mir_protobuf.pb.h"
27#include "buffer.h"
28#include <mutex>
29#include <memory>
30
31namespace mir
32{
33namespace client
34{
35class ClientBufferFactory;
36class ClientBuffer;
37class AsyncBufferFactory;
38namespace rpc
39{
40class DisplayServer;
41}
42
43class PresentationChain : public MirPresentationChain
44{
45public:
46 PresentationChain(
47 MirConnection* connection,
48 int rpc_id,
49 rpc::DisplayServer& server,
50 std::shared_ptr<ClientBufferFactory> const& native_buffer_factory,
51 std::shared_ptr<AsyncBufferFactory> const& mir_buffer_factory);
52 void submit_buffer(MirBuffer* buffer) override;
53 MirConnection* connection() const override;
54 int rpc_id() const override;
55 char const* error_msg() const override;
56 void set_dropping_mode() override;
57 void set_queueing_mode() override;
58
59private:
60
61 MirConnection* const connection_;
62 int const stream_id;
63 rpc::DisplayServer& server;
64 std::shared_ptr<ClientBufferFactory> const native_buffer_factory;
65 std::shared_ptr<AsyncBufferFactory> const mir_buffer_factory;
66
67 BufferStreamConfiguration interval_config;
68
69 std::mutex mutex;
70 std::vector<std::unique_ptr<Buffer>> buffers;
71};
72}
73}
74#endif /* MIR_CLIENT_PRESENTATION_CHAIN_H */
750
=== modified file 'src/client/render_surface.cpp'
--- src/client/render_surface.cpp 2016-12-09 02:54:31 +0000
+++ src/client/render_surface.cpp 2016-12-15 15:17:18 +0000
@@ -15,11 +15,13 @@
15 *15 *
16 * Authored by:16 * Authored by:
17 * Cemil Azizoglu <cemil.azizoglu@canonical.com>17 * Cemil Azizoglu <cemil.azizoglu@canonical.com>
18 * Kevin DuBois <kevin.dubois@canonical.com>
18 */19 */
1920
20#include "render_surface.h"21#include "render_surface.h"
21#include "buffer_stream.h"22#include "buffer_stream.h"
22#include "mir_wait_handle.h"23#include "mir_wait_handle.h"
24#include "mir/mir_buffer.h"
23#include "rpc/mir_display_server.h"25#include "rpc/mir_display_server.h"
2426
25#include "mir/client_platform.h"27#include "mir/client_platform.h"
@@ -33,15 +35,18 @@
3335
34mcl::RenderSurface::RenderSurface(36mcl::RenderSurface::RenderSurface(
35 MirConnection* const connection,37 MirConnection* const connection,
38 mcl::rpc::DisplayServer& server,
36 std::shared_ptr<void> native_window,39 std::shared_ptr<void> native_window,
37 std::shared_ptr<ClientPlatform> client_platform,40 std::shared_ptr<ClientPlatform> client_platform,
38 std::shared_ptr<mp::BufferStream> protobuf_bs,41 mf::BufferStreamId id,
39 geom::Size size) :42 geom::Size size) :
40 connection_(connection),43 connection_(connection),
44 server(server),
41 wrapped_native_window(native_window),45 wrapped_native_window(native_window),
42 platform(client_platform),46 platform(client_platform),
43 protobuf_bs(protobuf_bs),47 id(id),
44 desired_size{size}48 desired_size{size},
49 interval_config(server, id)
45{50{
46}51}
4752
@@ -52,7 +57,7 @@
5257
53mf::BufferStreamId mcl::RenderSurface::stream_id() const58mf::BufferStreamId mcl::RenderSurface::stream_id() const
54{59{
55 return mf::BufferStreamId(protobuf_bs->id().value());60 return id;
56}61}
5762
58MirBufferStream* mcl::RenderSurface::get_buffer_stream(63MirBufferStream* mcl::RenderSurface::get_buffer_stream(
@@ -60,15 +65,17 @@
60 MirPixelFormat format,65 MirPixelFormat format,
61 MirBufferUsage buffer_usage)66 MirBufferUsage buffer_usage)
62{67{
63 if (chain_from_id || stream_from_id)68 if (submitting || stream_from_id)
64 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));69 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
6570
66 protobuf_bs->set_pixel_format(format);71 mir::protobuf::BufferStream protobuf_bs;
67 protobuf_bs->set_buffer_usage(buffer_usage);72 protobuf_bs.mutable_id()->set_value(id.as_value());
73 protobuf_bs.set_pixel_format(format);
74 protobuf_bs.set_buffer_usage(buffer_usage);
68 stream_from_id = connection_->create_client_buffer_stream_with_id(width,75 stream_from_id = connection_->create_client_buffer_stream_with_id(width,
69 height,76 height,
70 this,77 this,
71 *protobuf_bs);78 protobuf_bs);
72 if (buffer_usage == mir_buffer_usage_hardware)79 if (buffer_usage == mir_buffer_usage_hardware)
73 {80 {
74 platform->use_egl_native_window(81 platform->use_egl_native_window(
@@ -78,19 +85,6 @@
78 return stream_from_id.get();85 return stream_from_id.get();
79}86}
8087
81MirPresentationChain* mcl::RenderSurface::get_presentation_chain()
82{
83 if (chain_from_id || stream_from_id)
84 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
85
86 chain_from_id = connection_->create_presentation_chain_with_id(this,
87 *protobuf_bs);
88 //TODO: Figure out how to handle mir_buffer_usage_hardware once
89 // EGL is made to support RSs.
90
91 return reinterpret_cast<MirPresentationChain*>(chain_from_id.get());
92}
93
94geom::Size mcl::RenderSurface::size() const88geom::Size mcl::RenderSurface::size() const
95{89{
96 std::lock_guard<decltype(size_mutex)> lk(size_mutex);90 std::lock_guard<decltype(size_mutex)> lk(size_mutex);
@@ -105,14 +99,49 @@
10599
106bool mcl::RenderSurface::valid() const100bool mcl::RenderSurface::valid() const
107{101{
108 return protobuf_bs->has_id() && !protobuf_bs->has_error();102 return true;
109}103}
110104
111char const* mcl::RenderSurface::get_error_message() const105char const* mcl::RenderSurface::get_error_message() const
112{106{
113 if (protobuf_bs->has_error())
114 {
115 return protobuf_bs->error().c_str();
116 }
117 return "";107 return "";
118}108}
109
110//note: the caller of the mir::client::rpc::DisplayServer interface
111// has to provide the object for the server to fill when we get a
112// response, but we can't pass ownership of the response object to
113// the server given the current interface, nor do we know when the
114// server has been destroyed, so we have to allow for responses
115// to complete after the PresentationChain object has been deleted.
116// (mcl::BufferStream has a similar situation)
117static void ignore_response(mp::Void* response)
118{
119 delete response;
120}
121
122void mcl::RenderSurface::submit_buffer(MirBuffer* buffer)
123{
124 if (stream_from_id)
125 BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out"));
126
127 submitting = true;
128 mp::BufferRequest request;
129 {
130 request.mutable_id()->set_value(stream_id().as_value());
131 request.mutable_buffer()->set_buffer_id(buffer->rpc_id());
132 buffer->submitted();
133 }
134
135 auto ignored = new mp::Void;
136 server.submit_buffer(&request, ignored, google::protobuf::NewCallback(ignore_response, ignored));
137}
138
139void mcl::RenderSurface::set_dropping_mode()
140{
141 mir_wait_for(interval_config.set_swap_interval(0));
142}
143
144void mcl::RenderSurface::set_queueing_mode()
145{
146 mir_wait_for(interval_config.set_swap_interval(1));
147}
119148
=== modified file 'src/client/render_surface.h'
--- src/client/render_surface.h 2016-12-13 06:00:32 +0000
+++ src/client/render_surface.h 2016-12-15 15:17:18 +0000
@@ -22,6 +22,7 @@
2222
23#include "mir_connection.h"23#include "mir_connection.h"
24#include "mir_render_surface.h"24#include "mir_render_surface.h"
25#include "buffer_stream_configuration.h"
25#include "mir_toolkit/mir_render_surface.h"26#include "mir_toolkit/mir_render_surface.h"
26#include "mir_toolkit/client_types.h"27#include "mir_toolkit/client_types.h"
27#include "mir/frontend/surface_id.h"28#include "mir/frontend/surface_id.h"
@@ -43,11 +44,13 @@
43class RenderSurface : public MirRenderSurface44class RenderSurface : public MirRenderSurface
44{45{
45public:46public:
46 RenderSurface(MirConnection* const connection,47 RenderSurface(
47 std::shared_ptr<void> native_window,48 MirConnection* const connection,
48 std::shared_ptr<ClientPlatform> client_platform,49 rpc::DisplayServer& server,
49 std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs,50 std::shared_ptr<void> native_window,
50 geometry::Size size);51 std::shared_ptr<ClientPlatform> client_platform,
52 frontend::BufferStreamId id,
53 geometry::Size size);
51 MirConnection* connection() const override;54 MirConnection* connection() const override;
52 mir::geometry::Size size() const override;55 mir::geometry::Size size() const override;
53 void set_size(mir::geometry::Size) override;56 void set_size(mir::geometry::Size) override;
@@ -58,18 +61,22 @@
58 int width, int height,61 int width, int height,
59 MirPixelFormat format,62 MirPixelFormat format,
60 MirBufferUsage buffer_usage) override;63 MirBufferUsage buffer_usage) override;
61 MirPresentationChain* get_presentation_chain() override;64 void submit_buffer(MirBuffer* buffer) override;
65 void set_dropping_mode() override;
66 void set_queueing_mode() override;
6267
63private:68private:
64 MirConnection* const connection_;69 MirConnection* const connection_;
70 rpc::DisplayServer& server;
65 std::shared_ptr<void> wrapped_native_window;71 std::shared_ptr<void> wrapped_native_window;
66 std::shared_ptr<ClientPlatform> platform;72 std::shared_ptr<ClientPlatform> platform;
67 std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs;73 frontend::BufferStreamId id;
68 std::shared_ptr<mir::client::BufferStream> stream_from_id;74 std::shared_ptr<mir::client::BufferStream> stream_from_id;
69 std::shared_ptr<mir::client::PresentationChain> chain_from_id;
7075
76 bool submitting = false;
71 std::mutex mutable size_mutex;77 std::mutex mutable size_mutex;
72 geometry::Size desired_size;78 geometry::Size desired_size;
79 BufferStreamConfiguration interval_config;
73};80};
74}81}
75}82}
7683
=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-12-13 06:00:32 +0000
+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2016-12-15 15:17:18 +0000
@@ -21,7 +21,6 @@
2121
22#include "../surface_map.h"22#include "../surface_map.h"
23#include "../buffer.h"23#include "../buffer.h"
24#include "../presentation_chain.h"
25#include "../buffer_factory.h"24#include "../buffer_factory.h"
26#include "../mir_surface.h"25#include "../mir_surface.h"
27#include "../display_configuration.h"26#include "../display_configuration.h"
2827
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2016-12-15 15:17:18 +0000
+++ src/client/symbols.map 2016-12-15 15:17:18 +0000
@@ -368,10 +368,8 @@
368 mir_buffer_unmap;368 mir_buffer_unmap;
369 mir_buffer_set_callback;369 mir_buffer_set_callback;
370 mir_buffer_release;370 mir_buffer_release;
371 mir_presentation_chain_is_valid;
372 mir_presentation_chain_get_error_message;
373 mir_connection_allocate_buffer;371 mir_connection_allocate_buffer;
374 mir_presentation_chain_submit_buffer;372 mir_render_surface_submit_buffer;
375 mir_buffer_get_width;373 mir_buffer_get_width;
376 mir_buffer_get_height;374 mir_buffer_get_height;
377 mir_buffer_get_pixel_format;375 mir_buffer_get_pixel_format;
@@ -382,7 +380,6 @@
382 mir_connection_create_render_surface;380 mir_connection_create_render_surface;
383 mir_connection_create_render_surface_sync;381 mir_connection_create_render_surface_sync;
384 mir_render_surface_get_buffer_stream;382 mir_render_surface_get_buffer_stream;
385 mir_render_surface_get_presentation_chain;
386 mir_render_surface_is_valid;383 mir_render_surface_is_valid;
387 mir_render_surface_get_error_message;384 mir_render_surface_get_error_message;
388 mir_render_surface_get_size;385 mir_render_surface_get_size;
@@ -393,8 +390,8 @@
393 #private functions needed temporarily by nested passthrough390 #private functions needed temporarily by nested passthrough
394 #should not be published along with the rest of the NBS symbols391 #should not be published along with the rest of the NBS symbols
395 mir_buffer_get_egl_image_parameters;392 mir_buffer_get_egl_image_parameters;
396 mir_presentation_chain_set_queueing_mode;393 mir_render_surface_set_queueing_mode;
397 mir_presentation_chain_set_dropping_mode;394 mir_render_surface_set_dropping_mode;
398 local:395 local:
399 *;396 *;
400} MIR_CLIENT_DETAIL_9v19;397} MIR_CLIENT_DETAIL_9v19;
401398
=== modified file 'src/include/client/mir_toolkit/client_types_nbs.h'
--- src/include/client/mir_toolkit/client_types_nbs.h 2016-12-15 15:17:18 +0000
+++ src/include/client/mir_toolkit/client_types_nbs.h 2016-12-15 15:17:18 +0000
@@ -29,7 +29,6 @@
29#endif29#endif
3030
31/* NOTE: this file will be rolled into mir_toolkit/client_types.h when made public. */31/* NOTE: this file will be rolled into mir_toolkit/client_types.h when made public. */
32typedef struct MirPresentationChain MirPresentationChain;
33typedef struct MirBuffer MirBuffer;32typedef struct MirBuffer MirBuffer;
34typedef struct MirRenderSurface MirRenderSurface;33typedef struct MirRenderSurface MirRenderSurface;
3534
3635
=== modified file 'src/include/client/mir_toolkit/extensions/android_buffer.h'
--- src/include/client/mir_toolkit/extensions/android_buffer.h 2016-11-30 18:00:03 +0000
+++ src/include/client/mir_toolkit/extensions/android_buffer.h 2016-12-15 15:17:18 +0000
@@ -34,7 +34,7 @@
34 *34 *
35 * The callback will be called when the buffer is available for use.35 * The callback will be called when the buffer is available for use.
36 * It will be called once when created, and once per every36 * It will be called once when created, and once per every
37 * mir_presentation_chain_submit_buffer.37 * mir_render_surface_submit_buffer.
38 *38 *
39 * The buffer can be destroyed via mir_buffer_release().39 * The buffer can be destroyed via mir_buffer_release().
40 *40 *
4141
=== modified file 'src/include/client/mir_toolkit/mir_buffer.h'
--- src/include/client/mir_toolkit/mir_buffer.h 2016-12-14 06:27:05 +0000
+++ src/include/client/mir_toolkit/mir_buffer.h 2016-12-15 15:17:18 +0000
@@ -34,7 +34,7 @@
34 *34 *
35 * The callback will be called when the buffer is available for use.35 * The callback will be called when the buffer is available for use.
36 * It will be called once when created, and once per every36 * It will be called once when created, and once per every
37 * mir_presentation_chain_submit_buffer.37 * mir_render_surface_submit_buffer.
38 *38 *
39 * \param [in] connection The connection39 * \param [in] connection The connection
40 * \param [in] width Requested buffer width40 * \param [in] width Requested buffer width
4141
=== modified file 'src/include/client/mir_toolkit/mir_buffer_private.h'
--- src/include/client/mir_toolkit/mir_buffer_private.h 2016-11-11 07:56:09 +0000
+++ src/include/client/mir_toolkit/mir_buffer_private.h 2016-12-15 15:17:18 +0000
@@ -30,28 +30,28 @@
30extern "C" {30extern "C" {
31#endif31#endif
3232
33/** Note: mir_presentation_chain{set_queueing,set_dropping}_mode are temporary33/** Note: mir_render_surface{set_queueing,set_dropping}_mode are temporary
34 * modes needed by the nested server to support swapinterval on passthrough34 * modes needed by the nested server to support swapinterval on passthrough
35 * clients. Once frame notification signals are given to the client, we can35 * clients. Once frame notification signals are given to the client, we can
36 * just have dropping mode.36 * just have dropping mode.
37 **/37 **/
3838
39/**39/**
40 * Set the MirPresentationChain to display all buffers for at least 1 frame40 * Set the MirRenderSurface to display all buffers for at least 1 frame
41 * once submitted via mir_presentation_chain_submit_buffer.41 * once submitted via mir_render_surface_submit_buffer.
42 *42 *
43 * \param [in] chain The chain43 * \param [in] chain The chain
44 **/44 **/
45void mir_presentation_chain_set_queueing_mode(MirPresentationChain* chain);45void mir_render_surface_set_queueing_mode(MirRenderSurface* chain);
4646
47/**47/**
48 * Set the MirPresentationChain to return buffers held by the server48 * Set the MirRenderSurface to return buffers held by the server
49 * to the client at the earliest possible time when a new buffer is submitted49 * to the client at the earliest possible time when a new buffer is submitted
50 * to mir_presentation_chain_submit_buffer.50 * to mir_render_surface_submit_buffer.
51 *51 *
52 * \param [in] chain The chain52 * \param [in] chain The chain
53 **/53 **/
54void mir_presentation_chain_set_dropping_mode(MirPresentationChain* chain);54void mir_render_surface_set_dropping_mode(MirRenderSurface* chain);
5555
56/** Suggest parameters to use with EGLCreateImage for a given MirBuffer56/** Suggest parameters to use with EGLCreateImage for a given MirBuffer
57 *57 *
5858
=== removed file 'src/include/client/mir_toolkit/mir_presentation_chain.h'
--- src/include/client/mir_toolkit/mir_presentation_chain.h 2016-12-15 15:17:18 +0000
+++ src/include/client/mir_toolkit/mir_presentation_chain.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
19#define MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
20
21#include <mir_toolkit/client_types_nbs.h>
22
23#ifdef __cplusplus
24/**
25 * \addtogroup mir_toolkit
26 * @{
27 */
28extern "C" {
29#endif
30
31/**
32 * Test for a valid presentation chain
33 *
34 * \param [in] presentation_chain The presentation chain
35 * \return True if the supplied presentation_chain is valid,
36 * or false otherwise.
37 */
38bool mir_presentation_chain_is_valid(MirPresentationChain* presentation_chain);
39
40/**
41 * Retrieve a text description of the error. The returned string is owned by
42 * the library and remains valid until the chain or the associated
43 * connection has been released.
44 * \param [in] presentation_chain The presentation chain
45 * \return A text description of any error
46 * resulting in an invalid chain, or the
47 * empty string "" if the chain is valid.
48 */
49char const *mir_presentation_chain_get_error_message(
50 MirPresentationChain* presentation_chain);
51
52/** Submit a buffer to the server so the server can display it.
53 *
54 * The server will notify the client when the buffer is available again via
55 * the callback registered during buffer creation.
56 *
57 * \warning: Once submitted, the buffer cannot be modified until the server
58 * has returned it. There's no guarantee about how long a server
59 * may hold the submitted buffer.
60 *
61 * \param [in] presentation_chain The presentation chain
62 * \param [in] buffer The buffer to be submitted
63 **/
64void mir_presentation_chain_submit_buffer(
65 MirPresentationChain* presentation_chain, MirBuffer* buffer);
66
67#ifdef __cplusplus
68}
69/**@}*/
70#endif
71
72#endif // MIR_TOOLKIT_MIR_PRESENTATION_CHAIN_H_
730
=== modified file 'src/include/client/mir_toolkit/mir_render_surface.h'
--- src/include/client/mir_toolkit/mir_render_surface.h 2016-12-13 06:00:32 +0000
+++ src/include/client/mir_toolkit/mir_render_surface.h 2016-12-15 15:17:18 +0000
@@ -125,9 +125,8 @@
125 * \param [in] usage Requested buffer usage125 * \param [in] usage Requested buffer usage
126 *126 *
127 * \return The buffer stream contained in the given render surface127 * \return The buffer stream contained in the given render surface
128 * or 'nullptr' if it, or128 * or 'nullptr' if mir_render_surface_submit_buffer()
129 * mir_render_surface_get_presentation_chain(), has already129 * has already been called once.
130 * been called once
131 */130 */
132MirBufferStream* mir_render_surface_get_buffer_stream(131MirBufferStream* mir_render_surface_get_buffer_stream(
133 MirRenderSurface* render_surface,132 MirRenderSurface* render_surface,
@@ -136,17 +135,6 @@
136 MirBufferUsage usage);135 MirBufferUsage usage);
137136
138/**137/**
139 * Obtain the presentation chain backing a given render surface
140 *
141 * \return The chain contained in the given render surface
142 * or 'nullptr' if it, or
143 * mir_render_surface_get_buffer_stream(), has already
144 * been called once
145 */
146MirPresentationChain* mir_render_surface_get_presentation_chain(
147 MirRenderSurface* render_surface);
148
149/**
150 * Set the MirSurfaceSpec to display content contained in a render surface138 * Set the MirSurfaceSpec to display content contained in a render surface
151 *139 *
152 * \warning: The initial call to mir_surface_spec_add_render_surface will set140 * \warning: The initial call to mir_surface_spec_add_render_surface will set
@@ -181,6 +169,22 @@
181 MirRenderSurface* render_surface,169 MirRenderSurface* render_surface,
182 int hotspot_x, int hotspot_y);170 int hotspot_x, int hotspot_y);
183171
172/** Submit a buffer to the server so the server can display it.
173 *
174 * The server will notify the client when the buffer is available again via
175 * the callback registered during buffer creation.
176 *
177 * \note: this queues in the same way as VK_PRESENT_MODE_FIFO_KHR
178 * \warning: Once submitted, the buffer cannot be modified until the server
179 * has returned it. There's no guarantee about how long a server
180 * may hold the submitted buffer.
181 *
182 * \param [in] render_surface The presentation chain
183 * \param [in] buffer The buffer to be submitted
184 **/
185void mir_render_surface_submit_buffer(
186 MirRenderSurface* render_surface, MirBuffer* buffer);
187
184#ifdef __cplusplus188#ifdef __cplusplus
185}189}
186/**@}*/190/**@}*/
187191
=== modified file 'src/server/graphics/nested/display_buffer.cpp'
--- src/server/graphics/nested/display_buffer.cpp 2016-11-16 13:24:41 +0000
+++ src/server/graphics/nested/display_buffer.cpp 2016-12-15 15:17:18 +0000
@@ -137,7 +137,7 @@
137137
138 {138 {
139 std::unique_lock<std::mutex> lk(mutex);139 std::unique_lock<std::mutex> lk(mutex);
140 SubmissionInfo submission_info{native->client_handle(), host_chain->handle()};140 SubmissionInfo submission_info{native->client_handle(), host_chain->rs()};
141 auto submitted = submitted_buffers.find(submission_info);141 auto submitted = submitted_buffers.find(submission_info);
142 if ((submission_info != last_submitted) && (submitted != submitted_buffers.end()))142 if ((submission_info != last_submitted) && (submitted != submitted_buffers.end()))
143 BOOST_THROW_EXCEPTION(std::logic_error("cannot resubmit buffer that has not been returned by host server"));143 BOOST_THROW_EXCEPTION(std::logic_error("cannot resubmit buffer that has not been returned by host server"));
@@ -155,7 +155,7 @@
155155
156 native->on_ownership_notification(156 native->on_ownership_notification(
157 std::bind(&mgn::detail::DisplayBuffer::release_buffer, this,157 std::bind(&mgn::detail::DisplayBuffer::release_buffer, this,
158 native->client_handle(), host_chain->handle()));158 native->client_handle(), host_chain->rs()));
159 host_chain->submit_buffer(*native);159 host_chain->submit_buffer(*native);
160160
161 if (content != BackingContent::chain)161 if (content != BackingContent::chain)
@@ -168,7 +168,7 @@
168 return true;168 return true;
169}169}
170170
171void mgn::detail::DisplayBuffer::release_buffer(MirBuffer* b, MirPresentationChain *c)171void mgn::detail::DisplayBuffer::release_buffer(MirBuffer* b, MirRenderSurface *c)
172{172{
173 std::unique_lock<std::mutex> lk(mutex);173 std::unique_lock<std::mutex> lk(mutex);
174 auto buf = submitted_buffers.find(SubmissionInfo{b, c});174 auto buf = submitted_buffers.find(SubmissionInfo{b, c});
175175
=== modified file 'src/server/graphics/nested/display_buffer.h'
--- src/server/graphics/nested/display_buffer.h 2016-10-31 02:37:31 +0000
+++ src/server/graphics/nested/display_buffer.h 2016-12-15 15:17:18 +0000
@@ -93,11 +93,11 @@
93 glm::mat4 const identity;93 glm::mat4 const identity;
9494
95 std::mutex mutex;95 std::mutex mutex;
96 typedef std::tuple<MirBuffer*, MirPresentationChain*> SubmissionInfo;96 typedef std::tuple<MirBuffer*, MirRenderSurface*> SubmissionInfo;
97 std::map<SubmissionInfo, std::shared_ptr<graphics::Buffer>> submitted_buffers;97 std::map<SubmissionInfo, std::shared_ptr<graphics::Buffer>> submitted_buffers;
98 SubmissionInfo last_submitted { nullptr, nullptr };98 SubmissionInfo last_submitted { nullptr, nullptr };
9999
100 void release_buffer(MirBuffer* b, MirPresentationChain* c);100 void release_buffer(MirBuffer* b, MirRenderSurface* c);
101};101};
102}102}
103}103}
104104
=== modified file 'src/server/graphics/nested/host_chain.h'
--- src/server/graphics/nested/host_chain.h 2016-12-15 15:17:18 +0000
+++ src/server/graphics/nested/host_chain.h 2016-12-15 15:17:18 +0000
@@ -40,7 +40,6 @@
40 virtual ~HostChain() = default;40 virtual ~HostChain() = default;
41 virtual void submit_buffer(NativeBuffer&) = 0;41 virtual void submit_buffer(NativeBuffer&) = 0;
42 virtual void set_submission_mode(SubmissionMode mode) = 0;42 virtual void set_submission_mode(SubmissionMode mode) = 0;
43 virtual MirPresentationChain* handle() = 0;
44 virtual MirRenderSurface* rs() const = 0;43 virtual MirRenderSurface* rs() const = 0;
45protected:44protected:
46 HostChain() = default;45 HostChain() = default;
4746
=== modified file 'src/server/graphics/nested/mir_client_host_connection.cpp'
--- src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-15 15:17:18 +0000
+++ src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-15 15:17:18 +0000
@@ -29,7 +29,6 @@
29#include "mir_toolkit/mir_buffer.h"29#include "mir_toolkit/mir_buffer.h"
30#include "mir_toolkit/mir_extension_core.h"30#include "mir_toolkit/mir_extension_core.h"
31#include "mir_toolkit/mir_buffer_private.h"31#include "mir_toolkit/mir_buffer_private.h"
32#include "mir_toolkit/mir_presentation_chain.h"
33#include "mir_toolkit/mir_render_surface.h"32#include "mir_toolkit/mir_render_surface.h"
34#include "mir_toolkit/extensions/fenced_buffers.h"33#include "mir_toolkit/extensions/fenced_buffers.h"
35#include "mir/raii.h"34#include "mir/raii.h"
@@ -505,8 +504,7 @@
505{504{
506505
507 Chain(MirConnection* connection) :506 Chain(MirConnection* connection) :
508 render_surface(mir_connection_create_render_surface_sync(connection, 0, 0)),507 render_surface(mir_connection_create_render_surface_sync(connection, 0, 0))
509 chain(mir_render_surface_get_presentation_chain(render_surface))
510 {508 {
511 }509 }
512 ~Chain()510 ~Chain()
@@ -516,20 +514,15 @@
516514
517 void submit_buffer(mgn::NativeBuffer& buffer) override515 void submit_buffer(mgn::NativeBuffer& buffer) override
518 {516 {
519 mir_presentation_chain_submit_buffer(chain, buffer.client_handle());517 mir_render_surface_submit_buffer(render_surface, buffer.client_handle());
520 }518 }
521519
522 void set_submission_mode(mgn::SubmissionMode mode) override520 void set_submission_mode(mgn::SubmissionMode mode) override
523 {521 {
524 if (mode == mgn::SubmissionMode::queueing)522 if (mode == mgn::SubmissionMode::queueing)
525 mir_presentation_chain_set_queueing_mode(chain);523 mir_render_surface_set_queueing_mode(render_surface);
526 else524 else
527 mir_presentation_chain_set_dropping_mode(chain);525 mir_render_surface_set_dropping_mode(render_surface);
528 }
529
530 MirPresentationChain* handle() override
531 {
532 return chain;
533 }526 }
534527
535 MirRenderSurface* rs() const override528 MirRenderSurface* rs() const override
@@ -539,7 +532,6 @@
539532
540private:533private:
541 MirRenderSurface* const render_surface;534 MirRenderSurface* const render_surface;
542 MirPresentationChain* chain;
543};535};
544536
545std::unique_ptr<mgn::HostChain> mgn::MirClientHostConnection::create_chain() const537std::unique_ptr<mgn::HostChain> mgn::MirClientHostConnection::create_chain() const
546538
=== modified file 'tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp'
--- tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp 2016-12-15 15:17:18 +0000
+++ tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp 2016-12-15 15:17:18 +0000
@@ -17,7 +17,6 @@
17 */17 */
1818
19#include "../buffer_stream_arrangement.h"19#include "../buffer_stream_arrangement.h"
20#include "mir_toolkit/mir_presentation_chain.h"
21#include "mir_toolkit/mir_render_surface.h"20#include "mir_toolkit/mir_render_surface.h"
22#include <gmock/gmock.h>21#include <gmock/gmock.h>
2322
2423
=== modified file 'tests/acceptance-tests/staging/test_presentation_chain.cpp'
--- tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
+++ tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
@@ -17,7 +17,6 @@
17 */17 */
1818
19#include "mir_toolkit/mir_render_surface.h"19#include "mir_toolkit/mir_render_surface.h"
20#include "mir_toolkit/mir_presentation_chain.h"
21#include "mir_toolkit/mir_buffer.h"20#include "mir_toolkit/mir_buffer.h"
2221
23#include "mir_toolkit/mir_client_library.h"22#include "mir_toolkit/mir_client_library.h"
@@ -46,28 +45,21 @@
46 Chain& operator=(Chain const&) = delete;45 Chain& operator=(Chain const&) = delete;
4746
48 Chain(MirConnection* connection) :47 Chain(MirConnection* connection) :
49 rs(mir_connection_create_render_surface_sync(connection, 0, 0)),48 rs(mir_connection_create_render_surface_sync(connection, 0, 0))
50 chain(mir_render_surface_get_presentation_chain(rs))
51 {49 {
52 }50 }
5351
54 MirRenderSurface* content()52 operator MirRenderSurface*()
55 {53 {
56 return rs;54 return rs;
57 }55 }
5856
59 operator MirPresentationChain*()
60 {
61 return chain;
62 }
63
64 ~Chain()57 ~Chain()
65 {58 {
66 mir_render_surface_release(rs);59 mir_render_surface_release(rs);
67 }60 }
68private:61private:
69 MirRenderSurface* rs;62 MirRenderSurface* rs;
70 MirPresentationChain* chain;
71};63};
7264
73class SurfaceWithChain65class SurfaceWithChain
@@ -118,7 +110,7 @@
118 auto spec = mir_connection_create_spec_for_normal_surface(110 auto spec = mir_connection_create_spec_for_normal_surface(
119 connection, size.width.as_int(), size.height.as_int(), pf);111 connection, size.width.as_int(), size.height.as_int(), pf);
120 mir_surface_spec_add_render_surface(112 mir_surface_spec_add_render_surface(
121 spec, chain.content(), size.width.as_int(), size.height.as_int(), 0, 0);113 spec, chain, size.width.as_int(), size.height.as_int(), 0, 0);
122 auto surface = mir_surface_create_sync(spec);114 auto surface = mir_surface_create_sync(spec);
123 mir_surface_spec_release(spec);115 mir_surface_spec_release(spec);
124 return surface;116 return surface;
@@ -144,7 +136,7 @@
144 mir_surface_spec_release(spec);136 mir_surface_spec_release(spec);
145 spec = mir_create_surface_spec(connection);137 spec = mir_create_surface_spec(connection);
146 mir_surface_spec_add_render_surface(138 mir_surface_spec_add_render_surface(
147 spec, chain.content(), size.width.as_int(), size.height.as_int(), 0, 0);139 spec, chain, size.width.as_int(), size.height.as_int(), 0, 0);
148 mir_surface_apply_spec(surface, spec);140 mir_surface_apply_spec(surface, spec);
149 mir_surface_spec_release(spec);141 mir_surface_spec_release(spec);
150 return surface;142 return surface;
@@ -310,7 +302,7 @@
310302
311 for(auto i = 0u; i < num_iterations; i++)303 for(auto i = 0u; i < num_iterations; i++)
312 {304 {
313 mir_presentation_chain_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());305 mir_render_surface_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
314 contexts[i % num_buffers].unavailable();306 contexts[i % num_buffers].unavailable();
315 if (i != 0)307 if (i != 0)
316 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;308 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;
@@ -339,7 +331,7 @@
339331
340 for(auto i = 0u; i < num_iterations; i++)332 for(auto i = 0u; i < num_iterations; i++)
341 {333 {
342 mir_presentation_chain_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());334 mir_render_surface_submit_buffer(surface.chain(), contexts[i % num_buffers].buffer());
343 contexts[i % num_buffers].unavailable();335 contexts[i % num_buffers].unavailable();
344 if (i != 0)336 if (i != 0)
345 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;337 ASSERT_TRUE(contexts[(i-1) % num_buffers].wait_for_buffer(10s)) << "iteration " << i;
@@ -360,7 +352,7 @@
360352
361 ASSERT_TRUE(context.wait_for_buffer(10s));353 ASSERT_TRUE(context.wait_for_buffer(10s));
362 ASSERT_THAT(context.buffer(), Ne(nullptr));354 ASSERT_THAT(context.buffer(), Ne(nullptr));
363 mir_presentation_chain_submit_buffer(surface.chain(), context.buffer());355 mir_render_surface_submit_buffer(surface.chain(), context.buffer());
364 mir_buffer_release(context.buffer());356 mir_buffer_release(context.buffer());
365}357}
366358
@@ -383,10 +375,8 @@
383TEST_F(PresentationChain, destroying_a_chain_will_return_buffers_associated_with_chain)375TEST_F(PresentationChain, destroying_a_chain_will_return_buffers_associated_with_chain)
384{376{
385 auto rs_chain = mir_connection_create_render_surface_sync(connection, 1, 1);377 auto rs_chain = mir_connection_create_render_surface_sync(connection, 1, 1);
386 auto chain = mir_render_surface_get_presentation_chain(rs_chain);
387 auto rs_stream = mir_connection_create_render_surface_sync(connection, 1, 1);378 auto rs_stream = mir_connection_create_render_surface_sync(connection, 1, 1);
388 auto stream = mir_render_surface_get_buffer_stream(rs_stream, 25, 12, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);379 auto stream = mir_render_surface_get_buffer_stream(rs_stream, 25, 12, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
389 ASSERT_TRUE(mir_presentation_chain_is_valid(chain));
390 ASSERT_TRUE(mir_render_surface_is_valid(rs_chain));380 ASSERT_TRUE(mir_render_surface_is_valid(rs_chain));
391 ASSERT_TRUE(mir_render_surface_is_valid(rs_stream));381 ASSERT_TRUE(mir_render_surface_is_valid(rs_stream));
392382
@@ -408,7 +398,7 @@
408 buffer_callback, &context);398 buffer_callback, &context);
409 ASSERT_TRUE(context.wait_for_buffer(10s));399 ASSERT_TRUE(context.wait_for_buffer(10s));
410 context.unavailable();400 context.unavailable();
411 mir_presentation_chain_submit_buffer(chain, context.buffer());401 mir_render_surface_submit_buffer(rs_chain, context.buffer());
412402
413 spec = mir_connection_create_spec_for_changes(connection);403 spec = mir_connection_create_spec_for_changes(connection);
414 mir_surface_spec_add_render_surface(spec, rs_stream, size.width.as_int(), size.height.as_int(), 0, 0);404 mir_surface_spec_add_render_surface(spec, rs_stream, size.width.as_int(), size.height.as_int(), 0, 0);
@@ -498,9 +488,9 @@
498488
499 mir_buffer_set_callback(context.buffer(), another_buffer_callback, &another_context);489 mir_buffer_set_callback(context.buffer(), another_buffer_callback, &another_context);
500490
501 mir_presentation_chain_submit_buffer(surface.chain(), context.buffer());491 mir_render_surface_submit_buffer(surface.chain(), context.buffer());
502 //flush the 1st buffer out492 //flush the 1st buffer out
503 mir_presentation_chain_submit_buffer(surface.chain(), second_buffer_context.buffer());493 mir_render_surface_submit_buffer(surface.chain(), second_buffer_context.buffer());
504494
505 ASSERT_TRUE(another_context.wait_for_buffer(10s));495 ASSERT_TRUE(another_context.wait_for_buffer(10s));
506 ASSERT_THAT(another_context.buffer(), Ne(nullptr));496 ASSERT_THAT(another_context.buffer(), Ne(nullptr));
507497
=== modified file 'tests/acceptance-tests/staging/test_render_surface.cpp'
--- tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-13 06:00:32 +0000
+++ tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-15 15:17:18 +0000
@@ -18,7 +18,7 @@
1818
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_render_surface.h"20#include "mir_toolkit/mir_render_surface.h"
21#include "mir_toolkit/mir_presentation_chain.h"21#include "mir_toolkit/mir_buffer.h"
2222
23#include "mir/geometry/size.h"23#include "mir/geometry/size.h"
24#include "mir_test_framework/headless_in_process_server.h"24#include "mir_test_framework/headless_in_process_server.h"
@@ -30,6 +30,7 @@
3030
31namespace mtf = mir_test_framework;31namespace mtf = mir_test_framework;
32namespace geom = mir::geometry;32namespace geom = mir::geometry;
33using namespace std::chrono_literals;
3334
34namespace35namespace
35{36{
@@ -192,127 +193,47 @@
192 mir_connection_release(connection);193 mir_connection_release(connection);
193}194}
194195
195TEST_F(RenderSurfaceTest, can_hand_out_presentation_chain)196//FIXME?: create/release for MirBufferStream would eliminate any sort of gotchas
196{197// with using that API.
197 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);198TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_content_is_in_use)
198
199 auto rs = mir_connection_create_render_surface_sync(
200 connection, logical_size.width.as_int(), logical_size.height.as_int());
201
202 auto pc = mir_render_surface_get_presentation_chain(rs);
203
204 ASSERT_THAT(pc, NotNull());
205 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
206
207 mir_render_surface_release(rs);
208 mir_connection_release(connection);
209}
210
211TEST_F(RenderSurfaceTest, hands_out_presentation_chain_only_once)
212{
213 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
214
215 auto rs = mir_connection_create_render_surface_sync(
216 connection, logical_size.width.as_int(), logical_size.height.as_int());
217
218 auto pc = mir_render_surface_get_presentation_chain(rs);
219
220 ASSERT_THAT(pc, NotNull());
221 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
222
223 auto pc2 = mir_render_surface_get_presentation_chain(rs);
224
225 EXPECT_THAT(pc2, Eq(nullptr));
226
227 mir_render_surface_release(rs);
228 mir_connection_release(connection);
229}
230
231TEST_F(RenderSurfaceTest, chain_can_be_constructed_after_surface_creation)
232{
233 int const width{800}, height{600};
234 MirPixelFormat const format{mir_pixel_format_abgr_8888};
235
236 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
237
238 auto rs = mir_connection_create_render_surface_sync(
239 connection, logical_size.width.as_int(), logical_size.height.as_int());
240 auto spec = mir_connection_create_spec_for_normal_surface(connection,
241 width, height,
242 format);
243 mir_surface_spec_add_render_surface(spec, rs, width, height, 0, 0);
244 auto surface = mir_surface_create_sync(spec);
245 mir_surface_spec_release(spec);
246 auto pc = mir_render_surface_get_presentation_chain(rs);
247
248 EXPECT_THAT(surface, IsValid());
249 EXPECT_THAT(mir_surface_get_buffer_stream(surface), Eq(nullptr));
250 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
251
252 mir_render_surface_release(rs);
253 mir_surface_release_sync(surface);
254 mir_connection_release(connection);
255}
256
257TEST_F(RenderSurfaceTest, dont_have_to_release_presentation_chain)
258{
259 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
260
261 auto rs = mir_connection_create_render_surface_sync(
262 connection, logical_size.width.as_int(), logical_size.height.as_int());
263 auto pc = mir_render_surface_get_presentation_chain(rs);
264
265 ASSERT_THAT(pc, NotNull());
266 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
267
268 mir_render_surface_release(rs);
269 mir_connection_release(connection);
270}
271
272TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_chain_handed_out)
273{199{
274 auto physical_size = logical_size;200 auto physical_size = logical_size;
275 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);201 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
276202
203 struct Buffer
204 {
205 std::mutex mutex;
206 std::condition_variable cv;
207 MirBuffer* buffer = nullptr;
208 } buffer;
209
210 mir_connection_allocate_buffer(
211 connection,
212 10, 10, mir_pixel_format_abgr_8888, mir_buffer_usage_software,
213 [](auto buffer, auto cxt) {
214 auto c = reinterpret_cast<Buffer*>(cxt);
215 std::unique_lock<decltype(c->mutex)> lk(c->mutex);
216 c->buffer = buffer;
217 c->cv.notify_all();
218 }, &buffer);
219
220 std::unique_lock<decltype(buffer.mutex)> lk(buffer.mutex);
221 EXPECT_TRUE(buffer.cv.wait_for(lk, 10s, [&] { return buffer.buffer; }));
222
277 auto rs = mir_connection_create_render_surface_sync(223 auto rs = mir_connection_create_render_surface_sync(
278 connection, logical_size.width.as_int(), logical_size.height.as_int());224 connection, logical_size.width.as_int(), logical_size.height.as_int());
279 auto pc = mir_render_surface_get_presentation_chain(rs);225 EXPECT_TRUE(mir_render_surface_is_valid(rs));
280226
281 ASSERT_THAT(pc, NotNull());227 mir_render_surface_submit_buffer(rs, buffer.buffer);
282 EXPECT_TRUE(mir_presentation_chain_is_valid(pc));
283228
284 auto bs = mir_render_surface_get_buffer_stream(229 auto bs = mir_render_surface_get_buffer_stream(
285 rs,230 rs,
286 physical_size.width.as_int(), physical_size.height.as_int(),231 physical_size.width.as_int(), physical_size.height.as_int(),
287 mir_pixel_format_abgr_8888,232 mir_pixel_format_abgr_8888,
288 mir_buffer_usage_hardware);233 mir_buffer_usage_hardware);
289
290 EXPECT_THAT(bs, Eq(nullptr));234 EXPECT_THAT(bs, Eq(nullptr));
291235
292 mir_render_surface_release(rs);236 mir_buffer_release(buffer.buffer);
293 mir_connection_release(connection);
294}
295
296TEST_F(RenderSurfaceTest, excepts_on_chain_request_if_stream_handed_out)
297{
298 auto physical_size = logical_size;
299 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
300
301 auto rs = mir_connection_create_render_surface_sync(
302 connection, logical_size.width.as_int(), logical_size.height.as_int());
303 auto bs = mir_render_surface_get_buffer_stream(
304 rs,
305 physical_size.width.as_int(), physical_size.height.as_int(),
306 mir_pixel_format_abgr_8888,
307 mir_buffer_usage_hardware);
308
309 ASSERT_THAT(bs, NotNull());
310 EXPECT_TRUE(mir_buffer_stream_is_valid(bs));
311
312 auto pc = mir_render_surface_get_presentation_chain(rs);
313
314 EXPECT_THAT(pc, Eq(nullptr));
315
316 mir_render_surface_release(rs);237 mir_render_surface_release(rs);
317 mir_connection_release(connection);238 mir_connection_release(connection);
318}239}
319240
=== modified file 'tests/include/mir/test/doubles/stub_host_connection.h'
--- tests/include/mir/test/doubles/stub_host_connection.h 2016-12-15 15:17:18 +0000
+++ tests/include/mir/test/doubles/stub_host_connection.h 2016-12-15 15:17:18 +0000
@@ -123,7 +123,6 @@
123 {123 {
124 MirRenderSurface* rs() const override { return nullptr; }124 MirRenderSurface* rs() const override { return nullptr; }
125 void submit_buffer(graphics::nested::NativeBuffer&) override {}125 void submit_buffer(graphics::nested::NativeBuffer&) override {}
126 MirPresentationChain* handle() override { return nullptr; }
127 void set_submission_mode(graphics::nested::SubmissionMode) override {}126 void set_submission_mode(graphics::nested::SubmissionMode) override {}
128 };127 };
129 return std::make_unique<NullHostChain>();128 return std::make_unique<NullHostChain>();
130129
=== modified file 'tests/unit-tests/client/test_connection_resource_map.cpp'
--- tests/unit-tests/client/test_connection_resource_map.cpp 2016-12-13 06:00:32 +0000
+++ tests/unit-tests/client/test_connection_resource_map.cpp 2016-12-15 15:17:18 +0000
@@ -18,7 +18,8 @@
1818
19#include "src/client/connection_surface_map.h"19#include "src/client/connection_surface_map.h"
20#include "src/client/mir_surface.h"20#include "src/client/mir_surface.h"
21#include "src/client/presentation_chain.h"21#include "src/client/buffer.h"
22#include "mir/mir_buffer.h"
22#include "src/client/render_surface.h"23#include "src/client/render_surface.h"
23#include "mir/test/doubles/mock_mir_buffer_stream.h"24#include "mir/test/doubles/mock_mir_buffer_stream.h"
24#include "mir/test/doubles/mock_protobuf_server.h"25#include "mir/test/doubles/mock_protobuf_server.h"
@@ -42,10 +43,8 @@
42 std::shared_ptr<mcl::Buffer> buffer {43 std::shared_ptr<mcl::Buffer> buffer {
43 std::make_shared<mcl::Buffer>(buffer_cb, nullptr, 0, nullptr, nullptr, mir_buffer_usage_software) };44 std::make_shared<mcl::Buffer>(buffer_cb, nullptr, 0, nullptr, nullptr, mir_buffer_usage_software) };
44 mtd::MockProtobufServer mock_server;45 mtd::MockProtobufServer mock_server;
45 std::shared_ptr<mcl::PresentationChain> chain{ std::make_shared<mcl::PresentationChain>(
46 nullptr, 0, mock_server, nullptr, nullptr) };
47 std::shared_ptr<MirRenderSurface> render_surface { std::make_shared<mcl::RenderSurface>(46 std::shared_ptr<MirRenderSurface> render_surface { std::make_shared<mcl::RenderSurface>(
48 nullptr, nullptr, nullptr, nullptr, mir::geometry::Size{0, 0}) };47 nullptr, mock_server, nullptr, nullptr, mf::BufferStreamId{11}, mir::geometry::Size{0, 0}) };
4948
50 mf::SurfaceId const surface_id{43};49 mf::SurfaceId const surface_id{43};
51 mf::BufferStreamId const stream_id{43};50 mf::BufferStreamId const stream_id{43};
@@ -79,17 +78,6 @@
79 map.erase(stream_id);78 map.erase(stream_id);
80}79}
8180
82TEST_F(ConnectionResourceMap, holds_chain_reference)
83{
84 using namespace testing;
85 mcl::ConnectionSurfaceMap map;
86 auto use_count = chain.use_count();
87 map.insert(stream_id, chain);
88 EXPECT_THAT(chain.use_count(), Gt(use_count));
89 map.erase(stream_id);
90 EXPECT_THAT(chain.use_count(), Eq(use_count));
91}
92
93TEST_F(ConnectionResourceMap, maps_buffers)81TEST_F(ConnectionResourceMap, maps_buffers)
94{82{
95 using namespace testing;83 using namespace testing;
9684
=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
--- tests/unit-tests/client/test_mir_connection.cpp 2016-12-15 15:17:18 +0000
+++ tests/unit-tests/client/test_mir_connection.cpp 2016-12-15 15:17:18 +0000
@@ -24,7 +24,6 @@
24#include "src/client/mir_render_surface.h"24#include "src/client/mir_render_surface.h"
25#include "src/client/buffer_factory.h"25#include "src/client/buffer_factory.h"
26#include "src/client/connection_surface_map.h"26#include "src/client/connection_surface_map.h"
27#include "src/client/presentation_chain.h"
2827
29#include "mir/client_platform.h"28#include "mir/client_platform.h"
30#include "mir/client_platform_factory.h"29#include "mir/client_platform_factory.h"
@@ -33,7 +32,6 @@
33#include "mir/dispatch/dispatchable.h"32#include "mir/dispatch/dispatchable.h"
34#include "mir/events/event_builders.h"33#include "mir/events/event_builders.h"
35#include "mir/geometry/rectangle.h"34#include "mir/geometry/rectangle.h"
36#include "mir_toolkit/mir_presentation_chain.h"
37#include "mir_toolkit/mir_render_surface.h"35#include "mir_toolkit/mir_render_surface.h"
3836
39#include "src/server/frontend/resource_cache.h" /* needed by test_server.h */37#include "src/server/frontend/resource_cache.h" /* needed by test_server.h */
4038
=== modified file 'tests/unit-tests/client/test_mir_render_surface.cpp'
--- tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-13 06:00:32 +0000
+++ tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-15 15:17:18 +0000
@@ -28,6 +28,8 @@
2828
29#include "mir/test/fake_shared.h"29#include "mir/test/fake_shared.h"
30#include "mir/test/doubles/stub_client_buffer_factory.h"30#include "mir/test/doubles/stub_client_buffer_factory.h"
31#include "mir/test/doubles/mock_protobuf_server.h"
32#include "mir/test/doubles/mock_mir_buffer.h"
31#include "mir_protobuf.pb.h"33#include "mir_protobuf.pb.h"
3234
33#include <sys/eventfd.h>35#include <sys/eventfd.h>
@@ -51,7 +53,6 @@
51 if (context)53 if (context)
52 *context = result;54 *context = result;
53}55}
54
55struct RenderSurfaceCallback56struct RenderSurfaceCallback
56{57{
57 static void created(MirRenderSurface* render_surface, void *client_context)58 static void created(MirRenderSurface* render_surface, void *client_context)
@@ -193,7 +194,11 @@
193 std::shared_ptr<testing::NiceMock<MockClientPlatform>> const mock_platform;194 std::shared_ptr<testing::NiceMock<MockClientPlatform>> const mock_platform;
194 std::shared_ptr<testing::NiceMock<MockRpcChannel>> const mock_channel;195 std::shared_ptr<testing::NiceMock<MockRpcChannel>> const mock_channel;
195 TestConnectionConfiguration conf;196 TestConnectionConfiguration conf;
197 mtd::MockProtobufServer mock_server;
196 std::shared_ptr<MirConnection> const connection;198 std::shared_ptr<MirConnection> const connection;
199 mir::frontend::BufferStreamId rpc_id { 33 };
200 int id = 4;
201 MirConnection* conn{ reinterpret_cast<MirConnection*>(&id) };
197};202};
198203
199TEST_F(MirRenderSurfaceTest, render_surface_can_be_created_and_released)204TEST_F(MirRenderSurfaceTest, render_surface_can_be_created_and_released)
@@ -249,29 +254,15 @@
249254
250TEST_F(MirRenderSurfaceTest, render_surface_returns_connection)255TEST_F(MirRenderSurfaceTest, render_surface_returns_connection)
251{256{
252 MirConnection* conn{ reinterpret_cast<MirConnection*>(0x12345678) };257 mcl::RenderSurface rs(conn, mock_server, nullptr, nullptr, rpc_id, {});
253
254 mcl::RenderSurface rs(
255 conn, nullptr, nullptr, nullptr, {});
256258
257 EXPECT_THAT(rs.connection(), Eq(conn));259 EXPECT_THAT(rs.connection(), Eq(conn));
258}260}
259261
260TEST_F(MirRenderSurfaceTest, render_surface_has_correct_id_before_content_creation)262TEST_F(MirRenderSurfaceTest, render_surface_has_correct_id_before_content_creation)
261{263{
262 MirConnection* conn{ reinterpret_cast<MirConnection*>(0x12345678) };264 mcl::RenderSurface rs(conn, mock_server, nullptr, nullptr, rpc_id, {});
263 auto id = 123;265 EXPECT_THAT(rs.stream_id(), Eq(rpc_id));
264
265 mp::BufferStream protobuf_bs;
266 mp::BufferStreamId bs_id;
267
268 bs_id.set_value(id);
269 *protobuf_bs.mutable_id() = bs_id;
270
271 mcl::RenderSurface rs(
272 conn, nullptr, nullptr, mt::fake_shared(protobuf_bs), {});
273
274 EXPECT_THAT(rs.stream_id().as_value(), Eq(id));
275}266}
276267
277TEST_F(MirRenderSurfaceTest, render_surface_can_create_buffer_stream)268TEST_F(MirRenderSurfaceTest, render_surface_can_create_buffer_stream)
@@ -287,8 +278,7 @@
287278
288 auto native_window = mock_platform->create_egl_native_window(nullptr);279 auto native_window = mock_platform->create_egl_native_window(nullptr);
289280
290 mcl::RenderSurface rs(281 mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
291 connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {});
292282
293 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,283 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
294 mir_buffer_usage_software);284 mir_buffer_usage_software);
@@ -296,34 +286,6 @@
296 EXPECT_THAT(bs, NotNull());286 EXPECT_THAT(bs, NotNull());
297}287}
298288
299TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_buffer_stream_more_than_once)
300{
301 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
302 auto id = 123;
303
304 mp::BufferStream protobuf_bs;
305 mp::BufferStreamId bs_id;
306
307 bs_id.set_value(id);
308 *protobuf_bs.mutable_id() = bs_id;
309
310 auto native_window = mock_platform->create_egl_native_window(nullptr);
311
312 mcl::RenderSurface rs(
313 connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
314
315 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));
316
317 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
318 mir_buffer_usage_hardware);
319
320 EXPECT_THROW(
321 { rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
322 mir_buffer_usage_hardware); },
323 std::logic_error);
324 EXPECT_THAT(bs, NotNull());
325}
326
327TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window)289TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window)
328{290{
329 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();291 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
@@ -337,8 +299,7 @@
337299
338 auto native_window = mock_platform->create_egl_native_window(nullptr);300 auto native_window = mock_platform->create_egl_native_window(nullptr);
339301
340 mcl::RenderSurface rs(302 mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
341 connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
342303
343 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));304 EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_));
344305
@@ -361,8 +322,7 @@
361322
362 auto native_window = mock_platform->create_egl_native_window(nullptr);323 auto native_window = mock_platform->create_egl_native_window(nullptr);
363324
364 mcl::RenderSurface rs(325 mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
365 connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
366326
367 EXPECT_CALL(*mock_platform, use_egl_native_window(_,_)).Times(0);327 EXPECT_CALL(*mock_platform, use_egl_native_window(_,_)).Times(0);
368328
@@ -391,111 +351,30 @@
391 EXPECT_THAT(callback.resulting_render_surface, Eq(render_surface));351 EXPECT_THAT(callback.resulting_render_surface, Eq(render_surface));
392352
393 auto rs = connection->connection_surface_map()->render_surface(callback.resulting_render_surface);353 auto rs = connection->connection_surface_map()->render_surface(callback.resulting_render_surface);
394354 EXPECT_THAT(rs->get_error_message(), StrEq("Error creating MirRenderSurface: no ID in response"));
395 EXPECT_THAT(rs->get_error_message(),
396 StrEq("Error processing buffer stream response during render "
397 "surface creation: no ID in response (disconnected?)"));
398 EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid()));355 EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid()));
399}356}
400357
401TEST_F(MirRenderSurfaceTest, render_surface_can_create_presentation_chain)358TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_submission)
402{359{
403 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();360 mtd::MockMirBuffer buffer;
404 auto id = 123;361 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
405362 auto native_window = mock_platform->create_egl_native_window(nullptr);
406 mp::BufferStream protobuf_bs;363 mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
407 mp::BufferStreamId bs_id;364 rs.submit_buffer(&buffer);
408365 EXPECT_THROW({
409 bs_id.set_value(id);366 rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
410 *protobuf_bs.mutable_id() = bs_id;367 }, std::logic_error);
411368}
412 auto native_window = mock_platform->create_egl_native_window(nullptr);369
413370TEST_F(MirRenderSurfaceTest, excepts_on_submission_after_creation_of_stream)
414 mcl::RenderSurface rs(371{
415 connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {});372 mtd::MockMirBuffer buffer;
416373 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
417 auto pc = rs.get_presentation_chain();374 auto native_window = mock_platform->create_egl_native_window(nullptr);
418375 mcl::RenderSurface rs(connection.get(), mock_server, native_window, mock_platform, rpc_id, {});
419 EXPECT_THAT(pc, NotNull());376 rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware);
420}377 EXPECT_THROW({
421378 rs.submit_buffer(&buffer);
422TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_presentation_chain_more_than_once)379 }, std::logic_error);
423{
424 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
425 auto id = 123;
426
427 mp::BufferStream protobuf_bs;
428 mp::BufferStreamId bs_id;
429
430 bs_id.set_value(id);
431 *protobuf_bs.mutable_id() = bs_id;
432
433 auto native_window = mock_platform->create_egl_native_window(nullptr);
434
435 mcl::RenderSurface rs(
436 connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {});
437
438 auto pc = rs.get_presentation_chain();
439 EXPECT_THAT(pc, NotNull());
440
441 EXPECT_THROW(
442 { rs.get_presentation_chain(); },
443 std::logic_error);
444}
445
446TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_chain_after_stream)
447{
448 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
449 auto id = 123;
450
451 mp::BufferStream protobuf_bs;
452 mp::BufferStreamId bs_id;
453
454 bs_id.set_value(id);
455 *protobuf_bs.mutable_id() = bs_id;
456
457 auto native_window = mock_platform->create_egl_native_window(nullptr);
458
459 mcl::RenderSurface rs(connection.get(),
460 native_window,
461 mock_platform,
462 mt::fake_shared(protobuf_bs),
463 {});
464
465 auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888,
466 mir_buffer_usage_hardware);
467
468 EXPECT_THAT(bs, NotNull());
469 EXPECT_THROW(
470 { rs.get_presentation_chain(); },
471 std::logic_error);
472}
473
474TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_chain)
475{
476 connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all();
477 auto id = 123;
478
479 mp::BufferStream protobuf_bs;
480 mp::BufferStreamId bs_id;
481
482 bs_id.set_value(id);
483 *protobuf_bs.mutable_id() = bs_id;
484
485 auto native_window = mock_platform->create_egl_native_window(nullptr);
486
487 mcl::RenderSurface rs(connection.get(),
488 native_window,
489 mock_platform,
490 mt::fake_shared(protobuf_bs),
491 {});
492
493 auto pc = rs.get_presentation_chain();
494
495 EXPECT_THAT(pc, NotNull());
496 EXPECT_THROW(
497 { rs.get_buffer_stream(2, 2,
498 mir_pixel_format_abgr_8888,
499 mir_buffer_usage_hardware); },
500 std::logic_error);
501}380}
502381
=== modified file 'tests/unit-tests/client/test_presentation_chain.cpp'
--- tests/unit-tests/client/test_presentation_chain.cpp 2016-07-18 07:38:38 +0000
+++ tests/unit-tests/client/test_presentation_chain.cpp 2016-12-15 15:17:18 +0000
@@ -20,7 +20,7 @@
20#include "mir/test/doubles/stub_client_buffer_factory.h"20#include "mir/test/doubles/stub_client_buffer_factory.h"
21#include "mir/test/doubles/mock_client_buffer.h"21#include "mir/test/doubles/mock_client_buffer.h"
22#include "mir/test/fake_shared.h"22#include "mir/test/fake_shared.h"
23#include "src/client/presentation_chain.h"23#include "src/client/render_surface.h"
24#include "src/client/buffer_factory.h"24#include "src/client/buffer_factory.h"
25#include "mir/client_buffer_factory.h"25#include "mir/client_buffer_factory.h"
2626
@@ -36,16 +36,16 @@
3636
37namespace37namespace
38{38{
39struct PresentationChain : Test39struct RenderSurface : Test
40{40{
41 PresentationChain()41 RenderSurface()
42 {42 {
43 ipc_buf.set_width(size.width.as_int());43 ipc_buf.set_width(size.width.as_int());
44 ipc_buf.set_height(size.height.as_int());44 ipc_buf.set_height(size.height.as_int());
45 ipc_buf.set_buffer_id(buffer_id);45 ipc_buf.set_buffer_id(buffer_id);
46 }46 }
4747
48 int rpc_id { 33 };48 mir::frontend::BufferStreamId rpc_id { 33 };
49 MirConnection* connection {reinterpret_cast<MirConnection*>(this)};49 MirConnection* connection {reinterpret_cast<MirConnection*>(this)};
50 geom::Size size {100, 200};50 geom::Size size {100, 200};
51 MirPixelFormat format = mir_pixel_format_abgr_8888;51 MirPixelFormat format = mir_pixel_format_abgr_8888;
@@ -71,53 +71,41 @@
7171
72}72}
7373
74TEST_F(PresentationChain, returns_associated_connection)74TEST_F(RenderSurface, returns_associated_connection)
75{75{
76 mcl::PresentationChain chain(76 mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
77 connection, rpc_id, mock_server,
78 std::make_shared<mtd::StubClientBufferFactory>(),
79 std::make_shared<mcl::BufferFactory>());
80 EXPECT_THAT(chain.connection(), Eq(connection));77 EXPECT_THAT(chain.connection(), Eq(connection));
81}78}
8279
83TEST_F(PresentationChain, returns_associated_rpc_id)80TEST_F(RenderSurface, returns_associated_stream_id)
84{81{
85 mcl::PresentationChain chain(82 mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
86 connection, rpc_id, mock_server,83 EXPECT_THAT(chain.stream_id(), Eq(rpc_id));
87 std::make_shared<mtd::StubClientBufferFactory>(),
88 std::make_shared<mcl::BufferFactory>());
89 EXPECT_THAT(chain.rpc_id(), Eq(rpc_id));
90}84}
9185
92TEST_F(PresentationChain, submits_buffer_when_asked)86TEST_F(RenderSurface, submits_buffer_when_asked)
93{87{
94 mp::BufferRequest request;88 mp::BufferRequest request;
95 request.mutable_id()->set_value(rpc_id);89 request.mutable_id()->set_value(rpc_id.as_value());
96 request.mutable_buffer()->set_buffer_id(buffer_id);90 request.mutable_buffer()->set_buffer_id(buffer_id);
9791
98 EXPECT_CALL(mock_server, submit_buffer(BufferRequestMatches(request),_,_))92 EXPECT_CALL(mock_server, submit_buffer(BufferRequestMatches(request),_,_))
99 .WillOnce(mtd::RunProtobufClosure());93 .WillOnce(mtd::RunProtobufClosure());
10094
101 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);95 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);
102 mcl::PresentationChain chain(96 mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
103 connection, rpc_id, mock_server,
104 std::make_shared<mtd::StubClientBufferFactory>(),
105 std::make_shared<mcl::BufferFactory>());
10697
107 buffer.received();98 buffer.received();
108 chain.submit_buffer(&buffer);99 chain.submit_buffer(&buffer);
109} 100}
110101
111TEST_F(PresentationChain, double_submission_throws)102TEST_F(RenderSurface, double_submission_throws)
112{103{
113 EXPECT_CALL(mock_server, submit_buffer(_,_,_))104 EXPECT_CALL(mock_server, submit_buffer(_,_,_))
114 .WillOnce(mtd::RunProtobufClosure());105 .WillOnce(mtd::RunProtobufClosure());
115106
116 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);107 mcl::Buffer buffer(buffer_callback, nullptr, buffer_id, client_buffer, nullptr, mir_buffer_usage_software);
117 mcl::PresentationChain chain(108 mcl::RenderSurface chain(connection, mock_server, nullptr, nullptr, rpc_id, {0, 0});
118 connection, rpc_id, mock_server,
119 std::make_shared<mtd::StubClientBufferFactory>(),
120 std::make_shared<mcl::BufferFactory>());
121109
122 buffer.received();110 buffer.received();
123 chain.submit_buffer(&buffer);111 chain.submit_buffer(&buffer);
124112
=== modified file 'tests/unit-tests/client/test_protobuf_rpc_channel.cpp'
--- tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2016-12-13 06:00:32 +0000
+++ tests/unit-tests/client/test_protobuf_rpc_channel.cpp 2016-12-15 15:17:18 +0000
@@ -65,7 +65,6 @@
65 void(std::function<void(MirBufferStream*)> const&));65 void(std::function<void(MirBufferStream*)> const&));
66 MOCK_CONST_METHOD1(buffer, std::shared_ptr<mcl::MirBuffer>(int));66 MOCK_CONST_METHOD1(buffer, std::shared_ptr<mcl::MirBuffer>(int));
67 MOCK_METHOD2(insert, void(int, std::shared_ptr<mcl::MirBuffer> const&));67 MOCK_METHOD2(insert, void(int, std::shared_ptr<mcl::MirBuffer> const&));
68 MOCK_METHOD2(insert, void(mir::frontend::BufferStreamId, std::shared_ptr<MirPresentationChain> const&));
69 MOCK_METHOD1(erase, void(int));68 MOCK_METHOD1(erase, void(int));
70}; 69};
71 70
@@ -83,9 +82,6 @@
83 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override82 void with_all_streams_do(std::function<void(MirBufferStream*)> const&) const override
84 {83 {
85 }84 }
86 void insert(mir::frontend::BufferStreamId, std::shared_ptr<MirPresentationChain> const&)
87 {
88 }
89 std::shared_ptr<mcl::MirBuffer> buffer(int) const override85 std::shared_ptr<mcl::MirBuffer> buffer(int) const override
90 {86 {
91 return nullptr;87 return nullptr;
9288
=== modified file 'tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp'
--- tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp 2016-12-15 15:17:18 +0000
+++ tests/unit-tests/platforms/nested/test_nested_display_buffer.cpp 2016-12-15 15:17:18 +0000
@@ -93,7 +93,6 @@
93struct MockNestedChain : mgn::HostChain93struct MockNestedChain : mgn::HostChain
94{94{
95 MOCK_METHOD1(submit_buffer, void(mgn::NativeBuffer&));95 MOCK_METHOD1(submit_buffer, void(mgn::NativeBuffer&));
96 MOCK_METHOD0(handle, MirPresentationChain*());
97 MOCK_METHOD1(set_submission_mode, void(mgn::SubmissionMode));96 MOCK_METHOD1(set_submission_mode, void(mgn::SubmissionMode));
98 MOCK_CONST_METHOD0(rs, MirRenderSurface*());97 MOCK_CONST_METHOD0(rs, MirRenderSurface*());
99};98};
@@ -317,8 +316,8 @@
317 EXPECT_CALL(nested_buffer, on_ownership_notification(_))316 EXPECT_CALL(nested_buffer, on_ownership_notification(_))
318 .Times(2);317 .Times(2);
319 EXPECT_CALL(*mock_chain, submit_buffer(Ref(nested_buffer)));318 EXPECT_CALL(*mock_chain, submit_buffer(Ref(nested_buffer)));
320 ON_CALL(*mock_chain, handle())319 ON_CALL(*mock_chain, rs())
321 .WillByDefault(Return(reinterpret_cast<MirPresentationChain*>(&fake_chain_handle)));320 .WillByDefault(Return(reinterpret_cast<MirRenderSurface*>(&fake_chain_handle)));
322 EXPECT_CALL(*mock_chain2, submit_buffer(Ref(nested_buffer)));321 EXPECT_CALL(*mock_chain2, submit_buffer(Ref(nested_buffer)));
323322
324 EXPECT_CALL(mock_host_connection, create_surface(_,_,_,_,_))323 EXPECT_CALL(mock_host_connection, create_surface(_,_,_,_,_))

Subscribers

People subscribed via source and target branches