Mir

Merge lp:~kdub/mir/fix-1563278 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 3458
Proposed branch: lp:~kdub/mir/fix-1563278
Merge into: lp:mir
Prerequisite: lp:~kdub/mir/require-streams-when-creating-surface
Diff against target: 1298 lines (+188/-200)
22 files modified
examples/render_surfaces.cpp (+1/-1)
include/server/mir/scene/surface_factory.h (+3/-1)
playground/mir_demo_client_prerendered_frames.c (+1/-6)
src/server/scene/application_session.cpp (+14/-2)
src/server/scene/basic_surface.cpp (+19/-5)
src/server/scene/basic_surface.h (+2/-2)
src/server/scene/surface_allocator.cpp (+3/-5)
src/server/scene/surface_allocator.h (+1/-1)
tests/acceptance-tests/throwback/test_presentation_chain.cpp (+1/-2)
tests/include/mir/test/doubles/mock_surface.h (+4/-2)
tests/include/mir/test/doubles/stub_surface_factory.h (+1/-1)
tests/integration-tests/surface_composition.cpp (+5/-4)
tests/integration-tests/test_error_reporting.cpp (+1/-1)
tests/integration-tests/test_session.cpp (+7/-6)
tests/integration-tests/test_surface_stack_with_compositor.cpp (+13/-9)
tests/unit-tests/scene/test_abstract_shell.cpp (+1/-2)
tests/unit-tests/scene/test_application_session.cpp (+15/-14)
tests/unit-tests/scene/test_basic_surface.cpp (+11/-36)
tests/unit-tests/scene/test_session_manager.cpp (+1/-1)
tests/unit-tests/scene/test_surface.cpp (+4/-9)
tests/unit-tests/scene/test_surface_impl.cpp (+5/-4)
tests/unit-tests/scene/test_surface_stack.cpp (+75/-86)
To merge this branch: bzr merge lp:~kdub/mir/fix-1563278
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Alan Griffiths Approve
Cemil Azizoglu (community) Approve
Review via email: mp+291647@code.launchpad.net

Commit message

fix LP: #1563278 by allowing Surfaces to be created with non-default streams.

This allows the user of MirPresentationChains to set up the MirSurface so that no MirBufferStream is created at MirSurface startup, or allows the user of mir_surface_spec_set_streams to set a non-default configuration at startup.

Description of the change

fix LP: #1563278 by allowing Surfaces to be created with non-default streams.

This allows the user of MirPresentationChains to set up the MirSurface so that no MirBufferStream is created at MirSurface startup, or allows the user of mir_surface_spec_set_streams to set a non-default configuration at startup.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

portending a suggestion to change std::list to std::vector... This reflects the existing set_streams() function that takes a std::list.

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

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

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

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Just nits:

 }
-
TEST_F(SurfaceStack, occludes_not_rendered_surface)

I'd like to keep that whitespace.

~~~~

+ stub_buffer_stream1 = std::make_shared<mtd::StubBufferStream>();
+ stub_buffer_stream2 = std::make_shared<mtd::StubBufferStream>();
+ stub_buffer_stream3 = std::make_shared<mtd::StubBufferStream>();
...
+ std::shared_ptr<mc::BufferStream> stub_buffer_stream1;
+ std::shared_ptr<mc::BufferStream> stub_buffer_stream2;
+ std::shared_ptr<mc::BufferStream> stub_buffer_stream3;

I think test fixtures are a great place for in-class initializers - half the lines used here and only one place to look.

~~~~

 }
-
//test associated with lp:1290306, 1293896, 1294048, 1294051, 1294053

I'd like to keep that whitespace.

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

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

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

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

unrelated, retriggering.

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

Looks good

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

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

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

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

19:23:52 [ RUN ] MirSurfaceVisibilityEvent.exposed_received_when_surface_raised_over_occluding_surface

Revision history for this message
Kevin DuBois (kdub) wrote :
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Probably a slow test environment - a generous 10s timeout and a test taking 30s to run!

18:51:00 11: [ RUN ] ApplicationNotRespondingDetection.failure_to_pong_is_noticed
18:51:00 11: [2016-04-13 18:50:59.936136] mirserver: Starting
18:51:00 11: [2016-04-13 18:51:00.526634] mirserver: Selected driver: dummy (version 0.22.0)
18:51:02 11: [2016-04-13 18:51:02.694384] mirserver: Using software cursor
18:51:03 11: [2016-04-13 18:51:03.829134] mirserver: Initial display configuration:
18:51:03 11: [2016-04-13 18:51:03.876013] mirserver: 1.1: VGA 0.0" 0x0mm
18:51:03 11: [2016-04-13 18:51:03.894852] mirserver: Current mode 1600x1600 60.00Hz
18:51:03 11: [2016-04-13 18:51:03.897768] mirserver: Preferred mode 1600x1600 60.00Hz
18:51:03 11: [2016-04-13 18:51:03.900158] mirserver: Logical position +0+0
18:51:05 11: [2016-04-13 18:51:05.590816] mirserver: Selected input driver: mir:stub-input (version: 0.22.0)
18:51:05 11: [2016-04-13 18:51:05.932306] mirserver: Mir version 0.22.0
18:51:26 11: /��BUILDDIR��/mir-0.22.0+xenial862bzr3452/tests/acceptance-tests/test_application_not_responding_detection.cpp:115: Failure
18:51:26 11: Value of: marked_as_unresponsive.wait_for(10s)
18:51:26 11: Actual: false
18:51:26 11: Expected: true
18:51:28 11: [2016-04-13 18:51:28.042141] mirserver: Stopping
18:51:30 11: [ FAILED ] ApplicationNotRespondingDetection.failure_to_pong_is_noticed (30224 ms)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Probably a slow test environment - a generous 10s timeout and a test taking
> 30s to run!

Logged as lp:1570327

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

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

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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2016-03-23 06:39:56 +0000
+++ examples/render_surfaces.cpp 2016-04-13 15:56:18 +0000
@@ -377,7 +377,7 @@
377377
378 auto const stream = buffer_stream_factory->create_buffer_stream(378 auto const stream = buffer_stream_factory->create_buffer_stream(
379 mf::BufferStreamId{}, std::make_shared<NullBufferSink>(), properties);379 mf::BufferStreamId{}, std::make_shared<NullBufferSink>(), properties);
380 auto const surface = surface_factory->create_surface(stream, params);380 auto const surface = surface_factory->create_surface({ ms::StreamInfo{ stream, {0, 0}, {} } }, params);
381 surface_stack->add_surface(surface, params.input_mode);381 surface_stack->add_surface(surface, params.input_mode);
382382
383 {383 {
384384
=== modified file 'include/server/mir/scene/surface_factory.h'
--- include/server/mir/scene/surface_factory.h 2015-06-17 05:20:42 +0000
+++ include/server/mir/scene/surface_factory.h 2016-04-13 15:56:18 +0000
@@ -21,6 +21,7 @@
2121
22#include "mir/scene/surface_creation_parameters.h"22#include "mir/scene/surface_creation_parameters.h"
23#include <memory>23#include <memory>
24#include <list>
2425
25namespace mir26namespace mir
26{27{
@@ -28,6 +29,7 @@
28namespace scene29namespace scene
29{30{
30class Surface;31class Surface;
32class StreamInfo;
3133
32class SurfaceFactory34class SurfaceFactory
33{35{
@@ -36,7 +38,7 @@
36 virtual ~SurfaceFactory() = default;38 virtual ~SurfaceFactory() = default;
3739
38 virtual std::shared_ptr<Surface> create_surface(40 virtual std::shared_ptr<Surface> create_surface(
39 std::shared_ptr<compositor::BufferStream> const&,41 std::list<scene::StreamInfo> const& streams,
40 SurfaceCreationParameters const& params) = 0;42 SurfaceCreationParameters const& params) = 0;
4143
42private:44private:
4345
=== modified file 'playground/mir_demo_client_prerendered_frames.c'
--- playground/mir_demo_client_prerendered_frames.c 2016-03-23 06:39:56 +0000
+++ playground/mir_demo_client_prerendered_frames.c 2016-04-13 15:56:18 +0000
@@ -159,14 +159,9 @@
159 }159 }
160160
161 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);161 MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format);
162 MirSurface* surface = mir_surface_create_sync(spec);
163 mir_surface_spec_release(spec);
164
165 //reassociate for advanced control
166 spec = mir_create_surface_spec(connection);
167 mir_surface_spec_add_presentation_chain(162 mir_surface_spec_add_presentation_chain(
168 spec, width, height, displacement_x, displacement_y, chain);163 spec, width, height, displacement_x, displacement_y, chain);
169 mir_surface_apply_spec(surface, spec);164 MirSurface* surface = mir_surface_create_sync(spec);
170 mir_surface_spec_release(spec);165 mir_surface_spec_release(spec);
171166
172 int num_prerendered_frames = 20;167 int num_prerendered_frames = 20;
173168
=== modified file 'src/server/scene/application_session.cpp'
--- src/server/scene/application_session.cpp 2016-04-12 14:10:00 +0000
+++ src/server/scene/application_session.cpp 2016-04-13 15:56:18 +0000
@@ -111,11 +111,23 @@
111 if (params.parent_id.is_set())111 if (params.parent_id.is_set())
112 params.parent = checked_find(the_params.parent_id.value())->second;112 params.parent = checked_find(the_params.parent_id.value())->second;
113113
114 auto buffer_stream = checked_find(params.content_id.value())->second;114 auto buffer_stream = checked_find(stream_id)->second;
115 if (params.size != buffer_stream->stream_size())115 if (params.size != buffer_stream->stream_size())
116 buffer_stream->resize(params.size);116 buffer_stream->resize(params.size);
117117
118 auto surface = surface_factory->create_surface(buffer_stream, params);118 std::list<StreamInfo> streams;
119 if (the_params.content_id.is_set())
120 {
121 streams.push_back({checked_find(the_params.content_id.value())->second, {0,0}, {}});
122 }
123 else
124 {
125 for (auto& stream : params.streams.value())
126 streams.push_back({checked_find(stream.stream_id)->second, stream.displacement, stream.size});
127 }
128
129 auto surface = surface_factory->create_surface(streams, params);
130
119 surface_stack->add_surface(surface, params.input_mode);131 surface_stack->add_surface(surface, params.input_mode);
120132
121 if (params.state.is_set())133 if (params.state.is_set())
122134
=== modified file 'src/server/scene/basic_surface.cpp'
--- src/server/scene/basic_surface.cpp 2016-04-04 18:19:17 +0000
+++ src/server/scene/basic_surface.cpp 2016-04-13 15:56:18 +0000
@@ -199,12 +199,26 @@
199 geom::Displacement hotspot;199 geom::Displacement hotspot;
200};200};
201201
202namespace
203{
204//TODO: the concept of default stream is going away very soon.
205std::shared_ptr<mc::BufferStream> default_stream(std::list<ms::StreamInfo> const& layers)
206{
207 //There's not a good reason, other than soon-to-be-deprecated api to disallow contentless surfaces
208 if (layers.empty())
209 BOOST_THROW_EXCEPTION(std::logic_error("Surface must have content"));
210 else
211 return layers.front().stream;
212}
213
214}
215
202ms::BasicSurface::BasicSurface(216ms::BasicSurface::BasicSurface(
203 std::string const& name,217 std::string const& name,
204 geometry::Rectangle rect,218 geometry::Rectangle rect,
205 std::weak_ptr<Surface> const& parent,219 std::weak_ptr<Surface> const& parent,
206 bool nonrectangular,220 bool nonrectangular,
207 std::shared_ptr<mc::BufferStream> const& buffer_stream,221 std::list<StreamInfo> const& layers,
208 std::shared_ptr<mi::InputChannel> const& input_channel,222 std::shared_ptr<mi::InputChannel> const& input_channel,
209 std::shared_ptr<input::InputSender> const& input_sender,223 std::shared_ptr<input::InputSender> const& input_sender,
210 std::shared_ptr<mg::CursorImage> const& cursor_image,224 std::shared_ptr<mg::CursorImage> const& cursor_image,
@@ -216,13 +230,13 @@
216 input_mode(mi::InputReceptionMode::normal),230 input_mode(mi::InputReceptionMode::normal),
217 nonrectangular(nonrectangular),231 nonrectangular(nonrectangular),
218 custom_input_rectangles(),232 custom_input_rectangles(),
219 surface_buffer_stream(buffer_stream),233 surface_buffer_stream(default_stream(layers)),
220 server_input_channel(input_channel),234 server_input_channel(input_channel),
221 input_sender(input_sender),235 input_sender(input_sender),
222 cursor_image_(cursor_image),236 cursor_image_(cursor_image),
223 report(report),237 report(report),
224 parent_(parent),238 parent_(parent),
225 layers({StreamInfo{buffer_stream, {0,0}, {}}}),239 layers(layers),
226 cursor_stream_adapter{std::make_unique<ms::CursorStreamImageAdapter>(*this)},240 cursor_stream_adapter{std::make_unique<ms::CursorStreamImageAdapter>(*this)},
227 input_validator([this](MirEvent const& ev) { this->input_sender->send_event(ev, server_input_channel); })241 input_validator([this](MirEvent const& ev) { this->input_sender->send_event(ev, server_input_channel); })
228{242{
@@ -233,12 +247,12 @@
233 std::string const& name,247 std::string const& name,
234 geometry::Rectangle rect,248 geometry::Rectangle rect,
235 bool nonrectangular,249 bool nonrectangular,
236 std::shared_ptr<mc::BufferStream> const& buffer_stream,250 std::list<StreamInfo> const& layers,
237 std::shared_ptr<mi::InputChannel> const& input_channel,251 std::shared_ptr<mi::InputChannel> const& input_channel,
238 std::shared_ptr<input::InputSender> const& input_sender,252 std::shared_ptr<input::InputSender> const& input_sender,
239 std::shared_ptr<mg::CursorImage> const& cursor_image,253 std::shared_ptr<mg::CursorImage> const& cursor_image,
240 std::shared_ptr<SceneReport> const& report) :254 std::shared_ptr<SceneReport> const& report) :
241 BasicSurface(name, rect, std::shared_ptr<Surface>{nullptr}, nonrectangular,buffer_stream,255 BasicSurface(name, rect, std::shared_ptr<Surface>{nullptr}, nonrectangular, layers,
242 input_channel, input_sender, cursor_image, report)256 input_channel, input_sender, cursor_image, report)
243{257{
244}258}
245259
=== modified file 'src/server/scene/basic_surface.h'
--- src/server/scene/basic_surface.h 2016-01-29 08:18:22 +0000
+++ src/server/scene/basic_surface.h 2016-04-13 15:56:18 +0000
@@ -65,7 +65,7 @@
65 std::string const& name,65 std::string const& name,
66 geometry::Rectangle rect,66 geometry::Rectangle rect,
67 bool nonrectangular,67 bool nonrectangular,
68 std::shared_ptr<compositor::BufferStream> const& buffer_stream,68 std::list<scene::StreamInfo> const& streams,
69 std::shared_ptr<input::InputChannel> const& input_channel,69 std::shared_ptr<input::InputChannel> const& input_channel,
70 std::shared_ptr<input::InputSender> const& sender,70 std::shared_ptr<input::InputSender> const& sender,
71 std::shared_ptr<graphics::CursorImage> const& cursor_image,71 std::shared_ptr<graphics::CursorImage> const& cursor_image,
@@ -76,7 +76,7 @@
76 geometry::Rectangle rect,76 geometry::Rectangle rect,
77 std::weak_ptr<Surface> const& parent,77 std::weak_ptr<Surface> const& parent,
78 bool nonrectangular,78 bool nonrectangular,
79 std::shared_ptr<compositor::BufferStream> const& buffer_stream,79 std::list<scene::StreamInfo> const& streams,
80 std::shared_ptr<input::InputChannel> const& input_channel,80 std::shared_ptr<input::InputChannel> const& input_channel,
81 std::shared_ptr<input::InputSender> const& sender,81 std::shared_ptr<input::InputSender> const& sender,
82 std::shared_ptr<graphics::CursorImage> const& cursor_image,82 std::shared_ptr<graphics::CursorImage> const& cursor_image,
8383
=== modified file 'src/server/scene/surface_allocator.cpp'
--- src/server/scene/surface_allocator.cpp 2015-06-17 05:20:42 +0000
+++ src/server/scene/surface_allocator.cpp 2016-04-13 15:56:18 +0000
@@ -48,19 +48,17 @@
48}48}
4949
50std::shared_ptr<ms::Surface> ms::SurfaceAllocator::create_surface(50std::shared_ptr<ms::Surface> ms::SurfaceAllocator::create_surface(
51 std::shared_ptr<compositor::BufferStream> const& buffer_stream,51 std::list<ms::StreamInfo> const& streams,
52 SurfaceCreationParameters const& params)52 SurfaceCreationParameters const& params)
53{53{
54 auto actual_size = geom::Rectangle{params.top_left, buffer_stream->stream_size()};
55
56 bool nonrectangular = has_alpha(params.pixel_format);54 bool nonrectangular = has_alpha(params.pixel_format);
57 auto input_channel = input_factory->make_input_channel();55 auto input_channel = input_factory->make_input_channel();
58 auto const surface = std::make_shared<BasicSurface>(56 auto const surface = std::make_shared<BasicSurface>(
59 params.name,57 params.name,
60 actual_size,58 geom::Rectangle{params.top_left, params.size},
61 params.parent,59 params.parent,
62 nonrectangular,60 nonrectangular,
63 buffer_stream,61 streams,
64 input_channel,62 input_channel,
65 input_sender,63 input_sender,
66 default_cursor_image,64 default_cursor_image,
6765
=== modified file 'src/server/scene/surface_allocator.h'
--- src/server/scene/surface_allocator.h 2015-06-17 05:20:42 +0000
+++ src/server/scene/surface_allocator.h 2016-04-13 15:56:18 +0000
@@ -47,7 +47,7 @@
47 std::shared_ptr<SceneReport> const& report);47 std::shared_ptr<SceneReport> const& report);
4848
49 std::shared_ptr<Surface> create_surface(49 std::shared_ptr<Surface> create_surface(
50 std::shared_ptr<compositor::BufferStream> const& buffer_stream,50 std::list<scene::StreamInfo> const& streams,
51 SurfaceCreationParameters const& params) override;51 SurfaceCreationParameters const& params) override;
5252
53private:53private:
5454
=== modified file 'tests/acceptance-tests/throwback/test_presentation_chain.cpp'
--- tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-03-23 06:39:56 +0000
+++ tests/acceptance-tests/throwback/test_presentation_chain.cpp 2016-04-13 15:56:18 +0000
@@ -268,8 +268,7 @@
268 EXPECT_THAT(region.pixel_format, Eq(pf));268 EXPECT_THAT(region.pixel_format, Eq(pf));
269}269}
270270
271//needs an ABI break to fix271TEST_F(PresentationChain, submission_will_eventually_call_callback)
272TEST_F(PresentationChain, DISABLED_submission_will_eventually_call_callback)
273{272{
274 SurfaceWithChainFromStart surface(connection, size, pf);273 SurfaceWithChainFromStart surface(connection, size, pf);
275274
276275
=== modified file 'tests/include/mir/test/doubles/mock_surface.h'
--- tests/include/mir/test/doubles/mock_surface.h 2016-01-29 08:18:22 +0000
+++ tests/include/mir/test/doubles/mock_surface.h 2016-04-13 15:56:18 +0000
@@ -43,14 +43,15 @@
43 {},43 {},
44 {{},{}},44 {{},{}},
45 true,45 true,
46 std::make_shared<testing::NiceMock<MockBufferStream>>(),46 { { std::make_shared<testing::NiceMock<MockBufferStream>>(), {0, 0}, {} } },
47 std::make_shared<StubInputChannel>(),47 std::make_shared<StubInputChannel>(),
48 {},48 {},
49 {},49 {},
50 mir::report::null_scene_report())50 mir::report::null_scene_report())
51 {51 {
52 ON_CALL(*this, primary_buffer_stream())52 ON_CALL(*this, primary_buffer_stream())
53 .WillByDefault(testing::Return(std::make_shared<testing::NiceMock<MockBufferStream>>()));53 .WillByDefault(testing::Invoke([this]
54 { return scene::BasicSurface::primary_buffer_stream(); }));
54 }55 }
5556
56 ~MockSurface() noexcept {}57 ~MockSurface() noexcept {}
@@ -76,6 +77,7 @@
76 MOCK_CONST_METHOD0(primary_buffer_stream, std::shared_ptr<frontend::BufferStream>());77 MOCK_CONST_METHOD0(primary_buffer_stream, std::shared_ptr<frontend::BufferStream>());
77 MOCK_METHOD1(set_streams, void(std::list<scene::StreamInfo> const&));78 MOCK_METHOD1(set_streams, void(std::list<scene::StreamInfo> const&));
7879
80 std::shared_ptr<MockBufferStream> const stream;
79};81};
8082
81}83}
8284
=== modified file 'tests/include/mir/test/doubles/stub_surface_factory.h'
--- tests/include/mir/test/doubles/stub_surface_factory.h 2016-01-29 08:18:22 +0000
+++ tests/include/mir/test/doubles/stub_surface_factory.h 2016-04-13 15:56:18 +0000
@@ -34,7 +34,7 @@
34{34{
35public:35public:
36 std::shared_ptr<scene::Surface> create_surface(36 std::shared_ptr<scene::Surface> create_surface(
37 std::shared_ptr<compositor::BufferStream> const&,37 std::list<scene::StreamInfo> const&,
38 scene::SurfaceCreationParameters const& params) override38 scene::SurfaceCreationParameters const& params) override
39 {39 {
40 using namespace testing;40 using namespace testing;
4141
=== modified file 'tests/integration-tests/surface_composition.cpp'
--- tests/integration-tests/surface_composition.cpp 2015-06-26 08:00:59 +0000
+++ tests/integration-tests/surface_composition.cpp 2016-04-13 15:56:18 +0000
@@ -42,14 +42,14 @@
42{42{
43struct SurfaceComposition : Test43struct SurfaceComposition : Test
44{44{
45 auto create_surface() const45 auto create_surface(std::shared_ptr<mc::BufferStream> const& stream) const
46 -> std::shared_ptr<ms::Surface>46 -> std::shared_ptr<ms::Surface>
47 {47 {
48 return std::make_shared<ms::BasicSurface>(48 return std::make_shared<ms::BasicSurface>(
49 std::string("SurfaceComposition"),49 std::string("SurfaceComposition"),
50 geom::Rectangle{{},{}},50 geom::Rectangle{{},{}},
51 false,51 false,
52 create_buffer_stream(),52 std::list<ms::StreamInfo> { { stream, {0,0}, {} } },
53 create_input_channel(),53 create_input_channel(),
54 create_input_sender(),54 create_input_sender(),
55 create_cursor_image(),55 create_cursor_image(),
@@ -98,7 +98,8 @@
98// Presumptive cause of lp:137632498// Presumptive cause of lp:1376324
99TEST_F(SurfaceComposition, does_not_send_client_buffers_to_dead_surfaces)99TEST_F(SurfaceComposition, does_not_send_client_buffers_to_dead_surfaces)
100{100{
101 auto surface = create_surface();101 auto stream = create_buffer_stream();
102 auto surface = create_surface(stream);
102103
103 mg::Buffer* old_buffer{nullptr};104 mg::Buffer* old_buffer{nullptr};
104105
@@ -117,7 +118,7 @@
117 while (called_back)118 while (called_back)
118 {119 {
119 called_back = false;120 called_back = false;
120 surface->primary_buffer_stream()->swap_buffers(old_buffer, callback);121 stream->swap_buffers(old_buffer, callback);
121 }122 }
122123
123 auto const renderables = surface->generate_renderables(this);124 auto const renderables = surface->generate_renderables(this);
124125
=== modified file 'tests/integration-tests/test_error_reporting.cpp'
--- tests/integration-tests/test_error_reporting.cpp 2016-01-29 08:18:22 +0000
+++ tests/integration-tests/test_error_reporting.cpp 2016-04-13 15:56:18 +0000
@@ -113,7 +113,7 @@
113 {113 {
114 std::shared_ptr<mir::scene::Surface>114 std::shared_ptr<mir::scene::Surface>
115 create_surface(115 create_surface(
116 std::shared_ptr<mir::compositor::BufferStream> const&,116 std::list<mir::scene::StreamInfo> const&,
117 mir::scene::SurfaceCreationParameters const&) override117 mir::scene::SurfaceCreationParameters const&) override
118 {118 {
119 throw std::runtime_error{test_exception_text};119 throw std::runtime_error{test_exception_text};
120120
=== modified file 'tests/integration-tests/test_session.cpp'
--- tests/integration-tests/test_session.cpp 2016-03-29 17:29:46 +0000
+++ tests/integration-tests/test_session.cpp 2016-04-13 15:56:18 +0000
@@ -68,13 +68,13 @@
68 }68 }
69};69};
7070
71void swap_buffers_blocking(mf::Surface& surf, mg::Buffer*& buffer)71void swap_buffers_blocking(mf::BufferStream& stream, mg::Buffer*& buffer)
72{72{
73 std::mutex mutex;73 std::mutex mutex;
74 std::condition_variable cv;74 std::condition_variable cv;
75 bool done = false;75 bool done = false;
7676
77 surf.primary_buffer_stream()->swap_buffers(buffer,77 stream.swap_buffers(buffer,
78 [&](mg::Buffer* new_buffer)78 [&](mg::Buffer* new_buffer)
79 {79 {
80 std::unique_lock<decltype(mutex)> lock(mutex);80 std::unique_lock<decltype(mutex)> lock(mutex);
@@ -128,8 +128,9 @@
128 };128 };
129129
130 mg::BufferProperties properties(geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::software);130 mg::BufferProperties properties(geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::software);
131 auto stream_id = session.create_buffer_stream(properties);
131 session.create_surface(132 session.create_surface(
132 ms::a_surface().with_buffer_stream(session.create_buffer_stream(properties)),133 ms::a_surface().with_buffer_stream(stream_id),
133 std::make_shared<mtd::NullEventSink>());134 std::make_shared<mtd::NullEventSink>());
134135
135 auto compositor = conf.the_compositor();136 auto compositor = conf.the_compositor();
@@ -138,13 +139,13 @@
138 session.default_surface()->configure(mir_surface_attrib_swapinterval, 0);139 session.default_surface()->configure(mir_surface_attrib_swapinterval, 0);
139140
140 std::thread client_thread{141 std::thread client_thread{
141 [&session]142 [&session, stream_id]
142 {143 {
143 mg::Buffer* buffer{nullptr};144 mg::Buffer* buffer{nullptr};
144 for (int i = 0; i < 500; ++i)145 for (int i = 0; i < 500; ++i)
145 {146 {
146 auto surface = session.default_surface();147 auto stream = session.get_buffer_stream(stream_id);
147 swap_buffers_blocking(*surface, buffer);148 swap_buffers_blocking(*stream, buffer);
148 std::this_thread::sleep_for(std::chrono::microseconds{50});149 std::this_thread::sleep_for(std::chrono::microseconds{50});
149 }150 }
150 }};151 }};
151152
=== modified file 'tests/integration-tests/test_surface_stack_with_compositor.cpp'
--- tests/integration-tests/test_surface_stack_with_compositor.cpp 2016-01-29 08:18:22 +0000
+++ tests/integration-tests/test_surface_stack_with_compositor.cpp 2016-04-13 15:56:18 +0000
@@ -122,11 +122,13 @@
122 SurfaceStackCompositor() :122 SurfaceStackCompositor() :
123 timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)},123 timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)},
124 mock_buffer_stream(std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>()),124 mock_buffer_stream(std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>()),
125 stream(std::make_shared<mc::BufferStreamSurfaces>(mock_buffer_stream)),
126 streams({ { stream, {0,0}, {} } }),
125 stub_surface{std::make_shared<ms::BasicSurface>(127 stub_surface{std::make_shared<ms::BasicSurface>(
126 std::string("stub"),128 std::string("stub"),
127 geom::Rectangle{{0,0},{1,1}},129 geom::Rectangle{{0,0},{1,1}},
128 false,130 false,
129 std::make_shared<mc::BufferStreamSurfaces>(mock_buffer_stream),131 streams,
130 std::shared_ptr<mir::input::InputChannel>(),132 std::shared_ptr<mir::input::InputChannel>(),
131 std::shared_ptr<mtd::StubInputSender>(),133 std::shared_ptr<mtd::StubInputSender>(),
132 std::shared_ptr<mg::CursorImage>(),134 std::shared_ptr<mg::CursorImage>(),
@@ -142,6 +144,8 @@
142 StubRendererFactory renderer_factory;144 StubRendererFactory renderer_factory;
143 std::chrono::system_clock::time_point timeout;145 std::chrono::system_clock::time_point timeout;
144 std::shared_ptr<mtd::MockBufferBundle> mock_buffer_stream;146 std::shared_ptr<mtd::MockBufferBundle> mock_buffer_stream;
147 std::shared_ptr<mc::BufferStream> stream;
148 std::list<ms::StreamInfo> const streams;
145 std::shared_ptr<ms::BasicSurface> stub_surface;149 std::shared_ptr<ms::BasicSurface> stub_surface;
146 ms::SurfaceCreationParameters default_params;150 ms::SurfaceCreationParameters default_params;
147 mtd::StubBuffer stubbuf{geom::Size{1,1}};151 mtd::StubBuffer stubbuf{geom::Size{1,1}};
@@ -197,7 +201,7 @@
197 mt_compositor.start();201 mt_compositor.start();
198202
199 stack.add_surface(stub_surface, default_params.input_mode);203 stack.add_surface(stub_surface, default_params.input_mode);
200 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});204 stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
201205
202 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));206 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));
203 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));207 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));
@@ -219,7 +223,7 @@
219 mt_compositor.start();223 mt_compositor.start();
220224
221 stack.add_surface(stub_surface, default_params.input_mode);225 stack.add_surface(stub_surface, default_params.input_mode);
222 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});226 streams.front().stream->swap_buffers(&stubbuf, [](auto){});
223227
224 EXPECT_TRUE(stub_primary_db.has_posted_at_least(5, timeout));228 EXPECT_TRUE(stub_primary_db.has_posted_at_least(5, timeout));
225 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(5, timeout));229 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(5, timeout));
@@ -242,7 +246,7 @@
242 mt_compositor.start();246 mt_compositor.start();
243247
244 stack.add_surface(stub_surface, default_params.input_mode);248 stack.add_surface(stub_surface, default_params.input_mode);
245 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});249 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
246250
247 EXPECT_TRUE(stub_primary_db.has_posted_at_least(5, timeout));251 EXPECT_TRUE(stub_primary_db.has_posted_at_least(5, timeout));
248 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(5, timeout));252 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(5, timeout));
@@ -263,7 +267,7 @@
263 mt_compositor.start();267 mt_compositor.start();
264268
265 stack.add_surface(stub_surface, default_params.input_mode);269 stack.add_surface(stub_surface, default_params.input_mode);
266 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});270 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
267271
268 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));272 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));
269 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));273 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));
@@ -276,7 +280,7 @@
276280
277TEST_F(SurfaceStackCompositor, moving_a_surface_triggers_composition)281TEST_F(SurfaceStackCompositor, moving_a_surface_triggers_composition)
278{282{
279 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});283 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
280 stack.add_surface(stub_surface, default_params.input_mode);284 stack.add_surface(stub_surface, default_params.input_mode);
281285
282 mc::MultiThreadedCompositor mt_compositor(286 mc::MultiThreadedCompositor mt_compositor(
@@ -295,7 +299,7 @@
295299
296TEST_F(SurfaceStackCompositor, removing_a_surface_triggers_composition)300TEST_F(SurfaceStackCompositor, removing_a_surface_triggers_composition)
297{301{
298 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});302 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
299 stack.add_surface(stub_surface, default_params.input_mode);303 stack.add_surface(stub_surface, default_params.input_mode);
300304
301 mc::MultiThreadedCompositor mt_compositor(305 mc::MultiThreadedCompositor mt_compositor(
@@ -318,7 +322,7 @@
318 ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_))322 ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_))
319 .WillByDefault(testing::Return(1));323 .WillByDefault(testing::Return(1));
320 stack.add_surface(stub_surface, default_params.input_mode);324 stack.add_surface(stub_surface, default_params.input_mode);
321 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});325 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
322326
323 mc::MultiThreadedCompositor mt_compositor(327 mc::MultiThreadedCompositor mt_compositor(
324 mt::fake_shared(stub_display),328 mt::fake_shared(stub_display),
@@ -328,7 +332,7 @@
328 null_comp_report, default_delay, false);332 null_comp_report, default_delay, false);
329333
330 mt_compositor.start();334 mt_compositor.start();
331 stub_surface->primary_buffer_stream()->swap_buffers(&stubbuf, [](mg::Buffer*){});335 streams.front().stream->swap_buffers(&stubbuf, [](mg::Buffer*){});
332336
333 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));337 EXPECT_TRUE(stub_primary_db.has_posted_at_least(1, timeout));
334 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));338 EXPECT_TRUE(stub_secondary_db.has_posted_at_least(1, timeout));
335339
=== modified file 'tests/unit-tests/scene/test_abstract_shell.cpp'
--- tests/unit-tests/scene/test_abstract_shell.cpp 2016-03-29 19:07:35 +0000
+++ tests/unit-tests/scene/test_abstract_shell.cpp 2016-04-13 15:56:18 +0000
@@ -95,8 +95,7 @@
95struct MockSurfaceFactory : public ms::SurfaceFactory95struct MockSurfaceFactory : public ms::SurfaceFactory
96{96{
97 MOCK_METHOD2(create_surface, std::shared_ptr<ms::Surface>(97 MOCK_METHOD2(create_surface, std::shared_ptr<ms::Surface>(
98 std::shared_ptr<mir::compositor::BufferStream> const&,98 std::list<ms::StreamInfo> const&, ms::SurfaceCreationParameters const&));
99 ms::SurfaceCreationParameters const&));
100};99};
101100
102using NiceMockWindowManager = NiceMock<mtd::MockWindowManager>;101using NiceMockWindowManager = NiceMock<mtd::MockWindowManager>;
103102
=== modified file 'tests/unit-tests/scene/test_application_session.cpp'
--- tests/unit-tests/scene/test_application_session.cpp 2016-04-12 14:10:00 +0000
+++ tests/unit-tests/scene/test_application_session.cpp 2016-04-13 15:56:18 +0000
@@ -229,7 +229,7 @@
229struct MockSurfaceFactory : ms::SurfaceFactory229struct MockSurfaceFactory : ms::SurfaceFactory
230{230{
231 MOCK_METHOD2(create_surface, std::shared_ptr<ms::Surface>(231 MOCK_METHOD2(create_surface, std::shared_ptr<ms::Surface>(
232 std::shared_ptr<mc::BufferStream> const&, ms::SurfaceCreationParameters const& params));232 std::list<ms::StreamInfo> const&, ms::SurfaceCreationParameters const& params));
233};233};
234}234}
235235
@@ -653,6 +653,15 @@
653 session->destroy_buffer_stream(id);653 session->destroy_buffer_stream(id);
654}654}
655655
656MATCHER_P(HasSingleStream, value, "")
657{
658 using namespace testing;
659 EXPECT_THAT(arg.size(), Eq(1));
660 if (arg.size() < 1 ) return false;
661 EXPECT_THAT(arg.front().stream.get(), Eq(value.get()));
662 return !(::testing::Test::HasFailure());
663}
664
656TEST_F(ApplicationSession, surface_uses_prexisting_buffer_stream_if_set)665TEST_F(ApplicationSession, surface_uses_prexisting_buffer_stream_if_set)
657{666{
658 using namespace testing;667 using namespace testing;
@@ -669,25 +678,17 @@
669 mt::fake_shared(mock_surface_factory));678 mt::fake_shared(mock_surface_factory));
670679
671 auto id = session->create_buffer_stream(properties);680 auto id = session->create_buffer_stream(properties);
681 auto stream = session->get_buffer_stream(id);
672682
673 EXPECT_CALL(mock_surface_factory, create_surface(Eq(session->get_buffer_stream(id)),_))683 EXPECT_CALL(mock_surface_factory, create_surface(HasSingleStream(stream),_))
674 .WillOnce(Invoke([&](auto bs, auto)684 .WillOnce(Return(make_mock_surface()));
675 {
676 auto surface = make_mock_surface();
677 ON_CALL(*surface, primary_buffer_stream())
678 .WillByDefault(Return(bs));
679 return surface;
680 }));
681685
682 ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{}686 ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{}
683 .of_name("Aardavks")687 .of_name("Aardavks")
684 .of_type(mir_surface_type_normal)688 .of_type(mir_surface_type_normal)
685 .with_buffer_stream(id);689 .with_buffer_stream(id);
686690
687 auto surface_id = session->create_surface(params, event_sink);691 session->create_surface(params, event_sink);
688 auto surface = session->get_surface(surface_id);
689
690 EXPECT_THAT(surface->primary_buffer_stream(), Eq(session->get_buffer_stream(id)));
691}692}
692693
693namespace694namespace
@@ -770,7 +771,7 @@
770{771{
771public:772public:
772 std::shared_ptr<ms::Surface> create_surface(773 std::shared_ptr<ms::Surface> create_surface(
773 std::shared_ptr<mir::compositor::BufferStream> const&,774 std::list<ms::StreamInfo> const&,
774 mir::scene::SurfaceCreationParameters const& params) override775 mir::scene::SurfaceCreationParameters const& params) override
775 {776 {
776 using namespace testing;777 using namespace testing;
777778
=== modified file 'tests/unit-tests/scene/test_basic_surface.cpp'
--- tests/unit-tests/scene/test_basic_surface.cpp 2016-03-23 06:39:56 +0000
+++ tests/unit-tests/scene/test_basic_surface.cpp 2016-04-13 15:56:18 +0000
@@ -72,17 +72,6 @@
72 MOCK_METHOD0(cursor_image_removed, void());72 MOCK_METHOD0(cursor_image_removed, void());
73};73};
7474
75void post_a_frame(ms::BasicSurface& surface)
76{
77 /*
78 * Make sure there's a frame ready. Otherwise visible()==false and the
79 * input_area will never report it containing anything for all the tests
80 * that use it.
81 */
82 mtd::StubBuffer buffer;
83 surface.primary_buffer_stream()->swap_buffers(&buffer, [&](mir::graphics::Buffer*){});
84}
85
86struct BasicSurfaceTest : public testing::Test75struct BasicSurfaceTest : public testing::Test
87{76{
88 std::string const name{"aa"};77 std::string const name{"aa"};
@@ -99,21 +88,17 @@
99 std::make_shared<ms::LegacySurfaceChangeNotification>(mock_change_cb, [this](int){mock_change_cb();});88 std::make_shared<ms::LegacySurfaceChangeNotification>(mock_change_cb, [this](int){mock_change_cb();});
100 std::shared_ptr<mi::InputSender> const stub_input_sender = std::make_shared<mtd::StubInputSender>();89 std::shared_ptr<mi::InputSender> const stub_input_sender = std::make_shared<mtd::StubInputSender>();
101 testing::NiceMock<mtd::MockInputSender> mock_sender;90 testing::NiceMock<mtd::MockInputSender> mock_sender;
91 std::list<ms::StreamInfo> streams { { mock_buffer_stream, {}, {} } };
10292
103 ms::BasicSurface surface{93 ms::BasicSurface surface{
104 name,94 name,
105 rect,95 rect,
106 false,96 false,
107 mock_buffer_stream,97 streams,
108 std::shared_ptr<mi::InputChannel>(),98 std::shared_ptr<mi::InputChannel>(),
109 stub_input_sender,99 stub_input_sender,
110 std::shared_ptr<mg::CursorImage>(),100 std::shared_ptr<mg::CursorImage>(),
111 report};101 report};
112
113 BasicSurfaceTest()
114 {
115 post_a_frame(surface);
116 }
117};102};
118103
119}104}
@@ -127,11 +112,6 @@
127 EXPECT_FALSE(renderable->shaped());112 EXPECT_FALSE(renderable->shaped());
128}113}
129114
130TEST_F(BasicSurfaceTest, primary_buffer_stream)
131{
132 EXPECT_THAT(surface.primary_buffer_stream(), Eq(mock_buffer_stream));
133}
134
135TEST_F(BasicSurfaceTest, buffer_stream_ids_always_unique)115TEST_F(BasicSurfaceTest, buffer_stream_ids_always_unique)
136{116{
137 int const n = 10;117 int const n = 10;
@@ -141,7 +121,9 @@
141 for (auto& surface : surfaces)121 for (auto& surface : surfaces)
142 {122 {
143 surface = std::make_unique<ms::BasicSurface>(123 surface = std::make_unique<ms::BasicSurface>(
144 name, rect, false, std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(),124 name, rect, false,
125 std::list<ms::StreamInfo> {
126 { std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(), {}, {} } },
145 std::shared_ptr<mi::InputChannel>(), stub_input_sender,127 std::shared_ptr<mi::InputChannel>(), stub_input_sender,
146 std::shared_ptr<mg::CursorImage>(), report);128 std::shared_ptr<mg::CursorImage>(), report);
147 for (auto& renderable : surface->generate_renderables(this))129 for (auto& renderable : surface->generate_renderables(this))
@@ -160,7 +142,7 @@
160 for (auto& surface : surfaces)142 for (auto& surface : surfaces)
161 {143 {
162 surface = std::make_unique<ms::BasicSurface>(144 surface = std::make_unique<ms::BasicSurface>(
163 name, rect, false, mock_buffer_stream,145 name, rect, false, streams,
164 std::shared_ptr<mi::InputChannel>(), stub_input_sender,146 std::shared_ptr<mi::InputChannel>(), stub_input_sender,
165 std::shared_ptr<mg::CursorImage>(), report);147 std::shared_ptr<mg::CursorImage>(), report);
166148
@@ -175,7 +157,6 @@
175 .Times(1);157 .Times(1);
176158
177 surface.add_observer(observer);159 surface.add_observer(observer);
178 post_a_frame(surface);
179160
180 EXPECT_EQ(rect.top_left, surface.top_left());161 EXPECT_EQ(rect.top_left, surface.top_left());
181162
@@ -192,7 +173,6 @@
192 .Times(1);173 .Times(1);
193174
194 surface.add_observer(observer);175 surface.add_observer(observer);
195 post_a_frame(surface);
196176
197 EXPECT_EQ(rect.size, surface.size());177 EXPECT_EQ(rect.size, surface.size());
198 EXPECT_NE(new_size, surface.size());178 EXPECT_NE(new_size, surface.size());
@@ -233,7 +213,6 @@
233 .Times(1);213 .Times(1);
234214
235 surface.add_observer(observer);215 surface.add_observer(observer);
236 post_a_frame(surface);
237216
238 auto renderables = surface.generate_renderables(compositor_id);217 auto renderables = surface.generate_renderables(compositor_id);
239 ASSERT_THAT(renderables.size(), testing::Eq(1));218 ASSERT_THAT(renderables.size(), testing::Eq(1));
@@ -258,7 +237,6 @@
258 .Times(1);237 .Times(1);
259238
260 surface.add_observer(observer);239 surface.add_observer(observer);
261 post_a_frame(surface);
262240
263 float alpha = 0.5f;241 float alpha = 0.5f;
264 surface.set_alpha(0.5f);242 surface.set_alpha(0.5f);
@@ -288,7 +266,7 @@
288 name,266 name,
289 rect,267 rect,
290 false,268 false,
291 mock_buffer_stream,269 streams,
292 std::shared_ptr<mi::InputChannel>(),270 std::shared_ptr<mi::InputChannel>(),
293 stub_input_sender,271 stub_input_sender,
294 std::shared_ptr<mg::CursorImage>(),272 std::shared_ptr<mg::CursorImage>(),
@@ -315,7 +293,6 @@
315 .Times(1);293 .Times(1);
316294
317 surface.add_observer(observer);295 surface.add_observer(observer);
318 post_a_frame(surface);
319296
320 surface.set_hidden(true);297 surface.set_hidden(true);
321}298}
@@ -329,14 +306,13 @@
329 name,306 name,
330 geom::Rectangle{pt, one_by_one},307 geom::Rectangle{pt, one_by_one},
331 false,308 false,
332 mock_buffer_stream,309 streams,
333 std::shared_ptr<mi::InputChannel>(),310 std::shared_ptr<mi::InputChannel>(),
334 stub_input_sender,311 stub_input_sender,
335 std::shared_ptr<mg::CursorImage>(),312 std::shared_ptr<mg::CursorImage>(),
336 report};313 report};
337314
338 surface.add_observer(observer);315 surface.add_observer(observer);
339 post_a_frame(surface);
340316
341 std::vector<geom::Point> contained_pt317 std::vector<geom::Point> contained_pt
342 {318 {
@@ -371,7 +347,7 @@
371 name,347 name,
372 geom::Rectangle{{0,0}, {100,100}},348 geom::Rectangle{{0,0}, {100,100}},
373 false,349 false,
374 mock_buffer_stream,350 streams,
375 std::shared_ptr<mi::InputChannel>(),351 std::shared_ptr<mi::InputChannel>(),
376 stub_input_sender,352 stub_input_sender,
377 std::shared_ptr<mg::CursorImage>(),353 std::shared_ptr<mg::CursorImage>(),
@@ -511,7 +487,7 @@
511 geom::Rectangle{{0,0}, {100,100}},487 geom::Rectangle{{0,0}, {100,100}},
512 parent,488 parent,
513 false,489 false,
514 mock_buffer_stream,490 streams,
515 std::shared_ptr<mi::InputChannel>(),491 std::shared_ptr<mi::InputChannel>(),
516 stub_input_sender,492 stub_input_sender,
517 std::shared_ptr<mg::CursorImage>(),493 std::shared_ptr<mg::CursorImage>(),
@@ -698,7 +674,7 @@
698 name,674 name,
699 rect,675 rect,
700 false,676 false,
701 mock_buffer_stream,677 streams,
702 std::shared_ptr<mi::InputChannel>(),678 std::shared_ptr<mi::InputChannel>(),
703 mt::fake_shared(mock_sender),679 mt::fake_shared(mock_sender),
704 nullptr,680 nullptr,
@@ -1130,7 +1106,6 @@
11301106
1131 EXPECT_THAT(observer->exposes(), Eq(0));1107 EXPECT_THAT(observer->exposes(), Eq(0));
1132 EXPECT_THAT(observer->hides(), Eq(0));1108 EXPECT_THAT(observer->hides(), Eq(0));
1133 post_a_frame(surface);
1134 surface.configure(mir_surface_attrib_visibility, mir_surface_visibility_exposed);1109 surface.configure(mir_surface_attrib_visibility, mir_surface_visibility_exposed);
11351110
1136 EXPECT_THAT(observer->exposes(), Eq(1));1111 EXPECT_THAT(observer->exposes(), Eq(1));
11371112
=== modified file 'tests/unit-tests/scene/test_session_manager.cpp'
--- tests/unit-tests/scene/test_session_manager.cpp 2016-03-29 19:17:37 +0000
+++ tests/unit-tests/scene/test_session_manager.cpp 2016-04-13 15:56:18 +0000
@@ -83,7 +83,7 @@
83 std::string("stub"),83 std::string("stub"),
84 geom::Rectangle{{},{}},84 geom::Rectangle{{},{}},
85 false,85 false,
86 std::make_shared<mtd::StubBufferStream>(),86 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
87 std::shared_ptr<mi::InputChannel>(),87 std::shared_ptr<mi::InputChannel>(),
88 std::shared_ptr<mi::InputSender>(),88 std::shared_ptr<mi::InputSender>(),
89 std::shared_ptr<mg::CursorImage>(),89 std::shared_ptr<mg::CursorImage>(),
9090
=== modified file 'tests/unit-tests/scene/test_surface.cpp'
--- tests/unit-tests/scene/test_surface.cpp 2016-03-24 22:06:39 +0000
+++ tests/unit-tests/scene/test_surface.cpp 2016-04-13 15:56:18 +0000
@@ -193,7 +193,7 @@
193{193{
194 SurfaceCreation()194 SurfaceCreation()
195 : surface(surface_name,195 : surface(surface_name,
196 rect, false, mock_buffer_stream, 196 rect, false, streams,
197 std::make_shared<mtd::StubInputChannel>(),197 std::make_shared<mtd::StubInputChannel>(),
198 std::make_shared<mtd::StubInputSender>(),198 std::make_shared<mtd::StubInputSender>(),
199 nullptr /* cursor_image */, report)199 nullptr /* cursor_image */, report)
@@ -215,6 +215,7 @@
215 }215 }
216216
217 std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>();217 std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>();
218 std::list<ms::StreamInfo> streams{ { mock_buffer_stream, {}, {} } };
218 std::function<void()> change_notification;219 std::function<void()> change_notification;
219 int notification_count = 0;220 int notification_count = 0;
220 mtd::StubBuffer stub_buffer;221 mtd::StubBuffer stub_buffer;
@@ -240,12 +241,6 @@
240 EXPECT_EQ(size, surface.size());241 EXPECT_EQ(size, surface.size());
241}242}
242243
243TEST_F(SurfaceCreation, constructed_stream_is_primary)
244{
245 using namespace testing;
246 EXPECT_THAT(surface.primary_buffer_stream(), Eq(mock_buffer_stream));
247}
248
249TEST_F(SurfaceCreation, test_surface_gets_top_left)244TEST_F(SurfaceCreation, test_surface_gets_top_left)
250{245{
251 auto ret_top_left = surface.top_left();246 auto ret_top_left = surface.top_left();
@@ -383,7 +378,7 @@
383 surface_name,378 surface_name,
384 rect,379 rect,
385 false,380 false,
386 mock_buffer_stream,381 streams,
387 mt::fake_shared(channel),382 mt::fake_shared(channel),
388 std::make_shared<mtd::StubInputSender>(),383 std::make_shared<mtd::StubInputSender>(),
389 std::shared_ptr<mg::CursorImage>(),384 std::shared_ptr<mg::CursorImage>(),
@@ -401,7 +396,7 @@
401 surface_name,396 surface_name,
402 rect,397 rect,
403 false,398 false,
404 mock_buffer_stream,399 streams,
405 std::make_shared<mtd::StubInputChannel>(),400 std::make_shared<mtd::StubInputChannel>(),
406 mt::fake_shared(mock_sender),401 mt::fake_shared(mock_sender),
407 std::shared_ptr<mg::CursorImage>(),402 std::shared_ptr<mg::CursorImage>(),
408403
=== modified file 'tests/unit-tests/scene/test_surface_impl.cpp'
--- tests/unit-tests/scene/test_surface_impl.cpp 2016-04-04 03:30:04 +0000
+++ tests/unit-tests/scene/test_surface_impl.cpp 2016-04-13 15:56:18 +0000
@@ -82,9 +82,10 @@
82 ON_CALL(*buffer_stream, acquire_client_buffer(_))82 ON_CALL(*buffer_stream, acquire_client_buffer(_))
83 .WillByDefault(InvokeArgument<0>(nullptr));83 .WillByDefault(InvokeArgument<0>(nullptr));
84 84
85 surface = std::make_shared<ms::BasicSurface>(std::string("stub"), geom::Rectangle{{},{}}, false,85 surface = std::make_shared<ms::BasicSurface>(
86 buffer_stream, nullptr /* input_channel */, stub_input_sender,86 std::string("stub"), geom::Rectangle{{},{}}, false,
87 nullptr /* cursor_image */, report);87 std::list<ms::StreamInfo> { { buffer_stream, {}, {} } },
88 nullptr, stub_input_sender, nullptr, report);
88 }89 }
8990
90 mf::SurfaceId stub_id;91 mf::SurfaceId stub_id;
@@ -280,7 +281,7 @@
280 std::string("stub"),281 std::string("stub"),
281 geom::Rectangle{{},{}},282 geom::Rectangle{{},{}},
282 false,283 false,
283 buffer_stream,284 std::list<ms::StreamInfo> { { buffer_stream, {}, {} } },
284 std::shared_ptr<mi::InputChannel>(),285 std::shared_ptr<mi::InputChannel>(),
285 stub_input_sender,286 stub_input_sender,
286 std::shared_ptr<mg::CursorImage>(),287 std::shared_ptr<mg::CursorImage>(),
287288
=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
--- tests/unit-tests/scene/test_surface_stack.cpp 2016-03-23 06:39:56 +0000
+++ tests/unit-tests/scene/test_surface_stack.cpp 2016-04-13 15:56:18 +0000
@@ -56,10 +56,10 @@
56namespace56namespace
57{57{
5858
59void post_a_frame(ms::Surface& s)59void post_a_frame(mc::BufferStream& s)
60{60{
61 mtd::StubBuffer old_buffer;61 mtd::StubBuffer old_buffer;
62 s.primary_buffer_stream()->swap_buffers(&old_buffer, [](mg::Buffer*){});62 s.swap_buffers(&old_buffer, [](mg::Buffer*){});
63}63}
6464
65MATCHER_P(SurfaceWithInputReceptionMode, mode, "")65MATCHER_P(SurfaceWithInputReceptionMode, mode, "")
@@ -67,11 +67,6 @@
67 return arg->reception_mode() == mode;67 return arg->reception_mode() == mode;
68}68}
6969
70MATCHER_P(SceneElementForSurface, surface, "")
71{
72 return arg->renderable()->id() == surface->primary_buffer_stream().get();
73}
74
75MATCHER_P(SceneElementForStream, stream, "")70MATCHER_P(SceneElementForStream, stream, "")
76{71{
77 return arg->renderable()->id() == stream.get();72 return arg->renderable()->id() == stream.get();
@@ -133,43 +128,39 @@
133 std::string("stub"),128 std::string("stub"),
134 geom::Rectangle{{},{}},129 geom::Rectangle{{},{}},
135 false,130 false,
136 std::make_shared<mtd::StubBufferStream>(),131 std::list<ms::StreamInfo> { { stub_buffer_stream1, {}, {} } },
137 std::shared_ptr<mir::input::InputChannel>(),132 std::shared_ptr<mir::input::InputChannel>(),
138 std::shared_ptr<mir::input::InputSender>(),133 std::shared_ptr<mir::input::InputSender>(),
139 std::shared_ptr<mg::CursorImage>(),134 std::shared_ptr<mg::CursorImage>(),
140 report);135 report);
141136
142 post_a_frame(*stub_surface1);
143
144 stub_surface2 = std::make_shared<ms::BasicSurface>(137 stub_surface2 = std::make_shared<ms::BasicSurface>(
145 std::string("stub"),138 std::string("stub"),
146 geom::Rectangle{{},{}},139 geom::Rectangle{{},{}},
147 false,140 false,
148 std::make_shared<mtd::StubBufferStream>(),141 std::list<ms::StreamInfo> { { stub_buffer_stream2, {}, {} } },
149 std::shared_ptr<mir::input::InputChannel>(),142 std::shared_ptr<mir::input::InputChannel>(),
150 std::shared_ptr<mir::input::InputSender>(),143 std::shared_ptr<mir::input::InputSender>(),
151 std::shared_ptr<mg::CursorImage>(),144 std::shared_ptr<mg::CursorImage>(),
152 report);145 report);
153146
154 post_a_frame(*stub_surface2);147
155
156 stub_surface3 = std::make_shared<ms::BasicSurface>(148 stub_surface3 = std::make_shared<ms::BasicSurface>(
157 std::string("stub"),149 std::string("stub"),
158 geom::Rectangle{{},{}},150 geom::Rectangle{{},{}},
159 false,151 false,
160 std::make_shared<mtd::StubBufferStream>(),152 std::list<ms::StreamInfo> { { stub_buffer_stream3, {}, {} } },
161 std::shared_ptr<mir::input::InputChannel>(),153 std::shared_ptr<mir::input::InputChannel>(),
162 std::shared_ptr<mir::input::InputSender>(),154 std::shared_ptr<mir::input::InputSender>(),
163 std::shared_ptr<mg::CursorImage>(),155 std::shared_ptr<mg::CursorImage>(),
164 report);156 report);
165157
166 post_a_frame(*stub_surface3);158
167
168 invisible_stub_surface = std::make_shared<ms::BasicSurface>(159 invisible_stub_surface = std::make_shared<ms::BasicSurface>(
169 std::string("stub"),160 std::string("stub"),
170 geom::Rectangle{{},{}},161 geom::Rectangle{{},{}},
171 false,162 false,
172 std::make_shared<mtd::StubBufferStream>(),163 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
173 std::shared_ptr<mir::input::InputChannel>(),164 std::shared_ptr<mir::input::InputChannel>(),
174 std::shared_ptr<mir::input::InputSender>(),165 std::shared_ptr<mir::input::InputSender>(),
175 std::shared_ptr<mg::CursorImage>(),166 std::shared_ptr<mg::CursorImage>(),
@@ -178,6 +169,10 @@
178 }169 }
179170
180 ms::SurfaceCreationParameters default_params;171 ms::SurfaceCreationParameters default_params;
172 std::shared_ptr<mc::BufferStream> stub_buffer_stream1 = std::make_shared<mtd::StubBufferStream>();
173 std::shared_ptr<mc::BufferStream> stub_buffer_stream2 = std::make_shared<mtd::StubBufferStream>();
174 std::shared_ptr<mc::BufferStream> stub_buffer_stream3 = std::make_shared<mtd::StubBufferStream>();
175
181 std::shared_ptr<ms::BasicSurface> stub_surface1;176 std::shared_ptr<ms::BasicSurface> stub_surface1;
182 std::shared_ptr<ms::BasicSurface> stub_surface2;177 std::shared_ptr<ms::BasicSurface> stub_surface2;
183 std::shared_ptr<ms::BasicSurface> stub_surface3;178 std::shared_ptr<ms::BasicSurface> stub_surface3;
@@ -216,9 +211,9 @@
216 EXPECT_THAT(211 EXPECT_THAT(
217 stack.scene_elements_for(compositor_id),212 stack.scene_elements_for(compositor_id),
218 ElementsAre(213 ElementsAre(
219 SceneElementForSurface(stub_surface1),214 SceneElementForStream(stub_buffer_stream1),
220 SceneElementForSurface(stub_surface2),215 SceneElementForStream(stub_buffer_stream2),
221 SceneElementForSurface(stub_surface3)));216 SceneElementForStream(stub_buffer_stream3)));
222}217}
223218
224TEST_F(SurfaceStack, stacking_order_with_multiple_buffer_streams)219TEST_F(SurfaceStack, stacking_order_with_multiple_buffer_streams)
@@ -228,7 +223,7 @@
228 auto stub_stream1 = std::make_shared<mtd::StubBufferStream>();223 auto stub_stream1 = std::make_shared<mtd::StubBufferStream>();
229 auto stub_stream2 = std::make_shared<mtd::StubBufferStream>();224 auto stub_stream2 = std::make_shared<mtd::StubBufferStream>();
230 std::list<ms::StreamInfo> streams = {225 std::list<ms::StreamInfo> streams = {
231 { stub_surface1->buffer_stream(), {0,0}, {} },226 { stub_buffer_stream1, {0,0}, {} },
232 { stub_stream0, {2,2}, {} },227 { stub_stream0, {2,2}, {} },
233 { stub_stream1, {2,3}, {} },228 { stub_stream1, {2,3}, {} },
234 };229 };
@@ -236,7 +231,7 @@
236231
237 streams = {232 streams = {
238 { stub_stream2, {2,4}, {} },233 { stub_stream2, {2,4}, {} },
239 { stub_surface3->buffer_stream(), {0,0}, {} }234 { stub_buffer_stream3, {0,0}, {} }
240 };235 };
241 stub_surface3->set_streams(streams);236 stub_surface3->set_streams(streams);
242237
@@ -244,16 +239,15 @@
244 stack.add_surface(stub_surface2, default_params.input_mode);239 stack.add_surface(stub_surface2, default_params.input_mode);
245 stack.add_surface(stub_surface3, default_params.input_mode);240 stack.add_surface(stub_surface3, default_params.input_mode);
246241
247
248 EXPECT_THAT(242 EXPECT_THAT(
249 stack.scene_elements_for(compositor_id),243 stack.scene_elements_for(compositor_id),
250 ElementsAre(244 ElementsAre(
251 SceneElementForSurface(stub_surface1),245 SceneElementForStream(stub_buffer_stream1),
252 SceneElementForStream(stub_stream0),246 SceneElementForStream(stub_stream0),
253 SceneElementForStream(stub_stream1),247 SceneElementForStream(stub_stream1),
254 SceneElementForSurface(stub_surface2),248 SceneElementForStream(stub_buffer_stream2),
255 SceneElementForStream(stub_stream2),249 SceneElementForStream(stub_stream2),
256 SceneElementForSurface(stub_surface3)250 SceneElementForStream(stub_buffer_stream3)
257 ));251 ));
258}252}
259253
@@ -268,8 +262,8 @@
268 EXPECT_THAT(262 EXPECT_THAT(
269 stack.scene_elements_for(compositor_id),263 stack.scene_elements_for(compositor_id),
270 ElementsAre(264 ElementsAre(
271 SceneElementForSurface(stub_surface1),265 SceneElementForStream(stub_buffer_stream1),
272 SceneElementForSurface(stub_surface2)));266 SceneElementForStream(stub_buffer_stream2)));
273}267}
274268
275TEST_F(SurfaceStack, decor_name_is_surface_name)269TEST_F(SurfaceStack, decor_name_is_surface_name)
@@ -281,7 +275,7 @@
281 std::string("Mary had a little lamb"),275 std::string("Mary had a little lamb"),
282 geom::Rectangle{{},{}},276 geom::Rectangle{{},{}},
283 false,277 false,
284 std::make_shared<mtd::StubBufferStream>(),278 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
285 std::shared_ptr<mir::input::InputChannel>(),279 std::shared_ptr<mir::input::InputChannel>(),
286 std::shared_ptr<mir::input::InputSender>(),280 std::shared_ptr<mir::input::InputSender>(),
287 std::shared_ptr<mg::CursorImage>(),281 std::shared_ptr<mg::CursorImage>(),
@@ -289,8 +283,7 @@
289 stack.add_surface(surface, default_params.input_mode);283 stack.add_surface(surface, default_params.input_mode);
290 surface->configure(mir_surface_attrib_visibility,284 surface->configure(mir_surface_attrib_visibility,
291 mir_surface_visibility_exposed);285 mir_surface_visibility_exposed);
292 post_a_frame(*surface);286
293
294 auto elements = stack.scene_elements_for(compositor_id);287 auto elements = stack.scene_elements_for(compositor_id);
295 ASSERT_EQ(1, elements.size());288 ASSERT_EQ(1, elements.size());
296289
@@ -311,7 +304,7 @@
311 std::string("username@hostname: /"),304 std::string("username@hostname: /"),
312 geom::Rectangle{{},{}},305 geom::Rectangle{{},{}},
313 false,306 false,
314 std::make_shared<mtd::StubBufferStream>(),307 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
315 std::shared_ptr<mir::input::InputChannel>(),308 std::shared_ptr<mir::input::InputChannel>(),
316 std::shared_ptr<mir::input::InputSender>(),309 std::shared_ptr<mir::input::InputSender>(),
317 std::shared_ptr<mg::CursorImage>(),310 std::shared_ptr<mg::CursorImage>(),
@@ -319,8 +312,7 @@
319 stack.add_surface(surface, default_params.input_mode);312 stack.add_surface(surface, default_params.input_mode);
320 surface->configure(mir_surface_attrib_visibility,313 surface->configure(mir_surface_attrib_visibility,
321 mir_surface_visibility_exposed);314 mir_surface_visibility_exposed);
322 post_a_frame(*surface);315
323
324 // (change directory in shell app)316 // (change directory in shell app)
325 surface->rename("username@hostname: ~/Documents");317 surface->rename("username@hostname: ~/Documents");
326318
@@ -350,11 +342,12 @@
350 ON_CALL(*mock_queue, compositor_acquire(_))342 ON_CALL(*mock_queue, compositor_acquire(_))
351 .WillByDefault(InvokeWithoutArgs([&]{ready--; return mt::fake_shared(stub_buffer); }));343 .WillByDefault(InvokeWithoutArgs([&]{ready--; return mt::fake_shared(stub_buffer); }));
352344
345 auto stream = std::make_shared<mc::BufferStreamSurfaces>(mock_queue);
353 auto surface = std::make_shared<ms::BasicSurface>(346 auto surface = std::make_shared<ms::BasicSurface>(
354 std::string("stub"),347 std::string("stub"),
355 geom::Rectangle{{},{}},348 geom::Rectangle{{},{}},
356 false,349 false,
357 std::make_shared<mc::BufferStreamSurfaces>(mock_queue),350 std::list<ms::StreamInfo> { { stream, {}, {} } },
358 std::shared_ptr<mir::input::InputChannel>(),351 std::shared_ptr<mir::input::InputChannel>(),
359 std::shared_ptr<mir::input::InputSender>(),352 std::shared_ptr<mir::input::InputSender>(),
360 std::shared_ptr<mg::CursorImage>(),353 std::shared_ptr<mg::CursorImage>(),
@@ -364,9 +357,9 @@
364 mir_surface_visibility_exposed);357 mir_surface_visibility_exposed);
365358
366 EXPECT_EQ(0, stack.frames_pending(this));359 EXPECT_EQ(0, stack.frames_pending(this));
367 post_a_frame(*surface);360 post_a_frame(*stream);
368 post_a_frame(*surface);361 post_a_frame(*stream);
369 post_a_frame(*surface);362 post_a_frame(*stream);
370 EXPECT_EQ(3, stack.frames_pending(this));363 EXPECT_EQ(3, stack.frames_pending(this));
371364
372 for (int expect = 3; expect >= 0; --expect)365 for (int expect = 3; expect >= 0; --expect)
@@ -386,11 +379,12 @@
386379
387 ms::SurfaceStack stack{report};380 ms::SurfaceStack stack{report};
388 stack.register_compositor(this);381 stack.register_compositor(this);
382 auto stream = std::make_shared<mtd::StubBufferStream>();
389 auto surface = std::make_shared<ms::BasicSurface>(383 auto surface = std::make_shared<ms::BasicSurface>(
390 std::string("stub"),384 std::string("stub"),
391 geom::Rectangle{{},{}},385 geom::Rectangle{{},{}},
392 false,386 false,
393 std::make_shared<mtd::StubBufferStream>(),387 std::list<ms::StreamInfo> { { stream, {}, {} } },
394 std::shared_ptr<mir::input::InputChannel>(),388 std::shared_ptr<mir::input::InputChannel>(),
395 std::shared_ptr<mir::input::InputSender>(),389 std::shared_ptr<mir::input::InputSender>(),
396 std::shared_ptr<mg::CursorImage>(),390 std::shared_ptr<mg::CursorImage>(),
@@ -402,9 +396,9 @@
402 elem->occluded();396 elem->occluded();
403397
404 EXPECT_EQ(0, stack.frames_pending(this));398 EXPECT_EQ(0, stack.frames_pending(this));
405 post_a_frame(*surface);399 post_a_frame(*stream);
406 post_a_frame(*surface);400 post_a_frame(*stream);
407 post_a_frame(*surface);401 post_a_frame(*stream);
408 EXPECT_EQ(0, stack.frames_pending(this));402 EXPECT_EQ(0, stack.frames_pending(this));
409}403}
410404
@@ -419,20 +413,21 @@
419413
420 stack.register_compositor(comp1);414 stack.register_compositor(comp1);
421 stack.register_compositor(comp2);415 stack.register_compositor(comp2);
416 auto stream = std::make_shared<mtd::StubBufferStream>();
422 auto surface = std::make_shared<ms::BasicSurface>(417 auto surface = std::make_shared<ms::BasicSurface>(
423 std::string("stub"),418 std::string("stub"),
424 geom::Rectangle{{},{}},419 geom::Rectangle{{},{}},
425 false,420 false,
426 std::make_shared<mtd::StubBufferStream>(),421 std::list<ms::StreamInfo> { { stream, {}, {} } },
427 std::shared_ptr<mir::input::InputChannel>(),422 std::shared_ptr<mir::input::InputChannel>(),
428 std::shared_ptr<mir::input::InputSender>(),423 std::shared_ptr<mir::input::InputSender>(),
429 std::shared_ptr<mg::CursorImage>(),424 std::shared_ptr<mg::CursorImage>(),
430 report);425 report);
431426
432 stack.add_surface(surface, default_params.input_mode);427 stack.add_surface(surface, default_params.input_mode);
433 post_a_frame(*surface);428 post_a_frame(*stream);
434 post_a_frame(*surface);429 post_a_frame(*stream);
435 post_a_frame(*surface);430 post_a_frame(*stream);
436431
437 EXPECT_EQ(3, stack.frames_pending(comp1));432 EXPECT_EQ(3, stack.frames_pending(comp1));
438 EXPECT_EQ(3, stack.frames_pending(comp2));433 EXPECT_EQ(3, stack.frames_pending(comp2));
@@ -464,9 +459,9 @@
464 EXPECT_THAT(459 EXPECT_THAT(
465 stack.scene_elements_for(compositor_id),460 stack.scene_elements_for(compositor_id),
466 ElementsAre(461 ElementsAre(
467 SceneElementForSurface(stub_surface1),462 SceneElementForStream(stub_buffer_stream1),
468 SceneElementForSurface(stub_surface3),463 SceneElementForStream(stub_buffer_stream3),
469 SceneElementForSurface(stub_surface2)));464 SceneElementForStream(stub_buffer_stream2)));
470}465}
471466
472467
@@ -500,18 +495,18 @@
500 EXPECT_THAT(495 EXPECT_THAT(
501 stack.scene_elements_for(compositor_id),496 stack.scene_elements_for(compositor_id),
502 ElementsAre(497 ElementsAre(
503 SceneElementForSurface(stub_surface1),498 SceneElementForStream(stub_buffer_stream1),
504 SceneElementForSurface(stub_surface2),499 SceneElementForStream(stub_buffer_stream2),
505 SceneElementForSurface(stub_surface3)));500 SceneElementForStream(stub_buffer_stream3)));
506501
507 stack.raise(stub_surface1);502 stack.raise(stub_surface1);
508503
509 EXPECT_THAT(504 EXPECT_THAT(
510 stack.scene_elements_for(compositor_id),505 stack.scene_elements_for(compositor_id),
511 ElementsAre(506 ElementsAre(
512 SceneElementForSurface(stub_surface2),507 SceneElementForStream(stub_buffer_stream2),
513 SceneElementForSurface(stub_surface3),508 SceneElementForStream(stub_buffer_stream3),
514 SceneElementForSurface(stub_surface1)));509 SceneElementForStream(stub_buffer_stream1)));
515}510}
516511
517TEST_F(SurfaceStack, raise_throw_behavior)512TEST_F(SurfaceStack, raise_throw_behavior)
@@ -537,13 +532,12 @@
537 std::string("stub"),532 std::string("stub"),
538 geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}},533 geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}},
539 true,534 true,
540 std::make_shared<mtd::StubBufferStream>(),535 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
541 std::shared_ptr<mir::input::InputChannel>(),536 std::shared_ptr<mir::input::InputChannel>(),
542 std::shared_ptr<mir::input::InputSender>(),537 std::shared_ptr<mir::input::InputSender>(),
543 std::shared_ptr<mg::CursorImage>(),538 std::shared_ptr<mg::CursorImage>(),
544 report);539 report);
545 post_a_frame(*surface);540
546
547 surfaces.emplace_back(surface);541 surfaces.emplace_back(surface);
548 stack.add_surface(surface, default_params.input_mode);542 stack.add_surface(surface, default_params.input_mode);
549 }543 }
@@ -723,7 +717,7 @@
723 std::string("stub"),717 std::string("stub"),
724 geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}},718 geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}},
725 true,719 true,
726 std::make_shared<mtd::StubBufferStream>(),720 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
727 std::shared_ptr<mir::input::InputChannel>(),721 std::shared_ptr<mir::input::InputChannel>(),
728 std::shared_ptr<mir::input::InputSender>(),722 std::shared_ptr<mir::input::InputSender>(),
729 std::shared_ptr<mg::CursorImage>(),723 std::shared_ptr<mg::CursorImage>(),
@@ -756,13 +750,12 @@
756 std::string("stub"),750 std::string("stub"),
757 geom::Rectangle{geom::Point{3, 4},geom::Size{1, 2}},751 geom::Rectangle{geom::Point{3, 4},geom::Size{1, 2}},
758 true,752 true,
759 mock_stream,753 std::list<ms::StreamInfo> { { mock_stream, {}, {} } },
760 std::shared_ptr<mir::input::InputChannel>(),754 std::shared_ptr<mir::input::InputChannel>(),
761 std::shared_ptr<mir::input::InputSender>(),755 std::shared_ptr<mir::input::InputSender>(),
762 std::shared_ptr<mg::CursorImage>(),756 std::shared_ptr<mg::CursorImage>(),
763 report);757 report);
764 post_a_frame(*surface);758 stack.add_surface(surface, default_params.input_mode);
765 stack.add_surface(surface, default_params.input_mode);
766759
767 auto const elements = stack.scene_elements_for(compositor_id);760 auto const elements = stack.scene_elements_for(compositor_id);
768761
@@ -787,13 +780,12 @@
787 std::string("stub"),780 std::string("stub"),
788 geom::Rectangle{geom::Point{3, 4},geom::Size{1, 2}},781 geom::Rectangle{geom::Point{3, 4},geom::Size{1, 2}},
789 true,782 true,
790 mock_stream,783 std::list<ms::StreamInfo> { { mock_stream, {}, {} } },
791 std::shared_ptr<mir::input::InputChannel>(),784 std::shared_ptr<mir::input::InputChannel>(),
792 std::shared_ptr<mir::input::InputSender>(),785 std::shared_ptr<mir::input::InputSender>(),
793 std::shared_ptr<mg::CursorImage>(),786 std::shared_ptr<mg::CursorImage>(),
794 report);787 report);
795 post_a_frame(*surface);788 stack.add_surface(surface, default_params.input_mode);
796 stack.add_surface(surface, default_params.input_mode);
797789
798 auto const elements = stack.scene_elements_for(compositor_id);790 auto const elements = stack.scene_elements_for(compositor_id);
799 ASSERT_THAT(elements.size(), Eq(1u));791 ASSERT_THAT(elements.size(), Eq(1u));
@@ -811,7 +803,7 @@
811 {},803 {},
812 {{},{}},804 {{},{}},
813 true,805 true,
814 std::make_shared<mtd::StubBufferStream>(),806 std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
815 {},807 {},
816 {},808 {},
817 {},809 {},
@@ -833,8 +825,7 @@
833825
834 auto const mock_surface = std::make_shared<MockConfigureSurface>();826 auto const mock_surface = std::make_shared<MockConfigureSurface>();
835 mock_surface->show();827 mock_surface->show();
836 post_a_frame(*mock_surface);828
837
838 stack.add_surface(mock_surface, default_params.input_mode);829 stack.add_surface(mock_surface, default_params.input_mode);
839830
840 auto const elements = stack.scene_elements_for(compositor_id);831 auto const elements = stack.scene_elements_for(compositor_id);
@@ -858,8 +849,7 @@
858 stack.register_compositor(compositor_id2);849 stack.register_compositor(compositor_id2);
859850
860 auto const mock_surface = std::make_shared<MockConfigureSurface>();851 auto const mock_surface = std::make_shared<MockConfigureSurface>();
861 post_a_frame(*mock_surface);852 stack.add_surface(mock_surface, default_params.input_mode);
862 stack.add_surface(mock_surface, default_params.input_mode);
863853
864 auto const elements = stack.scene_elements_for(compositor_id);854 auto const elements = stack.scene_elements_for(compositor_id);
865 ASSERT_THAT(elements.size(), Eq(1u));855 ASSERT_THAT(elements.size(), Eq(1u));
@@ -884,7 +874,6 @@
884 stack.register_compositor(compositor_id3);874 stack.register_compositor(compositor_id3);
885875
886 auto const mock_surface = std::make_shared<MockConfigureSurface>();876 auto const mock_surface = std::make_shared<MockConfigureSurface>();
887 post_a_frame(*mock_surface);
888 stack.add_surface(mock_surface, default_params.input_mode);877 stack.add_surface(mock_surface, default_params.input_mode);
889878
890 auto const elements = stack.scene_elements_for(compositor_id);879 auto const elements = stack.scene_elements_for(compositor_id);
@@ -1014,8 +1003,8 @@
1014 EXPECT_THAT(1003 EXPECT_THAT(
1015 stack.scene_elements_for(compositor_id),1004 stack.scene_elements_for(compositor_id),
1016 ElementsAre(1005 ElementsAre(
1017 SceneElementForSurface(stub_surface1),1006 SceneElementForStream(stub_buffer_stream1),
1018 SceneElementForSurface(stub_surface2),1007 SceneElementForStream(stub_buffer_stream2),
1019 SceneElementForStream(mt::fake_shared(r))));1008 SceneElementForStream(mt::fake_shared(r))));
1020}1009}
10211010
@@ -1032,8 +1021,8 @@
1032 EXPECT_THAT(1021 EXPECT_THAT(
1033 stack.scene_elements_for(compositor_id),1022 stack.scene_elements_for(compositor_id),
1034 ElementsAre(1023 ElementsAre(
1035 SceneElementForSurface(stub_surface1),1024 SceneElementForStream(stub_buffer_stream1),
1036 SceneElementForSurface(stub_surface2),1025 SceneElementForStream(stub_buffer_stream2),
1037 SceneElementForStream(mt::fake_shared(r))));1026 SceneElementForStream(mt::fake_shared(r))));
10381027
1039 stack.remove_input_visualization(mt::fake_shared(r));1028 stack.remove_input_visualization(mt::fake_shared(r));
@@ -1041,8 +1030,8 @@
1041 EXPECT_THAT(1030 EXPECT_THAT(
1042 stack.scene_elements_for(compositor_id),1031 stack.scene_elements_for(compositor_id),
1043 ElementsAre(1032 ElementsAre(
1044 SceneElementForSurface(stub_surface1),1033 SceneElementForStream(stub_buffer_stream1),
1045 SceneElementForSurface(stub_surface2)));1034 SceneElementForStream(stub_buffer_stream2)));
1046}1035}
10471036
1048TEST_F(SurfaceStack, scene_observers_notified_of_generic_scene_change)1037TEST_F(SurfaceStack, scene_observers_notified_of_generic_scene_change)
@@ -1140,9 +1129,9 @@
1140 EXPECT_THAT(1129 EXPECT_THAT(
1141 stack.scene_elements_for(compositor_id),1130 stack.scene_elements_for(compositor_id),
1142 ElementsAre(1131 ElementsAre(
1143 SceneElementForSurface(stub_surface2),1132 SceneElementForStream(stub_buffer_stream2),
1144 SceneElementForSurface(stub_surface1),1133 SceneElementForStream(stub_buffer_stream1),
1145 SceneElementForSurface(stub_surface3)));1134 SceneElementForStream(stub_buffer_stream3)));
11461135
1147 Mock::VerifyAndClearExpectations(&observer);1136 Mock::VerifyAndClearExpectations(&observer);
1148 EXPECT_CALL(observer, surfaces_reordered()).Times(1);1137 EXPECT_CALL(observer, surfaces_reordered()).Times(1);
@@ -1151,9 +1140,9 @@
1151 EXPECT_THAT(1140 EXPECT_THAT(
1152 stack.scene_elements_for(compositor_id),1141 stack.scene_elements_for(compositor_id),
1153 ElementsAre(1142 ElementsAre(
1154 SceneElementForSurface(stub_surface1),1143 SceneElementForStream(stub_buffer_stream1),
1155 SceneElementForSurface(stub_surface2),1144 SceneElementForStream(stub_buffer_stream2),
1156 SceneElementForSurface(stub_surface3)));1145 SceneElementForStream(stub_buffer_stream3)));
11571146
1158 Mock::VerifyAndClearExpectations(&observer);1147 Mock::VerifyAndClearExpectations(&observer);
1159 EXPECT_CALL(observer, surfaces_reordered()).Times(0);1148 EXPECT_CALL(observer, surfaces_reordered()).Times(0);
@@ -1162,7 +1151,7 @@
1162 EXPECT_THAT(1151 EXPECT_THAT(
1163 stack.scene_elements_for(compositor_id),1152 stack.scene_elements_for(compositor_id),
1164 ElementsAre(1153 ElementsAre(
1165 SceneElementForSurface(stub_surface1),1154 SceneElementForStream(stub_buffer_stream1),
1166 SceneElementForSurface(stub_surface2),1155 SceneElementForStream(stub_buffer_stream2),
1167 SceneElementForSurface(stub_surface3)));1156 SceneElementForStream(stub_buffer_stream3)));
1168}1157}

Subscribers

People subscribed via source and target branches