Mir
compositor_report.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17  */
18 
19 #ifndef MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
20 #define MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
21 
23 #include "mir/time/clock.h"
24 #include <memory>
25 #include <mutex>
26 #include <unordered_map>
27 #include <chrono>
28 
29 namespace mir
30 {
31 namespace logging
32 {
33 class Logger;
34 }
35 namespace report
36 {
37 namespace logging
38 {
39 
41 {
42 public:
43  CompositorReport(std::shared_ptr<mir::logging::Logger> const& logger,
44  std::shared_ptr<time::Clock> const& clock);
45  void added_display(int width, int height, int x, int y, SubCompositorId id) override;
46  void began_frame(SubCompositorId id) override;
47  void renderables_in_frame(SubCompositorId id, graphics::RenderableList const& renderables) override;
48  void rendered_frame(SubCompositorId id) override;
49  void finished_frame(SubCompositorId id) override;
50  void started() override;
51  void stopped() override;
52  void scheduled() override;
53 
54 private:
55  std::shared_ptr<mir::logging::Logger> const logger;
56  std::shared_ptr<time::Clock> const clock;
57 
58  typedef time::Timestamp TimePoint;
59  TimePoint now() const;
60 
61  struct Instance
62  {
63  TimePoint start_of_frame;
64  TimePoint end_of_frame;
65  TimePoint total_time_sum;
66  TimePoint render_time_sum;
67  TimePoint latency_sum;
68  long nframes = 0;
69  long nbypassed = 0;
70  bool bypassed = true;
71  bool prev_bypassed = false;
72 
73  TimePoint last_reported_total_time_sum;
74  TimePoint last_reported_render_time_sum;
75  TimePoint last_reported_latency_sum;
76  long last_reported_nframes = 0;
77  long last_reported_bypassed = 0;
78 
79  void log(mir::logging::Logger& logger, SubCompositorId id);
80  };
81 
82  std::mutex mutex; // Protects the following...
83  std::unordered_map<SubCompositorId, Instance> instance;
84  TimePoint last_scheduled;
85  TimePoint last_report;
86 };
87 
88 } // namespace logging
89 } // namespace report
90 } // namespace mir
91 
92 #endif // MIR_REPORT_LOGGING_COMPOSITOR_REPORT_H_
All things Mir.
Definition: atomic_callback.h:25
void rendered_frame(SubCompositorId id) override
void log(logging::Severity sev, char const *component, char const *fmt,...)
Definition: log.cpp:39
const void * SubCompositorId
Definition: compositor_report.h:32
void began_frame(SubCompositorId id) override
Definition: compositor_report.h:40
std::chrono::steady_clock::time_point Timestamp
Definition: types.h:29
void renderables_in_frame(SubCompositorId id, graphics::RenderableList const &renderables) override
Definition: logger.h:41
unsigned int width
Definition: black_arrow.c:4
Definition: compositor_report.h:29
void added_display(int width, int height, int x, int y, SubCompositorId id) override
unsigned int height
Definition: black_arrow.c:5
std::vector< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:79
void finished_frame(SubCompositorId id) override

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015