Mir

Merge lp:~kdub/mir/fix-1348330 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1845
Proposed branch: lp:~kdub/mir/fix-1348330
Merge into: lp:mir
Diff against target: 347 lines (+157/-32)
10 files modified
examples/demo-shell/CMakeLists.txt (+6/-2)
examples/demo-shell/demo_compositor.cpp (+14/-11)
examples/demo-shell/demo_compositor.h (+0/-1)
examples/demo-shell/demo_renderer.cpp (+40/-8)
examples/demo-shell/demo_renderer.h (+22/-10)
include/test/mir_test_doubles/mock_gl.h (+1/-0)
tests/mir_test_doubles/mock_gl.cpp (+6/-0)
tests/unit-tests/CMakeLists.txt (+2/-0)
tests/unit-tests/examples/CMakeLists.txt (+5/-0)
tests/unit-tests/examples/test_demo_renderer.cpp (+61/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-1348330
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Abstain
Robert Carr (community) Approve
Andreas Pokorny (community) Approve
Review via email: mp+229608@code.launchpad.net

Commit message

demo shell: detect the additional things the demo shell draws on the renderable list and avoid calling the optimized post function if they are being drawn. This avoids incorrect rendering on the android platform if "--disable-overlays false" is set. (lp: #1348330)

Description of the change

demo shell: detect the additional things the demo shell draws on the renderable list and avoid calling the optimized post function if they are being drawn. This avoids incorrect rendering on the android platform if "--disable-overlays false" is set. (lp: #1348330)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

fun valgrind error
==17821== valgrind: Unrecognised instruction at address 0xaa235d.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As already disapproved in previous proposals, I don't think this is a good idea. It introduces redundant decoration-specific logic which will soon need to be deleted as bug 1299977 gets fully resolved by server-side extents logic. As it will soon need to be untangled and deleted, this change increases our future maintenance burden, slowing down future work.

That said, if I don't complete the proper fix soon enough I understand I'm slowing kdub down too.

Revision history for this message
Kevin DuBois (kdub) wrote :

cant reproduce locally, lets see if it happens twice.

@Daniel,
I'm not particularly attached to the code, so once something better comes along lets get rid of it. It still seems like there's not a consensus/plan on how to handle some of the "desktop" compositions, so I appreciate not blocking the overlay stuff by default.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

looks fine. I does not seem like something hard to remove, additionally it only touches examples..

The illegal instruction is interesting ... it relates to code that has not changed.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

seems ok, comes with test, and unblocks stuff :)

On the other hand I think this code is only getting weirder ;)

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I still disagree with adding code we know should soon get deleted. But won't stand in the way of progress.

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

Still havent seen locally, but I noticed that the function valgrind was complaining about was calling glGenerateMipmap, which was not part of the mock gl. Added the function, perhaps that'll avert the complaint.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

Unpacking lxc-android-config (0.192) over (0.191) ...
dpkg: error processing archive /var/cache/apt/archives/lxc-android-config_0.192_all.deb (--unpack):
 unable to make backup link of `./lib/udev/rules.d/70-android.rules' before installing new version: Invalid cross-device link

apparently a dist-upgrade is triggered on the device, which fails. have to wait for ci resolution

Revision history for this message
Kevin DuBois (kdub) wrote :

This test had a failure in utopic-mediumtests-mako test suite that warranted further investigation before that test suite was disabled. We should hold this branch off until that suite is back.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> This test had a failure in utopic-mediumtests-mako test suite that warranted
> further investigation before that test suite was disabled. We should hold this
> branch off until that suite is back.

The suite is re-enabled and the ci passed.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'm not particularly convinced by this approach but I see no point in keeping this branch hanging around. At the very least the existence of the test will flag the need to write a replacement if/when the code dies.

I'm top-approving based on the existing votes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/demo-shell/CMakeLists.txt'
2--- examples/demo-shell/CMakeLists.txt 2014-07-24 18:48:23 +0000
3+++ examples/demo-shell/CMakeLists.txt 2014-08-13 12:22:03 +0000
4@@ -1,5 +1,4 @@
5-add_executable(mir_demo_server_shell
6- demo_shell.cpp
7+add_library(demo-shell STATIC
8 demo_compositor.cpp
9 demo_renderer.cpp
10 fullscreen_placement_strategy.cpp
11@@ -7,7 +6,12 @@
12 ../server_configuration.cpp
13 )
14
15+add_executable(mir_demo_server_shell
16+ demo_shell.cpp
17+)
18+
19 target_link_libraries(mir_demo_server_shell
20+ demo-shell
21 mirserver
22 )
23
24
25=== modified file 'examples/demo-shell/demo_compositor.cpp'
26--- examples/demo-shell/demo_compositor.cpp 2014-07-24 18:48:23 +0000
27+++ examples/demo-shell/demo_compositor.cpp 2014-08-13 12:22:03 +0000
28@@ -47,20 +47,27 @@
29 renderer(
30 factory,
31 display_buffer.view_area(),
32- destination_alpha(display_buffer))
33+ destination_alpha(display_buffer),
34+ 30.0f, //titlebar_height
35+ 80.0f) //shadow_radius
36 {
37 }
38
39-mg::RenderableList me::DemoCompositor::generate_renderables()
40+void me::DemoCompositor::composite()
41 {
42+ report->began_frame(this);
43 //a simple filtering out of renderables that shouldn't be drawn
44 //the elements should be notified if they are rendered or not
45+ bool nonrenderlist_elements{false};
46 mg::RenderableList renderable_list;
47 auto elements = scene->scene_elements_for(this);
48 for(auto const& it : elements)
49 {
50- auto const& renderable = it->renderable();
51- if (renderable->visible())
52+ auto const& renderable = it->renderable();
53+ auto const& view_area = display_buffer.view_area();
54+ auto embellished = renderer.would_embellish(*renderable, view_area);
55+ auto any_part_drawn = (view_area.overlaps(renderable->screen_position()) || embellished);
56+ if (renderable->visible() && any_part_drawn)
57 {
58 renderable_list.push_back(renderable);
59 it->rendered_in(this);
60@@ -69,15 +76,11 @@
61 {
62 it->occluded_in(this);
63 }
64+ nonrenderlist_elements |= embellished;
65 }
66- return renderable_list;
67-}
68
69-void me::DemoCompositor::composite()
70-{
71- report->began_frame(this);
72- auto const& renderable_list = generate_renderables();
73- if (display_buffer.post_renderables_if_optimizable(renderable_list))
74+ if (!nonrenderlist_elements &&
75+ display_buffer.post_renderables_if_optimizable(renderable_list))
76 {
77 renderer.suspend();
78 report->finished_frame(true, this);
79
80=== modified file 'examples/demo-shell/demo_compositor.h'
81--- examples/demo-shell/demo_compositor.h 2014-07-24 18:35:02 +0000
82+++ examples/demo-shell/demo_compositor.h 2014-08-13 12:22:03 +0000
83@@ -50,7 +50,6 @@
84 void composite() override;
85
86 private:
87- graphics::RenderableList generate_renderables();
88 graphics::DisplayBuffer& display_buffer;
89 std::shared_ptr<compositor::Scene> const scene;
90 std::shared_ptr<compositor::CompositorReport> const report;
91
92=== modified file 'examples/demo-shell/demo_renderer.cpp'
93--- examples/demo-shell/demo_renderer.cpp 2014-08-05 11:34:22 +0000
94+++ examples/demo-shell/demo_renderer.cpp 2014-08-13 12:22:03 +0000
95@@ -24,6 +24,7 @@
96
97 using namespace mir;
98 using namespace mir::examples;
99+using namespace mir::geometry;
100
101 namespace
102 {
103@@ -76,7 +77,7 @@
104 return corner;
105 }
106
107-GLuint generate_frame_corner_texture(float corner_radius,
108+GLuint generate_frame_corner_texture(int corner_radius,
109 Color const& color,
110 GLubyte highlight)
111 {
112@@ -138,13 +139,17 @@
113
114 DemoRenderer::DemoRenderer(
115 graphics::GLProgramFactory const& program_factory,
116- geometry::Rectangle const& display_area,
117- compositor::DestinationAlpha dest_alpha)
118- : GLRenderer(program_factory,
119+ Rectangle const& display_area,
120+ compositor::DestinationAlpha dest_alpha,
121+ float const titlebar_height,
122+ float const shadow_radius) :
123+ GLRenderer(program_factory,
124 std::unique_ptr<graphics::GLTextureCache>(new compositor::RecentlyUsedCache()),
125 display_area,
126- dest_alpha)
127- , corner_radius(0.5f)
128+ dest_alpha),
129+ titlebar_height{titlebar_height},
130+ shadow_radius{shadow_radius},
131+ corner_radius{0.5f}
132 {
133 shadow_corner_tex = generate_shadow_corner_texture(0.4f);
134 titlebar_corner_tex = generate_frame_corner_texture(corner_radius,
135@@ -177,8 +182,8 @@
136 graphics::Renderable const& renderable) const
137 {
138 GLRenderer::tessellate(primitives, renderable);
139- tessellate_shadow(primitives, renderable, 80.0f);
140- tessellate_frame(primitives, renderable, 30.0f);
141+ tessellate_shadow(primitives, renderable, shadow_radius);
142+ tessellate_frame(primitives, renderable, titlebar_height);
143 }
144
145 void DemoRenderer::tessellate_shadow(std::vector<graphics::GLPrimitive>& primitives,
146@@ -303,3 +308,30 @@
147 titlebar.vertices[3] = {{inleft, top, 0.0f}, {1.0f, 1.0f}};
148 }
149
150+bool DemoRenderer::would_embellish(
151+ graphics::Renderable const& renderable,
152+ Rectangle const& display_area) const
153+{
154+ auto const& window = renderable.screen_position();
155+ Height const full_height{2*shadow_radius + titlebar_height + window.size.height.as_int()};
156+ Width const side_trim{shadow_radius};
157+ Y const topmost_y{window.top_left.y.as_int() - shadow_radius - titlebar_height};
158+ X const leftmost_x{window.top_left.x.as_int() - shadow_radius};
159+ Rectangle const left{
160+ Point{leftmost_x, topmost_y},
161+ Size{side_trim, full_height}};
162+ Rectangle const right{
163+ Point{window.top_right().x, topmost_y},
164+ Size{side_trim, full_height}};
165+ Rectangle const bottom{
166+ window.bottom_left(),
167+ Size{window.size.width.as_int(), shadow_radius}};
168+ Rectangle const top{
169+ Point{window.top_left.x, topmost_y},
170+ Size{window.size.width.as_int(), shadow_radius + titlebar_height}};
171+
172+ return (display_area.overlaps(left) ||
173+ display_area.overlaps(right) ||
174+ display_area.overlaps(top) ||
175+ display_area.overlaps(bottom));
176+}
177
178=== modified file 'examples/demo-shell/demo_renderer.h'
179--- examples/demo-shell/demo_renderer.h 2014-08-05 11:34:22 +0000
180+++ examples/demo-shell/demo_renderer.h 2014-08-13 12:22:03 +0000
181@@ -29,21 +29,33 @@
182 class DemoRenderer : public compositor::GLRenderer
183 {
184 public:
185- DemoRenderer(graphics::GLProgramFactory const& factory, geometry::Rectangle const& display_area,
186- compositor::DestinationAlpha dest_alpha);
187+ DemoRenderer(
188+ graphics::GLProgramFactory const& factory,
189+ geometry::Rectangle const& display_area,
190+ compositor::DestinationAlpha dest_alpha,
191+ float const titlebar_height,
192+ float const shadow_radius);
193 ~DemoRenderer();
194
195 void begin() const override;
196- void tessellate(std::vector<graphics::GLPrimitive>& primitives,
197- graphics::Renderable const& renderable) const override;
198- void tessellate_shadow(std::vector<graphics::GLPrimitive>& primitives,
199- graphics::Renderable const& renderable,
200- float radius) const;
201- void tessellate_frame(std::vector<graphics::GLPrimitive>& primitives,
202- graphics::Renderable const& renderable,
203- float titlebar_height) const;
204+ void tessellate(
205+ std::vector<graphics::GLPrimitive>& primitives,
206+ graphics::Renderable const& renderable) const override;
207+ void tessellate_shadow(
208+ std::vector<graphics::GLPrimitive>& primitives,
209+ graphics::Renderable const& renderable,
210+ float radius) const;
211+ void tessellate_frame(
212+ std::vector<graphics::GLPrimitive>& primitives,
213+ graphics::Renderable const& renderable,
214+ float titlebar_height) const;
215+ bool would_embellish(
216+ graphics::Renderable const& renderable,
217+ geometry::Rectangle const&) const;
218
219 private:
220+ float const titlebar_height;
221+ float const shadow_radius;
222 float const corner_radius;
223 GLuint shadow_corner_tex;
224 GLuint titlebar_corner_tex;
225
226=== modified file 'include/test/mir_test_doubles/mock_gl.h'
227--- include/test/mir_test_doubles/mock_gl.h 2014-07-02 06:29:24 +0000
228+++ include/test/mir_test_doubles/mock_gl.h 2014-08-13 12:22:03 +0000
229@@ -105,6 +105,7 @@
230 void(GLuint, GLint, GLenum, GLboolean, GLsizei,
231 const GLvoid *));
232 MOCK_METHOD4(glViewport, void(GLint, GLint, GLsizei, GLsizei));
233+ MOCK_METHOD1(glGenerateMipmap, void(GLenum target));
234 };
235
236 }
237
238=== modified file 'tests/mir_test_doubles/mock_gl.cpp'
239--- tests/mir_test_doubles/mock_gl.cpp 2014-07-02 06:29:24 +0000
240+++ tests/mir_test_doubles/mock_gl.cpp 2014-08-13 12:22:03 +0000
241@@ -415,3 +415,9 @@
242 CHECK_GLOBAL_VOID_MOCK();
243 global_mock_gl->glFinish();
244 }
245+
246+void glGenerateMipmap(GLenum target)
247+{
248+ CHECK_GLOBAL_VOID_MOCK();
249+ global_mock_gl->glGenerateMipmap(target);
250+}
251
252=== modified file 'tests/unit-tests/CMakeLists.txt'
253--- tests/unit-tests/CMakeLists.txt 2014-08-04 08:58:40 +0000
254+++ tests/unit-tests/CMakeLists.txt 2014-08-13 12:22:03 +0000
255@@ -35,6 +35,7 @@
256 add_subdirectory(android_input/)
257 add_subdirectory(scene/)
258 add_subdirectory(draw/)
259+add_subdirectory(examples/)
260
261 link_directories(${LIBRARY_OUTPUT_PATH})
262
263@@ -51,6 +52,7 @@
264 mirserver
265 mirdraw
266 mirtestdraw
267+ demo-shell
268
269 mir-test
270 mir-test-doubles
271
272=== added directory 'tests/unit-tests/examples'
273=== added file 'tests/unit-tests/examples/CMakeLists.txt'
274--- tests/unit-tests/examples/CMakeLists.txt 1970-01-01 00:00:00 +0000
275+++ tests/unit-tests/examples/CMakeLists.txt 2014-08-13 12:22:03 +0000
276@@ -0,0 +1,5 @@
277+list(APPEND UNIT_TEST_SOURCES
278+ ${CMAKE_CURRENT_SOURCE_DIR}/test_demo_renderer.cpp
279+)
280+
281+set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)
282
283=== added file 'tests/unit-tests/examples/test_demo_renderer.cpp'
284--- tests/unit-tests/examples/test_demo_renderer.cpp 1970-01-01 00:00:00 +0000
285+++ tests/unit-tests/examples/test_demo_renderer.cpp 2014-08-13 12:22:03 +0000
286@@ -0,0 +1,61 @@
287+/*
288+ * Copyright © 2012 Canonical Ltd.
289+ *
290+ * This program is free software: you can redistribute it and/or modify
291+ * it under the terms of the GNU General Public License version 3 as
292+ * published by the Free Software Foundation.
293+ *
294+ * This program is distributed in the hope that it will be useful,
295+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
296+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
297+ * GNU General Public License for more details.
298+ *
299+ * You should have received a copy of the GNU General Public License
300+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
301+ *
302+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
303+ */
304+
305+#include "mir/graphics/renderable.h"
306+#include "mir/compositor/destination_alpha.h"
307+#include "mir_test_doubles/fake_renderable.h"
308+#include "mir_test_doubles/stub_gl_program_factory.h"
309+#include "mir_test_doubles/mock_gl.h"
310+#include "examples/demo-shell/demo_renderer.h"
311+#include <gtest/gtest.h>
312+
313+namespace mtd = mir::test::doubles;
314+namespace geom = mir::geometry;
315+namespace me = mir::examples;
316+namespace mc = mir::compositor;
317+
318+struct DemoRenderer : public testing::Test
319+{
320+ testing::NiceMock<mtd::MockGL> mock_gl;
321+ mtd::StubGLProgramFactory stub_factory;
322+ geom::Rectangle region{{0, 0}, {100, 100}};
323+ mc::DestinationAlpha dest_alpha{mc::DestinationAlpha::opaque};
324+ int const shadow_radius{20};
325+ int const titlebar_height{5};
326+};
327+
328+TEST_F(DemoRenderer, detects_embellishments_on_renderables)
329+{
330+ me::DemoRenderer demo_renderer(stub_factory, region, dest_alpha, titlebar_height, shadow_radius);
331+
332+ mtd::FakeRenderable fullscreen_surface(region);
333+ mtd::FakeRenderable oversized_surface(geom::Rectangle{{-10, -10}, {120, 120}});
334+ mtd::FakeRenderable top_shadow(geom::Rectangle{{0, 105}, {10, 10}});
335+ mtd::FakeRenderable right_shadow(geom::Rectangle{{-10, 0}, {10, 10}});
336+ mtd::FakeRenderable left_shadow(geom::Rectangle{{100, 0}, {10, 10}});
337+ mtd::FakeRenderable bottom_shadow(geom::Rectangle{{-10, 0}, {10, 10}});
338+ mtd::FakeRenderable only_titlebar(geom::Rectangle{{0, 5}, {100, 95}});
339+
340+ EXPECT_TRUE(demo_renderer.would_embellish(top_shadow, region));
341+ EXPECT_TRUE(demo_renderer.would_embellish(right_shadow, region));
342+ EXPECT_TRUE(demo_renderer.would_embellish(bottom_shadow, region));
343+ EXPECT_TRUE(demo_renderer.would_embellish(left_shadow, region));
344+ EXPECT_TRUE(demo_renderer.would_embellish(only_titlebar, region));
345+ EXPECT_FALSE(demo_renderer.would_embellish(fullscreen_surface, region));
346+ EXPECT_FALSE(demo_renderer.would_embellish(oversized_surface, region));
347+}

Subscribers

People subscribed via source and target branches