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