diff options
author | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 18:51:24 +0000 |
---|---|---|
committer | ernstm@chromium.org <ernstm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 18:51:24 +0000 |
commit | 376041ead822a40985f49f366941b19a13f6ac68 (patch) | |
tree | 132dab0fadcbd6506ea793fbf1e426923e827437 | |
parent | 151d950d12e893e516f79ad93daf20a124f00083 (diff) | |
download | chromium_src-376041ead822a40985f49f366941b19a13f6ac68.zip chromium_src-376041ead822a40985f49f366941b19a13f6ac68.tar.gz chromium_src-376041ead822a40985f49f366941b19a13f6ac68.tar.bz2 |
cc: RenderingStats overhaul
- Split RenderingStats into MainThreadRenderingStats and
ImplThreadRenderingStats
- Support accumulated stats and per-frame stats in RenderingStatsInstrumentation
- Dump MainThreadRenderingStats into trace event from
ThreadProxy::BeginFrameOnMainThread
- Dump ImplThreadRenderingStats into trace event from
LayerTreeHostImpl::DrawLayers
- Made naming of RenderingStats members consistent
R=nduca@chromium.org,jamesr@chromium.org
BUG=266101,264308
Review URL: https://chromiumcodereview.appspot.com/23088002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217824 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/debug/rendering_stats.cc | 219 | ||||
-rw-r--r-- | cc/debug/rendering_stats.h | 106 | ||||
-rw-r--r-- | cc/debug/rendering_stats_instrumentation.cc | 71 | ||||
-rw-r--r-- | cc/debug/rendering_stats_instrumentation.h | 26 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 21 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 1 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 7 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 26 |
8 files changed, 317 insertions, 160 deletions
diff --git a/cc/debug/rendering_stats.cc b/cc/debug/rendering_stats.cc index 12c5453..e8a758c 100644 --- a/cc/debug/rendering_stats.cc +++ b/cc/debug/rendering_stats.cc @@ -2,98 +2,185 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/values.h" #include "cc/debug/rendering_stats.h" namespace cc { -RenderingStats::RenderingStats() - : animation_frame_count(0), - screen_frame_count(0), +MainThreadRenderingStats::MainThreadRenderingStats() + : animation_frame_count(0), + screen_frame_count(0), + commit_count(0), + painted_pixel_count(0), + recorded_pixel_count(0), + image_gathering_count(0) {} + +ImplThreadRenderingStats::ImplThreadRenderingStats() + : screen_frame_count(0), dropped_frame_count(0), - total_commit_count(0), - total_pixels_painted(0), - total_pixels_recorded(0), - total_pixels_rasterized(0), - num_impl_thread_scrolls(0), - num_main_thread_scrolls(0), - num_layers_drawn(0), - num_missing_tiles(0), - total_deferred_image_decode_count(0), - total_deferred_image_cache_hit_count(0), - total_image_gathering_count(0), - total_tiles_analyzed(0), - solid_color_tiles_analyzed(0) {} + rasterized_pixel_count(0), + impl_thread_scroll_count(0), + main_thread_scroll_count(0), + drawn_layer_count(0), + missing_tile_count(0), + deferred_image_decode_count(0), + deferred_image_cache_hit_count(0), + tile_analysis_count(0), + solid_color_tile_analysis_count(0) {} -void RenderingStats::EnumerateFields(Enumerator* enumerator) const { +void MainThreadRenderingStats::EnumerateFields( + RenderingStatsEnumerator* enumerator) const { enumerator->AddInt64("numAnimationFrames", animation_frame_count); enumerator->AddInt64("numFramesSentToScreen", screen_frame_count); - enumerator->AddInt64("droppedFrameCount", dropped_frame_count); enumerator->AddDouble("totalPaintTimeInSeconds", - total_paint_time.InSecondsF()); + paint_time.InSecondsF()); enumerator->AddDouble("totalRecordTimeInSeconds", - total_record_time.InSecondsF()); + record_time.InSecondsF()); + enumerator->AddDouble("totalCommitTimeInSeconds", + commit_time.InSecondsF()); + enumerator->AddInt64("totalCommitCount", commit_count); + enumerator->AddInt64("totalPixelsPainted", painted_pixel_count); + enumerator->AddInt64("totalPixelsRecorded", recorded_pixel_count); + enumerator->AddInt64("totalImageGatheringCount", + image_gathering_count); + enumerator->AddDouble("totalImageGatheringTimeInSeconds", + image_gathering_time.InSecondsF()); +} + +void ImplThreadRenderingStats::EnumerateFields( + RenderingStatsEnumerator* enumerator) const { + enumerator->AddInt64("numFramesSentToScreen", screen_frame_count); + enumerator->AddInt64("droppedFrameCount", dropped_frame_count); enumerator->AddDouble("totalRasterizeTimeInSeconds", - total_rasterize_time.InSecondsF()); + rasterize_time.InSecondsF()); enumerator->AddDouble( "totalRasterizeTimeForNowBinsOnPendingTree", - total_rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); - enumerator->AddDouble("totalCommitTimeInSeconds", - total_commit_time.InSecondsF()); + rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); enumerator->AddDouble("bestRasterizeTimeInSeconds", best_rasterize_time.InSecondsF()); - enumerator->AddInt64("totalCommitCount", total_commit_count); - enumerator->AddInt64("totalPixelsPainted", total_pixels_painted); - enumerator->AddInt64("totalPixelsRecorded", total_pixels_recorded); - enumerator->AddInt64("totalPixelsRasterized", total_pixels_rasterized); - enumerator->AddInt64("numImplThreadScrolls", num_impl_thread_scrolls); - enumerator->AddInt64("numMainThreadScrolls", num_main_thread_scrolls); - enumerator->AddInt64("numLayersDrawn", num_layers_drawn); - enumerator->AddInt64("numMissingTiles", num_missing_tiles); + enumerator->AddInt64("totalPixelsRasterized", rasterized_pixel_count); + enumerator->AddInt64("numImplThreadScrolls", impl_thread_scroll_count); + enumerator->AddInt64("numMainThreadScrolls", main_thread_scroll_count); + enumerator->AddInt64("numLayersDrawn", drawn_layer_count); + enumerator->AddInt64("numMissingTiles", missing_tile_count); enumerator->AddInt64("totalDeferredImageDecodeCount", - total_deferred_image_decode_count); - enumerator->AddInt64("totalTilesAnalyzed", total_tiles_analyzed); + deferred_image_decode_count); + enumerator->AddInt64("totalTilesAnalyzed", tile_analysis_count); enumerator->AddInt64("solidColorTilesAnalyzed", - solid_color_tiles_analyzed); + solid_color_tile_analysis_count); enumerator->AddInt64("totalDeferredImageCacheHitCount", - total_deferred_image_cache_hit_count); - enumerator->AddInt64("totalImageGatheringCount", - total_image_gathering_count); + deferred_image_cache_hit_count); enumerator->AddDouble("totalDeferredImageDecodeTimeInSeconds", - total_deferred_image_decode_time.InSecondsF()); - enumerator->AddDouble("totalImageGatheringTimeInSeconds", - total_image_gathering_time.InSecondsF()); + deferred_image_decode_time.InSecondsF()); enumerator->AddDouble("totalTileAnalysisTimeInSeconds", - total_tile_analysis_time.InSecondsF()); + tile_analysis_time.InSecondsF()); } -void RenderingStats::Add(const RenderingStats& other) { +void RenderingStats::EnumerateFields(Enumerator* enumerator) const { + main_stats.EnumerateFields(enumerator); + impl_stats.EnumerateFields(enumerator); +} + +scoped_ptr<base::debug::ConvertableToTraceFormat> +MainThreadRenderingStats::AsTraceableData() const { + scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); + record_data->SetInteger("animation_frame_count", + animation_frame_count); + record_data->SetInteger("screen_frame_count", + screen_frame_count); + record_data->SetDouble("paint_time", + paint_time.InSecondsF()); + record_data->SetDouble("record_time", + record_time.InSecondsF()); + record_data->SetDouble("commit_time", + commit_time.InSecondsF()); + record_data->SetInteger("commit_count", + commit_count); + record_data->SetInteger("painted_pixel_count", + painted_pixel_count); + record_data->SetInteger("recorded_pixel_count", + recorded_pixel_count); + record_data->SetInteger("image_gathering_count", + image_gathering_count); + return TracedValue::FromValue(record_data.release()); +} + +scoped_ptr<base::debug::ConvertableToTraceFormat> +ImplThreadRenderingStats::AsTraceableData() const { + scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); + record_data->SetInteger("screen_frame_count", + screen_frame_count); + record_data->SetInteger("dropped_frame_count", + dropped_frame_count); + record_data->SetDouble("rasterize_time", + rasterize_time.InSecondsF()); + record_data->SetDouble( + "rasterize_time_for_now_bins_on_pending_tree", + rasterize_time_for_now_bins_on_pending_tree.InSecondsF()); + record_data->SetDouble("best_rasterize_time", + best_rasterize_time.InSecondsF()); + record_data->SetInteger("rasterized_pixel_count", + rasterized_pixel_count); + record_data->SetInteger("impl_thread_scroll_count", + impl_thread_scroll_count); + record_data->SetInteger("main_thread_scroll_count", + main_thread_scroll_count); + record_data->SetInteger("drawn_layer_count", + drawn_layer_count); + record_data->SetInteger("missing_tile_count", + missing_tile_count); + record_data->SetInteger("deferred_image_decode_count", + deferred_image_decode_count); + record_data->SetInteger("deferred_image_cache_hit_count", + deferred_image_cache_hit_count); + record_data->SetInteger("tile_analysis_count", + tile_analysis_count); + record_data->SetInteger("solid_color_tile_analysis_count", + solid_color_tile_analysis_count); + record_data->SetDouble("deferred_image_decode_time", + deferred_image_decode_time.InSecondsF()); + record_data->SetDouble("tile_analysis_time", + tile_analysis_time.InSecondsF()); + return TracedValue::FromValue(record_data.release()); +} + + +void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { animation_frame_count += other.animation_frame_count; screen_frame_count += other.screen_frame_count; + paint_time += other.paint_time; + record_time += other.record_time; + commit_time += other.commit_time; + commit_count += other.commit_count; + painted_pixel_count += other.painted_pixel_count; + recorded_pixel_count += other.recorded_pixel_count; + image_gathering_count += other.image_gathering_count; + image_gathering_time += other.image_gathering_time; +} + +void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { + screen_frame_count += other.screen_frame_count; dropped_frame_count += other.dropped_frame_count; - total_paint_time += other.total_paint_time; - total_record_time += other.total_record_time; - total_rasterize_time += other.total_rasterize_time; - total_rasterize_time_for_now_bins_on_pending_tree += - other.total_rasterize_time_for_now_bins_on_pending_tree; - total_commit_time += other.total_commit_time; + rasterize_time += other.rasterize_time; + rasterize_time_for_now_bins_on_pending_tree += + other.rasterize_time_for_now_bins_on_pending_tree; best_rasterize_time += other.best_rasterize_time; - total_commit_count += other.total_commit_count; - total_pixels_painted += other.total_pixels_painted; - total_pixels_recorded += other.total_pixels_recorded; - total_pixels_rasterized += other.total_pixels_rasterized; - num_impl_thread_scrolls += other.num_impl_thread_scrolls; - num_main_thread_scrolls += other.num_main_thread_scrolls; - num_layers_drawn += other.num_layers_drawn; - num_missing_tiles += other.num_missing_tiles; - total_deferred_image_decode_count += other.total_deferred_image_decode_count; - total_deferred_image_cache_hit_count += - other.total_deferred_image_cache_hit_count; - total_image_gathering_count += other.total_image_gathering_count; - total_deferred_image_decode_time += other.total_deferred_image_decode_time; - total_image_gathering_time += other.total_image_gathering_time; - total_tiles_analyzed += other.total_tiles_analyzed; - solid_color_tiles_analyzed += other.solid_color_tiles_analyzed; - total_tile_analysis_time += other.total_tile_analysis_time; + rasterized_pixel_count += other.rasterized_pixel_count; + impl_thread_scroll_count += other.impl_thread_scroll_count; + main_thread_scroll_count += other.main_thread_scroll_count; + drawn_layer_count += other.drawn_layer_count; + missing_tile_count += other.missing_tile_count; + deferred_image_decode_count += other.deferred_image_decode_count; + deferred_image_cache_hit_count += other.deferred_image_cache_hit_count; + deferred_image_decode_time += other.deferred_image_decode_time; + tile_analysis_count += other.tile_analysis_count; + solid_color_tile_analysis_count += other.solid_color_tile_analysis_count; + tile_analysis_time += other.tile_analysis_time; +} + +void RenderingStats::Add(const RenderingStats& other) { + main_stats.Add(other.main_stats); + impl_stats.Add(other.impl_stats); } } // namespace cc diff --git a/cc/debug/rendering_stats.h b/cc/debug/rendering_stats.h index eb01a57..8b9455d 100644 --- a/cc/debug/rendering_stats.h +++ b/cc/debug/rendering_stats.h @@ -8,55 +8,79 @@ #include "base/basictypes.h" #include "base/time/time.h" #include "cc/base/cc_export.h" +#include "cc/debug/traced_value.h" namespace cc { -struct CC_EXPORT RenderingStats { +// In conjunction with EnumerateFields, this allows the embedder to +// enumerate the values in this structure without +// having to embed references to its specific member variables. This +// simplifies the addition of new fields to this type. +class RenderingStatsEnumerator { + public: + virtual void AddInt64(const char* name, int64 value) = 0; + virtual void AddDouble(const char* name, double value) = 0; + virtual void AddInt(const char* name, int value) = 0; + virtual void AddTimeDeltaInSecondsF(const char* name, + const base::TimeDelta& value) = 0; + + protected: + virtual ~RenderingStatsEnumerator() {} +}; + +struct CC_EXPORT MainThreadRenderingStats { + // Note: when adding new members, please remember to update EnumerateFields + // and Add in rendering_stats.cc. + int64 animation_frame_count; int64 screen_frame_count; - int64 dropped_frame_count; - base::TimeDelta total_paint_time; - base::TimeDelta total_record_time; - base::TimeDelta total_rasterize_time; - base::TimeDelta total_rasterize_time_for_now_bins_on_pending_tree; - base::TimeDelta total_commit_time; - base::TimeDelta best_rasterize_time; - int64 total_commit_count; - int64 total_pixels_painted; - int64 total_pixels_recorded; - int64 total_pixels_rasterized; - int64 num_impl_thread_scrolls; - int64 num_main_thread_scrolls; - int64 num_layers_drawn; - int64 num_missing_tiles; - int64 total_deferred_image_decode_count; - int64 total_deferred_image_cache_hit_count; - int64 total_image_gathering_count; - int64 total_tiles_analyzed; - int64 solid_color_tiles_analyzed; - base::TimeDelta total_deferred_image_decode_time; - base::TimeDelta total_image_gathering_time; - base::TimeDelta total_tile_analysis_time; + base::TimeDelta paint_time; + base::TimeDelta record_time; + base::TimeDelta commit_time; + int64 commit_count; + int64 painted_pixel_count; + int64 recorded_pixel_count; + int64 image_gathering_count; + base::TimeDelta image_gathering_time; + + MainThreadRenderingStats(); + void EnumerateFields(RenderingStatsEnumerator* enumerator) const; + scoped_ptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; + void Add(const MainThreadRenderingStats& other); +}; + +struct CC_EXPORT ImplThreadRenderingStats { // Note: when adding new members, please remember to update EnumerateFields // and Add in rendering_stats.cc. - RenderingStats(); - - // In conjunction with EnumerateFields, this allows the embedder to - // enumerate the values in this structure without - // having to embed references to its specific member variables. This - // simplifies the addition of new fields to this type. - class Enumerator { - public: - virtual void AddInt64(const char* name, int64 value) = 0; - virtual void AddDouble(const char* name, double value) = 0; - virtual void AddInt(const char* name, int value) = 0; - virtual void AddTimeDeltaInSecondsF(const char* name, - const base::TimeDelta& value) = 0; - - protected: - virtual ~Enumerator() {} - }; + int64 screen_frame_count; + int64 dropped_frame_count; + base::TimeDelta rasterize_time; + base::TimeDelta rasterize_time_for_now_bins_on_pending_tree; + base::TimeDelta best_rasterize_time; + int64 rasterized_pixel_count; + int64 impl_thread_scroll_count; + int64 main_thread_scroll_count; + int64 drawn_layer_count; + int64 missing_tile_count; + int64 deferred_image_decode_count; + int64 deferred_image_cache_hit_count; + int64 tile_analysis_count; + int64 solid_color_tile_analysis_count; + base::TimeDelta deferred_image_decode_time; + base::TimeDelta tile_analysis_time; + + ImplThreadRenderingStats(); + void EnumerateFields(RenderingStatsEnumerator* enumerator) const; + scoped_ptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; + void Add(const ImplThreadRenderingStats& other); +}; + +struct CC_EXPORT RenderingStats { + typedef RenderingStatsEnumerator Enumerator; + + MainThreadRenderingStats main_stats; + ImplThreadRenderingStats impl_stats; // Outputs the fields in this structure to the provided enumerator. void EnumerateFields(Enumerator* enumerator) const; diff --git a/cc/debug/rendering_stats_instrumentation.cc b/cc/debug/rendering_stats_instrumentation.cc index b3886af..3c164f9 100644 --- a/cc/debug/rendering_stats_instrumentation.cc +++ b/cc/debug/rendering_stats_instrumentation.cc @@ -20,7 +20,22 @@ RenderingStatsInstrumentation::~RenderingStatsInstrumentation() {} RenderingStats RenderingStatsInstrumentation::GetRenderingStats() { base::AutoLock scoped_lock(lock_); - return rendering_stats_; + RenderingStats rendering_stats; + rendering_stats.main_stats = main_stats_accu_; + rendering_stats.main_stats.Add(main_stats_); + rendering_stats.impl_stats = impl_stats_accu_; + rendering_stats.impl_stats.Add(impl_stats_); + return rendering_stats; +} + +void RenderingStatsInstrumentation::AccumulateAndClearMainThreadStats() { + main_stats_accu_.Add(main_stats_); + main_stats_ = MainThreadRenderingStats(); +} + +void RenderingStatsInstrumentation::AccumulateAndClearImplThreadStats() { + impl_stats_accu_.Add(impl_stats_); + impl_stats_ = ImplThreadRenderingStats(); } base::TimeTicks RenderingStatsInstrumentation::StartRecording() const { @@ -41,23 +56,23 @@ void RenderingStatsInstrumentation::IncrementAnimationFrameCount() { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.animation_frame_count++; + main_stats_.animation_frame_count++; } -void RenderingStatsInstrumentation::SetScreenFrameCount(int64 count) { +void RenderingStatsInstrumentation::IncrementScreenFrameCount(int64 count) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - rendering_stats_.screen_frame_count = count; + impl_stats_.screen_frame_count += count; } -void RenderingStatsInstrumentation::SetDroppedFrameCount(int64 count) { +void RenderingStatsInstrumentation::IncrementDroppedFrameCount(int64 count) { if (!record_rendering_stats_) return; base::AutoLock scoped_lock(lock_); - rendering_stats_.dropped_frame_count = count; + impl_stats_.dropped_frame_count += count; } void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { @@ -65,8 +80,8 @@ void RenderingStatsInstrumentation::AddCommit(base::TimeDelta duration) { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_commit_time += duration; - rendering_stats_.total_commit_count++; + main_stats_.commit_time += duration; + main_stats_.commit_count++; } void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, @@ -75,8 +90,8 @@ void RenderingStatsInstrumentation::AddPaint(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_paint_time += duration; - rendering_stats_.total_pixels_painted += pixels; + main_stats_.paint_time += duration; + main_stats_.painted_pixel_count += pixels; } void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, @@ -85,8 +100,8 @@ void RenderingStatsInstrumentation::AddRecord(base::TimeDelta duration, return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_record_time += duration; - rendering_stats_.total_pixels_recorded += pixels; + main_stats_.record_time += duration; + main_stats_.recorded_pixel_count += pixels; } void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration, @@ -97,12 +112,12 @@ void RenderingStatsInstrumentation::AddRaster(base::TimeDelta total_duration, return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_rasterize_time += total_duration; - rendering_stats_.best_rasterize_time += best_duration; - rendering_stats_.total_pixels_rasterized += pixels; + impl_stats_.rasterize_time += total_duration; + impl_stats_.best_rasterize_time += best_duration; + impl_stats_.rasterized_pixel_count += pixels; if (is_in_pending_tree_now_bin) { - rendering_stats_.total_rasterize_time_for_now_bins_on_pending_tree += + impl_stats_.rasterize_time_for_now_bins_on_pending_tree += total_duration; } } @@ -112,7 +127,7 @@ void RenderingStatsInstrumentation::IncrementImplThreadScrolls() { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.num_impl_thread_scrolls++; + impl_stats_.impl_thread_scroll_count++; } void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { @@ -120,7 +135,7 @@ void RenderingStatsInstrumentation::IncrementMainThreadScrolls() { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.num_main_thread_scrolls++; + impl_stats_.main_thread_scroll_count++; } void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { @@ -128,7 +143,7 @@ void RenderingStatsInstrumentation::AddLayersDrawn(int64 amount) { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.num_layers_drawn += amount; + impl_stats_.drawn_layer_count += amount; } void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { @@ -136,7 +151,7 @@ void RenderingStatsInstrumentation::AddMissingTiles(int64 amount) { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.num_missing_tiles += amount; + impl_stats_.missing_tile_count += amount; } void RenderingStatsInstrumentation::AddDeferredImageDecode( @@ -145,8 +160,8 @@ void RenderingStatsInstrumentation::AddDeferredImageDecode( return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_deferred_image_decode_time += duration; - rendering_stats_.total_deferred_image_decode_count++; + impl_stats_.deferred_image_decode_time += duration; + impl_stats_.deferred_image_decode_count++; } void RenderingStatsInstrumentation::AddImageGathering( @@ -155,8 +170,8 @@ void RenderingStatsInstrumentation::AddImageGathering( return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_image_gathering_time += duration; - rendering_stats_.total_image_gathering_count++; + main_stats_.image_gathering_time += duration; + main_stats_.image_gathering_count++; } void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { @@ -164,7 +179,7 @@ void RenderingStatsInstrumentation::IncrementDeferredImageCacheHitCount() { return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_deferred_image_cache_hit_count++; + impl_stats_.deferred_image_cache_hit_count++; } void RenderingStatsInstrumentation::AddAnalysisResult( @@ -174,10 +189,10 @@ void RenderingStatsInstrumentation::AddAnalysisResult( return; base::AutoLock scoped_lock(lock_); - rendering_stats_.total_tiles_analyzed++; - rendering_stats_.total_tile_analysis_time += duration; + impl_stats_.tile_analysis_count++; + impl_stats_.tile_analysis_time += duration; if (is_solid_color) - rendering_stats_.solid_color_tiles_analyzed++; + impl_stats_.solid_color_tile_analysis_count++; } } // namespace cc diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h index 6f7515a..a7f9b308 100644 --- a/cc/debug/rendering_stats_instrumentation.h +++ b/cc/debug/rendering_stats_instrumentation.h @@ -18,8 +18,24 @@ class CC_EXPORT RenderingStatsInstrumentation { static scoped_ptr<RenderingStatsInstrumentation> Create(); virtual ~RenderingStatsInstrumentation(); + // Return current main thread rendering stats. + MainThreadRenderingStats GetMainThreadRenderingStats() { + return main_stats_; + } + // Return current impl thread rendering stats. + ImplThreadRenderingStats GetImplThreadRenderingStats() { + return impl_stats_; + } + // Return the accumulated, combined rendering stats. RenderingStats GetRenderingStats(); + // Add current main thread rendering stats to accumulator and + // clear current stats + void AccumulateAndClearMainThreadStats(); + // Add current impl thread rendering stats to accumulator and + // clear current stats + void AccumulateAndClearImplThreadStats(); + // 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. @@ -33,8 +49,8 @@ class CC_EXPORT RenderingStatsInstrumentation { base::TimeDelta EndRecording(base::TimeTicks start_time) const; void IncrementAnimationFrameCount(); - void SetScreenFrameCount(int64 count); - void SetDroppedFrameCount(int64 count); + void IncrementScreenFrameCount(int64 count); + void IncrementDroppedFrameCount(int64 count); void AddCommit(base::TimeDelta duration); void AddPaint(base::TimeDelta duration, int64 pixels); @@ -61,7 +77,11 @@ class CC_EXPORT RenderingStatsInstrumentation { RenderingStatsInstrumentation(); private: - RenderingStats rendering_stats_; + MainThreadRenderingStats main_stats_; + MainThreadRenderingStats main_stats_accu_; + ImplThreadRenderingStats impl_stats_; + ImplThreadRenderingStats impl_stats_accu_; + bool record_rendering_stats_; base::Lock lock_; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 720febd..5fcc2b0 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1226,24 +1226,25 @@ static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) { void LayerTreeHostImpl::DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time) { - TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); + TRACE_EVENT_BEGIN0("cc", "LayerTreeHostImpl::DrawLayers"); DCHECK(CanDraw()); if (frame->has_no_damage) { TRACE_EVENT0("cc", "EarlyOut_NoDamage"); DCHECK(!output_surface_->capabilities() .draw_and_swap_full_viewport_every_frame); + TRACE_EVENT_END0("cc", "LayerTreeHostImpl::DrawLayers"); return; } DCHECK(!frame->render_passes.empty()); + int old_dropped_frame_count = fps_counter_->dropped_frame_count(); fps_counter_->SaveTimeStamp(frame_begin_time); - rendering_stats_instrumentation_->SetScreenFrameCount( - fps_counter_->current_frame_number()); - rendering_stats_instrumentation_->SetDroppedFrameCount( - fps_counter_->dropped_frame_count()); + rendering_stats_instrumentation_->IncrementScreenFrameCount(1); + rendering_stats_instrumentation_->IncrementDroppedFrameCount( + fps_counter_->dropped_frame_count() - old_dropped_frame_count); if (tile_manager_) { memory_history_->SaveEntry( @@ -1262,7 +1263,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, if (!settings_.impl_side_painting && debug_state_.continuous_painting) { const RenderingStats& stats = rendering_stats_instrumentation_->GetRenderingStats(); - paint_time_counter_->SavePaintTime(stats.total_paint_time); + paint_time_counter_->SavePaintTime(stats.main_stats.paint_time); } bool is_new_trace; @@ -1307,6 +1308,10 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, DidDrawDamagedArea(); } active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); + TRACE_EVENT_END1("cc", "LayerTreeHostImpl::DrawLayers", + "data", rendering_stats_instrumentation_-> + GetImplThreadRenderingStats().AsTraceableData()); + rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); } void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { @@ -1511,8 +1516,8 @@ void LayerTreeHostImpl::ActivatePendingTree() { const RenderingStats& stats = rendering_stats_instrumentation_->GetRenderingStats(); paint_time_counter_->SavePaintTime( - stats.total_paint_time + stats.total_record_time + - stats.total_rasterize_time_for_now_bins_on_pending_tree); + stats.main_stats.paint_time + stats.main_stats.record_time + + stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); } client_->DidActivatePendingTree(); diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 3a26a07..65d7980 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -221,6 +221,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); stats_instrumentation->AddCommit(duration); + stats_instrumentation->AccumulateAndClearMainThreadStats(); } layer_tree_host_->CommitComplete(); next_frame_is_newly_committed_frame_ = true; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index a0bd4bf..31a497a 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -695,6 +695,7 @@ void ThreadProxy::BeginFrameOnMainThread( scoped_ptr<BeginFrameAndCommitState> begin_frame_state) { TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnMainThread"); DCHECK(IsMainThread()); + if (!layer_tree_host_) return; @@ -816,7 +817,7 @@ void ThreadProxy::BeginFrameOnMainThread( // point of view, but asynchronously performed on the impl thread, // coordinated by the Scheduler. { - TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnMainThread::commit"); + TRACE_EVENT_BEGIN0("cc", "ThreadProxy::BeginFrameOnMainThread::commit"); DebugScopedSetMainThreadBlocked main_thread_blocked(this); @@ -836,6 +837,10 @@ void ThreadProxy::BeginFrameOnMainThread( base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); stats_instrumentation->AddCommit(duration); + TRACE_EVENT_END1("cc", "ThreadProxy::BeginFrameOnMainThread::commit", + "data", stats_instrumentation-> + GetMainThreadRenderingStats().AsTraceableData()); + stats_instrumentation->AccumulateAndClearMainThreadStats(); } layer_tree_host_->CommitComplete(); diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 7a19c8e..0b206c7 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -1020,7 +1020,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, base::TimeDelta paint_time = base::TimeTicks::HighResNow() - paint_begin_ticks; if (!is_accelerated_compositing_active_) - software_stats_.total_paint_time += paint_time; + software_stats_.main_stats.paint_time += paint_time; } #endif } else { @@ -1035,7 +1035,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, base::TimeDelta paint_time = base::TimeTicks::HighResNow() - paint_begin_ticks; if (!is_accelerated_compositing_active_) - software_stats_.total_paint_time += paint_time; + software_stats_.main_stats.paint_time += paint_time; } // Flush to underlying bitmap. TODO(darin): is this needed? @@ -1047,7 +1047,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, if (kEnableGpuBenchmarking) { int64 num_pixels_processed = rect.width() * rect.height(); - software_stats_.total_pixels_painted += num_pixels_processed; + software_stats_.main_stats.painted_pixel_count += num_pixels_processed; } } @@ -1254,8 +1254,8 @@ void RenderWidget::DoDeferredUpdate() { last_do_deferred_update_time_ = frame_begin_ticks; if (!is_accelerated_compositing_active_) { - software_stats_.animation_frame_count++; - software_stats_.screen_frame_count++; + software_stats_.main_stats.animation_frame_count++; + software_stats_.main_stats.screen_frame_count++; } // OK, save the pending update to a local since painting may cause more @@ -2436,14 +2436,14 @@ void RenderWidget::GetRenderingStats( if (compositor_) compositor_->GetRenderingStats(&stats.rendering_stats); - stats.rendering_stats.animation_frame_count += - software_stats_.animation_frame_count; - stats.rendering_stats.screen_frame_count += - software_stats_.screen_frame_count; - stats.rendering_stats.total_paint_time += - software_stats_.total_paint_time; - stats.rendering_stats.total_pixels_painted += - software_stats_.total_pixels_painted; + stats.rendering_stats.main_stats.animation_frame_count += + software_stats_.main_stats.animation_frame_count; + stats.rendering_stats.main_stats.screen_frame_count += + software_stats_.main_stats.screen_frame_count; + stats.rendering_stats.main_stats.paint_time += + software_stats_.main_stats.paint_time; + stats.rendering_stats.main_stats.painted_pixel_count += + software_stats_.main_stats.painted_pixel_count; } bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |