rendering_stats_instrumentation.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
  5. #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "base/synchronization/lock.h"
  9. #include "cc/debug/rendering_stats.h"
  10. namespace cc {
  11. // RenderingStatsInstrumentation is shared among threads and manages conditional
  12. // recording of rendering stats into a private RenderingStats instance.
  13. class CC_DEBUG_EXPORT RenderingStatsInstrumentation {
  14. public:
  15. static std::unique_ptr<RenderingStatsInstrumentation> Create();
  16. RenderingStatsInstrumentation(const RenderingStatsInstrumentation&) = delete;
  17. virtual ~RenderingStatsInstrumentation();
  18. RenderingStatsInstrumentation& operator=(
  19. const RenderingStatsInstrumentation&) = delete;
  20. // Return copy of current impl thread rendering stats, and resets the current
  21. // stats.
  22. RenderingStats TakeImplThreadRenderingStats();
  23. // Read and write access to the record_rendering_stats_ flag is not locked to
  24. // improve performance. The flag is commonly turned off and hardly changes
  25. // it's value during runtime.
  26. bool record_rendering_stats() const { return record_rendering_stats_; }
  27. void set_record_rendering_stats(bool record_rendering_stats) {
  28. if (record_rendering_stats_ != record_rendering_stats)
  29. record_rendering_stats_ = record_rendering_stats;
  30. }
  31. void IncrementFrameCount(int64_t count);
  32. void AddVisibleContentArea(int64_t area);
  33. void AddApproximatedVisibleContentArea(int64_t area);
  34. void AddCheckerboardedVisibleContentArea(int64_t area);
  35. void AddCheckerboardedNoRecordingContentArea(int64_t area);
  36. void AddCheckerboardedNeedsRasterContentArea(int64_t area);
  37. void AddDrawDuration(base::TimeDelta draw_duration,
  38. base::TimeDelta draw_duration_estimate);
  39. void AddBeginMainFrameToCommitDuration(
  40. base::TimeDelta begin_main_frame_to_commit_duration);
  41. void AddCommitToActivateDuration(
  42. base::TimeDelta commit_to_activate_duration,
  43. base::TimeDelta commit_to_activate_duration_estimate);
  44. protected:
  45. RenderingStatsInstrumentation();
  46. private:
  47. RenderingStats impl_thread_rendering_stats_;
  48. bool record_rendering_stats_;
  49. base::Lock lock_;
  50. };
  51. } // namespace cc
  52. #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_