Mir

Merge lp:~albaguirre/mir/fix-1499039 into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 3073
Proposed branch: lp:~albaguirre/mir/fix-1499039
Merge into: lp:mir
Diff against target: 143 lines (+69/-9)
4 files modified
src/server/scene/rendering_tracker.cpp (+12/-0)
src/server/scene/rendering_tracker.h (+2/-1)
src/server/scene/surface_stack.cpp (+11/-8)
tests/unit-tests/scene/test_surface_stack.cpp (+44/-0)
To merge this branch: bzr merge lp:~albaguirre/mir/fix-1499039
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alan Griffiths Approve
Review via email: mp+276197@code.launchpad.net

Commit message

compositor: do not count pending frames from partially exposed surfaces

When querying the pending frames for a specific compositor, do not count frames in surfaces that have only been exposed in different compositor.

Description of the change

compositor: do not count pending frames from partially exposed surfaces

When querying the pending frames for a specific compositor, do not count frames in surfaces that have only been exposed in different compositor.

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
Alan Griffiths (alan-griffiths) wrote :

Nits:

Seems to upset vivid builds. Because I don't think you mean this:

+ auto comp1{reinterpret_cast<mc::CompositorID>(0)};
+ auto comp2{reinterpret_cast<mc::CompositorID>(1)};

But

    auto const comp1 = reinterpret_cast<mc::CompositorID>(0);
    auto const comp2 = reinterpret_cast<mc::CompositorID>(1);

Using "auto" with initializer lists is a Bad Idea as it rarely does what you intend.

~~~~

+ mutable std::mutex guard;

cv-qualifiers should follow the type

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

plausible

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

lgtm

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/scene/rendering_tracker.cpp'
--- src/server/scene/rendering_tracker.cpp 2015-02-22 07:46:25 +0000
+++ src/server/scene/rendering_tracker.cpp 2015-10-30 14:37:35 +0000
@@ -68,6 +68,18 @@
68 configure_visibility(mir_surface_visibility_occluded);68 configure_visibility(mir_surface_visibility_occluded);
69}69}
7070
71bool ms::RenderingTracker::is_exposed_in(mc::CompositorID cid) const
72{
73 std::lock_guard<std::mutex> lock{guard};
74
75 ensure_is_active_compositor(cid);
76
77 if (occlusions.size() == 0)
78 return true;
79
80 return occlusions.find(cid) == occlusions.end();
81}
82
71bool ms::RenderingTracker::occluded_in_all_active_compositors()83bool ms::RenderingTracker::occluded_in_all_active_compositors()
72{84{
73 return occlusions == active_compositors_;85 return occlusions == active_compositors_;
7486
=== modified file 'src/server/scene/rendering_tracker.h'
--- src/server/scene/rendering_tracker.h 2015-02-22 07:46:25 +0000
+++ src/server/scene/rendering_tracker.h 2015-10-30 14:37:35 +0000
@@ -42,6 +42,7 @@
42 void rendered_in(compositor::CompositorID cid);42 void rendered_in(compositor::CompositorID cid);
43 void occluded_in(compositor::CompositorID cid);43 void occluded_in(compositor::CompositorID cid);
44 void active_compositors(std::set<compositor::CompositorID> const& cids);44 void active_compositors(std::set<compositor::CompositorID> const& cids);
45 bool is_exposed_in(compositor::CompositorID cid) const;
4546
46private:47private:
47 bool occluded_in_all_active_compositors();48 bool occluded_in_all_active_compositors();
@@ -52,7 +53,7 @@
52 std::weak_ptr<Surface> const weak_surface;53 std::weak_ptr<Surface> const weak_surface;
53 std::set<compositor::CompositorID> occlusions;54 std::set<compositor::CompositorID> occlusions;
54 std::set<compositor::CompositorID> active_compositors_;55 std::set<compositor::CompositorID> active_compositors_;
55 std::mutex guard;56 std::mutex mutable guard;
56};57};
5758
58}59}
5960
=== modified file 'src/server/scene/surface_stack.cpp'
--- src/server/scene/surface_stack.cpp 2015-06-18 02:46:16 +0000
+++ src/server/scene/surface_stack.cpp 2015-10-30 14:37:35 +0000
@@ -168,15 +168,18 @@
168 // TODO: Rename mir_surface_attrib_visibility as it's obviously168 // TODO: Rename mir_surface_attrib_visibility as it's obviously
169 // confusing with visible()169 // confusing with visible()
170 if (surface->visible() &&170 if (surface->visible() &&
171 surface->query(mir_surface_attrib_visibility) ==171 surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed)
172 mir_surface_visibility_exposed)
173 {172 {
174 // Note that we ask the surface and not a Renderable.173 auto const tracker = rendering_trackers.find(surface.get());
175 // This is because we don't want to waste time and resources174 if (tracker != rendering_trackers.end() && tracker->second->is_exposed_in(id))
176 // on a snapshot till we're sure we need it...175 {
177 int ready = surface->buffers_ready_for_compositor(id);176 // Note that we ask the surface and not a Renderable.
178 if (ready > result)177 // This is because we don't want to waste time and resources
179 result = ready;178 // on a snapshot till we're sure we need it...
179 int ready = surface->buffers_ready_for_compositor(id);
180 if (ready > result)
181 result = ready;
182 }
180 }183 }
181 }184 }
182 }185 }
183186
=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
--- tests/unit-tests/scene/test_surface_stack.cpp 2015-06-26 08:00:59 +0000
+++ tests/unit-tests/scene/test_surface_stack.cpp 2015-10-30 14:37:35 +0000
@@ -339,6 +339,7 @@
339{339{
340 using namespace testing;340 using namespace testing;
341 ms::SurfaceStack stack{report};341 ms::SurfaceStack stack{report};
342 stack.register_compositor(this);
342 mtd::StubBuffer stub_buffer;343 mtd::StubBuffer stub_buffer;
343 int ready = 0;344 int ready = 0;
344 auto mock_queue = std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>();345 auto mock_queue = std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>();
@@ -384,6 +385,7 @@
384 using namespace testing;385 using namespace testing;
385386
386 ms::SurfaceStack stack{report};387 ms::SurfaceStack stack{report};
388 stack.register_compositor(this);
387 auto surface = std::make_shared<ms::BasicSurface>(389 auto surface = std::make_shared<ms::BasicSurface>(
388 std::string("stub"),390 std::string("stub"),
389 geom::Rectangle{{},{}},391 geom::Rectangle{{},{}},
@@ -405,6 +407,48 @@
405 EXPECT_EQ(0, stack.frames_pending(this));407 EXPECT_EQ(0, stack.frames_pending(this));
406}408}
407409
410TEST_F(SurfaceStack, scene_doesnt_count_pending_frames_from_partially_exposed_surfaces)
411{ // Regression test for LP: #1499039
412 using namespace testing;
413
414 // Partially exposed means occluded in one compositor but not another
415 ms::SurfaceStack stack{report};
416 auto const comp1 = reinterpret_cast<mc::CompositorID>(0);
417 auto const comp2 = reinterpret_cast<mc::CompositorID>(1);
418
419 stack.register_compositor(comp1);
420 stack.register_compositor(comp2);
421 auto surface = std::make_shared<ms::BasicSurface>(
422 std::string("stub"),
423 geom::Rectangle{{},{}},
424 false,
425 std::make_shared<mtd::StubBufferStream>(),
426 std::shared_ptr<mir::input::InputChannel>(),
427 std::shared_ptr<mir::input::InputSender>(),
428 std::shared_ptr<mg::CursorImage>(),
429 report);
430
431 stack.add_surface(surface, default_params.depth, default_params.input_mode);
432 post_a_frame(*surface);
433 post_a_frame(*surface);
434 post_a_frame(*surface);
435
436 EXPECT_EQ(3, stack.frames_pending(comp2));
437 auto elements = stack.scene_elements_for(comp1);
438 for (auto const& elem : elements)
439 {
440 elem->rendered();
441 }
442
443 elements = stack.scene_elements_for(comp2);
444 for (auto const& elem : elements)
445 {
446 elem->occluded();
447 }
448
449 EXPECT_EQ(0, stack.frames_pending(comp2));
450}
451
408TEST_F(SurfaceStack, surfaces_are_emitted_by_layer)452TEST_F(SurfaceStack, surfaces_are_emitted_by_layer)
409{453{
410 using namespace testing;454 using namespace testing;

Subscribers

People subscribed via source and target branches