1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74

cc / debug / rendering_stats.cc [blame]

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/debug/rendering_stats.h"

#include <utility>

namespace cc {

RenderingStats::TimeDeltaList::TimeDeltaList() = default;

RenderingStats::TimeDeltaList::TimeDeltaList(TimeDeltaList&& other) = default;

RenderingStats::TimeDeltaList& RenderingStats::TimeDeltaList::operator=(
    TimeDeltaList&& other) = default;

RenderingStats::TimeDeltaList::~TimeDeltaList() = default;

void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) {
  values.push_back(value);
}

void RenderingStats::TimeDeltaList::AddToTracedValue(
    const char* name,
    base::trace_event::TracedValue* list_value) const {
  list_value->BeginArray(name);
  for (const auto& value : values) {
    list_value->AppendDouble(value.InMillisecondsF());
  }
  list_value->EndArray();
}

void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) {
  values.insert(values.end(), other.values.begin(), other.values.end());
}

base::TimeDelta RenderingStats::TimeDeltaList::GetLastTimeDelta() const {
  return values.empty() ? base::TimeDelta() : values.back();
}

RenderingStats::RenderingStats() = default;

RenderingStats::RenderingStats(RenderingStats&& other) = default;

RenderingStats& RenderingStats::operator=(RenderingStats&& other) = default;

RenderingStats::~RenderingStats() = default;

std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
RenderingStats::AsTraceableData() const {
  std::unique_ptr<base::trace_event::TracedValue> record_data(
      new base::trace_event::TracedValue());
  record_data->SetInteger("frame_count", frame_count);
  record_data->SetInteger("visible_content_area", visible_content_area);
  record_data->SetInteger("approximated_visible_content_area",
                          approximated_visible_content_area);
  draw_duration.AddToTracedValue("draw_duration_ms", record_data.get());

  draw_duration_estimate.AddToTracedValue("draw_duration_estimate_ms",
                                          record_data.get());

  begin_main_frame_to_commit_duration.AddToTracedValue(
      "begin_main_frame_to_commit_duration_ms", record_data.get());

  commit_to_activate_duration.AddToTracedValue("commit_to_activate_duration_ms",
                                               record_data.get());

  commit_to_activate_duration_estimate.AddToTracedValue(
      "commit_to_activate_duration_estimate_ms", record_data.get());
  return std::move(record_data);
}

}  // namespace cc