diff options
author | karen@chromium.org <karen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 15:23:36 +0000 |
---|---|---|
committer | karen@chromium.org <karen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 15:23:36 +0000 |
commit | 1cbe42c5856ae0fdd3968114a2660bb63e931d56 (patch) | |
tree | cd9bf2af546d37be4837c6c6109dfd42b27dc2aa | |
parent | 676d353fc626dae6d793bc4d218eb29eb8ca4c9a (diff) | |
download | chromium_src-1cbe42c5856ae0fdd3968114a2660bb63e931d56.zip chromium_src-1cbe42c5856ae0fdd3968114a2660bb63e931d56.tar.gz chromium_src-1cbe42c5856ae0fdd3968114a2660bb63e931d56.tar.bz2 |
Revert 189621 "cc:: Add RenderingStatsInstrumentation to manage ..."
> cc:: Add RenderingStatsInstrumentation to manage collection of RenderingStats
>
> This change adds the class RenderingStatsInstrumentation that manages conditional
> saving and thread-specific access to a private RenderingStats instance.
> An instance of RenderingStatsRecorder is created on LayerTreeHost, which
> passes references to LayerTreeHostImpl and TileManager. Access to reading
> and writing on the internal RenderingStats instance is guarded by a lock.
>
> All rendering stats saving in LayerTreeHost, Single-/ThreadProxy,
> LayerTreeHostImpl and TileManager has been switched to use the
> RenderingStatsInstrumentation. Stats collection within Layer::update() still
> follows the original structure to keep this change small.
>
> BUG=181319
> NOTRY=true
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=189475
>
> Review URL: https://chromiumcodereview.appspot.com/12519006
TBR=egraether@chromium.org
Review URL: https://codereview.chromium.org/12471010
git-svn-id: svn://svn.chromium.org/chrome/branches/1451/src@190271 0039d316-1c4b-4281-b951-d872f2087c98
30 files changed, 293 insertions, 493 deletions
diff --git a/cc/base/worker_pool.cc b/cc/base/worker_pool.cc index 25596d4..caa3159 100644 --- a/cc/base/worker_pool.cc +++ b/cc/base/worker_pool.cc @@ -9,6 +9,7 @@ #include "base/stringprintf.h" #include "base/synchronization/condition_variable.h" #include "base/threading/simple_thread.h" +#include "cc/debug/rendering_stats.h" #if defined(OS_ANDROID) // TODO(epenner): Move thread priorities to base. (crbug.com/170549) @@ -28,12 +29,13 @@ class WorkerPoolTaskImpl : public internal::WorkerPoolTask { virtual bool IsCheap() OVERRIDE { return false; } - virtual void Run() OVERRIDE { - task_.Run(); + virtual void Run(RenderingStats* rendering_stats) OVERRIDE { + task_.Run(rendering_stats); } - virtual void RunOnThread(unsigned thread_index) OVERRIDE { - task_.Run(); + virtual void RunOnThread( + RenderingStats* rendering_stats, unsigned thread_index) OVERRIDE { + task_.Run(rendering_stats); } private: @@ -69,6 +71,10 @@ class WorkerPool::Inner : public base::DelegateSimpleThread::Delegate { void Shutdown(); + void SetRecordRenderingStats(bool record_rendering_stats); + + void GetRenderingStats(RenderingStats* stats); + void PostTask(scoped_ptr<internal::WorkerPoolTask> task, bool signal_workers); // Appends all completed tasks to worker pool's completed tasks queue @@ -143,6 +149,8 @@ class WorkerPool::Inner : public base::DelegateSimpleThread::Delegate { TaskDeque pending_tasks_; TaskDeque completed_tasks_; + scoped_ptr<RenderingStats> rendering_stats_; + ScopedPtrDeque<base::DelegateSimpleThread> workers_; DISALLOW_COPY_AND_ASSIGN(Inner); @@ -212,6 +220,22 @@ void WorkerPool::Inner::Shutdown() { } } +void WorkerPool::Inner::SetRecordRenderingStats(bool record_rendering_stats) { + base::AutoLock lock(lock_); + + if (record_rendering_stats) + rendering_stats_.reset(new RenderingStats); + else + rendering_stats_.reset(); +} + +void WorkerPool::Inner::GetRenderingStats(RenderingStats* stats) { + base::AutoLock lock(lock_); + + if (rendering_stats_) + stats->Add(*rendering_stats_); +} + void WorkerPool::Inner::PostTask(scoped_ptr<internal::WorkerPoolTask> task, bool signal_workers) { base::AutoLock lock(lock_); @@ -255,13 +279,18 @@ bool WorkerPool::Inner::RunCheapTasksUntilTimeLimit( break; } + scoped_ptr<RenderingStats> rendering_stats; + // Collect rendering stats if |rendering_stats_| is set. + if (rendering_stats_) + rendering_stats = make_scoped_ptr(new RenderingStats); + // Increment |running_task_count_| before starting to run task. running_task_count_++; { base::AutoUnlock unlock(lock_); - task->Run(); + task->Run(rendering_stats.get()); // Append tasks directly to worker pool's completed tasks queue. worker_pool_on_origin_thread_->completed_tasks_.push_back(task.Pass()); @@ -269,6 +298,10 @@ bool WorkerPool::Inner::RunCheapTasksUntilTimeLimit( worker_pool_on_origin_thread_->OnTaskCompleted(); } + // Add rendering stat results to |rendering_stats_|. + if (rendering_stats && rendering_stats_) + rendering_stats_->Add(*rendering_stats); + // Decrement |running_task_count_| now that we are done running task. running_task_count_--; } @@ -372,6 +405,11 @@ void WorkerPool::Inner::Run() { // Get next task. scoped_ptr<internal::WorkerPoolTask> task = pending_tasks_.take_front(); + scoped_ptr<RenderingStats> rendering_stats; + // Collect rendering stats if |rendering_stats_| is set. + if (rendering_stats_) + rendering_stats = make_scoped_ptr(new RenderingStats); + // Increment |running_task_count_| before starting to run task. running_task_count_++; @@ -382,11 +420,15 @@ void WorkerPool::Inner::Run() { { base::AutoUnlock unlock(lock_); - task->RunOnThread(thread_index); + task->RunOnThread(rendering_stats.get(), thread_index); } completed_tasks_.push_back(task.Pass()); + // Add rendering stat results to |rendering_stats_|. + if (rendering_stats && rendering_stats_) + rendering_stats_->Add(*rendering_stats); + // Decrement |running_task_count_| now that we are done running task. running_task_count_--; @@ -450,6 +492,14 @@ void WorkerPool::SetRunCheapTasksTimeLimit( ScheduleRunCheapTasks(); } +void WorkerPool::SetRecordRenderingStats(bool record_rendering_stats) { + inner_->SetRecordRenderingStats(record_rendering_stats); +} + +void WorkerPool::GetRenderingStats(RenderingStats* stats) { + inner_->GetRenderingStats(stats); +} + void WorkerPool::OnIdle() { TRACE_EVENT0("cc", "WorkerPool::OnIdle"); diff --git a/cc/base/worker_pool.h b/cc/base/worker_pool.h index af130f3..8e00b6b 100644 --- a/cc/base/worker_pool.h +++ b/cc/base/worker_pool.h @@ -15,6 +15,7 @@ #include "cc/base/scoped_ptr_deque.h" namespace cc { +struct RenderingStats; namespace internal { @@ -24,9 +25,10 @@ class WorkerPoolTask { virtual bool IsCheap() = 0; - virtual void Run() = 0; + virtual void Run(RenderingStats* rendering_stats) = 0; - virtual void RunOnThread(unsigned thread_index) = 0; + virtual void RunOnThread( + RenderingStats* rendering_stats, unsigned thread_index) = 0; void DidComplete(); @@ -50,7 +52,7 @@ class CC_EXPORT WorkerPoolClient { // of all pending tasks at shutdown. class WorkerPool { public: - typedef base::Callback<void()> Callback; + typedef base::Callback<void(RenderingStats*)> Callback; virtual ~WorkerPool(); @@ -76,6 +78,12 @@ class WorkerPool { // Set time limit for running cheap tasks. void SetRunCheapTasksTimeLimit(base::TimeTicks run_cheap_tasks_time_limit); + // Toggle rendering stats collection. + void SetRecordRenderingStats(bool record_rendering_stats); + + // Collect rendering stats of all completed tasks. + void GetRenderingStats(RenderingStats* stats); + protected: WorkerPool(WorkerPoolClient* client, size_t num_threads, @@ -211,8 +211,6 @@ 'output/renderer.h', 'debug/rendering_stats.cc', 'debug/rendering_stats.h', - 'debug/rendering_stats_instrumentation.cc', - 'debug/rendering_stats_instrumentation.h', 'resources/resource.cc', 'resources/resource.h', 'resources/resource_pool.cc', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index b625cce..2d363f7 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -99,7 +99,6 @@ 'test/fake_picture_layer_tiling_client.h', 'test/fake_proxy.cc', 'test/fake_proxy.h', - 'test/fake_rendering_stats_instrumentation.h', 'test/fake_scrollbar_layer.cc', 'test/fake_scrollbar_layer.h', 'test/fake_scrollbar_theme_painter.h', diff --git a/cc/debug/rendering_stats_instrumentation.cc b/cc/debug/rendering_stats_instrumentation.cc deleted file mode 100644 index 1fb5296..0000000 --- a/cc/debug/rendering_stats_instrumentation.cc +++ /dev/null @@ -1,164 +0,0 @@ -// 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/rendering_stats_instrumentation.h" - -namespace cc { - -// static -scoped_ptr<RenderingStatsInstrumentation> - RenderingStatsInstrumentation::Create() { - return make_scoped_ptr(new RenderingStatsInstrumentation()); -} - -RenderingStatsInstrumentation::RenderingStatsInstrumentation() - : record_rendering_stats_(false) { -} - -RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} - -RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { - base::AutoLock scoped_lock(lock_); - return rendering_stats_; -} - -base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { - if (record_rendering_stats_) - return base::TimeTicks::HighResNow(); - return base::TimeTicks(); -} - -base::TimeDelta RenderingStatsInstrumentation::EndRecording( - base::TimeTicks start_time) const { - if (!start_time.is_null()) - return base::TimeTicks::HighResNow() - start_time; - return base::TimeDelta(); -} - -void RenderingStatsInstrumentation::AddStats(const RenderingStats& other) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.Add(other); -} - -void RenderingStatsInstrumentation::IncrementAnimationFrameCount() { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numAnimationFrames++; -} - -void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numFramesSentToScreen = count; -} - -void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.droppedFrameCount = count; -} - -void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalCommitTime += duration; - rendering_stats_.totalCommitCount++; -} - -void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, - int64 pixels) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalPaintTime += duration; - rendering_stats_.totalPixelsPainted += pixels; -} - -void RenderingStatsInstrumentation::AddRaster(base::TimeDelta duration, - int64 pixels, - bool is_in_pending_tree_now_bin) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalRasterizeTime += duration; - rendering_stats_.totalPixelsRasterized += pixels; - - if (is_in_pending_tree_now_bin) - rendering_stats_.totalRasterizeTimeForNowBinsOnPendingTree += duration; -} - -void RenderingStatsInstrumentation::IncrementImplThreadScrolls() { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numImplThreadScrolls++; -} - -void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numMainThreadScrolls++; -} - -void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numLayersDrawn += amount; -} - -void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.numMissingTiles += amount; -} - -void RenderingStatsInstrumentation::AddDeferredImageDecode( - base::TimeDelta duration) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalDeferredImageDecodeTime += duration; - rendering_stats_.totalDeferredImageDecodeCount++; -} - -void RenderingStatsInstrumentation::AddImageGathering( - base::TimeDelta duration) { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalImageGatheringTime += duration; - rendering_stats_.totalImageGatheringCount++; -} - -void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { - if (!record_rendering_stats_) - return; - - base::AutoLock scoped_lock(lock_); - rendering_stats_.totalDeferredImageCacheHitCount++; -} - -} // namespace cc diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h deleted file mode 100644 index 63401c0..0000000 --- a/cc/debug/rendering_stats_instrumentation.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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_RENDERING_STATS_INSTRUMENTATION_H_ -#define CC_RENDERING_STATS_INSTRUMENTATION_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/synchronization/lock.h" -#include "cc/debug/rendering_stats.h" - -namespace cc { - -// RenderingStatsInstrumentation is shared among threads and manages conditional -// recording of rendering stats into a private RenderingStats instance. -class CC_EXPORT RenderingStatsInstrumentation { - public: - static scoped_ptr<RenderingStatsInstrumentation> Create(); - virtual ~RenderingStatsInstrumentation(); - - RenderingStats GetRenderingStats(); - - // Read and write access to the record_rendering_stats_ flag is not locked to - // improve performance. The flag is commonly turned off and hardly changes - // it's value during runtime. - bool record_rendering_stats() const { return record_rendering_stats_; } - void set_record_rendering_stats(bool record_rendering_stats) { - if (record_rendering_stats_ != record_rendering_stats) - record_rendering_stats_ = record_rendering_stats; - } - - base::TimeTicks StartRecording() const; - base::TimeDelta EndRecording(base::TimeTicks start_time) const; - - // TODO(egraether): Remove after switching Layer::update() to use this class. - // Used in LayerTreeHost::paintLayerContents(). - void AddStats(const RenderingStats& other); - - void IncrementAnimationFrameCount(); - void SetScreenFrameCount(int64 count); - void SetDroppedFrameCount(int64 count); - - void AddCommit(base::TimeDelta duration); - void AddPaint(base::TimeDelta duration, int64 pixels); - void AddRaster(base::TimeDelta duration, - int64 pixels, - bool is_in_pending_tree_now_bin); - - void IncrementImplThreadScrolls(); - void IncrementMainThreadScrolls(); - - void AddLayersDrawn(int64 amount); - void AddMissingTiles(int64 amount); - - void AddDeferredImageDecode(base::TimeDelta duration); - void AddImageGathering(base::TimeDelta duration); - - void IncrementDeferredImageCacheHitCount(); - - protected: - RenderingStatsInstrumentation(); - - private: - RenderingStats rendering_stats_; - bool record_rendering_stats_; - - base::Lock lock_; - - DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation); -}; - -} // namespace cc - -#endif // CC_RENDERING_STATS_INSTRUMENTATION_H_ diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc index 8968996..c0516df 100644 --- a/cc/layers/delegated_renderer_layer_impl_unittest.cc +++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc @@ -15,7 +15,6 @@ #include "cc/test/fake_layer_tree_host_impl_client.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/mock_quad_culler.h" #include "cc/test/render_pass_test_common.h" @@ -38,10 +37,7 @@ class DelegatedRendererLayerImplTest : public testing::Test { LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); - host_impl_ = LayerTreeHostImpl::Create(settings, - &client_, - &proxy_, - &stats_instrumentation_); + host_impl_ = LayerTreeHostImpl::Create(settings, &client_, &proxy_); host_impl_->InitializeRenderer(CreateFakeOutputSurface()); host_impl_->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); } @@ -51,7 +47,6 @@ class DelegatedRendererLayerImplTest : public testing::Test { FakeLayerTreeHostImplClient client_; DebugScopedSetImplThreadAndMainThreadBlocked always_impl_thread_and_main_thread_blocked_; - FakeRenderingStatsInstrumentation stats_instrumentation_; scoped_ptr<LayerTreeHostImpl> host_impl_; }; diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc index c2a4a0b..369a0e5 100644 --- a/cc/resources/raster_worker_pool.cc +++ b/cc/resources/raster_worker_pool.cc @@ -25,12 +25,14 @@ class RasterWorkerPoolTaskImpl : public internal::WorkerPoolTask { virtual bool IsCheap() OVERRIDE { return is_cheap_; } - virtual void Run() OVERRIDE { - task_.Run(picture_pile_.get()); + virtual void Run(RenderingStats* rendering_stats) OVERRIDE { + task_.Run(picture_pile_.get(), rendering_stats); } - virtual void RunOnThread(unsigned thread_index) OVERRIDE { - task_.Run(picture_pile_->GetCloneForDrawingOnThread(thread_index)); + virtual void RunOnThread( + RenderingStats* rendering_stats, unsigned thread_index) OVERRIDE { + task_.Run(picture_pile_->GetCloneForDrawingOnThread(thread_index), + rendering_stats); } private: diff --git a/cc/resources/raster_worker_pool.h b/cc/resources/raster_worker_pool.h index 0557946..4422860 100644 --- a/cc/resources/raster_worker_pool.h +++ b/cc/resources/raster_worker_pool.h @@ -15,7 +15,7 @@ class PicturePileImpl; // A worker thread pool that runs raster tasks. class RasterWorkerPool : public WorkerPool { public: - typedef base::Callback<void(PicturePileImpl*)> + typedef base::Callback<void(PicturePileImpl*, RenderingStats*)> RasterCallback; virtual ~RasterWorkerPool(); diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 10f9179..1deb354 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -152,8 +152,7 @@ TileManager::TileManager( size_t num_raster_threads, bool use_cheapness_estimator, bool use_color_estimator, - bool prediction_benchmarking, - RenderingStatsInstrumentation* rendering_stats_instrumentation) + bool prediction_benchmarking) : client_(client), resource_pool_(ResourcePool::Create(resource_provider)), raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)), @@ -162,12 +161,12 @@ TileManager::TileManager( bytes_pending_upload_(0), has_performed_uploads_since_last_flush_(false), ever_exceeded_memory_budget_(false), + record_rendering_stats_(false), use_cheapness_estimator_(use_cheapness_estimator), use_color_estimator_(use_color_estimator), prediction_benchmarking_(prediction_benchmarking), pending_tasks_(0), - max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads), - rendering_stats_instrumentation_(rendering_stats_instrumentation) { + max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads) { for (int i = 0; i < NUM_STATES; ++i) { for (int j = 0; j < NUM_TREES; ++j) { for (int k = 0; k < NUM_BINS; ++k) @@ -498,6 +497,24 @@ scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const { return requirements.PassAs<base::Value>(); } +void TileManager::SetRecordRenderingStats(bool record_rendering_stats) { + if (record_rendering_stats_ == record_rendering_stats) + return; + + record_rendering_stats_ = record_rendering_stats; + raster_worker_pool_->SetRecordRenderingStats(record_rendering_stats); +} + +void TileManager::GetRenderingStats(RenderingStats* stats) { + CHECK(record_rendering_stats_); + raster_worker_pool_->GetRenderingStats(stats); + stats->totalDeferredImageCacheHitCount = + rendering_stats_.totalDeferredImageCacheHitCount; + stats->totalImageGatheringCount = rendering_stats_.totalImageGatheringCount; + stats->totalImageGatheringTime = + rendering_stats_.totalImageGatheringTime; +} + bool TileManager::HasPendingWorkScheduled(WhichTree tree) const { // Always true when ManageTiles() call is pending. if (manage_tiles_pending_) @@ -724,16 +741,19 @@ void TileManager::GatherPixelRefsForTile(Tile* tile) { TRACE_EVENT0("cc", "TileManager::GatherPixelRefsForTile"); ManagedTileState& managed_tile_state = tile->managed_state(); if (managed_tile_state.need_to_gather_pixel_refs) { - base::TimeTicks start_time = - rendering_stats_instrumentation_->StartRecording(); + base::TimeTicks gather_begin_time; + if (record_rendering_stats_) + gather_begin_time = base::TimeTicks::HighResNow(); tile->picture_pile()->GatherPixelRefs( tile->content_rect_, tile->contents_scale_, managed_tile_state.pending_pixel_refs); managed_tile_state.need_to_gather_pixel_refs = false; - base::TimeDelta duration = - rendering_stats_instrumentation_->EndRecording(start_time); - rendering_stats_instrumentation_->AddImageGathering(duration); + if (record_rendering_stats_) { + rendering_stats_.totalImageGatheringCount++; + rendering_stats_.totalImageGatheringTime += + base::TimeTicks::HighResNow() - gather_begin_time; + } } } @@ -750,7 +770,7 @@ void TileManager::DispatchImageDecodeTasksForTile(Tile* tile) { } // TODO(qinmin): passing correct image size to PrepareToDecode(). if ((*it)->PrepareToDecode(skia::LazyPixelRef::PrepareParams())) { - rendering_stats_instrumentation_->IncrementDeferredImageCacheHitCount(); + rendering_stats_.totalDeferredImageCacheHitCount++; pending_pixel_refs.erase(it++); } else { if (pending_tasks_ >= max_pending_tasks_) @@ -770,9 +790,7 @@ void TileManager::DispatchOneImageDecodeTask( pending_decode_tasks_[pixel_ref_id] = pixel_ref; raster_worker_pool_->PostTaskAndReply( - base::Bind(&TileManager::RunImageDecodeTask, - pixel_ref, - rendering_stats_instrumentation_), + base::Bind(&TileManager::RunImageDecodeTask, pixel_ref), base::Bind(&TileManager::OnImageDecodeTaskCompleted, base::Unretained(this), tile, @@ -847,8 +865,7 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) { buffer, tile->content_rect(), tile->contents_scale(), - GetRasterTaskMetadata(*tile), - rendering_stats_instrumentation_), + GetRasterTaskMetadata(*tile)), base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), tile, @@ -958,13 +975,12 @@ void TileManager::DidTileTreeBinChange(Tile* tile, } // static -void TileManager::RunRasterTask( - uint8* buffer, - const gfx::Rect& rect, - float contents_scale, - const RasterTaskMetadata& metadata, - RenderingStatsInstrumentation* stats_instrumentation, - PicturePileImpl* picture_pile) { +void TileManager::RunRasterTask(uint8* buffer, + const gfx::Rect& rect, + float contents_scale, + const RasterTaskMetadata& metadata, + PicturePileImpl* picture_pile, + RenderingStats* stats) { TRACE_EVENT2( "cc", "TileManager::RunRasterTask", "is_on_pending_tree", @@ -982,18 +998,22 @@ void TileManager::RunRasterTask( SkDevice device(bitmap); SkCanvas canvas(&device); - base::TimeTicks start_time = stats_instrumentation->StartRecording(); + base::TimeTicks begin_time; + if (stats) + begin_time = base::TimeTicks::HighResNow(); int64 total_pixels_rasterized = 0; picture_pile->Raster(&canvas, rect, contents_scale, &total_pixels_rasterized); - base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); + if (stats) { + stats->totalPixelsRasterized += total_pixels_rasterized; - if (stats_instrumentation->record_rendering_stats()) { - stats_instrumentation->AddRaster(duration, - total_pixels_rasterized, - metadata.is_tile_in_pending_tree_now_bin); + base::TimeTicks end_time = base::TimeTicks::HighResNow(); + base::TimeDelta duration = end_time - begin_time; + stats->totalRasterizeTime += duration; + if (metadata.is_tile_in_pending_tree_now_bin) + stats->totalRasterizeTimeForNowBinsOnPendingTree += duration; UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.PictureRasterTimeMS", duration.InMilliseconds(), @@ -1086,14 +1106,18 @@ void TileManager::RecordSolidColorPredictorResults( } // static -void TileManager::RunImageDecodeTask( - skia::LazyPixelRef* pixel_ref, - RenderingStatsInstrumentation* stats_instrumentation) { +void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, + RenderingStats* stats) { TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); - base::TimeTicks start_time = stats_instrumentation->StartRecording(); + base::TimeTicks decode_begin_time; + if (stats) + decode_begin_time = base::TimeTicks::HighResNow(); pixel_ref->Decode(); - base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); - stats_instrumentation->AddDeferredImageDecode(duration); + if (stats) { + stats->totalDeferredImageDecodeCount++; + stats->totalDeferredImageDecodeTime += + base::TimeTicks::HighResNow() - decode_begin_time; + } } } // namespace cc diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index 76c2b89..85cb7c1 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -14,7 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "cc/base/worker_pool.h" -#include "cc/debug/rendering_stats_instrumentation.h" +#include "cc/debug/rendering_stats.h" #include "cc/resources/memory_history.h" #include "cc/resources/picture_pile_impl.h" #include "cc/resources/resource_pool.h" @@ -78,8 +78,7 @@ class CC_EXPORT TileManager : public WorkerPoolClient { size_t num_raster_threads, bool use_cheapess_estimator, bool use_color_estimator, - bool prediction_benchmarking, - RenderingStatsInstrumentation* rendering_stats_instrumentation); + bool prediction_benchmarking); virtual ~TileManager(); const GlobalStateThatImpactsTilePriority& GlobalState() const { @@ -95,9 +94,11 @@ class CC_EXPORT TileManager : public WorkerPoolClient { scoped_ptr<base::Value> BasicStateAsValue() const; scoped_ptr<base::Value> AllTilesAsValue() const; - void GetMemoryStats(size_t* memoryRequiredBytes, - size_t* memoryNiceToHaveBytes, - size_t* memoryUsedBytes) const; + void GetMemoryStats(size_t* memory_required_bytes, + size_t* memory_nice_to_have_bytes, + size_t* memory_used_bytes) const; + void SetRecordRenderingStats(bool record_rendering_stats); + void GetRenderingStats(RenderingStats* stats); bool HasPendingWorkScheduled(WhichTree tree) const; const MemoryHistory::Entry& memory_stats_from_last_assign() const { @@ -164,16 +165,14 @@ class CC_EXPORT TileManager : public WorkerPoolClient { WhichTree tree); scoped_ptr<Value> GetMemoryRequirementsAsValue() const; - static void RunRasterTask( - uint8* buffer, - const gfx::Rect& rect, - float contents_scale, - const RasterTaskMetadata& metadata, - RenderingStatsInstrumentation* stats_instrumentation, - PicturePileImpl* picture_pile); - static void RunImageDecodeTask( - skia::LazyPixelRef* pixel_ref, - RenderingStatsInstrumentation* stats_instrumentation); + static void RunRasterTask(uint8* buffer, + const gfx::Rect& rect, + float contents_scale, + const RasterTaskMetadata& metadata, + PicturePileImpl* picture_pile, + RenderingStats* stats); + static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, + RenderingStats* stats); static void RecordCheapnessPredictorResults(bool is_predicted_cheap, bool is_actually_cheap); @@ -212,7 +211,8 @@ class CC_EXPORT TileManager : public WorkerPoolClient { bool ever_exceeded_memory_budget_; MemoryHistory::Entry memory_stats_from_last_assign_; - RenderingStatsInstrumentation* rendering_stats_instrumentation_; + bool record_rendering_stats_; + RenderingStats rendering_stats_; bool use_cheapness_estimator_; bool use_color_estimator_; diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc index f393f1d..334ff9f 100644 --- a/cc/test/fake_layer_tree_host_impl.cc +++ b/cc/test/fake_layer_tree_host_impl.cc @@ -7,11 +7,7 @@ namespace cc { FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(Proxy* proxy) - : LayerTreeHostImpl(LayerTreeSettings(), - &client_, - proxy, - &stats_instrumentation_) -{ + : LayerTreeHostImpl(LayerTreeSettings(), &client_, proxy) { // Explicitly clear all debug settings. SetDebugState(LayerTreeDebugState()); } @@ -19,11 +15,7 @@ FakeLayerTreeHostImpl::FakeLayerTreeHostImpl(Proxy* proxy) FakeLayerTreeHostImpl::FakeLayerTreeHostImpl( const LayerTreeSettings& settings, Proxy* proxy) - : LayerTreeHostImpl(settings, - &client_, - proxy, - &stats_instrumentation_) -{ + : LayerTreeHostImpl(settings, &client_, proxy) { // Explicitly clear all debug settings. SetDebugState(LayerTreeDebugState()); } diff --git a/cc/test/fake_layer_tree_host_impl.h b/cc/test/fake_layer_tree_host_impl.h index 8ed07e8..2023411 100644 --- a/cc/test/fake_layer_tree_host_impl.h +++ b/cc/test/fake_layer_tree_host_impl.h @@ -6,7 +6,6 @@ #define CC_TEST_FAKE_LAYER_TREE_HOST_IMPL_H_ #include "cc/test/fake_layer_tree_host_impl_client.h" -#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/single_thread_proxy.h" @@ -28,7 +27,6 @@ class FakeLayerTreeHostImpl : public LayerTreeHostImpl { private: FakeLayerTreeHostImplClient client_; - FakeRenderingStatsInstrumentation stats_instrumentation_; }; } // namespace cc diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index e837846..c8b816b 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -21,13 +21,7 @@ class FakeInfinitePicturePileImpl : public PicturePileImpl { }; FakePictureLayerTilingClient::FakePictureLayerTilingClient() - : tile_manager_(&tile_manager_client_, - NULL, - 1, - false, - false, - false, - &stats_instrumentation_), + : tile_manager_(&tile_manager_client_, NULL, 1, false, false, false), pile_(new FakeInfinitePicturePileImpl()) { } diff --git a/cc/test/fake_picture_layer_tiling_client.h b/cc/test/fake_picture_layer_tiling_client.h index 0dd9717..9f2e77d 100644 --- a/cc/test/fake_picture_layer_tiling_client.h +++ b/cc/test/fake_picture_layer_tiling_client.h @@ -9,7 +9,6 @@ #include "cc/resources/picture_pile_impl.h" #include "cc/resources/tile.h" #include "cc/resources/tile_manager.h" -#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/fake_tile_manager_client.h" #include "ui/gfx/rect.h" @@ -33,7 +32,6 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient { protected: FakeTileManagerClient tile_manager_client_; - FakeRenderingStatsInstrumentation stats_instrumentation_; TileManager tile_manager_; scoped_refptr<PicturePileImpl> pile_; gfx::Size tile_size_; diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index 3be3f46..3b84723 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -28,6 +28,7 @@ class FakeProxy : public Proxy { virtual void SetVisible(bool visible) OVERRIDE {} virtual bool InitializeRenderer() OVERRIDE; virtual bool RecreateOutputSurface() OVERRIDE; + virtual void CollectRenderingStats(RenderingStats* stats) OVERRIDE {} virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual void SetNeedsAnimate() OVERRIDE {} virtual void SetNeedsCommit() OVERRIDE {} diff --git a/cc/test/fake_rendering_stats_instrumentation.h b/cc/test/fake_rendering_stats_instrumentation.h deleted file mode 100644 index d32e4a0..0000000 --- a/cc/test/fake_rendering_stats_instrumentation.h +++ /dev/null @@ -1,20 +0,0 @@ -// 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_TEST_FAKE_RENDERING_STATS_INSTRUMENTATION_H_ -#define CC_TEST_FAKE_RENDERING_STATS_INSTRUMENTATION_H_ - -#include "cc/debug/rendering_stats_instrumentation.h" - -namespace cc { - -class FakeRenderingStatsInstrumentation : public RenderingStatsInstrumentation { - public: - FakeRenderingStatsInstrumentation() {} - virtual ~FakeRenderingStatsInstrumentation() {} -}; - -} // namespace cc - -#endif // CC_TEST_FAKE_RENDERING_STATS_INSTRUMENTATION_H_ diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 5a56c14..b0b338f 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -69,27 +69,19 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { TestHooks* test_hooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* host_impl_client, - Proxy* proxy, - RenderingStatsInstrumentation* stats_instrumentation) { - return make_scoped_ptr( - new LayerTreeHostImplForTesting(test_hooks, - settings, - host_impl_client, - proxy, - stats_instrumentation)); + Proxy* proxy) { + return make_scoped_ptr(new LayerTreeHostImplForTesting(test_hooks, + settings, + host_impl_client, + proxy)); } protected: - LayerTreeHostImplForTesting( - TestHooks* test_hooks, - const LayerTreeSettings& settings, - LayerTreeHostImplClient* host_impl_client, - Proxy* proxy, - RenderingStatsInstrumentation* stats_instrumentation) - : LayerTreeHostImpl(settings, - host_impl_client, - proxy, - stats_instrumentation), + LayerTreeHostImplForTesting(TestHooks* test_hooks, + const LayerTreeSettings& settings, + LayerTreeHostImplClient* host_impl_client, + Proxy* proxy) + : LayerTreeHostImpl(settings, host_impl_client, proxy), test_hooks_(test_hooks) {} virtual void BeginCommit() OVERRIDE { @@ -199,8 +191,7 @@ class LayerTreeHostForTesting : public cc::LayerTreeHost { test_hooks_, settings(), host_impl_client, - proxy(), - rendering_stats_instrumentation()).PassAs<cc::LayerTreeHostImpl>(); + proxy()).PassAs<cc::LayerTreeHostImpl>(); } virtual void SetNeedsCommit() OVERRIDE { diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index b023f85..dbad9ac 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -15,7 +15,6 @@ #include "cc/base/math_util.h" #include "cc/base/thread.h" #include "cc/debug/overdraw_metrics.h" -#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/input/pinch_zoom_scrollbar.h" #include "cc/input/pinch_zoom_scrollbar_geometry.h" #include "cc/input/pinch_zoom_scrollbar_painter.h" @@ -78,7 +77,7 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, needs_filter_context_(false), client_(client), commit_number_(0), - rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), + rendering_stats_(), renderer_initialized_(false), output_surface_lost_(false), num_failed_recreate_attempts_(0), @@ -96,9 +95,6 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, if (settings_.accelerated_animation_enabled) animation_registrar_ = AnimationRegistrar::Create(); s_num_layer_tree_instances++; - - rendering_stats_instrumentation_->set_record_rendering_stats( - debug_state_.RecordRenderingStats()); } bool LayerTreeHost::Initialize(scoped_ptr<Thread> impl_thread) { @@ -234,7 +230,7 @@ void LayerTreeHost::UpdateAnimations(base::TimeTicks frame_begin_time) { AnimateLayers(frame_begin_time); animating_ = false; - rendering_stats_instrumentation_->IncrementAnimationFrameCount(); + rendering_stats_.numAnimationFrames++; } void LayerTreeHost::DidStopFlinging() { @@ -349,12 +345,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->DidBecomeActive(); } - if (debug_state_.continuous_painting) { - host_impl->SavePaintTime( - rendering_stats_instrumentation_->GetRenderingStats().totalPaintTime, - commit_number() - ); - } + if (debug_state_.continuous_painting) + host_impl->SavePaintTime(rendering_stats_.totalPaintTime, commit_number()); commit_number_++; } @@ -451,10 +443,7 @@ scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( LayerTreeHostImplClient* client) { DCHECK(proxy_->IsImplThread()); scoped_ptr<LayerTreeHostImpl> host_impl = - LayerTreeHostImpl::Create(settings_, - client, - proxy_.get(), - rendering_stats_instrumentation_.get()); + LayerTreeHostImpl::Create(settings_, client, proxy_.get()); if (settings_.calculate_top_controls_position && host_impl->top_controls_manager()) { top_controls_manager_weak_ptr_ = @@ -493,7 +482,8 @@ void LayerTreeHost::DidDeferCommit() {} void LayerTreeHost::CollectRenderingStats(RenderingStats* stats) const { CHECK(debug_state_.RecordRenderingStats()); - *stats = rendering_stats_instrumentation_->GetRenderingStats(); + *stats = rendering_stats_; + proxy_->CollectRenderingStats(stats); } const RendererCapabilities& LayerTreeHost::GetRendererCapabilities() const { @@ -567,10 +557,6 @@ void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { return; debug_state_ = new_debug_state; - - rendering_stats_instrumentation_->set_record_rendering_stats( - debug_state_.RecordRenderingStats()); - SetNeedsCommit(); } @@ -810,13 +796,15 @@ size_t LayerTreeHost::CalculateMemoryForRenderSurfaces( } bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, - ResourceUpdateQueue* queue, - RenderingStats* stats) { + ResourceUpdateQueue* queue) { // Note: Masks and replicas only exist for layers that own render surfaces. If // we reach this point in code, we already know that at least something will // be drawn into this render surface, so the mask and replica should be // painted. + RenderingStats* stats = + debug_state_.RecordRenderingStats() ? &rendering_stats_ : NULL; + bool need_more_updates = false; Layer* mask_layer = render_surface_layer->mask_layer(); if (mask_layer) { @@ -856,10 +844,8 @@ bool LayerTreeHost::PaintLayerContents( PrioritizeTextures(render_surface_layer_list, occlusion_tracker.overdraw_metrics()); - // TODO(egraether): Use RenderingStatsInstrumentation in Layer::update() - RenderingStats stats; - RenderingStats* stats_ptr = - debug_state_.RecordRenderingStats() ? &stats : NULL; + RenderingStats* stats = debug_state_.RecordRenderingStats() ? + &rendering_stats_ : NULL; LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); for (LayerIteratorType it = @@ -871,18 +857,16 @@ bool LayerTreeHost::PaintLayerContents( if (it.represents_target_render_surface()) { DCHECK(it->render_surface()->draw_opacity() || it->render_surface()->draw_opacity_is_animating()); - need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); + need_more_updates |= PaintMasksForRenderSurface(*it, queue); } else if (it.represents_itself()) { DCHECK(!it->bounds().IsEmpty()); - it->Update(queue, &occlusion_tracker, stats_ptr); + it->Update(queue, &occlusion_tracker, stats); need_more_updates |= it->NeedMoreUpdates(); } occlusion_tracker.LeaveLayer(it); } - rendering_stats_instrumentation_->AddStats(stats); - occlusion_tracker.overdraw_metrics()->RecordMetrics(this); return need_more_updates; diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 934ae46..ea769aa 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -17,6 +17,7 @@ #include "cc/animation/animation_events.h" #include "cc/base/cc_export.h" #include "cc/base/scoped_ptr_vector.h" +#include "cc/debug/rendering_stats.h" #include "cc/output/output_surface.h" #include "cc/scheduler/rate_limiter.h" #include "cc/trees/layer_tree_host_client.h" @@ -50,12 +51,10 @@ class LayerTreeHostImplClient; class PrioritizedResourceManager; class PrioritizedResource; class Region; -class RenderingStatsInstrumentation; class ResourceProvider; class ResourceUpdateQueue; class ScrollbarLayer; class TopControlsManager; -struct RenderingStats; struct ScrollAndScaleSet; // Provides information on an Impl's rendering capabilities back to the @@ -149,10 +148,6 @@ class CC_EXPORT LayerTreeHost : public RateLimiterClient { void CollectRenderingStats(RenderingStats* stats) const; - RenderingStatsInstrumentation* rendering_stats_instrumentation() const { - return rendering_stats_instrumentation_.get(); - } - const RendererCapabilities& GetRendererCapabilities() const; void SetNeedsAnimate(); @@ -252,8 +247,7 @@ class CC_EXPORT LayerTreeHost : public RateLimiterClient { bool PaintLayerContents(const LayerList& render_surface_layer_list, ResourceUpdateQueue* quue); bool PaintMasksForRenderSurface(Layer* render_surface_layer, - ResourceUpdateQueue* queue, - RenderingStats* stats); + ResourceUpdateQueue* queue); void UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue); void UpdateHudLayer(); @@ -281,7 +275,7 @@ class CC_EXPORT LayerTreeHost : public RateLimiterClient { scoped_ptr<Proxy> proxy_; int commit_number_; - scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_; + RenderingStats rendering_stats_; bool renderer_initialized_; bool output_surface_lost_; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index c69982e..d0be1af 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -19,7 +19,7 @@ #include "cc/debug/frame_rate_counter.h" #include "cc/debug/overdraw_metrics.h" #include "cc/debug/paint_time_counter.h" -#include "cc/debug/rendering_stats_instrumentation.h" +#include "cc/debug/rendering_stats.h" #include "cc/input/page_scale_animation.h" #include "cc/input/top_controls_manager.h" #include "cc/layers/append_quads_data.h" @@ -141,20 +141,13 @@ LayerTreeHostImpl::FrameData::~FrameData() {} scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( const LayerTreeSettings& settings, LayerTreeHostImplClient* client, - Proxy* proxy, - RenderingStatsInstrumentation* rendering_stats_instrumentation) { - return make_scoped_ptr( - new LayerTreeHostImpl(settings, - client, - proxy, - rendering_stats_instrumentation)); + Proxy* proxy) { + return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); } -LayerTreeHostImpl::LayerTreeHostImpl( - const LayerTreeSettings& settings, - LayerTreeHostImplClient* client, - Proxy* proxy, - RenderingStatsInstrumentation* rendering_stats_instrumentation) +LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, + LayerTreeHostImplClient* client, + Proxy* proxy) : client_(client), proxy_(proxy), did_lock_scrolling_layer_(false), @@ -173,11 +166,14 @@ LayerTreeHostImpl::LayerTreeHostImpl( paint_time_counter_(PaintTimeCounter::Create()), memory_history_(MemoryHistory::Create()), debug_rect_history_(DebugRectHistory::Create()), + num_impl_thread_scrolls_(0), + num_main_thread_scrolls_(0), + cumulative_num_layers_drawn_(0), + cumulative_num_missing_tiles_(0), last_sent_memory_visible_bytes_(0), last_sent_memory_visible_and_nearby_bytes_(0), last_sent_memory_use_bytes_(0), - animation_registrar_(AnimationRegistrar::Create()), - rendering_stats_instrumentation_(rendering_stats_instrumentation) { + animation_registrar_(AnimationRegistrar::Create()) { DCHECK(proxy_->IsImplThread()); DidVisibilityChange(this, visible_); @@ -544,8 +540,6 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { // texture suddenly appearing in the future. bool draw_frame = true; - int layers_drawn = 0; - LayerIteratorType end = LayerIteratorType::End(frame->render_surface_layer_list); for (LayerIteratorType it = @@ -614,15 +608,14 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { &append_quads_data); } - ++layers_drawn; + ++cumulative_num_layers_drawn_; } if (append_quads_data.hadOcclusionFromOutsideTargetSurface) target_render_pass->has_occlusion_from_outside_target_surface = true; if (append_quads_data.numMissingTiles) { - rendering_stats_instrumentation_->AddMissingTiles( - append_quads_data.numMissingTiles); + cumulative_num_missing_tiles_ += append_quads_data.numMissingTiles; bool layer_has_animating_transform = it->screen_space_transform_is_animating() || it->draw_transform_is_animating(); @@ -636,8 +629,6 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { occlusion_tracker.LeaveLayer(it); } - rendering_stats_instrumentation_->AddLayersDrawn(layers_drawn); - #ifndef NDEBUG for (size_t i = 0; i < frame->render_passes.size(); ++i) { for (size_t j = 0; j < frame->render_passes[i]->quad_list.size(); ++j) @@ -953,11 +944,6 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, fps_counter_->SaveTimeStamp(frame_begin_time); - rendering_stats_instrumentation_->SetScreenFrameCount( - fps_counter_->current_frame_number()); - rendering_stats_instrumentation_->SetDroppedFrameCount( - fps_counter_->dropped_frame_count()); - if (tile_manager_) { memory_history_->SaveEntry( tile_manager_->memory_stats_from_last_assign()); @@ -1188,8 +1174,8 @@ void LayerTreeHostImpl::ActivatePendingTree() { client_->RenewTreePriority(); if (tile_manager_ && debug_state_.continuous_painting) { - RenderingStats stats = - rendering_stats_instrumentation_->GetRenderingStats(); + RenderingStats stats; + tile_manager_->GetRenderingStats(&stats); paint_time_counter_->SaveRasterizeTime( stats.totalRasterizeTimeForNowBinsOnPendingTree, active_tree_->source_frame_number()); @@ -1249,8 +1235,8 @@ bool LayerTreeHostImpl::InitializeRenderer( settings_.num_raster_threads, settings_.use_cheapness_estimator, settings_.use_color_estimator, - settings_.prediction_benchmarking, - rendering_stats_instrumentation_)); + settings_.prediction_benchmarking)); + tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); } if (output_surface->capabilities().has_parent_compositor) { @@ -1375,7 +1361,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::ScrollBegin( // thread. ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); if (status == ScrollOnMainThread) { - rendering_stats_instrumentation_->IncrementMainThreadScrolls(); + num_main_thread_scrolls_++; UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); active_tree()->DidBeginScroll(); return ScrollOnMainThread; @@ -1389,7 +1375,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::ScrollBegin( // If any layer wants to divert the scroll event to the main thread, abort. if (status == ScrollOnMainThread) { - rendering_stats_instrumentation_->IncrementMainThreadScrolls(); + num_main_thread_scrolls_++; UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); active_tree()->DidBeginScroll(); return ScrollOnMainThread; @@ -1413,7 +1399,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::ScrollBegin( potentially_scrolling_layer_impl); should_bubble_scrolls_ = (type != NonBubblingGesture); wheel_scrolling_ = (type == Wheel); - rendering_stats_instrumentation_->IncrementImplThreadScrolls(); + num_impl_thread_scrolls_++; client_->RenewTreePriority(); UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); active_tree()->DidBeginScroll(); @@ -1856,6 +1842,18 @@ int LayerTreeHostImpl::SourceAnimationFrameNumber() const { return fps_counter_->current_frame_number(); } +void LayerTreeHostImpl::CollectRenderingStats(RenderingStats* stats) const { + stats->numFramesSentToScreen = fps_counter_->current_frame_number(); + stats->droppedFrameCount = fps_counter_->dropped_frame_count(); + stats->numImplThreadScrolls = num_impl_thread_scrolls_; + stats->numMainThreadScrolls = num_main_thread_scrolls_; + stats->numLayersDrawn = cumulative_num_layers_drawn_; + stats->numMissingTiles = cumulative_num_missing_tiles_; + + if (tile_manager_) + tile_manager_->GetRenderingStats(stats); +} + void LayerTreeHostImpl::SendManagedMemoryStats( size_t memory_visible_bytes, size_t memory_visible_and_nearby_bytes, @@ -2010,6 +2008,9 @@ void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { paint_time_counter_->ClearHistory(); debug_state_ = debug_state; + + if (tile_manager_) + tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); } void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 2f52f4a..b8c217b 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -35,11 +35,11 @@ class LayerTreeImpl; class PageScaleAnimation; class PaintTimeCounter; class MemoryHistory; -class RenderingStatsInstrumentation; class RenderPassDrawQuad; class ResourceProvider; class TopControlsManager; struct RendererCapabilities; +struct RenderingStats; // LayerTreeHost->Proxy callback interface. class LayerTreeHostImplClient { @@ -81,8 +81,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, static scoped_ptr<LayerTreeHostImpl> Create( const LayerTreeSettings& settings, LayerTreeHostImplClient* client, - Proxy* proxy, - RenderingStatsInstrumentation* rendering_stats_instrumentation); + Proxy* proxy); virtual ~LayerTreeHostImpl(); // InputHandlerClient implementation @@ -244,6 +243,8 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, return !animation_registrar_->active_animation_controllers().empty(); } + void CollectRenderingStats(RenderingStats* stats) const; + void SendManagedMemoryStats( size_t memory_visible_bytes, size_t memory_visible_and_nearby_bytes, @@ -333,11 +334,9 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, bool page_scale_animation_active() const { return !!page_scale_animation_; } protected: - LayerTreeHostImpl( - const LayerTreeSettings& settings, - LayerTreeHostImplClient* client, - Proxy* proxy, - RenderingStatsInstrumentation* rendering_stats_instrumentation); + LayerTreeHostImpl(const LayerTreeSettings& settings, + LayerTreeHostImplClient* client, + Proxy* proxy); void ActivatePendingTree(); // Virtual for testing. @@ -454,8 +453,6 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, scoped_ptr<AnimationRegistrar> animation_registrar_; - RenderingStatsInstrumentation* rendering_stats_instrumentation_; - DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); }; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index f4a4002..5a88112 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -32,7 +32,6 @@ #include "cc/test/animation_test_common.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/fake_video_frame_provider.h" #include "cc/test/fake_web_scrollbar_theme_geometry.h" #include "cc/test/geometry_test_utils.h" @@ -79,7 +78,7 @@ public: LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); - m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); m_hostImpl->InitializeRenderer(createOutputSurface()); m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); } @@ -113,7 +112,7 @@ public: settings.minimum_occlusion_tracking_size = gfx::Size(); settings.partial_swap_enabled = partialSwap; - m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); m_hostImpl->InitializeRenderer(outputSurface.Pass()); m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); @@ -225,7 +224,6 @@ protected: DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; scoped_ptr<LayerTreeHostImpl> m_hostImpl; - FakeRenderingStatsInstrumentation m_statsInstrumentation; bool m_onCanDrawStateChangedCalled; bool m_hasPendingTree; bool m_didRequestCommit; @@ -386,7 +384,7 @@ TEST_F(LayerTreeHostImplTest, scrollWithoutRootLayer) TEST_F(LayerTreeHostImplTest, scrollWithoutRenderer) { LayerTreeSettings settings; - m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Initialization will fail here. m_hostImpl->InitializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TestWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>()); @@ -1137,7 +1135,7 @@ TEST_F(LayerTreeHostImplTest, scrollNonScrollableRootWithTopControls) settings.calculate_top_controls_position = true; settings.top_controls_height = 50; - m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + m_hostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); m_hostImpl->InitializeRenderer(createOutputSurface()); m_hostImpl->SetViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); @@ -2187,7 +2185,7 @@ TEST_F(LayerTreeHostImplTest, partialSwapReceivesDamageRect) // that we can force partial swap enabled. LayerTreeSettings settings; settings.partial_swap_enabled = true; - scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); layerTreeHostImpl->InitializeRenderer(outputSurface.Pass()); layerTreeHostImpl->SetViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)); @@ -2479,13 +2477,13 @@ public: } }; -static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy, RenderingStatsInstrumentation* statsInstrumentation) +static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); LayerTreeSettings settings; settings.partial_swap_enabled = partialSwap; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, client, proxy, statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, client, proxy); myHostImpl->InitializeRenderer(outputSurface.Pass()); myHostImpl->SetViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); @@ -2549,7 +2547,7 @@ static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) { - scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy); { LayerTreeHostImpl::FrameData frame; @@ -2569,7 +2567,7 @@ TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) { - scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this, &m_proxy); { LayerTreeHostImpl::FrameData frame; @@ -2784,7 +2782,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusion) LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Layers are structure as follows: // @@ -2899,7 +2897,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Layers are structure as follows: // @@ -3014,7 +3012,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Layers are structured as follows: // @@ -3101,7 +3099,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) { LayerTreeSettings settings; settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Layers are structured as follows: // @@ -3176,7 +3174,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) settings.minimum_occlusion_tracking_size = gfx::Size(); settings.partial_swap_enabled = true; settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); // Layers are structure as follows: // @@ -3288,7 +3286,7 @@ TEST_F(LayerTreeHostImplTest, textureCachingWithScissor) LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); /* Layers are created as follows: @@ -3395,7 +3393,7 @@ TEST_F(LayerTreeHostImplTest, surfaceTextureCaching) settings.minimum_occlusion_tracking_size = gfx::Size(); settings.partial_swap_enabled = true; settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); LayerImpl* rootPtr; LayerImpl* intermediateLayerPtr; @@ -3554,7 +3552,7 @@ TEST_F(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); settings.cache_render_pass_contents = true; - scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy, &m_statsInstrumentation); + scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::Create(settings, this, &m_proxy); LayerImpl* rootPtr; LayerImpl* intermediateLayerPtr; diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index f0fece4..703c07a 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -22,6 +22,7 @@ class Vector2d; namespace cc { class Thread; +struct RenderingStats; struct RendererCapabilities; // Abstract class responsible for proxying commands from the main-thread side of @@ -77,6 +78,8 @@ class CC_EXPORT Proxy { // Returns false if the renderer couldn't be reinitialized. virtual bool RecreateOutputSurface() = 0; + virtual void CollectRenderingStats(RenderingStats* stats) = 0; + virtual const RendererCapabilities& GetRendererCapabilities() const = 0; virtual void SetNeedsAnimate() = 0; diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index da2046a..71c4652 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -171,6 +171,12 @@ bool SingleThreadProxy::RecreateOutputSurface() { return initialized; } +void SingleThreadProxy::CollectRenderingStats(RenderingStats* stats) { + stats->totalCommitTime = total_commit_time_; + stats->totalCommitCount = total_commit_count_; + layer_tree_host_impl_->CollectRenderingStats(stats); +} + const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { DCHECK(renderer_initialized_); // Note: this gets called during the commit by the "impl" thread. @@ -189,10 +195,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { DebugScopedSetMainThreadBlocked mainThreadBlocked(this); DebugScopedSetImplThread impl(this); - RenderingStatsInstrumentation* stats_instrumentation = - layer_tree_host_->rendering_stats_instrumentation(); - base::TimeTicks startTime = stats_instrumentation->StartRecording(); - + base::TimeTicks startTime = base::TimeTicks::HighResNow(); layer_tree_host_impl_->BeginCommit(); layer_tree_host_->contents_texture_manager()-> @@ -219,8 +222,9 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { DCHECK(!scrollInfo->scrolls.size()); #endif - base::TimeDelta duration = stats_instrumentation->EndRecording(startTime); - stats_instrumentation->AddCommit(duration); + base::TimeTicks endTime = base::TimeTicks::HighResNow(); + total_commit_time_ += endTime - startTime; + total_commit_count_++; } layer_tree_host_->CommitComplete(); next_frame_is_newly_committed_frame_ = true; diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index ea6b549..f5917b2 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -35,6 +35,7 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { virtual void SetVisible(bool visible) OVERRIDE; virtual bool InitializeRenderer() OVERRIDE; virtual bool RecreateOutputSurface() OVERRIDE; + virtual void CollectRenderingStats(RenderingStats* stats) OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsCommit() OVERRIDE; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index ba621e2..45835e8 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -60,6 +60,7 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layer_tree_host, next_frame_is_newly_committed_frame_on_impl_thread_(false), render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), inside_draw_(false), + total_commit_count_(0), defer_commits_(false), renew_tree_priority_on_impl_thread_pending_(false) { TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); @@ -277,6 +278,22 @@ bool ThreadProxy::RecreateOutputSurface() { return recreate_succeeded; } +void ThreadProxy::CollectRenderingStats(RenderingStats* stats) { + DCHECK(IsMainThread()); + + DebugScopedSetMainThreadBlocked main_thread_blocked(this); + CompletionEvent completion; + Proxy::ImplThread()->PostTask( + base::Bind(&ThreadProxy::RenderingStatsOnImplThread, + impl_thread_weak_ptr_, + &completion, + stats)); + stats->totalCommitTime = total_commit_time_; + stats->totalCommitCount = total_commit_count_; + + completion.Wait(); +} + const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { DCHECK(renderer_initialized_); return renderer_capabilities_main_thread_copy_; @@ -725,10 +742,7 @@ void ThreadProxy::BeginFrame( DebugScopedSetMainThreadBlocked main_thread_blocked(this); - RenderingStatsInstrumentation* stats_instrumentation = - layer_tree_host_->rendering_stats_instrumentation(); - base::TimeTicks start_time = stats_instrumentation->StartRecording(); - + base::TimeTicks start_time = base::TimeTicks::HighResNow(); CompletionEvent completion; Proxy::ImplThread()->PostTask( base::Bind(&ThreadProxy::BeginFrameCompleteOnImplThread, @@ -738,8 +752,9 @@ void ThreadProxy::BeginFrame( offscreen_context_provider)); completion.Wait(); - base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); - stats_instrumentation->AddCommit(duration); + base::TimeTicks end_time = base::TimeTicks::HighResNow(); + total_commit_time_ += end_time - start_time; + total_commit_count_++; } layer_tree_host_->CommitComplete(); @@ -1169,6 +1184,13 @@ void ThreadProxy::RecreateOutputSurfaceOnImplThread( completion->Signal(); } +void ThreadProxy::RenderingStatsOnImplThread(CompletionEvent* completion, + RenderingStats* stats) { + DCHECK(IsImplThread()); + layer_tree_host_impl_->CollectRenderingStats(stats); + completion->Signal(); +} + ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() : memory_allocation_limit_bytes(0) {} diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 5a235e3..d11b0a7 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -48,6 +48,7 @@ class ThreadProxy : public Proxy, virtual void SetVisible(bool visible) OVERRIDE; virtual bool InitializeRenderer() OVERRIDE; virtual bool RecreateOutputSurface() OVERRIDE; + virtual void CollectRenderingStats(RenderingStats* stats) OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsCommit() OVERRIDE; @@ -173,6 +174,8 @@ class ThreadProxy : public Proxy, scoped_refptr<cc::ContextProvider> offscreen_context_provider, bool* recreate_succeeded, RendererCapabilities* capabilities); + void RenderingStatsOnImplThread(CompletionEvent* completion, + RenderingStats* stats); ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( bool forced_draw); void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); @@ -251,6 +254,9 @@ class ThreadProxy : public Proxy, bool inside_draw_; + base::TimeDelta total_commit_time_; + size_t total_commit_count_; + bool defer_commits_; scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc index ee66e956..3b1632c 100644 --- a/cc/trees/tree_synchronizer_unittest.cc +++ b/cc/trees/tree_synchronizer_unittest.cc @@ -484,12 +484,8 @@ TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { LayerTreeSettings settings; FakeProxy proxy(scoped_ptr<Thread>(NULL)); DebugScopedSetImplThread impl(&proxy); - FakeRenderingStatsInstrumentation stats_instrumentation; scoped_ptr<LayerTreeHostImpl> host_impl = - LayerTreeHostImpl::Create(settings, - NULL, - &proxy, - &stats_instrumentation); + LayerTreeHostImpl::Create(settings, NULL, &proxy); scoped_refptr<Layer> layer_tree_root = Layer::Create(); diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 5444af1..a313bf1 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -163,6 +163,8 @@ class CONTENT_EXPORT RenderWidget // Fills in a WebRenderingStatsImpl struct containing information about // rendering, e.g. count of frames rendered, time spent painting. + // This call is relatively expensive in threaded compositing mode, + // as it blocks on the compositor thread. void GetRenderingStats(WebKit::WebRenderingStatsImpl&) const; // Fills in a GpuRenderingStats struct containing information about |