diff options
author | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-27 02:31:03 +0000 |
---|---|---|
committer | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-27 02:31:03 +0000 |
commit | 944314aa4ab8aa1dbba22a6dbdcfdf96cce20352 (patch) | |
tree | ccf648588bf8e3694f536290e95dbf1c646d8aff | |
parent | d461f62c56a00d085fab0072182658a1278eec4d (diff) | |
download | chromium_src-944314aa4ab8aa1dbba22a6dbdcfdf96cce20352.zip chromium_src-944314aa4ab8aa1dbba22a6dbdcfdf96cce20352.tar.gz chromium_src-944314aa4ab8aa1dbba22a6dbdcfdf96cce20352.tar.bz2 |
cc: Switch RenderingStats collection in Layer::Update() to RenderingStatsInstrumentation
This change switches all of the remaining RenderingStats collection in
composited mode to use RenderinStatsInstrumentation.
BUG=181319
Review URL: https://chromiumcodereview.appspot.com/12426024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190817 0039d316-1c4b-4281-b951-d872f2087c98
59 files changed, 280 insertions, 316 deletions
diff --git a/cc/debug/rendering_stats_instrumentation.cc b/cc/debug/rendering_stats_instrumentation.cc index f19daae..b1968f3 100644 --- a/cc/debug/rendering_stats_instrumentation.cc +++ b/cc/debug/rendering_stats_instrumentation.cc @@ -36,14 +36,6 @@ base::TimeDelta RenderingStatsInstrumentation::EndRecording( 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; diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h index c3ec320..6d26857 100644 --- a/cc/debug/rendering_stats_instrumentation.h +++ b/cc/debug/rendering_stats_instrumentation.h @@ -32,10 +32,6 @@ class CC_EXPORT RenderingStatsInstrumentation { 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); diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc index c29d72e..4ad1bc7 100644 --- a/cc/layers/content_layer.cc +++ b/cc/layers/content_layer.cc @@ -68,8 +68,7 @@ void ContentLayer::SetTexturePriorities( } void ContentLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { { base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, true); @@ -78,7 +77,7 @@ void ContentLayer::Update(ResourceUpdateQueue* queue, UpdateCanUseLCDText(); } - TiledLayer::Update(queue, occlusion, stats); + TiledLayer::Update(queue, occlusion); needs_display_ = false; } @@ -96,11 +95,17 @@ void ContentLayer::CreateUpdaterIfNeeded() { scoped_ptr<LayerPainter> painter = ContentLayerPainter::Create(client_).PassAs<LayerPainter>(); if (layer_tree_host()->settings().accelerate_painting) - updater_ = SkPictureContentLayerUpdater::Create(painter.Pass()); + updater_ = SkPictureContentLayerUpdater::Create( + painter.Pass(), + rendering_stats_instrumentation()); else if (layer_tree_host()->settings().per_tile_painting_enabled) - updater_ = BitmapSkPictureContentLayerUpdater::Create(painter.Pass()); + updater_ = BitmapSkPictureContentLayerUpdater::Create( + painter.Pass(), + rendering_stats_instrumentation()); else - updater_ = BitmapContentLayerUpdater::Create(painter.Pass()); + updater_ = BitmapContentLayerUpdater::Create( + painter.Pass(), + rendering_stats_instrumentation()); updater_->SetOpaque(contents_opaque()); unsigned texture_format = diff --git a/cc/layers/content_layer.h b/cc/layers/content_layer.h index 79394de..0f00cfd 100644 --- a/cc/layers/content_layer.h +++ b/cc/layers/content_layer.h @@ -44,8 +44,7 @@ class CC_EXPORT ContentLayer : public TiledLayer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual bool NeedMoreUpdates() OVERRIDE; virtual void SetContentsOpaque(bool contents_opaque) OVERRIDE; diff --git a/cc/layers/content_layer_unittest.cc b/cc/layers/content_layer_unittest.cc index 25421e7..b1c6a11 100644 --- a/cc/layers/content_layer_unittest.cc +++ b/cc/layers/content_layer_unittest.cc @@ -6,6 +6,7 @@ #include "cc/layers/content_layer_client.h" #include "cc/resources/bitmap_content_layer_updater.h" +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/geometry_test_utils.h" #include "skia/ext/platform_canvas.h" #include "testing/gtest/include/gtest/gtest.h" @@ -37,17 +38,18 @@ TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) { gfx::RectF opaque_rect_in_content_space = gfx::ScaleRect( opaque_rect_in_layer_space, contents_scale, contents_scale); MockContentLayerClient client(opaque_rect_in_layer_space); + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_refptr<BitmapContentLayerUpdater> updater = - BitmapContentLayerUpdater::Create(ContentLayerPainter::Create(&client). - PassAs<LayerPainter>()); + BitmapContentLayerUpdater::Create( + ContentLayerPainter::Create(&client).PassAs<LayerPainter>(), + &stats_instrumentation); gfx::Rect resulting_opaque_rect; updater->PrepareToUpdate(content_rect, gfx::Size(256, 256), contents_scale, contents_scale, - &resulting_opaque_rect, - NULL); + &resulting_opaque_rect); EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaque_rect_in_content_space), resulting_opaque_rect); diff --git a/cc/layers/contents_scaling_layer.cc b/cc/layers/contents_scaling_layer.cc index d602e88..01abcfe 100644 --- a/cc/layers/contents_scaling_layer.cc +++ b/cc/layers/contents_scaling_layer.cc @@ -35,8 +35,7 @@ void ContentsScalingLayer::CalculateContentsScale( void ContentsScalingLayer::Update( ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && draw_properties().contents_scale_y == last_update_contents_scale_y_) return; diff --git a/cc/layers/contents_scaling_layer.h b/cc/layers/contents_scaling_layer.h index a550c26..df853ec 100644 --- a/cc/layers/contents_scaling_layer.h +++ b/cc/layers/contents_scaling_layer.h @@ -23,8 +23,7 @@ class CC_EXPORT ContentsScalingLayer : public Layer { virtual void Update( ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; protected: ContentsScalingLayer(); diff --git a/cc/layers/heads_up_display_layer.cc b/cc/layers/heads_up_display_layer.cc index 76016b5..9945178 100644 --- a/cc/layers/heads_up_display_layer.cc +++ b/cc/layers/heads_up_display_layer.cc @@ -23,8 +23,7 @@ HeadsUpDisplayLayer::HeadsUpDisplayLayer() : Layer() { HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {} void HeadsUpDisplayLayer::Update(ResourceUpdateQueue*, - const OcclusionTracker*, - RenderingStats*) { + const OcclusionTracker*) { const LayerTreeDebugState& debug_state = layer_tree_host()->debug_state(); int max_texture_size = layer_tree_host()->GetRendererCapabilities().max_texture_size; diff --git a/cc/layers/heads_up_display_layer.h b/cc/layers/heads_up_display_layer.h index d7656c5..03d29a02 100644 --- a/cc/layers/heads_up_display_layer.h +++ b/cc/layers/heads_up_display_layer.h @@ -16,8 +16,7 @@ class CC_EXPORT HeadsUpDisplayLayer : public Layer { static scoped_refptr<HeadsUpDisplayLayer> Create(); virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* tracker, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* tracker) OVERRIDE; virtual bool DrawsContent() const OVERRIDE; virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) diff --git a/cc/layers/image_layer.cc b/cc/layers/image_layer.cc index 4f5e105..59cf913 100644 --- a/cc/layers/image_layer.cc +++ b/cc/layers/image_layer.cc @@ -41,8 +41,7 @@ void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { } void ImageLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { CreateUpdaterIfNeeded(); if (needs_display_) { updater_->set_bitmap(bitmap_); @@ -50,7 +49,7 @@ void ImageLayer::Update(ResourceUpdateQueue* queue, InvalidateContentRect(gfx::Rect(content_bounds())); needs_display_ = false; } - TiledLayer::Update(queue, occlusion, stats); + TiledLayer::Update(queue, occlusion); } void ImageLayer::CreateUpdaterIfNeeded() { diff --git a/cc/layers/image_layer.h b/cc/layers/image_layer.h index 8ba5b78..25ddf12 100644 --- a/cc/layers/image_layer.h +++ b/cc/layers/image_layer.h @@ -23,8 +23,7 @@ class CC_EXPORT ImageLayer : public TiledLayer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual void CalculateContentsScale(float ideal_contents_scale, bool animating_transform_to_screen, float* contents_scale_x, diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index bdd2a4f..c5a2ad8 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -818,4 +818,8 @@ ScrollbarLayer* Layer::ToScrollbarLayer() { return NULL; } +RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { + return layer_tree_host_->rendering_stats_instrumentation(); +} + } // namespace cc diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 2e72e63..6a1f3b2 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -43,7 +43,7 @@ class PriorityCalculator; class ResourceUpdateQueue; class ScrollbarLayer; struct AnimationEvent; -struct RenderingStats; +class RenderingStatsInstrumentation; // Base class for composited layers. Special layer types are derived from // this class. @@ -267,8 +267,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, // These methods typically need to be overwritten by derived classes. virtual bool DrawsContent() const; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) {} + const OcclusionTracker* occlusion) {} virtual bool NeedMoreUpdates(); virtual void SetIsMask(bool is_mask) {} @@ -370,6 +369,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, bool NeedsDisplayForTesting() const { return needs_display_; } void ResetNeedsDisplayForTesting() { needs_display_ = false; } + RenderingStatsInstrumentation* rendering_stats_instrumentation() const; + protected: friend class LayerImpl; friend class TreeSynchronizer; diff --git a/cc/layers/nine_patch_layer.cc b/cc/layers/nine_patch_layer.cc index 45c69eb..9a5022d 100644 --- a/cc/layers/nine_patch_layer.cc +++ b/cc/layers/nine_patch_layer.cc @@ -57,8 +57,7 @@ void NinePatchLayer::SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture) { } void NinePatchLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { CreateUpdaterIfNeeded(); if (resource_ && diff --git a/cc/layers/nine_patch_layer.h b/cc/layers/nine_patch_layer.h index 21b8cb9..eaa7a1a6 100644 --- a/cc/layers/nine_patch_layer.h +++ b/cc/layers/nine_patch_layer.h @@ -24,8 +24,7 @@ class CC_EXPORT NinePatchLayer : public Layer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; // aperture is in the pixel space of the bitmap resource and refers to diff --git a/cc/layers/nine_patch_layer_unittest.cc b/cc/layers/nine_patch_layer_unittest.cc index a274100..84c5348 100644 --- a/cc/layers/nine_patch_layer_unittest.cc +++ b/cc/layers/nine_patch_layer_unittest.cc @@ -73,7 +73,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) { // No bitmap set should not trigger any uploads. test_layer->SetTexturePriorities(calculator); - test_layer->Update(&queue, &occlusion_tracker, NULL); + test_layer->Update(&queue, &occlusion_tracker); EXPECT_EQ(queue.FullUploadSize(), 0); EXPECT_EQ(queue.PartialUploadSize(), 0); @@ -83,7 +83,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) { bitmap.allocPixels(); test_layer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); test_layer->SetTexturePriorities(calculator); - test_layer->Update(&queue, &occlusion_tracker, NULL); + test_layer->Update(&queue, &occlusion_tracker); EXPECT_EQ(queue.FullUploadSize(), 1); EXPECT_EQ(queue.PartialUploadSize(), 0); ResourceUpdate params = queue.TakeFirstFullUpload(); @@ -107,7 +107,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) { // Nothing changed, so no repeated upload. test_layer->SetTexturePriorities(calculator); - test_layer->Update(&queue, &occlusion_tracker, NULL); + test_layer->Update(&queue, &occlusion_tracker); EXPECT_EQ(queue.FullUploadSize(), 0); EXPECT_EQ(queue.PartialUploadSize(), 0); { @@ -119,7 +119,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) { // Reupload after eviction test_layer->SetTexturePriorities(calculator); - test_layer->Update(&queue, &occlusion_tracker, NULL); + test_layer->Update(&queue, &occlusion_tracker); EXPECT_EQ(queue.FullUploadSize(), 1); EXPECT_EQ(queue.PartialUploadSize(), 0); @@ -129,7 +129,7 @@ TEST_F(NinePatchLayerTest, TriggerFullUploadOnceWhenChangingBitmap) { EXPECT_EQ(NULL, params.texture->resource_manager()); test_layer->SetTexturePriorities(calculator); ResourceUpdateQueue queue2; - test_layer->Update(&queue2, &occlusion_tracker, NULL); + test_layer->Update(&queue2, &occlusion_tracker); EXPECT_EQ(queue2.FullUploadSize(), 1); EXPECT_EQ(queue2.PartialUploadSize(), 0); params = queue2.TakeFirstFullUpload(); diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index c6f341a..732f811 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -68,8 +68,7 @@ void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) { } void PictureLayer::Update(ResourceUpdateQueue*, - const OcclusionTracker*, - RenderingStats* stats) { + const OcclusionTracker*) { // Do not early-out of this function so that PicturePile::Update has a chance // to record pictures due to changing visibility of this layer. @@ -87,7 +86,7 @@ void PictureLayer::Update(ResourceUpdateQueue*, background_color(), pile_invalidation_, visible_layer_rect, - stats); + rendering_stats_instrumentation()); } void PictureLayer::SetIsMask(bool is_mask) { diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index 0ba4031..7dde9bc 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -15,7 +15,6 @@ namespace cc { class ContentLayerClient; class ResourceUpdateQueue; -struct RenderingStats; class CC_EXPORT PictureLayer : public ContentsScalingLayer { public: @@ -32,8 +31,7 @@ class CC_EXPORT PictureLayer : public ContentsScalingLayer { virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) OVERRIDE; virtual void Update( ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual void SetIsMask(bool is_mask) OVERRIDE; protected: diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 962d927..afbb597 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -11,6 +11,7 @@ #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_output_surface.h" +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -95,7 +96,8 @@ class TestablePicturePileImpl : public PicturePileImpl { return; gfx::Rect bounds(tiling().TileBounds(x, y)); scoped_refptr<Picture> picture(Picture::Create(bounds)); - picture->Record(&client_, NULL, tile_grid_info_); + FakeRenderingStatsInstrumentation stats_instrumentation; + picture->Record(&client_, &stats_instrumentation, tile_grid_info_); picture_list_map_[std::pair<int, int>(x, y)].push_back(picture); EXPECT_TRUE(HasRecordingAt(x, y)); diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc index c5f15b7..1bf71e6 100644 --- a/cc/layers/scrollbar_layer.cc +++ b/cc/layers/scrollbar_layer.cc @@ -270,7 +270,8 @@ void ScrollbarLayer::CreateUpdaterIfNeeded() { scrollbar_.get(), painter_.get(), geometry_.get(), - WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>()); + WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>(), + rendering_stats_instrumentation()); } if (!back_track_) { back_track_ = back_track_updater_->CreateResource( @@ -286,7 +287,8 @@ void ScrollbarLayer::CreateUpdaterIfNeeded() { scrollbar_.get(), painter_.get(), geometry_.get(), - WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>()); + WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>(), + rendering_stats_instrumentation()); } if (!fore_track_) { fore_track_ = fore_track_updater_->CreateResource( @@ -298,7 +300,8 @@ void ScrollbarLayer::CreateUpdaterIfNeeded() { thumb_updater_ = CachingBitmapContentLayerUpdater::Create( ScrollbarThumbPainter::Create(scrollbar_.get(), painter_.get(), - geometry_.get()).PassAs<LayerPainter>()); + geometry_.get()).PassAs<LayerPainter>(), + rendering_stats_instrumentation()); } if (!thumb_) { thumb_ = thumb_updater_->CreateResource( @@ -309,8 +312,7 @@ void ScrollbarLayer::CreateUpdaterIfNeeded() { void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, LayerUpdater::Resource* resource, gfx::Rect rect, - ResourceUpdateQueue* queue, - RenderingStats* stats) { + ResourceUpdateQueue* queue) { if (layer_tree_host()->settings().solid_color_scrollbars) return; @@ -332,8 +334,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, rect.size(), contents_scale_x(), contents_scale_y(), - &painted_opaque_rect, - stats); + &painted_opaque_rect); if (!painter->pixels_did_change() && resource->texture()->have_backing_texture()) { TRACE_EVENT_INSTANT0("cc", @@ -348,7 +349,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, resource->texture()->ReturnBackingTexture(); gfx::Vector2d dest_offset(0, 0); - resource->Update(queue, rect, dest_offset, partial_updates_allowed, stats); + resource->Update(queue, rect, dest_offset, partial_updates_allowed); } gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect( @@ -395,9 +396,8 @@ void ScrollbarLayer::SetTexturePriorities( } void ScrollbarLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { - ContentsScalingLayer::Update(queue, occlusion, stats); + const OcclusionTracker* occlusion) { + ContentsScalingLayer::Update(queue, occlusion); dirty_rect_.Union(update_rect_); if (content_bounds().IsEmpty()) @@ -412,14 +412,12 @@ void ScrollbarLayer::Update(ResourceUpdateQueue* queue, UpdatePart(back_track_updater_.get(), back_track_.get(), content_rect, - queue, - stats); + queue); if (fore_track_ && fore_track_updater_) { UpdatePart(fore_track_updater_.get(), fore_track_.get(), content_rect, - queue, - stats); + queue); } // Consider the thumb to be at the origin when painting. @@ -431,8 +429,7 @@ void ScrollbarLayer::Update(ResourceUpdateQueue* queue, UpdatePart(thumb_updater_.get(), thumb_.get(), origin_thumb_rect, - queue, - stats); + queue); } dirty_rect_ = gfx::RectF(); diff --git a/cc/layers/scrollbar_layer.h b/cc/layers/scrollbar_layer.h index db97272..7920964 100644 --- a/cc/layers/scrollbar_layer.h +++ b/cc/layers/scrollbar_layer.h @@ -40,8 +40,7 @@ class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual void CalculateContentsScale(float ideal_contents_scale, @@ -64,8 +63,7 @@ class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { void UpdatePart(CachingBitmapContentLayerUpdater* painter, LayerUpdater::Resource* resource, gfx::Rect rect, - ResourceUpdateQueue* queue, - RenderingStats* stats); + ResourceUpdateQueue* queue); void CreateUpdaterIfNeeded(); gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 779abf1..1258a8c 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -392,7 +392,7 @@ class ScrollbarLayerTestResourceCreation : public testing::Test { scrollbar_layer->SetTexturePriorities(calculator); layer_tree_host_->contents_texture_manager()->PrioritizeTextures(); - scrollbar_layer->Update(&queue, &occlusion_tracker, NULL); + scrollbar_layer->Update(&queue, &occlusion_tracker); EXPECT_EQ(0, queue.FullUploadSize()); EXPECT_EQ(expected_resources, queue.PartialUploadSize()); diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index acabc87..4d63f72 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -155,8 +155,7 @@ bool TextureLayer::DrawsContent() const { } void TextureLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { if (client_) { texture_id_ = client_->PrepareTexture(queue); context_lost_ = diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index 1e7b31b..28994f3 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -70,8 +70,7 @@ class CC_EXPORT TextureLayer : public Layer { virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; virtual bool DrawsContent() const OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual bool BlocksPendingCommit() const OVERRIDE; diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc index 99b44ce..7afb0d7 100644 --- a/cc/layers/tiled_layer.cc +++ b/cc/layers/tiled_layer.cc @@ -317,7 +317,6 @@ bool TiledLayer::UpdateTiles(int left, int bottom, ResourceUpdateQueue* queue, const OcclusionTracker* occlusion, - RenderingStats* stats, bool* did_paint) { *did_paint = false; CreateUpdaterIfNeeded(); @@ -339,7 +338,7 @@ bool TiledLayer::UpdateTiles(int left, *did_paint = true; UpdateTileTextures( - paint_rect, left, top, right, bottom, queue, occlusion, stats); + paint_rect, left, top, right, bottom, queue, occlusion); return true; } @@ -465,8 +464,7 @@ void TiledLayer::UpdateTileTextures(gfx::Rect paint_rect, int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { // The update_rect should be in layer space. So we have to convert the // paint_rect from content space to layer space. float width_scale = @@ -486,8 +484,7 @@ void TiledLayer::UpdateTileTextures(gfx::Rect paint_rect, tiler_->tile_size(), 1.f / width_scale, 1.f / height_scale, - &painted_opaque_rect, - stats); + &painted_opaque_rect); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { @@ -552,7 +549,7 @@ void TiledLayer::UpdateTileTextures(gfx::Rect paint_rect, CHECK_LE(paint_offset.y() + source_rect.height(), paint_rect.height()); tile->updater_resource()->Update( - queue, source_rect, dest_offset, tile->partial_update, stats); + queue, source_rect, dest_offset, tile->partial_update); if (occlusion) { occlusion->overdraw_metrics()-> DidUpload(gfx::Transform(), source_rect, tile->opaque_rect()); @@ -719,14 +716,13 @@ void TiledLayer::UpdateScrollPrediction() { } void TiledLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { DCHECK(!skips_draw_ && !failed_update_); // Did ResetUpdateState get skipped? { base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, true); - ContentsScalingLayer::Update(queue, occlusion, stats); + ContentsScalingLayer::Update(queue, occlusion); UpdateBounds(); } @@ -745,7 +741,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, &top, &right, &bottom); - UpdateTiles(left, top, right, bottom, queue, NULL, stats, &did_paint); + UpdateTiles(left, top, right, bottom, queue, NULL, &did_paint); if (did_paint) return; // This was an attempt to paint the entire layer so if we fail it's okay, @@ -763,7 +759,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, predicted_visible_rect_, &left, &top, &right, &bottom); MarkOcclusionsAndRequestTextures(left, top, right, bottom, occlusion); skips_draw_ = !UpdateTiles( - left, top, right, bottom, queue, occlusion, stats, &did_paint); + left, top, right, bottom, queue, occlusion, &did_paint); if (skips_draw_) tiler_->reset(); if (skips_draw_ || did_paint) @@ -776,7 +772,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, return; // Prepaint anything that was occluded but inside the layer's visible region. - if (!UpdateTiles(left, top, right, bottom, queue, NULL, stats, &did_paint) || + if (!UpdateTiles(left, top, right, bottom, queue, NULL, &did_paint) || did_paint) return; @@ -806,7 +802,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, while (bottom < prepaint_bottom) { ++bottom; if (!UpdateTiles( - left, bottom, right, bottom, queue, NULL, stats, &did_paint) || + left, bottom, right, bottom, queue, NULL, &did_paint) || did_paint) return; } @@ -815,7 +811,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, while (top > prepaint_top) { --top; if (!UpdateTiles( - left, top, right, top, queue, NULL, stats, &did_paint) || + left, top, right, top, queue, NULL, &did_paint) || did_paint) return; } @@ -824,7 +820,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, while (left > prepaint_left) { --left; if (!UpdateTiles( - left, top, left, bottom, queue, NULL, stats, &did_paint) || + left, top, left, bottom, queue, NULL, &did_paint) || did_paint) return; } @@ -833,7 +829,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue, while (right < prepaint_right) { ++right; if (!UpdateTiles( - right, top, right, bottom, queue, NULL, stats, &did_paint) || + right, top, right, bottom, queue, NULL, &did_paint) || did_paint) return; } diff --git a/cc/layers/tiled_layer.h b/cc/layers/tiled_layer.h index e6112d0..a2d1ecb 100644 --- a/cc/layers/tiled_layer.h +++ b/cc/layers/tiled_layer.h @@ -34,8 +34,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { OVERRIDE; virtual Region VisibleContentOpaqueRegion() const OVERRIDE; virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; protected: TiledLayer(); @@ -96,7 +95,6 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { int bottom, ResourceUpdateQueue* queue, const OcclusionTracker* occlusion, - RenderingStats* stats, bool* did_paint); bool HaveTexturesForTiles(int left, int top, @@ -114,8 +112,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats); + const OcclusionTracker* occlusion); void UpdateScrollPrediction(); UpdatableTile* TileAt(int i, int j) const; diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index dd6c06e..42b22b0 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -17,6 +17,7 @@ #include "cc/test/fake_layer_tree_host_impl.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/tiled_layer_test_common.h" #include "cc/trees/single_thread_proxy.h" @@ -112,7 +113,7 @@ class TiledLayerTest : public testing::Test { void LayerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) { DebugScopedSetMainThread main_thread(proxy_); - layer->Update(queue_.get(), occluded, NULL); + layer->Update(queue_.get(), occluded); } void CalcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) { @@ -161,9 +162,9 @@ class TiledLayerTest : public testing::Test { // Update content if (layer1) - layer1->Update(queue_.get(), occlusion_, NULL); + layer1->Update(queue_.get(), occlusion_); if (layer2) - layer2->Update(queue_.get(), occlusion_, NULL); + layer2->Update(queue_.get(), occlusion_); bool needs_update = false; if (layer1) @@ -605,7 +606,7 @@ TEST_F(TiledLayerTest, PaintSmallAnimatedLayersImmediately) { // if it is close to the viewport size and has the available memory. layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); UpdateTextures(); LayerPushPropertiesTo(layer.get(), layer_impl.get()); @@ -772,7 +773,7 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect()); UpdateTextures(); @@ -781,7 +782,7 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); layer->InvalidateContentRect(content_bounds); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); UpdateTextures(); @@ -791,7 +792,7 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) { layer->InvalidateContentRect(partial_damage); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); } @@ -811,7 +812,7 @@ TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { // Push the tiles to the impl side and check that there is exactly one. layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); UpdateTextures(); LayerPushPropertiesTo(layer.get(), layer_impl.get()); EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); @@ -829,7 +830,7 @@ TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { // The impl side should get 2x2 tiles now. layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); UpdateTextures(); LayerPushPropertiesTo(layer.get(), layer_impl.get()); EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); @@ -910,7 +911,7 @@ TEST_F(TiledLayerTest, ResizeToSmaller) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); layer->SetBounds(gfx::Size(200, 200)); layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); @@ -928,7 +929,7 @@ TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { // Ensure no crash for bounds where size * size would overflow an int. layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); } class TiledLayerPartialUpdateTest : public TiledLayerTest { @@ -1059,7 +1060,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); } @@ -1084,7 +1085,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1098,7 +1099,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { occluded.SetOcclusion(gfx::Rect(250, 200, 300, 100)); layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(36 - 2, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1113,7 +1114,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { occluded.SetOcclusion(gfx::Rect(250, 250, 300, 100)); layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(36, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1144,7 +1145,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(24 - 3, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1162,7 +1163,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1181,7 +1182,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(24 - 6, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1209,7 +1210,7 @@ TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); { UpdateTextures(); } @@ -1224,7 +1225,7 @@ TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { // Repaint without marking it dirty. The 3 culled tiles will be pre-painted // now. - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(3, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1259,7 +1260,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(36 - 3, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1298,7 +1299,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); // The content is half the size of the layer (so the number of tiles is // fewer). In this case, the content is 300x300, and since the tile size is // 100, the number of tiles 3x3. @@ -1322,7 +1323,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1349,7 +1350,7 @@ TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndScaling) { layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); EXPECT_EQ(9 - 1, layer->fake_layer_updater()->update_count()); EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); @@ -1387,7 +1388,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { layer->InvalidateContentRect(content_bounds); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_TRUE(opaque_contents.IsEmpty()); @@ -1404,7 +1405,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { layer->InvalidateContentRect(content_bounds); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), @@ -1421,7 +1422,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { layer->fake_layer_updater()->SetOpaquePaintRect(gfx::Rect()); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), @@ -1440,7 +1441,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { layer->InvalidateContentRect(gfx::Rect(0, 0, 1, 1)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(opaque_paint_rect, visible_bounds).ToString(), @@ -1459,7 +1460,7 @@ TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { layer->InvalidateContentRect(gfx::Rect(10, 10, 1, 1)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), @@ -1498,7 +1499,7 @@ TEST_F(TiledLayerTest, Pixels_paintedMetrics) { layer->InvalidateContentRect(content_bounds); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_TRUE(opaque_contents.IsEmpty()); @@ -1517,7 +1518,7 @@ TEST_F(TiledLayerTest, Pixels_paintedMetrics) { layer->InvalidateContentRect(gfx::Rect(50, 200, 10, 10)); layer->SetTexturePriorities(priority_calculator_); resource_manager_->PrioritizeTextures(); - layer->Update(queue_.get(), &occluded, NULL); + layer->Update(queue_.get(), &occluded); UpdateTextures(); opaque_contents = layer->VisibleContentOpaqueRegion(); EXPECT_TRUE(opaque_contents.IsEmpty()); @@ -1719,7 +1720,8 @@ class UpdateTrackingTiledLayer : public FakeTiledLayer { scoped_ptr<TrackingLayerPainter> painter(TrackingLayerPainter::Create()); tracking_layer_painter_ = painter.get(); layer_updater_ = - BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>()); + BitmapContentLayerUpdater::Create(painter.PassAs<LayerPainter>(), + &stats_instrumentation_); } TrackingLayerPainter* tracking_layer_painter() const { @@ -1734,6 +1736,7 @@ class UpdateTrackingTiledLayer : public FakeTiledLayer { TrackingLayerPainter* tracking_layer_painter_; scoped_refptr<BitmapContentLayerUpdater> layer_updater_; + FakeRenderingStatsInstrumentation stats_instrumentation_; }; TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { @@ -1754,7 +1757,7 @@ TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { resource_manager_->PrioritizeTextures(); // Update the whole tile. - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); layer->tracking_layer_painter()->ResetPaintedRect(); EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); @@ -1763,7 +1766,7 @@ TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { // Invalidate the entire layer in content space. When painting, the rect given // to webkit should match the layer's bounds. layer->InvalidateContentRect(content_rect); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); } @@ -1786,7 +1789,7 @@ TEST_F(TiledLayerTest, resource_manager_->PrioritizeTextures(); // Update the whole tile. - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); layer->tracking_layer_painter()->ResetPaintedRect(); EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); @@ -1795,7 +1798,7 @@ TEST_F(TiledLayerTest, // Invalidate the entire layer in layer space. When painting, the rect given // to webkit should match the layer's bounds. layer->SetNeedsDisplayRect(layer_rect); - layer->Update(queue_.get(), 0, NULL); + layer->Update(queue_.get(), NULL); EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); } diff --git a/cc/resources/bitmap_content_layer_updater.cc b/cc/resources/bitmap_content_layer_updater.cc index 5365c4c..93f5807 100644 --- a/cc/resources/bitmap_content_layer_updater.cc +++ b/cc/resources/bitmap_content_layer_updater.cc @@ -4,7 +4,7 @@ #include "cc/resources/bitmap_content_layer_updater.h" -#include "cc/debug/rendering_stats.h" +#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/resources/layer_painter.h" #include "cc/resources/prioritized_resource.h" #include "cc/resources/resource_update.h" @@ -23,20 +23,23 @@ BitmapContentLayerUpdater::Resource::~Resource() {} void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) { + bool partial_update) { updater_->UpdateTexture( queue, texture(), source_rect, dest_offset, partial_update); } scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( - scoped_ptr<LayerPainter> painter) { - return make_scoped_refptr(new BitmapContentLayerUpdater(painter.Pass())); + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) { + return make_scoped_refptr( + new BitmapContentLayerUpdater(painter.Pass(), stats_instrumentation)); } BitmapContentLayerUpdater::BitmapContentLayerUpdater( - scoped_ptr<LayerPainter> painter) - : ContentLayerUpdater(painter.Pass()), opaque_(false) {} + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) + : ContentLayerUpdater(painter.Pass(), stats_instrumentation), + opaque_(false) {} BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} @@ -51,25 +54,24 @@ void BitmapContentLayerUpdater::PrepareToUpdate( gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) { + gfx::Rect* resulting_opaque_rect) { if (canvas_size_ != content_rect.size()) { canvas_size_ = content_rect.size(); canvas_ = make_scoped_ptr(skia::CreateBitmapCanvas( canvas_size_.width(), canvas_size_.height(), opaque_)); } - if (stats) { - stats->total_pixels_rasterized += - content_rect.width() * content_rect.height(); - } + // TODO: Clarify if this needs to be saved here. crbug.com/223693 + rendering_stats_instrumentation_->AddRaster( + base::TimeDelta(), + content_rect.width() * content_rect.height(), + false); PaintContents(canvas_.get(), content_rect, contents_width_scale, contents_height_scale, - resulting_opaque_rect, - stats); + resulting_opaque_rect); } void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, diff --git a/cc/resources/bitmap_content_layer_updater.h b/cc/resources/bitmap_content_layer_updater.h index 0597f82..9f62204 100644 --- a/cc/resources/bitmap_content_layer_updater.h +++ b/cc/resources/bitmap_content_layer_updater.h @@ -13,6 +13,7 @@ class SkCanvas; namespace cc { class LayerPainter; +class RenderingStatsInstrumenation; // This class rasterizes the content_rect into a skia bitmap canvas. It then // updates textures by copying from the canvas into the texture, using @@ -28,8 +29,7 @@ class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) OVERRIDE; + bool partial_update) OVERRIDE; private: BitmapContentLayerUpdater* updater_; @@ -38,7 +38,8 @@ class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { }; static scoped_refptr<BitmapContentLayerUpdater> Create( - scoped_ptr<LayerPainter> painter); + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumenation); virtual scoped_ptr<LayerUpdater::Resource> CreateResource( PrioritizedResourceManager* manager) OVERRIDE; @@ -46,8 +47,7 @@ class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) OVERRIDE; + gfx::Rect* resulting_opaque_rect) OVERRIDE; void UpdateTexture(ResourceUpdateQueue* queue, PrioritizedResource* resource, gfx::Rect source_rect, @@ -57,7 +57,9 @@ class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { virtual void SetOpaque(bool opaque) OVERRIDE; protected: - explicit BitmapContentLayerUpdater(scoped_ptr<LayerPainter> painter); + BitmapContentLayerUpdater( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumenation); virtual ~BitmapContentLayerUpdater(); scoped_ptr<SkCanvas> canvas_; diff --git a/cc/resources/bitmap_skpicture_content_layer_updater.cc b/cc/resources/bitmap_skpicture_content_layer_updater.cc index e721891..455d7c9 100644 --- a/cc/resources/bitmap_skpicture_content_layer_updater.cc +++ b/cc/resources/bitmap_skpicture_content_layer_updater.cc @@ -5,7 +5,7 @@ #include "cc/resources/bitmap_skpicture_content_layer_updater.h" #include "base/time.h" -#include "cc/debug/rendering_stats.h" +#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/resources/layer_painter.h" #include "cc/resources/prioritized_resource.h" #include "cc/resources/resource_update_queue.h" @@ -23,20 +23,15 @@ void BitmapSkPictureContentLayerUpdater::Resource::Update( ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) { + bool partial_update) { bitmap_.setConfig( SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height()); bitmap_.allocPixels(); bitmap_.setIsOpaque(updater_->layer_is_opaque()); SkDevice device(bitmap_); SkCanvas canvas(&device); - base::TimeTicks paint_begin_time; - if (stats) - paint_begin_time = base::TimeTicks::Now(); - updater_->PaintContentsRect(&canvas, source_rect, stats); - if (stats) - stats->total_paint_time += base::TimeTicks::Now() - paint_begin_time; + + updater_->PaintContentsRect(&canvas, source_rect); ResourceUpdate upload = ResourceUpdate::Create( texture(), &bitmap_, source_rect, source_rect, dest_offset); @@ -47,14 +42,18 @@ void BitmapSkPictureContentLayerUpdater::Resource::Update( } scoped_refptr<BitmapSkPictureContentLayerUpdater> -BitmapSkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { +BitmapSkPictureContentLayerUpdater::Create( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) { return make_scoped_refptr( - new BitmapSkPictureContentLayerUpdater(painter.Pass())); + new BitmapSkPictureContentLayerUpdater(painter.Pass(), + stats_instrumentation)); } BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( - scoped_ptr<LayerPainter> painter) - : SkPictureContentLayerUpdater(painter.Pass()) {} + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) + : SkPictureContentLayerUpdater(painter.Pass(), stats_instrumentation) {} BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} @@ -67,21 +66,25 @@ BitmapSkPictureContentLayerUpdater::CreateResource( void BitmapSkPictureContentLayerUpdater::PaintContentsRect( SkCanvas* canvas, - gfx::Rect source_rect, - RenderingStats* stats) { + gfx::Rect source_rect) { // Translate the origin of content_rect to that of source_rect. canvas->translate(content_rect().x() - source_rect.x(), content_rect().y() - source_rect.y()); - base::TimeTicks rasterize_begin_time; - if (stats) - rasterize_begin_time = base::TimeTicks::Now(); + + base::TimeTicks start_time = + rendering_stats_instrumentation_->StartRecording(); + DrawPicture(canvas); - if (stats) { - stats->total_rasterize_time += - base::TimeTicks::Now() - rasterize_begin_time; - stats->total_pixels_rasterized += - source_rect.width() * source_rect.height(); - } + + base::TimeDelta duration = + rendering_stats_instrumentation_->EndRecording(start_time); + rendering_stats_instrumentation_->AddRaster( + duration, + source_rect.width() * source_rect.height(), + false); + + // TODO: Clarify if this needs to be saved here. crbug.com/223693 + rendering_stats_instrumentation_->AddPaint(duration, 0); } } // namespace cc diff --git a/cc/resources/bitmap_skpicture_content_layer_updater.h b/cc/resources/bitmap_skpicture_content_layer_updater.h index 63ca4a1..19458c1 100644 --- a/cc/resources/bitmap_skpicture_content_layer_updater.h +++ b/cc/resources/bitmap_skpicture_content_layer_updater.h @@ -23,8 +23,7 @@ class BitmapSkPictureContentLayerUpdater : public SkPictureContentLayerUpdater { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) OVERRIDE; + bool partial_update) OVERRIDE; private: SkBitmap bitmap_; @@ -34,16 +33,18 @@ class BitmapSkPictureContentLayerUpdater : public SkPictureContentLayerUpdater { }; static scoped_refptr<BitmapSkPictureContentLayerUpdater> Create( - scoped_ptr<LayerPainter> painter); + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual scoped_ptr<LayerUpdater::Resource> CreateResource( PrioritizedResourceManager* manager) OVERRIDE; void PaintContentsRect(SkCanvas* canvas, - gfx::Rect source_rect, - RenderingStats* stats); + gfx::Rect source_rect); private: - explicit BitmapSkPictureContentLayerUpdater(scoped_ptr<LayerPainter> painter); + BitmapSkPictureContentLayerUpdater( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual ~BitmapSkPictureContentLayerUpdater(); DISALLOW_COPY_AND_ASSIGN(BitmapSkPictureContentLayerUpdater); diff --git a/cc/resources/caching_bitmap_content_layer_updater.cc b/cc/resources/caching_bitmap_content_layer_updater.cc index 78f6097..252388e 100644 --- a/cc/resources/caching_bitmap_content_layer_updater.cc +++ b/cc/resources/caching_bitmap_content_layer_updater.cc @@ -11,14 +11,19 @@ namespace cc { scoped_refptr<CachingBitmapContentLayerUpdater> -CachingBitmapContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { +CachingBitmapContentLayerUpdater::Create( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) { return make_scoped_refptr( - new CachingBitmapContentLayerUpdater(painter.Pass())); + new CachingBitmapContentLayerUpdater(painter.Pass(), + stats_instrumentation)); } CachingBitmapContentLayerUpdater::CachingBitmapContentLayerUpdater( - scoped_ptr<LayerPainter> painter) - : BitmapContentLayerUpdater(painter.Pass()), pixels_did_change_(false) {} + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) + : BitmapContentLayerUpdater(painter.Pass(), stats_instrumentation), + pixels_did_change_(false) {} CachingBitmapContentLayerUpdater::~CachingBitmapContentLayerUpdater() {} @@ -27,14 +32,12 @@ void CachingBitmapContentLayerUpdater::PrepareToUpdate( gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) { + gfx::Rect* resulting_opaque_rect) { BitmapContentLayerUpdater::PrepareToUpdate(content_rect, tile_size, contents_width_scale, contents_height_scale, - resulting_opaque_rect, - stats); + resulting_opaque_rect); const SkBitmap& new_bitmap = canvas_->getDevice()->accessBitmap(false); SkAutoLockPixels lock(new_bitmap); diff --git a/cc/resources/caching_bitmap_content_layer_updater.h b/cc/resources/caching_bitmap_content_layer_updater.h index 420d6d5..e77ce0c 100644 --- a/cc/resources/caching_bitmap_content_layer_updater.h +++ b/cc/resources/caching_bitmap_content_layer_updater.h @@ -14,21 +14,23 @@ namespace cc { class CachingBitmapContentLayerUpdater : public BitmapContentLayerUpdater { public: static scoped_refptr<CachingBitmapContentLayerUpdater> Create( - scoped_ptr<LayerPainter>); + scoped_ptr<LayerPainter>, + RenderingStatsInstrumentation* stats_instrumentation); virtual void PrepareToUpdate(gfx::Rect content_rect, gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) OVERRIDE; + gfx::Rect* resulting_opaque_rect) OVERRIDE; bool pixels_did_change() const { return pixels_did_change_; } private: - explicit CachingBitmapContentLayerUpdater(scoped_ptr<LayerPainter> painter); + CachingBitmapContentLayerUpdater( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual ~CachingBitmapContentLayerUpdater(); bool pixels_did_change_; diff --git a/cc/resources/content_layer_updater.cc b/cc/resources/content_layer_updater.cc index f11083b..a1d9fdf 100644 --- a/cc/resources/content_layer_updater.cc +++ b/cc/resources/content_layer_updater.cc @@ -6,7 +6,7 @@ #include "base/debug/trace_event.h" #include "base/time.h" -#include "cc/debug/rendering_stats.h" +#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/resources/layer_painter.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPaint.h" @@ -17,8 +17,11 @@ namespace cc { -ContentLayerUpdater::ContentLayerUpdater(scoped_ptr<LayerPainter> painter) - : painter_(painter.Pass()) {} +ContentLayerUpdater::ContentLayerUpdater( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) + : painter_(painter.Pass()), + rendering_stats_instrumentation_(stats_instrumentation) {} ContentLayerUpdater::~ContentLayerUpdater() {} @@ -26,8 +29,7 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas, gfx::Rect content_rect, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) { + gfx::Rect* resulting_opaque_rect) { TRACE_EVENT0("cc", "ContentLayerUpdater::PaintContents"); canvas->save(); canvas->translate(SkFloatToScalar(-content_rect.x()), @@ -53,14 +55,18 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas, canvas->clipRect(layer_sk_rect); gfx::RectF opaque_layer_rect; - base::TimeTicks paint_begin_time; - if (stats) - paint_begin_time = base::TimeTicks::Now(); + + base::TimeTicks start_time = + rendering_stats_instrumentation_->StartRecording(); + painter_->Paint(canvas, layer_rect, &opaque_layer_rect); - if (stats) { - stats->total_paint_time += base::TimeTicks::Now() - paint_begin_time; - stats->total_pixels_painted += content_rect.width() * content_rect.height(); - } + + base::TimeDelta duration = + rendering_stats_instrumentation_->EndRecording(start_time); + rendering_stats_instrumentation_->AddPaint( + duration, + content_rect.width() * content_rect.height()); + canvas->restore(); gfx::RectF opaque_content_rect = gfx::ScaleRect( diff --git a/cc/resources/content_layer_updater.h b/cc/resources/content_layer_updater.h index 80b8a48..ca1f6e4 100644 --- a/cc/resources/content_layer_updater.h +++ b/cc/resources/content_layer_updater.h @@ -14,23 +14,26 @@ class SkCanvas; namespace cc { class LayerPainter; +class RenderingStatsInstrumentation; // Base class for BitmapContentLayerUpdater and // SkPictureContentLayerUpdater that reduces code duplication between // their respective PaintContents implementations. class CC_EXPORT ContentLayerUpdater : public LayerUpdater { protected: - explicit ContentLayerUpdater(scoped_ptr<LayerPainter> painter); + ContentLayerUpdater(scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual ~ContentLayerUpdater(); void PaintContents(SkCanvas* canvas, gfx::Rect content_rect, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats); + gfx::Rect* resulting_opaque_rect); gfx::Rect content_rect() const { return content_rect_; } + RenderingStatsInstrumentation* rendering_stats_instrumentation_; + private: gfx::Rect content_rect_; scoped_ptr<LayerPainter> painter_; diff --git a/cc/resources/image_layer_updater.cc b/cc/resources/image_layer_updater.cc index 378490d..6e9cdfea 100644 --- a/cc/resources/image_layer_updater.cc +++ b/cc/resources/image_layer_updater.cc @@ -17,8 +17,7 @@ ImageLayerUpdater::Resource::~Resource() {} void ImageLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats*) { + bool partial_update) { updater_->UpdateTexture( queue, texture(), source_rect, dest_offset, partial_update); } diff --git a/cc/resources/image_layer_updater.h b/cc/resources/image_layer_updater.h index f9fca00..6a47643 100644 --- a/cc/resources/image_layer_updater.h +++ b/cc/resources/image_layer_updater.h @@ -23,8 +23,7 @@ class ImageLayerUpdater : public LayerUpdater { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) OVERRIDE; + bool partial_update) OVERRIDE; private: ImageLayerUpdater* updater_; diff --git a/cc/resources/layer_updater.h b/cc/resources/layer_updater.h index a8b7657..13359ff 100644 --- a/cc/resources/layer_updater.h +++ b/cc/resources/layer_updater.h @@ -17,7 +17,6 @@ class PrioritizedResource; class PrioritizedResourceManager; class ResourceUpdateQueue; class TextureManager; -struct RenderingStats; class CC_EXPORT LayerUpdater : public base::RefCounted<LayerUpdater> { public: @@ -32,8 +31,7 @@ class CC_EXPORT LayerUpdater : public base::RefCounted<LayerUpdater> { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) = 0; + bool partial_update) = 0; protected: explicit Resource(scoped_ptr<PrioritizedResource> texture); @@ -54,8 +52,7 @@ class CC_EXPORT LayerUpdater : public base::RefCounted<LayerUpdater> { gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) {} + gfx::Rect* resulting_opaque_rect) {} // Set true by the layer when it is known that the entire output is going to // be opaque. diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index d3ddc53..9ace4d4 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/debug/trace_event.h" -#include "cc/debug/rendering_stats.h" +#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/layers/content_layer_client.h" #include "cc/resources/picture.h" #include "skia/ext/analysis_canvas.h" @@ -79,7 +79,7 @@ void Picture::CloneForDrawing(int num_threads) { } void Picture::Record(ContentLayerClient* painter, - RenderingStats* stats, + RenderingStatsInstrumentation* stats_instrumentation, const SkTileGridPicture::TileGridInfo& tile_grid_info) { TRACE_EVENT2("cc", "Picture::Record", "width", layer_rect_.width(), "height", layer_rect_.height()); @@ -111,15 +111,13 @@ void Picture::Record(ContentLayerClient* painter, canvas->drawRect(layer_skrect, paint); gfx::RectF opaque_layer_rect; - base::TimeTicks begin_paint_time; - if (stats) - begin_paint_time = base::TimeTicks::Now(); + base::TimeTicks start_time = stats_instrumentation->StartRecording(); + painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect); - if (stats) { - stats->total_paint_time += base::TimeTicks::Now() - begin_paint_time; - stats->total_pixels_painted += - layer_rect_.width() * layer_rect_.height(); - } + + base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); + stats_instrumentation->AddPaint(duration, + layer_rect_.width() * layer_rect_.height()); canvas->restore(); picture_->endRecording(); diff --git a/cc/resources/picture.h b/cc/resources/picture.h index 8598fbf..bb1a988 100644 --- a/cc/resources/picture.h +++ b/cc/resources/picture.h @@ -24,7 +24,7 @@ class AnalysisCanvas; namespace cc { class ContentLayerClient; -struct RenderingStats; +class RenderingStatsInstrumentation; class CC_EXPORT Picture : public base::RefCountedThreadSafe<Picture> { @@ -43,8 +43,9 @@ class CC_EXPORT Picture // Record a paint operation. To be able to safely use this SkPicture for // playback on a different thread this can only be called once. - void Record(ContentLayerClient*, RenderingStats*, - const SkTileGridPicture::TileGridInfo& tile_grid_info); + void Record(ContentLayerClient* painter, + RenderingStatsInstrumentation* stats_instrumentation, + const SkTileGridPicture::TileGridInfo& tile_grid_info); // Has Record() been called yet? bool HasRecording() const { return picture_.get() != NULL; } diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index 85a2e9b..bbb8f3d 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -36,7 +36,7 @@ void PicturePile::Update( SkColor background_color, const Region& invalidation, gfx::Rect visible_layer_rect, - RenderingStats* stats) { + RenderingStatsInstrumentation* stats_instrumentation) { background_color_ = background_color; gfx::Rect interest_rect = visible_layer_rect; @@ -103,7 +103,7 @@ void PicturePile::Update( for (PictureList::iterator pic = pic_list.begin(); pic != pic_list.end(); ++pic) { if (!(*pic)->HasRecording()) { - (*pic)->Record(painter, stats, tile_grid_info_); + (*pic)->Record(painter, stats_instrumentation, tile_grid_info_); (*pic)->CloneForDrawing(num_raster_threads_); } } diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index cc92bf8..bfd88f8 100644 --- a/cc/resources/picture_pile.h +++ b/cc/resources/picture_pile.h @@ -11,7 +11,7 @@ namespace cc { class PicturePileImpl; class Region; -struct RenderingStats; +class RenderingStatsInstrumentation; class CC_EXPORT PicturePile : public PicturePileBase { public: @@ -24,7 +24,7 @@ class CC_EXPORT PicturePile : public PicturePileBase { SkColor background_color, const Region& invalidation, gfx::Rect visible_layer_rect, - RenderingStats* stats); + RenderingStatsInstrumentation* stats_instrumentation); void set_num_raster_threads(int num_raster_threads) { num_raster_threads_ = num_raster_threads; diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc index 4e425e5..8b54c8a 100644 --- a/cc/resources/picture_pile_impl.cc +++ b/cc/resources/picture_pile_impl.cc @@ -5,7 +5,6 @@ #include "base/debug/trace_event.h" #include "cc/base/region.h" #include "cc/debug/debug_colors.h" -#include "cc/debug/rendering_stats.h" #include "cc/resources/picture_pile_impl.h" #include "skia/ext/analysis_canvas.h" #include "third_party/skia/include/core/SkCanvas.h" diff --git a/cc/resources/picture_pile_impl.h b/cc/resources/picture_pile_impl.h index 34364bd..a1a3c70 100644 --- a/cc/resources/picture_pile_impl.h +++ b/cc/resources/picture_pile_impl.h @@ -16,7 +16,6 @@ #include "third_party/skia/include/core/SkPicture.h" namespace cc { -struct RenderingStats; class CC_EXPORT PicturePileImpl : public PicturePileBase { public: diff --git a/cc/resources/skpicture_content_layer_updater.cc b/cc/resources/skpicture_content_layer_updater.cc index 6ce3df8..41b17b7 100644 --- a/cc/resources/skpicture_content_layer_updater.cc +++ b/cc/resources/skpicture_content_layer_updater.cc @@ -22,21 +22,25 @@ SkPictureContentLayerUpdater::Resource::~Resource() {} void SkPictureContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats*) { + bool partial_update) { updater_->UpdateTexture( queue, texture(), source_rect, dest_offset, partial_update); } SkPictureContentLayerUpdater::SkPictureContentLayerUpdater( - scoped_ptr<LayerPainter> painter) - : ContentLayerUpdater(painter.Pass()), layer_is_opaque_(false) {} + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) + : ContentLayerUpdater(painter.Pass(), stats_instrumentation), + layer_is_opaque_(false) {} SkPictureContentLayerUpdater::~SkPictureContentLayerUpdater() {} scoped_refptr<SkPictureContentLayerUpdater> -SkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { - return make_scoped_refptr(new SkPictureContentLayerUpdater(painter.Pass())); +SkPictureContentLayerUpdater::Create( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation) { + return make_scoped_refptr( + new SkPictureContentLayerUpdater(painter.Pass(), stats_instrumentation)); } scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::CreateResource( @@ -50,16 +54,14 @@ void SkPictureContentLayerUpdater::PrepareToUpdate( gfx::Size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) { + gfx::Rect* resulting_opaque_rect) { SkCanvas* canvas = picture_.beginRecording(content_rect.width(), content_rect.height()); PaintContents(canvas, content_rect, contents_width_scale, contents_height_scale, - resulting_opaque_rect, - stats); + resulting_opaque_rect); picture_.endRecording(); } diff --git a/cc/resources/skpicture_content_layer_updater.h b/cc/resources/skpicture_content_layer_updater.h index 218bbc9..3422b96 100644 --- a/cc/resources/skpicture_content_layer_updater.h +++ b/cc/resources/skpicture_content_layer_updater.h @@ -30,8 +30,7 @@ class SkPictureContentLayerUpdater : public ContentLayerUpdater { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) OVERRIDE; + bool partial_update) OVERRIDE; private: SkPictureContentLayerUpdater* updater_; @@ -40,22 +39,24 @@ class SkPictureContentLayerUpdater : public ContentLayerUpdater { }; static scoped_refptr<SkPictureContentLayerUpdater> Create( - scoped_ptr<LayerPainter> painter); + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual scoped_ptr<LayerUpdater::Resource> CreateResource( PrioritizedResourceManager* manager) OVERRIDE; virtual void SetOpaque(bool opaque) OVERRIDE; protected: - explicit SkPictureContentLayerUpdater(scoped_ptr<LayerPainter> painter); + SkPictureContentLayerUpdater( + scoped_ptr<LayerPainter> painter, + RenderingStatsInstrumentation* stats_instrumentation); virtual ~SkPictureContentLayerUpdater(); virtual void PrepareToUpdate(gfx::Rect content_rect, gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) OVERRIDE; + gfx::Rect* resulting_opaque_rect) OVERRIDE; void DrawPicture(SkCanvas* canvas); void UpdateTexture(ResourceUpdateQueue* queue, PrioritizedResource* texture, diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc index 384521c..a30ea95 100644 --- a/cc/test/fake_content_layer.cc +++ b/cc/test/fake_content_layer.cc @@ -25,9 +25,8 @@ scoped_ptr<LayerImpl> FakeContentLayer::CreateLayerImpl( } void FakeContentLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { - ContentLayer::Update(queue, occlusion, stats); + const OcclusionTracker* occlusion) { + ContentLayer::Update(queue, occlusion); update_count_++; } diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h index 52fea8f..cf8066a 100644 --- a/cc/test/fake_content_layer.h +++ b/cc/test/fake_content_layer.h @@ -24,8 +24,7 @@ class FakeContentLayer : public ContentLayer { virtual void Update( ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; bool HaveBackingAt(int i, int j); diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc index 96fbeec..457a5d1 100644 --- a/cc/test/fake_scrollbar_layer.cc +++ b/cc/test/fake_scrollbar_layer.cc @@ -31,11 +31,10 @@ FakeScrollbarLayer::FakeScrollbarLayer(bool paint_during_update, FakeScrollbarLayer::~FakeScrollbarLayer() {} void FakeScrollbarLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) { + const OcclusionTracker* occlusion) { size_t full = queue->FullUploadSize(); size_t partial = queue->PartialUploadSize(); - ScrollbarLayer::Update(queue, occlusion, stats); + ScrollbarLayer::Update(queue, occlusion); update_count_++; last_update_full_upload_size_ = queue->FullUploadSize() - full; last_update_partial_upload_size_ = queue->PartialUploadSize() - partial; diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h index f06f752..8d0d624 100644 --- a/cc/test/fake_scrollbar_layer.h +++ b/cc/test/fake_scrollbar_layer.h @@ -29,8 +29,7 @@ class FakeScrollbarLayer : public ScrollbarLayer { } virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE; + const OcclusionTracker* occlusion) OVERRIDE; private: FakeScrollbarLayer(bool paint_during_update, diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index ce3d365..ece1ec6 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -18,8 +18,7 @@ FakeLayerUpdater::Resource::~Resource() {} void FakeLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) { + bool partial_update) { const gfx::Rect kRect(0, 0, 10, 10); ResourceUpdate upload = ResourceUpdate::Create( texture(), &bitmap_, kRect, kRect, gfx::Vector2d()); @@ -39,8 +38,7 @@ void FakeLayerUpdater::PrepareToUpdate(gfx::Rect content_rect, gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) { + gfx::Rect* resulting_opaque_rect) { prepare_count_++; last_update_rect_ = content_rect; if (!rect_to_invalidate_.IsEmpty()) { diff --git a/cc/test/tiled_layer_test_common.h b/cc/test/tiled_layer_test_common.h index 11666d3..9e84e6e 100644 --- a/cc/test/tiled_layer_test_common.h +++ b/cc/test/tiled_layer_test_common.h @@ -32,8 +32,7 @@ class FakeLayerUpdater : public LayerUpdater { virtual void Update(ResourceUpdateQueue* queue, gfx::Rect source_rect, gfx::Vector2d dest_offset, - bool partial_update, - RenderingStats* stats) OVERRIDE; + bool partial_update) OVERRIDE; private: FakeLayerUpdater* layer_; @@ -51,8 +50,7 @@ class FakeLayerUpdater : public LayerUpdater { gfx::Size tile_size, float contents_width_scale, float contents_height_scale, - gfx::Rect* resulting_opaque_rect, - RenderingStats* stats) OVERRIDE; + gfx::Rect* resulting_opaque_rect) OVERRIDE; // Sets the rect to invalidate during the next call to PrepareToUpdate(). // After the next call to PrepareToUpdate() the rect is reset. void SetRectToInvalidate(gfx::Rect rect, FakeTiledLayer* layer); diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 16f6be7..2ba6da2 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -829,8 +829,7 @@ 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 @@ -839,7 +838,7 @@ bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, bool need_more_updates = false; Layer* mask_layer = render_surface_layer->mask_layer(); if (mask_layer) { - mask_layer->Update(queue, NULL, stats); + mask_layer->Update(queue, NULL); need_more_updates |= mask_layer->NeedMoreUpdates(); } @@ -847,7 +846,7 @@ bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, render_surface_layer->replica_layer() ? render_surface_layer->replica_layer()->mask_layer() : NULL; if (replica_mask_layer) { - replica_mask_layer->Update(queue, NULL, stats); + replica_mask_layer->Update(queue, NULL); need_more_updates |= replica_mask_layer->NeedMoreUpdates(); } return need_more_updates; @@ -875,11 +874,6 @@ 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; - LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); for (LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); @@ -890,18 +884,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); 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 220cbb5..8f39439 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -255,8 +255,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(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(); diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 3025832..9a19950 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -449,13 +449,6 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, scoped_ptr<MemoryHistory> memory_history_; scoped_ptr<DebugRectHistory> debug_rect_history_; - int64 num_impl_thread_scrolls_; - int64 num_main_thread_scrolls_; - - int64 cumulative_num_layers_drawn_; - - int64 cumulative_num_missing_tiles_; - size_t last_sent_memory_visible_bytes_; size_t last_sent_memory_visible_and_nearby_bytes_; size_t last_sent_memory_use_bytes_; diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 28a0ba7..812297f 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -563,9 +563,8 @@ class ContentLayerWithUpdateTracking : public ContentLayer { void ResetPaintContentsCount() { paint_contents_count_ = 0; } virtual void Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE { - ContentLayer::Update(queue, occlusion, stats); + const OcclusionTracker* occlusion) OVERRIDE { + ContentLayer::Update(queue, occlusion); paint_contents_count_++; } @@ -1230,8 +1229,7 @@ class EvictionTestLayer : public Layer { } virtual void Update(ResourceUpdateQueue*, - const OcclusionTracker*, - RenderingStats*) OVERRIDE; + const OcclusionTracker*) OVERRIDE; virtual bool DrawsContent() const OVERRIDE { return true; } virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) @@ -1291,8 +1289,7 @@ void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) { } void EvictionTestLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker*, - RenderingStats*) { + const OcclusionTracker*) { CreateTextureIfNeeded(); if (!texture_.get()) return; diff --git a/cc/trees/layer_tree_host_unittest_occlusion.cc b/cc/trees/layer_tree_host_unittest_occlusion.cc index 8be65f1..ced520c 100644 --- a/cc/trees/layer_tree_host_unittest_occlusion.cc +++ b/cc/trees/layer_tree_host_unittest_occlusion.cc @@ -19,8 +19,7 @@ class TestLayer : public Layer { virtual void Update( ResourceUpdateQueue* update_queue, - const OcclusionTracker* occlusion, - RenderingStats* stats) OVERRIDE { + const OcclusionTracker* occlusion) OVERRIDE { if (!occlusion) return; diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index e63a8fc..8cde4fa 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -29,8 +29,7 @@ SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host) created_offscreen_context_provider_(false), renderer_initialized_(false), next_frame_is_newly_committed_frame_(false), - inside_draw_(false), - total_commit_count_(0) { + inside_draw_(false) { TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); DCHECK(Proxy::IsMainThread()); DCHECK(layer_tree_host); diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index ff8a9d3..140ef20 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -104,9 +104,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { bool inside_draw_; - base::TimeDelta total_commit_time_; - size_t total_commit_count_; - DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); }; |