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
1=== modified file 'src/server/scene/rendering_tracker.cpp'
2--- src/server/scene/rendering_tracker.cpp 2015-02-22 07:46:25 +0000
3+++ src/server/scene/rendering_tracker.cpp 2015-10-30 14:37:35 +0000
4@@ -68,6 +68,18 @@
5 configure_visibility(mir_surface_visibility_occluded);
6 }
7
8+bool ms::RenderingTracker::is_exposed_in(mc::CompositorID cid) const
9+{
10+ std::lock_guard<std::mutex> lock{guard};
11+
12+ ensure_is_active_compositor(cid);
13+
14+ if (occlusions.size() == 0)
15+ return true;
16+
17+ return occlusions.find(cid) == occlusions.end();
18+}
19+
20 bool ms::RenderingTracker::occluded_in_all_active_compositors()
21 {
22 return occlusions == active_compositors_;
23
24=== modified file 'src/server/scene/rendering_tracker.h'
25--- src/server/scene/rendering_tracker.h 2015-02-22 07:46:25 +0000
26+++ src/server/scene/rendering_tracker.h 2015-10-30 14:37:35 +0000
27@@ -42,6 +42,7 @@
28 void rendered_in(compositor::CompositorID cid);
29 void occluded_in(compositor::CompositorID cid);
30 void active_compositors(std::set<compositor::CompositorID> const& cids);
31+ bool is_exposed_in(compositor::CompositorID cid) const;
32
33 private:
34 bool occluded_in_all_active_compositors();
35@@ -52,7 +53,7 @@
36 std::weak_ptr<Surface> const weak_surface;
37 std::set<compositor::CompositorID> occlusions;
38 std::set<compositor::CompositorID> active_compositors_;
39- std::mutex guard;
40+ std::mutex mutable guard;
41 };
42
43 }
44
45=== modified file 'src/server/scene/surface_stack.cpp'
46--- src/server/scene/surface_stack.cpp 2015-06-18 02:46:16 +0000
47+++ src/server/scene/surface_stack.cpp 2015-10-30 14:37:35 +0000
48@@ -168,15 +168,18 @@
49 // TODO: Rename mir_surface_attrib_visibility as it's obviously
50 // confusing with visible()
51 if (surface->visible() &&
52- surface->query(mir_surface_attrib_visibility) ==
53- mir_surface_visibility_exposed)
54+ surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed)
55 {
56- // Note that we ask the surface and not a Renderable.
57- // This is because we don't want to waste time and resources
58- // on a snapshot till we're sure we need it...
59- int ready = surface->buffers_ready_for_compositor(id);
60- if (ready > result)
61- result = ready;
62+ auto const tracker = rendering_trackers.find(surface.get());
63+ if (tracker != rendering_trackers.end() && tracker->second->is_exposed_in(id))
64+ {
65+ // Note that we ask the surface and not a Renderable.
66+ // This is because we don't want to waste time and resources
67+ // on a snapshot till we're sure we need it...
68+ int ready = surface->buffers_ready_for_compositor(id);
69+ if (ready > result)
70+ result = ready;
71+ }
72 }
73 }
74 }
75
76=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
77--- tests/unit-tests/scene/test_surface_stack.cpp 2015-06-26 08:00:59 +0000
78+++ tests/unit-tests/scene/test_surface_stack.cpp 2015-10-30 14:37:35 +0000
79@@ -339,6 +339,7 @@
80 {
81 using namespace testing;
82 ms::SurfaceStack stack{report};
83+ stack.register_compositor(this);
84 mtd::StubBuffer stub_buffer;
85 int ready = 0;
86 auto mock_queue = std::make_shared<testing::NiceMock<mtd::MockBufferBundle>>();
87@@ -384,6 +385,7 @@
88 using namespace testing;
89
90 ms::SurfaceStack stack{report};
91+ stack.register_compositor(this);
92 auto surface = std::make_shared<ms::BasicSurface>(
93 std::string("stub"),
94 geom::Rectangle{{},{}},
95@@ -405,6 +407,48 @@
96 EXPECT_EQ(0, stack.frames_pending(this));
97 }
98
99+TEST_F(SurfaceStack, scene_doesnt_count_pending_frames_from_partially_exposed_surfaces)
100+{ // Regression test for LP: #1499039
101+ using namespace testing;
102+
103+ // Partially exposed means occluded in one compositor but not another
104+ ms::SurfaceStack stack{report};
105+ auto const comp1 = reinterpret_cast<mc::CompositorID>(0);
106+ auto const comp2 = reinterpret_cast<mc::CompositorID>(1);
107+
108+ stack.register_compositor(comp1);
109+ stack.register_compositor(comp2);
110+ auto surface = std::make_shared<ms::BasicSurface>(
111+ std::string("stub"),
112+ geom::Rectangle{{},{}},
113+ false,
114+ std::make_shared<mtd::StubBufferStream>(),
115+ std::shared_ptr<mir::input::InputChannel>(),
116+ std::shared_ptr<mir::input::InputSender>(),
117+ std::shared_ptr<mg::CursorImage>(),
118+ report);
119+
120+ stack.add_surface(surface, default_params.depth, default_params.input_mode);
121+ post_a_frame(*surface);
122+ post_a_frame(*surface);
123+ post_a_frame(*surface);
124+
125+ EXPECT_EQ(3, stack.frames_pending(comp2));
126+ auto elements = stack.scene_elements_for(comp1);
127+ for (auto const& elem : elements)
128+ {
129+ elem->rendered();
130+ }
131+
132+ elements = stack.scene_elements_for(comp2);
133+ for (auto const& elem : elements)
134+ {
135+ elem->occluded();
136+ }
137+
138+ EXPECT_EQ(0, stack.frames_pending(comp2));
139+}
140+
141 TEST_F(SurfaceStack, surfaces_are_emitted_by_layer)
142 {
143 using namespace testing;

Subscribers

People subscribed via source and target branches