Mir

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

Proposed by Kevin DuBois on 2016-05-10
Status: Merged
Approved by: Kevin DuBois on 2016-06-08
Approved revision: 3509
Merged at revision: 3533
Proposed branch: lp:~kdub/mir/fix-1577967
Merge into: lp:mir
Diff against target: 349 lines (+137/-48)
7 files modified
include/client/mir_toolkit/mir_surface.h (+17/-5)
playground/mir_demo_client_prerendered_frames.c (+6/-0)
src/client/mir_connection.cpp (+21/-25)
src/client/mir_surface.cpp (+17/-16)
src/client/mir_surface.h (+7/-2)
tests/acceptance-tests/test_buffer_stream_arrangement.cpp (+45/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+24/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-1577967
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve on 2016-06-08
Daniel van Vugt Abstain on 2016-06-08
Cemil Azizoglu (community) Approve on 2016-05-16
Alan Griffiths Approve on 2016-05-11
Chris Halse Rogers 2016-05-10 Approve on 2016-05-11
Review via email: mp+294283@code.launchpad.net

Commit Message

fix lp: #1577967 by clarifying what mir_surface_get_buffer_stream() should do in a multistream world, and by making mir_surface_is_valid() respond properly when non-default streams are used.

Description of the Change

fix lp: #1577967 by clarifying what mir_surface_get_buffer_stream() should do in a multistream world, and by making mir_surface_is_valid() respond properly when non-default streams are used.

note: the original thought was designate the 1st MirBufferStream as 'the default stream', however, soon it will be possible to have multiple MirPresentationChains, in which case there are no MirBufferStream*'s to be the default.

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

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

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

review: Needs Fixing (continuous-integration)
Chris Halse Rogers (raof) wrote :

LGTM. Should we be marking all the mir_surface_* functions which implicitly deal with a default BufferStream as deprecated?

Certainly we should be marking mir_surface_{get,set}_swap_interval as deprecated. I lean towards marking mir_surface_get_buffer_stream as deprecated, also, although there's not a direct replacement.

review: Approve
Alan Griffiths (alan-griffiths) wrote :

Triggered rebuild as a quick looks suggested extremely slow test hardware leading to timeouts.

~~~~

+ uint32_t output_id;
+
};

Unnecessary whitespace

review: Approve
Mir CI Bot (mir-ci-bot) wrote :

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

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

review: Needs Fixing (continuous-integration)
Kevin DuBois (kdub) wrote :

> Certainly we should be marking mir_surface_{get,set}_swap_interval as
> deprecated. I lean towards marking mir_surface_get_buffer_stream as
> deprecated, also, although there's not a direct replacement.

There is a way in the current API to work without mir_surface_get_buffer_stream()

MirSurfaceSpec* spec = ...;
MirBufferStream* stream = mir_connection_buffer_stream_create_sync(..);
mir_surface_spec_set_streams(spec, {stream, 0, 0}, 1);
MirSurface* surface = mir_surface_create_sync(spec);

now the client knows which stream is in the surface, and could change/swap as it wants to.

Cemil Azizoglu (cemil-azizoglu) wrote :

>LGTM. Should we be marking all the mir_surface_* functions which implicitly deal with a default >BufferStream as deprecated?

+1 as the names are really confusing.

Needs fixings :

153 + legacy_default_stream(buffer_stream),

Since the notion of "default stream" is not going away, we should just call it "default_stream".
-------------------------------------------

209 + auto resize_event = mir_event_get_resize_event(&e);
210 + size = { mir_resize_event_get_width(resize_event), mir_resize_event_get_height(resize_event) };
211 + if (legacy_default_stream)
212 + legacy_default_stream->set_size(size);

The if statement should enclose the whole thing as it only makes sense when there is a default stream.

review: Needs Fixing
Kevin DuBois (kdub) wrote :

can add some deprecated tags to discourage use in the headers.

re legacy_default_stream, I think tagging legacy_ on front indicates that this bit of functionality is really only around for legacy purposes. Its not going away yet, but it is still around for legacy reasons. OTOH, its an internal member variable, so will change name and add comment to this effect.

The size member variable is used in get_parameters, and should be changed when the resize event occurs.

Cemil Azizoglu (cemil-azizoglu) wrote :

LGTM

review: Approve
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/269/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/1081/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/291/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1129
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1120
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1120
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1091/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/1091/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1091
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1091/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/1091
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1091/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/1091/console

review: Needs Fixing (continuous-integration)
Mir CI Bot (mir-ci-bot) wrote :

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

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

review: Needs Fixing (continuous-integration)
Daniel van Vugt (vanvugt) wrote :

A few failures:

16:48:22 9: [ FAILED ] 3 tests, listed below:
16:48:22 9: [ FAILED ] ServerStartup.creates_endpoint_on_filesystem
16:48:22 9: [ FAILED ] ServerStartup.after_server_sigkilled_can_start_new_instance
16:48:22 9: [ FAILED ] UnresponsiveClient.does_not_hang_server

They are not pre-existing bugs or known failures...

Daniel van Vugt (vanvugt) wrote :

Just a reminder - the CI failures appear to be consistent and unique to this branch. So I guess the branch is faulty.

review: Needs Fixing
lp:~kdub/mir/fix-1577967 updated on 2016-06-08
3507. By Kevin DuBois on 2016-05-20

merge in mir

3508. By Kevin DuBois on 2016-06-08

merge in mir

3509. By Kevin DuBois on 2016-06-08

remember to free spec in BufferStreamArrangement test suite

Mir CI Bot (mir-ci-bot) wrote :

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

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

review: Needs Fixing (continuous-integration)
Daniel van Vugt (vanvugt) :
review: Abstain
Kevin DuBois (kdub) wrote :

CI was ran against rev3508... rev3509 has fix for valgrind+ci.

Mir CI Bot (mir-ci-bot) wrote :

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

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

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/mir_surface.h'
2--- include/client/mir_toolkit/mir_surface.h 2016-05-03 06:55:25 +0000
3+++ include/client/mir_toolkit/mir_surface.h 2016-06-08 13:06:12 +0000
4@@ -538,7 +538,14 @@
5 /**
6 * Retrieve the primary MirBufferStream associated with a surface (to advance buffers,
7 * obtain EGLNativeWindow, etc...)
8- *
9+ *
10+ * \deprecated Users should use mir_surface_spec_set_streams() to arrange
11+ * the content of a surface, instead of relying on a stream
12+ * being created by default.
13+ * \warning If the surface was created with, or modified to have a
14+ * MirSurfaceSpec containing streams added through
15+ * mir_surface_spec_set_streams(), the default stream will
16+ * be removed, and this function will return NULL.
17 * \param[in] surface The surface
18 */
19 MirBufferStream* mir_surface_get_buffer_stream(MirSurface *surface);
20@@ -618,9 +625,13 @@
21 MirSurfaceState mir_surface_get_state(MirSurface *surface);
22
23 /**
24- * Set the swapinterval for mir_surface_swap_buffers. EGL users should use
25- * eglSwapInterval directly.
26- * At the time being, only swapinterval of 0 or 1 is supported.
27+ * Set the swapinterval for the default stream.
28+ * \warning EGL users should use eglSwapInterval directly.
29+ * \warning Only swapinterval of 0 or 1 is supported.
30+ * \warning If the surface was created with, or modified to have a
31+ * MirSurfaceSpec containing streams added through
32+ * mir_surface_spec_set_streams(), the default stream will
33+ * be removed, and this function will return NULL.
34 * \param [in] surface The surface to operate on
35 * \param [in] interval The number of vblank signals that
36 * mir_surface_swap_buffers will wait for
37@@ -634,7 +645,8 @@
38 * The default interval is 1.
39 * \param [in] surface The surface to operate on
40 * \return The swapinterval value that the client is operating with.
41- * Returns -1 if surface is invalid.
42+ * Returns -1 if surface is invalid, or if the default stream
43+ * was removed by use of mir_surface_spec_set_streams().
44 */
45 int mir_surface_get_swapinterval(MirSurface* surface);
46
47
48=== modified file 'playground/mir_demo_client_prerendered_frames.c'
49--- playground/mir_demo_client_prerendered_frames.c 2016-06-02 05:33:50 +0000
50+++ playground/mir_demo_client_prerendered_frames.c 2016-06-08 13:06:12 +0000
51@@ -161,6 +161,12 @@
52 mir_surface_spec_add_presentation_chain(
53 spec, width, height, displacement_x, displacement_y, chain);
54 MirSurface* surface = mir_surface_create_sync(spec);
55+ if (!mir_surface_is_valid(surface))
56+ {
57+ printf("could not create MirSurface\n");
58+ return -1;
59+ }
60+
61 mir_surface_spec_release(spec);
62
63 int num_prerendered_frames = 20;
64
65=== modified file 'src/client/mir_connection.cpp'
66--- src/client/mir_connection.cpp 2016-06-02 05:33:50 +0000
67+++ src/client/mir_connection.cpp 2016-06-08 13:06:12 +0000
68@@ -363,8 +363,6 @@
69 void MirConnection::surface_created(SurfaceCreationRequest* request)
70 {
71 std::unique_lock<decltype(mutex)> lock(mutex);
72- std::shared_ptr<MirSurface> surf {nullptr};
73- std::shared_ptr<mcl::ClientBufferStream> stream {nullptr};
74 //make sure this request actually was made.
75 auto request_it = std::find_if(surface_requests.begin(), surface_requests.end(),
76 [&request](std::shared_ptr<MirConnection::SurfaceCreationRequest> r){ return request == r.get(); });
77@@ -375,32 +373,34 @@
78 auto callback = request->cb;
79 auto context = request->context;
80 auto const& spec = request->spec;
81+ std::string name{spec.surface_name.is_set() ?
82+ spec.surface_name.value() : ""};
83
84- try
85+ std::shared_ptr<mcl::ClientBufferStream> default_stream {nullptr};
86+ if (surface_proto->buffer_stream().has_id())
87 {
88- std::string name{spec.surface_name.is_set() ?
89- spec.surface_name.value() : ""};
90-
91- if (surface_proto->has_buffer_stream())
92+ try
93 {
94- stream = std::make_shared<mcl::BufferStream>(
95+ default_stream = std::make_shared<mcl::BufferStream>(
96 this, request->wh, server, platform, surface_map, buffer_factory,
97 surface_proto->buffer_stream(), make_perf_report(logger), name,
98 mir::geometry::Size{surface_proto->width(), surface_proto->height()}, nbuffers);
99- }
100- }
101- catch (std::exception const& error)
102- {
103- if (!surface_proto->has_error())
104- surface_proto->set_error(error.what());
105- // failed to create buffer_stream, so clean up FDs it doesn't own
106- for (auto i = 0; i < surface_proto->fd_size(); i++)
107- ::close(surface_proto->fd(i));
108- if (surface_proto->has_buffer_stream() && surface_proto->buffer_stream().has_buffer())
109- for (int i = 0; i < surface_proto->buffer_stream().buffer().fd_size(); i++)
110- ::close(surface_proto->buffer_stream().buffer().fd(i));
111+ surface_map->insert(default_stream->rpc_id(), default_stream);
112+ }
113+ catch (std::exception const& error)
114+ {
115+ if (!surface_proto->has_error())
116+ surface_proto->set_error(error.what());
117+ // failed to create buffer_stream, so clean up FDs it doesn't own
118+ for (auto i = 0; i < surface_proto->fd_size(); i++)
119+ ::close(surface_proto->fd(i));
120+ if (surface_proto->has_buffer_stream() && surface_proto->buffer_stream().has_buffer())
121+ for (int i = 0; i < surface_proto->buffer_stream().buffer().fd_size(); i++)
122+ ::close(surface_proto->buffer_stream().buffer().fd(i));
123+ }
124 }
125
126+ std::shared_ptr<MirSurface> surf {nullptr};
127 if (surface_proto->has_error() || !surface_proto->has_id())
128 {
129 std::string reason;
130@@ -417,12 +417,8 @@
131 else
132 {
133 surf = std::make_shared<MirSurface>(
134- this, server, &debug, stream, input_platform, spec, *surface_proto, request->wh);
135-
136+ this, server, &debug, default_stream, input_platform, spec, *surface_proto, request->wh);
137 surface_map->insert(mf::SurfaceId{surface_proto->id().value()}, surf);
138-
139- if (stream)
140- surface_map->insert(mf::BufferStreamId{surface_proto->buffer_stream().id().value()}, stream);
141 }
142
143 callback(surf.get(), context);
144
145=== modified file 'src/client/mir_surface.cpp'
146--- src/client/mir_surface.cpp 2016-05-03 06:55:25 +0000
147+++ src/client/mir_surface.cpp 2016-06-08 13:06:12 +0000
148@@ -122,11 +122,15 @@
149 void_response{mcl::make_protobuf_object<mir::protobuf::Void>()},
150 modify_result{mcl::make_protobuf_object<mir::protobuf::Void>()},
151 connection_(allocating_connection),
152- buffer_stream(buffer_stream),
153+ default_stream(buffer_stream),
154 input_platform(input_platform),
155 keymapper(std::make_shared<mircv::XKBMapper>()),
156 configure_result{mcl::make_protobuf_object<mir::protobuf::SurfaceSetting>()},
157- creation_handle(handle)
158+ creation_handle(handle),
159+ size(spec.width.is_set() && spec.height.is_set() ? geom::Size{spec.width.value(), spec.height.value()} : geom::Size{0,0}),
160+ format(spec.pixel_format.is_set() ? spec.pixel_format.value() : mir_pixel_format_invalid),
161+ usage(spec.buffer_usage.is_set() ? spec.buffer_usage.value() : mir_buffer_usage_hardware),
162+ output_id(spec.output_id.is_set() ? spec.output_id.value() : static_cast<uint32_t>(mir_display_output_id_invalid))
163 {
164 for(int i = 0; i < surface_proto.attributes_size(); i++)
165 {
166@@ -172,7 +176,7 @@
167 {
168 std::lock_guard<decltype(mutex)> lock(mutex);
169
170- return buffer_stream->get_parameters();
171+ return {name.c_str(), size.width.as_int(), size.height.as_int(), format, usage, output_id};
172 }
173
174 char const * MirSurface::get_error_message()
175@@ -281,9 +285,9 @@
176 // possible to eliminate it in the second phase of buffer
177 // stream where the existing MirSurface swap interval functions
178 // may be deprecated in terms of mir_buffer_stream_ alternatives
179- if (at == mir_surface_attrib_swapinterval)
180+ if ((at == mir_surface_attrib_swapinterval) && default_stream)
181 {
182- buffer_stream->set_swap_interval(value);
183+ default_stream->set_swap_interval(value);
184 return &configure_wait_handle;
185 }
186
187@@ -387,8 +391,8 @@
188
189 if (at == mir_surface_attrib_swapinterval)
190 {
191- if (buffer_stream)
192- return buffer_stream->swap_interval();
193+ if (default_stream)
194+ return default_stream->swap_interval();
195 else // Surface creation is not finalized
196 return 1;
197 }
198@@ -448,13 +452,10 @@
199 }
200 case mir_event_type_resize:
201 {
202- if (auto_resize_stream)
203- {
204- auto resize_event = mir_event_get_resize_event(&e);
205- buffer_stream->set_size(geom::Size{
206- mir_resize_event_get_width(resize_event),
207- mir_resize_event_get_height(resize_event)});
208- }
209+ auto resize_event = mir_event_get_resize_event(&e);
210+ size = { mir_resize_event_get_width(resize_event), mir_resize_event_get_height(resize_event) };
211+ if (default_stream)
212+ default_stream->set_size(size);
213 break;
214 }
215 default:
216@@ -507,7 +508,7 @@
217 {
218 std::lock_guard<decltype(mutex)> lock(mutex);
219
220- return buffer_stream.get();
221+ return default_stream.get();
222 }
223
224 void MirSurface::on_modified()
225@@ -601,7 +602,7 @@
226
227 if (spec.streams.is_set())
228 {
229- auto_resize_stream = false;
230+ default_stream = nullptr;
231 for(auto const& stream : spec.streams.value())
232 {
233 auto const new_stream = surface_specification->add_stream();
234
235=== modified file 'src/client/mir_surface.h'
236--- src/client/mir_surface.h 2016-05-03 06:55:25 +0000
237+++ src/client/mir_surface.h 2016-06-08 13:06:12 +0000
238@@ -227,7 +227,8 @@
239 MirWaitHandle configure_cursor_wait_handle;
240 MirWaitHandle persistent_id_wait_handle;
241
242- std::shared_ptr<mir::client::ClientBufferStream> buffer_stream;
243+ //Deprecated functions can cause MirSurfaces to be created with a default stream
244+ std::shared_ptr<mir::client::ClientBufferStream> default_stream;
245 std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
246 std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper;
247
248@@ -239,11 +240,15 @@
249
250 std::function<void(MirEvent const*)> handle_event_callback;
251 std::shared_ptr<mir::dispatch::ThreadedDispatcher> input_thread;
252- bool auto_resize_stream{true};
253
254 //a bit batty, but the creation handle has to exist for as long as the MirSurface does,
255 //as we don't really manage the lifetime of MirWaitHandle sensibly.
256 std::shared_ptr<MirWaitHandle> const creation_handle;
257+ mir::geometry::Size size;
258+ MirPixelFormat format;
259+ MirBufferUsage usage;
260+ uint32_t output_id;
261+
262 };
263
264 #endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */
265
266=== modified file 'tests/acceptance-tests/test_buffer_stream_arrangement.cpp'
267--- tests/acceptance-tests/test_buffer_stream_arrangement.cpp 2016-05-18 07:27:24 +0000
268+++ tests/acceptance-tests/test_buffer_stream_arrangement.cpp 2016-06-08 13:06:12 +0000
269@@ -283,3 +283,48 @@
270 EXPECT_TRUE(ordering->wait_for_positions_within(positions, 5s))
271 << "timed out waiting to see the compositor post the streams in the right arrangement";
272 }
273+
274+//LP: #1577967
275+TEST_F(BufferStreamArrangement, surfaces_can_start_with_non_default_stream)
276+{
277+ using namespace testing;
278+ std::vector<MirBufferStreamInfo> infos(streams.size());
279+ auto i = 0u;
280+ for (auto const& stream : streams)
281+ {
282+ infos[i++] = MirBufferStreamInfo{
283+ stream->handle(),
284+ stream->position().x.as_int(),
285+ stream->position().y.as_int()};
286+ }
287+
288+ auto spec = mir_connection_create_spec_for_normal_surface(
289+ connection, 100, 100, mir_pixel_format_abgr_8888);
290+ mir_surface_spec_set_streams(spec, infos.data(), infos.size());
291+ auto surface = mir_surface_create_sync(spec);
292+ mir_surface_spec_release(spec);
293+ EXPECT_TRUE(mir_surface_is_valid(surface));
294+ EXPECT_THAT(mir_surface_get_error_message(surface), StrEq(""));
295+}
296+
297+TEST_F(BufferStreamArrangement, when_non_default_streams_are_set_surface_get_stream_gives_null)
298+{
299+ using namespace testing;
300+ EXPECT_TRUE(mir_buffer_stream_is_valid(mir_surface_get_buffer_stream(surface)));
301+
302+ std::vector<MirBufferStreamInfo> infos(streams.size());
303+ auto i = 0u;
304+ for (auto const& stream : streams)
305+ {
306+ infos[i++] = MirBufferStreamInfo{
307+ stream->handle(),
308+ stream->position().x.as_int(),
309+ stream->position().y.as_int()};
310+ }
311+ auto change_spec = mir_connection_create_spec_for_changes(connection);
312+ mir_surface_spec_set_streams(change_spec, infos.data(), infos.size());
313+ mir_surface_apply_spec(surface, change_spec);
314+ mir_surface_spec_release(change_spec);
315+
316+ EXPECT_THAT(mir_surface_get_buffer_stream(surface), Eq(nullptr));
317+}
318
319=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
320--- tests/unit-tests/client/test_client_mir_surface.cpp 2016-05-03 06:55:25 +0000
321+++ tests/unit-tests/client/test_client_mir_surface.cpp 2016-06-08 13:06:12 +0000
322@@ -542,3 +542,27 @@
323 surface.handle_event(*ev);
324 surface_map->erase(mir::frontend::BufferStreamId(2));
325 }
326+
327+TEST_F(MirClientSurfaceTest, parameters_are_unhooked_from_stream_sizes)
328+{
329+ using namespace testing;
330+ auto mock_stream = std::make_shared<mtd::MockClientBufferStream>();
331+ auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
332+ ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
333+ .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
334+ ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mir::frontend::BufferStreamId(2)));
335+ geom::Size size(120, 124);
336+ EXPECT_CALL(*mock_stream, set_size(size));
337+ auto ev = mir::events::make_event(mir::frontend::SurfaceId(2), size);
338+
339+ MirSurface surface{connection.get(), *client_comm_channel, nullptr,
340+ mock_stream, mock_input_platform, spec, surface_proto, wh};
341+
342+ auto params = surface.get_parameters();
343+ EXPECT_THAT(params.width, Eq(spec.width.value()));
344+ EXPECT_THAT(params.height, Eq(spec.height.value()));
345+ surface.handle_event(*ev);
346+ params = surface.get_parameters();
347+ EXPECT_THAT(params.width, Eq(size.width.as_int()));
348+ EXPECT_THAT(params.height, Eq(size.height.as_int()));
349+}

Subscribers

People subscribed via source and target branches