diff options
author | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-27 19:58:08 +0000 |
---|---|---|
committer | egraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-27 19:58:08 +0000 |
commit | 4e5eff7ffc6637da239f91ca43368c5ae1e7eb31 (patch) | |
tree | b68ca79e2ebb68c77efae54689156cb91feb4637 /cc | |
parent | 2ddc090ed09703a8b42cdddb556008084e8bfc09 (diff) | |
download | chromium_src-4e5eff7ffc6637da239f91ca43368c5ae1e7eb31.zip chromium_src-4e5eff7ffc6637da239f91ca43368c5ae1e7eb31.tar.gz chromium_src-4e5eff7ffc6637da239f91ca43368c5ae1e7eb31.tar.bz2 |
cc: Switch Picture to use RenderingStatsInstrumentation
depends on: https://codereview.chromium.org/13266002/
BUG=181319
Review URL: https://chromiumcodereview.appspot.com/13132005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/picture_layer.cc | 2 | ||||
-rw-r--r-- | cc/resources/picture.cc | 31 | ||||
-rw-r--r-- | cc/resources/picture.h | 6 | ||||
-rw-r--r-- | cc/resources/picture_pile.cc | 6 | ||||
-rw-r--r-- | cc/resources/picture_pile.h | 4 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl.cc | 1 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl.h | 1 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl_unittest.cc | 6 | ||||
-rw-r--r-- | cc/resources/picture_pile_unittest.cc | 16 | ||||
-rw-r--r-- | cc/resources/picture_unittest.cc | 31 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.cc | 7 |
11 files changed, 63 insertions, 48 deletions
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 2c3d71b..0187443 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -95,7 +95,7 @@ void PictureLayer::Update(ResourceUpdateQueue*, contents_opaque(), pile_invalidation_, visible_layer_rect, - stats); + rendering_stats_instrumentation()); } void PictureLayer::SetIsMask(bool is_mask) { diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index 4c85e7d..a3e779d 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -13,7 +13,7 @@ #include "base/values.h" #include "cc/base/math_util.h" #include "cc/base/util.h" -#include "cc/debug/rendering_stats.h" +#include "cc/debug/rendering_stats_instrumentation.h" #include "cc/debug/traced_picture.h" #include "cc/debug/traced_value.h" #include "cc/layers/content_layer_client.h" @@ -188,7 +188,7 @@ void Picture::CloneForDrawing(int num_threads) { void Picture::Record(ContentLayerClient* painter, const SkTileGridPicture::TileGridInfo& tile_grid_info, - RenderingStats* stats) { + RenderingStatsInstrumentation* stats_instrumentation) { TRACE_EVENT2("cc", "Picture::Record", "width", layer_rect_.width(), "height", layer_rect_.height()); @@ -214,15 +214,13 @@ void Picture::Record(ContentLayerClient* painter, canvas->clipRect(layer_skrect); gfx::RectF opaque_layer_rect; - base::TimeTicks begin_record_time; - if (stats) - begin_record_time = base::TimeTicks::Now(); + base::TimeTicks start_time = stats_instrumentation->StartRecording(); + painter->PaintContents(canvas, layer_rect_, &opaque_layer_rect); - if (stats) { - stats->total_record_time += base::TimeTicks::Now() - begin_record_time; - stats->total_pixels_recorded += - 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(); @@ -234,7 +232,7 @@ void Picture::Record(ContentLayerClient* painter, void Picture::GatherPixelRefs( const SkTileGridPicture::TileGridInfo& tile_grid_info, - RenderingStats* stats) { + RenderingStatsInstrumentation* stats_instrumentation) { TRACE_EVENT2("cc", "Picture::GatherPixelRefs", "width", layer_rect_.width(), "height", layer_rect_.height()); @@ -253,9 +251,7 @@ void Picture::GatherPixelRefs( int max_x = 0; int max_y = 0; - base::TimeTicks begin_image_gathering_time; - if (stats) - begin_image_gathering_time = base::TimeTicks::Now(); + base::TimeTicks start_time = stats_instrumentation->StartRecording(); skia::LazyPixelRefList pixel_refs; skia::LazyPixelRefUtils::GatherPixelRefs(picture_.get(), &pixel_refs); @@ -286,11 +282,8 @@ void Picture::GatherPixelRefs( max_y = std::max(max_y, max.y()); } - if (stats) { - stats->total_image_gathering_time += - base::TimeTicks::Now() - begin_image_gathering_time; - stats->total_image_gathering_count++; - } + base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); + stats_instrumentation->AddImageGathering(duration); min_pixel_cell_ = gfx::Point(min_x, min_y); max_pixel_cell_ = gfx::Point(max_x, max_y); diff --git a/cc/resources/picture.h b/cc/resources/picture.h index 6419b34..d58ce52 100644 --- a/cc/resources/picture.h +++ b/cc/resources/picture.h @@ -34,7 +34,7 @@ class AnalysisCanvas; namespace cc { class ContentLayerClient; -struct RenderingStats; +class RenderingStatsInstrumentation; class CC_EXPORT Picture : public base::RefCountedThreadSafe<Picture> { @@ -60,11 +60,11 @@ class CC_EXPORT Picture // playback on a different thread this can only be called once. void Record(ContentLayerClient* client, const SkTileGridPicture::TileGridInfo& tile_grid_info, - RenderingStats* stats); + RenderingStatsInstrumentation* stats_instrumentation); // Gather pixel refs from recording. void GatherPixelRefs(const SkTileGridPicture::TileGridInfo& tile_grid_info, - RenderingStats* stats); + RenderingStatsInstrumentation* stats_instrumentation); // 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 df48c96..1cca7dd 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -37,7 +37,7 @@ void PicturePile::Update( bool contents_opaque, const Region& invalidation, gfx::Rect visible_layer_rect, - RenderingStats* stats) { + RenderingStatsInstrumentation* stats_instrumentation) { background_color_ = background_color; contents_opaque_ = contents_opaque; @@ -109,8 +109,8 @@ void PicturePile::Update( if (!(*pic)->HasRecording()) { TRACE_EVENT0("cc", "PicturePile::Update recording loop"); for (int i = 0; i < repeat_count; i++) - (*pic)->Record(painter, tile_grid_info_, stats); - (*pic)->GatherPixelRefs(tile_grid_info_, stats); + (*pic)->Record(painter, tile_grid_info_, stats_instrumentation); + (*pic)->GatherPixelRefs(tile_grid_info_, stats_instrumentation); (*pic)->CloneForDrawing(num_raster_threads_); } } diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index 33ddc7e..155b333 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: @@ -25,7 +25,7 @@ class CC_EXPORT PicturePile : public PicturePileBase { bool contents_opaque, 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 fda7ecf..99e7c46 100644 --- a/cc/resources/picture_pile_impl.cc +++ b/cc/resources/picture_pile_impl.cc @@ -8,7 +8,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 7dc3a4b..23011d9 100644 --- a/cc/resources/picture_pile_impl.h +++ b/cc/resources/picture_pile_impl.h @@ -17,7 +17,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/picture_pile_impl_unittest.cc b/cc/resources/picture_pile_impl_unittest.cc index 336dc7a..6f33691 100644 --- a/cc/resources/picture_pile_impl_unittest.cc +++ b/cc/resources/picture_pile_impl_unittest.cc @@ -4,6 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "cc/test/fake_picture_pile_impl.h" +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/skia_common.h" #include "skia/ext/lazy_pixel_ref.h" #include "skia/ext/refptr.h" @@ -664,6 +665,7 @@ TEST(PicturePileImplTest, PixelRefIteratorMultiplePictures) { pile->RerecordPile(); FakeContentLayerClient content_layer_clients[2][2]; + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_refptr<Picture> pictures[2][2]; for (int y = 0; y < 2; ++y) { for (int x = 0; x < 2; ++x) { @@ -677,8 +679,8 @@ TEST(PicturePileImplTest, PixelRefIteratorMultiplePictures) { pictures[y][x]->Record( &content_layer_clients[y][x], tile_grid_info, - NULL); - pictures[y][x]->GatherPixelRefs(tile_grid_info, NULL); + &stats_instrumentation); + pictures[y][x]->GatherPixelRefs(tile_grid_info, &stats_instrumentation); pile->AddPictureToRecording(0, 0, pictures[y][x]); } } diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc index 1d2800b..1eeb5ad 100644 --- a/cc/resources/picture_pile_unittest.cc +++ b/cc/resources/picture_pile_unittest.cc @@ -4,6 +4,7 @@ #include "cc/resources/picture_pile.h" #include "cc/test/fake_content_layer_client.h" +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/rect_conversions.h" #include "ui/gfx/size_conversions.h" @@ -27,6 +28,7 @@ class TestPicturePile : public PicturePile { TEST(PicturePileTest, SmallInvalidateInflated) { FakeContentLayerClient client; + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_refptr<TestPicturePile> pile = new TestPicturePile; SkColor background_color = SK_ColorBLUE; @@ -44,7 +46,7 @@ TEST(PicturePileTest, SmallInvalidateInflated) { false, gfx::Rect(layer_size), gfx::Rect(layer_size), - NULL); + &stats_instrumentation); // Invalidate something inside a tile. gfx::Rect invalidate_rect(50, 50, 1, 1); @@ -53,7 +55,7 @@ TEST(PicturePileTest, SmallInvalidateInflated) { false, invalidate_rect, gfx::Rect(layer_size), - NULL); + &stats_instrumentation); EXPECT_EQ(1, pile->tiling().num_tiles_x()); EXPECT_EQ(1, pile->tiling().num_tiles_y()); @@ -78,6 +80,7 @@ TEST(PicturePileTest, SmallInvalidateInflated) { TEST(PicturePileTest, LargeInvalidateInflated) { FakeContentLayerClient client; + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_refptr<TestPicturePile> pile = new TestPicturePile; SkColor background_color = SK_ColorBLUE; @@ -95,7 +98,7 @@ TEST(PicturePileTest, LargeInvalidateInflated) { false, gfx::Rect(layer_size), gfx::Rect(layer_size), - NULL); + &stats_instrumentation); // Invalidate something inside a tile. gfx::Rect invalidate_rect(50, 50, 100, 100); @@ -104,7 +107,7 @@ TEST(PicturePileTest, LargeInvalidateInflated) { false, invalidate_rect, gfx::Rect(layer_size), - NULL); + &stats_instrumentation); EXPECT_EQ(1, pile->tiling().num_tiles_x()); EXPECT_EQ(1, pile->tiling().num_tiles_y()); @@ -131,6 +134,7 @@ TEST(PicturePileTest, LargeInvalidateInflated) { TEST(PicturePileTest, InvalidateOnTileBoundaryInflated) { FakeContentLayerClient client; + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_refptr<TestPicturePile> pile = new TestPicturePile; SkColor background_color = SK_ColorBLUE; @@ -157,7 +161,7 @@ TEST(PicturePileTest, InvalidateOnTileBoundaryInflated) { false, gfx::Rect(layer_size), gfx::Rect(layer_size), - NULL); + &stats_instrumentation); // Invalidate something just over a tile boundary by a single pixel. // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0). @@ -171,7 +175,7 @@ TEST(PicturePileTest, InvalidateOnTileBoundaryInflated) { false, invalidate_rect, gfx::Rect(layer_size), - NULL); + &stats_instrumentation); for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) { for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) { diff --git a/cc/resources/picture_unittest.cc b/cc/resources/picture_unittest.cc index e231778..ee5e07d 100644 --- a/cc/resources/picture_unittest.cc +++ b/cc/resources/picture_unittest.cc @@ -8,6 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "cc/test/fake_content_layer_client.h" +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/skia_common.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -32,6 +33,7 @@ TEST(PictureTest, AsBase64String) { tile_grid_info.fOffset.setZero(); FakeContentLayerClient content_layer_client; + FakeRenderingStatsInstrumentation stats_instrumentation; scoped_ptr<base::Value> tmp; @@ -49,7 +51,9 @@ TEST(PictureTest, AsBase64String) { // Single full-size rect picture. content_layer_client.add_draw_rect(layer_rect, red_paint); scoped_refptr<Picture> one_rect_picture = Picture::Create(layer_rect); - one_rect_picture->Record(&content_layer_client, tile_grid_info, NULL); + one_rect_picture->Record(&content_layer_client, + tile_grid_info, + &stats_instrumentation); scoped_ptr<base::Value> serialized_one_rect( one_rect_picture->AsValue()); @@ -74,7 +78,9 @@ TEST(PictureTest, AsBase64String) { // Two rect picture. content_layer_client.add_draw_rect(gfx::Rect(25, 25, 50, 50), green_paint); scoped_refptr<Picture> two_rect_picture = Picture::Create(layer_rect); - two_rect_picture->Record(&content_layer_client, tile_grid_info, NULL); + two_rect_picture->Record(&content_layer_client, + tile_grid_info, + &stats_instrumentation); scoped_ptr<base::Value> serialized_two_rect( two_rect_picture->AsValue()); @@ -107,6 +113,7 @@ TEST(PictureTest, PixelRefIterator) { tile_grid_info.fOffset.setZero(); FakeContentLayerClient content_layer_client; + FakeRenderingStatsInstrumentation stats_instrumentation; // Lazy pixel refs are found in the following grids: // |---|---|---|---| @@ -131,8 +138,10 @@ TEST(PictureTest, PixelRefIterator) { } scoped_refptr<Picture> picture = Picture::Create(layer_rect); - picture->Record(&content_layer_client, tile_grid_info, NULL); - picture->GatherPixelRefs(tile_grid_info, NULL); + picture->Record(&content_layer_client, + tile_grid_info, + &stats_instrumentation); + picture->GatherPixelRefs(tile_grid_info, &stats_instrumentation); // Default iterator does not have any pixel refs { @@ -202,6 +211,7 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { tile_grid_info.fOffset.setZero(); FakeContentLayerClient content_layer_client; + FakeRenderingStatsInstrumentation stats_instrumentation; // Lazy pixel refs are found in the following grids: // |---|---|---|---| @@ -226,8 +236,10 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { } scoped_refptr<Picture> picture = Picture::Create(layer_rect); - picture->Record(&content_layer_client, tile_grid_info, NULL); - picture->GatherPixelRefs(tile_grid_info, NULL); + picture->Record(&content_layer_client, + tile_grid_info, + &stats_instrumentation); + picture->GatherPixelRefs(tile_grid_info, &stats_instrumentation); // Default iterator does not have any pixel refs { @@ -321,6 +333,7 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { tile_grid_info.fOffset.setZero(); FakeContentLayerClient content_layer_client; + FakeRenderingStatsInstrumentation stats_instrumentation; // Lazy pixel refs are found in the following grids: // |---|---|---|---| @@ -345,8 +358,10 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { } scoped_refptr<Picture> picture = Picture::Create(layer_rect); - picture->Record(&content_layer_client, tile_grid_info, NULL); - picture->GatherPixelRefs(tile_grid_info, NULL); + picture->Record(&content_layer_client, + tile_grid_info, + &stats_instrumentation); + picture->GatherPixelRefs(tile_grid_info, &stats_instrumentation); for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index bce205f..80df818 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -6,6 +6,7 @@ #include <utility> +#include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/impl_side_painting_settings.h" #include "testing/gtest/include/gtest/gtest.h" @@ -52,9 +53,11 @@ void FakePicturePileImpl::AddRecordingAt(int x, int y) { gfx::Rect bounds(tiling().TileBounds(x, y)); bounds.Inset(-buffer_pixels(), -buffer_pixels()); + FakeRenderingStatsInstrumentation stats_instrumentation; + scoped_refptr<Picture> picture(Picture::Create(bounds)); - picture->Record(&client_, tile_grid_info_, NULL); - picture->GatherPixelRefs(tile_grid_info_, NULL); + picture->Record(&client_, tile_grid_info_, &stats_instrumentation); + picture->GatherPixelRefs(tile_grid_info_, &stats_instrumentation); picture_list_map_[std::pair<int, int>(x, y)].push_back(picture); EXPECT_TRUE(HasRecordingAt(x, y)); |