Merge lp:~kdub/mir/interval0-signal into lp:~mir-team/mir/trunk
- interval0-signal
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Daniel van Vugt | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 780 | ||||
Proposed branch: | lp:~kdub/mir/interval0-signal | ||||
Merge into: | lp:~mir-team/mir/trunk | ||||
Prerequisite: | lp:~kdub/mir/anativewindow-external-refcount | ||||
Diff against target: |
786 lines (+418/-23) 24 files modified
include/client/mir_toolkit/mir_client_library.h (+21/-0) include/server/mir/compositor/buffer_allocation_strategy.h (+1/-1) include/server/mir/compositor/buffer_stream_surfaces.h (+1/-0) include/server/mir/compositor/swapper_factory.h (+6/-2) include/server/mir/shell/surface.h (+1/-0) include/server/mir/surfaces/buffer_stream.h (+1/-0) include/server/mir/surfaces/surface.h (+2/-0) include/shared/mir_toolkit/common.h (+1/-1) include/test/mir_test_doubles/mock_buffer_stream.h (+2/-0) include/test/mir_test_doubles/mock_swapper_factory.h (+2/-2) include/test/mir_test_doubles/stub_buffer_stream.h (+4/-0) src/client/mir_client_library.cpp (+12/-0) src/client/mir_surface.cpp (+2/-0) src/server/compositor/buffer_stream_surfaces.cpp (+4/-0) src/server/compositor/swapper_factory.cpp (+36/-9) src/server/compositor/switching_bundle.cpp (+2/-2) src/server/shell/surface.cpp (+14/-1) src/server/surfaces/surface.cpp (+5/-0) tests/integration-tests/CMakeLists.txt (+1/-0) tests/integration-tests/test_swapinterval.cpp (+226/-0) tests/unit-tests/compositor/test_buffer_stream.cpp (+9/-0) tests/unit-tests/compositor/test_swapper_factory.cpp (+50/-2) tests/unit-tests/compositor/test_switching_bundle.cpp (+3/-3) tests/unit-tests/surfaces/test_surface.cpp (+12/-0) |
||||
To merge this branch: | bzr merge lp:~kdub/mir/interval0-signal | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Daniel van Vugt | Approve | ||
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+170423@code.launchpad.net |
This proposal supersedes a proposal from 2013-06-17.
Commit message
Activate sending a "swapinterval" signal over IPC. Add client api for software clients to request different swapintervals. (eglSwapInterval is not glued together just yet)
Currently only swapinterval of 0 or 1 is supported.
Description of the change
Activate sending a "swapinterval" signal over IPC. Add client api for software clients to request different swapintervals. (eglSwapInterval is not glued together just yet)
Currently only swapinterval of 0 or 1 is supported.
note that the actual path taken over ipc is via the surface parameters, there is no new protobuf message introduced to support the message.
tests/integrati
still in pre-review, dependent on anativewindow-
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:759
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:758
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
1. Swap interval >1 is valid, but not usually useful. I wonder if there's any value in generalizing so interval>1 is supported...?
2. Documentation on the limitations of swap interval ([0,1]) is missing from the comment for mir_surface_
3. Consistency:
132 +typedef enum MirSurfacePerfo
133 +{
134 + mir_surface_
135 + mir_surface_
136 + mir_surface_
137 +} MirSurfacePerfo
"MirSurfacePerf
124 + mir_surface_
Although "hint" is a bit vague. Why not make the attribute named "swap_interval" or similar? Then you don't need MirSurfacePerfo
4. Lack of indentation under "196 + switch (interval)" is a style I haven't seen in Mir before. Is it within policy? Do we care?
5. I tried adding mir_surface_
I see the swap happening *much* less often with 0 than 1. However adding a frame rate counter in the client shows it's higher for the client, as it should be. I suspect we have a buffer scheduling problem that makes interval=0 look much slower than it should. But it might just be the natural randomness of frame dropping making longer periods of green/blue appear in demo_client_
So really just #2-#4 need attention right now.
Alexandros Frantzis (afrantzis) wrote : | # |
> 4. Lack of indentation under "196 + switch (interval)" is a style I haven't seen in Mir before.
> Is it within policy? Do we care?
I see more indentation that we normally use, not a lack of it :)
274 + void mc::SwapperFact
297 + create_
298 - std::vector<
299 + BufferProperties const& buffer_properties, std::vector<
It feels strange that we remove/add buffers to the vector that is handed to us (although it has no ill effect, since the caller doesn't care about the buffers). I think it would be cleaner to create and manipulate a new vector internally (and make the create_
289 + } else
else should be on separate line
Kevin DuBois (kdub) wrote : | # |
@Daniel
#1, we don't have a driving use case for >1 swapinterval at the moment, plus it would take some changes to the swappers, so we can put it on the wishlist.
#2 hopefully better documentation added
#3 good idea, code is cleaner with this
#4 just bad indentation, was eliminated with #3
#5 i think this is just the unaccelerated client picking blue or green frames multiple times in a row. If you call this function with an eglapp.c based gl client, you'll see higher than vsync framerates reported.
@Alexandros
I agree, have to come up with a solution to allocate a buffer when going from 2->3 buffers, and preserve the buffer for any future 3->2 transitions. The android drivers didn't like switching buffers of the same size/format/usage out from under them.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:764
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Thanks Kevin. I can see the requested changes made but have not re-reviewed yet.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:765
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
A lot has landed today. So now we have:
Text conflict in src/server/
Text conflict in tests/unit-
2 conflicts encountered.
Daniel van Vugt (vanvugt) wrote : | # |
1. Conflicts:
Text conflict in src/server/
Text conflict in tests/unit-
2. Please resolve this inconsistency: "swapinterval" and "swap_interval".
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:766
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:767
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
OK, I have no more complaints. But I'm not going to redo all the testing I've already done on earlier revisions.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'include/client/mir_toolkit/mir_client_library.h' | |||
2 | --- include/client/mir_toolkit/mir_client_library.h 2013-06-20 09:43:30 +0000 | |||
3 | +++ include/client/mir_toolkit/mir_client_library.h 2013-06-25 19:32:30 +0000 | |||
4 | @@ -293,6 +293,27 @@ | |||
5 | 293 | */ | 293 | */ |
6 | 294 | MirSurfaceState mir_surface_get_state(MirSurface *surface); | 294 | MirSurfaceState mir_surface_get_state(MirSurface *surface); |
7 | 295 | 295 | ||
8 | 296 | /** | ||
9 | 297 | * Set the swapinterval for mir_surface_swap_buffers. EGL users should use | ||
10 | 298 | * eglSwapInterval directly. | ||
11 | 299 | * At the time being, only swapinterval of 0 or 1 is supported. | ||
12 | 300 | * \param [in] surface The surface to operate on | ||
13 | 301 | * \param [in] interval The number of vblank signals that | ||
14 | 302 | * mir_surface_swap_buffers will wait for | ||
15 | 303 | * \return A wait handle that can be passed to mir_wait_for, | ||
16 | 304 | * or NULL if the interval could not be supported | ||
17 | 305 | */ | ||
18 | 306 | MirWaitHandle* mir_surface_set_swapinterval(MirSurface* surface, int interval); | ||
19 | 307 | |||
20 | 308 | /** | ||
21 | 309 | * Query the swapinterval that the surface is operating with. | ||
22 | 310 | * The default interval is 1. | ||
23 | 311 | * \param [in] surface The surface to operate on | ||
24 | 312 | * \return The swapinterval value that the client is operating with. | ||
25 | 313 | * Returns -1 if surface is invalid. | ||
26 | 314 | */ | ||
27 | 315 | int mir_surface_get_swapinterval(MirSurface* surface); | ||
28 | 316 | |||
29 | 296 | #ifdef __cplusplus | 317 | #ifdef __cplusplus |
30 | 297 | } | 318 | } |
31 | 298 | /**@}*/ | 319 | /**@}*/ |
32 | 299 | 320 | ||
33 | === modified file 'include/server/mir/compositor/buffer_allocation_strategy.h' | |||
34 | --- include/server/mir/compositor/buffer_allocation_strategy.h 2013-06-17 10:26:18 +0000 | |||
35 | +++ include/server/mir/compositor/buffer_allocation_strategy.h 2013-06-25 19:32:30 +0000 | |||
36 | @@ -45,7 +45,7 @@ | |||
37 | 45 | class BufferAllocationStrategy | 45 | class BufferAllocationStrategy |
38 | 46 | { | 46 | { |
39 | 47 | public: | 47 | public: |
41 | 48 | virtual std::shared_ptr<BufferSwapper> create_swapper_reuse_buffers( | 48 | virtual std::shared_ptr<BufferSwapper> create_swapper_reuse_buffers(BufferProperties const&, |
42 | 49 | std::vector<std::shared_ptr<Buffer>>&, size_t, SwapperType) const = 0; | 49 | std::vector<std::shared_ptr<Buffer>>&, size_t, SwapperType) const = 0; |
43 | 50 | virtual std::shared_ptr<BufferSwapper> create_swapper_new_buffers( | 50 | virtual std::shared_ptr<BufferSwapper> create_swapper_new_buffers( |
44 | 51 | BufferProperties& actual_properties, BufferProperties const& requested_properties, SwapperType) const = 0; | 51 | BufferProperties& actual_properties, BufferProperties const& requested_properties, SwapperType) const = 0; |
45 | 52 | 52 | ||
46 | === modified file 'include/server/mir/compositor/buffer_stream_surfaces.h' | |||
47 | --- include/server/mir/compositor/buffer_stream_surfaces.h 2013-06-20 09:39:10 +0000 | |||
48 | +++ include/server/mir/compositor/buffer_stream_surfaces.h 2013-06-25 19:32:30 +0000 | |||
49 | @@ -46,6 +46,7 @@ | |||
50 | 46 | 46 | ||
51 | 47 | geometry::PixelFormat get_stream_pixel_format(); | 47 | geometry::PixelFormat get_stream_pixel_format(); |
52 | 48 | geometry::Size stream_size(); | 48 | geometry::Size stream_size(); |
53 | 49 | void allow_framedropping(bool); | ||
54 | 49 | void force_requests_to_complete(); | 50 | void force_requests_to_complete(); |
55 | 50 | 51 | ||
56 | 51 | protected: | 52 | protected: |
57 | 52 | 53 | ||
58 | === modified file 'include/server/mir/compositor/swapper_factory.h' | |||
59 | --- include/server/mir/compositor/swapper_factory.h 2013-06-11 15:05:27 +0000 | |||
60 | +++ include/server/mir/compositor/swapper_factory.h 2013-06-25 19:32:30 +0000 | |||
61 | @@ -38,14 +38,18 @@ | |||
62 | 38 | std::shared_ptr<GraphicBufferAllocator> const& gr_alloc, | 38 | std::shared_ptr<GraphicBufferAllocator> const& gr_alloc, |
63 | 39 | int number_of_buffers); | 39 | int number_of_buffers); |
64 | 40 | 40 | ||
66 | 41 | std::shared_ptr<BufferSwapper> create_swapper_reuse_buffers( | 41 | std::shared_ptr<BufferSwapper> create_swapper_reuse_buffers(BufferProperties const&, |
67 | 42 | std::vector<std::shared_ptr<Buffer>>&, size_t, SwapperType) const; | 42 | std::vector<std::shared_ptr<Buffer>>&, size_t, SwapperType) const; |
68 | 43 | std::shared_ptr<BufferSwapper> create_swapper_new_buffers( | 43 | std::shared_ptr<BufferSwapper> create_swapper_new_buffers( |
69 | 44 | BufferProperties& actual_properties, BufferProperties const& requested_properties, SwapperType) const; | 44 | BufferProperties& actual_properties, BufferProperties const& requested_properties, SwapperType) const; |
70 | 45 | 45 | ||
71 | 46 | private: | 46 | private: |
72 | 47 | void change_swapper_size( | ||
73 | 48 | std::vector<std::shared_ptr<Buffer>>&, size_t const, size_t, BufferProperties const&) const; | ||
74 | 49 | |||
75 | 47 | std::shared_ptr<GraphicBufferAllocator> const gr_allocator; | 50 | std::shared_ptr<GraphicBufferAllocator> const gr_allocator; |
77 | 48 | int const number_of_buffers; | 51 | unsigned int const synchronous_number_of_buffers; |
78 | 52 | unsigned int const spin_number_of_buffers; | ||
79 | 49 | }; | 53 | }; |
80 | 50 | } | 54 | } |
81 | 51 | } | 55 | } |
82 | 52 | 56 | ||
83 | === modified file 'include/server/mir/shell/surface.h' | |||
84 | --- include/server/mir/shell/surface.h 2013-06-25 05:42:49 +0000 | |||
85 | +++ include/server/mir/shell/surface.h 2013-06-25 19:32:30 +0000 | |||
86 | @@ -87,6 +87,7 @@ | |||
87 | 87 | 87 | ||
88 | 88 | virtual void take_input_focus(std::shared_ptr<InputTargeter> const& targeter); | 88 | virtual void take_input_focus(std::shared_ptr<InputTargeter> const& targeter); |
89 | 89 | 89 | ||
90 | 90 | virtual void allow_framedropping(bool); | ||
91 | 90 | private: | 91 | private: |
92 | 91 | bool set_type(MirSurfaceType t); // Use configure() to make public changes | 92 | bool set_type(MirSurfaceType t); // Use configure() to make public changes |
93 | 92 | bool set_state(MirSurfaceState s); | 93 | bool set_state(MirSurfaceState s); |
94 | 93 | 94 | ||
95 | === modified file 'include/server/mir/surfaces/buffer_stream.h' | |||
96 | --- include/server/mir/surfaces/buffer_stream.h 2013-06-20 09:39:10 +0000 | |||
97 | +++ include/server/mir/surfaces/buffer_stream.h 2013-06-25 19:32:30 +0000 | |||
98 | @@ -45,6 +45,7 @@ | |||
99 | 45 | virtual std::shared_ptr<compositor::Buffer> lock_back_buffer() = 0; | 45 | virtual std::shared_ptr<compositor::Buffer> lock_back_buffer() = 0; |
100 | 46 | virtual geometry::PixelFormat get_stream_pixel_format() = 0; | 46 | virtual geometry::PixelFormat get_stream_pixel_format() = 0; |
101 | 47 | virtual geometry::Size stream_size() = 0; | 47 | virtual geometry::Size stream_size() = 0; |
102 | 48 | virtual void allow_framedropping(bool) = 0; | ||
103 | 48 | virtual void force_requests_to_complete() = 0; | 49 | virtual void force_requests_to_complete() = 0; |
104 | 49 | }; | 50 | }; |
105 | 50 | 51 | ||
106 | 51 | 52 | ||
107 | === modified file 'include/server/mir/surfaces/surface.h' | |||
108 | --- include/server/mir/surfaces/surface.h 2013-06-25 05:42:49 +0000 | |||
109 | +++ include/server/mir/surfaces/surface.h 2013-06-25 19:32:30 +0000 | |||
110 | @@ -81,6 +81,8 @@ | |||
111 | 81 | bool supports_input() const; | 81 | bool supports_input() const; |
112 | 82 | int client_input_fd() const; | 82 | int client_input_fd() const; |
113 | 83 | int server_input_fd() const; | 83 | int server_input_fd() const; |
114 | 84 | |||
115 | 85 | void allow_framedropping(bool); | ||
116 | 84 | private: | 86 | private: |
117 | 85 | std::string surface_name; | 87 | std::string surface_name; |
118 | 86 | geometry::Point top_left_point; | 88 | geometry::Point top_left_point; |
119 | 87 | 89 | ||
120 | === modified file 'include/shared/mir_toolkit/common.h' | |||
121 | --- include/shared/mir_toolkit/common.h 2013-05-03 22:53:42 +0000 | |||
122 | +++ include/shared/mir_toolkit/common.h 2013-06-25 19:32:30 +0000 | |||
123 | @@ -35,6 +35,7 @@ | |||
124 | 35 | { | 35 | { |
125 | 36 | mir_surface_attrib_type, | 36 | mir_surface_attrib_type, |
126 | 37 | mir_surface_attrib_state, | 37 | mir_surface_attrib_state, |
127 | 38 | mir_surface_attrib_swapinterval, | ||
128 | 38 | mir_surface_attrib_arraysize_ | 39 | mir_surface_attrib_arraysize_ |
129 | 39 | } MirSurfaceAttrib; | 40 | } MirSurfaceAttrib; |
130 | 40 | 41 | ||
131 | @@ -62,7 +63,6 @@ | |||
132 | 62 | mir_surface_state_fullscreen, | 63 | mir_surface_state_fullscreen, |
133 | 63 | mir_surface_state_arraysize_ | 64 | mir_surface_state_arraysize_ |
134 | 64 | } MirSurfaceState; | 65 | } MirSurfaceState; |
135 | 65 | |||
136 | 66 | /**@}*/ | 66 | /**@}*/ |
137 | 67 | 67 | ||
138 | 68 | #endif | 68 | #endif |
139 | 69 | 69 | ||
140 | === modified file 'include/test/mir_test_doubles/mock_buffer_stream.h' | |||
141 | --- include/test/mir_test_doubles/mock_buffer_stream.h 2013-06-19 16:41:13 +0000 | |||
142 | +++ include/test/mir_test_doubles/mock_buffer_stream.h 2013-06-25 19:32:30 +0000 | |||
143 | @@ -36,6 +36,8 @@ | |||
144 | 36 | 36 | ||
145 | 37 | MOCK_METHOD0(get_stream_pixel_format, geometry::PixelFormat()); | 37 | MOCK_METHOD0(get_stream_pixel_format, geometry::PixelFormat()); |
146 | 38 | MOCK_METHOD0(stream_size, geometry::Size()); | 38 | MOCK_METHOD0(stream_size, geometry::Size()); |
147 | 39 | MOCK_METHOD0(force_client_completion, void()); | ||
148 | 40 | MOCK_METHOD1(allow_framedropping, void(bool)); | ||
149 | 39 | MOCK_METHOD0(force_requests_to_complete, void()); | 41 | MOCK_METHOD0(force_requests_to_complete, void()); |
150 | 40 | }; | 42 | }; |
151 | 41 | } | 43 | } |
152 | 42 | 44 | ||
153 | === modified file 'include/test/mir_test_doubles/mock_swapper_factory.h' | |||
154 | --- include/test/mir_test_doubles/mock_swapper_factory.h 2013-06-11 14:27:33 +0000 | |||
155 | +++ include/test/mir_test_doubles/mock_swapper_factory.h 2013-06-25 19:32:30 +0000 | |||
156 | @@ -33,8 +33,8 @@ | |||
157 | 33 | public: | 33 | public: |
158 | 34 | ~MockSwapperFactory() noexcept {} | 34 | ~MockSwapperFactory() noexcept {} |
159 | 35 | 35 | ||
162 | 36 | MOCK_CONST_METHOD3(create_swapper_reuse_buffers, | 36 | MOCK_CONST_METHOD4(create_swapper_reuse_buffers, |
163 | 37 | std::shared_ptr<compositor::BufferSwapper>( | 37 | std::shared_ptr<compositor::BufferSwapper>(compositor::BufferProperties const&, |
164 | 38 | std::vector<std::shared_ptr<compositor::Buffer>>&, size_t, compositor::SwapperType)); | 38 | std::vector<std::shared_ptr<compositor::Buffer>>&, size_t, compositor::SwapperType)); |
165 | 39 | MOCK_CONST_METHOD3(create_swapper_new_buffers, | 39 | MOCK_CONST_METHOD3(create_swapper_new_buffers, |
166 | 40 | std::shared_ptr<compositor::BufferSwapper>( | 40 | std::shared_ptr<compositor::BufferSwapper>( |
167 | 41 | 41 | ||
168 | === modified file 'include/test/mir_test_doubles/stub_buffer_stream.h' | |||
169 | --- include/test/mir_test_doubles/stub_buffer_stream.h 2013-06-19 16:41:13 +0000 | |||
170 | +++ include/test/mir_test_doubles/stub_buffer_stream.h 2013-06-25 19:32:30 +0000 | |||
171 | @@ -61,6 +61,10 @@ | |||
172 | 61 | { | 61 | { |
173 | 62 | } | 62 | } |
174 | 63 | 63 | ||
175 | 64 | void allow_framedropping(bool) | ||
176 | 65 | { | ||
177 | 66 | } | ||
178 | 67 | |||
179 | 64 | std::shared_ptr<compositor::Buffer> stub_client_buffer; | 68 | std::shared_ptr<compositor::Buffer> stub_client_buffer; |
180 | 65 | std::shared_ptr<compositor::Buffer> stub_compositor_buffer; | 69 | std::shared_ptr<compositor::Buffer> stub_compositor_buffer; |
181 | 66 | }; | 70 | }; |
182 | 67 | 71 | ||
183 | === modified file 'src/client/mir_client_library.cpp' | |||
184 | --- src/client/mir_client_library.cpp 2013-06-20 09:43:30 +0000 | |||
185 | +++ src/client/mir_client_library.cpp 2013-06-25 19:32:30 +0000 | |||
186 | @@ -316,3 +316,15 @@ | |||
187 | 316 | 316 | ||
188 | 317 | return state; | 317 | return state; |
189 | 318 | } | 318 | } |
190 | 319 | |||
191 | 320 | MirWaitHandle* mir_surface_set_swapinterval(MirSurface* surf, int interval) | ||
192 | 321 | { | ||
193 | 322 | if ((interval < 0) || (interval > 1)) | ||
194 | 323 | return NULL; | ||
195 | 324 | return surf ? surf->configure(mir_surface_attrib_swapinterval, interval) : NULL; | ||
196 | 325 | } | ||
197 | 326 | |||
198 | 327 | int mir_surface_get_swapinterval(MirSurface* surf) | ||
199 | 328 | { | ||
200 | 329 | return surf ? surf->attrib(mir_surface_attrib_swapinterval) : -1; | ||
201 | 330 | } | ||
202 | 319 | 331 | ||
203 | === modified file 'src/client/mir_surface.cpp' | |||
204 | --- src/client/mir_surface.cpp 2013-06-20 09:43:30 +0000 | |||
205 | +++ src/client/mir_surface.cpp 2013-06-25 19:32:30 +0000 | |||
206 | @@ -58,6 +58,7 @@ | |||
207 | 58 | attrib_cache[i] = -1; | 58 | attrib_cache[i] = -1; |
208 | 59 | attrib_cache[mir_surface_attrib_type] = mir_surface_type_normal; | 59 | attrib_cache[mir_surface_attrib_type] = mir_surface_type_normal; |
209 | 60 | attrib_cache[mir_surface_attrib_state] = mir_surface_state_unknown; | 60 | attrib_cache[mir_surface_attrib_state] = mir_surface_state_unknown; |
210 | 61 | attrib_cache[mir_surface_attrib_swapinterval] = 1; | ||
211 | 61 | } | 62 | } |
212 | 62 | 63 | ||
213 | 63 | MirSurface::~MirSurface() | 64 | MirSurface::~MirSurface() |
214 | @@ -269,6 +270,7 @@ | |||
215 | 269 | { | 270 | { |
216 | 270 | case mir_surface_attrib_type: | 271 | case mir_surface_attrib_type: |
217 | 271 | case mir_surface_attrib_state: | 272 | case mir_surface_attrib_state: |
218 | 273 | case mir_surface_attrib_swapinterval: | ||
219 | 272 | if (configure_result.has_ivalue()) | 274 | if (configure_result.has_ivalue()) |
220 | 273 | attrib_cache[a] = configure_result.ivalue(); | 275 | attrib_cache[a] = configure_result.ivalue(); |
221 | 274 | else | 276 | else |
222 | 275 | 277 | ||
223 | === modified file 'src/server/compositor/buffer_stream_surfaces.cpp' | |||
224 | --- src/server/compositor/buffer_stream_surfaces.cpp 2013-06-19 16:41:13 +0000 | |||
225 | +++ src/server/compositor/buffer_stream_surfaces.cpp 2013-06-25 19:32:30 +0000 | |||
226 | @@ -63,3 +63,7 @@ | |||
227 | 63 | buffer_bundle->force_requests_to_complete(); | 63 | buffer_bundle->force_requests_to_complete(); |
228 | 64 | } | 64 | } |
229 | 65 | 65 | ||
230 | 66 | void mc::BufferStreamSurfaces::allow_framedropping(bool allow) | ||
231 | 67 | { | ||
232 | 68 | buffer_bundle->allow_framedropping(allow); | ||
233 | 69 | } | ||
234 | 66 | 70 | ||
235 | === modified file 'src/server/compositor/swapper_factory.cpp' | |||
236 | --- src/server/compositor/swapper_factory.cpp 2013-06-11 19:55:10 +0000 | |||
237 | +++ src/server/compositor/swapper_factory.cpp 2013-06-25 19:32:30 +0000 | |||
238 | @@ -36,7 +36,8 @@ | |||
239 | 36 | std::shared_ptr<GraphicBufferAllocator> const& gr_alloc, | 36 | std::shared_ptr<GraphicBufferAllocator> const& gr_alloc, |
240 | 37 | int number_of_buffers) | 37 | int number_of_buffers) |
241 | 38 | : gr_allocator(gr_alloc), | 38 | : gr_allocator(gr_alloc), |
243 | 39 | number_of_buffers(number_of_buffers) | 39 | synchronous_number_of_buffers(number_of_buffers), |
244 | 40 | spin_number_of_buffers(3) //spin algorithm always takes 3 buffers | ||
245 | 40 | { | 41 | { |
246 | 41 | } | 42 | } |
247 | 42 | 43 | ||
248 | @@ -46,16 +47,43 @@ | |||
249 | 46 | { | 47 | { |
250 | 47 | } | 48 | } |
251 | 48 | 49 | ||
252 | 50 | void mc::SwapperFactory::change_swapper_size( | ||
253 | 51 | std::vector<std::shared_ptr<mc::Buffer>>& list, | ||
254 | 52 | size_t const desired_size, size_t current_size, BufferProperties const& buffer_properties) const | ||
255 | 53 | { | ||
256 | 54 | while (current_size < desired_size) | ||
257 | 55 | { | ||
258 | 56 | list.push_back(gr_allocator->alloc_buffer(buffer_properties)); | ||
259 | 57 | current_size++; | ||
260 | 58 | } | ||
261 | 59 | |||
262 | 60 | while (current_size > desired_size) | ||
263 | 61 | { | ||
264 | 62 | if (list.empty()) | ||
265 | 63 | { | ||
266 | 64 | BOOST_THROW_EXCEPTION(std::logic_error("SwapperFactory could not change algorithm")); | ||
267 | 65 | } | ||
268 | 66 | else | ||
269 | 67 | { | ||
270 | 68 | list.pop_back(); | ||
271 | 69 | current_size--; | ||
272 | 70 | } | ||
273 | 71 | } | ||
274 | 72 | } | ||
275 | 73 | |||
276 | 49 | std::shared_ptr<mc::BufferSwapper> mc::SwapperFactory::create_swapper_reuse_buffers( | 74 | std::shared_ptr<mc::BufferSwapper> mc::SwapperFactory::create_swapper_reuse_buffers( |
278 | 50 | std::vector<std::shared_ptr<Buffer>>& list, size_t buffer_num, SwapperType type) const | 75 | BufferProperties const& buffer_properties, std::vector<std::shared_ptr<Buffer>>& list, |
279 | 76 | size_t buffer_num, SwapperType type) const | ||
280 | 51 | { | 77 | { |
281 | 52 | if (type == mc::SwapperType::synchronous) | 78 | if (type == mc::SwapperType::synchronous) |
282 | 53 | { | 79 | { |
284 | 54 | return std::make_shared<mc::BufferSwapperMulti>(list, buffer_num); | 80 | change_swapper_size(list, synchronous_number_of_buffers, buffer_num, buffer_properties); |
285 | 81 | return std::make_shared<mc::BufferSwapperMulti>(list, synchronous_number_of_buffers); | ||
286 | 55 | } | 82 | } |
287 | 56 | else | 83 | else |
288 | 57 | { | 84 | { |
290 | 58 | return std::make_shared<mc::BufferSwapperSpin>(list, buffer_num); | 85 | change_swapper_size(list, spin_number_of_buffers, buffer_num, buffer_properties); |
291 | 86 | return std::make_shared<mc::BufferSwapperSpin>(list, spin_number_of_buffers); | ||
292 | 59 | } | 87 | } |
293 | 60 | } | 88 | } |
294 | 61 | 89 | ||
295 | @@ -68,20 +96,19 @@ | |||
296 | 68 | 96 | ||
297 | 69 | if (type == mc::SwapperType::synchronous) | 97 | if (type == mc::SwapperType::synchronous) |
298 | 70 | { | 98 | { |
300 | 71 | for(auto i=0; i< number_of_buffers; i++) | 99 | for(auto i=0u; i< synchronous_number_of_buffers; i++) |
301 | 72 | { | 100 | { |
302 | 73 | list.push_back(gr_allocator->alloc_buffer(requested_buffer_properties)); | 101 | list.push_back(gr_allocator->alloc_buffer(requested_buffer_properties)); |
303 | 74 | } | 102 | } |
305 | 75 | new_swapper = std::make_shared<mc::BufferSwapperMulti>(list, number_of_buffers); | 103 | new_swapper = std::make_shared<mc::BufferSwapperMulti>(list, synchronous_number_of_buffers); |
306 | 76 | } | 104 | } |
307 | 77 | else | 105 | else |
308 | 78 | { | 106 | { |
311 | 79 | int const async_buffer_count = 3; //async only can accept 3 buffers, so ignore constructor request | 107 | for(auto i=0u; i < spin_number_of_buffers; i++) |
310 | 80 | for(auto i=0; i < async_buffer_count; i++) | ||
312 | 81 | { | 108 | { |
313 | 82 | list.push_back(gr_allocator->alloc_buffer(requested_buffer_properties)); | 109 | list.push_back(gr_allocator->alloc_buffer(requested_buffer_properties)); |
314 | 83 | } | 110 | } |
316 | 84 | new_swapper = std::make_shared<mc::BufferSwapperSpin>(list, async_buffer_count); | 111 | new_swapper = std::make_shared<mc::BufferSwapperSpin>(list, spin_number_of_buffers); |
317 | 85 | } | 112 | } |
318 | 86 | 113 | ||
319 | 87 | actual_buffer_properties = BufferProperties{ | 114 | actual_buffer_properties = BufferProperties{ |
320 | 88 | 115 | ||
321 | === modified file 'src/server/compositor/switching_bundle.cpp' | |||
322 | --- src/server/compositor/switching_bundle.cpp 2013-06-15 11:09:16 +0000 | |||
323 | +++ src/server/compositor/switching_bundle.cpp 2013-06-25 19:32:30 +0000 | |||
324 | @@ -92,9 +92,9 @@ | |||
325 | 92 | swapper->end_responsibility(list, size); | 92 | swapper->end_responsibility(list, size); |
326 | 93 | 93 | ||
327 | 94 | if (allow_dropping) | 94 | if (allow_dropping) |
329 | 95 | swapper = swapper_factory->create_swapper_reuse_buffers(list, size, mc::SwapperType::framedropping); | 95 | swapper = swapper_factory->create_swapper_reuse_buffers(bundle_properties, list, size, mc::SwapperType::framedropping); |
330 | 96 | else | 96 | else |
332 | 97 | swapper = swapper_factory->create_swapper_reuse_buffers(list, size, mc::SwapperType::synchronous); | 97 | swapper = swapper_factory->create_swapper_reuse_buffers(bundle_properties, list, size, mc::SwapperType::synchronous); |
333 | 98 | 98 | ||
334 | 99 | cv.notify_all(); | 99 | cv.notify_all(); |
335 | 100 | } | 100 | } |
336 | 101 | 101 | ||
337 | === modified file 'src/server/shell/surface.cpp' | |||
338 | --- src/server/shell/surface.cpp 2013-06-25 05:42:49 +0000 | |||
339 | +++ src/server/shell/surface.cpp 2013-06-25 19:32:30 +0000 | |||
340 | @@ -189,6 +189,14 @@ | |||
341 | 189 | } | 189 | } |
342 | 190 | } | 190 | } |
343 | 191 | 191 | ||
344 | 192 | void msh::Surface::allow_framedropping(bool allow) | ||
345 | 193 | { | ||
346 | 194 | if (auto const& s = surface.lock()) | ||
347 | 195 | { | ||
348 | 196 | s->allow_framedropping(allow); | ||
349 | 197 | } | ||
350 | 198 | } | ||
351 | 199 | |||
352 | 192 | void msh::Surface::with_most_recent_buffer_do( | 200 | void msh::Surface::with_most_recent_buffer_do( |
353 | 193 | std::function<void(mc::Buffer&)> const& exec) | 201 | std::function<void(mc::Buffer&)> const& exec) |
354 | 194 | { | 202 | { |
355 | @@ -242,7 +250,7 @@ | |||
356 | 242 | int msh::Surface::configure(MirSurfaceAttrib attrib, int value) | 250 | int msh::Surface::configure(MirSurfaceAttrib attrib, int value) |
357 | 243 | { | 251 | { |
358 | 244 | int result = 0; | 252 | int result = 0; |
360 | 245 | 253 | bool allow_dropping = false; | |
361 | 246 | /* | 254 | /* |
362 | 247 | * TODO: In future, query the shell implementation for the subset of | 255 | * TODO: In future, query the shell implementation for the subset of |
363 | 248 | * attributes/types it implements. | 256 | * attributes/types it implements. |
364 | @@ -261,6 +269,11 @@ | |||
365 | 261 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface state.")); | 269 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface state.")); |
366 | 262 | result = state(); | 270 | result = state(); |
367 | 263 | break; | 271 | break; |
368 | 272 | case mir_surface_attrib_swapinterval: | ||
369 | 273 | allow_dropping = (value == 0); | ||
370 | 274 | allow_framedropping(allow_dropping); | ||
371 | 275 | result = value; | ||
372 | 276 | break; | ||
373 | 264 | default: | 277 | default: |
374 | 265 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface " | 278 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface " |
375 | 266 | "attribute.")); | 279 | "attribute.")); |
376 | 267 | 280 | ||
377 | === modified file 'src/server/surfaces/surface.cpp' | |||
378 | --- src/server/surfaces/surface.cpp 2013-06-25 05:42:49 +0000 | |||
379 | +++ src/server/surfaces/surface.cpp 2013-06-25 19:32:30 +0000 | |||
380 | @@ -176,6 +176,11 @@ | |||
381 | 176 | return buffer_stream->secure_client_buffer(); | 176 | return buffer_stream->secure_client_buffer(); |
382 | 177 | } | 177 | } |
383 | 178 | 178 | ||
384 | 179 | void ms::Surface::allow_framedropping(bool allow) | ||
385 | 180 | { | ||
386 | 181 | buffer_stream->allow_framedropping(allow); | ||
387 | 182 | } | ||
388 | 183 | |||
389 | 179 | std::shared_ptr<mc::Buffer> ms::Surface::compositor_buffer() const | 184 | std::shared_ptr<mc::Buffer> ms::Surface::compositor_buffer() const |
390 | 180 | { | 185 | { |
391 | 181 | return buffer_stream->lock_back_buffer(); | 186 | return buffer_stream->lock_back_buffer(); |
392 | 182 | 187 | ||
393 | === modified file 'tests/integration-tests/CMakeLists.txt' | |||
394 | --- tests/integration-tests/CMakeLists.txt 2013-06-25 03:25:49 +0000 | |||
395 | +++ tests/integration-tests/CMakeLists.txt 2013-06-25 19:32:30 +0000 | |||
396 | @@ -7,6 +7,7 @@ | |||
397 | 7 | test_display_info.cpp | 7 | test_display_info.cpp |
398 | 8 | test_display_server_main_loop_events.cpp | 8 | test_display_server_main_loop_events.cpp |
399 | 9 | test_surface_first_frame_sync.cpp | 9 | test_surface_first_frame_sync.cpp |
400 | 10 | test_swapinterval.cpp | ||
401 | 10 | ) | 11 | ) |
402 | 11 | 12 | ||
403 | 12 | add_subdirectory(client/) | 13 | add_subdirectory(client/) |
404 | 13 | 14 | ||
405 | === added file 'tests/integration-tests/test_swapinterval.cpp' | |||
406 | --- tests/integration-tests/test_swapinterval.cpp 1970-01-01 00:00:00 +0000 | |||
407 | +++ tests/integration-tests/test_swapinterval.cpp 2013-06-25 19:32:30 +0000 | |||
408 | @@ -0,0 +1,226 @@ | |||
409 | 1 | /* | ||
410 | 2 | * Copyright © 2013 Canonical Ltd. | ||
411 | 3 | * | ||
412 | 4 | * This program is free software: you can redistribute it and/or modify | ||
413 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
414 | 6 | * published by the Free Software Foundation. | ||
415 | 7 | * | ||
416 | 8 | * This program is distributed in the hope that it will be useful, | ||
417 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
418 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
419 | 11 | * GNU General Public License for more details. | ||
420 | 12 | * | ||
421 | 13 | * You should have received a copy of the GNU General Public License | ||
422 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
423 | 15 | * | ||
424 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | ||
425 | 17 | */ | ||
426 | 18 | |||
427 | 19 | #include "mir/geometry/rectangle.h" | ||
428 | 20 | #include "mir/graphics/display.h" | ||
429 | 21 | #include "mir/graphics/display_buffer.h" | ||
430 | 22 | #include "mir/graphics/renderer.h" | ||
431 | 23 | #include "mir/graphics/renderable.h" | ||
432 | 24 | #include "mir/compositor/compositor.h" | ||
433 | 25 | #include "mir/compositor/compositing_strategy.h" | ||
434 | 26 | #include "mir/compositor/renderables.h" | ||
435 | 27 | #include "mir/surfaces/buffer_stream.h" | ||
436 | 28 | #include "mir/surfaces/buffer_stream_factory.h" | ||
437 | 29 | |||
438 | 30 | #include "mir_test_framework/display_server_test_fixture.h" | ||
439 | 31 | #include "mir_test_doubles/stub_buffer.h" | ||
440 | 32 | |||
441 | 33 | #include "mir_toolkit/mir_client_library.h" | ||
442 | 34 | |||
443 | 35 | #include <gtest/gtest.h> | ||
444 | 36 | |||
445 | 37 | #include <thread> | ||
446 | 38 | #include <unistd.h> | ||
447 | 39 | #include <fcntl.h> | ||
448 | 40 | |||
449 | 41 | namespace geom = mir::geometry; | ||
450 | 42 | namespace mg = mir::graphics; | ||
451 | 43 | namespace mc = mir::compositor; | ||
452 | 44 | namespace mtf = mir_test_framework; | ||
453 | 45 | namespace ms = mir::surfaces; | ||
454 | 46 | namespace mtd = mir::test::doubles; | ||
455 | 47 | |||
456 | 48 | namespace | ||
457 | 49 | { | ||
458 | 50 | char const* const mir_test_socket = mtf::test_socket_file().c_str(); | ||
459 | 51 | |||
460 | 52 | class CountingBufferStream : public ms::BufferStream | ||
461 | 53 | { | ||
462 | 54 | public: | ||
463 | 55 | CountingBufferStream(int render_operations_fd) | ||
464 | 56 | : render_operations_fd(render_operations_fd) | ||
465 | 57 | { | ||
466 | 58 | } | ||
467 | 59 | |||
468 | 60 | std::shared_ptr<mc::Buffer> secure_client_buffer() { return std::make_shared<mtd::StubBuffer>(); } | ||
469 | 61 | std::shared_ptr<mc::Buffer> lock_back_buffer() { return std::make_shared<mtd::StubBuffer>(); } | ||
470 | 62 | geom::PixelFormat get_stream_pixel_format() { return geom::PixelFormat::abgr_8888; } | ||
471 | 63 | geom::Size stream_size() { return geom::Size{}; } | ||
472 | 64 | void force_requests_to_complete() {} | ||
473 | 65 | void allow_framedropping(bool) | ||
474 | 66 | { | ||
475 | 67 | while (write(render_operations_fd, "a", 1) != 1) continue; | ||
476 | 68 | } | ||
477 | 69 | |||
478 | 70 | private: | ||
479 | 71 | int render_operations_fd; | ||
480 | 72 | }; | ||
481 | 73 | |||
482 | 74 | class StubStreamFactory : public ms::BufferStreamFactory | ||
483 | 75 | { | ||
484 | 76 | public: | ||
485 | 77 | StubStreamFactory(int render_operations_fd) | ||
486 | 78 | : render_operations_fd(render_operations_fd) | ||
487 | 79 | { | ||
488 | 80 | } | ||
489 | 81 | |||
490 | 82 | std::shared_ptr<ms::BufferStream> create_buffer_stream(mc::BufferProperties const&) | ||
491 | 83 | { | ||
492 | 84 | return std::make_shared<CountingBufferStream>(render_operations_fd); | ||
493 | 85 | } | ||
494 | 86 | private: | ||
495 | 87 | int render_operations_fd; | ||
496 | 88 | }; | ||
497 | 89 | |||
498 | 90 | } | ||
499 | 91 | |||
500 | 92 | using SwapIntervalSignalTest = BespokeDisplayServerTestFixture; | ||
501 | 93 | TEST_F(SwapIntervalSignalTest, swapinterval_test) | ||
502 | 94 | { | ||
503 | 95 | static std::string const swapinterval_set{"swapinterval_set_952f3f10.tmp"}; | ||
504 | 96 | static std::string const do_client_finish{"do_client_finish_952f3f10.tmp"}; | ||
505 | 97 | |||
506 | 98 | std::remove(swapinterval_set.c_str()); | ||
507 | 99 | std::remove(do_client_finish.c_str()); | ||
508 | 100 | |||
509 | 101 | struct ServerConfig : TestingServerConfiguration | ||
510 | 102 | { | ||
511 | 103 | ServerConfig() | ||
512 | 104 | { | ||
513 | 105 | if (pipe(rendering_ops_pipe) != 0) | ||
514 | 106 | { | ||
515 | 107 | BOOST_THROW_EXCEPTION( | ||
516 | 108 | std::runtime_error("Failed to create pipe")); | ||
517 | 109 | } | ||
518 | 110 | |||
519 | 111 | if (fcntl(rendering_ops_pipe[0], F_SETFL, O_NONBLOCK) != 0) | ||
520 | 112 | { | ||
521 | 113 | BOOST_THROW_EXCEPTION( | ||
522 | 114 | std::runtime_error("Failed to make the read end of the pipe non-blocking")); | ||
523 | 115 | } | ||
524 | 116 | } | ||
525 | 117 | |||
526 | 118 | ~ServerConfig() | ||
527 | 119 | { | ||
528 | 120 | if (rendering_ops_pipe[0] >= 0) | ||
529 | 121 | close(rendering_ops_pipe[0]); | ||
530 | 122 | if (rendering_ops_pipe[1] >= 0) | ||
531 | 123 | close(rendering_ops_pipe[1]); | ||
532 | 124 | } | ||
533 | 125 | |||
534 | 126 | std::shared_ptr<ms::BufferStreamFactory> the_buffer_stream_factory() override | ||
535 | 127 | { | ||
536 | 128 | if (!stub_stream_factory) | ||
537 | 129 | stub_stream_factory = std::make_shared<StubStreamFactory>(rendering_ops_pipe[1]); | ||
538 | 130 | return stub_stream_factory; | ||
539 | 131 | } | ||
540 | 132 | |||
541 | 133 | int num_of_swapinterval_commands() | ||
542 | 134 | { | ||
543 | 135 | char c; | ||
544 | 136 | int ops{0}; | ||
545 | 137 | |||
546 | 138 | while (read(rendering_ops_pipe[0], &c, 1) == 1) | ||
547 | 139 | ops++; | ||
548 | 140 | |||
549 | 141 | return ops; | ||
550 | 142 | } | ||
551 | 143 | |||
552 | 144 | int rendering_ops_pipe[2]; | ||
553 | 145 | std::shared_ptr<StubStreamFactory> stub_stream_factory; | ||
554 | 146 | } server_config; | ||
555 | 147 | |||
556 | 148 | launch_server_process(server_config); | ||
557 | 149 | |||
558 | 150 | struct ClientConfig : TestingClientConfiguration | ||
559 | 151 | { | ||
560 | 152 | ClientConfig(std::string const& swapinterval_set, | ||
561 | 153 | std::string const& do_client_finish) | ||
562 | 154 | : swapinterval_set{swapinterval_set}, | ||
563 | 155 | do_client_finish{do_client_finish} | ||
564 | 156 | { | ||
565 | 157 | } | ||
566 | 158 | |||
567 | 159 | static void surface_callback(MirSurface*, void*) | ||
568 | 160 | { | ||
569 | 161 | } | ||
570 | 162 | |||
571 | 163 | void exec() | ||
572 | 164 | { | ||
573 | 165 | MirSurfaceParameters request_params = | ||
574 | 166 | { | ||
575 | 167 | __PRETTY_FUNCTION__, | ||
576 | 168 | 640, 480, | ||
577 | 169 | mir_pixel_format_abgr_8888, | ||
578 | 170 | mir_buffer_usage_hardware | ||
579 | 171 | }; | ||
580 | 172 | |||
581 | 173 | MirConnection* connection = mir_connect_sync(mir_test_socket, "testapp"); | ||
582 | 174 | MirSurface* surface = mir_connection_create_surface_sync(connection, &request_params); | ||
583 | 175 | |||
584 | 176 | //1 is the default swapinterval | ||
585 | 177 | EXPECT_EQ(1, mir_surface_get_swapinterval(surface)); | ||
586 | 178 | |||
587 | 179 | mir_wait_for(mir_surface_set_swapinterval(surface, 0)); | ||
588 | 180 | EXPECT_EQ(0, mir_surface_get_swapinterval(surface)); | ||
589 | 181 | |||
590 | 182 | mir_wait_for(mir_surface_set_swapinterval(surface, 1)); | ||
591 | 183 | EXPECT_EQ(1, mir_surface_get_swapinterval(surface)); | ||
592 | 184 | |||
593 | 185 | //swapinterval 2 not supported | ||
594 | 186 | EXPECT_EQ(NULL, mir_surface_set_swapinterval(surface, 2)); | ||
595 | 187 | EXPECT_EQ(1, mir_surface_get_swapinterval(surface)); | ||
596 | 188 | |||
597 | 189 | set_flag(swapinterval_set); | ||
598 | 190 | wait_for(do_client_finish); | ||
599 | 191 | |||
600 | 192 | mir_surface_release_sync(surface); | ||
601 | 193 | mir_connection_release(connection); | ||
602 | 194 | } | ||
603 | 195 | |||
604 | 196 | /* TODO: Extract this flag mechanism and make it reusable */ | ||
605 | 197 | void set_flag(std::string const& flag_file) | ||
606 | 198 | { | ||
607 | 199 | close(open(flag_file.c_str(), O_CREAT, S_IWUSR | S_IRUSR)); | ||
608 | 200 | } | ||
609 | 201 | |||
610 | 202 | void wait_for(std::string const& flag_file) | ||
611 | 203 | { | ||
612 | 204 | int fd = -1; | ||
613 | 205 | while ((fd = open(flag_file.c_str(), O_RDONLY, S_IWUSR | S_IRUSR)) == -1) | ||
614 | 206 | { | ||
615 | 207 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
616 | 208 | } | ||
617 | 209 | close(fd); | ||
618 | 210 | } | ||
619 | 211 | |||
620 | 212 | std::string const swapinterval_set; | ||
621 | 213 | std::string const do_client_finish; | ||
622 | 214 | } client_config{swapinterval_set, do_client_finish}; | ||
623 | 215 | |||
624 | 216 | launch_client_process(client_config); | ||
625 | 217 | |||
626 | 218 | run_in_test_process([&] | ||
627 | 219 | { | ||
628 | 220 | client_config.wait_for(swapinterval_set); | ||
629 | 221 | |||
630 | 222 | EXPECT_EQ(2, server_config.num_of_swapinterval_commands()); | ||
631 | 223 | |||
632 | 224 | client_config.set_flag(do_client_finish); | ||
633 | 225 | }); | ||
634 | 226 | } | ||
635 | 0 | 227 | ||
636 | === modified file 'tests/unit-tests/compositor/test_buffer_stream.cpp' | |||
637 | --- tests/unit-tests/compositor/test_buffer_stream.cpp 2013-06-17 15:55:04 +0000 | |||
638 | +++ tests/unit-tests/compositor/test_buffer_stream.cpp 2013-06-25 19:32:30 +0000 | |||
639 | @@ -122,3 +122,12 @@ | |||
640 | 122 | 122 | ||
641 | 123 | buffer_stream.secure_client_buffer(); | 123 | buffer_stream.secure_client_buffer(); |
642 | 124 | } | 124 | } |
643 | 125 | |||
644 | 126 | TEST_F(BufferStreamTest, allow_framedropping_command) | ||
645 | 127 | { | ||
646 | 128 | EXPECT_CALL(*mock_bundle, allow_framedropping(true)) | ||
647 | 129 | .Times(1); | ||
648 | 130 | |||
649 | 131 | mc::BufferStreamSurfaces buffer_stream(mock_bundle); | ||
650 | 132 | buffer_stream.allow_framedropping(true); | ||
651 | 133 | } | ||
652 | 125 | 134 | ||
653 | === modified file 'tests/unit-tests/compositor/test_swapper_factory.cpp' | |||
654 | --- tests/unit-tests/compositor/test_swapper_factory.cpp 2013-06-11 19:55:10 +0000 | |||
655 | +++ tests/unit-tests/compositor/test_swapper_factory.cpp 2013-06-25 19:32:30 +0000 | |||
656 | @@ -147,6 +147,7 @@ | |||
657 | 147 | { | 147 | { |
658 | 148 | using namespace testing; | 148 | using namespace testing; |
659 | 149 | 149 | ||
660 | 150 | mc::BufferProperties properties; | ||
661 | 150 | std::vector<std::shared_ptr<mc::Buffer>> list {}; | 151 | std::vector<std::shared_ptr<mc::Buffer>> list {}; |
662 | 151 | size_t size = 3; | 152 | size_t size = 3; |
663 | 152 | 153 | ||
664 | @@ -154,19 +155,66 @@ | |||
665 | 154 | .Times(0); | 155 | .Times(0); |
666 | 155 | 156 | ||
667 | 156 | mc::SwapperFactory strategy(mock_buffer_allocator); | 157 | mc::SwapperFactory strategy(mock_buffer_allocator); |
669 | 157 | auto swapper = strategy.create_swapper_reuse_buffers(list, size, mc::SwapperType::framedropping); | 158 | auto swapper = strategy.create_swapper_reuse_buffers(properties, list, size, mc::SwapperType::framedropping); |
670 | 158 | } | 159 | } |
671 | 159 | 160 | ||
672 | 160 | TEST_F(SwapperFactoryTest, create_sync_reuse) | 161 | TEST_F(SwapperFactoryTest, create_sync_reuse) |
673 | 161 | { | 162 | { |
674 | 162 | using namespace testing; | 163 | using namespace testing; |
675 | 163 | 164 | ||
676 | 165 | mc::BufferProperties properties; | ||
677 | 164 | std::vector<std::shared_ptr<mc::Buffer>> list; | 166 | std::vector<std::shared_ptr<mc::Buffer>> list; |
678 | 165 | size_t size = 3; | 167 | size_t size = 3; |
679 | 166 | 168 | ||
680 | 167 | EXPECT_CALL(*mock_buffer_allocator, alloc_buffer(properties)) | 169 | EXPECT_CALL(*mock_buffer_allocator, alloc_buffer(properties)) |
681 | 168 | .Times(0); | 170 | .Times(0); |
682 | 169 | 171 | ||
683 | 172 | mc::SwapperFactory strategy(mock_buffer_allocator, 3); | ||
684 | 173 | auto swapper = strategy.create_swapper_reuse_buffers(properties, list, size, mc::SwapperType::synchronous); | ||
685 | 174 | } | ||
686 | 175 | |||
687 | 176 | TEST_F(SwapperFactoryTest, reuse_drop_unneeded_buffer) | ||
688 | 177 | { | ||
689 | 178 | using namespace testing; | ||
690 | 179 | |||
691 | 180 | mc::SwapperFactory strategy(mock_buffer_allocator, 2); | ||
692 | 181 | |||
693 | 182 | auto buffer = std::make_shared<mtd::StubBuffer>(); | ||
694 | 183 | { | ||
695 | 184 | size_t size = 3; | ||
696 | 185 | std::vector<std::shared_ptr<mc::Buffer>> list{buffer}; | ||
697 | 186 | |||
698 | 187 | auto swapper = strategy.create_swapper_reuse_buffers( | ||
699 | 188 | properties, list, size, mc::SwapperType::synchronous); | ||
700 | 189 | } | ||
701 | 190 | EXPECT_EQ(1, buffer.use_count()); | ||
702 | 191 | } | ||
703 | 192 | |||
704 | 193 | TEST_F(SwapperFactoryTest, reuse_drop_unneeded_buffer_error) | ||
705 | 194 | { | ||
706 | 195 | using namespace testing; | ||
707 | 196 | |||
708 | 197 | mc::SwapperFactory strategy(mock_buffer_allocator, 2); | ||
709 | 198 | |||
710 | 199 | size_t size = 3; | ||
711 | 200 | std::vector<std::shared_ptr<mc::Buffer>> list{}; | ||
712 | 201 | |||
713 | 202 | EXPECT_THROW({ | ||
714 | 203 | strategy.create_swapper_reuse_buffers( | ||
715 | 204 | properties, list, size, mc::SwapperType::synchronous); | ||
716 | 205 | }, std::logic_error); | ||
717 | 206 | } | ||
718 | 207 | |||
719 | 208 | TEST_F(SwapperFactoryTest, reuse_alloc_additional_buffer_for_framedropping) | ||
720 | 209 | { | ||
721 | 210 | using namespace testing; | ||
722 | 211 | |||
723 | 212 | EXPECT_CALL(*mock_buffer_allocator, alloc_buffer(_)) | ||
724 | 213 | .Times(1); | ||
725 | 170 | mc::SwapperFactory strategy(mock_buffer_allocator); | 214 | mc::SwapperFactory strategy(mock_buffer_allocator); |
727 | 171 | auto swapper = strategy.create_swapper_reuse_buffers(list, size, mc::SwapperType::synchronous); | 215 | |
728 | 216 | size_t size = 2; | ||
729 | 217 | std::vector<std::shared_ptr<mc::Buffer>> list{}; | ||
730 | 218 | auto swapper = strategy.create_swapper_reuse_buffers( | ||
731 | 219 | properties, list, size, mc::SwapperType::framedropping); | ||
732 | 172 | } | 220 | } |
733 | 173 | 221 | ||
734 | === modified file 'tests/unit-tests/compositor/test_switching_bundle.cpp' | |||
735 | --- tests/unit-tests/compositor/test_switching_bundle.cpp 2013-06-13 08:59:25 +0000 | |||
736 | +++ tests/unit-tests/compositor/test_switching_bundle.cpp 2013-06-25 19:32:30 +0000 | |||
737 | @@ -90,7 +90,7 @@ | |||
738 | 90 | .WillOnce(Return(stub_buffer)); | 90 | .WillOnce(Return(stub_buffer)); |
739 | 91 | EXPECT_CALL(*mock_secondary_swapper, client_release(stub_buffer)) | 91 | EXPECT_CALL(*mock_secondary_swapper, client_release(stub_buffer)) |
740 | 92 | .Times(1); | 92 | .Times(1); |
742 | 93 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,_)) | 93 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,_,_)) |
743 | 94 | .Times(1) | 94 | .Times(1) |
744 | 95 | .WillOnce(Return(mock_secondary_swapper)); | 95 | .WillOnce(Return(mock_secondary_swapper)); |
745 | 96 | 96 | ||
746 | @@ -126,7 +126,7 @@ | |||
747 | 126 | .WillOnce(Return(stub_buffer)); | 126 | .WillOnce(Return(stub_buffer)); |
748 | 127 | EXPECT_CALL(*mock_secondary_swapper, compositor_release(stub_buffer)) | 127 | EXPECT_CALL(*mock_secondary_swapper, compositor_release(stub_buffer)) |
749 | 128 | .Times(1); | 128 | .Times(1); |
751 | 129 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,_)) | 129 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,_,_)) |
752 | 130 | .Times(1) | 130 | .Times(1) |
753 | 131 | .WillOnce(Return(mock_secondary_swapper)); | 131 | .WillOnce(Return(mock_secondary_swapper)); |
754 | 132 | 132 | ||
755 | @@ -147,7 +147,7 @@ | |||
756 | 147 | .Times(1); | 147 | .Times(1); |
757 | 148 | EXPECT_CALL(*mock_default_swapper, end_responsibility(_,_)) | 148 | EXPECT_CALL(*mock_default_swapper, end_responsibility(_,_)) |
758 | 149 | .Times(1); | 149 | .Times(1); |
760 | 150 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,mc::SwapperType::framedropping)) | 150 | EXPECT_CALL(*mock_swapper_factory, create_swapper_reuse_buffers(_,_,_,mc::SwapperType::framedropping)) |
761 | 151 | .Times(1) | 151 | .Times(1) |
762 | 152 | .WillOnce(Return(mock_secondary_swapper)); | 152 | .WillOnce(Return(mock_secondary_swapper)); |
763 | 153 | 153 | ||
764 | 154 | 154 | ||
765 | === modified file 'tests/unit-tests/surfaces/test_surface.cpp' | |||
766 | --- tests/unit-tests/surfaces/test_surface.cpp 2013-06-25 05:42:49 +0000 | |||
767 | +++ tests/unit-tests/surfaces/test_surface.cpp 2013-06-25 19:32:30 +0000 | |||
768 | @@ -445,6 +445,18 @@ | |||
769 | 445 | surf.force_requests_to_complete(); | 445 | surf.force_requests_to_complete(); |
770 | 446 | } | 446 | } |
771 | 447 | 447 | ||
772 | 448 | TEST_F(SurfaceCreation, test_surface_allow_framedropping) | ||
773 | 449 | { | ||
774 | 450 | using namespace testing; | ||
775 | 451 | |||
776 | 452 | EXPECT_CALL(*mock_buffer_stream, allow_framedropping(true)) | ||
777 | 453 | .Times(1); | ||
778 | 454 | |||
779 | 455 | ms::Surface surf{surface_name, geom::Point(), mock_buffer_stream, | ||
780 | 456 | std::shared_ptr<mi::InputChannel>(), mock_change_cb}; | ||
781 | 457 | surf.allow_framedropping(true); | ||
782 | 458 | } | ||
783 | 459 | |||
784 | 448 | TEST_F(SurfaceCreation, test_surface_next_buffer_does_not_set_valid_until_second_frame) | 460 | TEST_F(SurfaceCreation, test_surface_next_buffer_does_not_set_valid_until_second_frame) |
785 | 449 | { | 461 | { |
786 | 450 | ms::Surface surf{surface_name, geom::Point(), mock_buffer_stream, | 462 | ms::Surface surf{surface_name, geom::Point(), mock_buffer_stream, |
FAILED: Continuous integration, rev:758 jenkins. qa.ubuntu. com/job/ mir-ci/ 751/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 937/console jenkins. qa.ubuntu. com/job/ mir-clang- raring- amd64-build/ 819/console jenkins. qa.ubuntu. com/job/ mir-raring- amd64-ci/ 236/console jenkins. qa.ubuntu. com/job/ mir-vm- ci-build/ ./distribution= quantal, flavor= amd64/435
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 751/rebuild
http://