Merge lp:~kdub/mir/require-streams-when-creating-surface into lp:mir
- require-streams-when-creating-surface
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3453 |
Proposed branch: | lp:~kdub/mir/require-streams-when-creating-surface |
Merge into: | lp:mir |
Prerequisite: | lp:~kdub/mir/deprecate-next-buffer |
Diff against target: |
1228 lines (+343/-184) 16 files modified
examples/server_example_canonical_window_manager.cpp (+9/-3) examples/server_example_window_management_info.h (+1/-0) include/server/mir/scene/surface_creation_parameters.h (+1/-0) src/client/mir_connection.cpp (+17/-1) src/protobuf/mir_protobuf.proto (+1/-0) src/server/frontend/buffer_stream_tracker.cpp (+24/-0) src/server/frontend/buffer_stream_tracker.h (+7/-0) src/server/frontend/session_mediator.cpp (+66/-18) src/server/scene/application_session.cpp (+31/-27) src/server/scene/application_session.h (+2/-0) tests/integration-tests/session_management.cpp (+7/-2) tests/integration-tests/test_session.cpp (+5/-1) tests/unit-tests/frontend/test_session_mediator.cpp (+40/-56) tests/unit-tests/scene/test_abstract_shell.cpp (+47/-21) tests/unit-tests/scene/test_application_session.cpp (+80/-54) tests/unit-tests/scene/test_session_manager.cpp (+5/-1) |
To merge this branch: | bzr merge lp:~kdub/mir/require-streams-when-creating-surface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Approve | |
Andreas Pokorny (community) | Approve | ||
Cemil Azizoglu (community) | Approve | ||
Brandon Schaefer (community) | Approve | ||
Review via email: mp+290484@code.launchpad.net |
Commit message
shell: no longer auto-create a 'default stream' on behalf of user creating a surface without specifying a stream. Session:
Now, BufferStreamId and SurfaceId are independent id sequences (whereas previously, every SurfaceId was a BufferStreamId, but not vice-versa)
We got into the situation where create_surface() creates a stream and a surface when we split the stream concept from the surface concept a long time ago. Now that we want to create more elaborate stream configurations at startup (see lp: #1563278), we should just have the user tell us what they want via SurfaceCreation
Its currently necessary to have some content with a Surface (due to existing interfaces that need changing), but soon enough we could probably have content-less surfaces, if that's useful anywhere...
Downstreams (usc/qtmir) are not using Session to create their own surfaces apart from actual ipc clients, so although its an ABI break, they should be compatible.
Description of the change
shell: no longer auto-create a 'default stream' on behalf of user creating a surface without specifying a stream. Session:
We got into the situation where create_surface() creates a stream and a surface when we split the stream concept from the surface concept a long time ago. Now that we want to create more elaborate stream configurations at startup (see lp: #1563278), we should just have the user tell us what they want via SurfaceCreation
Its currently necessary to have some content with a Surface (due to existing interfaces that need changing), but soon enough we could probably have content-less surfaces, if that's useful anywhere...
Downstreams (usc/qtmir) are not using Session to create their own surfaces apart from actual ipc clients, so although its an ABI break, they should be compatible.
Mir CI Bot (mir-ci-bot) wrote : | # |
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3441
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3442
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Kevin DuBois (kdub) wrote : | # |
conflict
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3443
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Brandon Schaefer (brandontschaefer) wrote : | # |
Nit. Couldnt a_surface() take a mir::graphics:
+ auto params = ms::a_surface()
Dont see this namespace used in the header.
+class Session;
Shared ptr are defaulted to a nullptr, no need to set it.
+ std::shared_
// /usr/include/
_
: _M_ptr(0), _M_refcount() // never throws
{ }
This could be a bit simpler, as you have right now:
!(A || (B && C))
This could turn into:
!A && (B || C)
(wanted to do a truth table just to check haha: http://
Not super sure if its *simpler* just reads a bit easier :)
+ if (!((the_
+ (the_params.
Would turn into:
if (!the_params.
Up to you :)
Kevin DuBois (kdub) wrote : | # |
> Nit. Couldnt a_surface() take a mir::graphics:
> all the same arguments in both. Such as of_buffer_
> something... though either way we have to use those values twice :)
> + auto params = ms::a_surface()
>
Surfaces don't really have pixel_format and usage, these are really just properties of buffers. (although surfaces do have pf/usage fields still from un-cleaned-up cruft).
> Dont see this namespace used in the header.
> +class Session;
This is needed in the remove_
> Shared ptr are defaulted to a nullptr, no need to set it.
> + std::shared_
>
> // /usr/include/
> __shared_ptr()
> : _M_ptr(0), _M_refcount() // never throws
> { }
fixed
> This could be a bit simpler, as you have right now:
> !(A || (B && C))
> This could turn into:
> !A && (B || C)
>
> (wanted to do a truth table just to check haha:
> http://
>
> Not super sure if its *simpler* just reads a bit easier :)
>
Line 6 in the pastebin isn't correct. (the original expression is not computed correctly, the new expression is)
The expression could be reduced I suppose:
!(A || (B && C))
to
!A && !(B && C)
to
!A && (!B || !C)
Brandon Schaefer (brandontschaefer) wrote : | # |
Opps youre right! (Dang truth table :).
LGTM
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
The name added_streams is a bit confusing since streams may later be removed as well. How about just calling it 'streams'.
180 + std::unordered_
-------------------
We should just call them add_buffer_
170 + void add_content_
171 + void remove_
Andreas Pokorny (andreas-pokorny) wrote : | # |
Hm. Why does the BufferStream Tracker care about the frontend::Session in the remove_content_for method. It seems unbalanced in comparison to the add call. Correct me if I got the wrong picture..
Otherwise it looks fine
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3445
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Andreas Pokorny (andreas-pokorny) wrote : | # |
Ok my needs info is gone ..
Kevin DuBois (kdub) wrote : | # |
noticed that (for consistency's sake) we should throw when trying to delete a bufferstream that doesnt exist. will fix in this MP before TA.
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3447
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Alan Griffiths (alan-griffiths) wrote : | # |
I've a feeling this has been seen before, but I can't find the bug...
14:41:46 11: /��BUILDDIR�
14:41:46 11: Value of: client_
14:41:46 11: Actual: false
14:41:46 11: Expected: true
14:41:46 11: [2016-04-12 14:41:46.324381] mirserver: Stopping
14:41:46 11: [2016-04-12 14:41:46.602429] mirserver: Stopping
14:41:46 11: [ FAILED ] NestedServer.
Mir CI Bot (mir-ci-bot) : | # |
Preview Diff
1 | === modified file 'examples/server_example_canonical_window_manager.cpp' | |||
2 | --- examples/server_example_canonical_window_manager.cpp 2016-04-05 11:59:12 +0000 | |||
3 | +++ examples/server_example_canonical_window_manager.cpp 2016-04-12 14:23:09 +0000 | |||
4 | @@ -251,13 +251,17 @@ | |||
5 | 251 | return; | 251 | return; |
6 | 252 | 252 | ||
7 | 253 | auto format = mir_pixel_format_xrgb_8888; | 253 | auto format = mir_pixel_format_xrgb_8888; |
10 | 254 | ms::SurfaceCreationParameters params; | 254 | mir::graphics::BufferProperties properties(titlebar_size_for_window(surface->size()), |
11 | 255 | params.of_size(titlebar_size_for_window(surface->size())) | 255 | format, mir::graphics::BufferUsage::software); |
12 | 256 | auto stream_id = session->create_buffer_stream(properties); | ||
13 | 257 | auto params = ms::a_surface() | ||
14 | 258 | .of_size(titlebar_size_for_window(surface->size())) | ||
15 | 256 | .of_name("decoration") | 259 | .of_name("decoration") |
16 | 257 | .of_pixel_format(format) | 260 | .of_pixel_format(format) |
17 | 258 | .of_buffer_usage(mir::graphics::BufferUsage::software) | 261 | .of_buffer_usage(mir::graphics::BufferUsage::software) |
18 | 259 | .of_position(titlebar_position_for_window(surface->top_left())) | 262 | .of_position(titlebar_position_for_window(surface->top_left())) |
20 | 260 | .of_type(mir_surface_type_gloss); | 263 | .of_type(mir_surface_type_gloss) |
21 | 264 | .with_buffer_stream(stream_id); | ||
22 | 261 | auto id = build(session, params); | 265 | auto id = build(session, params); |
23 | 262 | auto titlebar = session->surface(id); | 266 | auto titlebar = session->surface(id); |
24 | 263 | titlebar->set_alpha(0.9); | 267 | titlebar->set_alpha(0.9); |
25 | @@ -265,6 +269,7 @@ | |||
26 | 265 | auto& surface_info = tools->info_for(surface); | 269 | auto& surface_info = tools->info_for(surface); |
27 | 266 | surface_info.titlebar = titlebar; | 270 | surface_info.titlebar = titlebar; |
28 | 267 | surface_info.titlebar_id = id; | 271 | surface_info.titlebar_id = id; |
29 | 272 | surface_info.titlebar_stream_id = stream_id; | ||
30 | 268 | surface_info.children.push_back(titlebar); | 273 | surface_info.children.push_back(titlebar); |
31 | 269 | 274 | ||
32 | 270 | SurfaceInfo& titlebar_info = | 275 | SurfaceInfo& titlebar_info = |
33 | @@ -437,6 +442,7 @@ | |||
34 | 437 | if (info.titlebar) | 442 | if (info.titlebar) |
35 | 438 | { | 443 | { |
36 | 439 | session->destroy_surface(info.titlebar_id); | 444 | session->destroy_surface(info.titlebar_id); |
37 | 445 | session->destroy_buffer_stream(info.titlebar_stream_id); | ||
38 | 440 | tools->forget(info.titlebar); | 446 | tools->forget(info.titlebar); |
39 | 441 | } | 447 | } |
40 | 442 | 448 | ||
41 | 443 | 449 | ||
42 | === modified file 'examples/server_example_window_management_info.h' | |||
43 | --- examples/server_example_window_management_info.h 2016-01-29 08:18:22 +0000 | |||
44 | +++ examples/server_example_window_management_info.h 2016-04-12 14:23:09 +0000 | |||
45 | @@ -65,6 +65,7 @@ | |||
46 | 65 | std::vector <std::weak_ptr<scene::Surface>> children; | 65 | std::vector <std::weak_ptr<scene::Surface>> children; |
47 | 66 | std::shared_ptr <scene::Surface> titlebar; | 66 | std::shared_ptr <scene::Surface> titlebar; |
48 | 67 | frontend::SurfaceId titlebar_id; | 67 | frontend::SurfaceId titlebar_id; |
49 | 68 | frontend::BufferStreamId titlebar_stream_id; | ||
50 | 68 | bool is_titlebar = false; | 69 | bool is_titlebar = false; |
51 | 69 | geometry::Width min_width; | 70 | geometry::Width min_width; |
52 | 70 | geometry::Height min_height; | 71 | geometry::Height min_height; |
53 | 71 | 72 | ||
54 | === modified file 'include/server/mir/scene/surface_creation_parameters.h' | |||
55 | --- include/server/mir/scene/surface_creation_parameters.h 2016-01-29 08:18:22 +0000 | |||
56 | +++ include/server/mir/scene/surface_creation_parameters.h 2016-04-12 14:23:09 +0000 | |||
57 | @@ -101,6 +101,7 @@ | |||
58 | 101 | 101 | ||
59 | 102 | mir::optional_value<std::vector<geometry::Rectangle>> input_shape; | 102 | mir::optional_value<std::vector<geometry::Rectangle>> input_shape; |
60 | 103 | mir::optional_value<MirShellChrome> shell_chrome; | 103 | mir::optional_value<MirShellChrome> shell_chrome; |
61 | 104 | mir::optional_value<std::vector<shell::StreamSpecification>> streams; | ||
62 | 104 | }; | 105 | }; |
63 | 105 | 106 | ||
64 | 106 | bool operator==(const SurfaceCreationParameters& lhs, const SurfaceCreationParameters& rhs); | 107 | bool operator==(const SurfaceCreationParameters& lhs, const SurfaceCreationParameters& rhs); |
65 | 107 | 108 | ||
66 | === modified file 'src/client/mir_connection.cpp' | |||
67 | --- src/client/mir_connection.cpp 2016-03-23 06:39:56 +0000 | |||
68 | +++ src/client/mir_connection.cpp 2016-04-12 14:23:09 +0000 | |||
69 | @@ -172,6 +172,22 @@ | |||
70 | 172 | } | 172 | } |
71 | 173 | } | 173 | } |
72 | 174 | 174 | ||
73 | 175 | if (spec.streams.is_set()) | ||
74 | 176 | { | ||
75 | 177 | for(auto const& stream : spec.streams.value()) | ||
76 | 178 | { | ||
77 | 179 | auto const new_stream = message.add_stream(); | ||
78 | 180 | new_stream->set_displacement_x(stream.displacement.dx.as_int()); | ||
79 | 181 | new_stream->set_displacement_y(stream.displacement.dy.as_int()); | ||
80 | 182 | new_stream->mutable_id()->set_value(stream.stream_id); | ||
81 | 183 | if (stream.size.is_set()) | ||
82 | 184 | { | ||
83 | 185 | new_stream->set_width(stream.size.value().width.as_int()); | ||
84 | 186 | new_stream->set_height(stream.size.value().height.as_int()); | ||
85 | 187 | } | ||
86 | 188 | } | ||
87 | 189 | } | ||
88 | 190 | |||
89 | 175 | return message; | 191 | return message; |
90 | 176 | } | 192 | } |
91 | 177 | 193 | ||
92 | @@ -400,7 +416,7 @@ | |||
93 | 400 | this, server, &debug, stream, input_platform, spec, *surface_proto, request->wh); | 416 | this, server, &debug, stream, input_platform, spec, *surface_proto, request->wh); |
94 | 401 | 417 | ||
95 | 402 | surface_map->insert(mf::SurfaceId{surface_proto->id().value()}, surf); | 418 | surface_map->insert(mf::SurfaceId{surface_proto->id().value()}, surf); |
97 | 403 | surface_map->insert(mf::BufferStreamId{surface_proto->id().value()}, stream); | 419 | surface_map->insert(mf::BufferStreamId{surface_proto->buffer_stream().id().value()}, stream); |
98 | 404 | } | 420 | } |
99 | 405 | 421 | ||
100 | 406 | callback(surf.get(), context); | 422 | callback(surf.get(), context); |
101 | 407 | 423 | ||
102 | === modified file 'src/protobuf/mir_protobuf.proto' | |||
103 | --- src/protobuf/mir_protobuf.proto 2016-03-23 06:39:56 +0000 | |||
104 | +++ src/protobuf/mir_protobuf.proto 2016-04-12 14:23:09 +0000 | |||
105 | @@ -39,6 +39,7 @@ | |||
106 | 39 | optional PersistentSurfaceId parent_persistent_id = 21; | 39 | optional PersistentSurfaceId parent_persistent_id = 21; |
107 | 40 | repeated Rectangle input_shape = 22; | 40 | repeated Rectangle input_shape = 22; |
108 | 41 | optional int32 shell_chrome = 24; | 41 | optional int32 shell_chrome = 24; |
109 | 42 | repeated StreamConfiguration stream = 25; | ||
110 | 42 | } | 43 | } |
111 | 43 | 44 | ||
112 | 44 | message SurfaceAspectRatio | 45 | message SurfaceAspectRatio |
113 | 45 | 46 | ||
114 | === modified file 'src/server/frontend/buffer_stream_tracker.cpp' | |||
115 | --- src/server/frontend/buffer_stream_tracker.cpp 2015-06-17 05:20:42 +0000 | |||
116 | +++ src/server/frontend/buffer_stream_tracker.cpp 2016-04-12 14:23:09 +0000 | |||
117 | @@ -21,6 +21,7 @@ | |||
118 | 21 | 21 | ||
119 | 22 | #include "mir/graphics/buffer.h" | 22 | #include "mir/graphics/buffer.h" |
120 | 23 | #include "mir/graphics/buffer_id.h" | 23 | #include "mir/graphics/buffer_id.h" |
121 | 24 | #include "mir/frontend/session.h" | ||
122 | 24 | 25 | ||
123 | 25 | #include <boost/throw_exception.hpp> | 26 | #include <boost/throw_exception.hpp> |
124 | 26 | #include <stdexcept> | 27 | #include <stdexcept> |
125 | @@ -93,3 +94,26 @@ | |||
126 | 93 | } | 94 | } |
127 | 94 | BOOST_THROW_EXCEPTION(std::logic_error("Buffer is not tracked")); | 95 | BOOST_THROW_EXCEPTION(std::logic_error("Buffer is not tracked")); |
128 | 95 | } | 96 | } |
129 | 97 | |||
130 | 98 | void mf::BufferStreamTracker::set_default_stream(mf::SurfaceId id, mf::BufferStreamId content) | ||
131 | 99 | { | ||
132 | 100 | std::lock_guard<decltype(mutex)> lock{mutex}; | ||
133 | 101 | default_streams[id] = content; | ||
134 | 102 | } | ||
135 | 103 | |||
136 | 104 | mir::optional_value<mf::BufferStreamId> mf::BufferStreamTracker::default_stream(mf::SurfaceId id) | ||
137 | 105 | { | ||
138 | 106 | std::lock_guard<decltype(mutex)> lock{mutex}; | ||
139 | 107 | auto it = default_streams.find(id); | ||
140 | 108 | if (it != default_streams.end()) | ||
141 | 109 | return it->second; | ||
142 | 110 | return {}; | ||
143 | 111 | } | ||
144 | 112 | |||
145 | 113 | void mf::BufferStreamTracker::remove_default_stream(mf::SurfaceId id) | ||
146 | 114 | { | ||
147 | 115 | std::lock_guard<decltype(mutex)> lock{mutex}; | ||
148 | 116 | auto it = default_streams.find(id); | ||
149 | 117 | if (it != default_streams.end()) | ||
150 | 118 | default_streams.erase(it); | ||
151 | 119 | } | ||
152 | 96 | 120 | ||
153 | === modified file 'src/server/frontend/buffer_stream_tracker.h' | |||
154 | --- src/server/frontend/buffer_stream_tracker.h 2015-06-17 05:20:42 +0000 | |||
155 | +++ src/server/frontend/buffer_stream_tracker.h 2016-04-12 14:23:09 +0000 | |||
156 | @@ -19,8 +19,10 @@ | |||
157 | 19 | #ifndef MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_ | 19 | #ifndef MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_ |
158 | 20 | #define MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_ | 20 | #define MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_ |
159 | 21 | 21 | ||
160 | 22 | #include "mir/frontend/surface_id.h" | ||
161 | 22 | #include "mir/frontend/buffer_stream_id.h" | 23 | #include "mir/frontend/buffer_stream_id.h" |
162 | 23 | #include "mir/graphics/buffer_id.h" | 24 | #include "mir/graphics/buffer_id.h" |
163 | 25 | #include "mir/optional_value.h" | ||
164 | 24 | 26 | ||
165 | 25 | #include <unordered_map> | 27 | #include <unordered_map> |
166 | 26 | #include <memory> | 28 | #include <memory> |
167 | @@ -56,6 +58,10 @@ | |||
168 | 56 | /* Access the buffer resource that the id corresponds to. */ | 58 | /* Access the buffer resource that the id corresponds to. */ |
169 | 57 | graphics::Buffer* buffer_from(graphics::BufferID) const; | 59 | graphics::Buffer* buffer_from(graphics::BufferID) const; |
170 | 58 | 60 | ||
171 | 61 | void set_default_stream(frontend::SurfaceId id, frontend::BufferStreamId); | ||
172 | 62 | optional_value<BufferStreamId> default_stream(SurfaceId id); | ||
173 | 63 | void remove_default_stream(frontend::SurfaceId); | ||
174 | 64 | |||
175 | 59 | private: | 65 | private: |
176 | 60 | size_t const client_cache_size; | 66 | size_t const client_cache_size; |
177 | 61 | std::unordered_map<BufferStreamId, std::shared_ptr<ClientBufferTracker>> client_buffer_tracker; | 67 | std::unordered_map<BufferStreamId, std::shared_ptr<ClientBufferTracker>> client_buffer_tracker; |
178 | @@ -67,6 +73,7 @@ | |||
179 | 67 | private: | 73 | private: |
180 | 68 | mutable std::mutex mutex; | 74 | mutable std::mutex mutex; |
181 | 69 | std::unordered_map<BufferStreamId, graphics::Buffer*> client_buffer_resource; | 75 | std::unordered_map<BufferStreamId, graphics::Buffer*> client_buffer_resource; |
182 | 76 | std::unordered_map<SurfaceId, frontend::BufferStreamId> default_streams; | ||
183 | 70 | }; | 77 | }; |
184 | 71 | 78 | ||
185 | 72 | } | 79 | } |
186 | 73 | 80 | ||
187 | === modified file 'src/server/frontend/session_mediator.cpp' | |||
188 | --- src/server/frontend/session_mediator.cpp 2016-04-05 03:47:49 +0000 | |||
189 | +++ src/server/frontend/session_mediator.cpp 2016-04-12 14:23:09 +0000 | |||
190 | @@ -286,6 +286,40 @@ | |||
191 | 286 | 286 | ||
192 | 287 | #undef COPY_IF_SET | 287 | #undef COPY_IF_SET |
193 | 288 | 288 | ||
194 | 289 | mf::BufferStreamId buffer_stream_id; | ||
195 | 290 | std::shared_ptr<mf::BufferStream> legacy_stream = nullptr; | ||
196 | 291 | if (request->stream_size() > 0) | ||
197 | 292 | { | ||
198 | 293 | std::vector<msh::StreamSpecification> stream_spec; | ||
199 | 294 | for (auto& stream : request->stream()) | ||
200 | 295 | { | ||
201 | 296 | if (stream.has_width() && stream.has_height()) | ||
202 | 297 | { | ||
203 | 298 | stream_spec.emplace_back( | ||
204 | 299 | msh::StreamSpecification{ | ||
205 | 300 | mf::BufferStreamId{stream.id().value()}, | ||
206 | 301 | geom::Displacement{stream.displacement_x(), stream.displacement_y()}, | ||
207 | 302 | geom::Size{stream.width(), stream.height()}}); | ||
208 | 303 | } | ||
209 | 304 | else | ||
210 | 305 | { | ||
211 | 306 | stream_spec.emplace_back( | ||
212 | 307 | msh::StreamSpecification{ | ||
213 | 308 | mf::BufferStreamId{stream.id().value()}, | ||
214 | 309 | geom::Displacement{stream.displacement_x(), stream.displacement_y()}, | ||
215 | 310 | {}}); | ||
216 | 311 | } | ||
217 | 312 | } | ||
218 | 313 | params.streams = std::move(stream_spec); | ||
219 | 314 | } | ||
220 | 315 | else | ||
221 | 316 | { | ||
222 | 317 | buffer_stream_id = session->create_buffer_stream( | ||
223 | 318 | {params.size, params.pixel_format, params.buffer_usage}); | ||
224 | 319 | legacy_stream = session->get_buffer_stream(buffer_stream_id); | ||
225 | 320 | params.content_id = buffer_stream_id; | ||
226 | 321 | } | ||
227 | 322 | |||
228 | 289 | if (request->has_min_aspect()) | 323 | if (request->has_min_aspect()) |
229 | 290 | params.min_aspect = { request->min_aspect().width(), request->min_aspect().height()}; | 324 | params.min_aspect = { request->min_aspect().width(), request->min_aspect().height()}; |
230 | 291 | 325 | ||
231 | @@ -298,10 +332,9 @@ | |||
232 | 298 | std::shared_ptr<mf::EventSink> sink = sink_factory->create_sink(buffering_sender); | 332 | std::shared_ptr<mf::EventSink> sink = sink_factory->create_sink(buffering_sender); |
233 | 299 | 333 | ||
234 | 300 | auto const surf_id = shell->create_surface(session, params, sink); | 334 | auto const surf_id = shell->create_surface(session, params, sink); |
235 | 301 | auto stream_id = mf::BufferStreamId(surf_id.as_value()); | ||
236 | 302 | 335 | ||
237 | 303 | auto surface = session->get_surface(surf_id); | 336 | auto surface = session->get_surface(surf_id); |
239 | 304 | auto stream = session->get_buffer_stream(stream_id); | 337 | auto stream = session->get_buffer_stream(buffer_stream_id); |
240 | 305 | auto const& client_size = surface->client_size(); | 338 | auto const& client_size = surface->client_size(); |
241 | 306 | response->mutable_id()->set_value(surf_id.as_value()); | 339 | response->mutable_id()->set_value(surf_id.as_value()); |
242 | 307 | response->set_width(client_size.width.as_uint32_t()); | 340 | response->set_width(client_size.width.as_uint32_t()); |
243 | @@ -326,21 +359,29 @@ | |||
244 | 326 | setting->set_ivalue(shell->get_surface_attribute(session, surf_id, static_cast<MirSurfaceAttrib>(i))); | 359 | setting->set_ivalue(shell->get_surface_attribute(session, surf_id, static_cast<MirSurfaceAttrib>(i))); |
245 | 327 | } | 360 | } |
246 | 328 | 361 | ||
262 | 329 | advance_buffer(stream_id, *stream, buffer_stream_tracker.last_buffer(stream_id), | 362 | if (legacy_stream) |
263 | 330 | [this, buffering_sender, surf_id, response, done, session] | 363 | { |
264 | 331 | (graphics::Buffer* client_buffer, graphics::BufferIpcMsgType msg_type) | 364 | buffer_stream_tracker.set_default_stream(surf_id, buffer_stream_id); |
265 | 332 | { | 365 | response->mutable_buffer_stream()->mutable_id()->set_value(buffer_stream_id.as_value()); |
266 | 333 | response->mutable_buffer_stream()->mutable_id()->set_value(surf_id.as_value()); | 366 | advance_buffer(buffer_stream_id, *legacy_stream, buffer_stream_tracker.last_buffer(buffer_stream_id), |
267 | 334 | if (client_buffer) | 367 | [this, buffering_sender, response, done, session] |
268 | 335 | pack_protobuf_buffer(*response->mutable_buffer_stream()->mutable_buffer(), client_buffer, msg_type); | 368 | (graphics::Buffer* client_buffer, graphics::BufferIpcMsgType msg_type) |
269 | 336 | 369 | { | |
270 | 337 | 370 | if (client_buffer) | |
271 | 338 | // Send the create_surface reply first... | 371 | pack_protobuf_buffer(*response->mutable_buffer_stream()->mutable_buffer(), client_buffer, msg_type); |
272 | 339 | done->Run(); | 372 | |
273 | 340 | 373 | // Send the create_surface reply first... | |
274 | 341 | // ...then uncork the message sender, sending all buffered surface events. | 374 | done->Run(); |
275 | 342 | buffering_sender->uncork(); | 375 | |
276 | 343 | }); | 376 | // ...then uncork the message sender, sending all buffered surface events. |
277 | 377 | buffering_sender->uncork(); | ||
278 | 378 | }); | ||
279 | 379 | } | ||
280 | 380 | else | ||
281 | 381 | { | ||
282 | 382 | done->Run(); | ||
283 | 383 | buffering_sender->uncork(); | ||
284 | 384 | } | ||
285 | 344 | } | 385 | } |
286 | 345 | 386 | ||
287 | 346 | void mf::SessionMediator::exchange_buffer( | 387 | void mf::SessionMediator::exchange_buffer( |
288 | @@ -469,7 +510,14 @@ | |||
289 | 469 | auto const id = SurfaceId(request->value()); | 510 | auto const id = SurfaceId(request->value()); |
290 | 470 | 511 | ||
291 | 471 | shell->destroy_surface(session, id); | 512 | shell->destroy_surface(session, id); |
293 | 472 | buffer_stream_tracker.remove_buffer_stream(BufferStreamId(request->value())); | 513 | |
294 | 514 | auto default_stream = buffer_stream_tracker.default_stream(id); | ||
295 | 515 | if (default_stream.is_set()) | ||
296 | 516 | { | ||
297 | 517 | session->destroy_buffer_stream(default_stream.value()); | ||
298 | 518 | buffer_stream_tracker.remove_buffer_stream(default_stream.value()); | ||
299 | 519 | buffer_stream_tracker.remove_default_stream(id); | ||
300 | 520 | } | ||
301 | 473 | 521 | ||
302 | 474 | // TODO: We rely on this sending responses synchronously. | 522 | // TODO: We rely on this sending responses synchronously. |
303 | 475 | done->Run(); | 523 | done->Run(); |
304 | 476 | 524 | ||
305 | === modified file 'src/server/scene/application_session.cpp' | |||
306 | --- src/server/scene/application_session.cpp 2016-04-06 08:44:01 +0000 | |||
307 | +++ src/server/scene/application_session.cpp 2016-04-12 14:23:09 +0000 | |||
308 | @@ -90,27 +90,31 @@ | |||
309 | 90 | std::shared_ptr<mf::EventSink> const& surface_sink) | 90 | std::shared_ptr<mf::EventSink> const& surface_sink) |
310 | 91 | { | 91 | { |
311 | 92 | auto const id = next_id(); | 92 | auto const id = next_id(); |
314 | 93 | mf::BufferStreamId const stream_id{the_params.content_id.is_set() ? | 93 | |
315 | 94 | the_params.content_id.value().as_value() : id.as_value()}; | 94 | //TODO: we take either the content_id or the first streams content for now. |
316 | 95 | // Once the surface factory interface takes more than one stream, | ||
317 | 96 | // we can take all the streams as content. | ||
318 | 97 | if (!((the_params.content_id.is_set()) || | ||
319 | 98 | (the_params.streams.is_set() && the_params.streams.value().size() > 0))) | ||
320 | 99 | { | ||
321 | 100 | BOOST_THROW_EXCEPTION(std::logic_error("surface must have content")); | ||
322 | 101 | } | ||
323 | 95 | 102 | ||
324 | 96 | auto params = the_params; | 103 | auto params = the_params; |
325 | 97 | 104 | ||
326 | 105 | mf::BufferStreamId stream_id; | ||
327 | 106 | if (params.content_id.is_set()) | ||
328 | 107 | stream_id = params.content_id.value(); | ||
329 | 108 | else | ||
330 | 109 | stream_id = params.streams.value()[0].stream_id; | ||
331 | 110 | |||
332 | 98 | if (params.parent_id.is_set()) | 111 | if (params.parent_id.is_set()) |
333 | 99 | params.parent = checked_find(the_params.parent_id.value())->second; | 112 | params.parent = checked_find(the_params.parent_id.value())->second; |
334 | 100 | 113 | ||
348 | 101 | std::shared_ptr<compositor::BufferStream> buffer_stream; | 114 | auto buffer_stream = checked_find(params.content_id.value())->second; |
349 | 102 | if (params.content_id.is_set()) | 115 | if (params.size != buffer_stream->stream_size()) |
350 | 103 | { | 116 | buffer_stream->resize(params.size); |
351 | 104 | buffer_stream = checked_find(params.content_id.value())->second; | 117 | |
339 | 105 | } | ||
340 | 106 | else | ||
341 | 107 | { | ||
342 | 108 | mg::BufferProperties buffer_properties{params.size, | ||
343 | 109 | params.pixel_format, | ||
344 | 110 | params.buffer_usage}; | ||
345 | 111 | buffer_stream = buffer_stream_factory->create_buffer_stream( | ||
346 | 112 | stream_id, surface_sink, buffer_properties); | ||
347 | 113 | } | ||
352 | 114 | auto surface = surface_factory->create_surface(buffer_stream, params); | 118 | auto surface = surface_factory->create_surface(buffer_stream, params); |
353 | 115 | surface_stack->add_surface(surface, params.input_mode); | 119 | surface_stack->add_surface(surface, params.input_mode); |
354 | 116 | 120 | ||
355 | @@ -133,7 +137,7 @@ | |||
356 | 133 | { | 137 | { |
357 | 134 | std::unique_lock<std::mutex> lock(surfaces_and_streams_mutex); | 138 | std::unique_lock<std::mutex> lock(surfaces_and_streams_mutex); |
358 | 135 | surfaces[id] = surface; | 139 | surfaces[id] = surface; |
360 | 136 | streams[stream_id] = buffer_stream; | 140 | default_content_map[id] = stream_id; |
361 | 137 | } | 141 | } |
362 | 138 | 142 | ||
363 | 139 | observer->moved_to(surface->top_left()); | 143 | observer->moved_to(surface->top_left()); |
364 | @@ -154,7 +158,7 @@ | |||
365 | 154 | { | 158 | { |
366 | 155 | auto p = streams.find(id); | 159 | auto p = streams.find(id); |
367 | 156 | if (p == streams.end()) | 160 | if (p == streams.end()) |
369 | 157 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid SurfaceId")); | 161 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid BufferStreamId")); |
370 | 158 | return p; | 162 | return p; |
371 | 159 | } | 163 | } |
372 | 160 | 164 | ||
373 | @@ -220,7 +224,7 @@ | |||
374 | 220 | { | 224 | { |
375 | 221 | if (default_surface() == surface_it.second) | 225 | if (default_surface() == surface_it.second) |
376 | 222 | { | 226 | { |
378 | 223 | auto id = mf::BufferStreamId(surface_it.first.as_value()); | 227 | auto id = default_content_map[surface_it.first]; |
379 | 224 | snapshot_strategy->take_snapshot_of(checked_find(id)->second, snapshot_taken); | 228 | snapshot_strategy->take_snapshot_of(checked_find(id)->second, snapshot_taken); |
380 | 225 | return; | 229 | return; |
381 | 226 | } | 230 | } |
382 | @@ -360,7 +364,12 @@ | |||
383 | 360 | void ms::ApplicationSession::destroy_buffer_stream(mf::BufferStreamId id) | 364 | void ms::ApplicationSession::destroy_buffer_stream(mf::BufferStreamId id) |
384 | 361 | { | 365 | { |
385 | 362 | std::unique_lock<std::mutex> lock(surfaces_and_streams_mutex); | 366 | std::unique_lock<std::mutex> lock(surfaces_and_streams_mutex); |
387 | 363 | streams.erase(checked_find(id)); | 367 | auto stream_it = streams.find(mir::frontend::BufferStreamId(id.as_value())); |
388 | 368 | if (stream_it == streams.end()) | ||
389 | 369 | BOOST_THROW_EXCEPTION(std::runtime_error("cannot destroy stream: Invalid BufferStreamId")); | ||
390 | 370 | |||
391 | 371 | stream_it->second->drop_outstanding_requests(); | ||
392 | 372 | streams.erase(stream_it); | ||
393 | 364 | } | 373 | } |
394 | 365 | 374 | ||
395 | 366 | void ms::ApplicationSession::configure_streams( | 375 | void ms::ApplicationSession::configure_streams( |
396 | @@ -391,17 +400,12 @@ | |||
397 | 391 | void ms::ApplicationSession::destroy_surface(std::unique_lock<std::mutex>& lock, Surfaces::const_iterator in_surfaces) | 400 | void ms::ApplicationSession::destroy_surface(std::unique_lock<std::mutex>& lock, Surfaces::const_iterator in_surfaces) |
398 | 392 | { | 401 | { |
399 | 393 | auto const surface = in_surfaces->second; | 402 | auto const surface = in_surfaces->second; |
402 | 394 | auto const id = in_surfaces->first; | 403 | auto it = default_content_map.find(in_surfaces->first); |
401 | 395 | |||
403 | 396 | session_listener->destroying_surface(*this, surface); | 404 | session_listener->destroying_surface(*this, surface); |
404 | 397 | surfaces.erase(in_surfaces); | 405 | surfaces.erase(in_surfaces); |
405 | 398 | 406 | ||
412 | 399 | auto stream_it = streams.find(mir::frontend::BufferStreamId(id.as_value())); | 407 | if (it != default_content_map.end()) |
413 | 400 | if (stream_it != streams.end()) | 408 | default_content_map.erase(it); |
408 | 401 | { | ||
409 | 402 | stream_it->second->drop_outstanding_requests(); | ||
410 | 403 | streams.erase(stream_it); | ||
411 | 404 | } | ||
414 | 405 | 409 | ||
415 | 406 | lock.unlock(); | 410 | lock.unlock(); |
416 | 407 | 411 | ||
417 | 408 | 412 | ||
418 | === modified file 'src/server/scene/application_session.h' | |||
419 | --- src/server/scene/application_session.h 2016-04-06 08:44:01 +0000 | |||
420 | +++ src/server/scene/application_session.h 2016-04-12 14:23:09 +0000 | |||
421 | @@ -126,6 +126,8 @@ | |||
422 | 126 | Surfaces surfaces; | 126 | Surfaces surfaces; |
423 | 127 | Streams streams; | 127 | Streams streams; |
424 | 128 | 128 | ||
425 | 129 | std::map<frontend::SurfaceId, frontend::BufferStreamId> default_content_map; | ||
426 | 130 | |||
427 | 129 | void destroy_surface(std::unique_lock<std::mutex>& lock, Surfaces::const_iterator in_surfaces); | 131 | void destroy_surface(std::unique_lock<std::mutex>& lock, Surfaces::const_iterator in_surfaces); |
428 | 130 | }; | 132 | }; |
429 | 131 | 133 | ||
430 | 132 | 134 | ||
431 | === modified file 'tests/integration-tests/session_management.cpp' | |||
432 | --- tests/integration-tests/session_management.cpp 2016-01-29 08:18:22 +0000 | |||
433 | +++ tests/integration-tests/session_management.cpp 2016-04-12 14:23:09 +0000 | |||
434 | @@ -95,8 +95,6 @@ | |||
435 | 95 | std::shared_ptr<mf::EventSink> const event_sink = std::make_shared<mtd::NullEventSink>(); | 95 | std::shared_ptr<mf::EventSink> const event_sink = std::make_shared<mtd::NullEventSink>(); |
436 | 96 | std::shared_ptr<mf::Shell> const session_manager = builder.the_frontend_shell(); | 96 | std::shared_ptr<mf::Shell> const session_manager = builder.the_frontend_shell(); |
437 | 97 | std::shared_ptr<TestSurfaceStack> const& test_surface_stack = builder.test_surface_stack; | 97 | std::shared_ptr<TestSurfaceStack> const& test_surface_stack = builder.test_surface_stack; |
438 | 98 | ms::SurfaceCreationParameters const params = ms::SurfaceCreationParameters().of_size(100,100).of_type(mir_surface_type_normal); | ||
439 | 99 | |||
440 | 100 | void SetUp() | 98 | void SetUp() |
441 | 101 | { | 99 | { |
442 | 102 | ASSERT_THAT(test_surface_stack, Ne(nullptr)); | 100 | ASSERT_THAT(test_surface_stack, Ne(nullptr)); |
443 | @@ -117,6 +115,13 @@ | |||
444 | 117 | { | 115 | { |
445 | 118 | auto const session = session_manager->open_session(0, __PRETTY_FUNCTION__, event_sink); | 116 | auto const session = session_manager->open_session(0, __PRETTY_FUNCTION__, event_sink); |
446 | 119 | 117 | ||
447 | 118 | mir::graphics::BufferProperties properties( | ||
448 | 119 | mir::geometry::Size{1,1}, mir_pixel_format_abgr_8888, mir::graphics::BufferUsage::software); | ||
449 | 120 | ms::SurfaceCreationParameters const params = ms::SurfaceCreationParameters() | ||
450 | 121 | .of_size(100,100) | ||
451 | 122 | .of_type(mir_surface_type_normal) | ||
452 | 123 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
453 | 124 | |||
454 | 120 | EXPECT_CALL(*test_surface_stack, add_surface(_,_)).Times(1); | 125 | EXPECT_CALL(*test_surface_stack, add_surface(_,_)).Times(1); |
455 | 121 | session_manager->create_surface(session, params, event_sink); | 126 | session_manager->create_surface(session, params, event_sink); |
456 | 122 | } | 127 | } |
457 | 123 | 128 | ||
458 | === modified file 'tests/integration-tests/test_session.cpp' | |||
459 | --- tests/integration-tests/test_session.cpp 2016-01-29 08:18:22 +0000 | |||
460 | +++ tests/integration-tests/test_session.cpp 2016-04-12 14:23:09 +0000 | |||
461 | @@ -126,7 +126,11 @@ | |||
462 | 126 | mtd::StubDisplayConfig{}, | 126 | mtd::StubDisplayConfig{}, |
463 | 127 | std::make_shared<mtd::NullEventSink>() | 127 | std::make_shared<mtd::NullEventSink>() |
464 | 128 | }; | 128 | }; |
466 | 129 | session.create_surface(ms::a_surface(), std::make_shared<mtd::NullEventSink>()); | 129 | |
467 | 130 | mg::BufferProperties properties(geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::software); | ||
468 | 131 | session.create_surface( | ||
469 | 132 | ms::a_surface().with_buffer_stream(session.create_buffer_stream(properties)), | ||
470 | 133 | std::make_shared<mtd::NullEventSink>()); | ||
471 | 130 | 134 | ||
472 | 131 | auto compositor = conf.the_compositor(); | 135 | auto compositor = conf.the_compositor(); |
473 | 132 | 136 | ||
474 | 133 | 137 | ||
475 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' | |||
476 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2016-04-05 03:47:49 +0000 | |||
477 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2016-04-12 14:23:09 +0000 | |||
478 | @@ -111,11 +111,6 @@ | |||
479 | 111 | class StubbedSession : public mtd::StubSession | 111 | class StubbedSession : public mtd::StubSession |
480 | 112 | { | 112 | { |
481 | 113 | public: | 113 | public: |
482 | 114 | StubbedSession() : | ||
483 | 115 | last_surface_id{0} | ||
484 | 116 | { | ||
485 | 117 | } | ||
486 | 118 | |||
487 | 119 | std::shared_ptr<mf::Surface> get_surface(mf::SurfaceId surface) const | 114 | std::shared_ptr<mf::Surface> get_surface(mf::SurfaceId surface) const |
488 | 120 | { | 115 | { |
489 | 121 | if (mock_surfaces.find(surface) == mock_surfaces.end()) | 116 | if (mock_surfaces.find(surface) == mock_surfaces.end()) |
490 | @@ -126,7 +121,7 @@ | |||
491 | 126 | std::shared_ptr<mf::BufferStream> get_buffer_stream(mf::BufferStreamId stream) const override | 121 | std::shared_ptr<mf::BufferStream> get_buffer_stream(mf::BufferStreamId stream) const override |
492 | 127 | { | 122 | { |
493 | 128 | if (mock_streams.find(stream) == mock_streams.end()) | 123 | if (mock_streams.find(stream) == mock_streams.end()) |
495 | 129 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid SurfaceId")); | 124 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid StreamId")); |
496 | 130 | return mock_streams.at(stream); | 125 | return mock_streams.at(stream); |
497 | 131 | } | 126 | } |
498 | 132 | 127 | ||
499 | @@ -137,43 +132,37 @@ | |||
500 | 137 | return mock_surfaces.at(id); | 132 | return mock_surfaces.at(id); |
501 | 138 | } | 133 | } |
502 | 139 | 134 | ||
504 | 140 | std::shared_ptr<mtd::MockBufferStream> mock_primary_stream_at(mf::SurfaceId id) | 135 | std::shared_ptr<mtd::MockBufferStream> mock_stream_at(mf::BufferStreamId id) |
505 | 141 | { | 136 | { |
509 | 142 | if (mock_surfaces.end() == mock_surfaces.find(id)) | 137 | if (mock_streams.end() == mock_streams.find(id)) |
510 | 143 | create_mock_surface(id); | 138 | return create_mock_stream(id); |
511 | 144 | return mock_streams.at(mf::BufferStreamId(id.as_value())); | 139 | return mock_streams.at(id); |
512 | 145 | } | 140 | } |
513 | 146 | 141 | ||
514 | 147 | std::shared_ptr<mtd::MockFrontendSurface> create_mock_surface(mf::SurfaceId id) | 142 | std::shared_ptr<mtd::MockFrontendSurface> create_mock_surface(mf::SurfaceId id) |
515 | 148 | { | 143 | { |
516 | 149 | using namespace testing; | 144 | using namespace testing; |
517 | 145 | mg::BufferProperties properties; | ||
518 | 146 | create_buffer_stream(properties); | ||
519 | 150 | auto surface = std::make_shared<testing::NiceMock<mtd::MockFrontendSurface>>(testing_client_input_fd); | 147 | auto surface = std::make_shared<testing::NiceMock<mtd::MockFrontendSurface>>(testing_client_input_fd); |
521 | 151 | auto stream = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); | 148 | mock_surfaces[id] = surface; |
522 | 149 | return surface; | ||
523 | 150 | } | ||
524 | 152 | 151 | ||
525 | 152 | std::shared_ptr<mtd::MockBufferStream> create_mock_stream(mf::BufferStreamId id) | ||
526 | 153 | { | ||
527 | 154 | mock_streams[id] = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); | ||
528 | 153 | auto buffer1 = std::make_shared<mtd::StubBuffer>(); | 155 | auto buffer1 = std::make_shared<mtd::StubBuffer>(); |
529 | 154 | auto buffer2 = std::make_shared<mtd::StubBuffer>(); | 156 | auto buffer2 = std::make_shared<mtd::StubBuffer>(); |
531 | 155 | ON_CALL(*stream, swap_buffers(testing::_,testing::_)) | 157 | ON_CALL(*mock_streams[id], swap_buffers(testing::_,testing::_)) |
532 | 156 | .WillByDefault(testing::Invoke( | 158 | .WillByDefault(testing::Invoke( |
533 | 157 | [buffer1, buffer2](mg::Buffer* b, std::function<void(mg::Buffer* new_buffer)> complete) | 159 | [buffer1, buffer2](mg::Buffer* b, std::function<void(mg::Buffer* new_buffer)> complete) |
534 | 158 | { | 160 | { |
535 | 159 | if ((!b) || (b == buffer1.get())) | 161 | if ((!b) || (b == buffer1.get())) |
536 | 160 | complete(buffer2.get()); | 162 | complete(buffer2.get()); |
537 | 161 | if (b == buffer2.get()) | 163 | if (b == buffer2.get()) |
539 | 162 | complete(buffer1.get()); | 164 | complete(buffer1.get()); |
540 | 163 | })); | 165 | })); |
541 | 164 | |||
542 | 165 | ON_CALL(*surface, primary_buffer_stream()) | ||
543 | 166 | .WillByDefault(Return(stream)); | ||
544 | 167 | |||
545 | 168 | |||
546 | 169 | mock_surfaces[id] = surface; | ||
547 | 170 | mock_streams[mf::BufferStreamId(id.as_value())] = stream; | ||
548 | 171 | return surface; | ||
549 | 172 | } | ||
550 | 173 | |||
551 | 174 | std::shared_ptr<mtd::MockBufferStream> create_mock_stream(mf::BufferStreamId id) | ||
552 | 175 | { | ||
553 | 176 | mock_streams[id] = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); | ||
554 | 177 | return mock_streams[id]; | 166 | return mock_streams[id]; |
555 | 178 | } | 167 | } |
556 | 179 | 168 | ||
557 | @@ -190,10 +179,10 @@ | |||
558 | 190 | 179 | ||
559 | 191 | mf::BufferStreamId create_buffer_stream(mg::BufferProperties const&) | 180 | mf::BufferStreamId create_buffer_stream(mg::BufferProperties const&) |
560 | 192 | { | 181 | { |
562 | 193 | mf::BufferStreamId id{last_surface_id}; | 182 | mf::BufferStreamId id{last_stream_id}; |
563 | 194 | if (mock_streams.end() == mock_streams.find(id)) | 183 | if (mock_streams.end() == mock_streams.find(id)) |
564 | 195 | create_mock_stream(id); | 184 | create_mock_stream(id); |
566 | 196 | last_surface_id++; | 185 | last_stream_id++; |
567 | 197 | return id; | 186 | return id; |
568 | 198 | } | 187 | } |
569 | 199 | 188 | ||
570 | @@ -205,7 +194,8 @@ | |||
571 | 205 | std::map<mf::BufferStreamId, std::shared_ptr<mtd::MockBufferStream>> mock_streams; | 194 | std::map<mf::BufferStreamId, std::shared_ptr<mtd::MockBufferStream>> mock_streams; |
572 | 206 | std::map<mf::SurfaceId, std::shared_ptr<mtd::MockFrontendSurface>> mock_surfaces; | 195 | std::map<mf::SurfaceId, std::shared_ptr<mtd::MockFrontendSurface>> mock_surfaces; |
573 | 207 | static int const testing_client_input_fd; | 196 | static int const testing_client_input_fd; |
575 | 208 | int last_surface_id; | 197 | int last_surface_id = 0; |
576 | 198 | int last_stream_id = 0; | ||
577 | 209 | }; | 199 | }; |
578 | 210 | 200 | ||
579 | 211 | int const StubbedSession::testing_client_input_fd{11}; | 201 | int const StubbedSession::testing_client_input_fd{11}; |
580 | @@ -298,6 +288,7 @@ | |||
581 | 298 | mp::Buffer buffer_response; | 288 | mp::Buffer buffer_response; |
582 | 299 | mp::BufferRequest buffer_request; | 289 | mp::BufferRequest buffer_request; |
583 | 300 | }; | 290 | }; |
584 | 291 | |||
585 | 301 | } | 292 | } |
586 | 302 | 293 | ||
587 | 303 | TEST_F(SessionMediator, disconnect_releases_session) | 294 | TEST_F(SessionMediator, disconnect_releases_session) |
588 | @@ -388,10 +379,6 @@ | |||
589 | 388 | }, std::logic_error); | 379 | }, std::logic_error); |
590 | 389 | 380 | ||
591 | 390 | EXPECT_THROW({ | 381 | EXPECT_THROW({ |
592 | 391 | mediator.exchange_buffer(&buffer_request, &buffer_response, null_callback.get()); | ||
593 | 392 | }, std::logic_error); | ||
594 | 393 | |||
595 | 394 | EXPECT_THROW({ | ||
596 | 395 | mediator.release_surface(&surface_id_request, nullptr, null_callback.get()); | 382 | mediator.release_surface(&surface_id_request, nullptr, null_callback.get()); |
597 | 396 | }, std::logic_error); | 383 | }, std::logic_error); |
598 | 397 | 384 | ||
599 | @@ -510,7 +497,7 @@ | |||
600 | 510 | mp::SurfaceParameters surface_request; | 497 | mp::SurfaceParameters surface_request; |
601 | 511 | mp::Surface surface_response; | 498 | mp::Surface surface_response; |
602 | 512 | 499 | ||
604 | 513 | auto stream1 = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 500 | auto stream1 = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
605 | 514 | ON_CALL(*stream1, swap_buffers(_,_)) | 501 | ON_CALL(*stream1, swap_buffers(_,_)) |
606 | 515 | .WillByDefault(InvokeArgument<1>(&buffer)); | 502 | .WillByDefault(InvokeArgument<1>(&buffer)); |
607 | 516 | 503 | ||
608 | @@ -653,7 +640,7 @@ | |||
609 | 653 | TEST_F(SessionMediator, exchange_buffer) | 640 | TEST_F(SessionMediator, exchange_buffer) |
610 | 654 | { | 641 | { |
611 | 655 | using namespace testing; | 642 | using namespace testing; |
613 | 656 | auto const& mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 643 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
614 | 657 | mp::Buffer exchanged_buffer; | 644 | mp::Buffer exchanged_buffer; |
615 | 658 | mtd::StubBuffer stub_buffer1; | 645 | mtd::StubBuffer stub_buffer1; |
616 | 659 | mtd::StubBuffer stub_buffer2; | 646 | mtd::StubBuffer stub_buffer2; |
617 | @@ -682,10 +669,10 @@ | |||
618 | 682 | { | 669 | { |
619 | 683 | using namespace testing; | 670 | using namespace testing; |
620 | 684 | mp::Buffer exchanged_buffer; | 671 | mp::Buffer exchanged_buffer; |
622 | 685 | mf::SurfaceId surf_id{0}; | 672 | mf::BufferStreamId stream_id{0}; |
623 | 686 | mtd::StubBuffer buffer1; | 673 | mtd::StubBuffer buffer1; |
624 | 687 | mtd::StubBuffer buffer2; | 674 | mtd::StubBuffer buffer2; |
626 | 688 | auto stream = stubbed_session->mock_primary_stream_at(surf_id); | 675 | auto stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
627 | 689 | ON_CALL(*stream, swap_buffers(nullptr,_)) | 676 | ON_CALL(*stream, swap_buffers(nullptr,_)) |
628 | 690 | .WillByDefault(InvokeArgument<1>(&buffer2)); | 677 | .WillByDefault(InvokeArgument<1>(&buffer2)); |
629 | 691 | ON_CALL(*stream, swap_buffers(&buffer1,_)) | 678 | ON_CALL(*stream, swap_buffers(&buffer1,_)) |
630 | @@ -732,7 +719,7 @@ | |||
631 | 732 | TEST_F(SessionMediator, exchange_buffer_throws_if_client_submits_bad_request) | 719 | TEST_F(SessionMediator, exchange_buffer_throws_if_client_submits_bad_request) |
632 | 733 | { | 720 | { |
633 | 734 | using namespace testing; | 721 | using namespace testing; |
635 | 735 | auto const& mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 722 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
636 | 736 | mp::Buffer exchanged_buffer; | 723 | mp::Buffer exchanged_buffer; |
637 | 737 | mtd::StubBuffer stub_buffer1; | 724 | mtd::StubBuffer stub_buffer1; |
638 | 738 | mtd::StubBuffer stub_buffer2; | 725 | mtd::StubBuffer stub_buffer2; |
639 | @@ -765,8 +752,8 @@ | |||
640 | 765 | mp::SurfaceParameters surface_request; | 752 | mp::SurfaceParameters surface_request; |
641 | 766 | mp::BufferRequest req1; | 753 | mp::BufferRequest req1; |
642 | 767 | mp::BufferRequest req2; | 754 | mp::BufferRequest req2; |
645 | 768 | auto const& mock_stream1 = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 755 | auto mock_stream1 = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
646 | 769 | auto const& mock_stream2 = stubbed_session->mock_primary_stream_at(mf::SurfaceId{1}); | 756 | auto mock_stream2 = stubbed_session->mock_stream_at(mf::BufferStreamId{2}); |
647 | 770 | Sequence seq; | 757 | Sequence seq; |
648 | 771 | EXPECT_CALL(*mock_stream1, swap_buffers(_,_)) | 758 | EXPECT_CALL(*mock_stream1, swap_buffers(_,_)) |
649 | 772 | .InSequence(seq); | 759 | .InSequence(seq); |
650 | @@ -780,10 +767,10 @@ | |||
651 | 780 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 767 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
652 | 781 | 768 | ||
653 | 782 | mediator.create_surface(&surface_request, &surface_response, null_callback.get()); | 769 | mediator.create_surface(&surface_request, &surface_response, null_callback.get()); |
655 | 783 | req1.mutable_id()->set_value(surface_response.id().value()); | 770 | req1.mutable_id()->set_value(surface_response.buffer_stream().id().value()); |
656 | 784 | *req1.mutable_buffer() = surface_response.buffer_stream().buffer(); | 771 | *req1.mutable_buffer() = surface_response.buffer_stream().buffer(); |
657 | 785 | mediator.create_surface(&surface_request, &surface_response, null_callback.get()); | 772 | mediator.create_surface(&surface_request, &surface_response, null_callback.get()); |
659 | 786 | req2.mutable_id()->set_value(surface_response.id().value()); | 773 | req2.mutable_id()->set_value(surface_response.buffer_stream().id().value()); |
660 | 787 | *req2.mutable_buffer() = surface_response.buffer_stream().buffer(); | 774 | *req2.mutable_buffer() = surface_response.buffer_stream().buffer(); |
661 | 788 | mediator.exchange_buffer(&req2, &buffer_response, null_callback.get()); | 775 | mediator.exchange_buffer(&req2, &buffer_response, null_callback.get()); |
662 | 789 | mediator.exchange_buffer(&req1, &buffer_response, null_callback.get()); | 776 | mediator.exchange_buffer(&req1, &buffer_response, null_callback.get()); |
663 | @@ -840,7 +827,7 @@ | |||
664 | 840 | TEST_F(SessionMediator, completes_exchange_buffer_when_completion_is_invoked_asynchronously_from_thread_that_initiated_exchange) | 827 | TEST_F(SessionMediator, completes_exchange_buffer_when_completion_is_invoked_asynchronously_from_thread_that_initiated_exchange) |
665 | 841 | { | 828 | { |
666 | 842 | using namespace testing; | 829 | using namespace testing; |
668 | 843 | auto const& mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 830 | auto const& mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
669 | 844 | mtd::StubBuffer stub_buffer1; | 831 | mtd::StubBuffer stub_buffer1; |
670 | 845 | mtd::StubBuffer stub_buffer2; | 832 | mtd::StubBuffer stub_buffer2; |
671 | 846 | std::function<void(mg::Buffer*)> completion_func; | 833 | std::function<void(mg::Buffer*)> completion_func; |
672 | @@ -954,7 +941,7 @@ | |||
673 | 954 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 941 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
674 | 955 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); | 942 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); |
675 | 956 | 943 | ||
677 | 957 | auto mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 944 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
678 | 958 | request.mutable_id()->set_value(surface_response.id().value()); | 945 | request.mutable_id()->set_value(surface_response.id().value()); |
679 | 959 | request.mutable_buffer()->set_buffer_id(buffer1->id().as_value()); | 946 | request.mutable_buffer()->set_buffer_id(buffer1->id().as_value()); |
680 | 960 | 947 | ||
681 | @@ -989,7 +976,7 @@ | |||
682 | 989 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 976 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
683 | 990 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); | 977 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); |
684 | 991 | 978 | ||
686 | 992 | auto mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 979 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
687 | 993 | EXPECT_CALL(*mock_stream, allocate_buffer(properties)) | 980 | EXPECT_CALL(*mock_stream, allocate_buffer(properties)) |
688 | 994 | .Times(num_requests) | 981 | .Times(num_requests) |
689 | 995 | .WillRepeatedly(Return(mg::BufferID{})); | 982 | .WillRepeatedly(Return(mg::BufferID{})); |
690 | @@ -1016,7 +1003,7 @@ | |||
691 | 1016 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 1003 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
692 | 1017 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); | 1004 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); |
693 | 1018 | 1005 | ||
695 | 1019 | auto mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 1006 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
696 | 1020 | EXPECT_CALL(*mock_stream, remove_buffer(mg::BufferID{buffer_id})) | 1007 | EXPECT_CALL(*mock_stream, remove_buffer(mg::BufferID{buffer_id})) |
697 | 1021 | .Times(num_requests); | 1008 | .Times(num_requests); |
698 | 1022 | 1009 | ||
699 | @@ -1026,7 +1013,7 @@ | |||
700 | 1026 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_submit) | 1013 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_submit) |
701 | 1027 | { | 1014 | { |
702 | 1028 | using namespace testing; | 1015 | using namespace testing; |
704 | 1029 | auto mock_stream = stubbed_session->mock_primary_stream_at(mf::SurfaceId{0}); | 1016 | auto mock_stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
705 | 1030 | ON_CALL(*mock_stream, swap_buffers(_,_)) | 1017 | ON_CALL(*mock_stream, swap_buffers(_,_)) |
706 | 1031 | .WillByDefault(InvokeArgument<1>(nullptr)); | 1018 | .WillByDefault(InvokeArgument<1>(nullptr)); |
707 | 1032 | auto buffer1 = std::make_shared<mtd::StubBuffer>(); | 1019 | auto buffer1 = std::make_shared<mtd::StubBuffer>(); |
708 | @@ -1062,10 +1049,9 @@ | |||
709 | 1062 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_create) | 1049 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_create) |
710 | 1063 | { | 1050 | { |
711 | 1064 | using namespace testing; | 1051 | using namespace testing; |
712 | 1065 | mf::SurfaceId surf_id{0}; | ||
713 | 1066 | mtd::StubBuffer buffer; | 1052 | mtd::StubBuffer buffer; |
714 | 1067 | 1053 | ||
716 | 1068 | auto stream = stubbed_session->mock_primary_stream_at(surf_id); | 1054 | auto stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
717 | 1069 | ON_CALL(*stream, swap_buffers(_,_)) | 1055 | ON_CALL(*stream, swap_buffers(_,_)) |
718 | 1070 | .WillByDefault(InvokeArgument<1>(nullptr)); | 1056 | .WillByDefault(InvokeArgument<1>(nullptr)); |
719 | 1071 | 1057 | ||
720 | @@ -1081,10 +1067,9 @@ | |||
721 | 1081 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_bstream_create) | 1067 | TEST_F(SessionMediator, doesnt_mind_swap_buffers_returning_nullptr_in_bstream_create) |
722 | 1082 | { | 1068 | { |
723 | 1083 | using namespace testing; | 1069 | using namespace testing; |
724 | 1084 | mf::SurfaceId surf_id{0}; | ||
725 | 1085 | mtd::StubBuffer buffer; | 1070 | mtd::StubBuffer buffer; |
726 | 1086 | 1071 | ||
728 | 1087 | auto stream = stubbed_session->mock_primary_stream_at(surf_id); | 1072 | auto stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
729 | 1088 | ON_CALL(*stream, swap_buffers(_,_)) | 1073 | ON_CALL(*stream, swap_buffers(_,_)) |
730 | 1089 | .WillByDefault(InvokeArgument<1>(nullptr)); | 1074 | .WillByDefault(InvokeArgument<1>(nullptr)); |
731 | 1090 | 1075 | ||
732 | @@ -1100,20 +1085,20 @@ | |||
733 | 1100 | TEST_F(SessionMediator, configures_swap_intervals_on_streams) | 1085 | TEST_F(SessionMediator, configures_swap_intervals_on_streams) |
734 | 1101 | { | 1086 | { |
735 | 1102 | using namespace testing; | 1087 | using namespace testing; |
737 | 1103 | mf::SurfaceId surf_id{0}; | 1088 | mf::BufferStreamId stream_id{0}; |
738 | 1104 | mp::StreamConfiguration request; | 1089 | mp::StreamConfiguration request; |
739 | 1105 | mp::Void response; | 1090 | mp::Void response; |
740 | 1106 | 1091 | ||
741 | 1107 | auto interval = 0u; | 1092 | auto interval = 0u; |
742 | 1108 | mtd::StubBuffer buffer; | 1093 | mtd::StubBuffer buffer; |
743 | 1109 | 1094 | ||
745 | 1110 | auto stream = stubbed_session->mock_primary_stream_at(surf_id); | 1095 | auto stream = stubbed_session->mock_stream_at(stream_id); |
746 | 1111 | EXPECT_CALL(*stream, allow_framedropping(true)); | 1096 | EXPECT_CALL(*stream, allow_framedropping(true)); |
747 | 1112 | 1097 | ||
748 | 1113 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 1098 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
749 | 1114 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); | 1099 | mediator.create_surface(&surface_parameters, &surface_response, null_callback.get()); |
750 | 1115 | 1100 | ||
752 | 1116 | request.mutable_id()->set_value(surf_id.as_value()); | 1101 | request.mutable_id()->set_value(stream_id.as_value()); |
753 | 1117 | request.set_swapinterval(interval); | 1102 | request.set_swapinterval(interval); |
754 | 1118 | mediator.configure_buffer_stream(&request, &response, null_callback.get()); | 1103 | mediator.configure_buffer_stream(&request, &response, null_callback.get()); |
755 | 1119 | } | 1104 | } |
756 | @@ -1209,10 +1194,9 @@ | |||
757 | 1209 | TEST_F(SessionMediator, doesnt_inadventently_set_buffer_field_when_theres_no_buffer) | 1194 | TEST_F(SessionMediator, doesnt_inadventently_set_buffer_field_when_theres_no_buffer) |
758 | 1210 | { | 1195 | { |
759 | 1211 | mp::Void null; | 1196 | mp::Void null; |
760 | 1212 | mf::SurfaceId surf_id{0}; | ||
761 | 1213 | mp::BufferStreamParameters stream_request; | 1197 | mp::BufferStreamParameters stream_request; |
762 | 1214 | mp::BufferStream stream_response; | 1198 | mp::BufferStream stream_response; |
764 | 1215 | auto stream = stubbed_session->mock_primary_stream_at(surf_id); | 1199 | auto stream = stubbed_session->mock_stream_at(mf::BufferStreamId{0}); |
765 | 1216 | ON_CALL(*stream, swap_buffers(nullptr,testing::_)) | 1200 | ON_CALL(*stream, swap_buffers(nullptr,testing::_)) |
766 | 1217 | .WillByDefault(testing::InvokeArgument<1>(nullptr)); | 1201 | .WillByDefault(testing::InvokeArgument<1>(nullptr)); |
767 | 1218 | mediator.connect(&connect_parameters, &connection, null_callback.get()); | 1202 | mediator.connect(&connect_parameters, &connection, null_callback.get()); |
768 | 1219 | 1203 | ||
769 | === modified file 'tests/unit-tests/scene/test_abstract_shell.cpp' | |||
770 | --- tests/unit-tests/scene/test_abstract_shell.cpp 2016-01-29 08:18:22 +0000 | |||
771 | +++ tests/unit-tests/scene/test_abstract_shell.cpp 2016-04-12 14:23:09 +0000 | |||
772 | @@ -145,6 +145,7 @@ | |||
773 | 145 | 145 | ||
774 | 146 | std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0); | 146 | std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0); |
775 | 147 | std::vector<uint8_t> const cookie; | 147 | std::vector<uint8_t> const cookie; |
776 | 148 | mg::BufferProperties properties { geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::software}; | ||
777 | 148 | }; | 149 | }; |
778 | 149 | } | 150 | } |
779 | 150 | 151 | ||
780 | @@ -197,9 +198,12 @@ | |||
781 | 197 | WillOnce(Return(mt::fake_shared(surface3))); | 198 | WillOnce(Return(mt::fake_shared(surface3))); |
782 | 198 | 199 | ||
783 | 199 | auto const session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 200 | auto const session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
787 | 200 | auto const surface_id1 = shell.create_surface(session, ms::a_surface(), nullptr); | 201 | auto const surface_id1 = shell.create_surface(session, |
788 | 201 | auto const surface_id2 = shell.create_surface(session, ms::a_surface(), nullptr); | 202 | ms::a_surface().with_buffer_stream(session->create_buffer_stream(properties)), nullptr); |
789 | 202 | auto const surface_id3 = shell.create_surface(session, ms::a_surface(), nullptr); | 203 | auto const surface_id2 = shell.create_surface(session, |
790 | 204 | ms::a_surface().with_buffer_stream(session->create_buffer_stream(properties)), nullptr); | ||
791 | 205 | auto const surface_id3 = shell.create_surface(session, | ||
792 | 206 | ms::a_surface().with_buffer_stream(session->create_buffer_stream(properties)), nullptr); | ||
793 | 203 | 207 | ||
794 | 204 | session->destroy_surface(surface_id2); | 208 | session->destroy_surface(surface_id2); |
795 | 205 | 209 | ||
796 | @@ -217,8 +221,8 @@ | |||
797 | 217 | std::shared_ptr<ms::Session> session = | 221 | std::shared_ptr<ms::Session> session = |
798 | 218 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 222 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
799 | 219 | 223 | ||
802 | 220 | auto params = ms::a_surface(); | 224 | auto params = ms::a_surface() |
803 | 221 | 225 | .with_buffer_stream(session->create_buffer_stream(properties)); | |
804 | 222 | EXPECT_CALL(*wm, add_surface(session, Ref(params), _)); | 226 | EXPECT_CALL(*wm, add_surface(session, Ref(params), _)); |
805 | 223 | 227 | ||
806 | 224 | shell.create_surface(session, params, nullptr); | 228 | shell.create_surface(session, params, nullptr); |
807 | @@ -229,7 +233,8 @@ | |||
808 | 229 | std::shared_ptr<ms::Session> const session = | 233 | std::shared_ptr<ms::Session> const session = |
809 | 230 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 234 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
810 | 231 | 235 | ||
812 | 232 | auto params = ms::a_surface(); | 236 | auto params = ms::a_surface() |
813 | 237 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
814 | 233 | auto placed_params = params; | 238 | auto placed_params = params; |
815 | 234 | placed_params.size.width = geom::Width{100}; | 239 | placed_params.size.width = geom::Width{100}; |
816 | 235 | 240 | ||
817 | @@ -246,9 +251,10 @@ | |||
818 | 246 | 251 | ||
819 | 247 | TEST_F(AbstractShell, destroy_surface_removes_surface_from_window_manager) | 252 | TEST_F(AbstractShell, destroy_surface_removes_surface_from_window_manager) |
820 | 248 | { | 253 | { |
821 | 249 | auto const params = ms::a_surface(); | ||
822 | 250 | std::shared_ptr<ms::Session> const session = | 254 | std::shared_ptr<ms::Session> const session = |
823 | 251 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 255 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
824 | 256 | auto const params = ms::a_surface() | ||
825 | 257 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
826 | 252 | 258 | ||
827 | 253 | auto const surface_id = shell.create_surface(session, params, nullptr); | 259 | auto const surface_id = shell.create_surface(session, params, nullptr); |
828 | 254 | auto const surface = session->surface(surface_id); | 260 | auto const surface = session->surface(surface_id); |
829 | @@ -357,7 +363,9 @@ | |||
830 | 357 | std::shared_ptr<ms::Session> const session = | 363 | std::shared_ptr<ms::Session> const session = |
831 | 358 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 364 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
832 | 359 | 365 | ||
834 | 360 | auto const surface_id = shell.create_surface(session, ms::a_surface(), nullptr); | 366 | auto const params = ms::a_surface() |
835 | 367 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
836 | 368 | auto const surface_id = shell.create_surface(session, params, nullptr); | ||
837 | 361 | auto const surface = session->surface(surface_id); | 369 | auto const surface = session->surface(surface_id); |
838 | 362 | 370 | ||
839 | 363 | MirSurfaceState const state{mir_surface_state_fullscreen}; | 371 | MirSurfaceState const state{mir_surface_state_fullscreen}; |
840 | @@ -392,8 +400,12 @@ | |||
841 | 392 | msh::FocusController& focus_controller = shell; | 400 | msh::FocusController& focus_controller = shell; |
842 | 393 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 401 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
843 | 394 | auto session1 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); | 402 | auto session1 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); |
846 | 395 | shell.create_surface(session, ms::a_surface(), nullptr); | 403 | auto const params = ms::a_surface() |
847 | 396 | shell.create_surface(session1, ms::a_surface(), nullptr); | 404 | .with_buffer_stream(session->create_buffer_stream(properties)); |
848 | 405 | auto const params2 = ms::a_surface() | ||
849 | 406 | .with_buffer_stream(session1->create_buffer_stream(properties)); | ||
850 | 407 | shell.create_surface(session, params, nullptr); | ||
851 | 408 | shell.create_surface(session1, params2, nullptr); | ||
852 | 397 | 409 | ||
853 | 398 | focus_controller.set_focus_to(session, {}); | 410 | focus_controller.set_focus_to(session, {}); |
854 | 399 | 411 | ||
855 | @@ -409,8 +421,12 @@ | |||
856 | 409 | { | 421 | { |
857 | 410 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 422 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
858 | 411 | auto session1 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); | 423 | auto session1 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); |
861 | 412 | shell.create_surface(session, ms::a_surface(), nullptr); | 424 | auto const params = ms::a_surface() |
862 | 413 | shell.create_surface(session1, ms::a_surface(), nullptr); | 425 | .with_buffer_stream(session->create_buffer_stream(properties)); |
863 | 426 | auto const params2 = ms::a_surface() | ||
864 | 427 | .with_buffer_stream(session1->create_buffer_stream(properties)); | ||
865 | 428 | shell.create_surface(session, params, nullptr); | ||
866 | 429 | shell.create_surface(session1, params2, nullptr); | ||
867 | 414 | 430 | ||
868 | 415 | EXPECT_CALL(session_container, successor_of(session1)). | 431 | EXPECT_CALL(session_container, successor_of(session1)). |
869 | 416 | WillOnce(Return(session)); | 432 | WillOnce(Return(session)); |
870 | @@ -437,10 +453,13 @@ | |||
871 | 437 | EXPECT_CALL(session_container, successor_of(session1)). | 453 | EXPECT_CALL(session_container, successor_of(session1)). |
872 | 438 | WillOnce(Return(session0)); | 454 | WillOnce(Return(session0)); |
873 | 439 | 455 | ||
876 | 440 | 456 | auto const params = ms::a_surface() | |
877 | 441 | auto const surface0_id = shell.create_surface(session0, ms::a_surface(), nullptr); | 457 | .with_buffer_stream(session0->create_buffer_stream(properties)); |
878 | 458 | auto const params2 = ms::a_surface() | ||
879 | 459 | .with_buffer_stream(session1->create_buffer_stream(properties)); | ||
880 | 460 | auto const surface0_id = shell.create_surface(session0, params, nullptr); | ||
881 | 442 | auto const surface0 = session0->surface(surface0_id); | 461 | auto const surface0 = session0->surface(surface0_id); |
883 | 443 | auto const surface1_id = shell.create_surface(session1, ms::a_surface(), nullptr); | 462 | auto const surface1_id = shell.create_surface(session1, params2, nullptr); |
884 | 444 | auto const surface1 = session1->surface(surface1_id); | 463 | auto const surface1 = session1->surface(surface1_id); |
885 | 445 | 464 | ||
886 | 446 | msh::FocusController& focus_controller = shell; | 465 | msh::FocusController& focus_controller = shell; |
887 | @@ -477,8 +496,12 @@ | |||
888 | 477 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 496 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
889 | 478 | auto session1 = shell.open_session(__LINE__, "Surfaceless", std::shared_ptr<mf::EventSink>()); | 497 | auto session1 = shell.open_session(__LINE__, "Surfaceless", std::shared_ptr<mf::EventSink>()); |
890 | 479 | auto session2 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); | 498 | auto session2 = shell.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>()); |
893 | 480 | auto surface_id = shell.create_surface(session, ms::a_surface(), nullptr); | 499 | auto const params = ms::a_surface() |
894 | 481 | shell.create_surface(session2, ms::a_surface(), nullptr); | 500 | .with_buffer_stream(session->create_buffer_stream(properties)); |
895 | 501 | auto surface_id = shell.create_surface(session, params, nullptr); | ||
896 | 502 | auto const params2 = ms::a_surface() | ||
897 | 503 | .with_buffer_stream(session2->create_buffer_stream(properties)); | ||
898 | 504 | shell.create_surface(session2, params2, nullptr); | ||
899 | 482 | 505 | ||
900 | 483 | focus_controller.set_focus_to(session, session->surface(surface_id)); | 506 | focus_controller.set_focus_to(session, session->surface(surface_id)); |
901 | 484 | 507 | ||
902 | @@ -498,7 +521,9 @@ | |||
903 | 498 | msh::FocusController& focus_controller = shell; | 521 | msh::FocusController& focus_controller = shell; |
904 | 499 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 522 | auto session = shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
905 | 500 | auto session1 = shell.open_session(__LINE__, "Surfaceless", std::shared_ptr<mf::EventSink>()); | 523 | auto session1 = shell.open_session(__LINE__, "Surfaceless", std::shared_ptr<mf::EventSink>()); |
907 | 501 | auto surface_id = shell.create_surface(session, ms::a_surface(), nullptr); | 524 | auto creation_params = ms::a_surface() |
908 | 525 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
909 | 526 | auto surface_id = shell.create_surface(session, creation_params, nullptr); | ||
910 | 502 | 527 | ||
911 | 503 | focus_controller.set_focus_to(session, session->surface(surface_id)); | 528 | focus_controller.set_focus_to(session, session->surface(surface_id)); |
912 | 504 | 529 | ||
913 | @@ -519,8 +544,8 @@ | |||
914 | 519 | std::shared_ptr<ms::Session> session = | 544 | std::shared_ptr<ms::Session> session = |
915 | 520 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 545 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
916 | 521 | 546 | ||
919 | 522 | auto creation_params = ms::a_surface(); | 547 | auto creation_params = ms::a_surface() |
920 | 523 | 548 | .with_buffer_stream(session->create_buffer_stream(properties)); | |
921 | 524 | auto surface_id = shell.create_surface(session, creation_params, nullptr); | 549 | auto surface_id = shell.create_surface(session, creation_params, nullptr); |
922 | 525 | auto surface = session->surface(surface_id); | 550 | auto surface = session->surface(surface_id); |
923 | 526 | 551 | ||
924 | @@ -537,7 +562,8 @@ | |||
925 | 537 | std::shared_ptr<ms::Session> session = | 562 | std::shared_ptr<ms::Session> session = |
926 | 538 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); | 563 | shell.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>()); |
927 | 539 | 564 | ||
929 | 540 | auto creation_params = ms::a_surface(); | 565 | auto creation_params = ms::a_surface() |
930 | 566 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
931 | 541 | 567 | ||
932 | 542 | auto surface_id = shell.create_surface(session, creation_params, nullptr); | 568 | auto surface_id = shell.create_surface(session, creation_params, nullptr); |
933 | 543 | auto surface = session->surface(surface_id); | 569 | auto surface = session->surface(surface_id); |
934 | 544 | 570 | ||
935 | === modified file 'tests/unit-tests/scene/test_application_session.cpp' | |||
936 | --- tests/unit-tests/scene/test_application_session.cpp 2016-04-04 03:30:04 +0000 | |||
937 | +++ tests/unit-tests/scene/test_application_session.cpp 2016-04-12 14:23:09 +0000 | |||
938 | @@ -223,6 +223,7 @@ | |||
939 | 223 | std::shared_ptr<mtd::StubBufferStream> const stub_buffer_stream{std::make_shared<mtd::StubBufferStream>()}; | 223 | std::shared_ptr<mtd::StubBufferStream> const stub_buffer_stream{std::make_shared<mtd::StubBufferStream>()}; |
940 | 224 | pid_t pid; | 224 | pid_t pid; |
941 | 225 | std::string name; | 225 | std::string name; |
942 | 226 | mg::BufferProperties properties { geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::hardware }; | ||
943 | 226 | }; | 227 | }; |
944 | 227 | 228 | ||
945 | 228 | struct MockSurfaceFactory : ms::SurfaceFactory | 229 | struct MockSurfaceFactory : ms::SurfaceFactory |
946 | @@ -246,10 +247,48 @@ | |||
947 | 246 | auto session = make_application_session( | 247 | auto session = make_application_session( |
948 | 247 | mt::fake_shared(surface_stack), mt::fake_shared(mock_surface_factory)); | 248 | mt::fake_shared(surface_stack), mt::fake_shared(mock_surface_factory)); |
949 | 248 | 249 | ||
954 | 249 | ms::SurfaceCreationParameters params; | 250 | ms::SurfaceCreationParameters params = ms::a_surface() |
955 | 250 | auto surf = session->create_surface(params, event_sink); | 251 | .with_buffer_stream(session->create_buffer_stream(properties)); |
956 | 251 | 252 | auto surf = session->create_surface(params, event_sink); | |
957 | 252 | session->destroy_surface(surf); | 253 | |
958 | 254 | session->destroy_surface(surf); | ||
959 | 255 | } | ||
960 | 256 | |||
961 | 257 | TEST_F(ApplicationSession, attempt_to_destroy_non_existent_stream_throws) | ||
962 | 258 | { | ||
963 | 259 | using namespace ::testing; | ||
964 | 260 | NiceMock<MockSurfaceFactory> mock_surface_factory; | ||
965 | 261 | NiceMock<mtd::MockSurfaceStack> surface_stack; | ||
966 | 262 | auto session = make_application_session( | ||
967 | 263 | mt::fake_shared(surface_stack), mt::fake_shared(mock_surface_factory)); | ||
968 | 264 | |||
969 | 265 | mf::BufferStreamId made_up_id{332}; | ||
970 | 266 | EXPECT_THROW({ | ||
971 | 267 | session->destroy_buffer_stream(made_up_id); | ||
972 | 268 | }, std::runtime_error); | ||
973 | 269 | } | ||
974 | 270 | |||
975 | 271 | TEST_F(ApplicationSession, can_destroy_buffer_stream_after_destroying_surface) | ||
976 | 272 | { | ||
977 | 273 | using namespace ::testing; | ||
978 | 274 | |||
979 | 275 | NiceMock<MockSurfaceFactory> mock_surface_factory; | ||
980 | 276 | NiceMock<mtd::MockSurfaceStack> surface_stack; | ||
981 | 277 | std::shared_ptr<ms::Surface> mock_surface = make_mock_surface(); | ||
982 | 278 | |||
983 | 279 | EXPECT_CALL(mock_surface_factory, create_surface(_,_)) | ||
984 | 280 | .WillOnce(Return(mock_surface)); | ||
985 | 281 | EXPECT_CALL(surface_stack, add_surface(mock_surface,_)); | ||
986 | 282 | auto session = make_application_session( | ||
987 | 283 | mt::fake_shared(surface_stack), mt::fake_shared(mock_surface_factory)); | ||
988 | 284 | |||
989 | 285 | auto buffer_stream = session->create_buffer_stream(properties); | ||
990 | 286 | ms::SurfaceCreationParameters params = ms::a_surface() | ||
991 | 287 | .with_buffer_stream(buffer_stream); | ||
992 | 288 | auto surf = session->create_surface(params, event_sink); | ||
993 | 289 | |||
994 | 290 | session->destroy_surface(surf); | ||
995 | 291 | session->destroy_buffer_stream(buffer_stream); | ||
996 | 253 | } | 292 | } |
997 | 254 | 293 | ||
998 | 255 | TEST_F(ApplicationSession, notifies_listener_of_create_and_destroy_surface) | 294 | TEST_F(ApplicationSession, notifies_listener_of_create_and_destroy_surface) |
999 | @@ -264,7 +303,8 @@ | |||
1000 | 264 | 303 | ||
1001 | 265 | auto session = make_application_session_with_listener(mt::fake_shared(listener)); | 304 | auto session = make_application_session_with_listener(mt::fake_shared(listener)); |
1002 | 266 | 305 | ||
1004 | 267 | ms::SurfaceCreationParameters params; | 306 | ms::SurfaceCreationParameters params = ms::a_surface() |
1005 | 307 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
1006 | 268 | auto surf = session->create_surface(params, event_sink); | 308 | auto surf = session->create_surface(params, event_sink); |
1007 | 269 | 309 | ||
1008 | 270 | session->destroy_surface(surf); | 310 | session->destroy_surface(surf); |
1009 | @@ -283,7 +323,8 @@ | |||
1010 | 283 | { | 323 | { |
1011 | 284 | auto session = make_application_session_with_listener(mt::fake_shared(listener)); | 324 | auto session = make_application_session_with_listener(mt::fake_shared(listener)); |
1012 | 285 | 325 | ||
1014 | 286 | ms::SurfaceCreationParameters params; | 326 | ms::SurfaceCreationParameters params = ms::a_surface() |
1015 | 327 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
1016 | 287 | session->create_surface(params, event_sink); | 328 | session->create_surface(params, event_sink); |
1017 | 288 | } | 329 | } |
1018 | 289 | } | 330 | } |
1019 | @@ -320,7 +361,8 @@ | |||
1020 | 320 | 361 | ||
1021 | 321 | auto app_session = make_application_session_with_stubs(); | 362 | auto app_session = make_application_session_with_stubs(); |
1022 | 322 | 363 | ||
1024 | 323 | ms::SurfaceCreationParameters params; | 364 | ms::SurfaceCreationParameters params = ms::a_surface() |
1025 | 365 | .with_buffer_stream(app_session->create_buffer_stream(properties)); | ||
1026 | 324 | auto id1 = app_session->create_surface(params, nullptr); | 366 | auto id1 = app_session->create_surface(params, nullptr); |
1027 | 325 | auto id2 = app_session->create_surface(params, nullptr); | 367 | auto id2 = app_session->create_surface(params, nullptr); |
1028 | 326 | auto id3 = app_session->create_surface(params, nullptr); | 368 | auto id3 = app_session->create_surface(params, nullptr); |
1029 | @@ -341,7 +383,8 @@ | |||
1030 | 341 | TEST_F(ApplicationSession, foreign_surface_has_no_successor) | 383 | TEST_F(ApplicationSession, foreign_surface_has_no_successor) |
1031 | 342 | { | 384 | { |
1032 | 343 | auto session1 = make_application_session_with_stubs(); | 385 | auto session1 = make_application_session_with_stubs(); |
1034 | 344 | ms::SurfaceCreationParameters params; | 386 | ms::SurfaceCreationParameters params = ms::a_surface() |
1035 | 387 | .with_buffer_stream(session1->create_buffer_stream(properties)); | ||
1036 | 345 | auto id1 = session1->create_surface(params, nullptr); | 388 | auto id1 = session1->create_surface(params, nullptr); |
1037 | 346 | auto surf1 = session1->surface(id1); | 389 | auto surf1 = session1->surface(id1); |
1038 | 347 | auto id2 = session1->create_surface(params, nullptr); | 390 | auto id2 = session1->create_surface(params, nullptr); |
1039 | @@ -358,7 +401,8 @@ | |||
1040 | 358 | TEST_F(ApplicationSession, surface_after_one_is_self) | 401 | TEST_F(ApplicationSession, surface_after_one_is_self) |
1041 | 359 | { | 402 | { |
1042 | 360 | auto session = make_application_session_with_stubs(); | 403 | auto session = make_application_session_with_stubs(); |
1044 | 361 | ms::SurfaceCreationParameters params; | 404 | ms::SurfaceCreationParameters params = ms::a_surface() |
1045 | 405 | .with_buffer_stream(session->create_buffer_stream(properties)); | ||
1046 | 362 | auto id = session->create_surface(params, nullptr); | 406 | auto id = session->create_surface(params, nullptr); |
1047 | 363 | auto surf = session->surface(id); | 407 | auto surf = session->surface(id); |
1048 | 364 | 408 | ||
1049 | @@ -371,7 +415,8 @@ | |||
1050 | 371 | { | 415 | { |
1051 | 372 | auto app_session = make_application_session_with_stubs(); | 416 | auto app_session = make_application_session_with_stubs(); |
1052 | 373 | 417 | ||
1054 | 374 | ms::SurfaceCreationParameters params; | 418 | ms::SurfaceCreationParameters params = ms::a_surface() |
1055 | 419 | .with_buffer_stream(app_session->create_buffer_stream(properties)); | ||
1056 | 375 | 420 | ||
1057 | 376 | int const N = 3; | 421 | int const N = 3; |
1058 | 377 | std::shared_ptr<ms::Surface> surf[N]; | 422 | std::shared_ptr<ms::Surface> surf[N]; |
1059 | @@ -412,7 +457,8 @@ | |||
1060 | 412 | EXPECT_CALL(*mock_surface, show()).Times(1); | 457 | EXPECT_CALL(*mock_surface, show()).Times(1); |
1061 | 413 | } | 458 | } |
1062 | 414 | 459 | ||
1064 | 415 | ms::SurfaceCreationParameters params; | 460 | ms::SurfaceCreationParameters params = ms::a_surface() |
1065 | 461 | .with_buffer_stream(app_session->create_buffer_stream(properties)); | ||
1066 | 416 | auto surf = app_session->create_surface(params, event_sink); | 462 | auto surf = app_session->create_surface(params, event_sink); |
1067 | 417 | 463 | ||
1068 | 418 | app_session->hide(); | 464 | app_session->hide(); |
1069 | @@ -447,7 +493,9 @@ | |||
1070 | 447 | mtd::StubDisplayConfig{}, | 493 | mtd::StubDisplayConfig{}, |
1071 | 448 | event_sink); | 494 | event_sink); |
1072 | 449 | 495 | ||
1074 | 450 | auto surface = app_session.create_surface(ms::SurfaceCreationParameters{}, event_sink); | 496 | ms::SurfaceCreationParameters params = ms::a_surface() |
1075 | 497 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1076 | 498 | auto surface = app_session.create_surface(params, event_sink); | ||
1077 | 451 | app_session.take_snapshot(ms::SnapshotCallback()); | 499 | app_session.take_snapshot(ms::SnapshotCallback()); |
1078 | 452 | app_session.destroy_surface(surface); | 500 | app_session.destroy_surface(surface); |
1079 | 453 | } | 501 | } |
1080 | @@ -492,42 +540,13 @@ | |||
1081 | 492 | EXPECT_THAT(app_session.process_id(), Eq(session_pid)); | 540 | EXPECT_THAT(app_session.process_id(), Eq(session_pid)); |
1082 | 493 | } | 541 | } |
1083 | 494 | 542 | ||
1084 | 495 | TEST_F(ApplicationSession, surface_ids_are_bufferstream_ids) | ||
1085 | 496 | { | ||
1086 | 497 | using namespace ::testing; | ||
1087 | 498 | |||
1088 | 499 | NiceMock<MockSurfaceFactory> mock_surface_factory; | ||
1089 | 500 | NiceMock<MockBufferStreamFactory> mock_bufferstream_factory; | ||
1090 | 501 | NiceMock<mtd::MockSurfaceStack> surface_stack; | ||
1091 | 502 | std::shared_ptr<ms::Surface> mock_surface = make_mock_surface(); | ||
1092 | 503 | auto stub_bstream = std::make_shared<mtd::StubBufferStream>(); | ||
1093 | 504 | EXPECT_CALL(mock_bufferstream_factory, create_buffer_stream(_,_,_)) | ||
1094 | 505 | .WillOnce(Return(stub_bstream)); | ||
1095 | 506 | EXPECT_CALL(mock_surface_factory, create_surface(std::shared_ptr<mc::BufferStream>(stub_bstream),_)) | ||
1096 | 507 | .WillOnce(Return(mock_surface)); | ||
1097 | 508 | auto session = make_application_session( | ||
1098 | 509 | mt::fake_shared(mock_bufferstream_factory), | ||
1099 | 510 | mt::fake_shared(mock_surface_factory)); | ||
1100 | 511 | |||
1101 | 512 | ms::SurfaceCreationParameters params; | ||
1102 | 513 | |||
1103 | 514 | auto id1 = session->create_surface(params, event_sink); | ||
1104 | 515 | EXPECT_THAT(session->get_buffer_stream(mf::BufferStreamId(id1.as_value())), Eq(stub_bstream)); | ||
1105 | 516 | EXPECT_THAT(session->get_surface(id1), Eq(mock_surface)); | ||
1106 | 517 | |||
1107 | 518 | session->destroy_surface(id1); | ||
1108 | 519 | |||
1109 | 520 | EXPECT_THROW({ | ||
1110 | 521 | session->get_buffer_stream(mf::BufferStreamId(id1.as_value())); | ||
1111 | 522 | }, std::runtime_error); | ||
1112 | 523 | } | ||
1113 | 524 | |||
1114 | 525 | TEST_F(ApplicationSession, can_destroy_surface_bstream) | 543 | TEST_F(ApplicationSession, can_destroy_surface_bstream) |
1115 | 526 | { | 544 | { |
1116 | 527 | auto session = make_application_session_with_stubs(); | 545 | auto session = make_application_session_with_stubs(); |
1118 | 528 | ms::SurfaceCreationParameters params; | 546 | mf::BufferStreamId stream_id = session->create_buffer_stream(properties); |
1119 | 547 | ms::SurfaceCreationParameters params = ms::a_surface() | ||
1120 | 548 | .with_buffer_stream(stream_id); | ||
1121 | 529 | auto id = session->create_surface(params, event_sink); | 549 | auto id = session->create_surface(params, event_sink); |
1122 | 530 | mf::BufferStreamId stream_id(id.as_value()); | ||
1123 | 531 | session->destroy_buffer_stream(stream_id); | 550 | session->destroy_buffer_stream(stream_id); |
1124 | 532 | EXPECT_THROW({ | 551 | EXPECT_THROW({ |
1125 | 533 | session->get_buffer_stream(stream_id); | 552 | session->get_buffer_stream(stream_id); |
1126 | @@ -565,11 +584,8 @@ | |||
1127 | 565 | auto session = make_application_session( | 584 | auto session = make_application_session( |
1128 | 566 | mt::fake_shared(mock_bufferstream_factory), | 585 | mt::fake_shared(mock_bufferstream_factory), |
1129 | 567 | mt::fake_shared(mock_surface_factory)); | 586 | mt::fake_shared(mock_surface_factory)); |
1130 | 568 | auto stream_id0 = mf::BufferStreamId( | ||
1131 | 569 | session->create_surface( | ||
1132 | 570 | ms::a_surface().of_position({1,1}), | ||
1133 | 571 | event_sink).as_value()); | ||
1134 | 572 | 587 | ||
1135 | 588 | auto stream_id0 = session->create_buffer_stream(stream_properties); | ||
1136 | 573 | auto stream_id1 = session->create_buffer_stream(stream_properties); | 589 | auto stream_id1 = session->create_buffer_stream(stream_properties); |
1137 | 574 | auto stream_id2 = session->create_buffer_stream(stream_properties); | 590 | auto stream_id2 = session->create_buffer_stream(stream_properties); |
1138 | 575 | 591 | ||
1139 | @@ -578,6 +594,10 @@ | |||
1140 | 578 | {streams[0], geom::Displacement{-1,1}, {}}, | 594 | {streams[0], geom::Displacement{-1,1}, {}}, |
1141 | 579 | {streams[1], geom::Displacement{0,2}, {}} | 595 | {streams[1], geom::Displacement{0,2}, {}} |
1142 | 580 | }; | 596 | }; |
1143 | 597 | |||
1144 | 598 | session->create_surface( | ||
1145 | 599 | ms::a_surface().with_buffer_stream(stream_id0), event_sink); | ||
1146 | 600 | |||
1147 | 581 | EXPECT_CALL(*mock_surface, set_streams(Pointwise(StreamEq(), info))); | 601 | EXPECT_CALL(*mock_surface, set_streams(Pointwise(StreamEq(), info))); |
1148 | 582 | session->configure_streams(*mock_surface, { | 602 | session->configure_streams(*mock_surface, { |
1149 | 583 | {stream_id2, geom::Displacement{0,3}, {}}, | 603 | {stream_id2, geom::Displacement{0,3}, {}}, |
1150 | @@ -884,7 +904,8 @@ | |||
1151 | 884 | app_session.send_display_config(config); | 904 | app_session.send_display_config(config); |
1152 | 885 | 905 | ||
1153 | 886 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 906 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1155 | 887 | .of_size({100, 100}); | 907 | .of_size({100, 100}) |
1156 | 908 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1157 | 888 | auto surf_id = app_session.create_surface(params, sender); | 909 | auto surf_id = app_session.create_surface(params, sender); |
1158 | 889 | auto surface = app_session.surface(surf_id); | 910 | auto surface = app_session.surface(surf_id); |
1159 | 890 | 911 | ||
1160 | @@ -909,7 +930,8 @@ | |||
1161 | 909 | })); | 930 | })); |
1162 | 910 | 931 | ||
1163 | 911 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 932 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1165 | 912 | .of_size({100, 100}); | 933 | .of_size({100, 100}) |
1166 | 934 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1167 | 913 | 935 | ||
1168 | 914 | mf::SurfaceId ids[2]; | 936 | mf::SurfaceId ids[2]; |
1169 | 915 | std::shared_ptr<ms::Surface> surfaces[2]; | 937 | std::shared_ptr<ms::Surface> surfaces[2]; |
1170 | @@ -962,7 +984,8 @@ | |||
1171 | 962 | })); | 984 | })); |
1172 | 963 | 985 | ||
1173 | 964 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 986 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1175 | 965 | .of_size({100, 100}); | 987 | .of_size({100, 100}) |
1176 | 988 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1177 | 966 | 989 | ||
1178 | 967 | auto id = app_session.create_surface(params, sender); | 990 | auto id = app_session.create_surface(params, sender); |
1179 | 968 | auto surface = app_session.surface(id); | 991 | auto surface = app_session.surface(id); |
1180 | @@ -1019,7 +1042,8 @@ | |||
1181 | 1019 | app_session.send_display_config(config); | 1042 | app_session.send_display_config(config); |
1182 | 1020 | 1043 | ||
1183 | 1021 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 1044 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1185 | 1022 | .of_size({640, 480}); | 1045 | .of_size({640, 480}) |
1186 | 1046 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1187 | 1023 | 1047 | ||
1188 | 1024 | auto id = app_session.create_surface(params, sender); | 1048 | auto id = app_session.create_surface(params, sender); |
1189 | 1025 | auto surface = app_session.surface(id); | 1049 | auto surface = app_session.surface(id); |
1190 | @@ -1076,7 +1100,8 @@ | |||
1191 | 1076 | app_session.send_display_config(config); | 1100 | app_session.send_display_config(config); |
1192 | 1077 | 1101 | ||
1193 | 1078 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 1102 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1195 | 1079 | .of_size({100, 100}); | 1103 | .of_size({100, 100}) |
1196 | 1104 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1197 | 1080 | 1105 | ||
1198 | 1081 | auto id = app_session.create_surface(params, sender); | 1106 | auto id = app_session.create_surface(params, sender); |
1199 | 1082 | auto surface = app_session.surface(id); | 1107 | auto surface = app_session.surface(id); |
1200 | @@ -1138,7 +1163,8 @@ | |||
1201 | 1138 | app_session.send_display_config(config); | 1163 | app_session.send_display_config(config); |
1202 | 1139 | 1164 | ||
1203 | 1140 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} | 1165 | ms::SurfaceCreationParameters params = ms::SurfaceCreationParameters{} |
1205 | 1141 | .of_size({100, 100}); | 1166 | .of_size({100, 100}) |
1206 | 1167 | .with_buffer_stream(app_session.create_buffer_stream(properties)); | ||
1207 | 1142 | 1168 | ||
1208 | 1143 | auto id = app_session.create_surface(params, sender); | 1169 | auto id = app_session.create_surface(params, sender); |
1209 | 1144 | auto surface = app_session.surface(id); | 1170 | auto surface = app_session.surface(id); |
1210 | 1145 | 1171 | ||
1211 | === modified file 'tests/unit-tests/scene/test_session_manager.cpp' | |||
1212 | --- tests/unit-tests/scene/test_session_manager.cpp 2016-01-29 08:18:22 +0000 | |||
1213 | +++ tests/unit-tests/scene/test_session_manager.cpp 2016-04-12 14:23:09 +0000 | |||
1214 | @@ -129,9 +129,13 @@ | |||
1215 | 129 | EXPECT_CALL(container, insert_session(_)).Times(1); | 129 | EXPECT_CALL(container, insert_session(_)).Times(1); |
1216 | 130 | EXPECT_CALL(container, remove_session(_)).Times(1); | 130 | EXPECT_CALL(container, remove_session(_)).Times(1); |
1217 | 131 | 131 | ||
1218 | 132 | mg::BufferProperties properties { | ||
1219 | 133 | geom::Size{1,1}, mir_pixel_format_abgr_8888, mg::BufferUsage::software }; | ||
1220 | 132 | auto session = session_manager.open_session(__LINE__, "Visual Basic Studio", mt::fake_shared(event_sink)); | 134 | auto session = session_manager.open_session(__LINE__, "Visual Basic Studio", mt::fake_shared(event_sink)); |
1221 | 133 | session->create_surface( | 135 | session->create_surface( |
1223 | 134 | ms::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}), | 136 | ms::a_surface() |
1224 | 137 | .of_size(geom::Size{geom::Width{1024}, geom::Height{768}}) | ||
1225 | 138 | .with_buffer_stream(session->create_buffer_stream(properties)), | ||
1226 | 135 | mt::fake_shared(event_sink)); | 139 | mt::fake_shared(event_sink)); |
1227 | 136 | 140 | ||
1228 | 137 | session_manager.close_session(session); | 141 | session_manager.close_session(session); |
FAILED: Continuous integration, rev:3440 /mir-jenkins. ubuntu. com/job/ mir-ci/ 701/
https:/
Executed test runs:
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 701/rebuild
https:/