Merge lp:~cemil-azizoglu/mir/improve-raii into lp:mir
- improve-raii
- Merge into development-branch
Status: | Work in progress |
---|---|
Proposed branch: | lp:~cemil-azizoglu/mir/improve-raii |
Merge into: | lp:mir |
Diff against target: |
5102 lines (+917/-1962) 52 files modified
src/include/server/mir/compositor/buffer_bundle.h (+4/-5) src/include/server/mir/compositor/buffer_handle.h (+61/-0) src/include/server/mir/compositor/buffer_queue.h (+7/-5) src/include/server/mir/compositor/buffer_stream.h (+0/-63) src/include/server/mir/default_server_configuration.h (+4/-4) src/include/server/mir/scene/buffer_queue_factory.h (+11/-11) src/server/compositor/CMakeLists.txt (+2/-3) src/server/compositor/buffer_handle.cpp (+63/-0) src/server/compositor/buffer_queue.cpp (+52/-43) src/server/compositor/buffer_queue_factory.cpp (+7/-12) src/server/compositor/buffer_queue_factory.h (+12/-12) src/server/compositor/buffer_stream_surfaces.cpp (+0/-101) src/server/compositor/buffer_stream_surfaces.h (+0/-69) src/server/compositor/default_configuration.cpp (+6/-6) src/server/compositor/default_display_buffer_compositor.cpp (+0/-1) src/server/compositor/gl_renderer.cpp (+0/-1) src/server/compositor/temporary_buffers.cpp (+0/-92) src/server/compositor/temporary_buffers.h (+0/-76) src/server/frontend/session_mediator.cpp (+0/-1) src/server/scene/basic_surface.cpp (+25/-37) src/server/scene/basic_surface.h (+5/-7) src/server/scene/default_configuration.cpp (+1/-1) src/server/scene/surface_allocator.cpp (+7/-9) src/server/scene/surface_allocator.h (+3/-3) src/server/symbols.map (+1/-1) tests/include/mir_test_doubles/mock_buffer_bundle.h (+14/-10) tests/include/mir_test_doubles/mock_buffer_stream.h (+0/-67) tests/include/mir_test_doubles/mock_surface.h (+2/-2) tests/include/mir_test_doubles/stub_buffer_bundle.h (+26/-23) tests/integration-tests/compositor/CMakeLists.txt (+0/-1) tests/integration-tests/compositor/test_buffer_stream.cpp (+0/-405) tests/integration-tests/compositor/test_swapping_swappers.cpp (+2/-4) tests/integration-tests/graphics/android/test_buffer_integration.cpp (+1/-1) tests/integration-tests/surface_composition.cpp (+2/-9) tests/integration-tests/test_exchange_buffer.cpp (+26/-21) tests/integration-tests/test_session.cpp (+0/-1) tests/integration-tests/test_surface_stack_with_compositor.cpp (+9/-12) tests/integration-tests/test_swapinterval.cpp (+23/-23) tests/unit-tests/compositor/CMakeLists.txt (+1/-2) tests/unit-tests/compositor/test_buffer_handle.cpp (+40/-0) tests/unit-tests/compositor/test_buffer_queue.cpp (+422/-395) tests/unit-tests/compositor/test_buffer_stream.cpp (+0/-194) tests/unit-tests/compositor/test_gl_renderer.cpp (+1/-2) tests/unit-tests/compositor/test_temporary_buffers.cpp (+0/-149) tests/unit-tests/examples/test_demo_compositor.cpp (+2/-2) tests/unit-tests/frontend/test_session_mediator.cpp (+0/-1) tests/unit-tests/graphics/test_program_factory.cpp (+1/-2) tests/unit-tests/scene/test_basic_surface.cpp (+13/-13) tests/unit-tests/scene/test_session_manager.cpp (+2/-2) tests/unit-tests/scene/test_surface.cpp (+23/-21) tests/unit-tests/scene/test_surface_impl.cpp (+11/-12) tests/unit-tests/scene/test_surface_stack.cpp (+25/-25) |
To merge this branch: | bzr merge lp:~cemil-azizoglu/mir/improve-raii |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Aguirre (community) | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Alexandros Frantzis (community) | Needs Fixing | ||
Daniel van Vugt | Needs Fixing | ||
Alan Griffiths | Needs Fixing | ||
Kevin DuBois (community) | Needs Fixing | ||
Review via email: mp+250219@code.launchpad.net |
Commit message
Improve raii in the way compositor and snapshot buffers are handled in the buffer queue.
Description of the change
Improve raii in buffer queue, which results in doing away with TemporaryBuffer and BufferStream (server-side) classes (at the cost of introducing a small BufferHandle class). Also BufferStreamFactory is now BufferQueueFactory.
The BufferBundle (and hence the BufferQueue) interface has been simplified due to the fact that now buffers are returned to the queue as part of BufferHandle destructor and not via an explicit call. This simplifies error handling during buffer releases.
Also, temporary buffers inheriting from Buffer is avoided, since they no longer exist. (This previously prevented Buffer being cast as the correct platform buffer type, though we found a different way to handle that case).
The heart of this MP lies in buffer_queue.cpp. For review purposes, one should start from compositor_
PS Jenkins bot (ps-jenkins) wrote : | # |
Kevin DuBois (kdub) wrote : | # |
Seems like (more or less) an even trade-off to me as to what we had before.
typing:
auto b = bundle-
b->buffer(
saves on having to update the Temporary*Buffer adapter objects, but is more awkward to type, compared to:
auto b = bundle-
b->methods();
84 +mc::BufferHand
We used to preserve ownership of the BufferBundle in the temporary buffers, seems like something that could cause problems around the client's destruction if we don't have BufferBundle ownership, and are trying to return in the destructor of BufferHandle.
169 + explicit CompositorBuffe
177 + explicit SnapshotBufferH
spacing
161 + std::shared_
170 + std::shared_
178 + std::shared_
const&
We already have a "native handle", might be over-using the word "Handle" in mc::BufferHandle. (I'm mostly just trying to avoid writing: mg::BufferHandle handle{...}; handle-
257 + std::shared_
258 + std::make_
259 +
260 + return acquired_buffer;
could just:
return std::make_
Alberto Aguirre (albaguirre) wrote : | # |
===
48 + virtual std::shared_
49 + virtual void compositor_
50 + virtual std::shared_
51 + virtual void snapshot_
==
I'd rather have compositor_acquire and snapshot_acquire return a BufferHandle by value.
BufferHandle should be a moveable only type.
The BufferHandle constructor could also be:
BufferHande(
Then we can remove compositor_release and snapshot_release.
===
334 + return buffer_
===
Nobody is holding the return shared_
In order for this to work correctly the caller of lock_compositor
===
160 + explicit BufferHandle(
161 + std::shared_
162 + BufferBundle* buffer_bundle;
===
As mentioned above this could probably be:
class BufferHandle
{
public:
typedef std::function<
explicit BufferHandle(
//Move constructor
BufferHandl
//Move assignment
BufferHandle& operator=
std:
private:
// Moveable only type
BufferHandl
BufferHandle& operator=
std:
Callback release;
};
===
213 + std::shared_
214 + std::make_
===
With the BufferHandle above then this would become:
BufferHandle const handle{
[weak_
{
if (auto self = weak_ptr_
{
}
}
The weak_ptr_this is needed to ensure you won't be calling dead code if the BufferQueue gets destroyed before one of the BufferHandles. Alternatively, you could keep a shared_ptr instead to keep the buffer queue object alive but I would prefer the BufferHandle to not impose that requirement.
The above will require enabled_
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
@Alberto, @Kevin, your comments should have been addressed.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2374
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 2375. By Cemil Azizoglu
-
Fix Android.
Daniel van Vugt (vanvugt) wrote : | # |
I knew this was coming. And by numbers I like the simplification. But the fact that some of our most sensitive test cases are being rewritten en-masse scares me. We'll all need to do some careful manual testing of this.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2375
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
2993 + ASSERT_NO_THROW(q = std::shared_
2994 + new mc::BufferQueue
Here and elsewhere, better with std::make_shared<>
- 2376. By Cemil Azizoglu
-
Use make_shared.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2376
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
===
68 +typedef std::function<
===
Should be ReleaseCallback according to the mir style guide:
http://
===
80 + virtual ~BufferHandle();
===
Not needed
===
356 + if (release_fn)
357 + release_
===
I think Move assignment should not cause the buffer to be released back to the queue.
That would be analogous to move assigning a unique_ptr and having the ptr be deleted while doing that.
===
1198 + compositor_
1209 + if (!compositor_
1210 + compositor_
===
Maybe a bit cleaner (but not blocking) if you allow BufferHandle to be default constructed and implement the negation operator,
so that line 1198 is not needed then, and line 1209 just becomes: if (!compositor_
===
1623 + return std::move(
1628 + return std::move(
===
You ca do away with the std::move
Needs information:
Do the BufferStream integration and unit tests (BufferStreamTe
Otherwise they should be updated but kept not removed.
Daniel van Vugt (vanvugt) wrote : | # |
(1) Regression: Did some quick manual testing. Fullscreen bypassed surfaces are visibly tearing when using this branch...
mir_
mir_
Daniel van Vugt (vanvugt) wrote : | # |
This is what happens when we rewrite test cases en-masse. Regression tests stop protecting us from regressions.
Daniel van Vugt (vanvugt) wrote : | # |
Or for even more tearing, try:
mir_demo_
Alexandros Frantzis (afrantzis) wrote : | # |
348 + release_
367 + if (release_fn)
Unfortunately the standard says that move-constructing a std::function from another std::function leaves the latter in a valid but unspecified state. So "if (release_fn)" in the destructor is not guaranteed to be false after the move. We could use "if (wrapped && release_fn)" instead, since std::shared_ptr provides the guarantee we need.
Also note that after we remove (as mentioned by Alberto above):
356 + if (release_fn)
357 + release_
we could use the default implementations of move-construct and move-assign methods (we would need to explicitly define them with "= default");
Alberto Aguirre (albaguirre) wrote : | # |
> 348 + release_
> 367 + if (release_fn)
>
> Unfortunately the standard says that move-constructing a std::function from
> another std::function leaves the latter in a valid but unspecified state. So
> "if (release_fn)" in the destructor is not guaranteed to be false after the
> move.
That's so weird. I guess you could use other.swap(
- 2377. By Cemil Azizoglu
-
Fixes for review feedback.
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
@Alberto, Alexandros, thanks. Should be fixed now.
@Alberto, I have yet to check if we have overlapping buffer stream tests.
@Daniel, thanks for testing. I cannot see tearing in
mir_demo_
mir_demo_
I see tearing and general corruption when I run
mir_demo_
However, when I run this on the trunk, the triangle moves once every second or so. Is this what youre seeing? And doesn't -n mean don't wait for vsync, so isn't tearing expected?
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2377
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Cemil,
You're using radeon still right? In that case the "once every second or so" is sadly expected. See bug 1211700. Seems only intel has the ability to unthrottle rendering without starving the server process of GPU time. radeon and nouveau are not so good at fair scheduling the GPU. IIRC, proprietary drivers have no such problems. So I guess don't use the "-n" option on your machine. Still, tearing is obviously wrong.
Daniel van Vugt (vanvugt) wrote : | # |
BTW, bypass is weird. And I think kdub's overlay logic requires the same approach.
To avoid tearing the compositor has to briefly hold both (at least 2) of the client's buffers so as to retain the guarantee for the scan-out hardware that whatever is on-screen is not touched by the client till something else is definitely on screen.
// buffer B is on screen
acquire buffer A
scan out buffer A
release buffer B (to the client)
wait for vblank // allows client almost 16ms to render new B
acquire buffer B
scan out buffer B
release buffer A (to the client)
wait for vblank // allows client almost 16ms to render new A
acquire buffer A
scan out buffer A
release buffer B
That's for normal bypass/overlays. If you use "-n" then framedropping mode forces the BufferQueue to have at least 3 buffers {A,B,C}. So the screen can't ever be starved of the newest frame by an unthrottled client (that issue applies to all compositing, not just bypass). But we always guarantee that and that's not the (radeon) bug you're seeing.
- 2378. By Cemil Azizoglu
-
Address CI failures.
Kevin DuBois (kdub) wrote : | # |
> This is what happens when we rewrite test cases en-masse. Regression tests
> stop protecting us from regressions.
+1, and the tests that have been rewritten are some of the most carefully written to avoid sensitive problems. We haven't had a tearing regression in quite a while (12+ months), so changing so much core testing and swapping code makes me nervous, especially because tearing is a very public regression that everyone tends to notice.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2378
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
===
360 + release_fn = std::move(
===
This has a similar issue:
From http://
"
(2) move assignment
The object acquires the target of rhs.
rhs is left in an unspecified but valid state.
"
The tearing occurs in bypass (or overlays with android) because the implementation of post_renderable
Kevin DuBois (kdub) wrote : | # |
> implies the same behavior. Some rework is needed there (which I think it's
> good, because we should avoid nebulous ownership semantics)
I don't think the current semantics are nebulous. The TemporaryBuffers are a Buffer resource; they're a guarantee that they have a buffer locked for a particular purpose for a period of time. Likewise the {mgm/mga}::Buffers are a Buffer resource too, but they have the lifetime of the allocation we request from the driver.
Kevin DuBois (kdub) wrote : | # |
>
> > implies the same behavior. Some rework is needed there (which I think it's
> > good, because we should avoid nebulous ownership semantics)
>
> I don't think the current semantics are nebulous. The TemporaryBuffers are a
> Buffer resource; they're a guarantee that they have a buffer locked for a
> particular purpose for a period of time. Likewise the {mgm/mga}::Buffers are a
> Buffer resource too, but they have the lifetime of the allocation we request
> from the driver.
Furthermore, from mg::Display:
- 2379. By Cemil Azizoglu
-
Do away with unnecessary std::move()
- 2380. By Cemil Azizoglu
-
Fix another case of std::move(
std::function( )).
Unmerged revisions
- 2380. By Cemil Azizoglu
-
Fix another case of std::move(
std::function( )). - 2379. By Cemil Azizoglu
-
Do away with unnecessary std::move()
- 2378. By Cemil Azizoglu
-
Address CI failures.
- 2377. By Cemil Azizoglu
-
Fixes for review feedback.
- 2376. By Cemil Azizoglu
-
Use make_shared.
- 2375. By Cemil Azizoglu
-
Fix Android.
- 2374. By Cemil Azizoglu
-
Add BufferHandle test.
- 2373. By Cemil Azizoglu
-
Fix test properly.
- 2372. By Cemil Azizoglu
-
Fix a test.
- 2371. By Cemil Azizoglu
-
Merge trunk
Preview Diff
1 | === renamed file 'src/server/compositor/buffer_bundle.h' => 'src/include/server/mir/compositor/buffer_bundle.h' |
2 | --- src/server/compositor/buffer_bundle.h 2015-01-21 08:53:28 +0000 |
3 | +++ src/include/server/mir/compositor/buffer_bundle.h 2015-03-20 19:31:52 +0000 |
4 | @@ -29,6 +29,7 @@ |
5 | |
6 | namespace compositor |
7 | { |
8 | +class BufferHandle; |
9 | |
10 | class BufferBundle |
11 | { |
12 | @@ -48,16 +49,14 @@ |
13 | * collisions, all callers should determine user_id |
14 | * in the same way (e.g. always use "this" pointer). |
15 | */ |
16 | - virtual std::shared_ptr<graphics::Buffer> |
17 | - compositor_acquire(void const* user_id) = 0; |
18 | - virtual void compositor_release(std::shared_ptr<graphics::Buffer> const&) = 0; |
19 | - virtual std::shared_ptr<graphics::Buffer> snapshot_acquire() = 0; |
20 | - virtual void snapshot_release(std::shared_ptr<graphics::Buffer> const&) = 0; |
21 | + virtual BufferHandle compositor_acquire(void const* user_id) = 0; |
22 | + virtual BufferHandle snapshot_acquire() = 0; |
23 | |
24 | virtual graphics::BufferProperties properties() const = 0; |
25 | virtual void allow_framedropping(bool dropping_allowed) = 0; |
26 | virtual void force_requests_to_complete() = 0; |
27 | virtual void resize(const geometry::Size &newsize) = 0; |
28 | + virtual geometry::Size size() const = 0; |
29 | virtual int buffers_ready_for_compositor(void const* user_id) const = 0; |
30 | |
31 | /** |
32 | |
33 | === added file 'src/include/server/mir/compositor/buffer_handle.h' |
34 | --- src/include/server/mir/compositor/buffer_handle.h 1970-01-01 00:00:00 +0000 |
35 | +++ src/include/server/mir/compositor/buffer_handle.h 2015-03-20 19:31:52 +0000 |
36 | @@ -0,0 +1,61 @@ |
37 | +/* |
38 | + * Copyright © 2015 Canonical Ltd. |
39 | + * |
40 | + * This program is free software: you can redistribute it and/or modify it |
41 | + * under the terms of the GNU General Public License version 3, |
42 | + * as published by the Free Software Foundation. |
43 | + * |
44 | + * This program is distributed in the hope that it will be useful, |
45 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
46 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47 | + * GNU General Public License for more details. |
48 | + * |
49 | + * You should have received a copy of the GNU General Public License |
50 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
51 | + * |
52 | + * Authored by: |
53 | + * Cemil Azizoglu <cemil.azizoglu@canonical.com> |
54 | + */ |
55 | + |
56 | +#ifndef MIR_BUFFER_HANDLE_H_ |
57 | +#define MIR_BUFFER_HANDLE_H_ |
58 | + |
59 | +#include <memory> |
60 | + |
61 | +namespace mir |
62 | +{ |
63 | +namespace graphics { class Buffer; } |
64 | + |
65 | +namespace compositor |
66 | +{ |
67 | + |
68 | +typedef std::function<void(graphics::Buffer* buffer)> ReleaseCallback; |
69 | + |
70 | +class BufferHandle |
71 | +{ |
72 | +public: |
73 | + explicit BufferHandle( |
74 | + std::shared_ptr<graphics::Buffer> const& buffer, |
75 | + ReleaseCallback const& release); |
76 | + |
77 | + BufferHandle(BufferHandle&& other); |
78 | + BufferHandle& operator=(BufferHandle&& other); |
79 | + BufferHandle() = default; |
80 | + |
81 | + ~BufferHandle(); |
82 | + |
83 | + std::shared_ptr<graphics::Buffer> buffer(); |
84 | + bool operator!(); |
85 | + |
86 | +private: |
87 | + BufferHandle(BufferHandle const&) = delete; |
88 | + BufferHandle& operator=(BufferHandle const&) = delete; |
89 | + |
90 | + std::shared_ptr<graphics::Buffer> wrapped; |
91 | + ReleaseCallback release_fn; |
92 | +}; |
93 | + |
94 | +} |
95 | +} |
96 | + |
97 | +#endif /* MIR_BUFFER_HANDLE_H_*/ |
98 | |
99 | === renamed file 'src/server/compositor/buffer_queue.h' => 'src/include/server/mir/compositor/buffer_queue.h' |
100 | --- src/server/compositor/buffer_queue.h 2015-03-06 03:52:41 +0000 |
101 | +++ src/include/server/mir/compositor/buffer_queue.h 2015-03-20 19:31:52 +0000 |
102 | @@ -37,7 +37,10 @@ |
103 | namespace compositor |
104 | { |
105 | |
106 | -class BufferQueue : public BufferBundle |
107 | +class BufferHandle; |
108 | + |
109 | +class BufferQueue : public BufferBundle, |
110 | + public std::enable_shared_from_this<BufferQueue> |
111 | { |
112 | public: |
113 | typedef std::function<void(graphics::Buffer* buffer)> Callback; |
114 | @@ -49,15 +52,14 @@ |
115 | |
116 | void client_acquire(Callback complete) override; |
117 | void client_release(graphics::Buffer* buffer) override; |
118 | - std::shared_ptr<graphics::Buffer> compositor_acquire(void const* user_id) override; |
119 | - void compositor_release(std::shared_ptr<graphics::Buffer> const& buffer) override; |
120 | - std::shared_ptr<graphics::Buffer> snapshot_acquire() override; |
121 | - void snapshot_release(std::shared_ptr<graphics::Buffer> const& buffer) override; |
122 | + BufferHandle compositor_acquire(void const* user_id) override; |
123 | + BufferHandle snapshot_acquire() override; |
124 | |
125 | graphics::BufferProperties properties() const override; |
126 | void allow_framedropping(bool dropping_allowed) override; |
127 | void force_requests_to_complete() override; |
128 | void resize(const geometry::Size &newsize) override; |
129 | + geometry::Size size() const override; |
130 | int buffers_ready_for_compositor(void const* user_id) const override; |
131 | int buffers_free_for_client() const override; |
132 | bool framedropping_allowed() const; |
133 | |
134 | === removed file 'src/include/server/mir/compositor/buffer_stream.h' |
135 | --- src/include/server/mir/compositor/buffer_stream.h 2015-01-21 08:53:28 +0000 |
136 | +++ src/include/server/mir/compositor/buffer_stream.h 1970-01-01 00:00:00 +0000 |
137 | @@ -1,63 +0,0 @@ |
138 | -/* |
139 | - * Copyright © 2012-2014 Canonical Ltd. |
140 | - * |
141 | - * This program is free software: you can redistribute it and/or modify it |
142 | - * under the terms of the GNU General Public License version 3, |
143 | - * as published by the Free Software Foundation. |
144 | - * |
145 | - * This program is distributed in the hope that it will be useful, |
146 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
147 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
148 | - * GNU General Public License for more details. |
149 | - * |
150 | - * You should have received a copy of the GNU General Public License |
151 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
152 | - * |
153 | - * Authored by: |
154 | - * Kevin DuBois <kevin.dubois@canonical.com> |
155 | - */ |
156 | - |
157 | -#ifndef MIR_COMPOSITOR_BUFFER_STREAM_H_ |
158 | -#define MIR_COMPOSITOR_BUFFER_STREAM_H_ |
159 | - |
160 | -#include "mir/geometry/size.h" |
161 | -#include "mir_toolkit/common.h" |
162 | -#include "mir/graphics/buffer_id.h" |
163 | - |
164 | -#include <memory> |
165 | - |
166 | -namespace mir |
167 | -{ |
168 | -namespace graphics |
169 | -{ |
170 | -class Buffer; |
171 | -} |
172 | - |
173 | -namespace compositor |
174 | -{ |
175 | - |
176 | -class BufferStream |
177 | -{ |
178 | -public: |
179 | - virtual ~BufferStream() = default; |
180 | - |
181 | - virtual void acquire_client_buffer( |
182 | - std::function<void(graphics::Buffer* buffer)> complete) = 0; |
183 | - virtual void release_client_buffer(graphics::Buffer* buf) = 0; |
184 | - virtual std::shared_ptr<graphics::Buffer> |
185 | - lock_compositor_buffer(void const* user_id) = 0; |
186 | - virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0; |
187 | - virtual MirPixelFormat get_stream_pixel_format() = 0; |
188 | - virtual geometry::Size stream_size() = 0; |
189 | - virtual void resize(geometry::Size const& size) = 0; |
190 | - virtual void allow_framedropping(bool) = 0; |
191 | - virtual void force_requests_to_complete() = 0; |
192 | - virtual int buffers_ready_for_compositor(void const* user_id) const = 0; |
193 | - virtual void drop_old_buffers() = 0; |
194 | - virtual void drop_client_requests() = 0; |
195 | -}; |
196 | - |
197 | -} |
198 | -} |
199 | - |
200 | -#endif /* MIR_COMPOSITOR_BUFFER_STREAM_H_ */ |
201 | |
202 | === modified file 'src/include/server/mir/default_server_configuration.h' |
203 | --- src/include/server/mir/default_server_configuration.h 2015-03-06 03:52:41 +0000 |
204 | +++ src/include/server/mir/default_server_configuration.h 2015-03-20 19:31:52 +0000 |
205 | @@ -45,7 +45,7 @@ |
206 | namespace compositor |
207 | { |
208 | class Renderer; |
209 | -class BufferStreamFactory; |
210 | +class BufferQueueFactory; |
211 | class Scene; |
212 | class Drawer; |
213 | class DisplayBufferCompositorFactory; |
214 | @@ -87,7 +87,7 @@ |
215 | { |
216 | class SurfaceFactory; |
217 | class BroadcastingSessionEventSink; |
218 | -class BufferStreamFactory; |
219 | +class BufferQueueFactory; |
220 | class MediatingDisplayChanger; |
221 | class PixelBuffer; |
222 | class PlacementStrategy; |
223 | @@ -278,7 +278,7 @@ |
224 | /** @name scene configuration - dependencies |
225 | * dependencies of scene on the rest of the Mir |
226 | * @{ */ |
227 | - virtual std::shared_ptr<scene::BufferStreamFactory> the_buffer_stream_factory(); |
228 | + virtual std::shared_ptr<scene::BufferQueueFactory> the_buffer_queue_factory(); |
229 | virtual std::shared_ptr<scene::SceneReport> the_scene_report(); |
230 | /** @} */ |
231 | |
232 | @@ -389,7 +389,7 @@ |
233 | CachedPtr<frontend::ConnectionCreator> prompt_connection_creator; |
234 | CachedPtr<frontend::Screencast> screencast; |
235 | CachedPtr<compositor::RendererFactory> renderer_factory; |
236 | - CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory; |
237 | + CachedPtr<compositor::BufferQueueFactory> buffer_queue_factory; |
238 | CachedPtr<compositor::FrameDroppingPolicyFactory> frame_dropping_policy_factory; |
239 | CachedPtr<scene::SurfaceStack> surface_stack; |
240 | CachedPtr<scene::SceneReport> scene_report; |
241 | |
242 | === renamed file 'src/include/server/mir/scene/buffer_stream_factory.h' => 'src/include/server/mir/scene/buffer_queue_factory.h' |
243 | --- src/include/server/mir/scene/buffer_stream_factory.h 2015-03-16 03:39:55 +0000 |
244 | +++ src/include/server/mir/scene/buffer_queue_factory.h 2015-03-20 19:31:52 +0000 |
245 | @@ -18,33 +18,33 @@ |
246 | * Thomas Voss <thomas.voss@canonical.com> |
247 | */ |
248 | |
249 | -#ifndef MIR_SCENE_BUFFER_STREAM_FACTORY_H_ |
250 | -#define MIR_SCENE_BUFFER_STREAM_FACTORY_H_ |
251 | +#ifndef MIR_SCENE_BUFFER_QUEUE_FACTORY_H_ |
252 | +#define MIR_SCENE_BUFFER_QUEUE_FACTORY_H_ |
253 | |
254 | #include <memory> |
255 | |
256 | namespace mir |
257 | { |
258 | -namespace compositor { class BufferStream; } |
259 | +namespace compositor { class BufferBundle; } |
260 | namespace graphics { struct BufferProperties; } |
261 | |
262 | namespace scene |
263 | { |
264 | -class BufferStreamFactory |
265 | +class BufferQueueFactory |
266 | { |
267 | public: |
268 | - virtual ~BufferStreamFactory() = default; |
269 | + virtual ~BufferQueueFactory() = default; |
270 | |
271 | - virtual std::shared_ptr<compositor::BufferStream> create_buffer_stream( |
272 | - int nbuffers, graphics::BufferProperties const& buffer_properties) = 0; |
273 | + virtual std::shared_ptr<compositor::BufferBundle> create_buffer_queue( |
274 | + int nbuffers, graphics::BufferProperties const& buffer_properties) = 0; |
275 | |
276 | protected: |
277 | - BufferStreamFactory() = default; |
278 | - BufferStreamFactory(const BufferStreamFactory&) = delete; |
279 | - BufferStreamFactory& operator=(const BufferStreamFactory&) = delete; |
280 | + BufferQueueFactory() = default; |
281 | + BufferQueueFactory(const BufferQueueFactory&) = delete; |
282 | + BufferQueueFactory& operator=(const BufferQueueFactory&) = delete; |
283 | }; |
284 | |
285 | } |
286 | } |
287 | |
288 | -#endif // MIR_SCENE_BUFFER_STREAM_FACTORY_H_ |
289 | +#endif // MIR_SCENE_BUFFER_QUEUE_FACTORY_H_ |
290 | |
291 | === modified file 'src/server/compositor/CMakeLists.txt' |
292 | --- src/server/compositor/CMakeLists.txt 2015-01-21 07:34:50 +0000 |
293 | +++ src/server/compositor/CMakeLists.txt 2015-03-20 19:31:52 +0000 |
294 | @@ -3,9 +3,7 @@ |
295 | |
296 | default_display_buffer_compositor.cpp |
297 | default_display_buffer_compositor_factory.cpp |
298 | - temporary_buffers.cpp |
299 | - buffer_stream_factory.cpp |
300 | - buffer_stream_surfaces.cpp |
301 | + buffer_queue_factory.cpp |
302 | gl_renderer.cpp |
303 | gl_renderer_factory.cpp |
304 | gl_program_family.cpp |
305 | @@ -16,6 +14,7 @@ |
306 | compositing_screencast.cpp |
307 | timeout_frame_dropping_policy_factory.cpp |
308 | buffer_queue.cpp |
309 | + buffer_handle.cpp |
310 | recently_used_cache.cpp |
311 | ) |
312 | |
313 | |
314 | === added file 'src/server/compositor/buffer_handle.cpp' |
315 | --- src/server/compositor/buffer_handle.cpp 1970-01-01 00:00:00 +0000 |
316 | +++ src/server/compositor/buffer_handle.cpp 2015-03-20 19:31:52 +0000 |
317 | @@ -0,0 +1,63 @@ |
318 | +/* |
319 | + * Copyright © 2015 Canonical Ltd. |
320 | + * |
321 | + * This program is free software: you can redistribute it and/or modify it |
322 | + * under the terms of the GNU General Public License version 3, |
323 | + * as published by the Free Software Foundation. |
324 | + * |
325 | + * This program is distributed in the hope that it will be useful, |
326 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
327 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
328 | + * GNU General Public License for more details. |
329 | + * |
330 | + * You should have received a copy of the GNU General Public License |
331 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
332 | + * |
333 | + * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
334 | + */ |
335 | + |
336 | +#include "mir/compositor/buffer_handle.h" |
337 | + |
338 | +namespace mc = mir::compositor; |
339 | +namespace mg = mir::graphics; |
340 | + |
341 | +mc::BufferHandle::BufferHandle(std::shared_ptr<mg::Buffer> const& buffer, |
342 | + ReleaseCallback const& release) |
343 | + : wrapped(buffer), |
344 | + release_fn(release) |
345 | +{ |
346 | +} |
347 | + |
348 | +mc::BufferHandle::BufferHandle(BufferHandle&& other) |
349 | + : wrapped(std::move(other.wrapped)) |
350 | +{ |
351 | + // We can't std:move a std::function as it leaves the "other" unspecified |
352 | + release_fn.swap(other.release_fn); |
353 | +} |
354 | + |
355 | +mc::BufferHandle& mc::BufferHandle::operator=(BufferHandle&& other) |
356 | +{ |
357 | + if (this != &other) |
358 | + { |
359 | + wrapped = std::move(other.wrapped); |
360 | + release_fn.swap(other.release_fn); |
361 | + } |
362 | + |
363 | + return *this; |
364 | +} |
365 | + |
366 | +bool mc::BufferHandle::operator!() |
367 | +{ |
368 | + return (wrapped == nullptr); |
369 | +} |
370 | + |
371 | +mc::BufferHandle::~BufferHandle() |
372 | +{ |
373 | + if (release_fn) |
374 | + release_fn(wrapped.get()); |
375 | +} |
376 | + |
377 | +std::shared_ptr<mg::Buffer> mc::BufferHandle::buffer() |
378 | +{ |
379 | + return wrapped; |
380 | +} |
381 | |
382 | === modified file 'src/server/compositor/buffer_queue.cpp' |
383 | --- src/server/compositor/buffer_queue.cpp 2015-03-06 03:52:41 +0000 |
384 | +++ src/server/compositor/buffer_queue.cpp 2015-03-20 19:31:52 +0000 |
385 | @@ -15,10 +15,11 @@ |
386 | * |
387 | */ |
388 | |
389 | -#include "buffer_queue.h" |
390 | +#include "mir/compositor/buffer_queue.h" |
391 | |
392 | #include "mir/graphics/graphic_buffer_allocator.h" |
393 | #include "mir/graphics/buffer_id.h" |
394 | +#include "mir/compositor/buffer_handle.h" |
395 | #include "mir/lockable_callback.h" |
396 | |
397 | #include <boost/throw_exception.hpp> |
398 | @@ -28,6 +29,7 @@ |
399 | |
400 | namespace mc = mir::compositor; |
401 | namespace mg = mir::graphics; |
402 | +namespace geom = mir::geometry; |
403 | |
404 | namespace |
405 | { |
406 | @@ -239,8 +241,7 @@ |
407 | ready_to_composite_queue.push_back(buffer); |
408 | } |
409 | |
410 | -std::shared_ptr<mg::Buffer> |
411 | -mc::BufferQueue::compositor_acquire(void const* user_id) |
412 | +mc::BufferHandle mc::BufferQueue::compositor_acquire(void const* user_id) |
413 | { |
414 | std::unique_lock<decltype(guard)> lock(guard); |
415 | |
416 | @@ -285,53 +286,56 @@ |
417 | |
418 | buffers_sent_to_compositor.push_back(current_compositor_buffer); |
419 | |
420 | - std::shared_ptr<mg::Buffer> const acquired_buffer = |
421 | - buffer_for(current_compositor_buffer, buffers); |
422 | + std::weak_ptr<BufferQueue> weak_this = shared_from_this(); |
423 | + |
424 | + mc::BufferHandle acquired_buffer( |
425 | + buffer_for(current_compositor_buffer, buffers), |
426 | + [weak_this](mg::Buffer* b) |
427 | + { |
428 | + if (auto self = weak_this.lock()) |
429 | + { |
430 | + std::unique_lock<decltype(self->guard)> lock(self->guard); |
431 | + |
432 | + remove(b, self->buffers_sent_to_compositor); |
433 | + |
434 | + /* Not ready to release it yet, other compositors still reference this buffer */ |
435 | + if (contains(b, self->buffers_sent_to_compositor)) |
436 | + return; |
437 | + |
438 | + if (self->nbuffers <= 1) |
439 | + return; |
440 | + |
441 | + if (self->current_compositor_buffer != b) |
442 | + self->release(b, std::move(lock)); |
443 | + } |
444 | + }); |
445 | |
446 | if (buffer_to_release) |
447 | release(buffer_to_release, std::move(lock)); |
448 | |
449 | - return acquired_buffer; |
450 | -} |
451 | - |
452 | -void mc::BufferQueue::compositor_release(std::shared_ptr<graphics::Buffer> const& buffer) |
453 | -{ |
454 | - std::unique_lock<decltype(guard)> lock(guard); |
455 | - |
456 | - if (!remove(buffer.get(), buffers_sent_to_compositor)) |
457 | - { |
458 | - BOOST_THROW_EXCEPTION( |
459 | - std::logic_error("unexpected release: buffer was not given to compositor")); |
460 | - } |
461 | - |
462 | - /* Not ready to release it yet, other compositors still reference this buffer */ |
463 | - if (contains(buffer.get(), buffers_sent_to_compositor)) |
464 | - return; |
465 | - |
466 | - if (nbuffers <= 1) |
467 | - return; |
468 | - |
469 | - if (current_compositor_buffer != buffer.get()) |
470 | - release(buffer.get(), std::move(lock)); |
471 | -} |
472 | - |
473 | -std::shared_ptr<mg::Buffer> mc::BufferQueue::snapshot_acquire() |
474 | + return std::move(acquired_buffer); |
475 | +} |
476 | + |
477 | +mc::BufferHandle mc::BufferQueue::snapshot_acquire() |
478 | { |
479 | std::unique_lock<decltype(guard)> lock(guard); |
480 | pending_snapshots.push_back(current_compositor_buffer); |
481 | - return buffer_for(current_compositor_buffer, buffers); |
482 | -} |
483 | - |
484 | -void mc::BufferQueue::snapshot_release(std::shared_ptr<graphics::Buffer> const& buffer) |
485 | -{ |
486 | - std::unique_lock<std::mutex> lock(guard); |
487 | - if (!remove(buffer.get(), pending_snapshots)) |
488 | - { |
489 | - BOOST_THROW_EXCEPTION( |
490 | - std::logic_error("unexpected release: no buffers were given to snapshotter")); |
491 | - } |
492 | - |
493 | - snapshot_released.notify_all(); |
494 | + |
495 | + std::weak_ptr<BufferQueue> weak_this = shared_from_this(); |
496 | + |
497 | + return std::move(mc::BufferHandle( |
498 | + buffer_for(current_compositor_buffer, buffers), |
499 | + [weak_this](mg::Buffer* b) |
500 | + { |
501 | + if (auto self = weak_this.lock()) |
502 | + { |
503 | + std::unique_lock<std::mutex> lock(self->guard); |
504 | + |
505 | + remove(b, self->pending_snapshots); |
506 | + |
507 | + self->snapshot_released.notify_all(); |
508 | + } |
509 | + })); |
510 | } |
511 | |
512 | mg::BufferProperties mc::BufferQueue::properties() const |
513 | @@ -367,6 +371,11 @@ |
514 | } |
515 | } |
516 | |
517 | +geom::Size mc::BufferQueue::size() const |
518 | +{ |
519 | + return properties().size; |
520 | +} |
521 | + |
522 | void mc::BufferQueue::resize(geometry::Size const& new_size) |
523 | { |
524 | std::lock_guard<decltype(guard)> lock(guard); |
525 | |
526 | === renamed file 'src/server/compositor/buffer_stream_factory.cpp' => 'src/server/compositor/buffer_queue_factory.cpp' |
527 | --- src/server/compositor/buffer_stream_factory.cpp 2015-03-16 03:39:55 +0000 |
528 | +++ src/server/compositor/buffer_queue_factory.cpp 2015-03-20 19:31:52 +0000 |
529 | @@ -18,10 +18,9 @@ |
530 | * Thomas Voss <thomas.voss@canonical.com> |
531 | */ |
532 | |
533 | -#include "buffer_stream_factory.h" |
534 | -#include "buffer_stream_surfaces.h" |
535 | +#include "buffer_queue_factory.h" |
536 | #include "mir/graphics/buffer_properties.h" |
537 | -#include "buffer_queue.h" |
538 | +#include "mir/compositor/buffer_queue.h" |
539 | #include "mir/graphics/buffer.h" |
540 | #include "mir/graphics/buffer_id.h" |
541 | #include "mir/graphics/graphic_buffer_allocator.h" |
542 | @@ -32,10 +31,9 @@ |
543 | |
544 | namespace mc = mir::compositor; |
545 | namespace mg = mir::graphics; |
546 | -namespace ms = mir::scene; |
547 | |
548 | -mc::BufferStreamFactory::BufferStreamFactory(std::shared_ptr<mg::GraphicBufferAllocator> const& gralloc, |
549 | - std::shared_ptr<mc::FrameDroppingPolicyFactory> const& policy_factory) |
550 | +mc::BufferQueueFactory::BufferQueueFactory(std::shared_ptr<mg::GraphicBufferAllocator> const& gralloc, |
551 | + std::shared_ptr<mc::FrameDroppingPolicyFactory> const& policy_factory) |
552 | : gralloc(gralloc), |
553 | policy_factory{policy_factory} |
554 | { |
555 | @@ -43,11 +41,8 @@ |
556 | assert(policy_factory); |
557 | } |
558 | |
559 | - |
560 | -std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream( |
561 | - int nbuffers, mg::BufferProperties const& buffer_properties) |
562 | +std::shared_ptr<mc::BufferBundle> mc::BufferQueueFactory::create_buffer_queue( |
563 | + int nbuffers, mg::BufferProperties const& buffer_properties) |
564 | { |
565 | - auto switching_bundle = std::make_shared<mc::BufferQueue>( |
566 | - nbuffers, gralloc, buffer_properties, *policy_factory); |
567 | - return std::make_shared<mc::BufferStreamSurfaces>(switching_bundle); |
568 | + return std::make_shared<mc::BufferQueue>(nbuffers, gralloc, buffer_properties, *policy_factory); |
569 | } |
570 | |
571 | === renamed file 'src/server/compositor/buffer_stream_factory.h' => 'src/server/compositor/buffer_queue_factory.h' |
572 | --- src/server/compositor/buffer_stream_factory.h 2015-03-16 03:39:55 +0000 |
573 | +++ src/server/compositor/buffer_queue_factory.h 2015-03-20 19:31:52 +0000 |
574 | @@ -18,10 +18,10 @@ |
575 | * Thomas Voss <thomas.voss@canonical.com> |
576 | */ |
577 | |
578 | -#ifndef MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ |
579 | -#define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ |
580 | +#ifndef MIR_COMPOSITOR_BUFFER_QUEUE_FACTORY_H_ |
581 | +#define MIR_COMPOSITOR_BUFFER_QUEUE_FACTORY_H_ |
582 | |
583 | -#include "mir/scene/buffer_stream_factory.h" |
584 | +#include "mir/scene/buffer_queue_factory.h" |
585 | #include "mir/compositor/frame_dropping_policy_factory.h" |
586 | |
587 | #include <memory> |
588 | @@ -35,16 +35,16 @@ |
589 | namespace compositor |
590 | { |
591 | |
592 | -class BufferStreamFactory : public scene::BufferStreamFactory |
593 | +class BufferQueueFactory : public scene::BufferQueueFactory |
594 | { |
595 | public: |
596 | - BufferStreamFactory(std::shared_ptr<graphics::GraphicBufferAllocator> const& gralloc, |
597 | - std::shared_ptr<FrameDroppingPolicyFactory> const& policy_factory); |
598 | - |
599 | - virtual ~BufferStreamFactory() {} |
600 | - |
601 | - virtual std::shared_ptr<BufferStream> create_buffer_stream( |
602 | - int nbuffers, graphics::BufferProperties const&) override; |
603 | + BufferQueueFactory(std::shared_ptr<graphics::GraphicBufferAllocator> const& gralloc, |
604 | + std::shared_ptr<FrameDroppingPolicyFactory> const& policy_factory); |
605 | + |
606 | + virtual ~BufferQueueFactory() {} |
607 | + |
608 | + virtual std::shared_ptr<BufferBundle> create_buffer_queue( |
609 | + int nbuffers, graphics::BufferProperties const& buffer_properties) override; |
610 | |
611 | private: |
612 | std::shared_ptr<graphics::GraphicBufferAllocator> gralloc; |
613 | @@ -55,4 +55,4 @@ |
614 | } |
615 | |
616 | |
617 | -#endif /* MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ */ |
618 | +#endif /* MIR_COMPOSITOR_BUFFER_QUEUE_FACTORY_H_ */ |
619 | |
620 | === removed file 'src/server/compositor/buffer_stream_surfaces.cpp' |
621 | --- src/server/compositor/buffer_stream_surfaces.cpp 2015-01-21 08:53:28 +0000 |
622 | +++ src/server/compositor/buffer_stream_surfaces.cpp 1970-01-01 00:00:00 +0000 |
623 | @@ -1,101 +0,0 @@ |
624 | -/* |
625 | - * Copyright © 2012 Canonical Ltd. |
626 | - * |
627 | - * This program is free software: you can redistribute it and/or modify it |
628 | - * under the terms of the GNU General Public License version 3, |
629 | - * as published by the Free Software Foundation. |
630 | - * |
631 | - * This program is distributed in the hope that it will be useful, |
632 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
633 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
634 | - * GNU General Public License for more details. |
635 | - * |
636 | - * You should have received a copy of the GNU General Public License |
637 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
638 | - * |
639 | - * Authored by: |
640 | - * Kevin DuBois <kevin.dubois@canonical.com> |
641 | - */ |
642 | - |
643 | -#include "buffer_stream_surfaces.h" |
644 | -#include "buffer_bundle.h" |
645 | -#include "mir/graphics/buffer_properties.h" |
646 | - |
647 | -#include "temporary_buffers.h" |
648 | - |
649 | -namespace mc = mir::compositor; |
650 | -namespace mg = mir::graphics; |
651 | -namespace geom = mir::geometry; |
652 | - |
653 | -mc::BufferStreamSurfaces::BufferStreamSurfaces(std::shared_ptr<BufferBundle> const& buffer_bundle) |
654 | - : buffer_bundle(buffer_bundle) |
655 | -{ |
656 | -} |
657 | - |
658 | -mc::BufferStreamSurfaces::~BufferStreamSurfaces() |
659 | -{ |
660 | - force_requests_to_complete(); |
661 | -} |
662 | - |
663 | -std::shared_ptr<mg::Buffer> mc::BufferStreamSurfaces::lock_compositor_buffer( |
664 | - void const* user_id) |
665 | -{ |
666 | - return std::make_shared<mc::TemporaryCompositorBuffer>( |
667 | - buffer_bundle, user_id); |
668 | -} |
669 | - |
670 | -std::shared_ptr<mg::Buffer> mc::BufferStreamSurfaces::lock_snapshot_buffer() |
671 | -{ |
672 | - return std::make_shared<mc::TemporarySnapshotBuffer>(buffer_bundle); |
673 | -} |
674 | - |
675 | -void mc::BufferStreamSurfaces::acquire_client_buffer( |
676 | - std::function<void(graphics::Buffer* buffer)> complete) |
677 | -{ |
678 | - buffer_bundle->client_acquire(complete); |
679 | -} |
680 | - |
681 | -void mc::BufferStreamSurfaces::release_client_buffer(graphics::Buffer* buf) |
682 | -{ |
683 | - buffer_bundle->client_release(buf); |
684 | -} |
685 | - |
686 | -MirPixelFormat mc::BufferStreamSurfaces::get_stream_pixel_format() |
687 | -{ |
688 | - return buffer_bundle->properties().format; |
689 | -} |
690 | - |
691 | -geom::Size mc::BufferStreamSurfaces::stream_size() |
692 | -{ |
693 | - return buffer_bundle->properties().size; |
694 | -} |
695 | - |
696 | -void mc::BufferStreamSurfaces::resize(geom::Size const& size) |
697 | -{ |
698 | - buffer_bundle->resize(size); |
699 | -} |
700 | - |
701 | -void mc::BufferStreamSurfaces::force_requests_to_complete() |
702 | -{ |
703 | - buffer_bundle->force_requests_to_complete(); |
704 | -} |
705 | - |
706 | -void mc::BufferStreamSurfaces::allow_framedropping(bool allow) |
707 | -{ |
708 | - buffer_bundle->allow_framedropping(allow); |
709 | -} |
710 | - |
711 | -int mc::BufferStreamSurfaces::buffers_ready_for_compositor(void const* user_id) const |
712 | -{ |
713 | - return buffer_bundle->buffers_ready_for_compositor(user_id); |
714 | -} |
715 | - |
716 | -void mc::BufferStreamSurfaces::drop_old_buffers() |
717 | -{ |
718 | - buffer_bundle->drop_old_buffers(); |
719 | -} |
720 | - |
721 | -void mc::BufferStreamSurfaces::drop_client_requests() |
722 | -{ |
723 | - buffer_bundle->drop_client_requests(); |
724 | -} |
725 | |
726 | === removed file 'src/server/compositor/buffer_stream_surfaces.h' |
727 | --- src/server/compositor/buffer_stream_surfaces.h 2015-01-21 08:53:28 +0000 |
728 | +++ src/server/compositor/buffer_stream_surfaces.h 1970-01-01 00:00:00 +0000 |
729 | @@ -1,69 +0,0 @@ |
730 | -/* |
731 | - * Copyright © 2012 Canonical Ltd. |
732 | - * |
733 | - * This program is free software: you can redistribute it and/or modify it |
734 | - * under the terms of the GNU General Public License version 3, |
735 | - * as published by the Free Software Foundation. |
736 | - * |
737 | - * This program is distributed in the hope that it will be useful, |
738 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
739 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
740 | - * GNU General Public License for more details. |
741 | - * |
742 | - * You should have received a copy of the GNU General Public License |
743 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
744 | - * |
745 | - * Authored by: |
746 | - * Kevin DuBois <kevin.dubois@canonical.com> |
747 | - */ |
748 | - |
749 | -#ifndef MIR_COMPOSITOR_BUFFER_STREAM_SCENE_H_ |
750 | -#define MIR_COMPOSITOR_BUFFER_STREAM_SCENE_H_ |
751 | - |
752 | -#include "mir/compositor/buffer_stream.h" |
753 | - |
754 | -#include <mutex> |
755 | - |
756 | -namespace mir |
757 | -{ |
758 | -namespace compositor |
759 | -{ |
760 | - |
761 | -class BufferIDUniqueGenerator; |
762 | -class BufferBundle; |
763 | -class BackBufferStrategy; |
764 | - |
765 | -class BufferStreamSurfaces : public BufferStream |
766 | -{ |
767 | -public: |
768 | - BufferStreamSurfaces(std::shared_ptr<BufferBundle> const& swapper); |
769 | - ~BufferStreamSurfaces(); |
770 | - |
771 | - void acquire_client_buffer(std::function<void(graphics::Buffer* buffer)> complete) override; |
772 | - void release_client_buffer(graphics::Buffer* buf) override; |
773 | - |
774 | - std::shared_ptr<graphics::Buffer> |
775 | - lock_compositor_buffer(void const* user_id) override; |
776 | - std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() override; |
777 | - |
778 | - MirPixelFormat get_stream_pixel_format() override; |
779 | - geometry::Size stream_size() override; |
780 | - void resize(geometry::Size const& size) override; |
781 | - void allow_framedropping(bool) override; |
782 | - void force_requests_to_complete() override; |
783 | - int buffers_ready_for_compositor(void const* user_id) const override; |
784 | - void drop_old_buffers() override; |
785 | - void drop_client_requests() override; |
786 | - |
787 | -protected: |
788 | - BufferStreamSurfaces(const BufferStreamSurfaces&) = delete; |
789 | - BufferStreamSurfaces& operator=(const BufferStreamSurfaces&) = delete; |
790 | - |
791 | -private: |
792 | - std::shared_ptr<BufferBundle> const buffer_bundle; |
793 | -}; |
794 | - |
795 | -} |
796 | -} |
797 | - |
798 | -#endif /* MIR_COMPOSITOR_BUFFER_STREAM_SCENE_H_ */ |
799 | |
800 | === modified file 'src/server/compositor/default_configuration.cpp' |
801 | --- src/server/compositor/default_configuration.cpp 2015-03-12 03:19:52 +0000 |
802 | +++ src/server/compositor/default_configuration.cpp 2015-03-20 19:31:52 +0000 |
803 | @@ -19,7 +19,7 @@ |
804 | #include "mir/default_server_configuration.h" |
805 | |
806 | #include "mir/shell/shell.h" |
807 | -#include "buffer_stream_factory.h" |
808 | +#include "buffer_queue_factory.h" |
809 | #include "default_display_buffer_compositor_factory.h" |
810 | #include "multi_threaded_compositor.h" |
811 | #include "gl_renderer_factory.h" |
812 | @@ -36,14 +36,14 @@ |
813 | namespace ms = mir::scene; |
814 | namespace mf = mir::frontend; |
815 | |
816 | -std::shared_ptr<ms::BufferStreamFactory> |
817 | -mir::DefaultServerConfiguration::the_buffer_stream_factory() |
818 | +std::shared_ptr<ms::BufferQueueFactory> |
819 | +mir::DefaultServerConfiguration::the_buffer_queue_factory() |
820 | { |
821 | - return buffer_stream_factory( |
822 | + return buffer_queue_factory( |
823 | [this]() |
824 | { |
825 | - return std::make_shared<mc::BufferStreamFactory>(the_buffer_allocator(), |
826 | - the_frame_dropping_policy_factory()); |
827 | + return std::make_shared<mc::BufferQueueFactory>(the_buffer_allocator(), |
828 | + the_frame_dropping_policy_factory()); |
829 | }); |
830 | } |
831 | |
832 | |
833 | === modified file 'src/server/compositor/default_display_buffer_compositor.cpp' |
834 | --- src/server/compositor/default_display_buffer_compositor.cpp 2015-03-12 03:19:52 +0000 |
835 | +++ src/server/compositor/default_display_buffer_compositor.cpp 2015-03-20 19:31:52 +0000 |
836 | @@ -25,7 +25,6 @@ |
837 | #include "mir/graphics/renderable.h" |
838 | #include "mir/graphics/display_buffer.h" |
839 | #include "mir/graphics/buffer.h" |
840 | -#include "mir/compositor/buffer_stream.h" |
841 | #include "occlusion.h" |
842 | #include <mutex> |
843 | #include <cstdlib> |
844 | |
845 | === modified file 'src/server/compositor/gl_renderer.cpp' |
846 | --- src/server/compositor/gl_renderer.cpp 2015-03-06 03:52:41 +0000 |
847 | +++ src/server/compositor/gl_renderer.cpp 2015-03-20 19:31:52 +0000 |
848 | @@ -17,7 +17,6 @@ |
849 | |
850 | #define MIR_LOG_COMPONENT "GL" |
851 | #include "mir/compositor/gl_renderer.h" |
852 | -#include "mir/compositor/buffer_stream.h" |
853 | #include "mir/compositor/destination_alpha.h" |
854 | #include "mir/graphics/renderable.h" |
855 | #include "mir/graphics/buffer.h" |
856 | |
857 | === removed file 'src/server/compositor/temporary_buffers.cpp' |
858 | --- src/server/compositor/temporary_buffers.cpp 2015-03-06 03:52:41 +0000 |
859 | +++ src/server/compositor/temporary_buffers.cpp 1970-01-01 00:00:00 +0000 |
860 | @@ -1,92 +0,0 @@ |
861 | -/* |
862 | - * Copyright © 2012 Canonical Ltd. |
863 | - * |
864 | - * This program is free software: you can redistribute it and/or modify it |
865 | - * under the terms of the GNU General Public License version 3, |
866 | - * as published by the Free Software Foundation. |
867 | - * |
868 | - * This program is distributed in the hope that it will be useful, |
869 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
870 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
871 | - * GNU General Public License for more details. |
872 | - * |
873 | - * You should have received a copy of the GNU General Public License |
874 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
875 | - * |
876 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
877 | - */ |
878 | - |
879 | -#include "buffer_bundle.h" |
880 | -#include "temporary_buffers.h" |
881 | - |
882 | -#include <boost/throw_exception.hpp> |
883 | -#include <stdexcept> |
884 | - |
885 | -namespace mc=mir::compositor; |
886 | -namespace mg=mir::graphics; |
887 | -namespace geom=mir::geometry; |
888 | - |
889 | -mc::TemporaryBuffer::TemporaryBuffer(std::shared_ptr<mg::Buffer> const& real_buffer) |
890 | - : buffer(real_buffer) |
891 | -{ |
892 | -} |
893 | - |
894 | -mc::TemporaryCompositorBuffer::TemporaryCompositorBuffer( |
895 | - std::shared_ptr<BufferBundle> const& bun, void const* user_id) |
896 | - : TemporaryBuffer(bun->compositor_acquire(user_id)), |
897 | - bundle(bun) |
898 | -{ |
899 | -} |
900 | - |
901 | -mc::TemporaryCompositorBuffer::~TemporaryCompositorBuffer() |
902 | -{ |
903 | - bundle->compositor_release(buffer); |
904 | -} |
905 | - |
906 | -mc::TemporarySnapshotBuffer::TemporarySnapshotBuffer( |
907 | - std::shared_ptr<BufferBundle> const& bun) |
908 | - : TemporaryBuffer(bun->snapshot_acquire()), |
909 | - bundle(bun) |
910 | -{ |
911 | -} |
912 | - |
913 | -mc::TemporarySnapshotBuffer::~TemporarySnapshotBuffer() |
914 | -{ |
915 | - bundle->snapshot_release(buffer); |
916 | -} |
917 | - |
918 | -geom::Size mc::TemporaryBuffer::size() const |
919 | -{ |
920 | - return buffer->size(); |
921 | -} |
922 | - |
923 | -geom::Stride mc::TemporaryBuffer::stride() const |
924 | -{ |
925 | - return buffer->stride(); |
926 | -} |
927 | - |
928 | -MirPixelFormat mc::TemporaryBuffer::pixel_format() const |
929 | -{ |
930 | - return buffer->pixel_format(); |
931 | -} |
932 | - |
933 | -mg::BufferID mc::TemporaryBuffer::id() const |
934 | -{ |
935 | - return buffer->id(); |
936 | -} |
937 | - |
938 | -void mc::TemporaryBuffer::gl_bind_to_texture() |
939 | -{ |
940 | - buffer->gl_bind_to_texture(); |
941 | -} |
942 | - |
943 | -std::shared_ptr<mg::NativeBuffer> mc::TemporaryBuffer::native_buffer_handle() const |
944 | -{ |
945 | - return buffer->native_buffer_handle(); |
946 | -} |
947 | - |
948 | -void mc::TemporaryBuffer::write(unsigned char const*, size_t) |
949 | -{ |
950 | - BOOST_THROW_EXCEPTION( |
951 | - std::runtime_error("Write to temporary buffer snapshot is ill advised and indicates programmer error")); |
952 | -} |
953 | |
954 | === removed file 'src/server/compositor/temporary_buffers.h' |
955 | --- src/server/compositor/temporary_buffers.h 2015-03-06 03:52:41 +0000 |
956 | +++ src/server/compositor/temporary_buffers.h 1970-01-01 00:00:00 +0000 |
957 | @@ -1,76 +0,0 @@ |
958 | -/* |
959 | - * Copyright © 2012 Canonical Ltd. |
960 | - * |
961 | - * This program is free software: you can redistribute it and/or modify it |
962 | - * under the terms of the GNU General Public License version 3, |
963 | - * as published by the Free Software Foundation. |
964 | - * |
965 | - * This program is distributed in the hope that it will be useful, |
966 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
967 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
968 | - * GNU General Public License for more details. |
969 | - * |
970 | - * You should have received a copy of the GNU General Public License |
971 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
972 | - * |
973 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
974 | - */ |
975 | - |
976 | -#ifndef MIR_COMPOSITOR_TEMPORARY_BUFFERS_H_ |
977 | -#define MIR_COMPOSITOR_TEMPORARY_BUFFERS_H_ |
978 | - |
979 | -#include "mir/graphics/buffer.h" |
980 | -#include "mir/graphics/buffer_id.h" |
981 | - |
982 | -namespace mg = mir::graphics; |
983 | - |
984 | -namespace mir |
985 | -{ |
986 | -namespace compositor |
987 | -{ |
988 | - |
989 | -class BufferBundle; |
990 | -class BackBufferStrategy; |
991 | - |
992 | -class TemporaryBuffer : public mg::Buffer |
993 | -{ |
994 | -public: |
995 | - geometry::Size size() const override; |
996 | - geometry::Stride stride() const override; |
997 | - MirPixelFormat pixel_format() const override; |
998 | - mg::BufferID id() const override; |
999 | - void gl_bind_to_texture() override; |
1000 | - std::shared_ptr<mg::NativeBuffer> native_buffer_handle() const override; |
1001 | - void write (unsigned char const* data, size_t size) override; |
1002 | - |
1003 | -protected: |
1004 | - explicit TemporaryBuffer(std::shared_ptr<mg::Buffer> const& real_buffer); |
1005 | - std::shared_ptr<mg::Buffer> const buffer; |
1006 | -}; |
1007 | - |
1008 | -class TemporaryCompositorBuffer : public TemporaryBuffer |
1009 | -{ |
1010 | -public: |
1011 | - explicit TemporaryCompositorBuffer( |
1012 | - std::shared_ptr<BufferBundle> const& bun, void const* user_id); |
1013 | - ~TemporaryCompositorBuffer(); |
1014 | - |
1015 | -private: |
1016 | - std::shared_ptr<BufferBundle> const bundle; |
1017 | -}; |
1018 | - |
1019 | -class TemporarySnapshotBuffer : public TemporaryBuffer |
1020 | -{ |
1021 | -public: |
1022 | - explicit TemporarySnapshotBuffer( |
1023 | - std::shared_ptr<BufferBundle> const& bun); |
1024 | - ~TemporarySnapshotBuffer(); |
1025 | - |
1026 | -private: |
1027 | - std::shared_ptr<BufferBundle> const bundle; |
1028 | -}; |
1029 | - |
1030 | -} |
1031 | -} |
1032 | - |
1033 | -#endif /* MIR_COMPOSITOR_TEMPORARY_BUFFERS_H_ */ |
1034 | |
1035 | === modified file 'src/server/frontend/session_mediator.cpp' |
1036 | --- src/server/frontend/session_mediator.cpp 2015-03-13 05:12:55 +0000 |
1037 | +++ src/server/frontend/session_mediator.cpp 2015-03-20 19:31:52 +0000 |
1038 | @@ -30,7 +30,6 @@ |
1039 | #include "mir/graphics/buffer_id.h" |
1040 | #include "mir/graphics/buffer.h" |
1041 | #include "mir/input/cursor_images.h" |
1042 | -#include "mir/compositor/buffer_stream.h" |
1043 | #include "mir/geometry/dimensions.h" |
1044 | #include "mir/frontend/display_changer.h" |
1045 | #include "mir/graphics/display_configuration.h" |
1046 | |
1047 | === modified file 'src/server/scene/basic_surface.cpp' |
1048 | --- src/server/scene/basic_surface.cpp 2015-03-18 18:48:02 +0000 |
1049 | +++ src/server/scene/basic_surface.cpp 2015-03-20 19:31:52 +0000 |
1050 | @@ -19,15 +19,14 @@ |
1051 | */ |
1052 | |
1053 | #include "basic_surface.h" |
1054 | -#include "mir/compositor/buffer_stream.h" |
1055 | #include "mir/frontend/event_sink.h" |
1056 | #include "mir/input/input_channel.h" |
1057 | #include "mir/shell/input_targeter.h" |
1058 | #include "mir/input/input_sender.h" |
1059 | #include "mir/graphics/buffer.h" |
1060 | #include "mir/geometry/displacement.h" |
1061 | - |
1062 | #include "mir/scene/scene_report.h" |
1063 | +#include "mir/compositor/buffer_bundle.h" |
1064 | |
1065 | #include <boost/throw_exception.hpp> |
1066 | |
1067 | @@ -119,7 +118,7 @@ |
1068 | geometry::Rectangle rect, |
1069 | std::weak_ptr<Surface> const& parent, |
1070 | bool nonrectangular, |
1071 | - std::shared_ptr<mc::BufferStream> const& buffer_stream, |
1072 | + std::shared_ptr<mc::BufferBundle> const& buffer_queue, |
1073 | std::shared_ptr<mi::InputChannel> const& input_channel, |
1074 | std::shared_ptr<input::InputSender> const& input_sender, |
1075 | std::shared_ptr<mg::CursorImage> const& cursor_image, |
1076 | @@ -132,7 +131,7 @@ |
1077 | input_mode(mi::InputReceptionMode::normal), |
1078 | nonrectangular(nonrectangular), |
1079 | custom_input_rectangles(), |
1080 | - surface_buffer_stream(buffer_stream), |
1081 | + buffer_queue(buffer_queue), |
1082 | server_input_channel(input_channel), |
1083 | input_sender(input_sender), |
1084 | cursor_image_(cursor_image), |
1085 | @@ -146,32 +145,27 @@ |
1086 | std::string const& name, |
1087 | geometry::Rectangle rect, |
1088 | bool nonrectangular, |
1089 | - std::shared_ptr<mc::BufferStream> const& buffer_stream, |
1090 | + std::shared_ptr<mc::BufferBundle> const& buffer_queue, |
1091 | std::shared_ptr<mi::InputChannel> const& input_channel, |
1092 | std::shared_ptr<input::InputSender> const& input_sender, |
1093 | std::shared_ptr<mg::CursorImage> const& cursor_image, |
1094 | std::shared_ptr<SceneReport> const& report) : |
1095 | - BasicSurface(name, rect, std::shared_ptr<Surface>{nullptr}, nonrectangular,buffer_stream, |
1096 | + BasicSurface(name, rect, std::shared_ptr<Surface>{nullptr}, nonrectangular, buffer_queue, |
1097 | input_channel, input_sender, cursor_image, report) |
1098 | { |
1099 | } |
1100 | |
1101 | void ms::BasicSurface::force_requests_to_complete() |
1102 | { |
1103 | - surface_buffer_stream->force_requests_to_complete(); |
1104 | + buffer_queue->force_requests_to_complete(); |
1105 | } |
1106 | |
1107 | ms::BasicSurface::~BasicSurface() noexcept |
1108 | { |
1109 | report->surface_deleted(this, surface_name); |
1110 | |
1111 | - if (surface_buffer_stream) // some tests use null for surface_buffer_stream |
1112 | - surface_buffer_stream->drop_client_requests(); |
1113 | -} |
1114 | - |
1115 | -std::shared_ptr<mc::BufferStream> ms::BasicSurface::buffer_stream() const |
1116 | -{ |
1117 | - return surface_buffer_stream; |
1118 | + if (buffer_queue) |
1119 | + buffer_queue->drop_client_requests(); |
1120 | } |
1121 | |
1122 | std::string ms::BasicSurface::name() const |
1123 | @@ -217,14 +211,14 @@ |
1124 | |
1125 | MirPixelFormat ms::BasicSurface::pixel_format() const |
1126 | { |
1127 | - return surface_buffer_stream->get_stream_pixel_format(); |
1128 | + return buffer_queue->properties().format; |
1129 | } |
1130 | |
1131 | void ms::BasicSurface::swap_buffers(mg::Buffer* old_buffer, std::function<void(mg::Buffer* new_buffer)> complete) |
1132 | { |
1133 | if (old_buffer) |
1134 | { |
1135 | - surface_buffer_stream->release_client_buffer(old_buffer); |
1136 | + buffer_queue->client_release(old_buffer); |
1137 | { |
1138 | std::unique_lock<std::mutex> lk(guard); |
1139 | first_frame_posted = true; |
1140 | @@ -238,17 +232,12 @@ |
1141 | observers.frame_posted(1); |
1142 | } |
1143 | |
1144 | - surface_buffer_stream->acquire_client_buffer(complete); |
1145 | + buffer_queue->client_acquire(complete); |
1146 | } |
1147 | |
1148 | void ms::BasicSurface::allow_framedropping(bool allow) |
1149 | { |
1150 | - surface_buffer_stream->allow_framedropping(allow); |
1151 | -} |
1152 | - |
1153 | -std::shared_ptr<mg::Buffer> ms::BasicSurface::snapshot_buffer() const |
1154 | -{ |
1155 | - return surface_buffer_stream->lock_snapshot_buffer(); |
1156 | + buffer_queue->allow_framedropping(allow); |
1157 | } |
1158 | |
1159 | bool ms::BasicSurface::supports_input() const |
1160 | @@ -291,7 +280,7 @@ |
1161 | * not predictable here. Such critical exceptions would arise from |
1162 | * the platform buffer allocator as a runtime_error via: |
1163 | */ |
1164 | - surface_buffer_stream->resize(new_size); |
1165 | + buffer_queue->resize(new_size); |
1166 | |
1167 | // Now the buffer stream has successfully resized, update the state second; |
1168 | { |
1169 | @@ -393,8 +382,8 @@ |
1170 | void ms::BasicSurface::with_most_recent_buffer_do( |
1171 | std::function<void(mg::Buffer&)> const& exec) |
1172 | { |
1173 | - auto buf = snapshot_buffer(); |
1174 | - exec(*buf); |
1175 | + auto buffer_handle = buffer_queue->snapshot_acquire(); |
1176 | + exec(*(buffer_handle.buffer())); |
1177 | } |
1178 | |
1179 | |
1180 | @@ -636,7 +625,7 @@ |
1181 | visibility_ = new_visibility; |
1182 | lg.unlock(); |
1183 | if (new_visibility == mir_surface_visibility_exposed) |
1184 | - surface_buffer_stream->drop_old_buffers(); |
1185 | + buffer_queue->drop_old_buffers(); |
1186 | observers.attrib_changed(mir_surface_attrib_visibility, visibility_); |
1187 | } |
1188 | |
1189 | @@ -669,15 +658,14 @@ |
1190 | { |
1191 | public: |
1192 | SurfaceSnapshot( |
1193 | - std::shared_ptr<mc::BufferStream> const& stream, |
1194 | + std::shared_ptr<mc::BufferBundle> const& bq, |
1195 | void const* compositor_id, |
1196 | geom::Rectangle const& position, |
1197 | glm::mat4 const& transform, |
1198 | float alpha, |
1199 | bool shaped, |
1200 | mg::Renderable::ID id) |
1201 | - : underlying_buffer_stream{stream}, |
1202 | - compositor_buffer{nullptr}, |
1203 | + : underlying_buffer_queue{bq}, |
1204 | compositor_id{compositor_id}, |
1205 | alpha_{alpha}, |
1206 | shaped_{shaped}, |
1207 | @@ -693,9 +681,9 @@ |
1208 | |
1209 | std::shared_ptr<mg::Buffer> buffer() const override |
1210 | { |
1211 | - if (!compositor_buffer) |
1212 | - compositor_buffer = underlying_buffer_stream->lock_compositor_buffer(compositor_id); |
1213 | - return compositor_buffer; |
1214 | + if (!compositor_buffer_handle) |
1215 | + compositor_buffer_handle = underlying_buffer_queue->compositor_acquire(compositor_id); |
1216 | + return compositor_buffer_handle.buffer(); |
1217 | } |
1218 | |
1219 | geom::Rectangle screen_position() const override |
1220 | @@ -713,8 +701,8 @@ |
1221 | mg::Renderable::ID id() const override |
1222 | { return id_; } |
1223 | private: |
1224 | - std::shared_ptr<mc::BufferStream> const underlying_buffer_stream; |
1225 | - std::shared_ptr<mg::Buffer> mutable compositor_buffer; |
1226 | + std::shared_ptr<mc::BufferBundle> const underlying_buffer_queue; |
1227 | + mc::BufferHandle mutable compositor_buffer_handle; |
1228 | void const*const compositor_id; |
1229 | float const alpha_; |
1230 | bool const shaped_; |
1231 | @@ -729,7 +717,7 @@ |
1232 | std::unique_lock<std::mutex> lk(guard); |
1233 | |
1234 | return std::make_unique<SurfaceSnapshot>( |
1235 | - surface_buffer_stream, |
1236 | + buffer_queue, |
1237 | compositor_id, |
1238 | surface_rect, |
1239 | transformation_matrix, |
1240 | @@ -741,7 +729,7 @@ |
1241 | int ms::BasicSurface::buffers_ready_for_compositor(void const* id) const |
1242 | { |
1243 | std::unique_lock<std::mutex> lk(guard); |
1244 | - return surface_buffer_stream->buffers_ready_for_compositor(id); |
1245 | + return buffer_queue->buffers_ready_for_compositor(id); |
1246 | } |
1247 | |
1248 | void ms::BasicSurface::consume(MirEvent const& event) |
1249 | |
1250 | === modified file 'src/server/scene/basic_surface.h' |
1251 | --- src/server/scene/basic_surface.h 2015-03-12 03:19:52 +0000 |
1252 | +++ src/server/scene/basic_surface.h 2015-03-20 19:31:52 +0000 |
1253 | @@ -22,6 +22,7 @@ |
1254 | #include "mir/scene/surface.h" |
1255 | #include "mir/basic_observers.h" |
1256 | #include "mir/scene/surface_observer.h" |
1257 | +#include "mir/compositor/buffer_handle.h" |
1258 | |
1259 | #include "mir/geometry/rectangle.h" |
1260 | |
1261 | @@ -38,7 +39,7 @@ |
1262 | namespace compositor |
1263 | { |
1264 | struct BufferIPCPackage; |
1265 | -class BufferStream; |
1266 | +class BufferBundle; |
1267 | } |
1268 | namespace frontend { class EventSink; } |
1269 | namespace graphics |
1270 | @@ -82,7 +83,7 @@ |
1271 | std::string const& name, |
1272 | geometry::Rectangle rect, |
1273 | bool nonrectangular, |
1274 | - std::shared_ptr<compositor::BufferStream> const& buffer_stream, |
1275 | + std::shared_ptr<compositor::BufferBundle> const& buffer_queue, |
1276 | std::shared_ptr<input::InputChannel> const& input_channel, |
1277 | std::shared_ptr<input::InputSender> const& sender, |
1278 | std::shared_ptr<graphics::CursorImage> const& cursor_image, |
1279 | @@ -93,7 +94,7 @@ |
1280 | geometry::Rectangle rect, |
1281 | std::weak_ptr<Surface> const& parent, |
1282 | bool nonrectangular, |
1283 | - std::shared_ptr<compositor::BufferStream> const& buffer_stream, |
1284 | + std::shared_ptr<compositor::BufferBundle> const& buffer_queue, |
1285 | std::shared_ptr<input::InputChannel> const& input_channel, |
1286 | std::shared_ptr<input::InputSender> const& sender, |
1287 | std::shared_ptr<graphics::CursorImage> const& cursor_image, |
1288 | @@ -111,7 +112,6 @@ |
1289 | |
1290 | MirPixelFormat pixel_format() const override; |
1291 | |
1292 | - std::shared_ptr<graphics::Buffer> snapshot_buffer() const; |
1293 | void swap_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override; |
1294 | void force_requests_to_complete() override; |
1295 | |
1296 | @@ -124,8 +124,6 @@ |
1297 | |
1298 | void set_input_region(std::vector<geometry::Rectangle> const& input_rectangles) override; |
1299 | |
1300 | - std::shared_ptr<compositor::BufferStream> buffer_stream() const; |
1301 | - |
1302 | void resize(geometry::Size const& size) override; |
1303 | geometry::Point top_left() const override; |
1304 | geometry::Rectangle input_bounds() const override; |
1305 | @@ -186,7 +184,7 @@ |
1306 | input::InputReceptionMode input_mode; |
1307 | const bool nonrectangular; |
1308 | std::vector<geometry::Rectangle> custom_input_rectangles; |
1309 | - std::shared_ptr<compositor::BufferStream> const surface_buffer_stream; |
1310 | + std::shared_ptr<compositor::BufferBundle> const buffer_queue; |
1311 | std::shared_ptr<input::InputChannel> const server_input_channel; |
1312 | std::shared_ptr<input::InputSender> const input_sender; |
1313 | std::shared_ptr<graphics::CursorImage> cursor_image_; |
1314 | |
1315 | === modified file 'src/server/scene/default_configuration.cpp' |
1316 | --- src/server/scene/default_configuration.cpp 2015-03-16 03:39:55 +0000 |
1317 | +++ src/server/scene/default_configuration.cpp 2015-03-20 19:31:52 +0000 |
1318 | @@ -73,7 +73,7 @@ |
1319 | [this]() |
1320 | { |
1321 | return std::make_shared<ms::SurfaceAllocator>( |
1322 | - the_buffer_stream_factory(), |
1323 | + the_buffer_queue_factory(), |
1324 | the_options()->get<int>(options::nbuffers_opt), |
1325 | the_input_channel_factory(), |
1326 | the_input_sender(), |
1327 | |
1328 | === modified file 'src/server/scene/surface_allocator.cpp' |
1329 | --- src/server/scene/surface_allocator.cpp 2015-03-16 03:39:55 +0000 |
1330 | +++ src/server/scene/surface_allocator.cpp 2015-03-20 19:31:52 +0000 |
1331 | @@ -17,9 +17,9 @@ |
1332 | */ |
1333 | |
1334 | #include "surface_allocator.h" |
1335 | -#include "mir/scene/buffer_stream_factory.h" |
1336 | -#include "mir/compositor/buffer_stream.h" |
1337 | +#include "mir/scene/buffer_queue_factory.h" |
1338 | #include "mir/input/input_channel_factory.h" |
1339 | +#include "mir/compositor/buffer_bundle.h" |
1340 | #include "basic_surface.h" |
1341 | |
1342 | namespace geom=mir::geometry; |
1343 | @@ -36,13 +36,13 @@ |
1344 | } |
1345 | |
1346 | ms::SurfaceAllocator::SurfaceAllocator( |
1347 | - std::shared_ptr<BufferStreamFactory> const& stream_factory, |
1348 | + std::shared_ptr<BufferQueueFactory> const& buffer_queue_factory, |
1349 | int nbuffers, |
1350 | std::shared_ptr<input::InputChannelFactory> const& input_factory, |
1351 | std::shared_ptr<input::InputSender> const& input_sender, |
1352 | std::shared_ptr<mg::CursorImage> const& default_cursor_image, |
1353 | std::shared_ptr<SceneReport> const& report) : |
1354 | - buffer_stream_factory(stream_factory), |
1355 | + buffer_queue_factory(buffer_queue_factory), |
1356 | nbuffers(nbuffers), |
1357 | input_factory(input_factory), |
1358 | input_sender(input_sender), |
1359 | @@ -58,10 +58,8 @@ |
1360 | mg::BufferProperties buffer_properties{params.size, |
1361 | params.pixel_format, |
1362 | params.buffer_usage}; |
1363 | - auto buffer_stream = buffer_stream_factory->create_buffer_stream( |
1364 | - nbuffers, |
1365 | - buffer_properties); |
1366 | - auto actual_size = geom::Rectangle{params.top_left, buffer_stream->stream_size()}; |
1367 | + auto buffer_queue = buffer_queue_factory->create_buffer_queue(nbuffers, buffer_properties); |
1368 | + auto actual_size = geom::Rectangle{params.top_left, buffer_queue->size()}; |
1369 | |
1370 | bool nonrectangular = has_alpha(params.pixel_format); |
1371 | auto input_channel = input_factory->make_input_channel(); |
1372 | @@ -70,7 +68,7 @@ |
1373 | actual_size, |
1374 | params.parent, |
1375 | nonrectangular, |
1376 | - buffer_stream, |
1377 | + buffer_queue, |
1378 | input_channel, |
1379 | input_sender, |
1380 | default_cursor_image, |
1381 | |
1382 | === modified file 'src/server/scene/surface_allocator.h' |
1383 | --- src/server/scene/surface_allocator.h 2015-03-16 03:39:55 +0000 |
1384 | +++ src/server/scene/surface_allocator.h 2015-03-20 19:31:52 +0000 |
1385 | @@ -34,14 +34,14 @@ |
1386 | } |
1387 | namespace scene |
1388 | { |
1389 | -class BufferStreamFactory; |
1390 | +class BufferQueueFactory; |
1391 | class SceneReport; |
1392 | class SurfaceConfigurator; |
1393 | |
1394 | class SurfaceAllocator : public SurfaceFactory |
1395 | { |
1396 | public: |
1397 | - SurfaceAllocator(std::shared_ptr<BufferStreamFactory> const& bb_factory, |
1398 | + SurfaceAllocator(std::shared_ptr<BufferQueueFactory> const& buffer_queue_factory, |
1399 | int buffers, |
1400 | std::shared_ptr<input::InputChannelFactory> const& input_factory, |
1401 | std::shared_ptr<input::InputSender> const& input_sender, |
1402 | @@ -51,7 +51,7 @@ |
1403 | std::shared_ptr<Surface> create_surface(SurfaceCreationParameters const& params) override; |
1404 | |
1405 | private: |
1406 | - std::shared_ptr<BufferStreamFactory> const buffer_stream_factory; |
1407 | + std::shared_ptr<BufferQueueFactory> const buffer_queue_factory; |
1408 | int const nbuffers; |
1409 | std::shared_ptr<input::InputChannelFactory> const input_factory; |
1410 | std::shared_ptr<input::InputSender> const input_sender; |
1411 | |
1412 | === modified file 'src/server/symbols.map' |
1413 | --- src/server/symbols.map 2015-03-16 03:39:55 +0000 |
1414 | +++ src/server/symbols.map 2015-03-20 19:31:52 +0000 |
1415 | @@ -515,7 +515,7 @@ |
1416 | mir::DefaultServerConfiguration::new_ipc_factory*; |
1417 | mir::DefaultServerConfiguration::the_android_input_dispatcher*; |
1418 | mir::DefaultServerConfiguration::the_buffer_allocator*; |
1419 | - mir::DefaultServerConfiguration::the_buffer_stream_factory*; |
1420 | + mir::DefaultServerConfiguration::the_buffer_queue_factory*; |
1421 | mir::DefaultServerConfiguration::the_clock*; |
1422 | mir::DefaultServerConfiguration::the_composite_event_filter*; |
1423 | mir::DefaultServerConfiguration::the_compositor*; |
1424 | |
1425 | === modified file 'tests/include/mir_test_doubles/mock_buffer_bundle.h' |
1426 | --- tests/include/mir_test_doubles/mock_buffer_bundle.h 2015-01-21 08:53:28 +0000 |
1427 | +++ tests/include/mir_test_doubles/mock_buffer_bundle.h 2015-03-20 19:31:52 +0000 |
1428 | @@ -18,7 +18,8 @@ |
1429 | #ifndef MIR_TEST_DOUBLES_MOCK_BUFFER_BUNDLE_H_ |
1430 | #define MIR_TEST_DOUBLES_MOCK_BUFFER_BUNDLE_H_ |
1431 | |
1432 | -#include "src/server/compositor/buffer_bundle.h" |
1433 | +#include "mir/compositor/buffer_handle.h" |
1434 | +#include "mir/compositor/buffer_bundle.h" |
1435 | |
1436 | #include <gmock/gmock.h> |
1437 | |
1438 | @@ -37,19 +38,22 @@ |
1439 | ~MockBufferBundle() noexcept |
1440 | {} |
1441 | |
1442 | - MOCK_METHOD1(client_acquire, void(std::function<void(graphics::Buffer*)>)); |
1443 | - MOCK_METHOD1(client_release, void(graphics::Buffer*)); |
1444 | - MOCK_METHOD1(compositor_acquire, std::shared_ptr<graphics::Buffer>(void const*)); |
1445 | - MOCK_METHOD1(compositor_release, void(std::shared_ptr<graphics::Buffer> const&)); |
1446 | - MOCK_METHOD0(snapshot_acquire, std::shared_ptr<graphics::Buffer>()); |
1447 | - MOCK_METHOD1(snapshot_release, void(std::shared_ptr<graphics::Buffer> const&)); |
1448 | + MOCK_METHOD1(client_acquire, void(std::function<void(graphics::Buffer*)>)); |
1449 | + MOCK_METHOD1(client_release, void(graphics::Buffer*)); |
1450 | + MOCK_CONST_METHOD0(properties, graphics::BufferProperties()); |
1451 | MOCK_METHOD1(allow_framedropping, void(bool)); |
1452 | - MOCK_CONST_METHOD0(properties, graphics::BufferProperties()); |
1453 | - MOCK_METHOD0(force_client_abort, void()); |
1454 | MOCK_METHOD0(force_requests_to_complete, void()); |
1455 | MOCK_METHOD1(resize, void(const geometry::Size &)); |
1456 | + MOCK_CONST_METHOD0(size, geometry::Size()); |
1457 | MOCK_METHOD0(drop_old_buffers, void()); |
1458 | - int buffers_ready_for_compositor(void const*) const override { return 1; } |
1459 | + MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*)); |
1460 | + |
1461 | + // TODO: Latest gmock (1.7.0) can't handle moveable only classes. |
1462 | + // The trunk can. We should be able to mock this once released. |
1463 | + compositor::BufferHandle compositor_acquire(void const*) override |
1464 | + { return std::move(compositor::BufferHandle(nullptr, nullptr)); } |
1465 | + compositor::BufferHandle snapshot_acquire() override |
1466 | + { return std::move(compositor::BufferHandle(nullptr, nullptr)); } |
1467 | int buffers_free_for_client() const override { return 1; } |
1468 | void drop_client_requests() override {} |
1469 | }; |
1470 | |
1471 | === removed file 'tests/include/mir_test_doubles/mock_buffer_stream.h' |
1472 | --- tests/include/mir_test_doubles/mock_buffer_stream.h 2015-01-21 08:53:28 +0000 |
1473 | +++ tests/include/mir_test_doubles/mock_buffer_stream.h 1970-01-01 00:00:00 +0000 |
1474 | @@ -1,67 +0,0 @@ |
1475 | -/* |
1476 | - * Copyright © 2012 Canonical Ltd. |
1477 | - * |
1478 | - * This program is free software: you can redistribute it and/or modify it |
1479 | - * under the terms of the GNU General Public License version 3, |
1480 | - * as published by the Free Software Foundation. |
1481 | - * |
1482 | - * This program is distributed in the hope that it will be useful, |
1483 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1484 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1485 | - * GNU General Public License for more details. |
1486 | - * |
1487 | - * You should have received a copy of the GNU General Public License |
1488 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1489 | - * |
1490 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1491 | - */ |
1492 | - |
1493 | -#ifndef MIR_TEST_DOUBLES_MOCK_BUFFER_STREAM_H_ |
1494 | -#define MIR_TEST_DOUBLES_MOCK_BUFFER_STREAM_H_ |
1495 | - |
1496 | -#include "mir/compositor/buffer_stream.h" |
1497 | - |
1498 | -#include <gmock/gmock.h> |
1499 | - |
1500 | -namespace mir |
1501 | -{ |
1502 | -namespace test |
1503 | -{ |
1504 | -namespace doubles |
1505 | -{ |
1506 | -struct MockBufferStream : public compositor::BufferStream |
1507 | -{ |
1508 | - int buffers_ready_{0}; |
1509 | - int buffers_ready(void const*) |
1510 | - { |
1511 | - if (buffers_ready_) |
1512 | - return buffers_ready_--; |
1513 | - return 0; |
1514 | - } |
1515 | - |
1516 | - MockBufferStream() |
1517 | - { |
1518 | - ON_CALL(*this, buffers_ready_for_compositor(::testing::_)) |
1519 | - .WillByDefault(testing::Invoke(this, &MockBufferStream::buffers_ready)); |
1520 | - } |
1521 | - MOCK_METHOD1(acquire_client_buffer, void(std::function<void(graphics::Buffer* buffer)>)); |
1522 | - MOCK_METHOD1(release_client_buffer, void(graphics::Buffer*)); |
1523 | - MOCK_METHOD1(lock_compositor_buffer, |
1524 | - std::shared_ptr<graphics::Buffer>(void const*)); |
1525 | - MOCK_METHOD0(lock_snapshot_buffer, std::shared_ptr<graphics::Buffer>()); |
1526 | - |
1527 | - MOCK_METHOD0(get_stream_pixel_format, MirPixelFormat()); |
1528 | - MOCK_METHOD0(stream_size, geometry::Size()); |
1529 | - MOCK_METHOD1(resize, void(geometry::Size const&)); |
1530 | - MOCK_METHOD0(force_client_completion, void()); |
1531 | - MOCK_METHOD1(allow_framedropping, void(bool)); |
1532 | - MOCK_METHOD0(force_requests_to_complete, void()); |
1533 | - MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*)); |
1534 | - MOCK_METHOD0(drop_old_buffers, void()); |
1535 | - MOCK_METHOD0(drop_client_requests, void()); |
1536 | -}; |
1537 | -} |
1538 | -} |
1539 | -} |
1540 | - |
1541 | -#endif /* MIR_TEST_DOUBLES_MOCK_BUFFER_STREAM_H_ */ |
1542 | |
1543 | === modified file 'tests/include/mir_test_doubles/mock_surface.h' |
1544 | --- tests/include/mir_test_doubles/mock_surface.h 2015-02-03 15:07:44 +0000 |
1545 | +++ tests/include/mir_test_doubles/mock_surface.h 2015-03-20 19:31:52 +0000 |
1546 | @@ -21,7 +21,7 @@ |
1547 | |
1548 | #include "src/server/scene/basic_surface.h" |
1549 | #include "src/server/report/null_report_factory.h" |
1550 | -#include "mock_buffer_stream.h" |
1551 | +#include "mock_buffer_bundle.h" |
1552 | |
1553 | #include <gmock/gmock.h> |
1554 | |
1555 | @@ -39,7 +39,7 @@ |
1556 | {}, |
1557 | {{},{}}, |
1558 | true, |
1559 | - std::make_shared<testing::NiceMock<MockBufferStream>>(), |
1560 | + std::make_shared<testing::NiceMock<MockBufferBundle>>(), |
1561 | {}, |
1562 | {}, |
1563 | {}, |
1564 | |
1565 | === renamed file 'tests/include/mir_test_doubles/stub_buffer_stream.h' => 'tests/include/mir_test_doubles/stub_buffer_bundle.h' |
1566 | --- tests/include/mir_test_doubles/stub_buffer_stream.h 2015-01-22 10:20:30 +0000 |
1567 | +++ tests/include/mir_test_doubles/stub_buffer_bundle.h 2015-03-20 19:31:52 +0000 |
1568 | @@ -16,10 +16,11 @@ |
1569 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
1570 | */ |
1571 | |
1572 | -#ifndef MIR_TEST_DOUBLES_NULL_BUFFER_STREAM_H_ |
1573 | -#define MIR_TEST_DOUBLES_NULL_BUFFER_STREAM_H_ |
1574 | +#ifndef MIR_TEST_DOUBLES_NULL_BUFFER_BUNDLE_H_ |
1575 | +#define MIR_TEST_DOUBLES_NULL_BUFFER_BUNDLE_H_ |
1576 | |
1577 | -#include <mir/compositor/buffer_stream.h> |
1578 | +#include "mir/compositor/buffer_handle.h" |
1579 | +#include <mir/compositor/buffer_bundle.h> |
1580 | #include <mir_test_doubles/stub_buffer.h> |
1581 | |
1582 | namespace mir |
1583 | @@ -29,42 +30,37 @@ |
1584 | namespace doubles |
1585 | { |
1586 | |
1587 | -class StubBufferStream : public compositor::BufferStream |
1588 | +class StubBufferBundle : public compositor::BufferBundle |
1589 | { |
1590 | public: |
1591 | - StubBufferStream() |
1592 | + StubBufferBundle() |
1593 | { |
1594 | stub_compositor_buffer = std::make_shared<StubBuffer>(); |
1595 | } |
1596 | |
1597 | - void acquire_client_buffer( |
1598 | + void client_acquire( |
1599 | std::function<void(graphics::Buffer* buffer)> complete) override |
1600 | { |
1601 | complete(&stub_client_buffer); |
1602 | } |
1603 | |
1604 | - void release_client_buffer(graphics::Buffer*) override |
1605 | + void client_release(graphics::Buffer*) override |
1606 | { |
1607 | ++nready; |
1608 | } |
1609 | |
1610 | - std::shared_ptr<graphics::Buffer> lock_compositor_buffer(void const*) override |
1611 | + compositor::BufferHandle compositor_acquire(void const*) override |
1612 | { |
1613 | --nready; |
1614 | - return stub_compositor_buffer; |
1615 | - } |
1616 | - |
1617 | - std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() override |
1618 | - { |
1619 | - return stub_compositor_buffer; |
1620 | - } |
1621 | - |
1622 | - MirPixelFormat get_stream_pixel_format() override |
1623 | - { |
1624 | - return MirPixelFormat(); |
1625 | - } |
1626 | - |
1627 | - geometry::Size stream_size() override |
1628 | + return compositor::BufferHandle(stub_compositor_buffer, nullptr); |
1629 | + } |
1630 | + |
1631 | + compositor::BufferHandle snapshot_acquire() override |
1632 | + { |
1633 | + return compositor::BufferHandle(stub_compositor_buffer, nullptr); |
1634 | + } |
1635 | + |
1636 | + geometry::Size size() const override |
1637 | { |
1638 | return geometry::Size(); |
1639 | } |
1640 | @@ -81,11 +77,18 @@ |
1641 | { |
1642 | } |
1643 | |
1644 | + int buffers_free_for_client() const override { return 0; } |
1645 | + |
1646 | int buffers_ready_for_compositor(void const*) const override { return nready; } |
1647 | |
1648 | void drop_old_buffers() override {} |
1649 | void drop_client_requests() override {} |
1650 | |
1651 | + graphics::BufferProperties properties() const override |
1652 | + { return graphics::BufferProperties(geometry::Size{0, 0}, |
1653 | + mir_pixel_format_invalid, |
1654 | + graphics::BufferUsage::undefined); } |
1655 | + |
1656 | StubBuffer stub_client_buffer; |
1657 | std::shared_ptr<graphics::Buffer> stub_compositor_buffer; |
1658 | int nready = 0; |
1659 | @@ -95,4 +98,4 @@ |
1660 | } |
1661 | } // namespace mir |
1662 | |
1663 | -#endif /* MIR_TEST_DOUBLES_NULL_BUFFER_STREAM_H_ */ |
1664 | +#endif /* MIR_TEST_DOUBLES_NULL_BUFFER_BUNDLE_H_ */ |
1665 | |
1666 | === modified file 'tests/integration-tests/compositor/CMakeLists.txt' |
1667 | --- tests/integration-tests/compositor/CMakeLists.txt 2013-07-24 05:13:16 +0000 |
1668 | +++ tests/integration-tests/compositor/CMakeLists.txt 2015-03-20 19:31:52 +0000 |
1669 | @@ -2,7 +2,6 @@ |
1670 | APPEND INTEGRATION_TESTS_SRCS |
1671 | ${CMAKE_CURRENT_SOURCE_DIR}/test_swapping_swappers.cpp |
1672 | ${CMAKE_CURRENT_SOURCE_DIR}/test_synchronizer.cpp |
1673 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_stream.cpp |
1674 | ) |
1675 | |
1676 | set( |
1677 | |
1678 | === removed file 'tests/integration-tests/compositor/test_buffer_stream.cpp' |
1679 | --- tests/integration-tests/compositor/test_buffer_stream.cpp 2015-03-06 03:52:41 +0000 |
1680 | +++ tests/integration-tests/compositor/test_buffer_stream.cpp 1970-01-01 00:00:00 +0000 |
1681 | @@ -1,405 +0,0 @@ |
1682 | -/* |
1683 | - * Copyright © 2013-2015 Canonical Ltd. |
1684 | - * |
1685 | - * This program is free software: you can redistribute it and/or modify |
1686 | - * it under the terms of the GNU General Public License version 3 as |
1687 | - * published by the Free Software Foundation. |
1688 | - * |
1689 | - * This program is distributed in the hope that it will be useful, |
1690 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1691 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1692 | - * GNU General Public License for more details. |
1693 | - * |
1694 | - * You should have received a copy of the GNU General Public License |
1695 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1696 | - * |
1697 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
1698 | - */ |
1699 | - |
1700 | -#include "src/server/compositor/buffer_stream_surfaces.h" |
1701 | -#include "mir/graphics/graphic_buffer_allocator.h" |
1702 | - |
1703 | -#include "src/server/compositor/buffer_queue.h" |
1704 | -#include "src/server/compositor/timeout_frame_dropping_policy_factory.h" |
1705 | - |
1706 | -#include "mir_test_doubles/stub_buffer.h" |
1707 | -#include "mir_test_doubles/stub_buffer_allocator.h" |
1708 | -#include "mir_test_doubles/mock_timer.h" |
1709 | -#include "mir_test/signal.h" |
1710 | - |
1711 | -#include <gmock/gmock.h> |
1712 | - |
1713 | -#include <condition_variable> |
1714 | -#include <thread> |
1715 | -#include <chrono> |
1716 | -#include <atomic> |
1717 | - |
1718 | -namespace mc = mir::compositor; |
1719 | -namespace mg = mir::graphics; |
1720 | -namespace mtd = mir::test::doubles; |
1721 | -namespace mt =mir::test; |
1722 | -namespace geom = mir::geometry; |
1723 | - |
1724 | -using namespace ::testing; |
1725 | - |
1726 | -namespace |
1727 | -{ |
1728 | - |
1729 | -struct BufferStreamSurfaces : mc::BufferStreamSurfaces |
1730 | -{ |
1731 | - using mc::BufferStreamSurfaces::BufferStreamSurfaces; |
1732 | - |
1733 | - void acquire_client_buffer_async(mg::Buffer*& buffer, |
1734 | - std::shared_ptr<mt::Signal> const& signal) |
1735 | - { |
1736 | - acquire_client_buffer( |
1737 | - [signal, &buffer](mg::Buffer* new_buffer) |
1738 | - { |
1739 | - buffer = new_buffer; |
1740 | - signal->raise(); |
1741 | - }); |
1742 | - } |
1743 | - |
1744 | - // Convenient functions to allow tests to be written in linear style |
1745 | - mg::Buffer* acquire_client_buffer_blocking() |
1746 | - { |
1747 | - mg::Buffer* buffer = nullptr; |
1748 | - auto signal = std::make_shared<mt::Signal>(); |
1749 | - acquire_client_buffer_async(buffer, signal); |
1750 | - signal->wait(); |
1751 | - return buffer; |
1752 | - } |
1753 | - |
1754 | - void swap_client_buffers_blocking(mg::Buffer*& buffer) |
1755 | - { |
1756 | - if (buffer) |
1757 | - release_client_buffer(buffer); |
1758 | - |
1759 | - buffer = acquire_client_buffer_blocking(); |
1760 | - } |
1761 | -}; |
1762 | - |
1763 | -struct BufferStreamTest : public ::testing::Test |
1764 | -{ |
1765 | - BufferStreamTest() |
1766 | - : clock{std::make_shared<mt::FakeClock>()}, |
1767 | - timer{std::make_shared<mtd::FakeTimer>(clock)}, |
1768 | - frame_drop_timeout{1000}, |
1769 | - nbuffers{3}, |
1770 | - buffer_stream{create_bundle()} |
1771 | - { |
1772 | - } |
1773 | - |
1774 | - int buffers_free_for_client() const |
1775 | - { |
1776 | - return buffer_queue->buffers_free_for_client(); |
1777 | - } |
1778 | - |
1779 | - std::shared_ptr<mc::BufferBundle> create_bundle() |
1780 | - { |
1781 | - auto allocator = std::make_shared<mtd::StubBufferAllocator>(); |
1782 | - mg::BufferProperties properties{geom::Size{380, 210}, |
1783 | - mir_pixel_format_abgr_8888, |
1784 | - mg::BufferUsage::hardware}; |
1785 | - mc::TimeoutFrameDroppingPolicyFactory policy_factory{timer, |
1786 | - frame_drop_timeout}; |
1787 | - |
1788 | - buffer_queue = std::make_shared<mc::BufferQueue>(nbuffers, |
1789 | - allocator, |
1790 | - properties, |
1791 | - policy_factory); |
1792 | - |
1793 | - return buffer_queue; |
1794 | - } |
1795 | - |
1796 | - std::shared_ptr<mt::FakeClock> clock; |
1797 | - std::shared_ptr<mtd::FakeTimer> timer; |
1798 | - std::chrono::milliseconds const frame_drop_timeout; |
1799 | - const int nbuffers; |
1800 | - std::shared_ptr<mc::BufferQueue> buffer_queue; |
1801 | - BufferStreamSurfaces buffer_stream; |
1802 | -}; |
1803 | - |
1804 | -} |
1805 | - |
1806 | -TEST_F(BufferStreamTest, gives_same_back_buffer_until_more_available) |
1807 | -{ |
1808 | - mg::Buffer* client1 = buffer_stream.acquire_client_buffer_blocking(); |
1809 | - auto client1_id = client1->id(); |
1810 | - buffer_stream.release_client_buffer(client1); |
1811 | - |
1812 | - auto comp1 = buffer_stream.lock_compositor_buffer(nullptr); |
1813 | - auto comp2 = buffer_stream.lock_compositor_buffer(nullptr); |
1814 | - |
1815 | - EXPECT_EQ(comp1->id(), comp2->id()); |
1816 | - EXPECT_EQ(comp1->id(), client1_id); |
1817 | - |
1818 | - comp1.reset(); |
1819 | - |
1820 | - mg::Buffer* client2 = buffer_stream.acquire_client_buffer_blocking(); |
1821 | - auto client2_id = client2->id(); |
1822 | - buffer_stream.release_client_buffer(client2); |
1823 | - |
1824 | - auto comp3 = buffer_stream.lock_compositor_buffer(nullptr); |
1825 | - |
1826 | - EXPECT_NE(client1_id, comp3->id()); |
1827 | - EXPECT_EQ(client2_id, comp3->id()); |
1828 | - |
1829 | - comp2.reset(); |
1830 | - auto comp3_id = comp3->id(); |
1831 | - comp3.reset(); |
1832 | - |
1833 | - auto comp4 = buffer_stream.lock_compositor_buffer(nullptr); |
1834 | - EXPECT_EQ(comp3_id, comp4->id()); |
1835 | -} |
1836 | - |
1837 | -TEST_F(BufferStreamTest, gives_all_monitors_the_same_buffer) |
1838 | -{ |
1839 | - mg::Buffer* client_buffer{nullptr}; |
1840 | - int const prefill = buffers_free_for_client(); |
1841 | - for (int i = 0; i < prefill; ++i) |
1842 | - buffer_stream.swap_client_buffers_blocking(client_buffer); |
1843 | - |
1844 | - auto first_monitor = buffer_stream.lock_compositor_buffer(0); |
1845 | - auto first_compositor_id = first_monitor->id(); |
1846 | - first_monitor.reset(); |
1847 | - |
1848 | - for (int m = 1; m <= 10; m++) |
1849 | - { |
1850 | - const void *th = reinterpret_cast<const void*>(m); |
1851 | - auto monitor = buffer_stream.lock_compositor_buffer(th); |
1852 | - ASSERT_EQ(first_compositor_id, monitor->id()); |
1853 | - } |
1854 | -} |
1855 | - |
1856 | -TEST_F(BufferStreamTest, gives_different_back_buffer_asap) |
1857 | -{ |
1858 | - buffer_stream.release_client_buffer(buffer_stream.acquire_client_buffer_blocking()); |
1859 | - auto comp1 = buffer_stream.lock_compositor_buffer(nullptr); |
1860 | - |
1861 | - buffer_stream.release_client_buffer(buffer_stream.acquire_client_buffer_blocking()); |
1862 | - auto comp2 = buffer_stream.lock_compositor_buffer(nullptr); |
1863 | - |
1864 | - EXPECT_NE(comp1->id(), comp2->id()); |
1865 | - |
1866 | - comp1.reset(); |
1867 | - comp2.reset(); |
1868 | -} |
1869 | - |
1870 | -TEST_F(BufferStreamTest, resize_affects_client_buffers_immediately) |
1871 | -{ |
1872 | - auto old_size = buffer_stream.stream_size(); |
1873 | - |
1874 | - mg::Buffer* client = buffer_stream.acquire_client_buffer_blocking(); |
1875 | - EXPECT_EQ(old_size, client->size()); |
1876 | - buffer_stream.release_client_buffer(client); |
1877 | - |
1878 | - buffer_stream.lock_compositor_buffer(this); |
1879 | - |
1880 | - geom::Size const new_size |
1881 | - { |
1882 | - old_size.width.as_int() * 2, |
1883 | - old_size.height.as_int() * 3 |
1884 | - }; |
1885 | - buffer_stream.resize(new_size); |
1886 | - EXPECT_EQ(new_size, buffer_stream.stream_size()); |
1887 | - |
1888 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1889 | - EXPECT_EQ(new_size, client->size()); |
1890 | - buffer_stream.release_client_buffer(client); |
1891 | - |
1892 | - buffer_stream.lock_compositor_buffer(this); |
1893 | - |
1894 | - buffer_stream.resize(old_size); |
1895 | - EXPECT_EQ(old_size, buffer_stream.stream_size()); |
1896 | - |
1897 | - buffer_stream.lock_compositor_buffer(this); |
1898 | - |
1899 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1900 | - EXPECT_EQ(old_size, client->size()); |
1901 | - buffer_stream.release_client_buffer(client); |
1902 | -} |
1903 | - |
1904 | -TEST_F(BufferStreamTest, compositor_gets_resized_buffers) |
1905 | -{ |
1906 | - auto old_size = buffer_stream.stream_size(); |
1907 | - |
1908 | - mg::Buffer* client = buffer_stream.acquire_client_buffer_blocking(); |
1909 | - buffer_stream.release_client_buffer(client); |
1910 | - |
1911 | - geom::Size const new_size |
1912 | - { |
1913 | - old_size.width.as_int() * 2, |
1914 | - old_size.height.as_int() * 3 |
1915 | - }; |
1916 | - buffer_stream.resize(new_size); |
1917 | - EXPECT_EQ(new_size, buffer_stream.stream_size()); |
1918 | - |
1919 | - auto comp1 = buffer_stream.lock_compositor_buffer(nullptr); |
1920 | - |
1921 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1922 | - buffer_stream.release_client_buffer(client); |
1923 | - |
1924 | - EXPECT_EQ(old_size, comp1->size()); |
1925 | - comp1.reset(); |
1926 | - |
1927 | - auto comp2 = buffer_stream.lock_compositor_buffer(nullptr); |
1928 | - |
1929 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1930 | - buffer_stream.release_client_buffer(client); |
1931 | - |
1932 | - EXPECT_EQ(new_size, comp2->size()); |
1933 | - comp2.reset(); |
1934 | - |
1935 | - auto comp3 = buffer_stream.lock_compositor_buffer(nullptr); |
1936 | - |
1937 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1938 | - buffer_stream.release_client_buffer(client); |
1939 | - |
1940 | - EXPECT_EQ(new_size, comp3->size()); |
1941 | - comp3.reset(); |
1942 | - |
1943 | - buffer_stream.resize(old_size); |
1944 | - EXPECT_EQ(old_size, buffer_stream.stream_size()); |
1945 | - |
1946 | - auto comp4 = buffer_stream.lock_compositor_buffer(nullptr); |
1947 | - |
1948 | - // No client frames "drawn" since resize(old_size), so compositor gets new_size |
1949 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1950 | - buffer_stream.release_client_buffer(client); |
1951 | - EXPECT_EQ(new_size, comp4->size()); |
1952 | - comp4.reset(); |
1953 | - |
1954 | - auto comp5 = buffer_stream.lock_compositor_buffer(nullptr); |
1955 | - |
1956 | - // Generate a new frame, which should be back to old_size now |
1957 | - client = buffer_stream.acquire_client_buffer_blocking(); |
1958 | - buffer_stream.release_client_buffer(client); |
1959 | - EXPECT_EQ(old_size, comp5->size()); |
1960 | - comp5.reset(); |
1961 | -} |
1962 | - |
1963 | -TEST_F(BufferStreamTest, can_get_partly_released_back_buffer) |
1964 | -{ |
1965 | - mg::Buffer* client = buffer_stream.acquire_client_buffer_blocking(); |
1966 | - buffer_stream.release_client_buffer(client); |
1967 | - |
1968 | - int a, b, c; |
1969 | - auto comp1 = buffer_stream.lock_compositor_buffer(&a); |
1970 | - auto comp2 = buffer_stream.lock_compositor_buffer(&b); |
1971 | - |
1972 | - EXPECT_EQ(comp1->id(), comp2->id()); |
1973 | - |
1974 | - comp1.reset(); |
1975 | - |
1976 | - auto comp3 = buffer_stream.lock_compositor_buffer(&c); |
1977 | - |
1978 | - EXPECT_EQ(comp2->id(), comp3->id()); |
1979 | -} |
1980 | - |
1981 | -namespace |
1982 | -{ |
1983 | - |
1984 | -void client_loop(int nframes, BufferStreamSurfaces& stream) |
1985 | -{ |
1986 | - mg::Buffer* out_buffer{nullptr}; |
1987 | - for (int f = 0; f < nframes; f++) |
1988 | - { |
1989 | - stream.swap_client_buffers_blocking(out_buffer); |
1990 | - ASSERT_NE(nullptr, out_buffer); |
1991 | - std::this_thread::yield(); |
1992 | - } |
1993 | -} |
1994 | - |
1995 | -void compositor_loop(mc::BufferStream &stream, |
1996 | - std::atomic<bool> &done) |
1997 | -{ |
1998 | - while (!done.load()) |
1999 | - { |
2000 | - auto comp1 = stream.lock_compositor_buffer(nullptr); |
2001 | - ASSERT_NE(nullptr, comp1); |
2002 | - |
2003 | - // Also stress test getting a second compositor buffer before yielding |
2004 | - auto comp2 = stream.lock_compositor_buffer(nullptr); |
2005 | - ASSERT_NE(nullptr, comp2); |
2006 | - |
2007 | - std::this_thread::yield(); |
2008 | - |
2009 | - comp1.reset(); |
2010 | - comp2.reset(); |
2011 | - } |
2012 | -} |
2013 | - |
2014 | -void snapshot_loop(mc::BufferStream &stream, |
2015 | - std::atomic<bool> &done) |
2016 | -{ |
2017 | - while (!done.load()) |
2018 | - { |
2019 | - auto out_region = stream.lock_snapshot_buffer(); |
2020 | - ASSERT_NE(nullptr, out_region); |
2021 | - std::this_thread::yield(); |
2022 | - } |
2023 | -} |
2024 | - |
2025 | -} |
2026 | - |
2027 | -TEST_F(BufferStreamTest, stress_test_distinct_buffers) |
2028 | -{ |
2029 | - // More would be good, but armhf takes too long |
2030 | - const int num_snapshotters{2}; |
2031 | - const int num_frames{200}; |
2032 | - |
2033 | - std::atomic<bool> done; |
2034 | - done = false; |
2035 | - |
2036 | - std::thread client(client_loop, |
2037 | - num_frames, |
2038 | - std::ref(buffer_stream)); |
2039 | - |
2040 | - std::thread compositor(compositor_loop, |
2041 | - std::ref(buffer_stream), |
2042 | - std::ref(done)); |
2043 | - |
2044 | - std::vector<std::shared_ptr<std::thread>> snapshotters; |
2045 | - for (unsigned int i = 0; i < num_snapshotters; i++) |
2046 | - { |
2047 | - snapshotters.push_back( |
2048 | - std::make_shared<std::thread>(snapshot_loop, |
2049 | - std::ref(buffer_stream), |
2050 | - std::ref(done))); |
2051 | - } |
2052 | - |
2053 | - client.join(); |
2054 | - |
2055 | - done = true; |
2056 | - |
2057 | - buffer_stream.force_requests_to_complete(); |
2058 | - |
2059 | - compositor.join(); |
2060 | - |
2061 | - for (auto &s : snapshotters) |
2062 | - s->join(); |
2063 | -} |
2064 | - |
2065 | -TEST_F(BufferStreamTest, blocked_client_is_released_on_timeout) |
2066 | -{ |
2067 | - using namespace testing; |
2068 | - |
2069 | - mg::Buffer* placeholder{nullptr}; |
2070 | - |
2071 | - // Grab all the buffers... |
2072 | - int max = buffers_free_for_client(); |
2073 | - for (int i = 0; i < max; ++i) |
2074 | - { |
2075 | - placeholder = buffer_stream.acquire_client_buffer_blocking(); |
2076 | - buffer_stream.release_client_buffer(placeholder); |
2077 | - } |
2078 | - |
2079 | - auto swap_completed = std::make_shared<mt::Signal>(); |
2080 | - buffer_stream.acquire_client_buffer([swap_completed](mg::Buffer*) {swap_completed->raise();}); |
2081 | - |
2082 | - EXPECT_FALSE(swap_completed->raised()); |
2083 | - clock->advance_time(frame_drop_timeout + std::chrono::milliseconds{1}); |
2084 | - |
2085 | - EXPECT_TRUE(swap_completed->wait_for(std::chrono::milliseconds{100})); |
2086 | -} |
2087 | |
2088 | === modified file 'tests/integration-tests/compositor/test_swapping_swappers.cpp' |
2089 | --- tests/integration-tests/compositor/test_swapping_swappers.cpp 2015-01-21 07:34:50 +0000 |
2090 | +++ tests/integration-tests/compositor/test_swapping_swappers.cpp 2015-03-20 19:31:52 +0000 |
2091 | @@ -20,8 +20,8 @@ |
2092 | #include "mir_test_doubles/stub_frame_dropping_policy_factory.h" |
2093 | #include "multithread_harness.h" |
2094 | |
2095 | -#include "src/server/compositor/buffer_queue.h" |
2096 | -#include "src/server/compositor/buffer_stream_surfaces.h" |
2097 | +#include "mir/compositor/buffer_handle.h" |
2098 | +#include "mir/compositor/buffer_queue.h" |
2099 | #include "mir/graphics/graphic_buffer_allocator.h" |
2100 | |
2101 | #include <gmock/gmock.h> |
2102 | @@ -105,7 +105,6 @@ |
2103 | { |
2104 | auto b = switching_bundle->compositor_acquire(0); |
2105 | std::this_thread::yield(); |
2106 | - switching_bundle->compositor_release(b); |
2107 | } |
2108 | }); |
2109 | |
2110 | @@ -149,7 +148,6 @@ |
2111 | { |
2112 | auto b = switching_bundle->compositor_acquire(0); |
2113 | std::this_thread::yield(); |
2114 | - switching_bundle->compositor_release(b); |
2115 | } |
2116 | }); |
2117 | |
2118 | |
2119 | === modified file 'tests/integration-tests/graphics/android/test_buffer_integration.cpp' |
2120 | --- tests/integration-tests/graphics/android/test_buffer_integration.cpp 2015-01-22 09:00:14 +0000 |
2121 | +++ tests/integration-tests/graphics/android/test_buffer_integration.cpp 2015-03-20 19:31:52 +0000 |
2122 | @@ -17,7 +17,7 @@ |
2123 | */ |
2124 | |
2125 | #include "src/platforms/android/server/android_graphic_buffer_allocator.h" |
2126 | -#include "src/server/compositor/buffer_queue.h" |
2127 | +#include "mir/compositor/buffer_queue.h" |
2128 | #include "src/server/report/null_report_factory.h" |
2129 | #include "mir/graphics/android/native_buffer.h" |
2130 | #include "mir/graphics/buffer_properties.h" |
2131 | |
2132 | === modified file 'tests/integration-tests/surface_composition.cpp' |
2133 | --- tests/integration-tests/surface_composition.cpp 2015-02-03 15:07:44 +0000 |
2134 | +++ tests/integration-tests/surface_composition.cpp 2015-03-20 19:31:52 +0000 |
2135 | @@ -18,8 +18,7 @@ |
2136 | |
2137 | #include "src/server/scene/basic_surface.h" |
2138 | #include "src/server/report/null_report_factory.h" |
2139 | -#include "src/server/compositor/buffer_stream_surfaces.h" |
2140 | -#include "src/server/compositor/buffer_queue.h" |
2141 | +#include "mir/compositor/buffer_queue.h" |
2142 | |
2143 | #include "mir_test_doubles/stub_buffer_allocator.h" |
2144 | #include "mir_test_doubles/stub_frame_dropping_policy_factory.h" |
2145 | @@ -49,7 +48,7 @@ |
2146 | std::string("SurfaceComposition"), |
2147 | geom::Rectangle{{},{}}, |
2148 | false, |
2149 | - create_buffer_stream(), |
2150 | + create_buffer_bundle(), |
2151 | create_input_channel(), |
2152 | create_input_sender(), |
2153 | create_cursor_image(), |
2154 | @@ -59,12 +58,6 @@ |
2155 | |
2156 | int const number_of_buffers = 3; |
2157 | |
2158 | - auto create_buffer_stream() const |
2159 | - ->std::shared_ptr<mc::BufferStream> |
2160 | - { |
2161 | - return std::make_shared<mc::BufferStreamSurfaces>(create_buffer_bundle()); |
2162 | - } |
2163 | - |
2164 | auto create_buffer_bundle() const |
2165 | -> std::shared_ptr<mc::BufferBundle> |
2166 | { |
2167 | |
2168 | === modified file 'tests/integration-tests/test_exchange_buffer.cpp' |
2169 | --- tests/integration-tests/test_exchange_buffer.cpp 2015-03-16 03:39:55 +0000 |
2170 | +++ tests/integration-tests/test_exchange_buffer.cpp 2015-03-20 19:31:52 +0000 |
2171 | @@ -26,8 +26,9 @@ |
2172 | #include "mir/graphics/buffer_id.h" |
2173 | #include "mir/graphics/buffer_ipc_message.h" |
2174 | #include "mir/graphics/platform_operation_message.h" |
2175 | -#include "mir/scene/buffer_stream_factory.h" |
2176 | -#include "mir/compositor/buffer_stream.h" |
2177 | +#include "mir/scene/buffer_queue_factory.h" |
2178 | +#include "mir/compositor/buffer_handle.h" |
2179 | +#include "mir/compositor/buffer_bundle.h" |
2180 | #include "mir_toolkit/mir_client_library.h" |
2181 | #include "src/client/mir_connection.h" |
2182 | #include <chrono> |
2183 | @@ -54,14 +55,14 @@ |
2184 | return arg; |
2185 | } |
2186 | |
2187 | -struct StubStream : public mc::BufferStream |
2188 | +struct StubQueue : public mc::BufferBundle |
2189 | { |
2190 | - StubStream(std::vector<mg::BufferID> const& ids) : |
2191 | + StubQueue(std::vector<mg::BufferID> const& ids) : |
2192 | buffer_id_seq(ids) |
2193 | { |
2194 | } |
2195 | |
2196 | - void acquire_client_buffer(std::function<void(mg::Buffer* buffer)> complete) |
2197 | + void client_acquire(std::function<void(mg::Buffer* buffer)> complete) |
2198 | { |
2199 | std::shared_ptr<mg::Buffer> stub_buffer; |
2200 | if (buffers_acquired < buffer_id_seq.size()) |
2201 | @@ -73,13 +74,11 @@ |
2202 | complete(stub_buffer.get()); |
2203 | } |
2204 | |
2205 | - void release_client_buffer(mg::Buffer*) {} |
2206 | - std::shared_ptr<mg::Buffer> lock_compositor_buffer(void const*) |
2207 | - { return std::make_shared<mtd::StubBuffer>(); } |
2208 | - std::shared_ptr<mg::Buffer> lock_snapshot_buffer() |
2209 | - { return std::make_shared<mtd::StubBuffer>(); } |
2210 | - MirPixelFormat get_stream_pixel_format() { return mir_pixel_format_abgr_8888; } |
2211 | - geom::Size stream_size() { return geom::Size{1,212121}; } |
2212 | + void client_release(mg::Buffer*) {} |
2213 | + mc::BufferHandle compositor_acquire(void const*) |
2214 | + { return std::move(mc::BufferHandle(std::make_shared<mtd::StubBuffer>(), nullptr)); } |
2215 | + mc::BufferHandle snapshot_acquire() |
2216 | + { return std::move(mc::BufferHandle(std::make_shared<mtd::StubBuffer>(), nullptr)); } |
2217 | void resize(geom::Size const&) {}; |
2218 | void allow_framedropping(bool) {}; |
2219 | void force_requests_to_complete() {}; |
2220 | @@ -87,20 +86,26 @@ |
2221 | void drop_old_buffers() {} |
2222 | void drop_client_requests() override {} |
2223 | |
2224 | + mg::BufferProperties properties() const override |
2225 | + { return mg::BufferProperties(geom::Size{0, 0}, |
2226 | + mir_pixel_format_invalid, |
2227 | + mg::BufferUsage::undefined); } |
2228 | + geom::Size size() const override { return geom::Size{1,212121}; } |
2229 | + int buffers_free_for_client() const override { return 0; } |
2230 | + |
2231 | std::vector<std::shared_ptr<mg::Buffer>> client_buffers; |
2232 | std::vector<mg::BufferID> const buffer_id_seq; |
2233 | unsigned int buffers_acquired{0}; |
2234 | }; |
2235 | |
2236 | -struct StubStreamFactory : public msc::BufferStreamFactory |
2237 | +struct StubQueueFactory : public msc::BufferQueueFactory |
2238 | { |
2239 | - StubStreamFactory(std::vector<mg::BufferID> const& ids) : |
2240 | + StubQueueFactory(std::vector<mg::BufferID> const& ids) : |
2241 | buffer_id_seq(ids) |
2242 | {} |
2243 | |
2244 | - std::shared_ptr<mc::BufferStream> create_buffer_stream( |
2245 | - int, mg::BufferProperties const&) override |
2246 | - { return std::make_shared<StubStream>(buffer_id_seq); } |
2247 | + std::shared_ptr<mc::BufferBundle> create_buffer_queue(int, mg::BufferProperties const&) override |
2248 | + { return std::make_shared<StubQueue>(buffer_id_seq); } |
2249 | std::vector<mg::BufferID> const buffer_id_seq; |
2250 | }; |
2251 | |
2252 | @@ -176,7 +181,7 @@ |
2253 | ExchangeServerConfiguration( |
2254 | std::vector<mg::BufferID> const& id_seq, |
2255 | std::shared_ptr<mg::PlatformIpcOperations> const& ipc_ops) : |
2256 | - stream_factory{std::make_shared<StubStreamFactory>(id_seq)}, |
2257 | + queue_factory{std::make_shared<StubQueueFactory>(id_seq)}, |
2258 | platform{std::make_shared<StubPlatform>(ipc_ops)} |
2259 | { |
2260 | } |
2261 | @@ -186,12 +191,12 @@ |
2262 | return platform; |
2263 | } |
2264 | |
2265 | - std::shared_ptr<msc::BufferStreamFactory> the_buffer_stream_factory() override |
2266 | + std::shared_ptr<msc::BufferQueueFactory> the_buffer_queue_factory() override |
2267 | { |
2268 | - return stream_factory; |
2269 | + return queue_factory; |
2270 | } |
2271 | |
2272 | - std::shared_ptr<msc::BufferStreamFactory> const stream_factory; |
2273 | + std::shared_ptr<msc::BufferQueueFactory> const queue_factory; |
2274 | std::shared_ptr<mg::Platform> const platform; |
2275 | }; |
2276 | |
2277 | |
2278 | === modified file 'tests/integration-tests/test_session.cpp' |
2279 | --- tests/integration-tests/test_session.cpp 2015-03-12 03:19:52 +0000 |
2280 | +++ tests/integration-tests/test_session.cpp 2015-03-20 19:31:52 +0000 |
2281 | @@ -25,7 +25,6 @@ |
2282 | #include "mir/scene/surface.h" |
2283 | #include "mir/scene/surface_creation_parameters.h" |
2284 | #include "mir/scene/null_session_listener.h" |
2285 | -#include "mir/compositor/buffer_stream.h" |
2286 | #include "mir/compositor/renderer.h" |
2287 | #include "mir/compositor/renderer_factory.h" |
2288 | #include "mir/frontend/connector.h" |
2289 | |
2290 | === modified file 'tests/integration-tests/test_surface_stack_with_compositor.cpp' |
2291 | --- tests/integration-tests/test_surface_stack_with_compositor.cpp 2015-03-12 03:19:52 +0000 |
2292 | +++ tests/integration-tests/test_surface_stack_with_compositor.cpp 2015-03-20 19:31:52 +0000 |
2293 | @@ -21,11 +21,11 @@ |
2294 | #include "src/server/report/null_report_factory.h" |
2295 | #include "src/server/scene/surface_stack.h" |
2296 | #include "src/server/compositor/gl_renderer_factory.h" |
2297 | +#include "mir_test_doubles/mock_buffer_bundle.h" |
2298 | #include "src/server/scene/basic_surface.h" |
2299 | #include "src/server/compositor/default_display_buffer_compositor_factory.h" |
2300 | #include "src/server/compositor/multi_threaded_compositor.h" |
2301 | #include "mir_test/fake_shared.h" |
2302 | -#include "mir_test_doubles/mock_buffer_stream.h" |
2303 | #include "mir_test_doubles/null_display.h" |
2304 | #include "mir_test_doubles/stub_renderer.h" |
2305 | #include "mir_test_doubles/stub_display_buffer.h" |
2306 | @@ -120,27 +120,24 @@ |
2307 | { |
2308 | SurfaceStackCompositor() : |
2309 | timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)}, |
2310 | - mock_buffer_stream(std::make_shared<testing::NiceMock<mtd::MockBufferStream>>()), |
2311 | + mock_buffer_bundle(std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>()), |
2312 | stub_surface{std::make_shared<ms::BasicSurface>( |
2313 | std::string("stub"), |
2314 | geom::Rectangle{{0,0},{1,1}}, |
2315 | false, |
2316 | - mock_buffer_stream, |
2317 | + mock_buffer_bundle, |
2318 | std::shared_ptr<mir::input::InputChannel>(), |
2319 | std::shared_ptr<mtd::StubInputSender>(), |
2320 | std::shared_ptr<mg::CursorImage>(), |
2321 | null_scene_report)} |
2322 | { |
2323 | - using namespace testing; |
2324 | - ON_CALL(*mock_buffer_stream, lock_compositor_buffer(_)) |
2325 | - .WillByDefault(Return(mt::fake_shared(stubbuf))); |
2326 | } |
2327 | std::shared_ptr<ms::SceneReport> null_scene_report{mr::null_scene_report()}; |
2328 | ms::SurfaceStack stack{null_scene_report}; |
2329 | std::shared_ptr<mc::CompositorReport> null_comp_report{mr::null_compositor_report()}; |
2330 | StubRendererFactory renderer_factory; |
2331 | std::chrono::system_clock::time_point timeout; |
2332 | - std::shared_ptr<mtd::MockBufferStream> mock_buffer_stream; |
2333 | + std::shared_ptr<mtd::MockBufferBundle> mock_buffer_bundle; |
2334 | std::shared_ptr<ms::BasicSurface> stub_surface; |
2335 | ms::SurfaceCreationParameters default_params; |
2336 | mtd::StubBuffer stubbuf; |
2337 | @@ -203,7 +200,7 @@ |
2338 | TEST_F(SurfaceStackCompositor, compositor_runs_until_all_surfaces_buffers_are_consumed) |
2339 | { |
2340 | using namespace testing; |
2341 | - ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_)) |
2342 | + ON_CALL(*mock_buffer_bundle, buffers_ready_for_compositor(_)) |
2343 | .WillByDefault(Return(5)); |
2344 | |
2345 | mc::MultiThreadedCompositor mt_compositor( |
2346 | @@ -224,7 +221,7 @@ |
2347 | TEST_F(SurfaceStackCompositor, bypassed_compositor_runs_until_all_surfaces_buffers_are_consumed) |
2348 | { |
2349 | using namespace testing; |
2350 | - ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_)) |
2351 | + ON_CALL(*mock_buffer_bundle, buffers_ready_for_compositor(_)) |
2352 | .WillByDefault(Return(5)); |
2353 | |
2354 | stub_surface->resize(geom::Size{10,10}); |
2355 | @@ -247,7 +244,7 @@ |
2356 | TEST_F(SurfaceStackCompositor, an_empty_scene_retriggers) |
2357 | { |
2358 | using namespace testing; |
2359 | - ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_)) |
2360 | + ON_CALL(*mock_buffer_bundle, buffers_ready_for_compositor(_)) |
2361 | .WillByDefault(Return(0)); |
2362 | |
2363 | mc::MultiThreadedCompositor mt_compositor( |
2364 | @@ -311,8 +308,8 @@ |
2365 | TEST_F(SurfaceStackCompositor, buffer_updates_trigger_composition) |
2366 | { |
2367 | using namespace testing; |
2368 | - ON_CALL(*mock_buffer_stream, buffers_ready_for_compositor(_)) |
2369 | - .WillByDefault(testing::Return(1)); |
2370 | + ON_CALL(*mock_buffer_bundle, buffers_ready_for_compositor(_)) |
2371 | + .WillByDefault(Return(1)); |
2372 | stack.add_surface(stub_surface, default_params.depth, default_params.input_mode); |
2373 | stub_surface->swap_buffers(&stubbuf, [](mg::Buffer*){}); |
2374 | |
2375 | |
2376 | === modified file 'tests/integration-tests/test_swapinterval.cpp' |
2377 | --- tests/integration-tests/test_swapinterval.cpp 2015-03-16 03:39:55 +0000 |
2378 | +++ tests/integration-tests/test_swapinterval.cpp 2015-03-20 19:31:52 +0000 |
2379 | @@ -23,12 +23,12 @@ |
2380 | #include "mir/compositor/compositor.h" |
2381 | #include "mir/compositor/display_buffer_compositor.h" |
2382 | #include "mir/compositor/scene.h" |
2383 | -#include "mir/compositor/buffer_stream.h" |
2384 | -#include "mir/scene/buffer_stream_factory.h" |
2385 | +#include "mir/compositor/buffer_bundle.h" |
2386 | +#include "mir/scene/buffer_queue_factory.h" |
2387 | |
2388 | #include "mir_test_framework/display_server_test_fixture.h" |
2389 | #include "mir_test_doubles/stub_buffer.h" |
2390 | -#include "mir_test_doubles/stub_buffer_stream.h" |
2391 | +#include "mir_test_doubles/stub_buffer_bundle.h" |
2392 | |
2393 | #include "mir_toolkit/mir_client_library.h" |
2394 | |
2395 | @@ -49,22 +49,23 @@ |
2396 | { |
2397 | char const* const mir_test_socket = mtf::test_socket_file().c_str(); |
2398 | |
2399 | -class CountingBufferStream : public mtd::StubBufferStream |
2400 | +class CountingBufferBundle : public mtd::StubBufferBundle |
2401 | { |
2402 | public: |
2403 | - CountingBufferStream(int render_operations_fd) |
2404 | + CountingBufferBundle(int render_operations_fd) |
2405 | : render_operations_fd(render_operations_fd) |
2406 | { |
2407 | } |
2408 | |
2409 | - std::shared_ptr<mg::Buffer> lock_compositor_buffer(void const*) override |
2410 | - { return std::make_shared<mtd::StubBuffer>(); } |
2411 | - |
2412 | - std::shared_ptr<mg::Buffer> lock_snapshot_buffer() override |
2413 | - { return std::make_shared<mtd::StubBuffer>(); } |
2414 | - |
2415 | - MirPixelFormat get_stream_pixel_format() override |
2416 | - { return mir_pixel_format_abgr_8888; } |
2417 | + mc::BufferHandle compositor_acquire(void const*) override |
2418 | + { |
2419 | + return std::move(mc::BufferHandle(nullptr, nullptr)); |
2420 | + } |
2421 | + |
2422 | + mc::BufferHandle snapshot_acquire() override |
2423 | + { |
2424 | + return std::move(mc::BufferHandle(nullptr, nullptr)); |
2425 | + } |
2426 | |
2427 | void allow_framedropping(bool) override |
2428 | { |
2429 | @@ -75,18 +76,17 @@ |
2430 | int render_operations_fd; |
2431 | }; |
2432 | |
2433 | -class StubStreamFactory : public ms::BufferStreamFactory |
2434 | +class StubQueueFactory : public ms::BufferQueueFactory |
2435 | { |
2436 | public: |
2437 | - StubStreamFactory(int render_operations_fd) |
2438 | + StubQueueFactory(int render_operations_fd) |
2439 | : render_operations_fd(render_operations_fd) |
2440 | { |
2441 | } |
2442 | |
2443 | - std::shared_ptr<mc::BufferStream> create_buffer_stream( |
2444 | - int, mg::BufferProperties const&) override |
2445 | + std::shared_ptr<mc::BufferBundle> create_buffer_queue(int, mg::BufferProperties const&) override |
2446 | { |
2447 | - return std::make_shared<CountingBufferStream>(render_operations_fd); |
2448 | + return std::make_shared<CountingBufferBundle>(render_operations_fd); |
2449 | } |
2450 | private: |
2451 | int render_operations_fd; |
2452 | @@ -128,11 +128,11 @@ |
2453 | close(rendering_ops_pipe[1]); |
2454 | } |
2455 | |
2456 | - std::shared_ptr<ms::BufferStreamFactory> the_buffer_stream_factory() override |
2457 | + std::shared_ptr<ms::BufferQueueFactory> the_buffer_queue_factory() override |
2458 | { |
2459 | - if (!stub_stream_factory) |
2460 | - stub_stream_factory = std::make_shared<StubStreamFactory>(rendering_ops_pipe[1]); |
2461 | - return stub_stream_factory; |
2462 | + if (!stub_queue_factory) |
2463 | + stub_queue_factory = std::make_shared<StubQueueFactory>(rendering_ops_pipe[1]); |
2464 | + return stub_queue_factory; |
2465 | } |
2466 | |
2467 | int num_of_swapinterval_devices() |
2468 | @@ -147,7 +147,7 @@ |
2469 | } |
2470 | |
2471 | int rendering_ops_pipe[2]; |
2472 | - std::shared_ptr<StubStreamFactory> stub_stream_factory; |
2473 | + std::shared_ptr<StubQueueFactory> stub_queue_factory; |
2474 | } server_config; |
2475 | |
2476 | launch_server_process(server_config); |
2477 | |
2478 | === modified file 'tests/unit-tests/compositor/CMakeLists.txt' |
2479 | --- tests/unit-tests/compositor/CMakeLists.txt 2015-03-06 03:52:41 +0000 |
2480 | +++ tests/unit-tests/compositor/CMakeLists.txt 2015-03-20 19:31:52 +0000 |
2481 | @@ -1,7 +1,6 @@ |
2482 | list(APPEND UNIT_TEST_SOURCES |
2483 | ${CMAKE_CURRENT_SOURCE_DIR}/test_default_display_buffer_compositor.cpp |
2484 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_stream.cpp |
2485 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_temporary_buffers.cpp |
2486 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_handle.cpp |
2487 | ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_threaded_compositor.cpp |
2488 | ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_queue.cpp |
2489 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_renderer.cpp |
2490 | |
2491 | === added file 'tests/unit-tests/compositor/test_buffer_handle.cpp' |
2492 | --- tests/unit-tests/compositor/test_buffer_handle.cpp 1970-01-01 00:00:00 +0000 |
2493 | +++ tests/unit-tests/compositor/test_buffer_handle.cpp 2015-03-20 19:31:52 +0000 |
2494 | @@ -0,0 +1,40 @@ |
2495 | +/* |
2496 | + * Copyright © 2015 Canonical Ltd. |
2497 | + * |
2498 | + * This program is free software: you can redistribute it and/or modify |
2499 | + * it under the terms of the GNU General Public License version 3 as |
2500 | + * published by the Free Software Foundation. |
2501 | + * |
2502 | + * This program is distributed in the hope that it will be useful, |
2503 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2504 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2505 | + * GNU General Public License for more details. |
2506 | + * |
2507 | + * You should have received a copy of the GNU General Public License |
2508 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2509 | + * |
2510 | + * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
2511 | + */ |
2512 | + |
2513 | +#include "mir_test_doubles/stub_buffer.h" |
2514 | +#include "mir/compositor/buffer_handle.h" |
2515 | +#include "mir_test/fake_shared.h" |
2516 | + |
2517 | +namespace mc = mir::compositor; |
2518 | +namespace mg = mir::graphics; |
2519 | +namespace mt = mir::test; |
2520 | +namespace mtd = mir::test::doubles; |
2521 | + |
2522 | +TEST(BufferHandleTest, can_contain_handout_and_release_buffer) |
2523 | +{ |
2524 | + mtd::StubBuffer mock_buffer; |
2525 | + |
2526 | + mc::BufferHandle buffer_handle( |
2527 | + mt::fake_shared(mock_buffer), |
2528 | + [&](mg::Buffer* b) |
2529 | + { |
2530 | + ASSERT_EQ(b, &mock_buffer); |
2531 | + }); |
2532 | + |
2533 | + ASSERT_EQ(buffer_handle.buffer().get(), &mock_buffer); |
2534 | +} |
2535 | |
2536 | === modified file 'tests/unit-tests/compositor/test_buffer_queue.cpp' |
2537 | --- tests/unit-tests/compositor/test_buffer_queue.cpp 2015-03-06 03:52:41 +0000 |
2538 | +++ tests/unit-tests/compositor/test_buffer_queue.cpp 2015-03-20 19:31:52 +0000 |
2539 | @@ -17,7 +17,8 @@ |
2540 | * Alberto Aguirre <alberto.aguirre@canonical.com> |
2541 | */ |
2542 | |
2543 | -#include "src/server/compositor/buffer_queue.h" |
2544 | +#include "mir/compositor/buffer_queue.h" |
2545 | +#include "mir/compositor/buffer_handle.h" |
2546 | #include "mir_test_doubles/stub_buffer_allocator.h" |
2547 | #include "mir_test_doubles/stub_buffer.h" |
2548 | #include "mir_test_doubles/stub_frame_dropping_policy_factory.h" |
2549 | @@ -155,7 +156,7 @@ |
2550 | { |
2551 | while (!done) |
2552 | { |
2553 | - bundle.compositor_release(bundle.compositor_acquire(nullptr)); |
2554 | + bundle.compositor_acquire(nullptr); |
2555 | std::this_thread::yield(); |
2556 | } |
2557 | } |
2558 | @@ -165,7 +166,7 @@ |
2559 | { |
2560 | while (!done) |
2561 | { |
2562 | - bundle.snapshot_release(bundle.snapshot_acquire()); |
2563 | + bundle.snapshot_acquire(); |
2564 | std::this_thread::yield(); |
2565 | } |
2566 | } |
2567 | @@ -196,10 +197,8 @@ |
2568 | |
2569 | TEST_F(BufferQueueTest, buffer_queue_of_one_is_supported) |
2570 | { |
2571 | - std::unique_ptr<mc::BufferQueue> q; |
2572 | - ASSERT_NO_THROW(q = std::move( |
2573 | - std::unique_ptr<mc::BufferQueue>( |
2574 | - new mc::BufferQueue(1, allocator, basic_properties, policy_factory)))); |
2575 | + std::shared_ptr<mc::BufferQueue> q; |
2576 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(1, allocator, basic_properties, policy_factory)); |
2577 | ASSERT_THAT(q, Ne(nullptr)); |
2578 | |
2579 | auto handle = client_acquire_async(*q); |
2580 | @@ -212,18 +211,18 @@ |
2581 | auto next_request = client_acquire_async(*q); |
2582 | EXPECT_THAT(next_request->has_acquired_buffer(), Eq(false)); |
2583 | |
2584 | - auto comp_buffer = q->compositor_acquire(this); |
2585 | - auto client_id = handle->id(); |
2586 | - |
2587 | - /* Client and compositor always share the same buffer */ |
2588 | - EXPECT_THAT(client_id, Eq(comp_buffer->id())); |
2589 | - |
2590 | - EXPECT_NO_THROW(handle->release_buffer()); |
2591 | - EXPECT_NO_THROW(q->compositor_release(comp_buffer)); |
2592 | + { |
2593 | + auto comp_buffer_handle = q->compositor_acquire(this); |
2594 | + auto client_id = handle->id(); |
2595 | + |
2596 | + /* Client and compositor always share the same buffer */ |
2597 | + EXPECT_THAT(client_id, Eq(comp_buffer_handle.buffer()->id())); |
2598 | + |
2599 | + EXPECT_NO_THROW(handle->release_buffer()); |
2600 | + } |
2601 | |
2602 | /* Simulate a composite pass */ |
2603 | - comp_buffer = q->compositor_acquire(this); |
2604 | - q->compositor_release(comp_buffer); |
2605 | + q->compositor_acquire(this); |
2606 | |
2607 | /* The request should now be fullfilled after compositor |
2608 | * released the buffer |
2609 | @@ -234,27 +233,29 @@ |
2610 | |
2611 | TEST_F(BufferQueueTest, buffer_queue_of_one_supports_resizing) |
2612 | { |
2613 | - mc::BufferQueue q(1, allocator, basic_properties, policy_factory); |
2614 | + std::shared_ptr<mc::BufferQueue> q; |
2615 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(1, allocator, basic_properties, policy_factory)); |
2616 | + ASSERT_THAT(q, Ne(nullptr)); |
2617 | |
2618 | const geom::Size expect_size{10, 20}; |
2619 | - q.resize(expect_size); |
2620 | + q->resize(expect_size); |
2621 | |
2622 | - auto handle = client_acquire_async(q); |
2623 | + auto handle = client_acquire_async(*q); |
2624 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2625 | auto buffer = handle->buffer(); |
2626 | ASSERT_THAT(buffer->size(), Eq(expect_size)); |
2627 | - |
2628 | - /* Client and compositor share the same buffer so |
2629 | - * expect the new size |
2630 | - */ |
2631 | - std::shared_ptr<mg::Buffer> comp_buffer; |
2632 | - ASSERT_NO_THROW(comp_buffer = q.compositor_acquire(this)); |
2633 | - |
2634 | - EXPECT_THAT(buffer->size(), Eq(expect_size)); |
2635 | - EXPECT_NO_THROW(q.compositor_release(comp_buffer)); |
2636 | + { |
2637 | + /* Client and compositor share the same buffer so |
2638 | + * expect the new size |
2639 | + */ |
2640 | + auto comp_buffer_handle = q->compositor_acquire(this); |
2641 | + ASSERT_NO_THROW(comp_buffer_handle.buffer()); |
2642 | + |
2643 | + EXPECT_THAT(buffer->size(), Eq(expect_size)); |
2644 | + } |
2645 | |
2646 | EXPECT_NO_THROW(handle->release_buffer()); |
2647 | - EXPECT_NO_THROW(q.compositor_release(q.compositor_acquire(this))); |
2648 | + EXPECT_NO_THROW(q->compositor_acquire(this)); |
2649 | } |
2650 | |
2651 | TEST_F(BufferQueueTest, framedropping_is_disabled_by_default) |
2652 | @@ -302,25 +303,27 @@ |
2653 | TEST_F(BufferQueueTest, clients_can_have_multiple_pending_completions) |
2654 | { |
2655 | int const nbuffers = 3; |
2656 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2657 | + std::shared_ptr<mc::BufferQueue> q; |
2658 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2659 | + ASSERT_THAT(q, Ne(nullptr)); |
2660 | |
2661 | - int const prefill = q.buffers_free_for_client(); |
2662 | + int const prefill = q->buffers_free_for_client(); |
2663 | ASSERT_THAT(prefill, Gt(0)); |
2664 | for (int i = 0; i < prefill; ++i) |
2665 | { |
2666 | - auto handle = client_acquire_async(q); |
2667 | + auto handle = client_acquire_async(*q); |
2668 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2669 | handle->release_buffer(); |
2670 | } |
2671 | |
2672 | - auto handle1 = client_acquire_async(q); |
2673 | + auto handle1 = client_acquire_async(*q); |
2674 | ASSERT_THAT(handle1->has_acquired_buffer(), Eq(false)); |
2675 | |
2676 | - auto handle2 = client_acquire_async(q); |
2677 | + auto handle2 = client_acquire_async(*q); |
2678 | ASSERT_THAT(handle1->has_acquired_buffer(), Eq(false)); |
2679 | |
2680 | for (int i = 0; i < nbuffers + 1; ++i) |
2681 | - q.compositor_release(q.compositor_acquire(this)); |
2682 | + q->compositor_acquire(this); |
2683 | |
2684 | EXPECT_THAT(handle1->has_acquired_buffer(), Eq(true)); |
2685 | EXPECT_THAT(handle2->has_acquired_buffer(), Eq(true)); |
2686 | @@ -334,27 +337,32 @@ |
2687 | { |
2688 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2689 | { |
2690 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2691 | - ASSERT_THAT(q.framedropping_allowed(), Eq(false)); |
2692 | + std::shared_ptr<mc::BufferQueue> q; |
2693 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2694 | + ASSERT_THAT(q, Ne(nullptr)); |
2695 | + ASSERT_THAT(q->framedropping_allowed(), Eq(false)); |
2696 | |
2697 | void const* main_compositor = reinterpret_cast<void const*>(0); |
2698 | void const* second_compositor = reinterpret_cast<void const*>(1); |
2699 | for (int i = 0; i < 20; i++) |
2700 | { |
2701 | - auto handle = client_acquire_async(q); |
2702 | + auto handle = client_acquire_async(*q); |
2703 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2704 | auto client_id = handle->id(); |
2705 | handle->release_buffer(); |
2706 | |
2707 | - auto comp_buffer = q.compositor_acquire(main_compositor); |
2708 | - auto composited_id = comp_buffer->id(); |
2709 | - q.compositor_release(comp_buffer); |
2710 | + mg::BufferID composited_id; |
2711 | + { |
2712 | + auto comp_buffer_handle = q->compositor_acquire(main_compositor); |
2713 | + composited_id = comp_buffer_handle.buffer()->id(); |
2714 | + } |
2715 | |
2716 | EXPECT_THAT(composited_id, Eq(client_id)); |
2717 | |
2718 | - comp_buffer = q.compositor_acquire(second_compositor); |
2719 | - EXPECT_THAT(composited_id, Eq(comp_buffer->id())); |
2720 | - q.compositor_release(comp_buffer); |
2721 | + { |
2722 | + auto comp_buffer_handle = q->compositor_acquire(second_compositor); |
2723 | + EXPECT_THAT(composited_id, Eq(comp_buffer_handle.buffer()->id())); |
2724 | + } |
2725 | } |
2726 | } |
2727 | } |
2728 | @@ -378,20 +386,21 @@ |
2729 | /* Regression test for LP: #1210042 */ |
2730 | TEST_F(BufferQueueTest, clients_dont_recycle_startup_buffer) |
2731 | { |
2732 | - mc::BufferQueue q(3, allocator, basic_properties, policy_factory); |
2733 | + std::shared_ptr<mc::BufferQueue> q; |
2734 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(3, allocator, basic_properties, policy_factory)); |
2735 | + ASSERT_THAT(q, Ne(nullptr)); |
2736 | |
2737 | - auto handle = client_acquire_async(q); |
2738 | + auto handle = client_acquire_async(*q); |
2739 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2740 | auto client_id = handle->id(); |
2741 | handle->release_buffer(); |
2742 | |
2743 | - handle = client_acquire_async(q); |
2744 | + handle = client_acquire_async(*q); |
2745 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2746 | handle->release_buffer(); |
2747 | |
2748 | - auto comp_buffer = q.compositor_acquire(this); |
2749 | - EXPECT_THAT(client_id, Eq(comp_buffer->id())); |
2750 | - q.compositor_release(comp_buffer); |
2751 | + auto comp_buffer_handle = q->compositor_acquire(this); |
2752 | + EXPECT_THAT(client_id, Eq(comp_buffer_handle.buffer()->id())); |
2753 | } |
2754 | |
2755 | TEST_F(BufferQueueTest, throws_on_out_of_order_client_release) |
2756 | @@ -418,12 +427,14 @@ |
2757 | { |
2758 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2759 | { |
2760 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2761 | + std::shared_ptr<mc::BufferQueue> q; |
2762 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2763 | + ASSERT_THAT(q, Ne(nullptr)); |
2764 | |
2765 | std::atomic<bool> done(false); |
2766 | auto unblock = [&done] { done = true; }; |
2767 | mt::AutoUnblockThread compositor(unblock, |
2768 | - compositor_thread, std::ref(q), std::ref(done)); |
2769 | + compositor_thread, std::ref(*q), std::ref(done)); |
2770 | |
2771 | std::unordered_set<uint32_t> ids_acquired; |
2772 | int const max_ownable_buffers = nbuffers - 1; |
2773 | @@ -432,7 +443,7 @@ |
2774 | std::vector<mg::Buffer *> client_buffers; |
2775 | for (int acquires = 0; acquires < max_ownable_buffers; ++acquires) |
2776 | { |
2777 | - auto handle = client_acquire_async(q); |
2778 | + auto handle = client_acquire_async(*q); |
2779 | handle->wait_for(std::chrono::seconds(1)); |
2780 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2781 | ids_acquired.insert(handle->id().as_value()); |
2782 | @@ -441,7 +452,7 @@ |
2783 | |
2784 | for (auto const& buffer : client_buffers) |
2785 | { |
2786 | - q.client_release(buffer); |
2787 | + q->client_release(buffer); |
2788 | } |
2789 | } |
2790 | |
2791 | @@ -453,17 +464,18 @@ |
2792 | { |
2793 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2794 | { |
2795 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2796 | + std::shared_ptr<mc::BufferQueue> q; |
2797 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2798 | + ASSERT_THAT(q, Ne(nullptr)); |
2799 | |
2800 | - auto handle = client_acquire_async(q); |
2801 | + auto handle = client_acquire_async(*q); |
2802 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2803 | |
2804 | auto client_id = handle->id(); |
2805 | ASSERT_NO_THROW(handle->release_buffer()); |
2806 | |
2807 | - auto comp_buffer = q.compositor_acquire(this); |
2808 | - EXPECT_THAT(client_id, Eq(comp_buffer->id())); |
2809 | - EXPECT_NO_THROW(q.compositor_release(comp_buffer)); |
2810 | + auto comp_buffer_handle = q->compositor_acquire(this); |
2811 | + EXPECT_THAT(client_id, Eq(comp_buffer_handle.buffer()->id())); |
2812 | } |
2813 | } |
2814 | |
2815 | @@ -471,9 +483,11 @@ |
2816 | { |
2817 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2818 | { |
2819 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2820 | + std::shared_ptr<mc::BufferQueue> q; |
2821 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2822 | + ASSERT_THAT(q, Ne(nullptr)); |
2823 | |
2824 | - auto handle = client_acquire_async(q); |
2825 | + auto handle = client_acquire_async(*q); |
2826 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2827 | |
2828 | auto client_id = handle->id(); |
2829 | @@ -482,9 +496,8 @@ |
2830 | for (int monitor = 0; monitor < 10; monitor++) |
2831 | { |
2832 | void const* user_id = reinterpret_cast<void const*>(monitor); |
2833 | - auto comp_buffer = q.compositor_acquire(user_id); |
2834 | - EXPECT_THAT(client_id, Eq(comp_buffer->id())); |
2835 | - q.compositor_release(comp_buffer); |
2836 | + auto comp_buffer_handle = q->compositor_acquire(user_id); |
2837 | + EXPECT_THAT(client_id, Eq(comp_buffer_handle.buffer()->id())); |
2838 | } |
2839 | } |
2840 | } |
2841 | @@ -493,16 +506,18 @@ |
2842 | { // Regression test for LP: #1420678 |
2843 | for (int nbuffers = 3; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2844 | { |
2845 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2846 | + std::shared_ptr<mc::BufferQueue> q; |
2847 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2848 | + ASSERT_THAT(q, Ne(nullptr)); |
2849 | |
2850 | // Client generates first frame |
2851 | - auto handle1 = client_acquire_async(q); |
2852 | + auto handle1 = client_acquire_async(*q); |
2853 | ASSERT_TRUE(handle1->has_acquired_buffer()); |
2854 | auto client_id1 = handle1->id(); |
2855 | handle1->release_buffer(); |
2856 | |
2857 | // Client generates second frame |
2858 | - auto handle2 = client_acquire_async(q); |
2859 | + auto handle2 = client_acquire_async(*q); |
2860 | ASSERT_TRUE(handle2->has_acquired_buffer()); |
2861 | auto client_id2 = handle2->id(); |
2862 | handle2->release_buffer(); |
2863 | @@ -511,18 +526,16 @@ |
2864 | for (int monitor = 0; monitor < 10; monitor++) |
2865 | { |
2866 | void const* user_id = reinterpret_cast<void const*>(monitor); |
2867 | - auto comp_buffer = q.compositor_acquire(user_id); |
2868 | - ASSERT_EQ(client_id1, comp_buffer->id()); |
2869 | - q.compositor_release(comp_buffer); |
2870 | + auto comp_buffer_handle = q->compositor_acquire(user_id); |
2871 | + ASSERT_EQ(client_id1, comp_buffer_handle.buffer()->id()); |
2872 | } |
2873 | |
2874 | // Still many monitors... verify they all get the second frame. |
2875 | for (int monitor = 0; monitor < 10; monitor++) |
2876 | { |
2877 | void const* user_id = reinterpret_cast<void const*>(monitor); |
2878 | - auto comp_buffer = q.compositor_acquire(user_id); |
2879 | - ASSERT_EQ(client_id2, comp_buffer->id()); |
2880 | - q.compositor_release(comp_buffer); |
2881 | + auto comp_buffer_handle = q->compositor_acquire(user_id); |
2882 | + ASSERT_EQ(client_id2, comp_buffer_handle.buffer()->id()); |
2883 | } |
2884 | } |
2885 | } |
2886 | @@ -531,7 +544,9 @@ |
2887 | { |
2888 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2889 | { |
2890 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2891 | + std::shared_ptr<mc::BufferQueue> q; |
2892 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2893 | + ASSERT_THAT(q, Ne(nullptr)); |
2894 | |
2895 | for (int i = 0; i < 10; ++i) |
2896 | { |
2897 | @@ -540,7 +555,7 @@ |
2898 | int const max_ownable_buffers = nbuffers - 1; |
2899 | for (int i = 0; i < max_ownable_buffers; ++i) |
2900 | { |
2901 | - auto handle = client_acquire_async(q); |
2902 | + auto handle = client_acquire_async(*q); |
2903 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2904 | buffers.push_back(handle->buffer()); |
2905 | } |
2906 | @@ -548,14 +563,13 @@ |
2907 | for (auto buffer : buffers) |
2908 | { |
2909 | client_release_sequence.push_back(buffer->id()); |
2910 | - q.client_release(buffer); |
2911 | + q->client_release(buffer); |
2912 | } |
2913 | |
2914 | for (auto const& client_id : client_release_sequence) |
2915 | { |
2916 | - auto comp_buffer = q.compositor_acquire(this); |
2917 | - EXPECT_THAT(client_id, Eq(comp_buffer->id())); |
2918 | - q.compositor_release(comp_buffer); |
2919 | + auto comp_buffer_handle = q->compositor_acquire(this); |
2920 | + EXPECT_THAT(client_id, Eq(comp_buffer_handle.buffer()->id())); |
2921 | } |
2922 | } |
2923 | } |
2924 | @@ -565,13 +579,12 @@ |
2925 | { |
2926 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2927 | { |
2928 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2929 | + std::shared_ptr<mc::BufferQueue> q; |
2930 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2931 | + ASSERT_THAT(q, Ne(nullptr)); |
2932 | |
2933 | for (int i = 0; i < 100; i++) |
2934 | - { |
2935 | - auto buffer = q.compositor_acquire(this); |
2936 | - q.compositor_release(buffer); |
2937 | - } |
2938 | + q->compositor_acquire(this); |
2939 | } |
2940 | } |
2941 | |
2942 | @@ -579,8 +592,10 @@ |
2943 | { |
2944 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2945 | { |
2946 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2947 | - q.allow_framedropping(false); |
2948 | + std::shared_ptr<mc::BufferQueue> q; |
2949 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2950 | + ASSERT_THAT(q, Ne(nullptr)); |
2951 | + q->allow_framedropping(false); |
2952 | |
2953 | std::atomic<bool> done(false); |
2954 | auto unblock = [&done] { done = true; }; |
2955 | @@ -589,7 +604,7 @@ |
2956 | { |
2957 | for (int nframes = 0; nframes < 100; ++nframes) |
2958 | { |
2959 | - auto handle = client_acquire_async(q); |
2960 | + auto handle = client_acquire_async(*q); |
2961 | handle->wait_for(std::chrono::seconds(1)); |
2962 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2963 | handle->release_buffer(); |
2964 | @@ -600,10 +615,11 @@ |
2965 | { |
2966 | while (!done) |
2967 | { |
2968 | - std::shared_ptr<mg::Buffer> buffer; |
2969 | - EXPECT_NO_THROW(buffer = q.compositor_acquire(this)); |
2970 | - EXPECT_THAT(buffer, Ne(nullptr)); |
2971 | - EXPECT_NO_THROW(q.compositor_release(buffer)); |
2972 | + { |
2973 | + std::shared_ptr<mg::Buffer> buffer; |
2974 | + EXPECT_NO_THROW(buffer = q->compositor_acquire(this).buffer()); |
2975 | + EXPECT_THAT(buffer, Ne(nullptr)); |
2976 | + } |
2977 | std::this_thread::yield(); |
2978 | } |
2979 | }); |
2980 | @@ -617,7 +633,9 @@ |
2981 | { |
2982 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
2983 | { |
2984 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
2985 | + std::shared_ptr<mc::BufferQueue> q; |
2986 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
2987 | + ASSERT_THAT(q, Ne(nullptr)); |
2988 | |
2989 | mg::Buffer* last_client_acquired_buffer{nullptr}; |
2990 | |
2991 | @@ -625,7 +643,7 @@ |
2992 | { |
2993 | if (i % 10 == 0) |
2994 | { |
2995 | - auto handle = client_acquire_async(q); |
2996 | + auto handle = client_acquire_async(*q); |
2997 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
2998 | last_client_acquired_buffer = handle->buffer(); |
2999 | handle->release_buffer(); |
3000 | @@ -634,51 +652,35 @@ |
3001 | for (int monitor_id = 0; monitor_id < 10; monitor_id++) |
3002 | { |
3003 | void const* user_id = reinterpret_cast<void const*>(monitor_id); |
3004 | - auto buffer = q.compositor_acquire(user_id); |
3005 | - ASSERT_THAT(buffer.get(), Eq(last_client_acquired_buffer)); |
3006 | - q.compositor_release(buffer); |
3007 | + auto buffer_handle = q->compositor_acquire(user_id); |
3008 | + ASSERT_THAT(buffer_handle.buffer().get(), Eq(last_client_acquired_buffer)); |
3009 | } |
3010 | } |
3011 | } |
3012 | } |
3013 | |
3014 | -TEST_F(BufferQueueTest, compositor_release_verifies_parameter) |
3015 | -{ |
3016 | - for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3017 | - { |
3018 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3019 | - |
3020 | - auto handle = client_acquire_async(q); |
3021 | - ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3022 | - handle->release_buffer(); |
3023 | - |
3024 | - auto comp_buffer = q.compositor_acquire(this); |
3025 | - q.compositor_release(comp_buffer); |
3026 | - EXPECT_THROW(q.compositor_release(comp_buffer), std::logic_error); |
3027 | - } |
3028 | -} |
3029 | - |
3030 | /* Regression test for LP#1270964 */ |
3031 | TEST_F(BufferQueueTest, compositor_client_interleaved) |
3032 | { |
3033 | - mc::BufferQueue q(3, allocator, basic_properties, policy_factory); |
3034 | + std::shared_ptr<mc::BufferQueue> q; |
3035 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(3, allocator, basic_properties, policy_factory)); |
3036 | + ASSERT_THAT(q, Ne(nullptr)); |
3037 | |
3038 | - auto handle = client_acquire_async(q); |
3039 | + auto handle = client_acquire_async(*q); |
3040 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3041 | |
3042 | auto first_ready_buffer_id = handle->id(); |
3043 | handle->release_buffer(); |
3044 | |
3045 | - handle = client_acquire_async(q); |
3046 | + handle = client_acquire_async(*q); |
3047 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3048 | |
3049 | // in the original bug, compositor would be given the wrong buffer here |
3050 | - auto compositor_buffer = q.compositor_acquire(this); |
3051 | + auto compositor_buffer_handle = q->compositor_acquire(this); |
3052 | |
3053 | - EXPECT_THAT(compositor_buffer->id(), Eq(first_ready_buffer_id)); |
3054 | + EXPECT_THAT(compositor_buffer_handle.buffer()->id(), Eq(first_ready_buffer_id)); |
3055 | |
3056 | handle->release_buffer(); |
3057 | - q.compositor_release(compositor_buffer); |
3058 | } |
3059 | |
3060 | TEST_F(BufferQueueTest, overlapping_compositors_get_different_frames) |
3061 | @@ -686,36 +688,42 @@ |
3062 | // This test simulates bypass behaviour |
3063 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3064 | { |
3065 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3066 | - |
3067 | - std::shared_ptr<mg::Buffer> compositor[2]; |
3068 | - |
3069 | - auto handle = client_acquire_async(q); |
3070 | - ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3071 | - handle->release_buffer(); |
3072 | - compositor[0] = q.compositor_acquire(this); |
3073 | - |
3074 | - handle = client_acquire_async(q); |
3075 | - ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3076 | - handle->release_buffer(); |
3077 | - compositor[1] = q.compositor_acquire(this); |
3078 | + std::shared_ptr<mc::BufferQueue> q; |
3079 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3080 | + ASSERT_THAT(q, Ne(nullptr)); |
3081 | + |
3082 | + mc::BufferHandle *compositor[] = |
3083 | + { new mc::BufferHandle(nullptr, nullptr), |
3084 | + new mc::BufferHandle(nullptr, nullptr) }; |
3085 | + |
3086 | + auto handle = client_acquire_async(*q); |
3087 | + ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3088 | + handle->release_buffer(); |
3089 | + *compositor[0] = q->compositor_acquire(this); |
3090 | + |
3091 | + handle = client_acquire_async(*q); |
3092 | + ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3093 | + handle->release_buffer(); |
3094 | + *compositor[1] = q->compositor_acquire(this); |
3095 | |
3096 | for (int i = 0; i < 20; i++) |
3097 | { |
3098 | // Two compositors acquired, and they're always different... |
3099 | - ASSERT_THAT(compositor[0]->id(), Ne(compositor[1]->id())); |
3100 | - |
3101 | + ASSERT_THAT(compositor[0]->buffer()->id(), Ne(compositor[1]->buffer()->id())); |
3102 | // One of the compositors (the oldest one) gets a new buffer... |
3103 | int oldest = i & 1; |
3104 | - q.compositor_release(compositor[oldest]); |
3105 | - auto handle = client_acquire_async(q); |
3106 | + delete compositor[oldest]; |
3107 | + compositor[oldest] = nullptr; |
3108 | + auto handle = client_acquire_async(*q); |
3109 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3110 | handle->release_buffer(); |
3111 | - compositor[oldest] = q.compositor_acquire(this); |
3112 | + compositor[oldest] = new mc::BufferHandle(nullptr, nullptr); |
3113 | + *compositor[oldest] = q->compositor_acquire(this); |
3114 | } |
3115 | |
3116 | - q.compositor_release(compositor[0]); |
3117 | - q.compositor_release(compositor[1]); |
3118 | + for (int i = 0; i < 2; i++) |
3119 | + if (compositor[i]) |
3120 | + delete compositor[i]; |
3121 | } |
3122 | } |
3123 | |
3124 | @@ -723,13 +731,14 @@ |
3125 | { |
3126 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3127 | { |
3128 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3129 | + std::shared_ptr<mc::BufferQueue> q; |
3130 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3131 | + ASSERT_THAT(q, Ne(nullptr)); |
3132 | |
3133 | - auto comp_buffer = q.compositor_acquire(this); |
3134 | - auto snapshot = q.snapshot_acquire(); |
3135 | - EXPECT_THAT(snapshot->id(), Eq(comp_buffer->id())); |
3136 | - q.compositor_release(comp_buffer); |
3137 | - q.snapshot_release(snapshot); |
3138 | + auto comp_buffer_handle = q->compositor_acquire(this); |
3139 | + auto snapshot_handle = q->snapshot_acquire(); |
3140 | + EXPECT_THAT(snapshot_handle.buffer()->id(), |
3141 | + Eq(comp_buffer_handle.buffer()->id())); |
3142 | } |
3143 | } |
3144 | |
3145 | @@ -744,13 +753,16 @@ |
3146 | |
3147 | TEST_F(BufferQueueTest, callbacks_cant_happen_after_shutdown_with_snapshots) |
3148 | { |
3149 | - mc::BufferQueue q(1, allocator, basic_properties, policy_factory); |
3150 | - |
3151 | - auto snapshot = q.snapshot_acquire(); |
3152 | - q.drop_client_requests(); |
3153 | - q.snapshot_release(snapshot); |
3154 | - |
3155 | - auto client = client_acquire_async(q); |
3156 | + std::shared_ptr<mc::BufferQueue> q; |
3157 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(1, allocator, basic_properties, policy_factory)); |
3158 | + ASSERT_THAT(q, Ne(nullptr)); |
3159 | + |
3160 | + { |
3161 | + auto snapshot = q->snapshot_acquire(); |
3162 | + q->drop_client_requests(); |
3163 | + } |
3164 | + |
3165 | + auto client = client_acquire_async(*q); |
3166 | ASSERT_FALSE(client->has_acquired_buffer()); |
3167 | } |
3168 | |
3169 | @@ -758,39 +770,19 @@ |
3170 | { |
3171 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3172 | { |
3173 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3174 | + std::shared_ptr<mc::BufferQueue> q; |
3175 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3176 | + ASSERT_THAT(q, Ne(nullptr)); |
3177 | int const num_snapshots = 100; |
3178 | |
3179 | - std::shared_ptr<mg::Buffer> buf[num_snapshots]; |
3180 | - for (int i = 0; i < num_snapshots; i++) |
3181 | - buf[i] = q.snapshot_acquire(); |
3182 | - |
3183 | - for (int i = 0; i < num_snapshots; i++) |
3184 | - q.snapshot_release(buf[i]); |
3185 | - } |
3186 | -} |
3187 | - |
3188 | -TEST_F(BufferQueueTest, snapshot_release_verifies_parameter) |
3189 | -{ |
3190 | - for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3191 | - { |
3192 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3193 | - |
3194 | - auto handle = client_acquire_async(q); |
3195 | - ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3196 | - handle->release_buffer(); |
3197 | - |
3198 | - auto comp_buffer = q.compositor_acquire(this); |
3199 | - EXPECT_THROW(q.snapshot_release(comp_buffer), std::logic_error); |
3200 | - |
3201 | - handle = client_acquire_async(q); |
3202 | - ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3203 | - auto snapshot = q.snapshot_acquire(); |
3204 | - |
3205 | - EXPECT_THAT(snapshot->id(), Eq(comp_buffer->id())); |
3206 | - EXPECT_THAT(snapshot->id(), Ne(handle->id())); |
3207 | - EXPECT_NO_THROW(q.snapshot_release(snapshot)); |
3208 | - EXPECT_THROW(q.snapshot_release(snapshot), std::logic_error); |
3209 | + std::vector<mc::BufferHandle> bufs; |
3210 | + bufs.reserve(num_snapshots); |
3211 | + |
3212 | + for (int i = 0; i < num_snapshots; i++) |
3213 | + bufs.push_back(std::move(mc::BufferHandle(nullptr, nullptr))); |
3214 | + |
3215 | + for (int i = 0; i < num_snapshots; i++) |
3216 | + bufs[i] = q->snapshot_acquire(); |
3217 | } |
3218 | } |
3219 | |
3220 | @@ -798,31 +790,33 @@ |
3221 | { |
3222 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3223 | { |
3224 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3225 | + std::shared_ptr<mc::BufferQueue> q; |
3226 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3227 | + ASSERT_THAT(q, Ne(nullptr)); |
3228 | |
3229 | std::atomic<bool> done(false); |
3230 | |
3231 | auto unblock = [&done]{ done = true;}; |
3232 | |
3233 | mt::AutoUnblockThread compositor(unblock, compositor_thread, |
3234 | - std::ref(q), |
3235 | + std::ref(*q), |
3236 | std::ref(done)); |
3237 | mt::AutoUnblockThread snapshotter1(unblock, snapshot_thread, |
3238 | - std::ref(q), |
3239 | + std::ref(*q), |
3240 | std::ref(done)); |
3241 | mt::AutoUnblockThread snapshotter2(unblock, snapshot_thread, |
3242 | - std::ref(q), |
3243 | + std::ref(*q), |
3244 | std::ref(done)); |
3245 | |
3246 | - q.allow_framedropping(false); |
3247 | - mt::AutoJoinThread client1(client_thread, std::ref(q), 1000); |
3248 | + q->allow_framedropping(false); |
3249 | + mt::AutoJoinThread client1(client_thread, std::ref(*q), 1000); |
3250 | client1.stop(); |
3251 | |
3252 | - q.allow_framedropping(true); |
3253 | - mt::AutoJoinThread client2(client_thread, std::ref(q), 1000); |
3254 | + q->allow_framedropping(true); |
3255 | + mt::AutoJoinThread client2(client_thread, std::ref(*q), 1000); |
3256 | client2.stop(); |
3257 | |
3258 | - mt::AutoJoinThread client3(switching_client_thread, std::ref(q), 1000); |
3259 | + mt::AutoJoinThread client3(switching_client_thread, std::ref(*q), 1000); |
3260 | client3.stop(); |
3261 | } |
3262 | } |
3263 | @@ -878,11 +872,13 @@ |
3264 | { |
3265 | for (int nbuffers = 2; nbuffers <= 3; nbuffers++) |
3266 | { |
3267 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3268 | + std::shared_ptr<mc::BufferQueue> q; |
3269 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3270 | + ASSERT_THAT(q, Ne(nullptr)); |
3271 | unsigned long client_frames = 0; |
3272 | const unsigned long compose_frames = 20; |
3273 | |
3274 | - q.allow_framedropping(false); |
3275 | + q->allow_framedropping(false); |
3276 | |
3277 | std::atomic<bool> done(false); |
3278 | |
3279 | @@ -892,8 +888,7 @@ |
3280 | { |
3281 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
3282 | |
3283 | - auto buf = q.compositor_acquire(this); |
3284 | - q.compositor_release(buf); |
3285 | + q->compositor_acquire(this); |
3286 | |
3287 | if (frame == compose_frames) |
3288 | { |
3289 | @@ -905,13 +900,13 @@ |
3290 | } |
3291 | }); |
3292 | |
3293 | - auto handle = client_acquire_async(q); |
3294 | + auto handle = client_acquire_async(*q); |
3295 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3296 | handle->release_buffer(); |
3297 | |
3298 | while (!done.load()) |
3299 | { |
3300 | - auto handle = client_acquire_async(q); |
3301 | + auto handle = client_acquire_async(*q); |
3302 | handle->wait_for(std::chrono::seconds(1)); |
3303 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3304 | handle->release_buffer(); |
3305 | @@ -934,12 +929,14 @@ |
3306 | */ |
3307 | for (int nbuffers = 3; nbuffers <= 3; nbuffers++) |
3308 | { |
3309 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3310 | + std::shared_ptr<mc::BufferQueue> q; |
3311 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3312 | + ASSERT_THAT(q, Ne(nullptr)); |
3313 | unsigned long client_frames = 0; |
3314 | unsigned long const compose_frames = 100; |
3315 | auto const frame_time = std::chrono::milliseconds(16); |
3316 | |
3317 | - q.allow_framedropping(false); |
3318 | + q->allow_framedropping(false); |
3319 | |
3320 | std::atomic<bool> done(false); |
3321 | std::mutex sync; |
3322 | @@ -950,8 +947,7 @@ |
3323 | { |
3324 | std::this_thread::sleep_for(frame_time); |
3325 | sync.lock(); |
3326 | - auto buf = q.compositor_acquire(this); |
3327 | - q.compositor_release(buf); |
3328 | + q->compositor_acquire(this); |
3329 | sync.unlock(); |
3330 | |
3331 | if (frame == compose_frames) |
3332 | @@ -964,7 +960,7 @@ |
3333 | } |
3334 | }); |
3335 | |
3336 | - auto handle = client_acquire_async(q); |
3337 | + auto handle = client_acquire_async(*q); |
3338 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3339 | handle->release_buffer(); |
3340 | |
3341 | @@ -972,7 +968,7 @@ |
3342 | { |
3343 | sync.lock(); |
3344 | sync.unlock(); |
3345 | - auto handle = client_acquire_async(q); |
3346 | + auto handle = client_acquire_async(*q); |
3347 | handle->wait_for(std::chrono::seconds(1)); |
3348 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3349 | std::this_thread::sleep_for(frame_time); |
3350 | @@ -992,7 +988,9 @@ |
3351 | { |
3352 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3353 | { |
3354 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3355 | + std::shared_ptr<mc::BufferQueue> q; |
3356 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3357 | + ASSERT_THAT(q, Ne(nullptr)); |
3358 | |
3359 | for (int width = 1; width < 100; ++width) |
3360 | { |
3361 | @@ -1000,16 +998,15 @@ |
3362 | |
3363 | for (int subframe = 0; subframe < 3; ++subframe) |
3364 | { |
3365 | - q.resize(expect_size); |
3366 | - auto handle = client_acquire_async(q); |
3367 | + q->resize(expect_size); |
3368 | + auto handle = client_acquire_async(*q); |
3369 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3370 | auto buffer = handle->buffer(); |
3371 | ASSERT_THAT(expect_size, Eq(buffer->size())); |
3372 | handle->release_buffer(); |
3373 | |
3374 | - auto comp_buffer = q.compositor_acquire(this); |
3375 | - ASSERT_THAT(expect_size, Eq(comp_buffer->size())); |
3376 | - q.compositor_release(comp_buffer); |
3377 | + auto comp_buffer_handle = q->compositor_acquire(this); |
3378 | + ASSERT_THAT(expect_size, Eq(comp_buffer_handle.buffer()->size())); |
3379 | } |
3380 | } |
3381 | } |
3382 | @@ -1027,7 +1024,9 @@ |
3383 | { |
3384 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3385 | { |
3386 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3387 | + std::shared_ptr<mc::BufferQueue> q; |
3388 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3389 | + ASSERT_THAT(q, Ne(nullptr)); |
3390 | std::vector<mg::BufferID> history; |
3391 | |
3392 | const int width0 = 123; |
3393 | @@ -1036,7 +1035,7 @@ |
3394 | const int dy = -3; |
3395 | int width = width0; |
3396 | int height = height0; |
3397 | - int const nbuffers_to_use = q.buffers_free_for_client(); |
3398 | + int const nbuffers_to_use = q->buffers_free_for_client(); |
3399 | ASSERT_THAT(nbuffers_to_use, Gt(0)); |
3400 | |
3401 | int max_buffers{max_ownable_buffers(nbuffers)}; |
3402 | @@ -1046,8 +1045,8 @@ |
3403 | width += dx; |
3404 | height += dy; |
3405 | |
3406 | - q.resize(new_size); |
3407 | - auto handle = client_acquire_async(q); |
3408 | + q->resize(new_size); |
3409 | + auto handle = client_acquire_async(*q); |
3410 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3411 | history.emplace_back(handle->id()); |
3412 | auto buffer = handle->buffer(); |
3413 | @@ -1065,25 +1064,22 @@ |
3414 | width += dx; |
3415 | height += dy; |
3416 | |
3417 | - auto buffer = q.compositor_acquire(this); |
3418 | + auto buffer_handle = q->compositor_acquire(this); |
3419 | |
3420 | // Verify the compositor gets resized buffers, eventually |
3421 | - ASSERT_THAT(buffer->size(), Eq(expect_size)); |
3422 | + ASSERT_THAT(buffer_handle.buffer()->size(), Eq(expect_size)); |
3423 | |
3424 | // Verify the compositor gets buffers with *contents*, ie. that |
3425 | // they have not been resized prematurely and are empty. |
3426 | - ASSERT_THAT(history[consume], Eq(buffer->id())); |
3427 | - |
3428 | - q.compositor_release(buffer); |
3429 | + ASSERT_THAT(history[consume], Eq(buffer_handle.buffer()->id())); |
3430 | } |
3431 | |
3432 | // Verify the final buffer size sticks |
3433 | const geom::Size final_size{width - dx, height - dy}; |
3434 | for (int unchanging = 0; unchanging < 100; ++unchanging) |
3435 | { |
3436 | - auto buffer = q.compositor_acquire(this); |
3437 | - ASSERT_THAT(buffer->size(), Eq(final_size)); |
3438 | - q.compositor_release(buffer); |
3439 | + auto buffer_handle = q->compositor_acquire(this); |
3440 | + ASSERT_THAT(buffer_handle.buffer()->size(), Eq(final_size)); |
3441 | } |
3442 | } |
3443 | } |
3444 | @@ -1093,23 +1089,22 @@ |
3445 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3446 | { |
3447 | mtd::MockFrameDroppingPolicyFactory policy_factory; |
3448 | - mc::BufferQueue q(nbuffers, |
3449 | - allocator, |
3450 | - basic_properties, |
3451 | - policy_factory); |
3452 | + std::shared_ptr<mc::BufferQueue> q; |
3453 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3454 | + ASSERT_THAT(q, Ne(nullptr)); |
3455 | |
3456 | - auto first = client_acquire_sync(q); |
3457 | - q.client_release(first); |
3458 | + auto first = client_acquire_sync(*q); |
3459 | + q->client_release(first); |
3460 | |
3461 | // Start rendering one (don't finish) |
3462 | - auto d = q.compositor_acquire(nullptr); |
3463 | - ASSERT_EQ(first, d.get()); |
3464 | + auto d = q->compositor_acquire(nullptr); |
3465 | + ASSERT_EQ(first, d.buffer().get()); |
3466 | |
3467 | - auto second = client_acquire_sync(q); |
3468 | - q.client_release(second); |
3469 | + auto second = client_acquire_sync(*q); |
3470 | + q->client_release(second); |
3471 | |
3472 | // Client waits for a new frame |
3473 | - auto end = client_acquire_async(q); |
3474 | + auto end = client_acquire_async(*q); |
3475 | |
3476 | // Surface goes offscreen or occluded; trigger a timeout |
3477 | policy_factory.trigger_policies(); |
3478 | @@ -1121,8 +1116,6 @@ |
3479 | // will produce another frame. |
3480 | if (end->has_acquired_buffer()) |
3481 | ASSERT_NE(second, end->buffer()); |
3482 | - |
3483 | - q.compositor_release(d); |
3484 | } |
3485 | } |
3486 | |
3487 | @@ -1130,34 +1123,33 @@ |
3488 | { // Second regression test for LP: #1396006, LP: #1379685 |
3489 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3490 | { |
3491 | - mc::BufferQueue q(nbuffers, |
3492 | - allocator, |
3493 | - basic_properties, |
3494 | - policy_factory); |
3495 | + std::shared_ptr<mc::BufferQueue> q; |
3496 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3497 | + ASSERT_THAT(q, Ne(nullptr)); |
3498 | |
3499 | - q.allow_framedropping(true); |
3500 | + q->allow_framedropping(true); |
3501 | |
3502 | // Fill 'er up |
3503 | std::vector<mg::Buffer*> order; |
3504 | for (int f = 0; f < nbuffers; ++f) |
3505 | { |
3506 | - auto b = client_acquire_sync(q); |
3507 | + auto b = client_acquire_sync(*q); |
3508 | order.push_back(b); |
3509 | - q.client_release(b); |
3510 | + q->client_release(b); |
3511 | } |
3512 | |
3513 | // Composite all but one |
3514 | std::vector<std::shared_ptr<mg::Buffer>> compositing; |
3515 | for (int n = 0; n < nbuffers-1; ++n) |
3516 | { |
3517 | - auto c = q.compositor_acquire(nullptr); |
3518 | - compositing.push_back(c); |
3519 | - ASSERT_EQ(order[n], c.get()); |
3520 | + auto c = q->compositor_acquire(nullptr); |
3521 | + compositing.push_back(c.buffer()); |
3522 | + ASSERT_EQ(order[n], c.buffer().get()); |
3523 | } |
3524 | |
3525 | // Ensure it's not the newest frame that gets dropped to satisfy the |
3526 | // client. |
3527 | - auto end = client_acquire_async(q); |
3528 | + auto end = client_acquire_async(*q); |
3529 | |
3530 | // The queue could solve this problem a few ways. It might choose to |
3531 | // defer framedropping till it's safe, or even allocate additional |
3532 | @@ -1203,25 +1195,24 @@ |
3533 | nbuffers++) |
3534 | { |
3535 | mtd::MockFrameDroppingPolicyFactory policy_factory; |
3536 | - mc::BufferQueue q(nbuffers, |
3537 | - allocator, |
3538 | - basic_properties, |
3539 | - policy_factory); |
3540 | + std::shared_ptr<mc::BufferQueue> q; |
3541 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3542 | + ASSERT_THAT(q, Ne(nullptr)); |
3543 | |
3544 | for (int i = 0; i < max_ownable_buffers(nbuffers); i++) |
3545 | { |
3546 | - auto client = client_acquire_sync(q); |
3547 | - q.client_release(client); |
3548 | + auto client = client_acquire_sync(*q); |
3549 | + q->client_release(client); |
3550 | } |
3551 | |
3552 | /* Queue up two pending swaps */ |
3553 | - auto first_swap = client_acquire_async(q); |
3554 | - auto second_swap = client_acquire_async(q); |
3555 | + auto first_swap = client_acquire_async(*q); |
3556 | + auto second_swap = client_acquire_async(*q); |
3557 | |
3558 | ASSERT_FALSE(first_swap->has_acquired_buffer()); |
3559 | ASSERT_FALSE(second_swap->has_acquired_buffer()); |
3560 | |
3561 | - q.compositor_acquire(nullptr); |
3562 | + q->compositor_acquire(nullptr); |
3563 | |
3564 | EXPECT_TRUE(first_swap->has_acquired_buffer()); |
3565 | EXPECT_FALSE(second_swap->has_acquired_buffer()); |
3566 | @@ -1241,48 +1232,54 @@ |
3567 | int const nbuffers{1}; |
3568 | geom::Size const new_size{123,456}; |
3569 | |
3570 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3571 | - |
3572 | - q.client_release(client_acquire_sync(q)); |
3573 | - q.resize(new_size); |
3574 | - |
3575 | - auto const handle = client_acquire_async(q); |
3576 | + std::shared_ptr<mc::BufferQueue> q; |
3577 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3578 | + ASSERT_THAT(q, Ne(nullptr)); |
3579 | + |
3580 | + q->client_release(client_acquire_sync(*q)); |
3581 | + q->resize(new_size); |
3582 | + |
3583 | + auto const handle = client_acquire_async(*q); |
3584 | EXPECT_THAT(handle->has_acquired_buffer(), Eq(false)); |
3585 | |
3586 | - auto buf = q.compositor_acquire(this); |
3587 | - q.compositor_release(buf); |
3588 | + q->compositor_acquire(this); |
3589 | |
3590 | - buf = q.compositor_acquire(this); |
3591 | - EXPECT_THAT(buf->size(), Eq(new_size)); |
3592 | - q.compositor_release(buf); |
3593 | + { |
3594 | + auto buf_handle = q->compositor_acquire(this); |
3595 | + EXPECT_THAT(buf_handle.buffer()->size(), Eq(new_size)); |
3596 | + } |
3597 | } |
3598 | |
3599 | TEST_F(BufferQueueTest, double_buffered_client_is_not_blocked_prematurely) |
3600 | { // Regression test for LP: #1319765 |
3601 | using namespace testing; |
3602 | |
3603 | - mc::BufferQueue q{2, allocator, basic_properties, policy_factory}; |
3604 | - |
3605 | - q.client_release(client_acquire_sync(q)); |
3606 | - auto a = q.compositor_acquire(this); |
3607 | - q.client_release(client_acquire_sync(q)); |
3608 | - auto b = q.compositor_acquire(this); |
3609 | - |
3610 | - ASSERT_NE(a.get(), b.get()); |
3611 | - |
3612 | - q.compositor_release(a); |
3613 | - q.client_release(client_acquire_sync(q)); |
3614 | - |
3615 | - q.compositor_release(b); |
3616 | + std::shared_ptr<mc::BufferQueue> q; |
3617 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(2, allocator, basic_properties, policy_factory)); |
3618 | + ASSERT_THAT(q, Ne(nullptr)); |
3619 | + |
3620 | + q->client_release(client_acquire_sync(*q)); |
3621 | + auto a = new mc::BufferHandle(nullptr, nullptr); |
3622 | + *a = q->compositor_acquire(this); |
3623 | + q->client_release(client_acquire_sync(*q)); |
3624 | + auto b = new mc::BufferHandle(nullptr, nullptr); |
3625 | + *b = q->compositor_acquire(this); |
3626 | + |
3627 | + ASSERT_NE(a->buffer().get(), b->buffer().get()); |
3628 | + delete a; |
3629 | + |
3630 | + q->client_release(client_acquire_sync(*q)); |
3631 | + |
3632 | + delete b; |
3633 | |
3634 | /* |
3635 | * Update to the original test case; This additional compositor acquire |
3636 | * represents the fixing of LP: #1395581 in the compositor logic. |
3637 | */ |
3638 | - if (q.buffers_ready_for_compositor(this)) |
3639 | - q.compositor_release(q.compositor_acquire(this)); |
3640 | + if (q->buffers_ready_for_compositor(this)) |
3641 | + q->compositor_acquire(this); |
3642 | |
3643 | - auto handle = client_acquire_async(q); |
3644 | + auto handle = client_acquire_async(*q); |
3645 | // With the fix, a buffer will be available instantaneously: |
3646 | ASSERT_TRUE(handle->has_acquired_buffer()); |
3647 | handle->release_buffer(); |
3648 | @@ -1292,45 +1289,49 @@ |
3649 | { // Extended regression test for LP: #1319765 |
3650 | using namespace testing; |
3651 | |
3652 | - mc::BufferQueue q{2, allocator, basic_properties, policy_factory}; |
3653 | + std::shared_ptr<mc::BufferQueue> q; |
3654 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(2, allocator, basic_properties, policy_factory)); |
3655 | + ASSERT_THAT(q, Ne(nullptr)); |
3656 | |
3657 | for (int i = 0; i < 100; ++i) |
3658 | { |
3659 | - auto x = client_acquire_async(q); |
3660 | + auto x = client_acquire_async(*q); |
3661 | ASSERT_TRUE(x->has_acquired_buffer()); |
3662 | x->release_buffer(); |
3663 | |
3664 | - auto a = q.compositor_acquire(this); |
3665 | + auto a = new mc::BufferHandle(nullptr, nullptr); |
3666 | + *a = q->compositor_acquire(this); |
3667 | |
3668 | - auto y = client_acquire_async(q); |
3669 | + auto y = client_acquire_async(*q); |
3670 | ASSERT_TRUE(y->has_acquired_buffer()); |
3671 | y->release_buffer(); |
3672 | |
3673 | - auto b = q.compositor_acquire(this); |
3674 | - |
3675 | - ASSERT_NE(a.get(), b.get()); |
3676 | - |
3677 | - q.compositor_release(a); |
3678 | - |
3679 | - auto w = client_acquire_async(q); |
3680 | + auto b = new mc::BufferHandle(nullptr, nullptr); |
3681 | + *b = q->compositor_acquire(this); |
3682 | + |
3683 | + ASSERT_NE(a->buffer(), b->buffer()); |
3684 | + |
3685 | + delete a; |
3686 | + |
3687 | + auto w = client_acquire_async(*q); |
3688 | ASSERT_TRUE(w->has_acquired_buffer()); |
3689 | w->release_buffer(); |
3690 | - |
3691 | - q.compositor_release(b); |
3692 | + |
3693 | + delete b; |
3694 | |
3695 | /* |
3696 | * Update to the original test case; This additional compositor acquire |
3697 | * represents the fixing of LP: #1395581 in the compositor logic. |
3698 | */ |
3699 | - if (q.buffers_ready_for_compositor(this)) |
3700 | - q.compositor_release(q.compositor_acquire(this)); |
3701 | + if (q->buffers_ready_for_compositor(this)) |
3702 | + q->compositor_acquire(this); |
3703 | |
3704 | - auto z = client_acquire_async(q); |
3705 | + auto z = client_acquire_async(*q); |
3706 | ASSERT_TRUE(z->has_acquired_buffer()); |
3707 | z->release_buffer(); |
3708 | |
3709 | - q.compositor_release(q.compositor_acquire(this)); |
3710 | - q.compositor_release(q.compositor_acquire(this)); |
3711 | + q->compositor_acquire(this); |
3712 | + q->compositor_acquire(this); |
3713 | } |
3714 | } |
3715 | |
3716 | @@ -1340,34 +1341,40 @@ |
3717 | |
3718 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3719 | { |
3720 | - mc::BufferQueue q{nbuffers, allocator, basic_properties, policy_factory}; |
3721 | + std::shared_ptr<mc::BufferQueue> q; |
3722 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3723 | + ASSERT_THAT(q, Ne(nullptr)); |
3724 | |
3725 | // Produce frame 1 |
3726 | - q.client_release(client_acquire_sync(q)); |
3727 | + q->client_release(client_acquire_sync(*q)); |
3728 | // Acquire frame 1 |
3729 | - auto a = q.compositor_acquire(this); |
3730 | + auto a = new mc::BufferHandle(nullptr, nullptr); |
3731 | + *a = q->compositor_acquire(this); |
3732 | |
3733 | // Produce frame 2 |
3734 | - q.client_release(client_acquire_sync(q)); |
3735 | + q->client_release(client_acquire_sync(*q)); |
3736 | // Acquire frame 2 |
3737 | - auto b = q.compositor_acquire(this); |
3738 | + auto b = new mc::BufferHandle(nullptr, nullptr); |
3739 | + *b = q->compositor_acquire(this); |
3740 | |
3741 | // Release frame 1 |
3742 | - q.compositor_release(a); |
3743 | + delete a; |
3744 | + |
3745 | // Produce frame 3 |
3746 | - q.client_release(client_acquire_sync(q)); |
3747 | + q->client_release(client_acquire_sync(*q)); |
3748 | // Release frame 2 |
3749 | - q.compositor_release(b); |
3750 | + delete b; |
3751 | |
3752 | // Verify frame 3 is ready for the first compositor |
3753 | - ASSERT_THAT(q.buffers_ready_for_compositor(this), Ge(1)); |
3754 | - auto c = q.compositor_acquire(this); |
3755 | + ASSERT_THAT(q->buffers_ready_for_compositor(this), Ge(1)); |
3756 | + auto c = new mc::BufferHandle(nullptr, nullptr); |
3757 | + *c = q->compositor_acquire(this); |
3758 | |
3759 | // Verify frame 3 is ready for a second compositor |
3760 | int const that = 0; |
3761 | - ASSERT_THAT(q.buffers_ready_for_compositor(&that), Ge(1)); |
3762 | + ASSERT_THAT(q->buffers_ready_for_compositor(&that), Ge(1)); |
3763 | |
3764 | - q.compositor_release(c); |
3765 | + delete c; |
3766 | } |
3767 | } |
3768 | |
3769 | @@ -1377,25 +1384,27 @@ |
3770 | |
3771 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3772 | { |
3773 | - mc::BufferQueue q{nbuffers, allocator, basic_properties, policy_factory}; |
3774 | + std::shared_ptr<mc::BufferQueue> q; |
3775 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3776 | + ASSERT_THAT(q, Ne(nullptr)); |
3777 | |
3778 | const int nmonitors = 3; |
3779 | int monitor[nmonitors]; |
3780 | |
3781 | for (int m = 0; m < nmonitors; ++m) |
3782 | { |
3783 | - ASSERT_EQ(0, q.buffers_ready_for_compositor(&monitor[m])); |
3784 | + ASSERT_EQ(0, q->buffers_ready_for_compositor(&monitor[m])); |
3785 | } |
3786 | |
3787 | // Produce a frame |
3788 | - q.client_release(client_acquire_sync(q)); |
3789 | + q->client_release(client_acquire_sync(*q)); |
3790 | |
3791 | // Consume |
3792 | for (int m = 0; m < nmonitors; ++m) |
3793 | { |
3794 | - ASSERT_EQ(1, q.buffers_ready_for_compositor(&monitor[m])); |
3795 | - q.compositor_release(q.compositor_acquire(&monitor[m])); |
3796 | - ASSERT_EQ(0, q.buffers_ready_for_compositor(&monitor[m])); |
3797 | + ASSERT_EQ(1, q->buffers_ready_for_compositor(&monitor[m])); |
3798 | + q->compositor_acquire(&monitor[m]); |
3799 | + ASSERT_EQ(0, q->buffers_ready_for_compositor(&monitor[m])); |
3800 | } |
3801 | } |
3802 | } |
3803 | @@ -1407,47 +1416,47 @@ |
3804 | |
3805 | int const nbuffers{3}; |
3806 | |
3807 | - mc::BufferQueue q{nbuffers, allocator, basic_properties, policy_factory}; |
3808 | - q.allow_framedropping(true); |
3809 | + std::shared_ptr<mc::BufferQueue> q; |
3810 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3811 | + ASSERT_THAT(q, Ne(nullptr)); |
3812 | + q->allow_framedropping(true); |
3813 | |
3814 | - std::vector<std::shared_ptr<mg::Buffer>> buffers; |
3815 | + std::vector<mc::BufferHandle> buffer_handles; |
3816 | |
3817 | /* The client can never own this acquired buffer */ |
3818 | - auto comp_buffer = q.compositor_acquire(this); |
3819 | - buffers.push_back(comp_buffer); |
3820 | + auto comp_buffer_handle = q->compositor_acquire(this); |
3821 | + auto id_from_comp = comp_buffer_handle.buffer()->id(); |
3822 | + buffer_handles.push_back(std::move(comp_buffer_handle)); |
3823 | |
3824 | /* Let client release all possible buffers so they go into |
3825 | * the ready queue |
3826 | */ |
3827 | for (int i = 0; i < nbuffers; ++i) |
3828 | { |
3829 | - auto handle = client_acquire_async(q); |
3830 | + auto handle = client_acquire_async(*q); |
3831 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3832 | /* Check the client never got the compositor buffer acquired above */ |
3833 | - ASSERT_THAT(handle->id(), Ne(comp_buffer->id())); |
3834 | + ASSERT_THAT(handle->id(), Ne(id_from_comp)); |
3835 | handle->release_buffer(); |
3836 | } |
3837 | |
3838 | /* Let the compositor acquire all ready buffers */ |
3839 | for (int i = 0; i < nbuffers; ++i) |
3840 | - { |
3841 | - buffers.push_back(q.compositor_acquire(this)); |
3842 | - } |
3843 | + buffer_handles.push_back(q->compositor_acquire(this)); |
3844 | |
3845 | /* At this point the queue has 0 free buffers and 0 ready buffers |
3846 | * so the next client request should not be satisfied until |
3847 | * a compositor releases its buffers */ |
3848 | - auto handle = client_acquire_async(q); |
3849 | + auto handle = client_acquire_async(*q); |
3850 | /* ... unless the BufferQueue is overallocating. In that case it will |
3851 | * have succeeding in acquiring immediately. |
3852 | */ |
3853 | if (!handle->has_acquired_buffer()) |
3854 | { |
3855 | /* Release compositor buffers so that the client can get one */ |
3856 | - for (auto const& buffer : buffers) |
3857 | - { |
3858 | - q.compositor_release(buffer); |
3859 | - } |
3860 | + for (auto& buf_handle : buffer_handles) |
3861 | + buf_handle = std::move(mc::BufferHandle(nullptr, nullptr)); |
3862 | + |
3863 | EXPECT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3864 | } |
3865 | } |
3866 | @@ -1458,7 +1467,9 @@ |
3867 | |
3868 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3869 | { |
3870 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3871 | + std::shared_ptr<mc::BufferQueue> q; |
3872 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3873 | + ASSERT_THAT(q, Ne(nullptr)); |
3874 | |
3875 | std::mutex client_buffer_guard; |
3876 | std::condition_variable client_buffer_cv; |
3877 | @@ -1470,7 +1481,7 @@ |
3878 | { |
3879 | while (!done) |
3880 | { |
3881 | - auto buffer = q.compositor_acquire(this); |
3882 | + auto buffer_handle = q->compositor_acquire(this); |
3883 | |
3884 | { |
3885 | std::unique_lock<std::mutex> lock(client_buffer_guard); |
3886 | @@ -1480,18 +1491,17 @@ |
3887 | time_for_client_to_acquire, |
3888 | [&]()->bool{ return client_buffer; })) |
3889 | { |
3890 | - ASSERT_THAT(buffer->id(), Ne(client_buffer->id())); |
3891 | + ASSERT_THAT(buffer_handle.buffer()->id(), Ne(client_buffer->id())); |
3892 | } |
3893 | } |
3894 | |
3895 | std::this_thread::yield(); |
3896 | - q.compositor_release(buffer); |
3897 | } |
3898 | }); |
3899 | |
3900 | for (int i = 0; i < 1000; ++i) |
3901 | { |
3902 | - auto handle = client_acquire_async(q); |
3903 | + auto handle = client_acquire_async(*q); |
3904 | handle->wait_for(std::chrono::seconds(1)); |
3905 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3906 | |
3907 | @@ -1514,30 +1524,35 @@ |
3908 | { |
3909 | for (int nbuffers = 2; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3910 | { |
3911 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3912 | + std::shared_ptr<mc::BufferQueue> q; |
3913 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3914 | + ASSERT_THAT(q, Ne(nullptr)); |
3915 | + |
3916 | for (int i = 0; i < 100; ++i) |
3917 | { |
3918 | - auto handle = client_acquire_async(q); |
3919 | + auto handle = client_acquire_async(*q); |
3920 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3921 | |
3922 | auto client_id = handle->id(); |
3923 | - std::vector<std::shared_ptr<mg::Buffer>> buffers; |
3924 | + std::vector<mc::BufferHandle*> buffer_handles; |
3925 | for (int j = 0; j < nbuffers; j++) |
3926 | { |
3927 | - auto buffer = q.compositor_acquire(this); |
3928 | - ASSERT_THAT(client_id, Ne(buffer->id())); |
3929 | - buffers.push_back(buffer); |
3930 | + auto buffer_handle_ptr = new mc::BufferHandle(nullptr, nullptr); |
3931 | + *buffer_handle_ptr = q->compositor_acquire(this); |
3932 | + ASSERT_THAT(client_id, Ne(buffer_handle_ptr->buffer()->id())); |
3933 | + buffer_handles.push_back(buffer_handle_ptr); |
3934 | } |
3935 | |
3936 | - for (auto const& buffer: buffers) |
3937 | - q.compositor_release(buffer); |
3938 | + for (auto& buf_handle: buffer_handles) |
3939 | + delete buf_handle; |
3940 | |
3941 | handle->release_buffer(); |
3942 | |
3943 | - /* Flush out one ready buffer */ |
3944 | - auto buffer = q.compositor_acquire(this); |
3945 | - ASSERT_THAT(client_id, Eq(buffer->id())); |
3946 | - q.compositor_release(buffer); |
3947 | + { |
3948 | + /* Flush out one ready buffer */ |
3949 | + auto buffer_handle = q->compositor_acquire(this); |
3950 | + ASSERT_THAT(client_id, Eq(buffer_handle.buffer()->id())); |
3951 | + } |
3952 | } |
3953 | } |
3954 | } |
3955 | @@ -1550,36 +1565,36 @@ |
3956 | { |
3957 | for (int nbuffers = 3; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
3958 | { |
3959 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
3960 | + std::shared_ptr<mc::BufferQueue> q; |
3961 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
3962 | + ASSERT_THAT(q, Ne(nullptr)); |
3963 | |
3964 | void const* main_compositor = reinterpret_cast<void const*>(0); |
3965 | void const* second_compositor = reinterpret_cast<void const*>(1); |
3966 | |
3967 | - /* Hold a reference to current compositor buffer*/ |
3968 | - auto comp_buffer1 = q.compositor_acquire(main_compositor); |
3969 | + auto comp_buffer1 = new mc::BufferHandle(nullptr, nullptr); |
3970 | + *comp_buffer1 = q->compositor_acquire(main_compositor); |
3971 | |
3972 | - int const prefill = q.buffers_free_for_client(); |
3973 | + int const prefill = q->buffers_free_for_client(); |
3974 | ASSERT_THAT(prefill, Gt(0)); |
3975 | for (int acquires = 0; acquires < prefill; ++acquires) |
3976 | { |
3977 | - auto handle = client_acquire_async(q); |
3978 | + auto handle = client_acquire_async(*q); |
3979 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
3980 | handle->release_buffer(); |
3981 | } |
3982 | |
3983 | /* Have a second compositor advance the current compositor buffer at least twice */ |
3984 | for (int acquires = 0; acquires < nbuffers; ++acquires) |
3985 | - { |
3986 | - auto comp_buffer = q.compositor_acquire(second_compositor); |
3987 | - q.compositor_release(comp_buffer); |
3988 | - } |
3989 | - q.compositor_release(comp_buffer1); |
3990 | + q->compositor_acquire(second_compositor); |
3991 | + |
3992 | + delete comp_buffer1; |
3993 | |
3994 | /* An async client should still be able to cycle through all the available buffers */ |
3995 | std::atomic<bool> done(false); |
3996 | auto unblock = [&done] { done = true; }; |
3997 | mt::AutoUnblockThread compositor(unblock, |
3998 | - compositor_thread, std::ref(q), std::ref(done)); |
3999 | + compositor_thread, std::ref(*q), std::ref(done)); |
4000 | |
4001 | std::unordered_set<mg::Buffer *> unique_buffers_acquired; |
4002 | int const max_ownable_buffers = nbuffers - 1; |
4003 | @@ -1588,7 +1603,7 @@ |
4004 | std::vector<mg::Buffer *> client_buffers; |
4005 | for (int acquires = 0; acquires < max_ownable_buffers; ++acquires) |
4006 | { |
4007 | - auto handle = client_acquire_async(q); |
4008 | + auto handle = client_acquire_async(*q); |
4009 | handle->wait_for(std::chrono::seconds(1)); |
4010 | ASSERT_THAT(handle->has_acquired_buffer(), Eq(true)); |
4011 | unique_buffers_acquired.insert(handle->buffer()); |
4012 | @@ -1597,7 +1612,7 @@ |
4013 | |
4014 | for (auto const& buffer : client_buffers) |
4015 | { |
4016 | - q.client_release(buffer); |
4017 | + q->client_release(buffer); |
4018 | } |
4019 | } |
4020 | |
4021 | @@ -1666,54 +1681,63 @@ |
4022 | q.client_release(client_acquire_sync(q)); |
4023 | }}; |
4024 | |
4025 | - auto b = q.compositor_acquire(this); |
4026 | - q.compositor_release(b); |
4027 | + q.compositor_acquire(this); |
4028 | } |
4029 | |
4030 | TEST_F(BufferQueueTest, first_user_is_recorded) |
4031 | { |
4032 | for (int nbuffers = 1; nbuffers <= max_nbuffers_to_test; ++nbuffers) |
4033 | { |
4034 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
4035 | + std::shared_ptr<mc::BufferQueue> q; |
4036 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
4037 | + ASSERT_THAT(q, Ne(nullptr)); |
4038 | |
4039 | - auto comp = q.compositor_acquire(this); |
4040 | - EXPECT_TRUE(q.is_a_current_buffer_user(this)); |
4041 | - q.compositor_release(comp); |
4042 | + { |
4043 | + auto comp = q->compositor_acquire(this); |
4044 | + EXPECT_TRUE(q->is_a_current_buffer_user(this)); |
4045 | + } |
4046 | } |
4047 | } |
4048 | |
4049 | TEST_F(BufferQueueTest, gives_compositor_a_valid_buffer_after_dropping_old_buffers_without_clients) |
4050 | { |
4051 | int const nbuffers = 3; |
4052 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
4053 | - |
4054 | - q.drop_old_buffers(); |
4055 | - |
4056 | - auto comp = q.compositor_acquire(this); |
4057 | - ASSERT_THAT(comp, Ne(nullptr)); |
4058 | + std::shared_ptr<mc::BufferQueue> q; |
4059 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
4060 | + ASSERT_THAT(q, Ne(nullptr)); |
4061 | + |
4062 | + q->drop_old_buffers(); |
4063 | + |
4064 | + auto comp = q->compositor_acquire(this); |
4065 | + ASSERT_THAT(comp.buffer(), Ne(nullptr)); |
4066 | } |
4067 | |
4068 | TEST_F(BufferQueueTest, gives_compositor_the_newest_buffer_after_dropping_old_buffers) |
4069 | { |
4070 | int const nbuffers = 3; |
4071 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
4072 | + std::shared_ptr<mc::BufferQueue> q; |
4073 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
4074 | + ASSERT_THAT(q, Ne(nullptr)); |
4075 | |
4076 | - auto handle1 = client_acquire_async(q); |
4077 | + auto handle1 = client_acquire_async(*q); |
4078 | ASSERT_THAT(handle1->has_acquired_buffer(), Eq(true)); |
4079 | handle1->release_buffer(); |
4080 | |
4081 | - auto handle2 = client_acquire_async(q); |
4082 | + auto handle2 = client_acquire_async(*q); |
4083 | ASSERT_THAT(handle2->has_acquired_buffer(), Eq(true)); |
4084 | handle2->release_buffer(); |
4085 | |
4086 | - q.drop_old_buffers(); |
4087 | - |
4088 | - auto comp = q.compositor_acquire(this); |
4089 | - ASSERT_THAT(comp->id(), Eq(handle2->id())); |
4090 | - q.compositor_release(comp); |
4091 | - |
4092 | - comp = q.compositor_acquire(this); |
4093 | - ASSERT_THAT(comp->id(), Eq(handle2->id())); |
4094 | + q->drop_old_buffers(); |
4095 | + |
4096 | + { |
4097 | + auto buffer_handle = q->compositor_acquire(this); |
4098 | + ASSERT_THAT(buffer_handle.buffer()->id(), Eq(handle2->id())); |
4099 | + } |
4100 | + |
4101 | + { |
4102 | + auto buffer_handle = q->compositor_acquire(this); |
4103 | + ASSERT_THAT(buffer_handle.buffer()->id(), Eq(handle2->id())); |
4104 | + } |
4105 | } |
4106 | |
4107 | TEST_F(BufferQueueTest, gives_new_compositor_the_newest_buffer_after_dropping_old_buffers) |
4108 | @@ -1721,22 +1745,25 @@ |
4109 | int const nbuffers = 3; |
4110 | void const* const new_compositor_id{&nbuffers}; |
4111 | |
4112 | - mc::BufferQueue q(nbuffers, allocator, basic_properties, policy_factory); |
4113 | + std::shared_ptr<mc::BufferQueue> q; |
4114 | + ASSERT_NO_THROW(q = std::make_shared<mc::BufferQueue>(nbuffers, allocator, basic_properties, policy_factory)); |
4115 | + ASSERT_THAT(q, Ne(nullptr)); |
4116 | |
4117 | - auto handle1 = client_acquire_async(q); |
4118 | + auto handle1 = client_acquire_async(*q); |
4119 | ASSERT_THAT(handle1->has_acquired_buffer(), Eq(true)); |
4120 | handle1->release_buffer(); |
4121 | |
4122 | - auto comp = q.compositor_acquire(this); |
4123 | - ASSERT_THAT(comp->id(), Eq(handle1->id())); |
4124 | - q.compositor_release(comp); |
4125 | + { |
4126 | + auto buffer_handle = q->compositor_acquire(this); |
4127 | + ASSERT_THAT(buffer_handle.buffer()->id(), Eq(handle1->id())); |
4128 | + } |
4129 | |
4130 | - auto handle2 = client_acquire_async(q); |
4131 | + auto handle2 = client_acquire_async(*q); |
4132 | ASSERT_THAT(handle2->has_acquired_buffer(), Eq(true)); |
4133 | handle2->release_buffer(); |
4134 | |
4135 | - q.drop_old_buffers(); |
4136 | + q->drop_old_buffers(); |
4137 | |
4138 | - auto comp2 = q.compositor_acquire(new_compositor_id); |
4139 | - ASSERT_THAT(comp2->id(), Eq(handle2->id())); |
4140 | + auto buffer_handle2 = q->compositor_acquire(new_compositor_id); |
4141 | + ASSERT_THAT(buffer_handle2.buffer()->id(), Eq(handle2->id())); |
4142 | } |
4143 | |
4144 | === removed file 'tests/unit-tests/compositor/test_buffer_stream.cpp' |
4145 | --- tests/unit-tests/compositor/test_buffer_stream.cpp 2015-01-21 07:34:50 +0000 |
4146 | +++ tests/unit-tests/compositor/test_buffer_stream.cpp 1970-01-01 00:00:00 +0000 |
4147 | @@ -1,194 +0,0 @@ |
4148 | -/* |
4149 | - * Copyright © 2012 Canonical Ltd. |
4150 | - * |
4151 | - * This program is free software: you can redistribute it and/or modify |
4152 | - * it under the terms of the GNU General Public License version 3 as |
4153 | - * published by the Free Software Foundation. |
4154 | - * |
4155 | - * This program is distributed in the hope that it will be useful, |
4156 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4157 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4158 | - * GNU General Public License for more details. |
4159 | - * |
4160 | - * You should have received a copy of the GNU General Public License |
4161 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4162 | - * |
4163 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4164 | - */ |
4165 | - |
4166 | -#include "src/server/compositor/buffer_stream_surfaces.h" |
4167 | - |
4168 | -#include "mir_test_doubles/stub_buffer.h" |
4169 | -#include "mir_test_doubles/mock_buffer_bundle.h" |
4170 | -#include "mir_test/gmock_fixes.h" |
4171 | - |
4172 | -#include <gmock/gmock.h> |
4173 | -#include <gtest/gtest.h> |
4174 | - |
4175 | -#include <condition_variable> |
4176 | - |
4177 | -namespace mc = mir::compositor; |
4178 | -namespace mg = mir::graphics; |
4179 | -namespace geom = mir::geometry; |
4180 | -namespace mtd = mir::test::doubles; |
4181 | - |
4182 | -class BufferStreamTest : public ::testing::Test |
4183 | -{ |
4184 | -protected: |
4185 | - BufferStreamTest() |
4186 | - { |
4187 | - mock_buffer = std::make_shared<mtd::StubBuffer>(); |
4188 | - mock_bundle = std::make_shared<mtd::MockBufferBundle>(); |
4189 | - |
4190 | - // Two of the tests care about this, the rest should not... |
4191 | - EXPECT_CALL(*mock_bundle, force_requests_to_complete()) |
4192 | - .Times(::testing::AnyNumber()); |
4193 | - } |
4194 | - |
4195 | - std::shared_ptr<mtd::StubBuffer> mock_buffer; |
4196 | - std::shared_ptr<mtd::MockBufferBundle> mock_bundle; |
4197 | -}; |
4198 | - |
4199 | -TEST_F(BufferStreamTest, size_query) |
4200 | -{ |
4201 | - geom::Size size{4, 5}; |
4202 | - mg::BufferProperties properties {size, mir_pixel_format_abgr_8888, mg::BufferUsage::hardware}; |
4203 | - EXPECT_CALL(*mock_bundle, properties()) |
4204 | - .Times(1) |
4205 | - .WillOnce(testing::Return(properties)); |
4206 | - |
4207 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4208 | - auto returned_size = buffer_stream.stream_size(); |
4209 | - EXPECT_EQ(size, returned_size); |
4210 | -} |
4211 | - |
4212 | -TEST_F(BufferStreamTest, pixel_format_query) |
4213 | -{ |
4214 | - MirPixelFormat format{mir_pixel_format_abgr_8888}; |
4215 | - mg::BufferProperties properties {geom::Size{4, 5}, format, mg::BufferUsage::hardware}; |
4216 | - EXPECT_CALL(*mock_bundle, properties()) |
4217 | - .Times(1) |
4218 | - .WillOnce(testing::Return(properties)); |
4219 | - |
4220 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4221 | - auto returned_pf = buffer_stream.get_stream_pixel_format(); |
4222 | - EXPECT_EQ(format, returned_pf); |
4223 | -} |
4224 | - |
4225 | -TEST_F(BufferStreamTest, force_requests_to_complete) |
4226 | -{ |
4227 | - EXPECT_CALL(*mock_bundle, force_requests_to_complete()) |
4228 | - .Times(2); // Once explcit, once on destruction |
4229 | - |
4230 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4231 | - buffer_stream.force_requests_to_complete(); |
4232 | -} |
4233 | - |
4234 | -TEST_F(BufferStreamTest, requests_are_completed_before_destruction) |
4235 | -{ |
4236 | - EXPECT_CALL(*mock_bundle, force_requests_to_complete()) |
4237 | - .Times(1); |
4238 | - |
4239 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4240 | -} |
4241 | - |
4242 | -TEST_F(BufferStreamTest, get_buffer_for_compositor_handles_resources) |
4243 | -{ |
4244 | - using namespace testing; |
4245 | - |
4246 | - EXPECT_CALL(*mock_bundle, compositor_acquire(_)) |
4247 | - .Times(1) |
4248 | - .WillOnce(Return(mock_buffer)); |
4249 | - EXPECT_CALL(*mock_bundle, compositor_release(_)) |
4250 | - .Times(1); |
4251 | - |
4252 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4253 | - |
4254 | - buffer_stream.lock_compositor_buffer(0); |
4255 | -} |
4256 | - |
4257 | -TEST_F(BufferStreamTest, get_buffer_for_compositor_can_lock) |
4258 | -{ |
4259 | - using namespace testing; |
4260 | - |
4261 | - EXPECT_CALL(*mock_bundle, compositor_acquire(_)) |
4262 | - .Times(1) |
4263 | - .WillOnce(Return(mock_buffer)); |
4264 | - EXPECT_CALL(*mock_bundle, compositor_release(_)) |
4265 | - .Times(1); |
4266 | - |
4267 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4268 | - |
4269 | - buffer_stream.lock_compositor_buffer(0); |
4270 | -} |
4271 | - |
4272 | -TEST_F(BufferStreamTest, get_buffer_for_client_releases_resources) |
4273 | -{ |
4274 | - std::mutex mutex; |
4275 | - std::condition_variable cv; |
4276 | - mg::Buffer* buffer{nullptr}; |
4277 | - bool done = false; |
4278 | - |
4279 | - auto const callback = |
4280 | - [&](mg::Buffer* new_buffer) |
4281 | - { |
4282 | - std::unique_lock<decltype(mutex)> lock(mutex); |
4283 | - buffer = new_buffer; |
4284 | - done = true; |
4285 | - cv.notify_one(); |
4286 | - }; |
4287 | - |
4288 | - using namespace testing; |
4289 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4290 | - |
4291 | - InSequence seq; |
4292 | - EXPECT_CALL(*mock_bundle, client_acquire(_)) |
4293 | - .Times(1) |
4294 | - .WillOnce(InvokeArgument<0>(mock_buffer.get())); |
4295 | - EXPECT_CALL(*mock_bundle, client_release(_)) |
4296 | - .Times(1); |
4297 | - EXPECT_CALL(*mock_bundle, client_acquire(_)) |
4298 | - .Times(1) |
4299 | - .WillOnce(InvokeArgument<0>(mock_buffer.get())); |
4300 | - |
4301 | - buffer_stream.acquire_client_buffer(callback); |
4302 | - |
4303 | - { |
4304 | - std::unique_lock<decltype(mutex)> lock(mutex); |
4305 | - |
4306 | - cv.wait(lock, [&]{ return done; }); |
4307 | - } |
4308 | - |
4309 | - done = false; |
4310 | - |
4311 | - if (buffer) |
4312 | - buffer_stream.release_client_buffer(buffer); |
4313 | - buffer_stream.acquire_client_buffer(callback); |
4314 | - |
4315 | - { |
4316 | - std::unique_lock<decltype(mutex)> lock(mutex); |
4317 | - |
4318 | - cv.wait(lock, [&]{ return done; }); |
4319 | - } |
4320 | -} |
4321 | - |
4322 | -TEST_F(BufferStreamTest, allow_framedropping_device) |
4323 | -{ |
4324 | - EXPECT_CALL(*mock_bundle, allow_framedropping(true)) |
4325 | - .Times(1); |
4326 | - |
4327 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4328 | - buffer_stream.allow_framedropping(true); |
4329 | -} |
4330 | - |
4331 | -TEST_F(BufferStreamTest, resizes_bundle) |
4332 | -{ |
4333 | - geom::Size const new_size{66, 77}; |
4334 | - |
4335 | - EXPECT_CALL(*mock_bundle, resize(new_size)) |
4336 | - .Times(1); |
4337 | - |
4338 | - mc::BufferStreamSurfaces buffer_stream(mock_bundle); |
4339 | - buffer_stream.resize(new_size); |
4340 | -} |
4341 | - |
4342 | |
4343 | === modified file 'tests/unit-tests/compositor/test_gl_renderer.cpp' |
4344 | --- tests/unit-tests/compositor/test_gl_renderer.cpp 2015-01-22 09:00:14 +0000 |
4345 | +++ tests/unit-tests/compositor/test_gl_renderer.cpp 2015-03-20 19:31:52 +0000 |
4346 | @@ -28,8 +28,7 @@ |
4347 | #include <mir_test/fake_shared.h> |
4348 | #include <mir_test_doubles/mock_buffer.h> |
4349 | #include <mir_test_doubles/mock_renderable.h> |
4350 | -#include <mir_test_doubles/mock_buffer_stream.h> |
4351 | -#include <mir/compositor/buffer_stream.h> |
4352 | +#include <mir_test_doubles/mock_buffer_bundle.h> |
4353 | #include <mir_test_doubles/mock_gl.h> |
4354 | |
4355 | using testing::SetArgPointee; |
4356 | |
4357 | === removed file 'tests/unit-tests/compositor/test_temporary_buffers.cpp' |
4358 | --- tests/unit-tests/compositor/test_temporary_buffers.cpp 2015-01-21 07:34:50 +0000 |
4359 | +++ tests/unit-tests/compositor/test_temporary_buffers.cpp 1970-01-01 00:00:00 +0000 |
4360 | @@ -1,149 +0,0 @@ |
4361 | -/* |
4362 | - * Copyright © 2012 Canonical Ltd. |
4363 | - * |
4364 | - * This program is free software: you can redistribute it and/or modify |
4365 | - * it under the terms of the GNU General Public License version 3 as |
4366 | - * published by the Free Software Foundation. |
4367 | - * |
4368 | - * This program is distributed in the hope that it will be useful, |
4369 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4370 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4371 | - * GNU General Public License for more details. |
4372 | - * |
4373 | - * You should have received a copy of the GNU General Public License |
4374 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4375 | - * |
4376 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4377 | - */ |
4378 | - |
4379 | -#include "src/server/compositor/temporary_buffers.h" |
4380 | -#include "mir_test_doubles/mock_buffer.h" |
4381 | -#include "mir_test_doubles/stub_buffer.h" |
4382 | -#include "mir_test_doubles/mock_buffer_bundle.h" |
4383 | -#include <gtest/gtest.h> |
4384 | -#include <stdexcept> |
4385 | - |
4386 | -namespace mtd=mir::test::doubles; |
4387 | -namespace mg = mir::graphics; |
4388 | -namespace mc=mir::compositor; |
4389 | -namespace geom=mir::geometry; |
4390 | - |
4391 | -namespace |
4392 | -{ |
4393 | -class TemporaryTestBuffer : public mc::TemporaryBuffer |
4394 | -{ |
4395 | -public: |
4396 | - TemporaryTestBuffer(const std::shared_ptr<mg::Buffer>& buf) |
4397 | - : TemporaryBuffer(buf) |
4398 | - { |
4399 | - } |
4400 | -}; |
4401 | - |
4402 | -class TemporaryBuffersTest : public ::testing::Test |
4403 | -{ |
4404 | -public: |
4405 | - TemporaryBuffersTest() |
4406 | - : buffer_size{1024, 768}, |
4407 | - buffer_stride{1024}, |
4408 | - buffer_pixel_format{mir_pixel_format_abgr_8888}, |
4409 | - mock_buffer{std::make_shared<testing::NiceMock<mtd::MockBuffer>>( |
4410 | - buffer_size, buffer_stride, buffer_pixel_format)}, |
4411 | - mock_bundle{std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>()} |
4412 | - { |
4413 | - using namespace testing; |
4414 | - |
4415 | - ON_CALL(*mock_bundle, client_acquire(_)) |
4416 | - .WillByDefault(InvokeArgument<0>(mock_buffer.get())); |
4417 | - ON_CALL(*mock_bundle, compositor_acquire(_)) |
4418 | - .WillByDefault(Return(mock_buffer)); |
4419 | - } |
4420 | - |
4421 | - geom::Size const buffer_size; |
4422 | - geom::Stride const buffer_stride; |
4423 | - MirPixelFormat const buffer_pixel_format; |
4424 | - std::shared_ptr<mtd::MockBuffer> const mock_buffer; |
4425 | - std::shared_ptr<mtd::MockBufferBundle> mock_bundle; |
4426 | -}; |
4427 | -} |
4428 | - |
4429 | -TEST_F(TemporaryBuffersTest, compositor_buffer_acquires_and_releases) |
4430 | -{ |
4431 | - using namespace testing; |
4432 | - EXPECT_CALL(*mock_bundle, compositor_acquire(_)) |
4433 | - .WillOnce(Return(mock_buffer)); |
4434 | - EXPECT_CALL(*mock_bundle, compositor_release(_)) |
4435 | - .Times(1); |
4436 | - |
4437 | - mc::TemporaryCompositorBuffer proxy_buffer(mock_bundle, 0); |
4438 | -} |
4439 | - |
4440 | -TEST_F(TemporaryBuffersTest, snapshot_buffer_acquires_and_releases) |
4441 | -{ |
4442 | - using namespace testing; |
4443 | - EXPECT_CALL(*mock_bundle, snapshot_acquire()) |
4444 | - .WillOnce(Return(mock_buffer)); |
4445 | - EXPECT_CALL(*mock_bundle, snapshot_release(_)) |
4446 | - .Times(1); |
4447 | - |
4448 | - mc::TemporarySnapshotBuffer proxy_buffer(mock_bundle); |
4449 | -} |
4450 | - |
4451 | -TEST_F(TemporaryBuffersTest, base_test_size) |
4452 | -{ |
4453 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4454 | - EXPECT_CALL(*mock_buffer, size()) |
4455 | - .Times(1); |
4456 | - |
4457 | - geom::Size size; |
4458 | - size = proxy_buffer.size(); |
4459 | - EXPECT_EQ(buffer_size, size); |
4460 | -} |
4461 | - |
4462 | -TEST_F(TemporaryBuffersTest, base_test_stride) |
4463 | -{ |
4464 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4465 | - EXPECT_CALL(*mock_buffer, stride()) |
4466 | - .Times(1); |
4467 | - |
4468 | - geom::Stride stride; |
4469 | - stride = proxy_buffer.stride(); |
4470 | - EXPECT_EQ(buffer_stride, stride); |
4471 | -} |
4472 | - |
4473 | -TEST_F(TemporaryBuffersTest, base_test_pixel_format) |
4474 | -{ |
4475 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4476 | - EXPECT_CALL(*mock_buffer, pixel_format()) |
4477 | - .Times(1); |
4478 | - |
4479 | - MirPixelFormat pixel_format; |
4480 | - pixel_format = proxy_buffer.pixel_format(); |
4481 | - EXPECT_EQ(buffer_pixel_format, pixel_format); |
4482 | -} |
4483 | - |
4484 | -TEST_F(TemporaryBuffersTest, base_gl_bind_to_texture) |
4485 | -{ |
4486 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4487 | - EXPECT_CALL(*mock_buffer, gl_bind_to_texture()) |
4488 | - .Times(1); |
4489 | - |
4490 | - proxy_buffer.gl_bind_to_texture(); |
4491 | -} |
4492 | - |
4493 | -TEST_F(TemporaryBuffersTest, base_test_id) |
4494 | -{ |
4495 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4496 | - EXPECT_CALL(*mock_buffer, id()) |
4497 | - .Times(1); |
4498 | - |
4499 | - proxy_buffer.id(); |
4500 | -} |
4501 | - |
4502 | -TEST_F(TemporaryBuffersTest, base_test_native_buffer_handle) |
4503 | -{ |
4504 | - TemporaryTestBuffer proxy_buffer(mock_buffer); |
4505 | - EXPECT_CALL(*mock_buffer, native_buffer_handle()) |
4506 | - .Times(1); |
4507 | - |
4508 | - proxy_buffer.native_buffer_handle(); |
4509 | -} |
4510 | |
4511 | === modified file 'tests/unit-tests/examples/test_demo_compositor.cpp' |
4512 | --- tests/unit-tests/examples/test_demo_compositor.cpp 2015-03-06 03:52:41 +0000 |
4513 | +++ tests/unit-tests/examples/test_demo_compositor.cpp 2015-03-20 19:31:52 +0000 |
4514 | @@ -27,7 +27,7 @@ |
4515 | |
4516 | #include "mir_test_doubles/mock_gl.h" |
4517 | #include "mir_test_doubles/stub_display_buffer.h" |
4518 | -#include "mir_test_doubles/stub_buffer_stream.h" |
4519 | +#include "mir_test_doubles/stub_buffer_bundle.h" |
4520 | #include "mir_test_doubles/stub_renderable.h" |
4521 | #include "mir_test/fake_shared.h" |
4522 | |
4523 | @@ -61,7 +61,7 @@ |
4524 | std::string("stub"), |
4525 | geom::Rectangle{{0,0},{100,100}}, |
4526 | false, |
4527 | - std::make_shared<mtd::StubBufferStream>(), |
4528 | + std::make_shared<mtd::StubBufferBundle>(), |
4529 | std::shared_ptr<mir::input::InputChannel>(), |
4530 | std::shared_ptr<mir::input::InputSender>(), |
4531 | std::shared_ptr<mir::graphics::CursorImage>(), |
4532 | |
4533 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
4534 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2015-03-06 03:52:41 +0000 |
4535 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2015-03-20 19:31:52 +0000 |
4536 | @@ -16,7 +16,6 @@ |
4537 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
4538 | */ |
4539 | |
4540 | -#include "mir/compositor/buffer_stream.h" |
4541 | #include "src/server/frontend/session_mediator.h" |
4542 | #include "src/server/report/null_report_factory.h" |
4543 | #include "src/server/frontend/resource_cache.h" |
4544 | |
4545 | === modified file 'tests/unit-tests/graphics/test_program_factory.cpp' |
4546 | --- tests/unit-tests/graphics/test_program_factory.cpp 2015-01-21 07:34:50 +0000 |
4547 | +++ tests/unit-tests/graphics/test_program_factory.cpp 2015-03-20 19:31:52 +0000 |
4548 | @@ -29,8 +29,7 @@ |
4549 | #include <mir_test/fake_shared.h> |
4550 | #include <mir_test_doubles/mock_buffer.h> |
4551 | #include <mir_test_doubles/mock_renderable.h> |
4552 | -#include <mir_test_doubles/mock_buffer_stream.h> |
4553 | -#include <mir/compositor/buffer_stream.h> |
4554 | +#include <mir_test_doubles/mock_buffer_bundle.h> |
4555 | #include <mir_test_doubles/mock_gl.h> |
4556 | |
4557 | using testing::SetArgPointee; |
4558 | |
4559 | === modified file 'tests/unit-tests/scene/test_basic_surface.cpp' |
4560 | --- tests/unit-tests/scene/test_basic_surface.cpp 2015-03-06 03:52:41 +0000 |
4561 | +++ tests/unit-tests/scene/test_basic_surface.cpp 2015-03-20 19:31:52 +0000 |
4562 | @@ -27,7 +27,7 @@ |
4563 | #include "mir/scene/null_surface_observer.h" |
4564 | #include "mir/events/event_builders.h" |
4565 | |
4566 | -#include "mir_test_doubles/mock_buffer_stream.h" |
4567 | +#include "mir_test_doubles/mock_buffer_bundle.h" |
4568 | #include "mir_test_doubles/mock_input_sender.h" |
4569 | #include "mir_test_doubles/stub_input_sender.h" |
4570 | #include "mir_test_doubles/stub_buffer.h" |
4571 | @@ -92,8 +92,8 @@ |
4572 | testing::NiceMock<MockCallback> mock_callback; |
4573 | std::function<void()> null_change_cb{[]{}}; |
4574 | std::function<void()> mock_change_cb{std::bind(&MockCallback::call, &mock_callback)}; |
4575 | - std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = |
4576 | - std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); |
4577 | + std::shared_ptr<testing::NiceMock<mtd::MockBufferBundle>> mock_buffer_bundle = |
4578 | + std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>(); |
4579 | std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report(); |
4580 | void const* compositor_id{nullptr}; |
4581 | std::shared_ptr<ms::LegacySurfaceChangeNotification> observer = |
4582 | @@ -105,7 +105,7 @@ |
4583 | name, |
4584 | rect, |
4585 | false, |
4586 | - mock_buffer_stream, |
4587 | + mock_buffer_bundle, |
4588 | std::shared_ptr<mi::InputChannel>(), |
4589 | stub_input_sender, |
4590 | std::shared_ptr<mg::CursorImage>(), |
4591 | @@ -135,7 +135,7 @@ |
4592 | for (int i = 0; i < N; ++i) |
4593 | { |
4594 | surfaces[i].reset(new ms::BasicSurface( |
4595 | - name, rect, false, mock_buffer_stream, |
4596 | + name, rect, false, mock_buffer_bundle, |
4597 | std::shared_ptr<mi::InputChannel>(), stub_input_sender, |
4598 | std::shared_ptr<mg::CursorImage>(), report) |
4599 | ); |
4600 | @@ -155,7 +155,7 @@ |
4601 | for (int i = 0; i < N; ++i) |
4602 | { |
4603 | surfaces[i].reset(new ms::BasicSurface( |
4604 | - name, rect, false, mock_buffer_stream, |
4605 | + name, rect, false, mock_buffer_bundle, |
4606 | std::shared_ptr<mi::InputChannel>(), stub_input_sender, |
4607 | std::shared_ptr<mg::CursorImage>(), report) |
4608 | ); |
4609 | @@ -260,7 +260,7 @@ |
4610 | { |
4611 | using namespace testing; |
4612 | mtd::StubBuffer mock_buffer; |
4613 | - EXPECT_CALL(*mock_buffer_stream, acquire_client_buffer(_)).Times(2) |
4614 | + EXPECT_CALL(*mock_buffer_bundle, client_acquire(_)).Times(2) |
4615 | .WillRepeatedly(InvokeArgument<0>(&mock_buffer)); |
4616 | |
4617 | mir::graphics::Buffer* buffer = nullptr; |
4618 | @@ -271,7 +271,7 @@ |
4619 | name, |
4620 | rect, |
4621 | false, |
4622 | - mock_buffer_stream, |
4623 | + mock_buffer_bundle, |
4624 | std::shared_ptr<mi::InputChannel>(), |
4625 | stub_input_sender, |
4626 | std::shared_ptr<mg::CursorImage>(), |
4627 | @@ -314,7 +314,7 @@ |
4628 | { |
4629 | using namespace testing; |
4630 | mtd::StubBuffer mock_buffer; |
4631 | - EXPECT_CALL(*mock_buffer_stream, acquire_client_buffer(_)).Times(2) |
4632 | + EXPECT_CALL(*mock_buffer_bundle, client_acquire(_)).Times(2) |
4633 | .WillRepeatedly(InvokeArgument<0>(&mock_buffer)); |
4634 | |
4635 | surface.add_observer(observer); |
4636 | @@ -338,7 +338,7 @@ |
4637 | name, |
4638 | geom::Rectangle{pt, one_by_one}, |
4639 | false, |
4640 | - mock_buffer_stream, |
4641 | + mock_buffer_bundle, |
4642 | std::shared_ptr<mi::InputChannel>(), |
4643 | stub_input_sender, |
4644 | std::shared_ptr<mg::CursorImage>(), |
4645 | @@ -376,7 +376,7 @@ |
4646 | name, |
4647 | geom::Rectangle{{0,0}, {100,100}}, |
4648 | false, |
4649 | - mock_buffer_stream, |
4650 | + mock_buffer_bundle, |
4651 | std::shared_ptr<mi::InputChannel>(), |
4652 | stub_input_sender, |
4653 | std::shared_ptr<mg::CursorImage>(), |
4654 | @@ -517,7 +517,7 @@ |
4655 | geom::Rectangle{{0,0}, {100,100}}, |
4656 | parent, |
4657 | false, |
4658 | - mock_buffer_stream, |
4659 | + mock_buffer_bundle, |
4660 | std::shared_ptr<mi::InputChannel>(), |
4661 | stub_input_sender, |
4662 | std::shared_ptr<mg::CursorImage>(), |
4663 | @@ -678,7 +678,7 @@ |
4664 | name, |
4665 | rect, |
4666 | false, |
4667 | - mock_buffer_stream, |
4668 | + mock_buffer_bundle, |
4669 | std::shared_ptr<mi::InputChannel>(), |
4670 | mt::fake_shared(mock_sender), |
4671 | nullptr, |
4672 | |
4673 | === modified file 'tests/unit-tests/scene/test_session_manager.cpp' |
4674 | --- tests/unit-tests/scene/test_session_manager.cpp 2015-03-06 03:52:41 +0000 |
4675 | +++ tests/unit-tests/scene/test_session_manager.cpp 2015-03-20 19:31:52 +0000 |
4676 | @@ -29,7 +29,7 @@ |
4677 | |
4678 | #include "mir_test_doubles/mock_surface_coordinator.h" |
4679 | #include "mir_test_doubles/mock_session_listener.h" |
4680 | -#include "mir_test_doubles/stub_buffer_stream.h" |
4681 | +#include "mir_test_doubles/stub_buffer_bundle.h" |
4682 | #include "mir_test_doubles/null_snapshot_strategy.h" |
4683 | #include "mir_test_doubles/null_session_event_sink.h" |
4684 | |
4685 | @@ -78,7 +78,7 @@ |
4686 | std::string("stub"), |
4687 | geom::Rectangle{{},{}}, |
4688 | false, |
4689 | - std::make_shared<mtd::StubBufferStream>(), |
4690 | + std::make_shared<mtd::StubBufferBundle>(), |
4691 | std::shared_ptr<mi::InputChannel>(), |
4692 | std::shared_ptr<mi::InputSender>(), |
4693 | std::shared_ptr<mg::CursorImage>(), |
4694 | |
4695 | === modified file 'tests/unit-tests/scene/test_surface.cpp' |
4696 | --- tests/unit-tests/scene/test_surface.cpp 2015-03-18 18:48:02 +0000 |
4697 | +++ tests/unit-tests/scene/test_surface.cpp 2015-03-20 19:31:52 +0000 |
4698 | @@ -27,7 +27,7 @@ |
4699 | #include "mir/scene/surface_event_source.h" |
4700 | #include "mir/input/input_channel.h" |
4701 | |
4702 | -#include "mir_test_doubles/mock_buffer_stream.h" |
4703 | +#include "mir_test_doubles/mock_buffer_bundle.h" |
4704 | #include "mir_test_doubles/mock_input_surface.h" |
4705 | #include "mir_test_doubles/stub_buffer.h" |
4706 | #include "mir_test_doubles/mock_input_sender.h" |
4707 | @@ -192,7 +192,7 @@ |
4708 | { |
4709 | SurfaceCreation() |
4710 | : surface(surface_name, |
4711 | - rect, false, mock_buffer_stream, |
4712 | + rect, false, mock_buffer_bundle, |
4713 | std::make_shared<mtd::StubInputChannel>(), |
4714 | std::make_shared<mtd::StubInputSender>(), |
4715 | nullptr /* cursor_image */, report) |
4716 | @@ -209,11 +209,11 @@ |
4717 | notification_count++; |
4718 | }; |
4719 | |
4720 | - ON_CALL(*mock_buffer_stream, acquire_client_buffer(_)) |
4721 | + ON_CALL(*mock_buffer_bundle, client_acquire(_)) |
4722 | .WillByDefault(InvokeArgument<0>(&stub_buffer)); |
4723 | } |
4724 | |
4725 | - std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); |
4726 | + std::shared_ptr<testing::NiceMock<mtd::MockBufferBundle>> mock_buffer_bundle = std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>(); |
4727 | std::function<void()> change_notification; |
4728 | int notification_count = 0; |
4729 | mtd::StubBuffer stub_buffer; |
4730 | @@ -229,13 +229,15 @@ |
4731 | |
4732 | } |
4733 | |
4734 | -TEST_F(SurfaceCreation, test_surface_queries_stream_for_pf) |
4735 | +TEST_F(SurfaceCreation, test_surface_queries_bundle_for_pf) |
4736 | { |
4737 | using namespace testing; |
4738 | |
4739 | - EXPECT_CALL(*mock_buffer_stream, get_stream_pixel_format()) |
4740 | + EXPECT_CALL(*mock_buffer_bundle, properties()) |
4741 | .Times(1) |
4742 | - .WillOnce(Return(pf)); |
4743 | + .WillOnce(Return(mg::BufferProperties(geom::Size{0, 0}, |
4744 | + pf, |
4745 | + mg::BufferUsage::undefined))); |
4746 | |
4747 | auto ret_pf = surface.pixel_format(); |
4748 | |
4749 | @@ -258,7 +260,7 @@ |
4750 | |
4751 | mtd::StubBuffer graphics_resource; |
4752 | |
4753 | - EXPECT_CALL(*mock_buffer_stream, acquire_client_buffer(_)) |
4754 | + EXPECT_CALL(*mock_buffer_bundle, client_acquire(_)) |
4755 | .Times(1) |
4756 | .WillOnce(InvokeArgument<0>(&graphics_resource)); |
4757 | |
4758 | @@ -267,13 +269,13 @@ |
4759 | [&graphics_resource](mg::Buffer* result){ EXPECT_THAT(result, Eq(&graphics_resource)); }); |
4760 | } |
4761 | |
4762 | -TEST_F(SurfaceCreation, test_surface_gets_ipc_from_stream) |
4763 | +TEST_F(SurfaceCreation, test_surface_gets_ipc_from_bundle) |
4764 | { |
4765 | using namespace testing; |
4766 | |
4767 | mtd::StubBuffer stub_buffer; |
4768 | |
4769 | - EXPECT_CALL(*mock_buffer_stream, acquire_client_buffer(_)) |
4770 | + EXPECT_CALL(*mock_buffer_bundle, client_acquire(_)) |
4771 | .Times(1) |
4772 | .WillOnce(InvokeArgument<0>(&stub_buffer)); |
4773 | |
4774 | @@ -296,12 +298,12 @@ |
4775 | EXPECT_EQ(p, surface.top_left()); |
4776 | } |
4777 | |
4778 | -TEST_F(SurfaceCreation, resize_updates_stream_and_state) |
4779 | +TEST_F(SurfaceCreation, resize_updates_bundle_and_state) |
4780 | { |
4781 | using namespace testing; |
4782 | geom::Size const new_size{123, 456}; |
4783 | |
4784 | - EXPECT_CALL(*mock_buffer_stream, resize(new_size)) |
4785 | + EXPECT_CALL(*mock_buffer_bundle, resize(new_size)) |
4786 | .Times(1); |
4787 | |
4788 | auto const mock_event_sink = std::make_shared<MockEventSink>(); |
4789 | @@ -327,15 +329,15 @@ |
4790 | |
4791 | ASSERT_THAT(surface.size(), Ne(new_size)); |
4792 | |
4793 | - EXPECT_CALL(*mock_buffer_stream, resize(new_size)).Times(1); |
4794 | + EXPECT_CALL(*mock_buffer_bundle, resize(new_size)).Times(1); |
4795 | EXPECT_CALL(*mock_event_sink, handle_event(_)).Times(1); |
4796 | surface.resize(new_size); |
4797 | EXPECT_THAT(surface.size(), Eq(new_size)); |
4798 | |
4799 | - Mock::VerifyAndClearExpectations(mock_buffer_stream.get()); |
4800 | + Mock::VerifyAndClearExpectations(mock_buffer_bundle.get()); |
4801 | Mock::VerifyAndClearExpectations(mock_event_sink.get()); |
4802 | |
4803 | - EXPECT_CALL(*mock_buffer_stream, resize(_)).Times(0); |
4804 | + EXPECT_CALL(*mock_buffer_bundle, resize(_)).Times(0); |
4805 | EXPECT_CALL(*mock_event_sink, handle_event(_)).Times(0); |
4806 | surface.resize(new_size); |
4807 | EXPECT_THAT(surface.size(), Eq(new_size)); |
4808 | @@ -346,7 +348,7 @@ |
4809 | using namespace testing; |
4810 | geom::Size const new_size{123, 456}; |
4811 | |
4812 | - EXPECT_CALL(*mock_buffer_stream, resize(new_size)) |
4813 | + EXPECT_CALL(*mock_buffer_bundle, resize(new_size)) |
4814 | .Times(1) |
4815 | .WillOnce(Throw(std::runtime_error("bad resize"))); |
4816 | |
4817 | @@ -378,7 +380,7 @@ |
4818 | if (expect_size.height <= geom::Height{0}) |
4819 | expect_size.height = geom::Height{1}; |
4820 | |
4821 | - EXPECT_CALL(*mock_buffer_stream, resize(expect_size)).Times(1); |
4822 | + EXPECT_CALL(*mock_buffer_bundle, resize(expect_size)).Times(1); |
4823 | EXPECT_NO_THROW({ surface.resize(size); }); |
4824 | EXPECT_EQ(expect_size, surface.size()); |
4825 | } |
4826 | @@ -407,7 +409,7 @@ |
4827 | { |
4828 | using namespace testing; |
4829 | |
4830 | - EXPECT_CALL(*mock_buffer_stream, force_requests_to_complete()).Times(Exactly(1)); |
4831 | + EXPECT_CALL(*mock_buffer_bundle, force_requests_to_complete()).Times(Exactly(1)); |
4832 | |
4833 | surface.force_requests_to_complete(); |
4834 | } |
4835 | @@ -416,7 +418,7 @@ |
4836 | { |
4837 | using namespace testing; |
4838 | |
4839 | - EXPECT_CALL(*mock_buffer_stream, allow_framedropping(true)) |
4840 | + EXPECT_CALL(*mock_buffer_bundle, allow_framedropping(true)) |
4841 | .Times(1); |
4842 | |
4843 | surface.allow_framedropping(true); |
4844 | @@ -452,7 +454,7 @@ |
4845 | surface_name, |
4846 | rect, |
4847 | false, |
4848 | - mock_buffer_stream, |
4849 | + mock_buffer_bundle, |
4850 | mt::fake_shared(channel), |
4851 | std::make_shared<mtd::StubInputSender>(), |
4852 | std::shared_ptr<mg::CursorImage>(), |
4853 | @@ -470,7 +472,7 @@ |
4854 | surface_name, |
4855 | rect, |
4856 | false, |
4857 | - mock_buffer_stream, |
4858 | + mock_buffer_bundle, |
4859 | std::make_shared<mtd::StubInputChannel>(), |
4860 | mt::fake_shared(mock_sender), |
4861 | std::shared_ptr<mg::CursorImage>(), |
4862 | |
4863 | === modified file 'tests/unit-tests/scene/test_surface_impl.cpp' |
4864 | --- tests/unit-tests/scene/test_surface_impl.cpp 2015-03-06 03:52:41 +0000 |
4865 | +++ tests/unit-tests/scene/test_surface_impl.cpp 2015-03-20 19:31:52 +0000 |
4866 | @@ -25,8 +25,8 @@ |
4867 | #include "mir/frontend/event_sink.h" |
4868 | #include "mir/graphics/display_configuration.h" |
4869 | |
4870 | -#include "mir_test_doubles/stub_buffer_stream.h" |
4871 | -#include "mir_test_doubles/mock_buffer_stream.h" |
4872 | +#include "mir_test_doubles/stub_buffer_bundle.h" |
4873 | +#include "mir_test_doubles/mock_buffer_bundle.h" |
4874 | #include "mir_test_doubles/mock_input_targeter.h" |
4875 | #include "mir_test_doubles/stub_input_sender.h" |
4876 | #include "mir_test_doubles/null_event_sink.h" |
4877 | @@ -53,23 +53,22 @@ |
4878 | namespace |
4879 | { |
4880 | |
4881 | -typedef testing::NiceMock<mtd::MockBufferStream> StubBufferStream; |
4882 | +typedef testing::NiceMock<mtd::MockBufferBundle> StubBufferBundle; |
4883 | |
4884 | struct Surface : testing::Test |
4885 | { |
4886 | - std::shared_ptr<StubBufferStream> const buffer_stream = std::make_shared<StubBufferStream>(); |
4887 | + std::shared_ptr<StubBufferBundle> const buffer_bundle = std::make_shared<StubBufferBundle>(); |
4888 | |
4889 | void SetUp() |
4890 | { |
4891 | using namespace testing; |
4892 | |
4893 | - ON_CALL(*buffer_stream, stream_size()).WillByDefault(Return(geom::Size())); |
4894 | - ON_CALL(*buffer_stream, get_stream_pixel_format()).WillByDefault(Return(mir_pixel_format_abgr_8888)); |
4895 | - ON_CALL(*buffer_stream, acquire_client_buffer(_)) |
4896 | + ON_CALL(*buffer_bundle, size()).WillByDefault(Return(geom::Size())); |
4897 | + ON_CALL(*buffer_bundle, client_acquire(_)) |
4898 | .WillByDefault(InvokeArgument<0>(nullptr)); |
4899 | |
4900 | surface = std::make_shared<ms::BasicSurface>(std::string("stub"), geom::Rectangle{{},{}}, false, |
4901 | - buffer_stream, nullptr /* input_channel */, stub_input_sender, |
4902 | + buffer_bundle, nullptr /* input_channel */, stub_input_sender, |
4903 | nullptr /* cursor_image */, report); |
4904 | } |
4905 | |
4906 | @@ -264,13 +263,13 @@ |
4907 | |
4908 | TEST_F(Surface, with_most_recent_buffer_do_uses_compositor_buffer) |
4909 | { |
4910 | - auto stub_buffer_stream = std::make_shared<mtd::StubBufferStream>(); |
4911 | + auto stub_buffer_bundle = std::make_shared<mtd::StubBufferBundle>(); |
4912 | |
4913 | ms::BasicSurface surf( |
4914 | std::string("stub"), |
4915 | geom::Rectangle{{},{}}, |
4916 | false, |
4917 | - stub_buffer_stream, |
4918 | + stub_buffer_bundle, |
4919 | std::shared_ptr<mi::InputChannel>(), |
4920 | stub_input_sender, |
4921 | std::shared_ptr<mg::CursorImage>(), |
4922 | @@ -284,7 +283,7 @@ |
4923 | buf_ptr = &buffer; |
4924 | }); |
4925 | |
4926 | - EXPECT_EQ(stub_buffer_stream->stub_compositor_buffer.get(), buf_ptr); |
4927 | + EXPECT_EQ(stub_buffer_bundle->stub_compositor_buffer.get(), buf_ptr); |
4928 | } |
4929 | |
4930 | TEST_F(Surface, emits_client_close_events) |
4931 | @@ -314,7 +313,7 @@ |
4932 | std::string("stub"), |
4933 | geom::Rectangle{{},{}}, |
4934 | false, |
4935 | - buffer_stream, |
4936 | + buffer_bundle, |
4937 | std::shared_ptr<mi::InputChannel>(), |
4938 | stub_input_sender, |
4939 | std::shared_ptr<mg::CursorImage>(), |
4940 | |
4941 | === modified file 'tests/unit-tests/scene/test_surface_stack.cpp' |
4942 | --- tests/unit-tests/scene/test_surface_stack.cpp 2015-03-06 03:52:41 +0000 |
4943 | +++ tests/unit-tests/scene/test_surface_stack.cpp 2015-03-20 19:31:52 +0000 |
4944 | @@ -27,9 +27,9 @@ |
4945 | #include "mir/input/input_channel_factory.h" |
4946 | #include "mir_test_doubles/stub_input_channel.h" |
4947 | #include "mir_test/fake_shared.h" |
4948 | -#include "mir_test_doubles/stub_buffer_stream.h" |
4949 | +#include "mir_test_doubles/stub_buffer_bundle.h" |
4950 | #include "mir_test_doubles/stub_renderable.h" |
4951 | -#include "mir_test_doubles/mock_buffer_stream.h" |
4952 | +#include "mir_test_doubles/mock_buffer_bundle.h" |
4953 | |
4954 | #include <gmock/gmock.h> |
4955 | #include <gtest/gtest.h> |
4956 | @@ -125,7 +125,7 @@ |
4957 | std::string("stub"), |
4958 | geom::Rectangle{{},{}}, |
4959 | false, |
4960 | - std::make_shared<mtd::StubBufferStream>(), |
4961 | + std::make_shared<mtd::StubBufferBundle>(), |
4962 | std::shared_ptr<mir::input::InputChannel>(), |
4963 | std::shared_ptr<mir::input::InputSender>(), |
4964 | std::shared_ptr<mg::CursorImage>(), |
4965 | @@ -137,7 +137,7 @@ |
4966 | std::string("stub"), |
4967 | geom::Rectangle{{},{}}, |
4968 | false, |
4969 | - std::make_shared<mtd::StubBufferStream>(), |
4970 | + std::make_shared<mtd::StubBufferBundle>(), |
4971 | std::shared_ptr<mir::input::InputChannel>(), |
4972 | std::shared_ptr<mir::input::InputSender>(), |
4973 | std::shared_ptr<mg::CursorImage>(), |
4974 | @@ -149,7 +149,7 @@ |
4975 | std::string("stub"), |
4976 | geom::Rectangle{{},{}}, |
4977 | false, |
4978 | - std::make_shared<mtd::StubBufferStream>(), |
4979 | + std::make_shared<mtd::StubBufferBundle>(), |
4980 | std::shared_ptr<mir::input::InputChannel>(), |
4981 | std::shared_ptr<mir::input::InputSender>(), |
4982 | std::shared_ptr<mg::CursorImage>(), |
4983 | @@ -161,7 +161,7 @@ |
4984 | std::string("stub"), |
4985 | geom::Rectangle{{},{}}, |
4986 | false, |
4987 | - std::make_shared<mtd::StubBufferStream>(), |
4988 | + std::make_shared<mtd::StubBufferBundle>(), |
4989 | std::shared_ptr<mir::input::InputChannel>(), |
4990 | std::shared_ptr<mir::input::InputSender>(), |
4991 | std::shared_ptr<mg::CursorImage>(), |
4992 | @@ -236,7 +236,7 @@ |
4993 | std::string("Mary had a little lamb"), |
4994 | geom::Rectangle{{},{}}, |
4995 | false, |
4996 | - std::make_shared<mtd::StubBufferStream>(), |
4997 | + std::make_shared<mtd::StubBufferBundle>(), |
4998 | std::shared_ptr<mir::input::InputChannel>(), |
4999 | std::shared_ptr<mir::input::InputSender>(), |
5000 | std::shared_ptr<mg::CursorImage>(), |
PASSED: Continuous integration, rev:2343 jenkins. qa.ubuntu. com/job/ mir-ci/ 3094/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/1456 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/1455 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/1410 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 1091 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 1091/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1410 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1410/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/4432 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 18437
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/3094/ rebuild
http://