Merge lp:~cemil-azizoglu/mir/create-chain-from-render-surface into lp:mir
- create-chain-from-render-surface
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Cemil Azizoglu |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3868 |
Proposed branch: | lp:~cemil-azizoglu/mir/create-chain-from-render-surface |
Merge into: | lp:mir |
Prerequisite: | lp:~cemil-azizoglu/mir/separate_out_render_surface_tests |
Diff against target: |
822 lines (+404/-57) 15 files modified
playground/mir_demo_client_chain_jumping_buffers.c (+19/-10) playground/mir_demo_client_prerendered_frames.c (+12/-4) src/client/error_render_surface.cpp (+11/-4) src/client/error_render_surface.h (+1/-0) src/client/error_stream.cpp (+14/-12) src/client/mir_connection.cpp (+13/-0) src/client/mir_connection.h (+4/-0) src/client/mir_render_surface.h (+1/-0) src/client/mir_render_surface_api.cpp (+15/-0) src/client/render_surface.cpp (+25/-13) src/client/render_surface.h (+3/-0) src/client/symbols.map (+1/-0) src/include/client/mir_toolkit/mir_render_surface.h (+14/-2) tests/acceptance-tests/staging/test_render_surface.cpp (+158/-2) tests/unit-tests/client/test_mir_render_surface.cpp (+113/-10) |
To merge this branch: | bzr merge lp:~cemil-azizoglu/mir/create-chain-from-render-surface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kevin DuBois (community) | Approve | ||
Mir CI Bot | continuous-integration | Approve | |
Review via email: mp+312211@code.launchpad.net |
This proposal supersedes a proposal from 2016-11-30.
Commit message
Get presentation chain from a render surface.
Description of the change
Get presentation chain from a render surface.
I also modified the two presentation chain examples in the playground to use render surfaces.
Mir CI Bot (mir-ci-bot) wrote : | # |
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3857
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3858
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Kevin DuBois (kdub) wrote : | # |
(just repeating myself from email chain)
The signature looks good to me. I think its more straightforward internally and for the client if MirRenderSurface doesn't have one-time factory-like methods (the _get_ ones), but rather there are create/destroy (discussed in email chain). So, I guess on this point, I'm 'needs info' about if we're going to use create/destroy as opposed to get (and can wait for the email chain to figure that out).
Like, the function is described as
+ * Obtain the presentation chain backing a given render surface
but what's really going on is an object is created that has the same lifetime as MirRenderSurface, and it precludes the use of mir_render_
prior problem, may as well fix in this MP:
121: + throw std::runtime_
Recently popped up in one of my MP's I guess the 'standard mir' way is to use BOOST_THROW_
https:/
needs info:
+ EXPECT_THAT(bs2, Eq(nullptr));
Returning an "error object" would seem more appropriate to the mir client api?
needs fixing:
+ auto determine_
+ {
+ int width = -1;
+ int height = -1;
+ mir_render_
+ return {width, height};
+ };
repeated code, and not really needed. The client is not required to create its buffers (or bufferstreams) based from the logical size that the rs has.
Kevin DuBois (kdub) wrote : | # |
Just to clarify, the create/destroy vs get is probably for a followup mp, not part of the 'needs fixing'
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
> (just repeating myself from email chain)
> The signature looks good to me. I think its more straightforward internally
> and for the client if MirRenderSurface doesn't have one-time factory-like
> methods (the _get_ ones), but rather there are create/destroy (discussed in
> email chain). So, I guess on this point, I'm 'needs info' about if we're going
> to use create/destroy as opposed to get (and can wait for the email chain to
> figure that out).
> Like, the function is described as
> + * Obtain the presentation chain backing a given render surface
> but what's really going on is an object is created that has the same lifetime
> as MirRenderSurface, and it precludes the use of
> mir_render_
Ack, will wait for the outcome of the discussion.
>
> prior problem, may as well fix in this MP:
> 121: + throw std::runtime_
> Recently popped up in one of my MP's I guess the 'standard mir' way is to use
> BOOST_THROW_
> https:/
Fixed, also fixed those in error_stream.cpp
>
> needs info:
> + EXPECT_THAT(bs2, Eq(nullptr));
> Returning an "error object" would seem more appropriate to the mir client api?
>
Though seemingly innocent, this will require a bunch of superfluous code changes for not much return (due to the throw coming from render_surface.cpp, not mir_connection.cpp where the error stream code is, along with necessary constructs like the surface_map). There are also other cases where we return nullptr (e.g. in buffer_
> needs fixing:
> + auto determine_
> + {
> + int width = -1;
> + int height = -1;
> + mir_render_
> + return {width, height};
> + };
> repeated code, and not really needed. The client is not required to create its
> buffers (or bufferstreams) based from the logical size that the rs has.
Fixed.
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3859
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3860
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
Did anyone else notice how many related client objects we have now?...
MirSurface
MirBufferStream
MirPresentati
MirRenderSurface
Surely someone who understands what these all are could try and reduce the number? (and shorten their names)
Chris Halse Rogers (raof) wrote : | # |
Of course we could collapse those all into one type, just like we could collapse *all* Mir types into void*.
But each of those types relates to a thing with distinct properties and uses, so the only way you'll reduce the number of types is by conflating two concepts.
Kevin DuBois (kdub) wrote : | # |
> > (just repeating myself from email chain)
> > The signature looks good to me. I think its more straightforward internally
> > and for the client if MirRenderSurface doesn't have one-time factory-like
> > methods (the _get_ ones), but rather there are create/destroy (discussed in
> > email chain). So, I guess on this point, I'm 'needs info' about if we're
> going
> > to use create/destroy as opposed to get (and can wait for the email chain to
> > figure that out).
> > Like, the function is described as
> > + * Obtain the presentation chain backing a given render surface
> > but what's really going on is an object is created that has the same
> lifetime
> > as MirRenderSurface, and it precludes the use of
> > mir_render_
>
> Ack, will wait for the outcome of the discussion.
>
Sure, would even be happy to spike the idea.
> >
> > prior problem, may as well fix in this MP:
> > 121: + throw std::runtime_
> > Recently popped up in one of my MP's I guess the 'standard mir' way is to
> use
> > BOOST_THROW_
> > https:/
>
> Fixed, also fixed those in error_stream.cpp
>
> >
> > needs info:
> > + EXPECT_THAT(bs2, Eq(nullptr));
> > Returning an "error object" would seem more appropriate to the mir client
> api?
> >
>
> Though seemingly innocent, this will require a bunch of superfluous code
> changes for not much return (due to the throw coming from render_surface.cpp,
> not mir_connection.cpp where the error stream code is, along with necessary
> constructs like the surface_map). There are also other cases where we return
> nullptr (e.g. in buffer_
> can more easily do this once, the render surfaces become the authoritative way
> to obtain content (as opposed to being able to do that through MirConnection,
> too).
>
So sounds like something that we will do, once its easier to move the code in src/client. The MirConnection object particularly needs a cleanup to make this easier.
> > needs fixing:
> > + auto determine_
> > + {
> > + int width = -1;
> > + int height = -1;
> > + mir_render_
> > + return {width, height};
> > + };
> > repeated code, and not really needed. The client is not required to create
> its
> > buffers (or bufferstreams) based from the logical size that the rs has.
>
> Fixed.
Kevin DuBois (kdub) : | # |
Kevin DuBois (kdub) wrote : | # |
> Did anyone else notice how many related client objects we have now?...
>
> MirSurface
> MirBufferStream
> MirPresentation
> MirRenderSurface
>
> Surely someone who understands what these all are could try and reduce the
> number? (and shorten their names)
As Chris mentioned, they have different purposes, so they have different names.
As talked about before, the names might be off, but they're hard to move.
MirSurface -> the window, contains input, graphics, etc
MirRenderSurface-> the graphics content
MirPresentation
MirBufferStream -> the legacy type, with swap-based submissions
Now, I think that MirRenderSurface and MirPresentation
MirBufferStream is largely a helper object provided for legacy/convenience reasons. It is built internally on MirPresentation
Kevin DuBois (kdub) wrote : | # |
+ //TODO: Figure out how to handle mir_buffer_
+ // EGL is made to support RSs.
+
I think its also valuable (in terms of saving work) to figure out how to chase the MirBufferUsage field out of MirBufferStream.
(in the same line as https:/
Kevin DuBois (kdub) wrote : | # |
> + //TODO: Figure out how to handle mir_buffer_
> + // EGL is made to support RSs.
> +
>
> I think its also valuable (in terms of saving work) to figure out how to chase
> the MirBufferUsage field out of MirBufferStream.
>
> (in the same line as https:/
> alloc-extension
oh, and maybe not in this MP, as its a bit of a separate discussion ^_^
Preview Diff
1 | === modified file 'playground/mir_demo_client_chain_jumping_buffers.c' | |||
2 | --- playground/mir_demo_client_chain_jumping_buffers.c 2016-11-16 12:50:00 +0000 | |||
3 | +++ playground/mir_demo_client_chain_jumping_buffers.c 2016-12-01 23:49:58 +0000 | |||
4 | @@ -21,6 +21,7 @@ | |||
5 | 21 | #include <mir_toolkit/mir_buffer_stream.h> | 21 | #include <mir_toolkit/mir_buffer_stream.h> |
6 | 22 | #include <mir_toolkit/mir_surface.h> | 22 | #include <mir_toolkit/mir_surface.h> |
7 | 23 | #include <mir_toolkit/mir_presentation_chain.h> | 23 | #include <mir_toolkit/mir_presentation_chain.h> |
8 | 24 | #include <mir_toolkit/mir_render_surface.h> | ||
9 | 24 | #include <mir_toolkit/mir_buffer.h> | 25 | #include <mir_toolkit/mir_buffer.h> |
10 | 25 | #include <mir_toolkit/version.h> | 26 | #include <mir_toolkit/version.h> |
11 | 26 | #include <sys/types.h> | 27 | #include <sys/types.h> |
12 | @@ -174,9 +175,17 @@ | |||
13 | 174 | unsigned int spare_buffer = 0; | 175 | unsigned int spare_buffer = 0; |
14 | 175 | 176 | ||
15 | 176 | MirPresentationChain* chain[num_chains]; | 177 | MirPresentationChain* chain[num_chains]; |
16 | 178 | MirRenderSurface* render_surface[num_chains]; | ||
17 | 177 | for(unsigned int i = 0u; i < num_chains; i++) | 179 | for(unsigned int i = 0u; i < num_chains; i++) |
18 | 178 | { | 180 | { |
20 | 179 | chain[i] = mir_connection_create_presentation_chain_sync(connection); | 181 | render_surface[i] = mir_connection_create_render_surface_sync(connection, chain_width, chain_height); |
21 | 182 | if (!mir_render_surface_is_valid(render_surface[i])) | ||
22 | 183 | { | ||
23 | 184 | printf("could not create render surface\n"); | ||
24 | 185 | return -1; | ||
25 | 186 | } | ||
26 | 187 | |||
27 | 188 | chain[i] = mir_render_surface_get_presentation_chain(render_surface[i]); | ||
28 | 180 | if (!mir_presentation_chain_is_valid(chain[i])) | 189 | if (!mir_presentation_chain_is_valid(chain[i])) |
29 | 181 | { | 190 | { |
30 | 182 | printf("could not create MirPresentationChain\n"); | 191 | printf("could not create MirPresentationChain\n"); |
31 | @@ -193,14 +202,14 @@ | |||
32 | 193 | 202 | ||
33 | 194 | //Arrange a 2x2 grid of chains within surface | 203 | //Arrange a 2x2 grid of chains within surface |
34 | 195 | MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format); | 204 | MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format); |
43 | 196 | mir_surface_spec_add_presentation_chain( | 205 | mir_surface_spec_add_render_surface( |
44 | 197 | spec, chain_width, chain_height, displacement_x, displacement_y, chain[0]); | 206 | spec, render_surface[0], chain_width, chain_height, displacement_x, displacement_y); |
45 | 198 | mir_surface_spec_add_presentation_chain( | 207 | mir_surface_spec_add_render_surface( |
46 | 199 | spec, chain_width, chain_height, chain_width, displacement_y, chain[1]); | 208 | spec, render_surface[1], chain_width, chain_height, chain_width, displacement_y); |
47 | 200 | mir_surface_spec_add_presentation_chain( | 209 | mir_surface_spec_add_render_surface( |
48 | 201 | spec, chain_width, chain_height, displacement_x, chain_height, chain[2]); | 210 | spec, render_surface[2], chain_width, chain_height, displacement_x, chain_height); |
49 | 202 | mir_surface_spec_add_presentation_chain( | 211 | mir_surface_spec_add_render_surface( |
50 | 203 | spec, chain_width, chain_height, chain_width, chain_height, chain[3]); | 212 | spec, render_surface[3], chain_width, chain_height, chain_width, chain_height); |
51 | 204 | MirSurface* surface = mir_surface_create_sync(spec); | 213 | MirSurface* surface = mir_surface_create_sync(spec); |
52 | 205 | mir_surface_spec_release(spec); | 214 | mir_surface_spec_release(spec); |
53 | 206 | 215 | ||
54 | @@ -256,7 +265,7 @@ | |||
55 | 256 | for (unsigned int i = 0u; i < num_buffers; i++) | 265 | for (unsigned int i = 0u; i < num_buffers; i++) |
56 | 257 | mir_buffer_release(buffer_available[i].buffer); | 266 | mir_buffer_release(buffer_available[i].buffer); |
57 | 258 | for (unsigned int i = 0u; i < num_chains; i++) | 267 | for (unsigned int i = 0u; i < num_chains; i++) |
59 | 259 | mir_presentation_chain_release(chain[i]); | 268 | mir_render_surface_release(render_surface[i]); |
60 | 260 | mir_surface_release_sync(surface); | 269 | mir_surface_release_sync(surface); |
61 | 261 | mir_connection_release(connection); | 270 | mir_connection_release(connection); |
62 | 262 | return 0; | 271 | return 0; |
63 | 263 | 272 | ||
64 | === modified file 'playground/mir_demo_client_prerendered_frames.c' | |||
65 | --- playground/mir_demo_client_prerendered_frames.c 2016-11-16 12:50:00 +0000 | |||
66 | +++ playground/mir_demo_client_prerendered_frames.c 2016-12-01 23:49:58 +0000 | |||
67 | @@ -21,6 +21,7 @@ | |||
68 | 21 | #include <mir_toolkit/mir_buffer_stream.h> | 21 | #include <mir_toolkit/mir_buffer_stream.h> |
69 | 22 | #include <mir_toolkit/mir_surface.h> | 22 | #include <mir_toolkit/mir_surface.h> |
70 | 23 | #include <mir_toolkit/mir_presentation_chain.h> | 23 | #include <mir_toolkit/mir_presentation_chain.h> |
71 | 24 | #include <mir_toolkit/mir_render_surface.h> | ||
72 | 24 | #include <mir_toolkit/mir_buffer.h> | 25 | #include <mir_toolkit/mir_buffer.h> |
73 | 25 | #include <mir_toolkit/version.h> | 26 | #include <mir_toolkit/version.h> |
74 | 26 | #include <sys/types.h> | 27 | #include <sys/types.h> |
75 | @@ -146,7 +147,14 @@ | |||
76 | 146 | return -1; | 147 | return -1; |
77 | 147 | } | 148 | } |
78 | 148 | 149 | ||
80 | 149 | MirPresentationChain* chain = mir_connection_create_presentation_chain_sync(connection); | 150 | MirRenderSurface* render_surface = mir_connection_create_render_surface_sync(connection, width, height); |
81 | 151 | if (!mir_render_surface_is_valid(render_surface)) | ||
82 | 152 | { | ||
83 | 153 | printf("could not create a render surface\n"); | ||
84 | 154 | return -1; | ||
85 | 155 | } | ||
86 | 156 | |||
87 | 157 | MirPresentationChain* chain = mir_render_surface_get_presentation_chain(render_surface); | ||
88 | 150 | if (!mir_presentation_chain_is_valid(chain)) | 158 | if (!mir_presentation_chain_is_valid(chain)) |
89 | 151 | { | 159 | { |
90 | 152 | printf("could not create MirPresentationChain\n"); | 160 | printf("could not create MirPresentationChain\n"); |
91 | @@ -161,8 +169,8 @@ | |||
92 | 161 | } | 169 | } |
93 | 162 | 170 | ||
94 | 163 | MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format); | 171 | MirSurfaceSpec* spec = mir_connection_create_spec_for_normal_surface(connection, width, height, format); |
97 | 164 | mir_surface_spec_add_presentation_chain( | 172 | mir_surface_spec_add_render_surface( |
98 | 165 | spec, width, height, displacement_x, displacement_y, chain); | 173 | spec, render_surface, width, height, displacement_x, displacement_y); |
99 | 166 | MirSurface* surface = mir_surface_create_sync(spec); | 174 | MirSurface* surface = mir_surface_create_sync(spec); |
100 | 167 | if (!mir_surface_is_valid(surface)) | 175 | if (!mir_surface_is_valid(surface)) |
101 | 168 | { | 176 | { |
102 | @@ -224,7 +232,7 @@ | |||
103 | 224 | 232 | ||
104 | 225 | for (i = 0u; i < num_prerendered_frames; i++) | 233 | for (i = 0u; i < num_prerendered_frames; i++) |
105 | 226 | mir_buffer_release(buffer_available[i].buffer); | 234 | mir_buffer_release(buffer_available[i].buffer); |
107 | 227 | mir_presentation_chain_release(chain); | 235 | mir_render_surface_release(render_surface); |
108 | 228 | mir_surface_release_sync(surface); | 236 | mir_surface_release_sync(surface); |
109 | 229 | mir_connection_release(connection); | 237 | mir_connection_release(connection); |
110 | 230 | return 0; | 238 | return 0; |
111 | 231 | 239 | ||
112 | === modified file 'src/client/error_render_surface.cpp' | |||
113 | --- src/client/error_render_surface.cpp 2016-11-22 18:44:52 +0000 | |||
114 | +++ src/client/error_render_surface.cpp 2016-12-01 23:49:58 +0000 | |||
115 | @@ -18,6 +18,8 @@ | |||
116 | 18 | 18 | ||
117 | 19 | #include "error_render_surface.h" | 19 | #include "error_render_surface.h" |
118 | 20 | 20 | ||
119 | 21 | #include <boost/throw_exception.hpp> | ||
120 | 22 | |||
121 | 21 | namespace mcl = mir::client; | 23 | namespace mcl = mir::client; |
122 | 22 | 24 | ||
123 | 23 | mcl::ErrorRenderSurface::ErrorRenderSurface( | 25 | mcl::ErrorRenderSurface::ErrorRenderSurface( |
124 | @@ -34,17 +36,17 @@ | |||
125 | 34 | 36 | ||
126 | 35 | mir::frontend::BufferStreamId mcl::ErrorRenderSurface::stream_id() const | 37 | mir::frontend::BufferStreamId mcl::ErrorRenderSurface::stream_id() const |
127 | 36 | { | 38 | { |
129 | 37 | throw std::runtime_error(error); | 39 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
130 | 38 | } | 40 | } |
131 | 39 | 41 | ||
132 | 40 | mir::geometry::Size mcl::ErrorRenderSurface::size() const | 42 | mir::geometry::Size mcl::ErrorRenderSurface::size() const |
133 | 41 | { | 43 | { |
135 | 42 | throw std::runtime_error(error); | 44 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
136 | 43 | } | 45 | } |
137 | 44 | 46 | ||
138 | 45 | void mcl::ErrorRenderSurface::set_size(mir::geometry::Size /*size*/) | 47 | void mcl::ErrorRenderSurface::set_size(mir::geometry::Size /*size*/) |
139 | 46 | { | 48 | { |
141 | 47 | throw std::runtime_error(error); | 49 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
142 | 48 | } | 50 | } |
143 | 49 | 51 | ||
144 | 50 | bool mcl::ErrorRenderSurface::valid() const | 52 | bool mcl::ErrorRenderSurface::valid() const |
145 | @@ -57,7 +59,12 @@ | |||
146 | 57 | MirPixelFormat /*format*/, | 59 | MirPixelFormat /*format*/, |
147 | 58 | MirBufferUsage /*buffer_usage*/) | 60 | MirBufferUsage /*buffer_usage*/) |
148 | 59 | { | 61 | { |
150 | 60 | throw std::runtime_error(error); | 62 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
151 | 63 | } | ||
152 | 64 | |||
153 | 65 | MirPresentationChain* mcl::ErrorRenderSurface::get_presentation_chain() | ||
154 | 66 | { | ||
155 | 67 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); | ||
156 | 61 | } | 68 | } |
157 | 62 | 69 | ||
158 | 63 | char const* mcl::ErrorRenderSurface::get_error_message() const | 70 | char const* mcl::ErrorRenderSurface::get_error_message() const |
159 | 64 | 71 | ||
160 | === modified file 'src/client/error_render_surface.h' | |||
161 | --- src/client/error_render_surface.h 2016-11-22 18:44:52 +0000 | |||
162 | +++ src/client/error_render_surface.h 2016-12-01 23:49:58 +0000 | |||
163 | @@ -41,6 +41,7 @@ | |||
164 | 41 | int width, int height, | 41 | int width, int height, |
165 | 42 | MirPixelFormat format, | 42 | MirPixelFormat format, |
166 | 43 | MirBufferUsage buffer_usage) override; | 43 | MirBufferUsage buffer_usage) override; |
167 | 44 | MirPresentationChain* get_presentation_chain() override; | ||
168 | 44 | private: | 45 | private: |
169 | 45 | std::string const error; | 46 | std::string const error; |
170 | 46 | MirConnection* const connection_; | 47 | MirConnection* const connection_; |
171 | 47 | 48 | ||
172 | === modified file 'src/client/error_stream.cpp' | |||
173 | --- src/client/error_stream.cpp 2016-11-14 21:59:19 +0000 | |||
174 | +++ src/client/error_stream.cpp 2016-12-01 23:49:58 +0000 | |||
175 | @@ -18,6 +18,8 @@ | |||
176 | 18 | 18 | ||
177 | 19 | #include "error_stream.h" | 19 | #include "error_stream.h" |
178 | 20 | 20 | ||
179 | 21 | #include <boost/throw_exception.hpp> | ||
180 | 22 | |||
181 | 21 | namespace mcl = mir::client; | 23 | namespace mcl = mir::client; |
182 | 22 | 24 | ||
183 | 23 | mcl::ErrorStream::ErrorStream( | 25 | mcl::ErrorStream::ErrorStream( |
184 | @@ -57,53 +59,53 @@ | |||
185 | 57 | 59 | ||
186 | 58 | MirSurfaceParameters mcl::ErrorStream::get_parameters() const | 60 | MirSurfaceParameters mcl::ErrorStream::get_parameters() const |
187 | 59 | { | 61 | { |
189 | 60 | throw std::runtime_error(error); | 62 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
190 | 61 | } | 63 | } |
191 | 62 | std::shared_ptr<mcl::ClientBuffer> mcl::ErrorStream::get_current_buffer() | 64 | std::shared_ptr<mcl::ClientBuffer> mcl::ErrorStream::get_current_buffer() |
192 | 63 | { | 65 | { |
194 | 64 | throw std::runtime_error(error); | 66 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
195 | 65 | } | 67 | } |
196 | 66 | uint32_t mcl::ErrorStream::get_current_buffer_id() | 68 | uint32_t mcl::ErrorStream::get_current_buffer_id() |
197 | 67 | { | 69 | { |
199 | 68 | throw std::runtime_error(error); | 70 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
200 | 69 | } | 71 | } |
201 | 70 | EGLNativeWindowType mcl::ErrorStream::egl_native_window() | 72 | EGLNativeWindowType mcl::ErrorStream::egl_native_window() |
202 | 71 | { | 73 | { |
204 | 72 | throw std::runtime_error(error); | 74 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
205 | 73 | } | 75 | } |
206 | 74 | MirWaitHandle* mcl::ErrorStream::next_buffer(std::function<void()> const&) | 76 | MirWaitHandle* mcl::ErrorStream::next_buffer(std::function<void()> const&) |
207 | 75 | { | 77 | { |
209 | 76 | throw std::runtime_error(error); | 78 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
210 | 77 | } | 79 | } |
211 | 78 | std::shared_ptr<mcl::MemoryRegion> mcl::ErrorStream::secure_for_cpu_write() | 80 | std::shared_ptr<mcl::MemoryRegion> mcl::ErrorStream::secure_for_cpu_write() |
212 | 79 | { | 81 | { |
214 | 80 | throw std::runtime_error(error); | 82 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
215 | 81 | } | 83 | } |
216 | 82 | 84 | ||
217 | 83 | int mcl::ErrorStream::swap_interval() const | 85 | int mcl::ErrorStream::swap_interval() const |
218 | 84 | { | 86 | { |
220 | 85 | throw std::runtime_error(error); | 87 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
221 | 86 | } | 88 | } |
222 | 87 | MirWaitHandle* mcl::ErrorStream::set_swap_interval(int) | 89 | MirWaitHandle* mcl::ErrorStream::set_swap_interval(int) |
223 | 88 | { | 90 | { |
225 | 89 | throw std::runtime_error(error); | 91 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
226 | 90 | } | 92 | } |
227 | 91 | MirNativeBuffer* mcl::ErrorStream::get_current_buffer_package() | 93 | MirNativeBuffer* mcl::ErrorStream::get_current_buffer_package() |
228 | 92 | { | 94 | { |
230 | 93 | throw std::runtime_error(error); | 95 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
231 | 94 | } | 96 | } |
232 | 95 | MirPlatformType mcl::ErrorStream::platform_type() | 97 | MirPlatformType mcl::ErrorStream::platform_type() |
233 | 96 | { | 98 | { |
235 | 97 | throw std::runtime_error(error); | 99 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
236 | 98 | } | 100 | } |
237 | 99 | MirWaitHandle* mcl::ErrorStream::set_scale(float) | 101 | MirWaitHandle* mcl::ErrorStream::set_scale(float) |
238 | 100 | { | 102 | { |
240 | 101 | throw std::runtime_error(error); | 103 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
241 | 102 | } | 104 | } |
242 | 103 | 105 | ||
243 | 104 | mir::geometry::Size mcl::ErrorStream::size() const | 106 | mir::geometry::Size mcl::ErrorStream::size() const |
244 | 105 | { | 107 | { |
246 | 106 | throw std::runtime_error(error); | 108 | BOOST_THROW_EXCEPTION(std::runtime_error(error)); |
247 | 107 | } | 109 | } |
248 | 108 | 110 | ||
249 | 109 | void mcl::ErrorStream::buffer_available(mir::protobuf::Buffer const&) {} | 111 | void mcl::ErrorStream::buffer_available(mir::protobuf::Buffer const&) {} |
250 | 110 | 112 | ||
251 | === modified file 'src/client/mir_connection.cpp' | |||
252 | --- src/client/mir_connection.cpp 2016-11-30 09:18:39 +0000 | |||
253 | +++ src/client/mir_connection.cpp 2016-12-01 23:49:58 +0000 | |||
254 | @@ -1172,6 +1172,19 @@ | |||
255 | 1172 | return display_configuration->take_snapshot(); | 1172 | return display_configuration->take_snapshot(); |
256 | 1173 | } | 1173 | } |
257 | 1174 | 1174 | ||
258 | 1175 | std::shared_ptr<mcl::PresentationChain> MirConnection::create_presentation_chain_with_id( | ||
259 | 1176 | MirRenderSurface* render_surface, | ||
260 | 1177 | mir::protobuf::BufferStream const& a_protobuf_bs) | ||
261 | 1178 | { | ||
262 | 1179 | if (!client_buffer_factory) | ||
263 | 1180 | client_buffer_factory = platform->create_buffer_factory(); | ||
264 | 1181 | auto chain = std::make_shared<mcl::PresentationChain>( | ||
265 | 1182 | this, a_protobuf_bs.id().value(), server, client_buffer_factory, buffer_factory); | ||
266 | 1183 | |||
267 | 1184 | surface_map->insert(render_surface->stream_id(), chain); | ||
268 | 1185 | return chain; | ||
269 | 1186 | } | ||
270 | 1187 | |||
271 | 1175 | void MirConnection::create_presentation_chain( | 1188 | void MirConnection::create_presentation_chain( |
272 | 1176 | mir_presentation_chain_callback callback, | 1189 | mir_presentation_chain_callback callback, |
273 | 1177 | void *context) | 1190 | void *context) |
274 | 1178 | 1191 | ||
275 | === modified file 'src/client/mir_connection.h' | |||
276 | --- src/client/mir_connection.h 2016-11-30 09:02:39 +0000 | |||
277 | +++ src/client/mir_connection.h 2016-12-01 23:49:58 +0000 | |||
278 | @@ -66,6 +66,7 @@ | |||
279 | 66 | class AsyncBufferFactory; | 66 | class AsyncBufferFactory; |
280 | 67 | class MirBuffer; | 67 | class MirBuffer; |
281 | 68 | class BufferStream; | 68 | class BufferStream; |
282 | 69 | class PresentationChain; | ||
283 | 69 | 70 | ||
284 | 70 | namespace rpc | 71 | namespace rpc |
285 | 71 | { | 72 | { |
286 | @@ -169,6 +170,9 @@ | |||
287 | 169 | void create_presentation_chain( | 170 | void create_presentation_chain( |
288 | 170 | mir_presentation_chain_callback callback, | 171 | mir_presentation_chain_callback callback, |
289 | 171 | void *context); | 172 | void *context); |
290 | 173 | std::shared_ptr<mir::client::PresentationChain> create_presentation_chain_with_id( | ||
291 | 174 | MirRenderSurface* render_surface, | ||
292 | 175 | mir::protobuf::BufferStream const& a_protobuf_bs); | ||
293 | 172 | void release_presentation_chain(MirPresentationChain* context); | 176 | void release_presentation_chain(MirPresentationChain* context); |
294 | 173 | 177 | ||
295 | 174 | void release_consumer_stream(MirBufferStream*); | 178 | void release_consumer_stream(MirBufferStream*); |
296 | 175 | 179 | ||
297 | === modified file 'src/client/mir_render_surface.h' | |||
298 | --- src/client/mir_render_surface.h 2016-11-22 18:44:52 +0000 | |||
299 | +++ src/client/mir_render_surface.h 2016-12-01 23:49:58 +0000 | |||
300 | @@ -36,6 +36,7 @@ | |||
301 | 36 | int width, int height, | 36 | int width, int height, |
302 | 37 | MirPixelFormat format, | 37 | MirPixelFormat format, |
303 | 38 | MirBufferUsage buffer_usage) = 0; | 38 | MirBufferUsage buffer_usage) = 0; |
304 | 39 | virtual MirPresentationChain* get_presentation_chain() = 0; | ||
305 | 39 | virtual char const* get_error_message() const = 0; | 40 | virtual char const* get_error_message() const = 0; |
306 | 40 | virtual ~MirRenderSurface() = default; | 41 | virtual ~MirRenderSurface() = default; |
307 | 41 | protected: | 42 | protected: |
308 | 42 | 43 | ||
309 | === modified file 'src/client/mir_render_surface_api.cpp' | |||
310 | --- src/client/mir_render_surface_api.cpp 2016-11-29 14:18:01 +0000 | |||
311 | +++ src/client/mir_render_surface_api.cpp 2016-12-01 23:49:58 +0000 | |||
312 | @@ -189,6 +189,21 @@ | |||
313 | 189 | return nullptr; | 189 | return nullptr; |
314 | 190 | } | 190 | } |
315 | 191 | 191 | ||
316 | 192 | MirPresentationChain* mir_render_surface_get_presentation_chain( | ||
317 | 193 | MirRenderSurface* render_surface) | ||
318 | 194 | try | ||
319 | 195 | { | ||
320 | 196 | mir::require(render_surface); | ||
321 | 197 | auto connection = connection_map.connection(static_cast<void*>(render_surface)); | ||
322 | 198 | auto rs = connection->connection_surface_map()->render_surface(render_surface); | ||
323 | 199 | return rs->get_presentation_chain(); | ||
324 | 200 | } | ||
325 | 201 | catch (std::exception const& ex) | ||
326 | 202 | { | ||
327 | 203 | MIR_LOG_UNCAUGHT_EXCEPTION(ex); | ||
328 | 204 | return nullptr; | ||
329 | 205 | } | ||
330 | 206 | |||
331 | 192 | void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height) | 207 | void mir_render_surface_get_size(MirRenderSurface* render_surface, int* width, int* height) |
332 | 193 | { | 208 | { |
333 | 194 | mir::require(render_surface && width && height); | 209 | mir::require(render_surface && width && height); |
334 | 195 | 210 | ||
335 | === modified file 'src/client/render_surface.cpp' | |||
336 | --- src/client/render_surface.cpp 2016-11-30 09:18:39 +0000 | |||
337 | +++ src/client/render_surface.cpp 2016-12-01 23:49:58 +0000 | |||
338 | @@ -27,7 +27,6 @@ | |||
339 | 27 | #include <boost/throw_exception.hpp> | 27 | #include <boost/throw_exception.hpp> |
340 | 28 | 28 | ||
341 | 29 | namespace mcl = mir::client; | 29 | namespace mcl = mir::client; |
342 | 30 | namespace mclr = mcl::rpc; | ||
343 | 31 | namespace geom = mir::geometry; | 30 | namespace geom = mir::geometry; |
344 | 32 | namespace mp = mir::protobuf; | 31 | namespace mp = mir::protobuf; |
345 | 33 | namespace mf = mir::frontend; | 32 | namespace mf = mir::frontend; |
346 | @@ -61,24 +60,37 @@ | |||
347 | 61 | MirPixelFormat format, | 60 | MirPixelFormat format, |
348 | 62 | MirBufferUsage buffer_usage) | 61 | MirBufferUsage buffer_usage) |
349 | 63 | { | 62 | { |
351 | 64 | if (!stream_from_id) | 63 | if (chain_from_id || stream_from_id) |
352 | 64 | BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out")); | ||
353 | 65 | |||
354 | 66 | protobuf_bs->set_pixel_format(format); | ||
355 | 67 | protobuf_bs->set_buffer_usage(buffer_usage); | ||
356 | 68 | stream_from_id = connection_->create_client_buffer_stream_with_id(width, | ||
357 | 69 | height, | ||
358 | 70 | this, | ||
359 | 71 | *protobuf_bs); | ||
360 | 72 | if (buffer_usage == mir_buffer_usage_hardware) | ||
361 | 65 | { | 73 | { |
373 | 66 | protobuf_bs->set_pixel_format(format); | 74 | platform->use_egl_native_window( |
374 | 67 | protobuf_bs->set_buffer_usage(buffer_usage); | 75 | wrapped_native_window, dynamic_cast<EGLNativeSurface*>(stream_from_id.get())); |
364 | 68 | stream_from_id = connection_->create_client_buffer_stream_with_id(width, | ||
365 | 69 | height, | ||
366 | 70 | this, | ||
367 | 71 | *protobuf_bs); | ||
368 | 72 | if (buffer_usage == mir_buffer_usage_hardware) | ||
369 | 73 | { | ||
370 | 74 | platform->use_egl_native_window( | ||
371 | 75 | wrapped_native_window, dynamic_cast<EGLNativeSurface*>(stream_from_id.get())); | ||
372 | 76 | } | ||
375 | 77 | } | 76 | } |
376 | 78 | 77 | ||
377 | 79 | return stream_from_id.get(); | 78 | return stream_from_id.get(); |
378 | 80 | } | 79 | } |
379 | 81 | 80 | ||
380 | 81 | MirPresentationChain* mcl::RenderSurface::get_presentation_chain() | ||
381 | 82 | { | ||
382 | 83 | if (chain_from_id || stream_from_id) | ||
383 | 84 | BOOST_THROW_EXCEPTION(std::logic_error("Content already handed out")); | ||
384 | 85 | |||
385 | 86 | chain_from_id = connection_->create_presentation_chain_with_id(this, | ||
386 | 87 | *protobuf_bs); | ||
387 | 88 | //TODO: Figure out how to handle mir_buffer_usage_hardware once | ||
388 | 89 | // EGL is made to support RSs. | ||
389 | 90 | |||
390 | 91 | return reinterpret_cast<MirPresentationChain*>(chain_from_id.get()); | ||
391 | 92 | } | ||
392 | 93 | |||
393 | 82 | geom::Size mcl::RenderSurface::size() const | 94 | geom::Size mcl::RenderSurface::size() const |
394 | 83 | { | 95 | { |
395 | 84 | std::lock_guard<decltype(size_mutex)> lk(size_mutex); | 96 | std::lock_guard<decltype(size_mutex)> lk(size_mutex); |
396 | 85 | 97 | ||
397 | === modified file 'src/client/render_surface.h' | |||
398 | --- src/client/render_surface.h 2016-11-22 18:44:52 +0000 | |||
399 | +++ src/client/render_surface.h 2016-12-01 23:49:58 +0000 | |||
400 | @@ -39,6 +39,7 @@ | |||
401 | 39 | { | 39 | { |
402 | 40 | class ClientPlatform; | 40 | class ClientPlatform; |
403 | 41 | class BufferStream; | 41 | class BufferStream; |
404 | 42 | class PresentationChain; | ||
405 | 42 | class RenderSurface : public MirRenderSurface | 43 | class RenderSurface : public MirRenderSurface |
406 | 43 | { | 44 | { |
407 | 44 | public: | 45 | public: |
408 | @@ -57,6 +58,7 @@ | |||
409 | 57 | int width, int height, | 58 | int width, int height, |
410 | 58 | MirPixelFormat format, | 59 | MirPixelFormat format, |
411 | 59 | MirBufferUsage buffer_usage) override; | 60 | MirBufferUsage buffer_usage) override; |
412 | 61 | MirPresentationChain* get_presentation_chain() override; | ||
413 | 60 | 62 | ||
414 | 61 | private: | 63 | private: |
415 | 62 | MirConnection* const connection_; | 64 | MirConnection* const connection_; |
416 | @@ -64,6 +66,7 @@ | |||
417 | 64 | std::shared_ptr<ClientPlatform> platform; | 66 | std::shared_ptr<ClientPlatform> platform; |
418 | 65 | std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs; | 67 | std::shared_ptr<mir::protobuf::BufferStream> protobuf_bs; |
419 | 66 | std::shared_ptr<mir::client::BufferStream> stream_from_id; | 68 | std::shared_ptr<mir::client::BufferStream> stream_from_id; |
420 | 69 | std::shared_ptr<mir::client::PresentationChain> chain_from_id; | ||
421 | 67 | 70 | ||
422 | 68 | std::mutex mutable size_mutex; | 71 | std::mutex mutable size_mutex; |
423 | 69 | geometry::Size desired_size; | 72 | geometry::Size desired_size; |
424 | 70 | 73 | ||
425 | === modified file 'src/client/symbols.map' | |||
426 | --- src/client/symbols.map 2016-12-01 18:48:07 +0000 | |||
427 | +++ src/client/symbols.map 2016-12-01 23:49:58 +0000 | |||
428 | @@ -390,6 +390,7 @@ | |||
429 | 390 | mir_connection_create_render_surface; | 390 | mir_connection_create_render_surface; |
430 | 391 | mir_connection_create_render_surface_sync; | 391 | mir_connection_create_render_surface_sync; |
431 | 392 | mir_render_surface_get_buffer_stream; | 392 | mir_render_surface_get_buffer_stream; |
432 | 393 | mir_render_surface_get_presentation_chain; | ||
433 | 393 | mir_render_surface_is_valid; | 394 | mir_render_surface_is_valid; |
434 | 394 | mir_render_surface_get_error_message; | 395 | mir_render_surface_get_error_message; |
435 | 395 | mir_render_surface_get_size; | 396 | mir_render_surface_get_size; |
436 | 396 | 397 | ||
437 | === modified file 'src/include/client/mir_toolkit/mir_render_surface.h' | |||
438 | --- src/include/client/mir_toolkit/mir_render_surface.h 2016-11-29 14:18:01 +0000 | |||
439 | +++ src/include/client/mir_toolkit/mir_render_surface.h 2016-12-01 23:49:58 +0000 | |||
440 | @@ -125,6 +125,9 @@ | |||
441 | 125 | * \param [in] usage Requested buffer usage | 125 | * \param [in] usage Requested buffer usage |
442 | 126 | * | 126 | * |
443 | 127 | * \return The buffer stream contained in the given render surface | 127 | * \return The buffer stream contained in the given render surface |
444 | 128 | * or 'nullptr' if it, or | ||
445 | 129 | * mir_render_surface_get_presentation_chain(), has already | ||
446 | 130 | * been called once | ||
447 | 128 | */ | 131 | */ |
448 | 129 | MirBufferStream* mir_render_surface_get_buffer_stream( | 132 | MirBufferStream* mir_render_surface_get_buffer_stream( |
449 | 130 | MirRenderSurface* render_surface, | 133 | MirRenderSurface* render_surface, |
450 | @@ -133,13 +136,22 @@ | |||
451 | 133 | MirBufferUsage usage); | 136 | MirBufferUsage usage); |
452 | 134 | 137 | ||
453 | 135 | /** | 138 | /** |
454 | 139 | * Obtain the presentation chain backing a given render surface | ||
455 | 140 | * | ||
456 | 141 | * \return The chain contained in the given render surface | ||
457 | 142 | * or 'nullptr' if it, or | ||
458 | 143 | * mir_render_surface_get_buffer_stream(), has already | ||
459 | 144 | * been called once | ||
460 | 145 | */ | ||
461 | 146 | MirPresentationChain* mir_render_surface_get_presentation_chain( | ||
462 | 147 | MirRenderSurface* render_surface); | ||
463 | 148 | |||
464 | 149 | /** | ||
465 | 136 | * Set the MirSurfaceSpec to display content contained in a render surface | 150 | * Set the MirSurfaceSpec to display content contained in a render surface |
466 | 137 | * | 151 | * |
467 | 138 | * \warning: The initial call to mir_surface_spec_add_render_surface will set | 152 | * \warning: The initial call to mir_surface_spec_add_render_surface will set |
468 | 139 | * the bottom-most content, and subsequent calls will stack the | 153 | * the bottom-most content, and subsequent calls will stack the |
469 | 140 | * content on top. | 154 | * content on top. |
470 | 141 | * \warning: It's an error to call this function with a render surface | ||
471 | 142 | * that holds no content. | ||
472 | 143 | * | 155 | * |
473 | 144 | * \param spec The surface_spec to be updated | 156 | * \param spec The surface_spec to be updated |
474 | 145 | * \param render_surface The render surface containing the content to be displayed | 157 | * \param render_surface The render surface containing the content to be displayed |
475 | 146 | 158 | ||
476 | === modified file 'tests/acceptance-tests/staging/test_render_surface.cpp' | |||
477 | --- tests/acceptance-tests/staging/test_render_surface.cpp 2016-11-29 22:59:26 +0000 | |||
478 | +++ tests/acceptance-tests/staging/test_render_surface.cpp 2016-12-01 23:49:58 +0000 | |||
479 | @@ -18,6 +18,7 @@ | |||
480 | 18 | 18 | ||
481 | 19 | #include "mir_toolkit/mir_client_library.h" | 19 | #include "mir_toolkit/mir_client_library.h" |
482 | 20 | #include "mir_toolkit/mir_render_surface.h" | 20 | #include "mir_toolkit/mir_render_surface.h" |
483 | 21 | #include "mir_toolkit/mir_presentation_chain.h" | ||
484 | 21 | 22 | ||
485 | 22 | #include "mir/geometry/size.h" | 23 | #include "mir/geometry/size.h" |
486 | 23 | #include "mir_test_framework/headless_in_process_server.h" | 24 | #include "mir_test_framework/headless_in_process_server.h" |
487 | @@ -57,7 +58,7 @@ | |||
488 | 57 | mir_connection_release(connection); | 58 | mir_connection_release(connection); |
489 | 58 | } | 59 | } |
490 | 59 | 60 | ||
492 | 60 | TEST_F(RenderSurfaceTest, can_hand_out_buffer_streams) | 61 | TEST_F(RenderSurfaceTest, can_hand_out_buffer_stream) |
493 | 61 | { | 62 | { |
494 | 62 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | 63 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); |
495 | 63 | 64 | ||
496 | @@ -86,6 +87,36 @@ | |||
497 | 86 | mir_connection_release(connection); | 87 | mir_connection_release(connection); |
498 | 87 | } | 88 | } |
499 | 88 | 89 | ||
500 | 90 | TEST_F(RenderSurfaceTest, hands_out_buffer_stream_only_once) | ||
501 | 91 | { | ||
502 | 92 | auto physical_size = logical_size; | ||
503 | 93 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
504 | 94 | |||
505 | 95 | auto rs = mir_connection_create_render_surface_sync( | ||
506 | 96 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
507 | 97 | |||
508 | 98 | auto bs = mir_render_surface_get_buffer_stream( | ||
509 | 99 | rs, | ||
510 | 100 | physical_size.width.as_int(), physical_size.height.as_int(), | ||
511 | 101 | mir_pixel_format_abgr_8888, | ||
512 | 102 | mir_buffer_usage_hardware); | ||
513 | 103 | |||
514 | 104 | ASSERT_THAT(bs, NotNull()); | ||
515 | 105 | EXPECT_TRUE(mir_buffer_stream_is_valid(bs)); | ||
516 | 106 | EXPECT_THAT(mir_buffer_stream_get_error_message(bs), StrEq("")); | ||
517 | 107 | |||
518 | 108 | auto bs2 = mir_render_surface_get_buffer_stream( | ||
519 | 109 | rs, | ||
520 | 110 | physical_size.width.as_int(), physical_size.height.as_int(), | ||
521 | 111 | mir_pixel_format_abgr_8888, | ||
522 | 112 | mir_buffer_usage_hardware); | ||
523 | 113 | |||
524 | 114 | EXPECT_THAT(bs2, Eq(nullptr)); | ||
525 | 115 | |||
526 | 116 | mir_render_surface_release(rs); | ||
527 | 117 | mir_connection_release(connection); | ||
528 | 118 | } | ||
529 | 119 | |||
530 | 89 | TEST_F(RenderSurfaceTest, dont_have_to_release_buffer_stream) | 120 | TEST_F(RenderSurfaceTest, dont_have_to_release_buffer_stream) |
531 | 90 | { | 121 | { |
532 | 91 | auto physical_size = logical_size; | 122 | auto physical_size = logical_size; |
533 | @@ -131,7 +162,7 @@ | |||
534 | 131 | mir_connection_release(connection); | 162 | mir_connection_release(connection); |
535 | 132 | } | 163 | } |
536 | 133 | 164 | ||
538 | 134 | TEST_F(RenderSurfaceTest, content_can_be_constructed_after_surface_creation) | 165 | TEST_F(RenderSurfaceTest, stream_can_be_constructed_after_surface_creation) |
539 | 135 | { | 166 | { |
540 | 136 | int const width{800}, height{600}; | 167 | int const width{800}, height{600}; |
541 | 137 | MirPixelFormat const format{mir_pixel_format_abgr_8888}; | 168 | MirPixelFormat const format{mir_pixel_format_abgr_8888}; |
542 | @@ -160,3 +191,128 @@ | |||
543 | 160 | mir_surface_release_sync(surface); | 191 | mir_surface_release_sync(surface); |
544 | 161 | mir_connection_release(connection); | 192 | mir_connection_release(connection); |
545 | 162 | } | 193 | } |
546 | 194 | |||
547 | 195 | TEST_F(RenderSurfaceTest, can_hand_out_presentation_chain) | ||
548 | 196 | { | ||
549 | 197 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
550 | 198 | |||
551 | 199 | auto rs = mir_connection_create_render_surface_sync( | ||
552 | 200 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
553 | 201 | |||
554 | 202 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
555 | 203 | |||
556 | 204 | ASSERT_THAT(pc, NotNull()); | ||
557 | 205 | EXPECT_TRUE(mir_presentation_chain_is_valid(pc)); | ||
558 | 206 | |||
559 | 207 | mir_render_surface_release(rs); | ||
560 | 208 | mir_connection_release(connection); | ||
561 | 209 | } | ||
562 | 210 | |||
563 | 211 | TEST_F(RenderSurfaceTest, hands_out_presentation_chain_only_once) | ||
564 | 212 | { | ||
565 | 213 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
566 | 214 | |||
567 | 215 | auto rs = mir_connection_create_render_surface_sync( | ||
568 | 216 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
569 | 217 | |||
570 | 218 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
571 | 219 | |||
572 | 220 | ASSERT_THAT(pc, NotNull()); | ||
573 | 221 | EXPECT_TRUE(mir_presentation_chain_is_valid(pc)); | ||
574 | 222 | |||
575 | 223 | auto pc2 = mir_render_surface_get_presentation_chain(rs); | ||
576 | 224 | |||
577 | 225 | EXPECT_THAT(pc2, Eq(nullptr)); | ||
578 | 226 | |||
579 | 227 | mir_render_surface_release(rs); | ||
580 | 228 | mir_connection_release(connection); | ||
581 | 229 | } | ||
582 | 230 | |||
583 | 231 | TEST_F(RenderSurfaceTest, chain_can_be_constructed_after_surface_creation) | ||
584 | 232 | { | ||
585 | 233 | int const width{800}, height{600}; | ||
586 | 234 | MirPixelFormat const format{mir_pixel_format_abgr_8888}; | ||
587 | 235 | |||
588 | 236 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
589 | 237 | |||
590 | 238 | auto rs = mir_connection_create_render_surface_sync( | ||
591 | 239 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
592 | 240 | auto spec = mir_connection_create_spec_for_normal_surface(connection, | ||
593 | 241 | width, height, | ||
594 | 242 | format); | ||
595 | 243 | mir_surface_spec_add_render_surface(spec, rs, width, height, 0, 0); | ||
596 | 244 | auto surface = mir_surface_create_sync(spec); | ||
597 | 245 | mir_surface_spec_release(spec); | ||
598 | 246 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
599 | 247 | |||
600 | 248 | EXPECT_THAT(surface, IsValid()); | ||
601 | 249 | EXPECT_THAT(mir_surface_get_buffer_stream(surface), Eq(nullptr)); | ||
602 | 250 | EXPECT_TRUE(mir_presentation_chain_is_valid(pc)); | ||
603 | 251 | |||
604 | 252 | mir_render_surface_release(rs); | ||
605 | 253 | mir_surface_release_sync(surface); | ||
606 | 254 | mir_connection_release(connection); | ||
607 | 255 | } | ||
608 | 256 | |||
609 | 257 | TEST_F(RenderSurfaceTest, dont_have_to_release_presentation_chain) | ||
610 | 258 | { | ||
611 | 259 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
612 | 260 | |||
613 | 261 | auto rs = mir_connection_create_render_surface_sync( | ||
614 | 262 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
615 | 263 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
616 | 264 | |||
617 | 265 | ASSERT_THAT(pc, NotNull()); | ||
618 | 266 | EXPECT_TRUE(mir_presentation_chain_is_valid(pc)); | ||
619 | 267 | |||
620 | 268 | mir_render_surface_release(rs); | ||
621 | 269 | mir_connection_release(connection); | ||
622 | 270 | } | ||
623 | 271 | |||
624 | 272 | TEST_F(RenderSurfaceTest, excepts_on_stream_request_if_chain_handed_out) | ||
625 | 273 | { | ||
626 | 274 | auto physical_size = logical_size; | ||
627 | 275 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
628 | 276 | |||
629 | 277 | auto rs = mir_connection_create_render_surface_sync( | ||
630 | 278 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
631 | 279 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
632 | 280 | |||
633 | 281 | ASSERT_THAT(pc, NotNull()); | ||
634 | 282 | EXPECT_TRUE(mir_presentation_chain_is_valid(pc)); | ||
635 | 283 | |||
636 | 284 | auto bs = mir_render_surface_get_buffer_stream( | ||
637 | 285 | rs, | ||
638 | 286 | physical_size.width.as_int(), physical_size.height.as_int(), | ||
639 | 287 | mir_pixel_format_abgr_8888, | ||
640 | 288 | mir_buffer_usage_hardware); | ||
641 | 289 | |||
642 | 290 | EXPECT_THAT(bs, Eq(nullptr)); | ||
643 | 291 | |||
644 | 292 | mir_render_surface_release(rs); | ||
645 | 293 | mir_connection_release(connection); | ||
646 | 294 | } | ||
647 | 295 | |||
648 | 296 | TEST_F(RenderSurfaceTest, excepts_on_chain_request_if_stream_handed_out) | ||
649 | 297 | { | ||
650 | 298 | auto physical_size = logical_size; | ||
651 | 299 | auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); | ||
652 | 300 | |||
653 | 301 | auto rs = mir_connection_create_render_surface_sync( | ||
654 | 302 | connection, logical_size.width.as_int(), logical_size.height.as_int()); | ||
655 | 303 | auto bs = mir_render_surface_get_buffer_stream( | ||
656 | 304 | rs, | ||
657 | 305 | physical_size.width.as_int(), physical_size.height.as_int(), | ||
658 | 306 | mir_pixel_format_abgr_8888, | ||
659 | 307 | mir_buffer_usage_hardware); | ||
660 | 308 | |||
661 | 309 | ASSERT_THAT(bs, NotNull()); | ||
662 | 310 | EXPECT_TRUE(mir_buffer_stream_is_valid(bs)); | ||
663 | 311 | |||
664 | 312 | auto pc = mir_render_surface_get_presentation_chain(rs); | ||
665 | 313 | |||
666 | 314 | EXPECT_THAT(pc, Eq(nullptr)); | ||
667 | 315 | |||
668 | 316 | mir_render_surface_release(rs); | ||
669 | 317 | mir_connection_release(connection); | ||
670 | 318 | } | ||
671 | 163 | 319 | ||
672 | === modified file 'tests/unit-tests/client/test_mir_render_surface.cpp' | |||
673 | --- tests/unit-tests/client/test_mir_render_surface.cpp 2016-11-30 16:58:48 +0000 | |||
674 | +++ tests/unit-tests/client/test_mir_render_surface.cpp 2016-12-01 23:49:58 +0000 | |||
675 | @@ -298,7 +298,7 @@ | |||
676 | 298 | EXPECT_THAT(bs, NotNull()); | 298 | EXPECT_THAT(bs, NotNull()); |
677 | 299 | } | 299 | } |
678 | 300 | 300 | ||
680 | 301 | TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_more_than_once_returns_same_object) | 301 | TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_buffer_stream_more_than_once) |
681 | 302 | { | 302 | { |
682 | 303 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); | 303 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); |
683 | 304 | auto id = 123; | 304 | auto id = 123; |
684 | @@ -316,15 +316,14 @@ | |||
685 | 316 | 316 | ||
686 | 317 | EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_)); | 317 | EXPECT_CALL(*mock_platform, use_egl_native_window(native_window,_)); |
687 | 318 | 318 | ||
697 | 319 | auto bs1 = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, | 319 | auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, |
698 | 320 | mir_buffer_usage_hardware); | 320 | mir_buffer_usage_hardware); |
699 | 321 | 321 | ||
700 | 322 | auto bs2 = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, | 322 | EXPECT_THROW( |
701 | 323 | mir_buffer_usage_hardware); | 323 | { rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, |
702 | 324 | 324 | mir_buffer_usage_hardware); }, | |
703 | 325 | EXPECT_THAT(bs1, NotNull()); | 325 | std::logic_error); |
704 | 326 | EXPECT_THAT(bs2, NotNull()); | 326 | EXPECT_THAT(bs, NotNull()); |
696 | 327 | EXPECT_THAT(bs1, Eq(bs2)); | ||
705 | 328 | } | 327 | } |
706 | 329 | 328 | ||
707 | 330 | TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window) | 329 | TEST_F(MirRenderSurfaceTest, render_surface_creation_of_buffer_stream_with_hardware_usage_installs_new_native_window) |
708 | @@ -394,10 +393,114 @@ | |||
709 | 394 | 393 | ||
710 | 395 | EXPECT_TRUE(callback.invoked); | 394 | EXPECT_TRUE(callback.invoked); |
711 | 396 | EXPECT_THAT(callback.resulting_render_surface, NotNull()); | 395 | EXPECT_THAT(callback.resulting_render_surface, NotNull()); |
712 | 396 | |||
713 | 397 | auto rs = connection->connection_surface_map()->render_surface( | 397 | auto rs = connection->connection_surface_map()->render_surface( |
714 | 398 | static_cast<void*>(callback.resulting_render_surface)); | 398 | static_cast<void*>(callback.resulting_render_surface)); |
715 | 399 | |||
716 | 399 | EXPECT_THAT(rs->get_error_message(), | 400 | EXPECT_THAT(rs->get_error_message(), |
717 | 400 | StrEq("Error processing buffer stream response during render " | 401 | StrEq("Error processing buffer stream response during render " |
718 | 401 | "surface creation: no ID in response (disconnected?)")); | 402 | "surface creation: no ID in response (disconnected?)")); |
719 | 402 | EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid())); | 403 | EXPECT_FALSE(reinterpret_cast<mcl::RenderSurface*>(rs->valid())); |
720 | 403 | } | 404 | } |
721 | 405 | |||
722 | 406 | TEST_F(MirRenderSurfaceTest, render_surface_can_create_presentation_chain) | ||
723 | 407 | { | ||
724 | 408 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); | ||
725 | 409 | auto id = 123; | ||
726 | 410 | |||
727 | 411 | mp::BufferStream protobuf_bs; | ||
728 | 412 | mp::BufferStreamId bs_id; | ||
729 | 413 | |||
730 | 414 | bs_id.set_value(id); | ||
731 | 415 | *protobuf_bs.mutable_id() = bs_id; | ||
732 | 416 | |||
733 | 417 | auto native_window = mock_platform->create_egl_native_window(nullptr); | ||
734 | 418 | |||
735 | 419 | mcl::RenderSurface rs( | ||
736 | 420 | connection.get(), native_window, nullptr, mt::fake_shared(protobuf_bs), {}); | ||
737 | 421 | |||
738 | 422 | auto pc = rs.get_presentation_chain(); | ||
739 | 423 | |||
740 | 424 | EXPECT_THAT(pc, NotNull()); | ||
741 | 425 | } | ||
742 | 426 | |||
743 | 427 | TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_presentation_chain_more_than_once) | ||
744 | 428 | { | ||
745 | 429 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); | ||
746 | 430 | auto id = 123; | ||
747 | 431 | |||
748 | 432 | mp::BufferStream protobuf_bs; | ||
749 | 433 | mp::BufferStreamId bs_id; | ||
750 | 434 | |||
751 | 435 | bs_id.set_value(id); | ||
752 | 436 | *protobuf_bs.mutable_id() = bs_id; | ||
753 | 437 | |||
754 | 438 | auto native_window = mock_platform->create_egl_native_window(nullptr); | ||
755 | 439 | |||
756 | 440 | mcl::RenderSurface rs( | ||
757 | 441 | connection.get(), native_window, mock_platform, mt::fake_shared(protobuf_bs), {}); | ||
758 | 442 | |||
759 | 443 | auto pc = rs.get_presentation_chain(); | ||
760 | 444 | EXPECT_THAT(pc, NotNull()); | ||
761 | 445 | |||
762 | 446 | EXPECT_THROW( | ||
763 | 447 | { rs.get_presentation_chain(); }, | ||
764 | 448 | std::logic_error); | ||
765 | 449 | } | ||
766 | 450 | |||
767 | 451 | TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_chain_after_stream) | ||
768 | 452 | { | ||
769 | 453 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); | ||
770 | 454 | auto id = 123; | ||
771 | 455 | |||
772 | 456 | mp::BufferStream protobuf_bs; | ||
773 | 457 | mp::BufferStreamId bs_id; | ||
774 | 458 | |||
775 | 459 | bs_id.set_value(id); | ||
776 | 460 | *protobuf_bs.mutable_id() = bs_id; | ||
777 | 461 | |||
778 | 462 | auto native_window = mock_platform->create_egl_native_window(nullptr); | ||
779 | 463 | |||
780 | 464 | mcl::RenderSurface rs(connection.get(), | ||
781 | 465 | native_window, | ||
782 | 466 | mock_platform, | ||
783 | 467 | mt::fake_shared(protobuf_bs), | ||
784 | 468 | {}); | ||
785 | 469 | |||
786 | 470 | auto bs = rs.get_buffer_stream(2, 2, mir_pixel_format_abgr_8888, | ||
787 | 471 | mir_buffer_usage_hardware); | ||
788 | 472 | |||
789 | 473 | EXPECT_THAT(bs, NotNull()); | ||
790 | 474 | EXPECT_THROW( | ||
791 | 475 | { rs.get_presentation_chain(); }, | ||
792 | 476 | std::logic_error); | ||
793 | 477 | } | ||
794 | 478 | |||
795 | 479 | TEST_F(MirRenderSurfaceTest, excepts_on_creation_of_stream_after_chain) | ||
796 | 480 | { | ||
797 | 481 | connection->connect("MirRenderSurfaceTest", connected_callback, 0)->wait_for_all(); | ||
798 | 482 | auto id = 123; | ||
799 | 483 | |||
800 | 484 | mp::BufferStream protobuf_bs; | ||
801 | 485 | mp::BufferStreamId bs_id; | ||
802 | 486 | |||
803 | 487 | bs_id.set_value(id); | ||
804 | 488 | *protobuf_bs.mutable_id() = bs_id; | ||
805 | 489 | |||
806 | 490 | auto native_window = mock_platform->create_egl_native_window(nullptr); | ||
807 | 491 | |||
808 | 492 | mcl::RenderSurface rs(connection.get(), | ||
809 | 493 | native_window, | ||
810 | 494 | mock_platform, | ||
811 | 495 | mt::fake_shared(protobuf_bs), | ||
812 | 496 | {}); | ||
813 | 497 | |||
814 | 498 | auto pc = rs.get_presentation_chain(); | ||
815 | 499 | |||
816 | 500 | EXPECT_THAT(pc, NotNull()); | ||
817 | 501 | EXPECT_THROW( | ||
818 | 502 | { rs.get_buffer_stream(2, 2, | ||
819 | 503 | mir_pixel_format_abgr_8888, | ||
820 | 504 | mir_buffer_usage_hardware); }, | ||
821 | 505 | std::logic_error); | ||
822 | 506 | } |
PASSED: Continuous integration, rev:3856 /mir-jenkins. ubuntu. com/job/ mir-ci/ 2295/ /mir-jenkins. ubuntu. com/job/ build-mir/ 2982 /mir-jenkins. ubuntu. com/job/ build-0- fetch/3047 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 3039 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 3039 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 3039 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= yakkety/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= yakkety/ 3011/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3011/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= yakkety/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= yakkety/ 3011/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 3011/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 3011/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3011 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3011/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 2295/rebuild
https:/