diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-12-05 15:04:29 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-09 10:49:28 +0100 |
commit | af6588f8d723931a298c995fa97259bb7f7deb55 (patch) | |
tree | 060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/cc/debug | |
parent | 2fff84d821cc7b1c785f6404e0f8091333283e74 (diff) | |
download | qtwebengine-chromium-af6588f8d723931a298c995fa97259bb7f7deb55.tar.gz |
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/cc/debug')
31 files changed, 511 insertions, 294 deletions
diff --git a/chromium/cc/debug/benchmark_instrumentation.cc b/chromium/cc/debug/benchmark_instrumentation.cc index bf2b0222720..74caae8bcc2 100644 --- a/chromium/cc/debug/benchmark_instrumentation.cc +++ b/chromium/cc/debug/benchmark_instrumentation.cc @@ -6,25 +6,39 @@ #include "cc/debug/benchmark_instrumentation.h" namespace cc { +namespace benchmark_instrumentation { // Please do not change the trace events in this file without updating // tools/perf/measurements/rendering_stats.py accordingly. // The benchmarks search for events and their arguments by name. -void BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( - const MainThreadRenderingStats& stats) { +void IssueMainThreadRenderingStatsEvent( + const RenderingStats::MainThreadRenderingStats& stats) { TRACE_EVENT_INSTANT1("benchmark", "BenchmarkInstrumentation::MainThreadRenderingStats", TRACE_EVENT_SCOPE_THREAD, "data", stats.AsTraceableData()); } -void BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent( - const ImplThreadRenderingStats& stats) { +void IssueImplThreadRenderingStatsEvent( + const RenderingStats::ImplThreadRenderingStats& stats) { TRACE_EVENT_INSTANT1("benchmark", "BenchmarkInstrumentation::ImplThreadRenderingStats", TRACE_EVENT_SCOPE_THREAD, "data", stats.AsTraceableData()); } +void IssueDisplayRenderingStatsEvent() { + scoped_refptr<base::debug::TracedValue> record_data = + new base::debug::TracedValue(); + record_data->SetInteger("frame_count", 1); + TRACE_EVENT_INSTANT1( + "benchmark", + "BenchmarkInstrumentation::DisplayRenderingStats", + TRACE_EVENT_SCOPE_THREAD, + "data", + scoped_refptr<base::debug::ConvertableToTraceFormat>(record_data)); +} + +} // namespace benchmark_instrumentation } // namespace cc diff --git a/chromium/cc/debug/benchmark_instrumentation.h b/chromium/cc/debug/benchmark_instrumentation.h index 2614814914c..bd524b99042 100644 --- a/chromium/cc/debug/benchmark_instrumentation.h +++ b/chromium/cc/debug/benchmark_instrumentation.h @@ -5,18 +5,50 @@ #ifndef CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ #define CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ +#include "cc/base/cc_export.h" #include "cc/debug/rendering_stats.h" namespace cc { +namespace benchmark_instrumentation { -class CC_EXPORT BenchmarkInstrumentation { +// Please do not change the trace events in this file without updating +// tools/perf/measurements/rendering_stats.py accordingly. +// The benchmarks search for events and their arguments by name. + +namespace internal { +const char kCategory[] = "cc,benchmark"; +const char kBeginFrameId[] = "begin_frame_id"; +} // namespace internal + +const char kSendBeginFrame[] = "ThreadProxy::ScheduledActionSendBeginMainFrame"; +const char kDoBeginFrame[] = "ThreadProxy::BeginMainFrame"; + +class ScopedBeginFrameTask { public: - static void IssueMainThreadRenderingStatsEvent( - const MainThreadRenderingStats& stats); - static void IssueImplThreadRenderingStatsEvent( - const ImplThreadRenderingStats& stats); + ScopedBeginFrameTask(const char* event_name, unsigned int begin_frame_id) + : event_name_(event_name) { + TRACE_EVENT_BEGIN1(internal::kCategory, + event_name_, + internal::kBeginFrameId, + begin_frame_id); + } + ~ScopedBeginFrameTask() { + TRACE_EVENT_END0(internal::kCategory, event_name_); + } + + private: + const char* event_name_; + + DISALLOW_COPY_AND_ASSIGN(ScopedBeginFrameTask); }; +void IssueMainThreadRenderingStatsEvent( + const RenderingStats::MainThreadRenderingStats& stats); +void IssueImplThreadRenderingStatsEvent( + const RenderingStats::ImplThreadRenderingStats& stats); +void CC_EXPORT IssueDisplayRenderingStatsEvent(); + +} // namespace benchmark_instrumentation } // namespace cc #endif // CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_ diff --git a/chromium/cc/debug/debug_rect_history.cc b/chromium/cc/debug/debug_rect_history.cc index e8792e7789e..a8c50306134 100644 --- a/chromium/cc/debug/debug_rect_history.cc +++ b/chromium/cc/debug/debug_rect_history.cc @@ -82,7 +82,7 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) { float height_scale = layer->content_bounds().height() / static_cast<float>(layer->bounds().height()); gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect( - gfx::ToEnclosingRect(layer->update_rect()), width_scale, height_scale); + layer->update_rect(), width_scale, height_scale); debug_rects_.push_back( DebugRect(PAINT_RECT_TYPE, MathUtil::MapEnclosingClippedRect( diff --git a/chromium/cc/debug/debug_rect_history.h b/chromium/cc/debug/debug_rect_history.h index 278b20865a8..6d25b2964db 100644 --- a/chromium/cc/debug/debug_rect_history.h +++ b/chromium/cc/debug/debug_rect_history.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "cc/layers/layer_lists.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" namespace cc { diff --git a/chromium/cc/debug/frame_viewer_instrumentation.h b/chromium/cc/debug/frame_viewer_instrumentation.h index 16cf4335ac2..e0e54eb3cb8 100644 --- a/chromium/cc/debug/frame_viewer_instrumentation.h +++ b/chromium/cc/debug/frame_viewer_instrumentation.h @@ -18,22 +18,22 @@ const char kLayerId[] = "layerId"; const char kTileId[] = "tileId"; const char kTileResolution[] = "tileResolution"; const char kSourceFrameNumber[] = "sourceFrameNumber"; -const char kRasterMode[] = "rasterMode"; const char kAnalyzeTask[] = "AnalyzeTask"; const char kRasterTask[] = "RasterTask"; -scoped_ptr<base::Value> TileDataAsValue(const void* tile_id, - TileResolution tile_resolution, - int source_frame_number, - int layer_id) { - scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); - res->Set(internal::kTileId, TracedValue::CreateIDRef(tile_id).release()); - res->Set(internal::kTileResolution, - TileResolutionAsValue(tile_resolution).release()); +scoped_refptr<base::debug::ConvertableToTraceFormat> TileDataAsValue( + const void* tile_id, + TileResolution tile_resolution, + int source_frame_number, + int layer_id) { + scoped_refptr<base::debug::TracedValue> res(new base::debug::TracedValue()); + TracedValue::SetIDRef(tile_id, res.get(), internal::kTileId); + res->SetString(internal::kTileResolution, + TileResolutionToString(tile_resolution)); res->SetInteger(internal::kSourceFrameNumber, source_frame_number); res->SetInteger(internal::kLayerId, layer_id); - return res.PassAs<base::Value>(); + return res; } } // namespace internal @@ -48,10 +48,8 @@ class ScopedAnalyzeTask { internal::kCategory, internal::kAnalyzeTask, internal::kTileData, - TracedValue::FromValue(internal::TileDataAsValue(tile_id, - tile_resolution, - source_frame_number, - layer_id).release())); + internal::TileDataAsValue( + tile_id, tile_resolution, source_frame_number, layer_id)); } ~ScopedAnalyzeTask() { TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask); @@ -66,18 +64,13 @@ class ScopedRasterTask { ScopedRasterTask(const void* tile_id, TileResolution tile_resolution, int source_frame_number, - int layer_id, - RasterMode raster_mode) { - TRACE_EVENT_BEGIN2( + int layer_id) { + TRACE_EVENT_BEGIN1( internal::kCategory, internal::kRasterTask, internal::kTileData, - TracedValue::FromValue(internal::TileDataAsValue(tile_id, - tile_resolution, - source_frame_number, - layer_id).release()), - internal::kRasterMode, - TracedValue::FromValue(RasterModeAsValue(raster_mode).release())); + internal::TileDataAsValue( + tile_id, tile_resolution, source_frame_number, layer_id)); } ~ScopedRasterTask() { TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask); diff --git a/chromium/cc/debug/invalidation_benchmark.cc b/chromium/cc/debug/invalidation_benchmark.cc index f063fe71d74..1a6a2b83d6b 100644 --- a/chromium/cc/debug/invalidation_benchmark.cc +++ b/chromium/cc/debug/invalidation_benchmark.cc @@ -14,7 +14,7 @@ #include "cc/layers/picture_layer.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" namespace cc { @@ -28,7 +28,7 @@ InvalidationBenchmark::InvalidationBenchmark( scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback) : MicroBenchmark(callback), seed_(0) { - base::DictionaryValue* settings = NULL; + base::DictionaryValue* settings = nullptr; value->GetAsDictionary(&settings); if (!settings) return; @@ -111,7 +111,7 @@ void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) { } bool InvalidationBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { - base::DictionaryValue* message = NULL; + base::DictionaryValue* message = nullptr; value->GetAsDictionary(&message); if (!message) return false; diff --git a/chromium/cc/debug/invalidation_benchmark.h b/chromium/cc/debug/invalidation_benchmark.h index 00481ae4c36..f17fdbd2fd4 100644 --- a/chromium/cc/debug/invalidation_benchmark.h +++ b/chromium/cc/debug/invalidation_benchmark.h @@ -21,12 +21,12 @@ class CC_EXPORT InvalidationBenchmark : public MicroBenchmark { public: explicit InvalidationBenchmark(scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback); - virtual ~InvalidationBenchmark(); + ~InvalidationBenchmark() override; // Implements MicroBenchmark interface. - virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; - virtual void RunOnLayer(PictureLayer* layer) OVERRIDE; - virtual bool ProcessMessage(scoped_ptr<base::Value> value) OVERRIDE; + void DidUpdateLayers(LayerTreeHost* host) override; + void RunOnLayer(PictureLayer* layer) override; + bool ProcessMessage(scoped_ptr<base::Value> value) override; private: enum Mode { FIXED_SIZE, LAYER, VIEWPORT, RANDOM }; diff --git a/chromium/cc/debug/micro_benchmark.cc b/chromium/cc/debug/micro_benchmark.cc index 05c5c0d1a56..64629de165a 100644 --- a/chromium/cc/debug/micro_benchmark.cc +++ b/chromium/cc/debug/micro_benchmark.cc @@ -54,7 +54,7 @@ scoped_ptr<MicroBenchmarkImpl> MicroBenchmark::GetBenchmarkImpl( scoped_ptr<MicroBenchmarkImpl> MicroBenchmark::CreateBenchmarkImpl( scoped_refptr<base::MessageLoopProxy> origin_loop) { - return make_scoped_ptr<MicroBenchmarkImpl>(NULL); + return make_scoped_ptr<MicroBenchmarkImpl>(nullptr); } } // namespace cc diff --git a/chromium/cc/debug/micro_benchmark_controller.cc b/chromium/cc/debug/micro_benchmark_controller.cc index 8b20bdf197f..bf981005419 100644 --- a/chromium/cc/debug/micro_benchmark_controller.cc +++ b/chromium/cc/debug/micro_benchmark_controller.cc @@ -28,19 +28,16 @@ scoped_ptr<MicroBenchmark> CreateBenchmark( scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback) { if (name == "invalidation_benchmark") { - return scoped_ptr<MicroBenchmark>( - new InvalidationBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new InvalidationBenchmark(value.Pass(), callback)); } else if (name == "picture_record_benchmark") { - return scoped_ptr<MicroBenchmark>( - new PictureRecordBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new PictureRecordBenchmark(value.Pass(), callback)); } else if (name == "rasterize_and_record_benchmark") { - return scoped_ptr<MicroBenchmark>( + return make_scoped_ptr( new RasterizeAndRecordBenchmark(value.Pass(), callback)); } else if (name == "unittest_only_benchmark") { - return scoped_ptr<MicroBenchmark>( - new UnittestOnlyBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new UnittestOnlyBenchmark(value.Pass(), callback)); } - return scoped_ptr<MicroBenchmark>(); + return nullptr; } class IsDonePredicate { diff --git a/chromium/cc/debug/micro_benchmark_controller_unittest.cc b/chromium/cc/debug/micro_benchmark_controller_unittest.cc index 83faeabf9a1..a5683c4ed14 100644 --- a/chromium/cc/debug/micro_benchmark_controller_unittest.cc +++ b/chromium/cc/debug/micro_benchmark_controller_unittest.cc @@ -18,23 +18,27 @@ namespace { class MicroBenchmarkControllerTest : public testing::Test { public: - virtual void SetUp() OVERRIDE { + MicroBenchmarkControllerTest() + : layer_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D) {} + + virtual void SetUp() override { impl_proxy_ = make_scoped_ptr(new FakeImplProxy); shared_bitmap_manager_.reset(new TestSharedBitmapManager()); layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl( impl_proxy_.get(), shared_bitmap_manager_.get())); - layer_tree_host_ = FakeLayerTreeHost::Create(); + layer_tree_host_ = FakeLayerTreeHost::Create(&layer_tree_host_client_); layer_tree_host_->SetRootLayer(Layer::Create()); layer_tree_host_->InitializeForTesting(scoped_ptr<Proxy>(new FakeProxy)); } - virtual void TearDown() OVERRIDE { - layer_tree_host_impl_.reset(); - layer_tree_host_.reset(); - impl_proxy_.reset(); + virtual void TearDown() override { + layer_tree_host_impl_ = nullptr; + layer_tree_host_ = nullptr; + impl_proxy_ = nullptr; } + FakeLayerTreeHostClient layer_tree_host_client_; scoped_ptr<FakeLayerTreeHost> layer_tree_host_; scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_; @@ -50,14 +54,14 @@ void IncrementCallCount(int* count, scoped_ptr<base::Value> value) { TEST_F(MicroBenchmarkControllerTest, ScheduleFail) { int id = layer_tree_host_->ScheduleMicroBenchmark( - "non_existant_benchmark", scoped_ptr<base::Value>(), base::Bind(&Noop)); + "non_existant_benchmark", nullptr, base::Bind(&Noop)); EXPECT_EQ(id, 0); } TEST_F(MicroBenchmarkControllerTest, CommitScheduled) { EXPECT_FALSE(layer_tree_host_->needs_commit()); int id = layer_tree_host_->ScheduleMicroBenchmark( - "unittest_only_benchmark", scoped_ptr<base::Value>(), base::Bind(&Noop)); + "unittest_only_benchmark", nullptr, base::Bind(&Noop)); EXPECT_GT(id, 0); EXPECT_TRUE(layer_tree_host_->needs_commit()); } @@ -66,7 +70,7 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkRan) { int run_count = 0; int id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); @@ -81,12 +85,12 @@ TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) { int run_count = 0; int id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); @@ -98,12 +102,12 @@ TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) { id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); @@ -122,7 +126,7 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) { // Schedule a main thread benchmark. int id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - settings.PassAs<base::Value>(), + settings.Pass(), base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); @@ -143,30 +147,30 @@ TEST_F(MicroBenchmarkControllerTest, SendMessage) { // Send valid message to invalid benchmark (id = 0) scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue); message->SetBoolean("can_handle", true); - bool message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - 0, message.PassAs<base::Value>()); + bool message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(0, message.Pass()); EXPECT_FALSE(message_handled); // Schedule a benchmark int run_count = 0; int id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - scoped_ptr<base::Value>(), + nullptr, base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); // Send valid message to valid benchmark - message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); + message = make_scoped_ptr(new base::DictionaryValue); message->SetBoolean("can_handle", true); - message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - id, message.PassAs<base::Value>()); + message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass()); EXPECT_TRUE(message_handled); // Send invalid message to valid benchmark - message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); + message = make_scoped_ptr(new base::DictionaryValue); message->SetBoolean("can_handle", false); - message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - id, message.PassAs<base::Value>()); + message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass()); EXPECT_FALSE(message_handled); } diff --git a/chromium/cc/debug/paint_time_counter.cc b/chromium/cc/debug/paint_time_counter.cc index 7d5415427ff..41ef1a334a6 100644 --- a/chromium/cc/debug/paint_time_counter.cc +++ b/chromium/cc/debug/paint_time_counter.cc @@ -11,18 +11,11 @@ scoped_ptr<PaintTimeCounter> PaintTimeCounter::Create() { return make_scoped_ptr(new PaintTimeCounter()); } -PaintTimeCounter::PaintTimeCounter() - : can_save_paint_time_delta_(false) { +PaintTimeCounter::PaintTimeCounter() { } -void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) { - if (can_save_paint_time_delta_) { - base::TimeDelta paint_time = total_paint_time - last_total_paint_time_; - ring_buffer_.SaveToBuffer(paint_time); - } - - last_total_paint_time_ = total_paint_time; - can_save_paint_time_delta_ = true; +void PaintTimeCounter::SavePaintTime(const base::TimeDelta& paint_time) { + ring_buffer_.SaveToBuffer(paint_time); } void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, @@ -45,7 +38,6 @@ void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, void PaintTimeCounter::ClearHistory() { ring_buffer_.Clear(); - can_save_paint_time_delta_ = false; } } // namespace cc diff --git a/chromium/cc/debug/paint_time_counter.h b/chromium/cc/debug/paint_time_counter.h index 8d109d03f73..c93980bc836 100644 --- a/chromium/cc/debug/paint_time_counter.h +++ b/chromium/cc/debug/paint_time_counter.h @@ -36,8 +36,6 @@ class PaintTimeCounter { PaintTimeCounter(); RingBufferType ring_buffer_; - base::TimeDelta last_total_paint_time_; - bool can_save_paint_time_delta_; DISALLOW_COPY_AND_ASSIGN(PaintTimeCounter); }; diff --git a/chromium/cc/debug/picture_record_benchmark.cc b/chromium/cc/debug/picture_record_benchmark.cc index a1528c36d7d..5f832ae4897 100644 --- a/chromium/cc/debug/picture_record_benchmark.cc +++ b/chromium/cc/debug/picture_record_benchmark.cc @@ -12,7 +12,7 @@ #include "cc/layers/picture_layer.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" namespace cc { @@ -31,13 +31,13 @@ PictureRecordBenchmark::PictureRecordBenchmark( if (!value) return; - base::ListValue* list = NULL; + base::ListValue* list = nullptr; value->GetAsList(&list); if (!list) return; for (base::ListValue::iterator it = list->begin(); it != list->end(); ++it) { - base::DictionaryValue* dictionary = NULL; + base::DictionaryValue* dictionary = nullptr; (*it)->GetAsDictionary(&dictionary); if (!dictionary || !dictionary->HasKey("width") || @@ -80,7 +80,7 @@ void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { results->Append(result.release()); } - NotifyDone(results.PassAs<base::Value>()); + NotifyDone(results.Pass()); } void PictureRecordBenchmark::Run(Layer* layer) { @@ -111,7 +111,7 @@ void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) { base::TimeTicks start = base::TimeTicks::HighResNow(); scoped_refptr<Picture> picture = Picture::Create( - rect, painter, tile_grid_info, false, 0, Picture::RECORD_NORMALLY); + rect, painter, tile_grid_info, false, Picture::RECORD_NORMALLY); base::TimeTicks end = base::TimeTicks::HighResNow(); base::TimeDelta duration = end - start; diff --git a/chromium/cc/debug/picture_record_benchmark.h b/chromium/cc/debug/picture_record_benchmark.h index 89f2bc0781e..d6330fe1adb 100644 --- a/chromium/cc/debug/picture_record_benchmark.h +++ b/chromium/cc/debug/picture_record_benchmark.h @@ -20,18 +20,18 @@ class CC_EXPORT PictureRecordBenchmark : public MicroBenchmark { public: explicit PictureRecordBenchmark(scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback); - virtual ~PictureRecordBenchmark(); + ~PictureRecordBenchmark() override; // Implements MicroBenchmark interface. - virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; - virtual void RunOnLayer(PictureLayer* layer) OVERRIDE; + void DidUpdateLayers(LayerTreeHost* host) override; + void RunOnLayer(PictureLayer* layer) override; private: void Run(Layer* layer); typedef std::pair<base::TimeDelta, unsigned> TotalTime; std::map<std::pair<int, int>, TotalTime> times_; - std::vector<std::pair<int, int> > dimensions_; + std::vector<std::pair<int, int>> dimensions_; }; } // namespace cc diff --git a/chromium/cc/debug/rasterize_and_record_benchmark.cc b/chromium/cc/debug/rasterize_and_record_benchmark.cc index 197fb291a05..f24dce3baf1 100644 --- a/chromium/cc/debug/rasterize_and_record_benchmark.cc +++ b/chromium/cc/debug/rasterize_and_record_benchmark.cc @@ -17,7 +17,7 @@ #include "cc/layers/picture_layer.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" namespace cc { @@ -26,7 +26,9 @@ namespace { const int kDefaultRecordRepeatCount = 100; const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { - "", "_sk_null_canvas", "_painting_disabled", "_skrecord"}; + "", + "_sk_null_canvas", + "_painting_disabled"}; } // namespace @@ -37,9 +39,9 @@ RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( record_repeat_count_(kDefaultRecordRepeatCount), settings_(value.Pass()), main_thread_benchmark_done_(false), - host_(NULL), + host_(nullptr), weak_ptr_factory_(this) { - base::DictionaryValue* settings = NULL; + base::DictionaryValue* settings = nullptr; settings_->GetAsDictionary(&settings); if (!settings) return; @@ -74,18 +76,18 @@ void RasterizeAndRecordBenchmark::RecordRasterResults( scoped_ptr<base::Value> results_value) { DCHECK(main_thread_benchmark_done_); - base::DictionaryValue* results = NULL; + base::DictionaryValue* results = nullptr; results_value->GetAsDictionary(&results); DCHECK(results); results_->MergeDictionary(results); - NotifyDone(results_.PassAs<base::Value>()); + NotifyDone(results_.Pass()); } scoped_ptr<MicroBenchmarkImpl> RasterizeAndRecordBenchmark::CreateBenchmarkImpl( scoped_refptr<base::MessageLoopProxy> origin_loop) { - return scoped_ptr<MicroBenchmarkImpl>(new RasterizeAndRecordBenchmarkImpl( + return make_scoped_ptr(new RasterizeAndRecordBenchmarkImpl( origin_loop, settings_.get(), base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, @@ -130,7 +132,7 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { kTimeCheckInterval); do { scoped_refptr<Picture> picture = Picture::Create( - visible_content_rect, painter, tile_grid_info, false, 0, mode); + visible_content_rect, painter, tile_grid_info, false, mode); timer.NextLap(); } while (!timer.HasTimeLimitExpired()); base::TimeDelta duration = diff --git a/chromium/cc/debug/rasterize_and_record_benchmark.h b/chromium/cc/debug/rasterize_and_record_benchmark.h index e2942d4b3e2..68d5d05fe6c 100644 --- a/chromium/cc/debug/rasterize_and_record_benchmark.h +++ b/chromium/cc/debug/rasterize_and_record_benchmark.h @@ -27,14 +27,14 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark { explicit RasterizeAndRecordBenchmark( scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback); - virtual ~RasterizeAndRecordBenchmark(); + ~RasterizeAndRecordBenchmark() override; // Implements MicroBenchmark interface. - virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; - virtual void RunOnLayer(PictureLayer* layer) OVERRIDE; + void DidUpdateLayers(LayerTreeHost* host) override; + void RunOnLayer(PictureLayer* layer) override; - virtual scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( - scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE; + scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) override; private: void Run(Layer* layer); diff --git a/chromium/cc/debug/rasterize_and_record_benchmark_impl.cc b/chromium/cc/debug/rasterize_and_record_benchmark_impl.cc index a22c2cd4d28..2ffac1b38d6 100644 --- a/chromium/cc/debug/rasterize_and_record_benchmark_impl.cc +++ b/chromium/cc/debug/rasterize_and_record_benchmark_impl.cc @@ -15,7 +15,7 @@ #include "cc/resources/raster_worker_pool.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_host_impl.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" namespace cc { @@ -25,11 +25,11 @@ const int kDefaultRasterizeRepeatCount = 100; class BenchmarkRasterTask : public Task { public: - BenchmarkRasterTask(PicturePileImpl* picture_pile, + BenchmarkRasterTask(RasterSource* raster_source, const gfx::Rect& content_rect, float contents_scale, size_t repeat_count) - : picture_pile_(picture_pile), + : raster_source_(raster_source), content_rect_(content_rect), contents_scale_(contents_scale), repeat_count_(repeat_count), @@ -37,10 +37,7 @@ class BenchmarkRasterTask : public Task { best_time_(base::TimeDelta::Max()) {} // Overridden from Task: - virtual void RunOnWorkerThread() OVERRIDE { - PicturePileImpl* picture_pile = picture_pile_->GetCloneForDrawingOnThread( - RasterWorkerPool::GetPictureCloneIndexForCurrentThread()); - + void RunOnWorkerThread() override { // Parameters for LapTimer. const int kTimeLimitMillis = 1; const int kWarmupRuns = 0; @@ -57,12 +54,12 @@ class BenchmarkRasterTask : public Task { bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), content_rect_.height())); SkCanvas canvas(bitmap); - PicturePileImpl::Analysis analysis; + RasterSource::SolidColorAnalysis analysis; - picture_pile->AnalyzeInRect( - content_rect_, contents_scale_, &analysis, NULL); - picture_pile->RasterToBitmap( - &canvas, content_rect_, contents_scale_, NULL); + raster_source_->PerformSolidColorAnalysis(content_rect_, + contents_scale_, &analysis); + raster_source_->PlaybackToCanvas(&canvas, content_rect_, + contents_scale_); is_solid_color_ = analysis.is_solid_color; @@ -72,7 +69,6 @@ class BenchmarkRasterTask : public Task { base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); if (duration < best_time_) best_time_ = duration; - } } @@ -80,9 +76,9 @@ class BenchmarkRasterTask : public Task { base::TimeDelta GetBestTime() const { return best_time_; } private: - virtual ~BenchmarkRasterTask() {} + ~BenchmarkRasterTask() override {} - PicturePileImpl* picture_pile_; + RasterSource* raster_source_; gfx::Rect content_rect_; float contents_scale_; size_t repeat_count_; @@ -90,6 +86,64 @@ class BenchmarkRasterTask : public Task { base::TimeDelta best_time_; }; +class FixedInvalidationPictureLayerTilingClient + : public PictureLayerTilingClient { + public: + FixedInvalidationPictureLayerTilingClient( + PictureLayerTilingClient* base_client, + const Region invalidation) + : base_client_(base_client), invalidation_(invalidation) {} + + scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, + const gfx::Rect& content_rect) override { + return base_client_->CreateTile(tiling, content_rect); + } + + RasterSource* GetRasterSource() override { + return base_client_->GetRasterSource(); + } + + gfx::Size CalculateTileSize(const gfx::Size& content_bounds) const override { + return base_client_->CalculateTileSize(content_bounds); + } + + // This is the only function that returns something different from the base + // client. Avoids sharing tiles in this area. + const Region* GetPendingInvalidation() override { return &invalidation_; } + + const PictureLayerTiling* GetPendingOrActiveTwinTiling( + const PictureLayerTiling* tiling) const override { + return base_client_->GetPendingOrActiveTwinTiling(tiling); + } + + PictureLayerTiling* GetRecycledTwinTiling( + const PictureLayerTiling* tiling) override { + return base_client_->GetRecycledTwinTiling(tiling); + } + + size_t GetMaxTilesForInterestArea() const override { + return base_client_->GetMaxTilesForInterestArea(); + } + + float GetSkewportTargetTimeInSeconds() const override { + return base_client_->GetSkewportTargetTimeInSeconds(); + } + + int GetSkewportExtrapolationLimitInContentPixels() const override { + return base_client_->GetSkewportExtrapolationLimitInContentPixels(); + } + + WhichTree GetTree() const override { return base_client_->GetTree(); } + + bool RequiresHighResToDraw() const override { + return base_client_->RequiresHighResToDraw(); + } + + private: + PictureLayerTilingClient* base_client_; + Region invalidation_; +}; + } // namespace RasterizeAndRecordBenchmarkImpl::RasterizeAndRecordBenchmarkImpl( @@ -98,7 +152,7 @@ RasterizeAndRecordBenchmarkImpl::RasterizeAndRecordBenchmarkImpl( const MicroBenchmarkImpl::DoneCallback& callback) : MicroBenchmarkImpl(callback, origin_loop), rasterize_repeat_count_(kDefaultRasterizeRepeatCount) { - base::DictionaryValue* settings = NULL; + base::DictionaryValue* settings = nullptr; value->GetAsDictionary(&settings); if (!settings) return; @@ -132,7 +186,7 @@ void RasterizeAndRecordBenchmarkImpl::DidCompleteCommit( result->SetInteger("total_picture_layers_off_screen", rasterize_results_.total_picture_layers_off_screen); - NotifyDone(result.PassAs<base::Value>()); + NotifyDone(result.Pass()); } void RasterizeAndRecordBenchmarkImpl::Run(LayerImpl* layer) { @@ -157,9 +211,12 @@ void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) { if (!task_namespace_.IsValid()) task_namespace_ = task_graph_runner->GetNamespaceToken(); - PictureLayerTilingSet tiling_set(layer, layer->content_bounds()); + FixedInvalidationPictureLayerTilingClient client( + layer, gfx::Rect(layer->content_bounds())); + PictureLayerTilingSet tiling_set(&client); - PictureLayerTiling* tiling = tiling_set.AddTiling(layer->contents_scale_x()); + PictureLayerTiling* tiling = + tiling_set.AddTiling(layer->contents_scale_x(), layer->bounds()); tiling->CreateAllTilesForTesting(); for (PictureLayerTiling::CoverageIterator it( tiling, layer->contents_scale_x(), layer->visible_content_rect()); @@ -167,12 +224,12 @@ void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) { ++it) { DCHECK(*it); - PicturePileImpl* picture_pile = (*it)->picture_pile(); + RasterSource* raster_source = (*it)->raster_source(); gfx::Rect content_rect = (*it)->content_rect(); float contents_scale = (*it)->contents_scale(); scoped_refptr<BenchmarkRasterTask> benchmark_raster_task( - new BenchmarkRasterTask(picture_pile, + new BenchmarkRasterTask(raster_source, content_rect, contents_scale, rasterize_repeat_count_)); @@ -180,7 +237,7 @@ void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) { TaskGraph graph; graph.nodes.push_back( - TaskGraph::Node(benchmark_raster_task, + TaskGraph::Node(benchmark_raster_task.get(), RasterWorkerPool::kBenchmarkRasterTaskPriority, 0u)); diff --git a/chromium/cc/debug/rasterize_and_record_benchmark_impl.h b/chromium/cc/debug/rasterize_and_record_benchmark_impl.h index cceef051698..c0f26fd3704 100644 --- a/chromium/cc/debug/rasterize_and_record_benchmark_impl.h +++ b/chromium/cc/debug/rasterize_and_record_benchmark_impl.h @@ -24,11 +24,11 @@ class RasterizeAndRecordBenchmarkImpl : public MicroBenchmarkImpl { scoped_refptr<base::MessageLoopProxy> origin_loop, base::Value* value, const MicroBenchmarkImpl::DoneCallback& callback); - virtual ~RasterizeAndRecordBenchmarkImpl(); + ~RasterizeAndRecordBenchmarkImpl() override; // Implements MicroBenchmark interface. - virtual void DidCompleteCommit(LayerTreeHostImpl* host) OVERRIDE; - virtual void RunOnLayer(PictureLayerImpl* layer) OVERRIDE; + void DidCompleteCommit(LayerTreeHostImpl* host) override; + void RunOnLayer(PictureLayerImpl* layer) override; private: void Run(LayerImpl* layer); diff --git a/chromium/cc/debug/rendering_stats.cc b/chromium/cc/debug/rendering_stats.cc index 3e123b667c7..558c882ec7c 100644 --- a/chromium/cc/debug/rendering_stats.cc +++ b/chromium/cc/debug/rendering_stats.cc @@ -2,61 +2,121 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/values.h" #include "cc/debug/rendering_stats.h" namespace cc { -MainThreadRenderingStats::MainThreadRenderingStats() - : frame_count(0), - painted_pixel_count(0), - recorded_pixel_count(0) {} +RenderingStats::TimeDeltaList::TimeDeltaList() { +} + +RenderingStats::TimeDeltaList::~TimeDeltaList() { +} + +void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { + values.push_back(value); +} + +void RenderingStats::TimeDeltaList::AddToTracedValue( + base::debug::TracedValue* list_value) const { + std::list<base::TimeDelta>::const_iterator iter; + for (iter = values.begin(); iter != values.end(); ++iter) { + list_value->AppendDouble(iter->InMillisecondsF()); + } +} + +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::MainThreadRenderingStats::MainThreadRenderingStats() + : painted_pixel_count(0), recorded_pixel_count(0) { +} + +RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() { +} scoped_refptr<base::debug::ConvertableToTraceFormat> -MainThreadRenderingStats::AsTraceableData() const { - scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); - record_data->SetInteger("frame_count", frame_count); +RenderingStats::MainThreadRenderingStats::AsTraceableData() const { + scoped_refptr<base::debug::TracedValue> record_data = + new base::debug::TracedValue(); record_data->SetDouble("paint_time", paint_time.InSecondsF()); record_data->SetInteger("painted_pixel_count", painted_pixel_count); record_data->SetDouble("record_time", record_time.InSecondsF()); record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); - return TracedValue::FromValue(record_data.release()); + return record_data; } -void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { - frame_count += other.frame_count; +void RenderingStats::MainThreadRenderingStats::Add( + const MainThreadRenderingStats& other) { paint_time += other.paint_time; painted_pixel_count += other.painted_pixel_count; record_time += other.record_time; recorded_pixel_count += other.recorded_pixel_count; } -ImplThreadRenderingStats::ImplThreadRenderingStats() +RenderingStats::ImplThreadRenderingStats::ImplThreadRenderingStats() : frame_count(0), - rasterized_pixel_count(0), visible_content_area(0), approximated_visible_content_area(0) { } +RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() { +} + scoped_refptr<base::debug::ConvertableToTraceFormat> -ImplThreadRenderingStats::AsTraceableData() const { - scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); +RenderingStats::ImplThreadRenderingStats::AsTraceableData() const { + scoped_refptr<base::debug::TracedValue> record_data = + new base::debug::TracedValue(); record_data->SetInteger("frame_count", frame_count); - record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); - record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); record_data->SetInteger("visible_content_area", visible_content_area); record_data->SetInteger("approximated_visible_content_area", approximated_visible_content_area); - return TracedValue::FromValue(record_data.release()); + record_data->BeginArray("draw_duration_ms"); + draw_duration.AddToTracedValue(record_data.get()); + record_data->EndArray(); + + record_data->BeginArray("draw_duration_estimate_ms"); + draw_duration_estimate.AddToTracedValue(record_data.get()); + record_data->EndArray(); + + record_data->BeginArray("begin_main_frame_to_commit_duration_ms"); + begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get()); + record_data->EndArray(); + + record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms"); + begin_main_frame_to_commit_duration_estimate.AddToTracedValue( + record_data.get()); + record_data->EndArray(); + + record_data->BeginArray("commit_to_activate_duration_ms"); + commit_to_activate_duration.AddToTracedValue(record_data.get()); + record_data->EndArray(); + + record_data->BeginArray("commit_to_activate_duration_estimate_ms"); + commit_to_activate_duration_estimate.AddToTracedValue(record_data.get()); + record_data->EndArray(); + return record_data; } -void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { +void RenderingStats::ImplThreadRenderingStats::Add( + const ImplThreadRenderingStats& other) { frame_count += other.frame_count; - rasterize_time += other.rasterize_time; - analysis_time += other.analysis_time; - rasterized_pixel_count += other.rasterized_pixel_count; visible_content_area += other.visible_content_area; approximated_visible_content_area += other.approximated_visible_content_area; + + draw_duration.Add(other.draw_duration); + draw_duration_estimate.Add(other.draw_duration_estimate); + begin_main_frame_to_commit_duration.Add( + other.begin_main_frame_to_commit_duration); + begin_main_frame_to_commit_duration_estimate.Add( + other.begin_main_frame_to_commit_duration_estimate); + commit_to_activate_duration.Add(other.commit_to_activate_duration); + commit_to_activate_duration_estimate.Add( + other.commit_to_activate_duration_estimate); } void RenderingStats::Add(const RenderingStats& other) { diff --git a/chromium/cc/debug/rendering_stats.h b/chromium/cc/debug/rendering_stats.h index bd3b7c72442..7b1898a9daa 100644 --- a/chromium/cc/debug/rendering_stats.h +++ b/chromium/cc/debug/rendering_stats.h @@ -5,45 +5,73 @@ #ifndef CC_DEBUG_RENDERING_STATS_H_ #define CC_DEBUG_RENDERING_STATS_H_ +#include <list> + #include "base/basictypes.h" +#include "base/debug/trace_event_argument.h" #include "base/time/time.h" +#include "base/values.h" #include "cc/base/cc_export.h" #include "cc/debug/traced_value.h" namespace cc { -struct CC_EXPORT MainThreadRenderingStats { - // Note: when adding new members, please remember to update EnumerateFields - // and Add in rendering_stats.cc. +struct CC_EXPORT RenderingStats { + // Stores a sequence of TimeDelta objects. + class CC_EXPORT TimeDeltaList { + public: + TimeDeltaList(); + ~TimeDeltaList(); - int64 frame_count; - base::TimeDelta paint_time; - int64 painted_pixel_count; - base::TimeDelta record_time; - int64 recorded_pixel_count; + void Append(base::TimeDelta value); + void AddToTracedValue(base::debug::TracedValue* list_value) const; - MainThreadRenderingStats(); - scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; - void Add(const MainThreadRenderingStats& other); -}; + void Add(const TimeDeltaList& other); -struct CC_EXPORT ImplThreadRenderingStats { - // Note: when adding new members, please remember to update EnumerateFields - // and Add in rendering_stats.cc. + base::TimeDelta GetLastTimeDelta() const; - int64 frame_count; - base::TimeDelta rasterize_time; - base::TimeDelta analysis_time; - int64 rasterized_pixel_count; - int64 visible_content_area; - int64 approximated_visible_content_area; + private: + std::list<base::TimeDelta> values; + }; - ImplThreadRenderingStats(); - scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; - void Add(const ImplThreadRenderingStats& other); -}; + struct CC_EXPORT MainThreadRenderingStats { + // Note: when adding new members, please remember to update Add in + // rendering_stats.cc. + + base::TimeDelta paint_time; + int64 painted_pixel_count; + base::TimeDelta record_time; + int64 recorded_pixel_count; + + MainThreadRenderingStats(); + ~MainThreadRenderingStats(); + scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() + const; + void Add(const MainThreadRenderingStats& other); + }; + + struct CC_EXPORT ImplThreadRenderingStats { + // Note: when adding new members, please remember to update Add in + // rendering_stats.cc. + + int64 frame_count; + int64 visible_content_area; + int64 approximated_visible_content_area; + + TimeDeltaList draw_duration; + TimeDeltaList draw_duration_estimate; + TimeDeltaList begin_main_frame_to_commit_duration; + TimeDeltaList begin_main_frame_to_commit_duration_estimate; + TimeDeltaList commit_to_activate_duration; + TimeDeltaList commit_to_activate_duration_estimate; + + ImplThreadRenderingStats(); + ~ImplThreadRenderingStats(); + scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableData() + const; + void Add(const ImplThreadRenderingStats& other); + }; -struct CC_EXPORT RenderingStats { MainThreadRenderingStats main_stats; ImplThreadRenderingStats impl_stats; diff --git a/chromium/cc/debug/rendering_stats_instrumentation.cc b/chromium/cc/debug/rendering_stats_instrumentation.cc index 9655241c639..f5f2e07225d 100644 --- a/chromium/cc/debug/rendering_stats_instrumentation.cc +++ b/chromium/cc/debug/rendering_stats_instrumentation.cc @@ -18,13 +18,13 @@ RenderingStatsInstrumentation::RenderingStatsInstrumentation() RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} -MainThreadRenderingStats +RenderingStats::MainThreadRenderingStats RenderingStatsInstrumentation::main_thread_rendering_stats() { base::AutoLock scoped_lock(lock_); return main_thread_rendering_stats_; } -ImplThreadRenderingStats +RenderingStats::ImplThreadRenderingStats RenderingStatsInstrumentation::impl_thread_rendering_stats() { base::AutoLock scoped_lock(lock_); return impl_thread_rendering_stats_; @@ -43,13 +43,13 @@ RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { base::AutoLock scoped_lock(lock_); main_thread_rendering_stats_accu_.Add(main_thread_rendering_stats_); - main_thread_rendering_stats_ = MainThreadRenderingStats(); + main_thread_rendering_stats_ = RenderingStats::MainThreadRenderingStats(); } void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { base::AutoLock scoped_lock(lock_); impl_thread_rendering_stats_accu_.Add(impl_thread_rendering_stats_); - impl_thread_rendering_stats_ = ImplThreadRenderingStats(); + impl_thread_rendering_stats_ = RenderingStats::ImplThreadRenderingStats(); } base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { @@ -71,16 +71,12 @@ base::TimeDelta RenderingStatsInstrumentation::EndRecording( return base::TimeDelta(); } -void RenderingStatsInstrumentation::IncrementFrameCount(int64 count, - bool main_thread) { +void RenderingStatsInstrumentation::IncrementFrameCount(int64 count) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - if (main_thread) - main_thread_rendering_stats_.frame_count += count; - else - impl_thread_rendering_stats_.frame_count += count; + impl_thread_rendering_stats_.frame_count += count; } void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, @@ -103,40 +99,59 @@ void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, main_thread_rendering_stats_.recorded_pixel_count += pixels; } -void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, - int64 pixels) { +void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - impl_thread_rendering_stats_.rasterize_time += duration; - impl_thread_rendering_stats_.rasterized_pixel_count += pixels; + impl_thread_rendering_stats_.visible_content_area += area; } -void RenderingStatsInstrumentation::AddAnalysis(base::TimeDelta duration, - int64 pixels) { +void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( + int64 area) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - impl_thread_rendering_stats_.analysis_time += duration; + impl_thread_rendering_stats_.approximated_visible_content_area += area; } -void RenderingStatsInstrumentation::AddVisibleContentArea(int64 area) { +void RenderingStatsInstrumentation::AddDrawDuration( + base::TimeDelta draw_duration, + base::TimeDelta draw_duration_estimate) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - impl_thread_rendering_stats_.visible_content_area += area; + impl_thread_rendering_stats_.draw_duration.Append(draw_duration); + impl_thread_rendering_stats_.draw_duration_estimate.Append( + draw_duration_estimate); } -void RenderingStatsInstrumentation::AddApproximatedVisibleContentArea( - int64 area) { +void RenderingStatsInstrumentation::AddBeginMainFrameToCommitDuration( + base::TimeDelta begin_main_frame_to_commit_duration, + base::TimeDelta begin_main_frame_to_commit_duration_estimate) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - impl_thread_rendering_stats_.approximated_visible_content_area += area; + impl_thread_rendering_stats_.begin_main_frame_to_commit_duration.Append( + begin_main_frame_to_commit_duration); + impl_thread_rendering_stats_.begin_main_frame_to_commit_duration_estimate + .Append(begin_main_frame_to_commit_duration_estimate); +} + +void RenderingStatsInstrumentation::AddCommitToActivateDuration( + base::TimeDelta commit_to_activate_duration, + base::TimeDelta commit_to_activate_duration_estimate) { + if (!record_rendering_stats_) + return; + + base::AutoLock scoped_lock(lock_); + impl_thread_rendering_stats_.commit_to_activate_duration.Append( + commit_to_activate_duration); + impl_thread_rendering_stats_.commit_to_activate_duration_estimate.Append( + commit_to_activate_duration_estimate); } } // namespace cc diff --git a/chromium/cc/debug/rendering_stats_instrumentation.h b/chromium/cc/debug/rendering_stats_instrumentation.h index 664013186cd..734583a5815 100644 --- a/chromium/cc/debug/rendering_stats_instrumentation.h +++ b/chromium/cc/debug/rendering_stats_instrumentation.h @@ -19,10 +19,10 @@ class CC_EXPORT RenderingStatsInstrumentation { virtual ~RenderingStatsInstrumentation(); // Return copy of current main thread rendering stats. - MainThreadRenderingStats main_thread_rendering_stats(); + RenderingStats::MainThreadRenderingStats main_thread_rendering_stats(); // Return copy of current impl thread rendering stats. - ImplThreadRenderingStats impl_thread_rendering_stats(); + RenderingStats::ImplThreadRenderingStats impl_thread_rendering_stats(); // Return the accumulated, combined rendering stats. RenderingStats GetRenderingStats(); @@ -47,22 +47,28 @@ class CC_EXPORT RenderingStatsInstrumentation { base::TimeTicks StartRecording() const; base::TimeDelta EndRecording(base::TimeTicks start_time) const; - void IncrementFrameCount(int64 count, bool main_thread); + void IncrementFrameCount(int64 count); void AddPaint(base::TimeDelta duration, int64 pixels); void AddRecord(base::TimeDelta duration, int64 pixels); - void AddRaster(base::TimeDelta duration, int64 pixels); - void AddAnalysis(base::TimeDelta duration, int64 pixels); void AddVisibleContentArea(int64 area); void AddApproximatedVisibleContentArea(int64 area); + void AddDrawDuration(base::TimeDelta draw_duration, + base::TimeDelta draw_duration_estimate); + void AddBeginMainFrameToCommitDuration( + base::TimeDelta begin_main_frame_to_commit_duration, + base::TimeDelta begin_main_frame_to_commit_duration_estimate); + void AddCommitToActivateDuration( + base::TimeDelta commit_to_activate_duration, + base::TimeDelta commit_to_activate_duration_estimate); protected: RenderingStatsInstrumentation(); private: - MainThreadRenderingStats main_thread_rendering_stats_; - MainThreadRenderingStats main_thread_rendering_stats_accu_; - ImplThreadRenderingStats impl_thread_rendering_stats_; - ImplThreadRenderingStats impl_thread_rendering_stats_accu_; + RenderingStats::MainThreadRenderingStats main_thread_rendering_stats_; + RenderingStats::MainThreadRenderingStats main_thread_rendering_stats_accu_; + RenderingStats::ImplThreadRenderingStats impl_thread_rendering_stats_; + RenderingStats::ImplThreadRenderingStats impl_thread_rendering_stats_accu_; bool record_rendering_stats_; diff --git a/chromium/cc/debug/rendering_stats_unittest.cc b/chromium/cc/debug/rendering_stats_unittest.cc new file mode 100644 index 00000000000..a6340932371 --- /dev/null +++ b/chromium/cc/debug/rendering_stats_unittest.cc @@ -0,0 +1,53 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <string> + +#include "base/time/time.h" +#include "base/values.h" +#include "cc/debug/rendering_stats.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cc { +namespace { + +static std::string ToString(const RenderingStats::TimeDeltaList& list) { + scoped_refptr<base::debug::TracedValue> value = + new base::debug::TracedValue(); + value->BeginArray("list_value"); + list.AddToTracedValue(value.get()); + value->EndArray(); + return value->ToString(); +} + +TEST(RenderingStatsTest, TimeDeltaListEmpty) { + RenderingStats::TimeDeltaList time_delta_list; + EXPECT_EQ("{\"list_value\":[]}", ToString(time_delta_list)); +} + +TEST(RenderingStatsTest, TimeDeltaListNonEmpty) { + RenderingStats::TimeDeltaList time_delta_list; + time_delta_list.Append(base::TimeDelta::FromMilliseconds(234)); + time_delta_list.Append(base::TimeDelta::FromMilliseconds(827)); + + EXPECT_EQ("{\"list_value\":[234.0,827.0]}", ToString(time_delta_list)); +} + +TEST(RenderingStatsTest, TimeDeltaListAdd) { + RenderingStats::TimeDeltaList time_delta_list_a; + time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(810)); + time_delta_list_a.Append(base::TimeDelta::FromMilliseconds(32)); + + RenderingStats::TimeDeltaList time_delta_list_b; + time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(43)); + time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(938)); + time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(2)); + + time_delta_list_a.Add(time_delta_list_b); + EXPECT_EQ("{\"list_value\":[810.0,32.0,43.0,938.0,2.0]}", + ToString(time_delta_list_a)); +} + +} // namespace +} // namespace cc diff --git a/chromium/cc/debug/traced_picture.cc b/chromium/cc/debug/traced_picture.cc index 89d988fec93..2db549234d8 100644 --- a/chromium/cc/debug/traced_picture.cc +++ b/chromium/cc/debug/traced_picture.cc @@ -7,7 +7,6 @@ #include "base/json/json_writer.h" #include "base/strings/stringprintf.h" #include "base/values.h" -#include "cc/debug/traced_value.h" namespace cc { diff --git a/chromium/cc/debug/traced_picture.h b/chromium/cc/debug/traced_picture.h index 638f00bb7dd..b5f5e3ae134 100644 --- a/chromium/cc/debug/traced_picture.h +++ b/chromium/cc/debug/traced_picture.h @@ -23,10 +23,10 @@ class TracedPicture : public base::debug::ConvertableToTraceFormat { static scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceablePictureAlias(const Picture* original); - virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; + void AppendAsTraceFormat(std::string* out) const override; private: - virtual ~TracedPicture(); + ~TracedPicture() override; void AppendPicture(std::string* out) const; void AppendPictureAlias(std::string* out) const; diff --git a/chromium/cc/debug/traced_value.cc b/chromium/cc/debug/traced_value.cc index 3b506ae7e37..5828cb8894e 100644 --- a/chromium/cc/debug/traced_value.cc +++ b/chromium/cc/debug/traced_value.cc @@ -4,26 +4,34 @@ #include "cc/debug/traced_value.h" -#include "base/json/json_writer.h" +#include "base/debug/trace_event_argument.h" #include "base/strings/stringprintf.h" -#include "base/values.h" namespace cc { -scoped_ptr<base::Value> TracedValue::CreateIDRef(const void* id) { - scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); - res->SetString("id_ref", base::StringPrintf("%p", id)); - return res.PassAs<base::Value>(); +void TracedValue::AppendIDRef(const void* id, base::debug::TracedValue* state) { + state->BeginDictionary(); + state->SetString("id_ref", base::StringPrintf("%p", id)); + state->EndDictionary(); } -void TracedValue::MakeDictIntoImplicitSnapshot( - base::DictionaryValue* dict, const char* object_name, const void* id) { +void TracedValue::SetIDRef(const void* id, + base::debug::TracedValue* state, + const char* name) { + state->BeginDictionary(name); + state->SetString("id_ref", base::StringPrintf("%p", id)); + state->EndDictionary(); +} + +void TracedValue::MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict, + const char* object_name, + const void* id) { dict->SetString("id", base::StringPrintf("%s/%p", object_name, id)); } void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::DictionaryValue* dict, + base::debug::TracedValue* dict, const char* object_name, const void* id) { dict->SetString("cat", category); @@ -32,7 +40,7 @@ void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::DictionaryValue* dict, + base::debug::TracedValue* dict, const char* object_base_type_name, const char* object_name, const void* id) { @@ -41,23 +49,4 @@ void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( MakeDictIntoImplicitSnapshot(dict, object_name, id); } -scoped_refptr<base::debug::ConvertableToTraceFormat> TracedValue::FromValue( - base::Value* value) { - return scoped_refptr<base::debug::ConvertableToTraceFormat>( - new TracedValue(value)); -} - -TracedValue::TracedValue(base::Value* value) - : value_(value) { -} - -TracedValue::~TracedValue() { -} - -void TracedValue::AppendAsTraceFormat(std::string* out) const { - std::string tmp; - base::JSONWriter::Write(value_.get(), &tmp); - *out += tmp; -} - } // namespace cc diff --git a/chromium/cc/debug/traced_value.h b/chromium/cc/debug/traced_value.h index 560eaf8307b..c5ea30aedda 100644 --- a/chromium/cc/debug/traced_value.h +++ b/chromium/cc/debug/traced_value.h @@ -5,58 +5,36 @@ #ifndef CC_DEBUG_TRACED_VALUE_H_ #define CC_DEBUG_TRACED_VALUE_H_ -#include <string> - -#include "base/debug/trace_event.h" -#include "base/memory/scoped_ptr.h" - namespace base { -class DictionaryValue; -class Value; +namespace debug { +class TracedValue; +} } + namespace cc { -class TracedValue : public base::debug::ConvertableToTraceFormat { +class TracedValue { public: - static scoped_ptr<base::Value> CreateIDRef(const void* id); - static void MakeDictIntoImplicitSnapshot( - base::DictionaryValue* dict, const char* object_name, const void* id); + static void AppendIDRef(const void* id, base::debug::TracedValue* array); + static void SetIDRef(const void* id, + base::debug::TracedValue* dict, + const char* name); + static void MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict, + const char* object_name, + const void* id); static void MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::DictionaryValue* dict, + base::debug::TracedValue* dict, const char* object_name, const void* id); static void MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::DictionaryValue* dict, + base::debug::TracedValue* dict, const char* object_base_type_name, const char* object_name, const void* id); - static scoped_refptr<base::debug::ConvertableToTraceFormat> FromValue( - base::Value* value); - - virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; - - private: - explicit TracedValue(base::Value* value); - virtual ~TracedValue(); - - scoped_ptr<base::Value> value_; - - DISALLOW_COPY_AND_ASSIGN(TracedValue); }; -template <class T> -static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace(T* t) { - return TracedValue::FromValue(t->AsValue().release()); -} - -template <class T> -static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace( - const T& t) { - return ToTrace(&t); -} - } // namespace cc #endif // CC_DEBUG_TRACED_VALUE_H_ diff --git a/chromium/cc/debug/unittest_only_benchmark.cc b/chromium/cc/debug/unittest_only_benchmark.cc index 0f0694ad9df..2bd5be99d98 100644 --- a/chromium/cc/debug/unittest_only_benchmark.cc +++ b/chromium/cc/debug/unittest_only_benchmark.cc @@ -19,7 +19,7 @@ UnittestOnlyBenchmark::UnittestOnlyBenchmark(scoped_ptr<base::Value> value, if (!value) return; - base::DictionaryValue* settings = NULL; + base::DictionaryValue* settings = nullptr; value->GetAsDictionary(&settings); if (!settings) return; @@ -33,11 +33,11 @@ UnittestOnlyBenchmark::~UnittestOnlyBenchmark() { } void UnittestOnlyBenchmark::DidUpdateLayers(LayerTreeHost* host) { - NotifyDone(scoped_ptr<base::Value>()); + NotifyDone(nullptr); } bool UnittestOnlyBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { - base::DictionaryValue* message = NULL; + base::DictionaryValue* message = nullptr; value->GetAsDictionary(&message); bool can_handle; if (message->HasKey("can_handle")) { @@ -55,11 +55,11 @@ void UnittestOnlyBenchmark::RecordImplResults(scoped_ptr<base::Value> results) { scoped_ptr<MicroBenchmarkImpl> UnittestOnlyBenchmark::CreateBenchmarkImpl( scoped_refptr<base::MessageLoopProxy> origin_loop) { if (!create_impl_benchmark_) - return make_scoped_ptr<MicroBenchmarkImpl>(NULL); + return make_scoped_ptr<MicroBenchmarkImpl>(nullptr); - return scoped_ptr<MicroBenchmarkImpl>(new UnittestOnlyBenchmarkImpl( + return make_scoped_ptr(new UnittestOnlyBenchmarkImpl( origin_loop, - NULL, + nullptr, base::Bind(&UnittestOnlyBenchmark::RecordImplResults, weak_ptr_factory_.GetWeakPtr()))); } diff --git a/chromium/cc/debug/unittest_only_benchmark.h b/chromium/cc/debug/unittest_only_benchmark.h index 8b2c8159b22..7fa2b4dcab4 100644 --- a/chromium/cc/debug/unittest_only_benchmark.h +++ b/chromium/cc/debug/unittest_only_benchmark.h @@ -14,14 +14,14 @@ class CC_EXPORT UnittestOnlyBenchmark : public MicroBenchmark { public: UnittestOnlyBenchmark(scoped_ptr<base::Value> value, const DoneCallback& callback); - virtual ~UnittestOnlyBenchmark(); + ~UnittestOnlyBenchmark() override; - virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; - virtual bool ProcessMessage(scoped_ptr<base::Value> value) OVERRIDE; + void DidUpdateLayers(LayerTreeHost* host) override; + bool ProcessMessage(scoped_ptr<base::Value> value) override; protected: - virtual scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( - scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE; + scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) override; private: void RecordImplResults(scoped_ptr<base::Value> results); diff --git a/chromium/cc/debug/unittest_only_benchmark_impl.cc b/chromium/cc/debug/unittest_only_benchmark_impl.cc index b249ce34476..a3b040f0d44 100644 --- a/chromium/cc/debug/unittest_only_benchmark_impl.cc +++ b/chromium/cc/debug/unittest_only_benchmark_impl.cc @@ -18,7 +18,7 @@ UnittestOnlyBenchmarkImpl::UnittestOnlyBenchmarkImpl( UnittestOnlyBenchmarkImpl::~UnittestOnlyBenchmarkImpl() {} void UnittestOnlyBenchmarkImpl::DidCompleteCommit(LayerTreeHostImpl* host) { - NotifyDone(scoped_ptr<base::Value>()); + NotifyDone(nullptr); } } // namespace cc diff --git a/chromium/cc/debug/unittest_only_benchmark_impl.h b/chromium/cc/debug/unittest_only_benchmark_impl.h index b9e9bc9e95b..f9b256d3c69 100644 --- a/chromium/cc/debug/unittest_only_benchmark_impl.h +++ b/chromium/cc/debug/unittest_only_benchmark_impl.h @@ -21,9 +21,9 @@ class CC_EXPORT UnittestOnlyBenchmarkImpl : public MicroBenchmarkImpl { UnittestOnlyBenchmarkImpl(scoped_refptr<base::MessageLoopProxy> origin_loop, base::Value* settings, const DoneCallback& callback); - virtual ~UnittestOnlyBenchmarkImpl(); + ~UnittestOnlyBenchmarkImpl() override; - virtual void DidCompleteCommit(LayerTreeHostImpl* host) OVERRIDE; + void DidCompleteCommit(LayerTreeHostImpl* host) override; }; } // namespace cc |