Merge lp:~vanvugt/mir/shape into lp:mir
- shape
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1113 |
Proposed branch: | lp:~vanvugt/mir/shape |
Merge into: | lp:mir |
Diff against target: |
493 lines (+149/-32) 15 files modified
examples/eglapp.c (+43/-2) examples/eglapp.h (+2/-0) examples/eglflash.c (+11/-11) examples/egltriangle.c (+1/-1) include/server/mir/compositor/compositing_criteria.h (+1/-0) include/shared/mir/geometry/pixel_format.h (+6/-0) include/test/mir_test_doubles/mock_compositing_criteria.h (+1/-0) include/test/mir_test_doubles/mock_surface_state.h (+1/-0) include/test/mir_test_doubles/stub_compositing_criteria.h (+10/-2) src/server/compositor/bypass.cpp (+1/-1) src/server/surfaces/surface_allocator.cpp (+4/-1) src/server/surfaces/surface_data.cpp (+7/-1) src/server/surfaces/surface_data.h (+4/-1) tests/unit-tests/compositor/test_bypass.cpp (+43/-0) tests/unit-tests/surfaces/test_surface_data.cpp (+14/-12) |
To merge this branch: | bzr merge lp:~vanvugt/mir/shape |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Kevin DuBois (community) | Approve | ||
Alan Griffiths | Approve | ||
Review via email: mp+189557@code.launchpad.net |
Commit message
Ensure nonrectangular surfaces are never bypassed, even if they are
fullscreen and on top (e.g. Unity8 shell at present).
(LP: #1236264)
Description of the change
More importantly, the shape() method is required to fix bug 1227739 on the phone, soon.
Alan Griffiths (alan-griffiths) wrote : | # |
Alan Griffiths (alan-griffiths) wrote : | # |
I think there's some conflation of shaped/
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1117
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
To me 'nonrectangular' doesn't immediately mean to me 'surface has alpha channel', (alpha_masked(), perhaps)? but its ok.
Daniel van Vugt (vanvugt) wrote : | # |
I agree the terminology is confusing. Present terminology:
Mir alpha() == Compiz opacity()
Mir shaped() == Compiz alpha()
Since they're distinctly different things, and both related to alpha blending, I suggest not mentioning "alpha" at all. Hence bug 1236224.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Daniel van Vugt (vanvugt) wrote : | # |
The failure is a bug which seems to already exist on the target branch. I just reproduced it using development-branch.
It has nothing to do with this proposal. Retry...
Daniel van Vugt (vanvugt) wrote : | # |
The failure is now logged as bug 1236698.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'examples/eglapp.c' | |||
2 | --- examples/eglapp.c 2013-09-19 13:24:22 +0000 | |||
3 | +++ examples/eglapp.c 2013-10-07 10:02:32 +0000 | |||
4 | @@ -26,6 +26,8 @@ | |||
5 | 26 | 26 | ||
6 | 27 | #include <xkbcommon/xkbcommon-keysyms.h> | 27 | #include <xkbcommon/xkbcommon-keysyms.h> |
7 | 28 | 28 | ||
8 | 29 | float mir_eglapp_background_opacity = 1.0f; | ||
9 | 30 | |||
10 | 29 | static const char appname[] = "egldemo"; | 31 | static const char appname[] = "egldemo"; |
11 | 30 | 32 | ||
12 | 31 | static MirConnection *connection; | 33 | static MirConnection *connection; |
13 | @@ -182,6 +184,26 @@ | |||
14 | 182 | { | 184 | { |
15 | 183 | switch (arg[1]) | 185 | switch (arg[1]) |
16 | 184 | { | 186 | { |
17 | 187 | case 'b': | ||
18 | 188 | { | ||
19 | 189 | float alpha = 1.0f; | ||
20 | 190 | arg += 2; | ||
21 | 191 | if (!arg[0] && i < argc-1) | ||
22 | 192 | { | ||
23 | 193 | i++; | ||
24 | 194 | arg = argv[i]; | ||
25 | 195 | } | ||
26 | 196 | if (sscanf(arg, "%f", &alpha) == 1) | ||
27 | 197 | { | ||
28 | 198 | mir_eglapp_background_opacity = alpha; | ||
29 | 199 | } | ||
30 | 200 | else | ||
31 | 201 | { | ||
32 | 202 | printf("Invalid opacity value: %s\n", arg); | ||
33 | 203 | help = 1; | ||
34 | 204 | } | ||
35 | 205 | } | ||
36 | 206 | break; | ||
37 | 185 | case 'n': | 207 | case 'n': |
38 | 186 | swapinterval = 0; | 208 | swapinterval = 0; |
39 | 187 | break; | 209 | break; |
40 | @@ -247,6 +269,7 @@ | |||
41 | 247 | if (help) | 269 | if (help) |
42 | 248 | { | 270 | { |
43 | 249 | printf("Usage: %s [<options>]\n" | 271 | printf("Usage: %s [<options>]\n" |
44 | 272 | " -b Background opacity (0.0 - 1.0)\n" | ||
45 | 250 | " -h Show this help text\n" | 273 | " -h Show this help text\n" |
46 | 251 | " -f Force full screen\n" | 274 | " -f Force full screen\n" |
47 | 252 | " -o ID Force placement on output monitor ID\n" | 275 | " -o ID Force placement on output monitor ID\n" |
48 | @@ -277,9 +300,27 @@ | |||
49 | 277 | 300 | ||
50 | 278 | const MirDisplayMode *mode = &output->modes[output->current_mode]; | 301 | const MirDisplayMode *mode = &output->modes[output->current_mode]; |
51 | 279 | 302 | ||
53 | 280 | unsigned int valid_formats; | 303 | const unsigned int max_formats = 10; |
54 | 304 | unsigned int format[max_formats]; | ||
55 | 305 | unsigned int nformats; | ||
56 | 306 | |||
57 | 281 | mir_connection_get_available_surface_formats(connection, | 307 | mir_connection_get_available_surface_formats(connection, |
59 | 282 | &surfaceparm.pixel_format, 1, &valid_formats); | 308 | format, max_formats, &nformats); |
60 | 309 | |||
61 | 310 | surfaceparm.pixel_format = format[0]; | ||
62 | 311 | for (unsigned int f = 0; f < nformats; f++) | ||
63 | 312 | { | ||
64 | 313 | const int opaque = (format[f] == mir_pixel_format_xbgr_8888 || | ||
65 | 314 | format[f] == mir_pixel_format_xrgb_8888 || | ||
66 | 315 | format[f] == mir_pixel_format_bgr_888); | ||
67 | 316 | |||
68 | 317 | if ((mir_eglapp_background_opacity == 1.0f && opaque) || | ||
69 | 318 | (mir_eglapp_background_opacity < 1.0f && !opaque)) | ||
70 | 319 | { | ||
71 | 320 | surfaceparm.pixel_format = format[f]; | ||
72 | 321 | break; | ||
73 | 322 | } | ||
74 | 323 | } | ||
75 | 283 | 324 | ||
76 | 284 | printf("Connected to display: resolution (%dx%d), position(%dx%d), " | 325 | printf("Connected to display: resolution (%dx%d), position(%dx%d), " |
77 | 285 | "supports %d pixel formats\n", | 326 | "supports %d pixel formats\n", |
78 | 286 | 327 | ||
79 | === modified file 'examples/eglapp.h' | |||
80 | --- examples/eglapp.h 2013-09-19 13:24:22 +0000 | |||
81 | +++ examples/eglapp.h 2013-10-07 10:02:32 +0000 | |||
82 | @@ -27,6 +27,8 @@ | |||
83 | 27 | struct MirConnection; | 27 | struct MirConnection; |
84 | 28 | struct MirSurface; | 28 | struct MirSurface; |
85 | 29 | 29 | ||
86 | 30 | extern float mir_eglapp_background_opacity; | ||
87 | 31 | |||
88 | 30 | mir_eglapp_bool mir_eglapp_init(int argc, char *argv[], | 32 | mir_eglapp_bool mir_eglapp_init(int argc, char *argv[], |
89 | 31 | unsigned int *width, unsigned int *height); | 33 | unsigned int *width, unsigned int *height); |
90 | 32 | void mir_eglapp_swap_buffers(void); | 34 | void mir_eglapp_swap_buffers(void); |
91 | 33 | 35 | ||
92 | === modified file 'examples/eglflash.c' | |||
93 | --- examples/eglflash.c 2013-09-19 13:24:22 +0000 | |||
94 | +++ examples/eglflash.c 2013-10-07 10:02:32 +0000 | |||
95 | @@ -33,17 +33,17 @@ | |||
96 | 33 | /* This is probably the simplest GL you can do */ | 33 | /* This is probably the simplest GL you can do */ |
97 | 34 | while (mir_eglapp_running()) | 34 | while (mir_eglapp_running()) |
98 | 35 | { | 35 | { |
110 | 36 | glClearColor(1.0f, 0.0f, 0.0f, 1.0f); | 36 | glClearColor(1.0f, 0.0f, 0.0f, mir_eglapp_background_opacity); |
111 | 37 | glClear(GL_COLOR_BUFFER_BIT); | 37 | glClear(GL_COLOR_BUFFER_BIT); |
112 | 38 | mir_eglapp_swap_buffers(); | 38 | mir_eglapp_swap_buffers(); |
113 | 39 | sleep(1); | 39 | sleep(1); |
114 | 40 | 40 | ||
115 | 41 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); | 41 | glClearColor(0.0f, 1.0f, 0.0f, mir_eglapp_background_opacity); |
116 | 42 | glClear(GL_COLOR_BUFFER_BIT); | 42 | glClear(GL_COLOR_BUFFER_BIT); |
117 | 43 | mir_eglapp_swap_buffers(); | 43 | mir_eglapp_swap_buffers(); |
118 | 44 | sleep(1); | 44 | sleep(1); |
119 | 45 | 45 | ||
120 | 46 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); | 46 | glClearColor(0.0f, 0.0f, 1.0f, mir_eglapp_background_opacity); |
121 | 47 | glClear(GL_COLOR_BUFFER_BIT); | 47 | glClear(GL_COLOR_BUFFER_BIT); |
122 | 48 | mir_eglapp_swap_buffers(); | 48 | mir_eglapp_swap_buffers(); |
123 | 49 | sleep(1); | 49 | sleep(1); |
124 | 50 | 50 | ||
125 | === modified file 'examples/egltriangle.c' | |||
126 | --- examples/egltriangle.c 2013-09-19 13:24:22 +0000 | |||
127 | +++ examples/egltriangle.c 2013-10-07 10:02:32 +0000 | |||
128 | @@ -105,7 +105,7 @@ | |||
129 | 105 | return 2; | 105 | return 2; |
130 | 106 | } | 106 | } |
131 | 107 | 107 | ||
133 | 108 | glClearColor(MID_AUBERGINE, 1.0); | 108 | glClearColor(MID_AUBERGINE, mir_eglapp_background_opacity); |
134 | 109 | glViewport(0, 0, width, height); | 109 | glViewport(0, 0, width, height); |
135 | 110 | 110 | ||
136 | 111 | glUseProgram(prog); | 111 | glUseProgram(prog); |
137 | 112 | 112 | ||
138 | === modified file 'include/server/mir/compositor/compositing_criteria.h' | |||
139 | --- include/server/mir/compositor/compositing_criteria.h 2013-08-28 03:41:48 +0000 | |||
140 | +++ include/server/mir/compositor/compositing_criteria.h 2013-10-07 10:02:32 +0000 | |||
141 | @@ -36,6 +36,7 @@ | |||
142 | 36 | virtual float alpha() const = 0; | 36 | virtual float alpha() const = 0; |
143 | 37 | virtual glm::mat4 const& transformation() const = 0; | 37 | virtual glm::mat4 const& transformation() const = 0; |
144 | 38 | virtual bool should_be_rendered_in(geometry::Rectangle const& rect) const = 0; | 38 | virtual bool should_be_rendered_in(geometry::Rectangle const& rect) const = 0; |
145 | 39 | virtual bool shaped() const = 0; // meaning the pixel format has alpha | ||
146 | 39 | 40 | ||
147 | 40 | virtual ~CompositingCriteria() = default; | 41 | virtual ~CompositingCriteria() = default; |
148 | 41 | 42 | ||
149 | 42 | 43 | ||
150 | === modified file 'include/shared/mir/geometry/pixel_format.h' | |||
151 | --- include/shared/mir/geometry/pixel_format.h 2013-06-12 09:36:20 +0000 | |||
152 | +++ include/shared/mir/geometry/pixel_format.h 2013-10-07 10:02:32 +0000 | |||
153 | @@ -42,6 +42,12 @@ | |||
154 | 42 | return (fmt == PixelFormat::bgr_888) ? 3 : 4; | 42 | return (fmt == PixelFormat::bgr_888) ? 3 : 4; |
155 | 43 | } | 43 | } |
156 | 44 | 44 | ||
157 | 45 | static inline bool has_alpha(PixelFormat fmt) | ||
158 | 46 | { | ||
159 | 47 | return (fmt == PixelFormat::abgr_8888) || | ||
160 | 48 | (fmt == PixelFormat::argb_8888); | ||
161 | 49 | } | ||
162 | 50 | |||
163 | 45 | } | 51 | } |
164 | 46 | } | 52 | } |
165 | 47 | 53 | ||
166 | 48 | 54 | ||
167 | === modified file 'include/test/mir_test_doubles/mock_compositing_criteria.h' | |||
168 | --- include/test/mir_test_doubles/mock_compositing_criteria.h 2013-08-28 03:41:48 +0000 | |||
169 | +++ include/test/mir_test_doubles/mock_compositing_criteria.h 2013-10-07 10:02:32 +0000 | |||
170 | @@ -36,6 +36,7 @@ | |||
171 | 36 | MOCK_CONST_METHOD0(alpha, float()); | 36 | MOCK_CONST_METHOD0(alpha, float()); |
172 | 37 | MOCK_CONST_METHOD0(transformation, glm::mat4 const&()); | 37 | MOCK_CONST_METHOD0(transformation, glm::mat4 const&()); |
173 | 38 | MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const&)); | 38 | MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const&)); |
174 | 39 | MOCK_CONST_METHOD0(shaped, bool()); | ||
175 | 39 | }; | 40 | }; |
176 | 40 | 41 | ||
177 | 41 | } | 42 | } |
178 | 42 | 43 | ||
179 | === modified file 'include/test/mir_test_doubles/mock_surface_state.h' | |||
180 | --- include/test/mir_test_doubles/mock_surface_state.h 2013-10-03 06:01:11 +0000 | |||
181 | +++ include/test/mir_test_doubles/mock_surface_state.h 2013-10-07 10:02:32 +0000 | |||
182 | @@ -60,6 +60,7 @@ | |||
183 | 60 | MOCK_METHOD0(frame_posted, void()); | 60 | MOCK_METHOD0(frame_posted, void()); |
184 | 61 | MOCK_METHOD1(set_hidden, void(bool)); | 61 | MOCK_METHOD1(set_hidden, void(bool)); |
185 | 62 | MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const&)); | 62 | MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const&)); |
186 | 63 | MOCK_CONST_METHOD0(shaped, bool()); | ||
187 | 63 | }; | 64 | }; |
188 | 64 | 65 | ||
189 | 65 | typedef ::testing::NiceMock<MockSurfaceState> StubSurfaceState; | 66 | typedef ::testing::NiceMock<MockSurfaceState> StubSurfaceState; |
190 | 66 | 67 | ||
191 | === modified file 'include/test/mir_test_doubles/stub_compositing_criteria.h' | |||
192 | --- include/test/mir_test_doubles/stub_compositing_criteria.h 2013-08-13 07:07:12 +0000 | |||
193 | +++ include/test/mir_test_doubles/stub_compositing_criteria.h 2013-10-07 10:02:32 +0000 | |||
194 | @@ -34,9 +34,11 @@ | |||
195 | 34 | { | 34 | { |
196 | 35 | public: | 35 | public: |
197 | 36 | StubCompositingCriteria(int x, int y, int width, int height, | 36 | StubCompositingCriteria(int x, int y, int width, int height, |
199 | 37 | float opacity=1.0f) | 37 | float opacity=1.0f, |
200 | 38 | bool rectangular=true) | ||
201 | 38 | : rect{{x, y}, {width, height}}, | 39 | : rect{{x, y}, {width, height}}, |
203 | 39 | opacity(opacity) | 40 | opacity(opacity), |
204 | 41 | rectangular(rectangular) | ||
205 | 40 | { | 42 | { |
206 | 41 | const glm::mat4 ident; | 43 | const glm::mat4 ident; |
207 | 42 | glm::vec3 size(width, height, 0.0f); | 44 | glm::vec3 size(width, height, 0.0f); |
208 | @@ -59,10 +61,16 @@ | |||
209 | 59 | return rect.overlaps(r); | 61 | return rect.overlaps(r); |
210 | 60 | } | 62 | } |
211 | 61 | 63 | ||
212 | 64 | bool shaped() const override | ||
213 | 65 | { | ||
214 | 66 | return !rectangular; | ||
215 | 67 | } | ||
216 | 68 | |||
217 | 62 | private: | 69 | private: |
218 | 63 | mir::geometry::Rectangle rect; | 70 | mir::geometry::Rectangle rect; |
219 | 64 | glm::mat4 trans; | 71 | glm::mat4 trans; |
220 | 65 | float opacity; | 72 | float opacity; |
221 | 73 | bool rectangular; | ||
222 | 66 | }; | 74 | }; |
223 | 67 | 75 | ||
224 | 68 | } // namespace doubles | 76 | } // namespace doubles |
225 | 69 | 77 | ||
226 | === modified file 'src/server/compositor/bypass.cpp' | |||
227 | --- src/server/compositor/bypass.cpp 2013-08-13 07:14:11 +0000 | |||
228 | +++ src/server/compositor/bypass.cpp 2013-10-07 10:02:32 +0000 | |||
229 | @@ -57,7 +57,7 @@ | |||
230 | 57 | 57 | ||
231 | 58 | bool BypassFilter::operator()(const CompositingCriteria &criteria) | 58 | bool BypassFilter::operator()(const CompositingCriteria &criteria) |
232 | 59 | { | 59 | { |
234 | 60 | if (criteria.alpha() != 1.0f) | 60 | if (criteria.alpha() != 1.0f || criteria.shaped()) |
235 | 61 | return false; | 61 | return false; |
236 | 62 | 62 | ||
237 | 63 | if (!all_orthogonal) | 63 | if (!all_orthogonal) |
238 | 64 | 64 | ||
239 | === modified file 'src/server/surfaces/surface_allocator.cpp' | |||
240 | --- src/server/surfaces/surface_allocator.cpp 2013-10-03 03:44:08 +0000 | |||
241 | +++ src/server/surfaces/surface_allocator.cpp 2013-10-07 10:02:32 +0000 | |||
242 | @@ -46,9 +46,12 @@ | |||
243 | 46 | params.buffer_usage}; | 46 | params.buffer_usage}; |
244 | 47 | auto buffer_stream = buffer_stream_factory->create_buffer_stream(buffer_properties); | 47 | auto buffer_stream = buffer_stream_factory->create_buffer_stream(buffer_properties); |
245 | 48 | auto actual_size = geom::Rectangle{params.top_left, buffer_stream->stream_size()}; | 48 | auto actual_size = geom::Rectangle{params.top_left, buffer_stream->stream_size()}; |
246 | 49 | |||
247 | 50 | bool nonrectangular = has_alpha(params.pixel_format); | ||
248 | 49 | auto state = std::make_shared<ms::SurfaceData>(params.name, | 51 | auto state = std::make_shared<ms::SurfaceData>(params.name, |
249 | 50 | actual_size, | 52 | actual_size, |
251 | 51 | change_callback); | 53 | change_callback, |
252 | 54 | nonrectangular); | ||
253 | 52 | auto input_channel = input_factory->make_input_channel(); | 55 | auto input_channel = input_factory->make_input_channel(); |
254 | 53 | return std::make_shared<ms::Surface>(state, buffer_stream, input_channel); | 56 | return std::make_shared<ms::Surface>(state, buffer_stream, input_channel); |
255 | 54 | } | 57 | } |
256 | 55 | 58 | ||
257 | === modified file 'src/server/surfaces/surface_data.cpp' | |||
258 | --- src/server/surfaces/surface_data.cpp 2013-10-03 03:44:08 +0000 | |||
259 | +++ src/server/surfaces/surface_data.cpp 2013-10-07 10:02:32 +0000 | |||
260 | @@ -22,7 +22,7 @@ | |||
261 | 22 | namespace geom=mir::geometry; | 22 | namespace geom=mir::geometry; |
262 | 23 | namespace ms = mir::surfaces; | 23 | namespace ms = mir::surfaces; |
263 | 24 | 24 | ||
265 | 25 | ms::SurfaceData::SurfaceData(std::string const& name, geom::Rectangle rect, std::function<void()> change_cb) | 25 | ms::SurfaceData::SurfaceData(std::string const& name, geom::Rectangle rect, std::function<void()> change_cb, bool nonrectangular) |
266 | 26 | : notify_change(change_cb), | 26 | : notify_change(change_cb), |
267 | 27 | surface_name(name), | 27 | surface_name(name), |
268 | 28 | surface_rect(rect), | 28 | surface_rect(rect), |
269 | @@ -30,6 +30,7 @@ | |||
270 | 30 | surface_alpha(1.0f), | 30 | surface_alpha(1.0f), |
271 | 31 | first_frame_posted(false), | 31 | first_frame_posted(false), |
272 | 32 | hidden(false), | 32 | hidden(false), |
273 | 33 | nonrectangular(nonrectangular), | ||
274 | 33 | input_rectangles{surface_rect} | 34 | input_rectangles{surface_rect} |
275 | 34 | { | 35 | { |
276 | 35 | } | 36 | } |
277 | @@ -91,6 +92,11 @@ | |||
278 | 91 | return rect.overlaps(surface_rect); | 92 | return rect.overlaps(surface_rect); |
279 | 92 | } | 93 | } |
280 | 93 | 94 | ||
281 | 95 | bool ms::SurfaceData::shaped() const | ||
282 | 96 | { | ||
283 | 97 | return nonrectangular; | ||
284 | 98 | } | ||
285 | 99 | |||
286 | 94 | void ms::SurfaceData::apply_alpha(float alpha) | 100 | void ms::SurfaceData::apply_alpha(float alpha) |
287 | 95 | { | 101 | { |
288 | 96 | { | 102 | { |
289 | 97 | 103 | ||
290 | === modified file 'src/server/surfaces/surface_data.h' | |||
291 | --- src/server/surfaces/surface_data.h 2013-10-03 08:42:27 +0000 | |||
292 | +++ src/server/surfaces/surface_data.h 2013-10-07 10:02:32 +0000 | |||
293 | @@ -34,12 +34,14 @@ | |||
294 | 34 | { | 34 | { |
295 | 35 | public: | 35 | public: |
296 | 36 | SurfaceData(std::string const& name, geometry::Rectangle rect, | 36 | SurfaceData(std::string const& name, geometry::Rectangle rect, |
298 | 37 | std::function<void()> change_cb); | 37 | std::function<void()> change_cb, |
299 | 38 | bool nonrectangular); | ||
300 | 38 | 39 | ||
301 | 39 | //mc::CompositingCriteria | 40 | //mc::CompositingCriteria |
302 | 40 | glm::mat4 const& transformation() const; | 41 | glm::mat4 const& transformation() const; |
303 | 41 | float alpha() const; | 42 | float alpha() const; |
304 | 42 | bool should_be_rendered_in(geometry::Rectangle const& rect) const; | 43 | bool should_be_rendered_in(geometry::Rectangle const& rect) const; |
305 | 44 | bool shaped() const override; | ||
306 | 43 | 45 | ||
307 | 44 | //mi::Surface | 46 | //mi::Surface |
308 | 45 | std::string const& name() const; | 47 | std::string const& name() const; |
309 | @@ -67,6 +69,7 @@ | |||
310 | 67 | float surface_alpha; | 69 | float surface_alpha; |
311 | 68 | bool first_frame_posted; | 70 | bool first_frame_posted; |
312 | 69 | bool hidden; | 71 | bool hidden; |
313 | 72 | const bool nonrectangular; | ||
314 | 70 | std::vector<geometry::Rectangle> input_rectangles; | 73 | std::vector<geometry::Rectangle> input_rectangles; |
315 | 71 | }; | 74 | }; |
316 | 72 | 75 | ||
317 | 73 | 76 | ||
318 | === modified file 'tests/unit-tests/compositor/test_bypass.cpp' | |||
319 | --- tests/unit-tests/compositor/test_bypass.cpp 2013-08-13 07:18:22 +0000 | |||
320 | +++ tests/unit-tests/compositor/test_bypass.cpp 2013-10-07 10:02:32 +0000 | |||
321 | @@ -88,6 +88,16 @@ | |||
322 | 88 | EXPECT_FALSE(filter.fullscreen_on_top()); | 88 | EXPECT_FALSE(filter.fullscreen_on_top()); |
323 | 89 | } | 89 | } |
324 | 90 | 90 | ||
325 | 91 | TEST_F(BypassFilterTest, shaped_fullscreen_window_not_bypassed) | ||
326 | 92 | { | ||
327 | 93 | BypassFilter filter(display_buffer[0]); | ||
328 | 94 | |||
329 | 95 | StubCompositingCriteria win(0, 0, 1920, 1200, 1.0f, false); | ||
330 | 96 | |||
331 | 97 | EXPECT_FALSE(filter(win)); | ||
332 | 98 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
333 | 99 | } | ||
334 | 100 | |||
335 | 91 | TEST_F(BypassFilterTest, offset_fullscreen_window_not_bypassed) | 101 | TEST_F(BypassFilterTest, offset_fullscreen_window_not_bypassed) |
336 | 92 | { | 102 | { |
337 | 93 | BypassFilter filter(display_buffer[0]); | 103 | BypassFilter filter(display_buffer[0]); |
338 | @@ -167,6 +177,39 @@ | |||
339 | 167 | EXPECT_TRUE(filter.fullscreen_on_top()); | 177 | EXPECT_TRUE(filter.fullscreen_on_top()); |
340 | 168 | } | 178 | } |
341 | 169 | 179 | ||
342 | 180 | TEST_F(BypassFilterTest, many_fullscreen_windows_only_bypass_top_rectangular) | ||
343 | 181 | { | ||
344 | 182 | BypassFilter filter(display_buffer[0]); | ||
345 | 183 | |||
346 | 184 | StubCompositingCriteria a(0, 0, 1920, 1200, 1.0f, false); | ||
347 | 185 | EXPECT_FALSE(filter(a)); | ||
348 | 186 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
349 | 187 | |||
350 | 188 | StubCompositingCriteria b(1, 2, 3, 4); | ||
351 | 189 | EXPECT_FALSE(filter(b)); | ||
352 | 190 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
353 | 191 | |||
354 | 192 | StubCompositingCriteria c(0, 0, 1920, 1200); | ||
355 | 193 | EXPECT_TRUE(filter(c)); | ||
356 | 194 | EXPECT_TRUE(filter.fullscreen_on_top()); | ||
357 | 195 | |||
358 | 196 | StubCompositingCriteria d(5, 6, 7, 8); | ||
359 | 197 | EXPECT_FALSE(filter(d)); | ||
360 | 198 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
361 | 199 | |||
362 | 200 | StubCompositingCriteria e(0, 0, 1920, 1200, 1.0f, true); | ||
363 | 201 | EXPECT_TRUE(filter(e)); | ||
364 | 202 | EXPECT_TRUE(filter.fullscreen_on_top()); | ||
365 | 203 | |||
366 | 204 | StubCompositingCriteria f(9, 10, 11, 12); | ||
367 | 205 | EXPECT_FALSE(filter(f)); | ||
368 | 206 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
369 | 207 | |||
370 | 208 | StubCompositingCriteria g(0, 0, 1920, 1200, 0.5f, false); | ||
371 | 209 | EXPECT_FALSE(filter(g)); | ||
372 | 210 | EXPECT_FALSE(filter.fullscreen_on_top()); | ||
373 | 211 | } | ||
374 | 212 | |||
375 | 170 | TEST_F(BypassFilterTest, multimonitor_one_bypassed) | 213 | TEST_F(BypassFilterTest, multimonitor_one_bypassed) |
376 | 171 | { | 214 | { |
377 | 172 | BypassFilter left(display_buffer[0]); | 215 | BypassFilter left(display_buffer[0]); |
378 | 173 | 216 | ||
379 | === modified file 'tests/unit-tests/surfaces/test_surface_data.cpp' | |||
380 | --- tests/unit-tests/surfaces/test_surface_data.cpp 2013-10-03 03:44:08 +0000 | |||
381 | +++ tests/unit-tests/surfaces/test_surface_data.cpp 2013-10-07 10:02:32 +0000 | |||
382 | @@ -67,10 +67,11 @@ | |||
383 | 67 | 67 | ||
384 | 68 | TEST_F(SurfaceDataTest, basics) | 68 | TEST_F(SurfaceDataTest, basics) |
385 | 69 | { | 69 | { |
387 | 70 | ms::SurfaceData data{name, rect, null_change_cb}; | 70 | ms::SurfaceData data{name, rect, null_change_cb, false}; |
388 | 71 | EXPECT_EQ(name, data.name()); | 71 | EXPECT_EQ(name, data.name()); |
389 | 72 | EXPECT_EQ(rect.size, data.size()); | 72 | EXPECT_EQ(rect.size, data.size()); |
390 | 73 | EXPECT_EQ(rect.top_left, data.position()); | 73 | EXPECT_EQ(rect.top_left, data.position()); |
391 | 74 | EXPECT_FALSE(data.shaped()); | ||
392 | 74 | } | 75 | } |
393 | 75 | 76 | ||
394 | 76 | TEST_F(SurfaceDataTest, update_position) | 77 | TEST_F(SurfaceDataTest, update_position) |
395 | @@ -78,7 +79,7 @@ | |||
396 | 78 | EXPECT_CALL(mock_callback, call()) | 79 | EXPECT_CALL(mock_callback, call()) |
397 | 79 | .Times(1); | 80 | .Times(1); |
398 | 80 | 81 | ||
400 | 81 | ms::SurfaceData storage{name, rect, mock_change_cb}; | 82 | ms::SurfaceData storage{name, rect, mock_change_cb, false}; |
401 | 82 | EXPECT_EQ(rect.top_left, storage.position()); | 83 | EXPECT_EQ(rect.top_left, storage.position()); |
402 | 83 | 84 | ||
403 | 84 | auto new_top_left = geom::Point{geom::X{6}, geom::Y{10}}; | 85 | auto new_top_left = geom::Point{geom::X{6}, geom::Y{10}}; |
404 | @@ -91,7 +92,7 @@ | |||
405 | 91 | EXPECT_CALL(mock_callback, call()) | 92 | EXPECT_CALL(mock_callback, call()) |
406 | 92 | .Times(1); | 93 | .Times(1); |
407 | 93 | 94 | ||
409 | 94 | ms::SurfaceData storage{name, rect, mock_change_cb}; | 95 | ms::SurfaceData storage{name, rect, mock_change_cb, false}; |
410 | 95 | auto original_transformation = storage.transformation(); | 96 | auto original_transformation = storage.transformation(); |
411 | 96 | 97 | ||
412 | 97 | storage.apply_rotation(60.0f, glm::vec3{0.0f, 0.0f, 1.0f}); | 98 | storage.apply_rotation(60.0f, glm::vec3{0.0f, 0.0f, 1.0f}); |
413 | @@ -106,7 +107,7 @@ | |||
414 | 106 | const geom::Size sz{geom::Width{85}, geom::Height{43}}; | 107 | const geom::Size sz{geom::Width{85}, geom::Height{43}}; |
415 | 107 | const geom::Rectangle origin{geom::Point{geom::X{77}, geom::Y{88}}, sz}; | 108 | const geom::Rectangle origin{geom::Point{geom::X{77}, geom::Y{88}}, sz}; |
416 | 108 | const geom::Rectangle moved_pt{geom::Point{geom::X{55}, geom::Y{66}}, sz}; | 109 | const geom::Rectangle moved_pt{geom::Point{geom::X{55}, geom::Y{66}}, sz}; |
418 | 109 | ms::SurfaceData storage{name, origin, null_change_cb}; | 110 | ms::SurfaceData storage{name, origin, null_change_cb, false}; |
419 | 110 | 111 | ||
420 | 111 | glm::mat4 t0 = storage.transformation(); | 112 | glm::mat4 t0 = storage.transformation(); |
421 | 112 | storage.move_to(moved_pt.top_left); | 113 | storage.move_to(moved_pt.top_left); |
422 | @@ -125,7 +126,7 @@ | |||
423 | 125 | EXPECT_CALL(mock_callback, call()) | 126 | EXPECT_CALL(mock_callback, call()) |
424 | 126 | .Times(1); | 127 | .Times(1); |
425 | 127 | 128 | ||
427 | 128 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 129 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
428 | 129 | 130 | ||
429 | 130 | float alpha = 0.5f; | 131 | float alpha = 0.5f; |
430 | 131 | surface_state.apply_alpha(0.5f); | 132 | surface_state.apply_alpha(0.5f); |
431 | @@ -135,8 +136,9 @@ | |||
432 | 135 | TEST_F(SurfaceDataTest, test_surface_is_opaque_by_default) | 136 | TEST_F(SurfaceDataTest, test_surface_is_opaque_by_default) |
433 | 136 | { | 137 | { |
434 | 137 | using namespace testing; | 138 | using namespace testing; |
436 | 138 | ms::SurfaceData surface_state{name, rect, null_change_cb}; | 139 | ms::SurfaceData surface_state{name, rect, null_change_cb, false}; |
437 | 139 | EXPECT_THAT(1.0f, FloatEq(surface_state.alpha())); | 140 | EXPECT_THAT(1.0f, FloatEq(surface_state.alpha())); |
438 | 141 | EXPECT_FALSE(surface_state.shaped()); | ||
439 | 140 | } | 142 | } |
440 | 141 | 143 | ||
441 | 142 | TEST_F(SurfaceDataTest, test_surface_apply_rotation) | 144 | TEST_F(SurfaceDataTest, test_surface_apply_rotation) |
442 | @@ -144,13 +146,13 @@ | |||
443 | 144 | EXPECT_CALL(mock_callback, call()) | 146 | EXPECT_CALL(mock_callback, call()) |
444 | 145 | .Times(1); | 147 | .Times(1); |
445 | 146 | 148 | ||
447 | 147 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 149 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
448 | 148 | surface_state.apply_rotation(60.0f, glm::vec3{0.0f, 0.0f, 1.0f}); | 150 | surface_state.apply_rotation(60.0f, glm::vec3{0.0f, 0.0f, 1.0f}); |
449 | 149 | } | 151 | } |
450 | 150 | 152 | ||
451 | 151 | TEST_F(SurfaceDataTest, test_surface_should_be_rendered_in) | 153 | TEST_F(SurfaceDataTest, test_surface_should_be_rendered_in) |
452 | 152 | { | 154 | { |
454 | 153 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 155 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
455 | 154 | geom::Rectangle output_rect{geom::Point{0,0}, geom::Size{100, 100}}; | 156 | geom::Rectangle output_rect{geom::Point{0,0}, geom::Size{100, 100}}; |
456 | 155 | 157 | ||
457 | 156 | //not renderable by default | 158 | //not renderable by default |
458 | @@ -179,7 +181,7 @@ | |||
459 | 179 | EXPECT_CALL(mock_callback, call()) | 181 | EXPECT_CALL(mock_callback, call()) |
460 | 180 | .Times(1); | 182 | .Times(1); |
461 | 181 | 183 | ||
463 | 182 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 184 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
464 | 183 | surface_state.set_hidden(true); | 185 | surface_state.set_hidden(true); |
465 | 184 | } | 186 | } |
466 | 185 | 187 | ||
467 | @@ -189,7 +191,7 @@ | |||
468 | 189 | EXPECT_CALL(mock_callback, call()) | 191 | EXPECT_CALL(mock_callback, call()) |
469 | 190 | .Times(1); | 192 | .Times(1); |
470 | 191 | 193 | ||
472 | 192 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 194 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
473 | 193 | surface_state.frame_posted(); | 195 | surface_state.frame_posted(); |
474 | 194 | } | 196 | } |
475 | 195 | 197 | ||
476 | @@ -198,7 +200,7 @@ | |||
477 | 198 | { | 200 | { |
478 | 199 | geom::Point pt(1,1); | 201 | geom::Point pt(1,1); |
479 | 200 | geom::Size one_by_one{geom::Width{1}, geom::Height{1}}; | 202 | geom::Size one_by_one{geom::Width{1}, geom::Height{1}}; |
481 | 201 | ms::SurfaceData surface_state{name, geom::Rectangle{pt, one_by_one}, mock_change_cb}; | 203 | ms::SurfaceData surface_state{name, geom::Rectangle{pt, one_by_one}, mock_change_cb, false}; |
482 | 202 | 204 | ||
483 | 203 | std::vector<geom::Point> contained_pt | 205 | std::vector<geom::Point> contained_pt |
484 | 204 | { | 206 | { |
485 | @@ -230,7 +232,7 @@ | |||
486 | 230 | {{geom::X{1}, geom::Y{1}}, {geom::Width{1}, geom::Height{1}}} //region1 | 232 | {{geom::X{1}, geom::Y{1}}, {geom::Width{1}, geom::Height{1}}} //region1 |
487 | 231 | }; | 233 | }; |
488 | 232 | 234 | ||
490 | 233 | ms::SurfaceData surface_state{name, rect, mock_change_cb}; | 235 | ms::SurfaceData surface_state{name, rect, mock_change_cb, false}; |
491 | 234 | surface_state.set_input_region(rectangles); | 236 | surface_state.set_input_region(rectangles); |
492 | 235 | 237 | ||
493 | 236 | std::vector<geom::Point> contained_pt | 238 | std::vector<geom::Point> contained_pt |
145 + virtual bool shaped() const = 0; // meaning the pixel format has alpha
When comments and code disagree: trust neither!
Surely we can come up with clearer terminology?