diff options
24 files changed, 448 insertions, 23 deletions
@@ -82,8 +82,12 @@ 'debug/layer_tree_debug_state.h', 'debug/micro_benchmark.cc', 'debug/micro_benchmark.h', + 'debug/micro_benchmark_impl.cc', + 'debug/micro_benchmark_impl.h', 'debug/micro_benchmark_controller.cc', 'debug/micro_benchmark_controller.h', + 'debug/micro_benchmark_controller_impl.cc', + 'debug/micro_benchmark_controller_impl.h', 'debug/overdraw_metrics.cc', 'debug/overdraw_metrics.h', 'debug/paint_time_counter.cc', @@ -101,6 +105,8 @@ 'debug/traced_value.h', 'debug/unittest_only_benchmark.cc', 'debug/unittest_only_benchmark.h', + 'debug/unittest_only_benchmark_impl.cc', + 'debug/unittest_only_benchmark_impl.h', 'input/input_handler.h', 'input/page_scale_animation.cc', 'input/page_scale_animation.h', diff --git a/cc/debug/micro_benchmark.cc b/cc/debug/micro_benchmark.cc index 1742e7f..464d0cb 100644 --- a/cc/debug/micro_benchmark.cc +++ b/cc/debug/micro_benchmark.cc @@ -5,13 +5,18 @@ #include "cc/debug/micro_benchmark.h" #include "base/callback.h" +#include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/values.h" +#include "cc/debug/micro_benchmark_impl.h" namespace cc { MicroBenchmark::MicroBenchmark(const DoneCallback& callback) - : callback_(callback), is_done_(false) {} + : callback_(callback), + is_done_(false), + processed_for_benchmark_impl_(false) {} MicroBenchmark::~MicroBenchmark() {} @@ -30,4 +35,20 @@ void MicroBenchmark::RunOnLayer(Layer* layer) {} void MicroBenchmark::RunOnLayer(PictureLayer* layer) {} +bool MicroBenchmark::ProcessedForBenchmarkImpl() const { + return processed_for_benchmark_impl_; +} + +scoped_ptr<MicroBenchmarkImpl> MicroBenchmark::GetBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) { + DCHECK(!processed_for_benchmark_impl_); + processed_for_benchmark_impl_ = true; + return CreateBenchmarkImpl(origin_loop); +} + +scoped_ptr<MicroBenchmarkImpl> MicroBenchmark::CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) { + return make_scoped_ptr<MicroBenchmarkImpl>(NULL); +} + } // namespace cc diff --git a/cc/debug/micro_benchmark.h b/cc/debug/micro_benchmark.h index 92c9b75..f179fb9 100644 --- a/cc/debug/micro_benchmark.h +++ b/cc/debug/micro_benchmark.h @@ -7,9 +7,11 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" +#include "cc/base/cc_export.h" namespace base { class Value; +class MessageLoopProxy; } // namespace base namespace cc { @@ -17,7 +19,8 @@ namespace cc { class LayerTreeHost; class Layer; class PictureLayer; -class MicroBenchmark { +class MicroBenchmarkImpl; +class CC_EXPORT MicroBenchmark { public: typedef base::Callback<void(scoped_ptr<base::Value>)> DoneCallback; @@ -30,12 +33,20 @@ class MicroBenchmark { virtual void RunOnLayer(Layer* layer); virtual void RunOnLayer(PictureLayer* layer); + bool ProcessedForBenchmarkImpl() const; + scoped_ptr<MicroBenchmarkImpl> GetBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop); + protected: void NotifyDone(scoped_ptr<base::Value> result); + virtual scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop); + private: DoneCallback callback_; bool is_done_; + bool processed_for_benchmark_impl_; }; } // namespace cc diff --git a/cc/debug/micro_benchmark_controller.cc b/cc/debug/micro_benchmark_controller.cc index 6e34e48..52e91ae 100644 --- a/cc/debug/micro_benchmark_controller.cc +++ b/cc/debug/micro_benchmark_controller.cc @@ -7,10 +7,12 @@ #include <string> #include "base/callback.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/values.h" #include "cc/debug/picture_record_benchmark.h" #include "cc/debug/unittest_only_benchmark.h" #include "cc/trees/layer_tree_host.h" +#include "cc/trees/layer_tree_host_impl.h" namespace cc { @@ -43,7 +45,8 @@ class IsDonePredicate { } // namespace MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host) - : host_(host) { + : host_(host), + main_controller_message_loop_(base::MessageLoopProxy::current().get()) { DCHECK(host_); } @@ -63,12 +66,28 @@ bool MicroBenchmarkController::ScheduleRun( return false; } +void MicroBenchmarkController::ScheduleImplBenchmarks( + LayerTreeHostImpl* host_impl) { + for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); + it != benchmarks_.end(); + ++it) { + scoped_ptr<MicroBenchmarkImpl> benchmark_impl; + if (!(*it)->ProcessedForBenchmarkImpl()) { + benchmark_impl = + (*it)->GetBenchmarkImpl(main_controller_message_loop_); + } + + if (benchmark_impl.get()) + host_impl->ScheduleMicroBenchmark(benchmark_impl.Pass()); + } +} + void MicroBenchmarkController::DidUpdateLayers() { for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); it != benchmarks_.end(); ++it) { - DCHECK(!(*it)->IsDone()); - (*it)->DidUpdateLayers(host_); + if (!(*it)->IsDone()) + (*it)->DidUpdateLayers(host_); } CleanUpFinishedBenchmarks(); diff --git a/cc/debug/micro_benchmark_controller.h b/cc/debug/micro_benchmark_controller.h index 63cf9c7..7220dc1 100644 --- a/cc/debug/micro_benchmark_controller.h +++ b/cc/debug/micro_benchmark_controller.h @@ -14,14 +14,14 @@ namespace base { class Value; +class MessageLoopProxy; } // namespace base namespace cc { class LayerTreeHost; -class Layer; -class PictureLayer; -class MicroBenchmarkController { +class LayerTreeHostImpl; +class CC_EXPORT MicroBenchmarkController { public: explicit MicroBenchmarkController(LayerTreeHost* host); ~MicroBenchmarkController(); @@ -32,11 +32,14 @@ class MicroBenchmarkController { scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback); + void ScheduleImplBenchmarks(LayerTreeHostImpl* host_impl); + private: void CleanUpFinishedBenchmarks(); LayerTreeHost* host_; ScopedPtrVector<MicroBenchmark> benchmarks_; + scoped_refptr<base::MessageLoopProxy> main_controller_message_loop_; DISALLOW_COPY_AND_ASSIGN(MicroBenchmarkController); }; diff --git a/cc/debug/micro_benchmark_controller_impl.cc b/cc/debug/micro_benchmark_controller_impl.cc new file mode 100644 index 0000000..821ba5f --- /dev/null +++ b/cc/debug/micro_benchmark_controller_impl.cc @@ -0,0 +1,59 @@ +// Copyright 2013 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 "cc/debug/micro_benchmark_controller_impl.h" + +#include <string> + +#include "base/callback.h" +#include "base/values.h" +#include "cc/trees/layer_tree_host_impl.h" + +namespace cc { + +namespace { + +class IsDonePredicate { + public: + typedef const MicroBenchmarkImpl* argument_type; + typedef bool result_type; + + result_type operator()(argument_type benchmark) const { + return benchmark->IsDone(); + } +}; + +} // namespace + +MicroBenchmarkControllerImpl::MicroBenchmarkControllerImpl( + LayerTreeHostImpl* host) + : host_(host) { + DCHECK(host_); +} + +MicroBenchmarkControllerImpl::~MicroBenchmarkControllerImpl() {} + +void MicroBenchmarkControllerImpl::ScheduleRun( + scoped_ptr<MicroBenchmarkImpl> benchmark) { + benchmarks_.push_back(benchmark.Pass()); +} + +void MicroBenchmarkControllerImpl::DidCompleteCommit() { + for (ScopedPtrVector<MicroBenchmarkImpl>::iterator it = benchmarks_.begin(); + it != benchmarks_.end(); + ++it) { + DCHECK(!(*it)->IsDone()); + (*it)->DidCompleteCommit(host_); + } + + CleanUpFinishedBenchmarks(); +} + +void MicroBenchmarkControllerImpl::CleanUpFinishedBenchmarks() { + benchmarks_.erase( + benchmarks_.partition(std::not1(IsDonePredicate())), + benchmarks_.end()); +} + +} // namespace cc diff --git a/cc/debug/micro_benchmark_controller_impl.h b/cc/debug/micro_benchmark_controller_impl.h new file mode 100644 index 0000000..734bf63 --- /dev/null +++ b/cc/debug/micro_benchmark_controller_impl.h @@ -0,0 +1,37 @@ +// Copyright 2013 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. + +#ifndef CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_IMPL_H_ +#define CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_IMPL_H_ + +#include <string> + +#include "base/basictypes.h" +#include "cc/base/scoped_ptr_vector.h" +#include "cc/debug/micro_benchmark_impl.h" + +namespace cc { + +class LayerTreeHostImpl; +class CC_EXPORT MicroBenchmarkControllerImpl { + public: + explicit MicroBenchmarkControllerImpl(LayerTreeHostImpl* host); + ~MicroBenchmarkControllerImpl(); + + void DidCompleteCommit(); + + void ScheduleRun(scoped_ptr<MicroBenchmarkImpl> benchmark); + + private: + void CleanUpFinishedBenchmarks(); + + LayerTreeHostImpl* host_; + ScopedPtrVector<MicroBenchmarkImpl> benchmarks_; + + DISALLOW_COPY_AND_ASSIGN(MicroBenchmarkControllerImpl); +}; + +} // namespace cc + +#endif // CC_DEBUG_MICRO_BENCHMARK_CONTROLLER_IMPL_H_ diff --git a/cc/debug/micro_benchmark_controller_unittest.cc b/cc/debug/micro_benchmark_controller_unittest.cc index e1d8d1e..4894947 100644 --- a/cc/debug/micro_benchmark_controller_unittest.cc +++ b/cc/debug/micro_benchmark_controller_unittest.cc @@ -9,6 +9,7 @@ #include "cc/layers/layer.h" #include "cc/resources/resource_update_queue.h" #include "cc/test/fake_layer_tree_host.h" +#include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_proxy.h" #include "testing/gtest/include/gtest/gtest.h" @@ -17,14 +18,25 @@ namespace { class MicroBenchmarkControllerTest : public testing::Test { public: - virtual void SetUp() { + virtual void SetUp() OVERRIDE { + impl_proxy_ = make_scoped_ptr(new FakeImplProxy); + layer_tree_host_impl_ = + make_scoped_ptr(new FakeLayerTreeHostImpl(impl_proxy_.get())); + layer_tree_host_ = FakeLayerTreeHost::Create(); layer_tree_host_->SetRootLayer(Layer::Create()); - layer_tree_host_->InitializeForTesting( - scoped_ptr<Proxy>(new FakeProxy)); + 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(); } scoped_ptr<FakeLayerTreeHost> layer_tree_host_; + scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_; + scoped_ptr<FakeImplProxy> impl_proxy_; }; void Noop(scoped_ptr<base::Value> value) { @@ -100,5 +112,30 @@ TEST_F(MicroBenchmarkControllerTest, MultipleBenchmarkRan) { EXPECT_EQ(4, run_count); } +TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) { + int run_count = 0; + scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue); + settings->SetBoolean("run_benchmark_impl", true); + + // Schedule a main thread benchmark. + bool result = layer_tree_host_->ScheduleMicroBenchmark( + "unittest_only_benchmark", + settings.PassAs<base::Value>(), + base::Bind(&IncrementCallCount, base::Unretained(&run_count))); + EXPECT_TRUE(result); + + // Schedule impl benchmarks. In production code, this is run in commit. + layer_tree_host_->GetMicroBenchmarkController()->ScheduleImplBenchmarks( + layer_tree_host_impl_.get()); + + // Now complete the commit (as if on the impl thread). + layer_tree_host_impl_->CommitComplete(); + + // Make sure all posted messages run. + base::MessageLoop::current()->RunUntilIdle(); + + EXPECT_EQ(1, run_count); +} + } // namespace } // namespace cc diff --git a/cc/debug/micro_benchmark_impl.cc b/cc/debug/micro_benchmark_impl.cc new file mode 100644 index 0000000..7ec58c8 --- /dev/null +++ b/cc/debug/micro_benchmark_impl.cc @@ -0,0 +1,48 @@ +// Copyright 2013 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 "cc/debug/micro_benchmark_impl.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_loop.h" +#include "base/values.h" + +namespace cc { + +namespace { + +void RunCallback(const MicroBenchmarkImpl::DoneCallback& callback, + scoped_ptr<base::Value> result) { + callback.Run(result.Pass()); +} + +} + +MicroBenchmarkImpl::MicroBenchmarkImpl( + const DoneCallback& callback, + scoped_refptr<base::MessageLoopProxy> origin_loop) + : callback_(callback), is_done_(false), origin_loop_(origin_loop) {} + +MicroBenchmarkImpl::~MicroBenchmarkImpl() {} + +bool MicroBenchmarkImpl::IsDone() const { + return is_done_; +} + +void MicroBenchmarkImpl::DidCompleteCommit(LayerTreeHostImpl* host) {} + +void MicroBenchmarkImpl::NotifyDone(scoped_ptr<base::Value> result) { + origin_loop_->PostTask( + FROM_HERE, + base::Bind(RunCallback, callback_, base::Passed(&result))); + is_done_ = true; +} + +void MicroBenchmarkImpl::RunOnLayer(LayerImpl* layer) {} + +void MicroBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) {} + +} // namespace cc diff --git a/cc/debug/micro_benchmark_impl.h b/cc/debug/micro_benchmark_impl.h new file mode 100644 index 0000000..4f3f74f --- /dev/null +++ b/cc/debug/micro_benchmark_impl.h @@ -0,0 +1,48 @@ +// Copyright 2013 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. + +#ifndef CC_DEBUG_MICRO_BENCHMARK_IMPL_H_ +#define CC_DEBUG_MICRO_BENCHMARK_IMPL_H_ + +#include "base/callback.h" +#include "base/memory/scoped_ptr.h" +#include "cc/base/cc_export.h" + +namespace base { +class Value; +class MessageLoopProxy; +} // namespace base + +namespace cc { + +class LayerTreeHostImpl; +class LayerImpl; +class PictureLayerImpl; +class CC_EXPORT MicroBenchmarkImpl { + public: + typedef base::Callback<void(scoped_ptr<base::Value>)> DoneCallback; + + explicit MicroBenchmarkImpl( + const DoneCallback& callback, + scoped_refptr<base::MessageLoopProxy> origin_loop); + virtual ~MicroBenchmarkImpl(); + + bool IsDone() const; + virtual void DidCompleteCommit(LayerTreeHostImpl* host); + + virtual void RunOnLayer(LayerImpl* layer); + virtual void RunOnLayer(PictureLayerImpl* layer); + + protected: + void NotifyDone(scoped_ptr<base::Value> result); + + private: + DoneCallback callback_; + bool is_done_; + scoped_refptr<base::MessageLoopProxy> origin_loop_; +}; + +} // namespace cc + +#endif // CC_DEBUG_MICRO_BENCHMARK_IMPL_H_ diff --git a/cc/debug/picture_record_benchmark.h b/cc/debug/picture_record_benchmark.h index 9d3f075..89f2bc0 100644 --- a/cc/debug/picture_record_benchmark.h +++ b/cc/debug/picture_record_benchmark.h @@ -16,7 +16,7 @@ namespace cc { class LayerTreeHost; class Layer; -class PictureRecordBenchmark : public MicroBenchmark { +class CC_EXPORT PictureRecordBenchmark : public MicroBenchmark { public: explicit PictureRecordBenchmark(scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback); diff --git a/cc/debug/unittest_only_benchmark.cc b/cc/debug/unittest_only_benchmark.cc index fbd9dde..9c6b176 100644 --- a/cc/debug/unittest_only_benchmark.cc +++ b/cc/debug/unittest_only_benchmark.cc @@ -2,19 +2,54 @@ // 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/unittest_only_benchmark.h" +#include "base/bind.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/values.h" +#include "cc/debug/unittest_only_benchmark_impl.h" + namespace cc { UnittestOnlyBenchmark::UnittestOnlyBenchmark(scoped_ptr<base::Value> value, const DoneCallback& callback) - : MicroBenchmark(callback) {} + : MicroBenchmark(callback), + create_impl_benchmark_(false), + weak_ptr_factory_(this) { + if (!value) + return; + + base::DictionaryValue* settings = NULL; + value->GetAsDictionary(&settings); + if (!settings) + return; + + if (settings->HasKey("run_benchmark_impl")) + settings->GetBoolean("run_benchmark_impl", &create_impl_benchmark_); +} -UnittestOnlyBenchmark::~UnittestOnlyBenchmark() {} +UnittestOnlyBenchmark::~UnittestOnlyBenchmark() { + weak_ptr_factory_.InvalidateWeakPtrs(); +} void UnittestOnlyBenchmark::DidUpdateLayers(LayerTreeHost* host) { NotifyDone(scoped_ptr<base::Value>()); } +void UnittestOnlyBenchmark::RecordImplResults(scoped_ptr<base::Value> results) { + NotifyDone(results.Pass()); +} + +scoped_ptr<MicroBenchmarkImpl> UnittestOnlyBenchmark::CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) { + if (!create_impl_benchmark_) + return make_scoped_ptr<MicroBenchmarkImpl>(NULL); + + return scoped_ptr<MicroBenchmarkImpl>(new UnittestOnlyBenchmarkImpl( + origin_loop, + NULL, + base::Bind(&UnittestOnlyBenchmark::RecordImplResults, + weak_ptr_factory_.GetWeakPtr()))); +} + } // namespace cc diff --git a/cc/debug/unittest_only_benchmark.h b/cc/debug/unittest_only_benchmark.h index 5dd7291..8331285 100644 --- a/cc/debug/unittest_only_benchmark.h +++ b/cc/debug/unittest_only_benchmark.h @@ -5,17 +5,28 @@ #ifndef CC_DEBUG_UNITTEST_ONLY_BENCHMARK_H_ #define CC_DEBUG_UNITTEST_ONLY_BENCHMARK_H_ +#include "base/memory/weak_ptr.h" #include "cc/debug/micro_benchmark.h" namespace cc { -class UnittestOnlyBenchmark : public MicroBenchmark { +class CC_EXPORT UnittestOnlyBenchmark : public MicroBenchmark { public: - explicit UnittestOnlyBenchmark(scoped_ptr<base::Value> value, - const DoneCallback& callback); + UnittestOnlyBenchmark(scoped_ptr<base::Value> value, + const DoneCallback& callback); virtual ~UnittestOnlyBenchmark(); virtual void DidUpdateLayers(LayerTreeHost* host) OVERRIDE; + + protected: + virtual scoped_ptr<MicroBenchmarkImpl> CreateBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop) OVERRIDE; + + private: + void RecordImplResults(scoped_ptr<base::Value> results); + + bool create_impl_benchmark_; + base::WeakPtrFactory<UnittestOnlyBenchmark> weak_ptr_factory_; }; } // namespace cc diff --git a/cc/debug/unittest_only_benchmark_impl.cc b/cc/debug/unittest_only_benchmark_impl.cc new file mode 100644 index 0000000..b249ce3 --- /dev/null +++ b/cc/debug/unittest_only_benchmark_impl.cc @@ -0,0 +1,24 @@ +// Copyright 2013 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 "cc/debug/unittest_only_benchmark_impl.h" + +#include "base/message_loop/message_loop_proxy.h" +#include "base/values.h" + +namespace cc { + +UnittestOnlyBenchmarkImpl::UnittestOnlyBenchmarkImpl( + scoped_refptr<base::MessageLoopProxy> origin_loop, + base::Value* settings, + const DoneCallback& callback) + : MicroBenchmarkImpl(callback, origin_loop) {} + +UnittestOnlyBenchmarkImpl::~UnittestOnlyBenchmarkImpl() {} + +void UnittestOnlyBenchmarkImpl::DidCompleteCommit(LayerTreeHostImpl* host) { + NotifyDone(scoped_ptr<base::Value>()); +} + +} // namespace cc diff --git a/cc/debug/unittest_only_benchmark_impl.h b/cc/debug/unittest_only_benchmark_impl.h new file mode 100644 index 0000000..b9e9bc9 --- /dev/null +++ b/cc/debug/unittest_only_benchmark_impl.h @@ -0,0 +1,31 @@ +// Copyright 2013 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. + +#ifndef CC_DEBUG_UNITTEST_ONLY_BENCHMARK_IMPL_H_ +#define CC_DEBUG_UNITTEST_ONLY_BENCHMARK_IMPL_H_ + +#include "base/memory/weak_ptr.h" +#include "cc/debug/micro_benchmark_impl.h" + +namespace base { +class Value; +class MessageLoopProxy; +} + +namespace cc { + +class LayerTreeHostImpl; +class CC_EXPORT UnittestOnlyBenchmarkImpl : public MicroBenchmarkImpl { + public: + UnittestOnlyBenchmarkImpl(scoped_refptr<base::MessageLoopProxy> origin_loop, + base::Value* settings, + const DoneCallback& callback); + virtual ~UnittestOnlyBenchmarkImpl(); + + virtual void DidCompleteCommit(LayerTreeHostImpl* host) OVERRIDE; +}; + +} // namespace cc + +#endif // CC_DEBUG_UNITTEST_ONLY_BENCHMARK_IMPL_H_ diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 72f70ed..1033b61 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -1,4 +1,4 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. +// Copyright 2012 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. @@ -13,6 +13,7 @@ #include "cc/base/math_util.h" #include "cc/debug/debug_colors.h" #include "cc/debug/layer_tree_debug_state.h" +#include "cc/debug/micro_benchmark_impl.h" #include "cc/debug/traced_value.h" #include "cc/input/layer_scroll_offset_delegate.h" #include "cc/layers/painted_scrollbar_layer_impl.h" @@ -1348,4 +1349,8 @@ scoped_ptr<base::Value> LayerImpl::AsValue() const { return state.PassAs<base::Value>(); } +void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { + benchmark->RunOnLayer(this); +} + } // namespace cc diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 9d3951b..e774dfa 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -42,6 +42,7 @@ namespace cc { class LayerTreeHostImpl; class LayerTreeImpl; +class MicroBenchmarkImpl; class QuadSink; class Renderer; class ScrollbarAnimationController; @@ -490,6 +491,8 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver { bool needs_push_properties() const { return true; } bool descendant_needs_push_properties() const { return true; } + virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark); + protected: LayerImpl(LayerTreeImpl* layer_impl, int id); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 065a66a..5e752c6 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -10,6 +10,7 @@ #include "cc/base/math_util.h" #include "cc/base/util.h" #include "cc/debug/debug_colors.h" +#include "cc/debug/micro_benchmark_impl.h" #include "cc/debug/traced_value.h" #include "cc/layers/append_quads_data.h" #include "cc/layers/quad_sink.h" @@ -1095,4 +1096,8 @@ size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { return tilings_->GPUMemoryUsageInBytes(); } +void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { + benchmark->RunOnLayer(this); +} + } // namespace cc diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index fd5c067..de322ea 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -21,6 +21,7 @@ namespace cc { struct AppendQuadsData; class QuadSink; +class MicroBenchmarkImpl; class CC_EXPORT PictureLayerImpl : public LayerImpl, @@ -70,6 +71,8 @@ class CC_EXPORT PictureLayerImpl virtual size_t GPUMemoryUsageInBytes() const OVERRIDE; + virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) OVERRIDE; + protected: PictureLayerImpl(LayerTreeImpl* tree_impl, int id); PictureLayerTiling* AddTiling(float contents_scale); diff --git a/cc/test/fake_layer_tree_host.h b/cc/test/fake_layer_tree_host.h index 09657ef..29426e8 100644 --- a/cc/test/fake_layer_tree_host.h +++ b/cc/test/fake_layer_tree_host.h @@ -5,6 +5,7 @@ #ifndef CC_TEST_FAKE_LAYER_TREE_HOST_H_ #define CC_TEST_FAKE_LAYER_TREE_HOST_H_ +#include "cc/debug/micro_benchmark_controller.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_impl.h" @@ -42,6 +43,10 @@ class FakeLayerTreeHost : public LayerTreeHost { LayerTreeHost::UpdateLayers(queue); } + MicroBenchmarkController* GetMicroBenchmarkController() { + return µ_benchmark_controller_; + } + bool needs_commit() { return needs_commit_; } private: diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index b6afb01..c17c3b2 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -100,14 +100,14 @@ LayerTreeHost::LayerTreeHost( LayerTreeHostClient* client, SharedBitmapManager* manager, const LayerTreeSettings& settings) - : next_ui_resource_id_(1), + : micro_benchmark_controller_(this), + next_ui_resource_id_(1), animating_(false), needs_full_tree_sync_(true), needs_filter_context_(false), client_(client), source_frame_number_(0), rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), - micro_benchmark_controller_(this), output_surface_can_be_initialized_(true), output_surface_lost_(true), num_failed_recreate_attempts_(0), @@ -425,6 +425,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->DidBecomeActive(); } + micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); + source_frame_number_++; } diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 339ae4e..54962fc 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -299,6 +299,8 @@ class CC_EXPORT LayerTreeHost { output_surface_lost_ = is_lost; } + MicroBenchmarkController micro_benchmark_controller_; + private: bool InitializeProxy(scoped_ptr<Proxy> proxy); @@ -353,8 +355,6 @@ class CC_EXPORT LayerTreeHost { int source_frame_number_; scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_; - MicroBenchmarkController micro_benchmark_controller_; - bool output_surface_can_be_initialized_; bool output_surface_lost_; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 9f0b7c0..7f7d45a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -235,6 +235,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( external_stencil_test_enabled_(false), animation_registrar_(AnimationRegistrar::Create()), rendering_stats_instrumentation_(rendering_stats_instrumentation), + micro_benchmark_controller_(this), need_to_update_visible_tiles_before_draw_(false), shared_bitmap_manager_(manager) { DCHECK(proxy_->IsImplThread()); @@ -301,6 +302,8 @@ void LayerTreeHostImpl::CommitComplete() { } client_->SendManagedMemoryStats(); + + micro_benchmark_controller_.DidCompleteCommit(); } bool LayerTreeHostImpl::CanDraw() const { @@ -2841,4 +2844,9 @@ void LayerTreeHostImpl::MarkUIResourceNotEvicted(UIResourceId uid) { client_->OnCanDrawStateChanged(CanDraw()); } +void LayerTreeHostImpl::ScheduleMicroBenchmark( + scoped_ptr<MicroBenchmarkImpl> benchmark) { + micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); +} + } // namespace cc diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 8ae65d5..9ee107e47 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -17,6 +17,7 @@ #include "cc/animation/animation_events.h" #include "cc/animation/animation_registrar.h" #include "cc/base/cc_export.h" +#include "cc/debug/micro_benchmark_controller_impl.h" #include "cc/input/input_handler.h" #include "cc/input/layer_scroll_offset_delegate.h" #include "cc/input/top_controls_manager_client.h" @@ -411,6 +412,8 @@ class CC_EXPORT LayerTreeHostImpl bool opaque; }; + void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark); + protected: LayerTreeHostImpl( const LayerTreeSettings& settings, @@ -620,6 +623,7 @@ class CC_EXPORT LayerTreeHostImpl scoped_ptr<AnimationRegistrar> animation_registrar_; RenderingStatsInstrumentation* rendering_stats_instrumentation_; + MicroBenchmarkControllerImpl micro_benchmark_controller_; bool need_to_update_visible_tiles_before_draw_; |