diff options
author | hendrikw <hendrikw@chromium.org> | 2014-11-11 12:19:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-11 20:20:55 +0000 |
commit | 9d909aa7cc62495eb1ae74202b60727e6c49fbf9 (patch) | |
tree | 95a1f4ab67d2af7566f5c3b453805a03e0a79937 /cc | |
parent | aea8be38fa47e4c1dadacc88faf43a6b099a146f (diff) | |
download | chromium_src-9d909aa7cc62495eb1ae74202b60727e6c49fbf9.zip chromium_src-9d909aa7cc62495eb1ae74202b60727e6c49fbf9.tar.gz chromium_src-9d909aa7cc62495eb1ae74202b60727e6c49fbf9.tar.bz2 |
cc: Add RecordingSource and replace references to PicturePiles
Adds the RecordingSource base class and replaces many
references to PicturePile in the tests. Replace the pile_
member in PictureLayer with a scoped_ptr to the new interface.
This is the other side of: https://codereview.chromium.org/707193007/
TODO: Disconnect from PicturePileBase
TODO: Clean up the new interface so that it will work for both
approaches
Review URL: https://codereview.chromium.org/711843003
Cr-Commit-Position: refs/heads/master@{#303708}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.gyp | 1 | ||||
-rw-r--r-- | cc/layers/picture_layer.cc | 40 | ||||
-rw-r--r-- | cc/layers/picture_layer.h | 8 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_perftest.cc | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 56 | ||||
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 10 | ||||
-rw-r--r-- | cc/resources/picture_pile.cc | 41 | ||||
-rw-r--r-- | cc/resources/picture_pile.h | 57 | ||||
-rw-r--r-- | cc/resources/picture_pile_unittest.cc | 28 | ||||
-rw-r--r-- | cc/resources/recording_source.h | 58 | ||||
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 6 | ||||
-rw-r--r-- | cc/resources/tile_manager_unittest.cc | 10 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_impl.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 3 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 20 |
15 files changed, 223 insertions, 125 deletions
@@ -404,6 +404,7 @@ 'resources/raster_worker_pool.h', 'resources/rasterizer.cc', 'resources/rasterizer.h', + 'resources/recording_source.h', 'resources/release_callback.h', 'resources/resource.cc', 'resources/resource.h', diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index fdf25f4..a6b68cc 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -19,6 +19,7 @@ scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { PictureLayer::PictureLayer(ContentLayerClient* client) : client_(client), + recording_source_(new PicturePile), instrumentation_object_tracker_(id()), update_source_frame_number_(-1), can_use_lcd_text_last_frame_(can_use_lcd_text()) { @@ -37,38 +38,38 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { int source_frame_number = layer_tree_host()->source_frame_number(); gfx::Size impl_bounds = layer_impl->bounds(); - gfx::Size pile_bounds = pile_.tiling_size(); + gfx::Size recording_source_bounds = recording_source_->GetSize(); // If update called, then pile size must match bounds pushed to impl layer. DCHECK_IMPLIES(update_source_frame_number_ == source_frame_number, - impl_bounds == pile_bounds) + impl_bounds == recording_source_bounds) << " bounds " << impl_bounds.ToString() << " pile " - << pile_bounds.ToString(); + << recording_source_bounds.ToString(); if (update_source_frame_number_ != source_frame_number && - pile_bounds != impl_bounds) { + recording_source_bounds != impl_bounds) { // Update may not get called for the layer (if it's not in the viewport // for example, even though it has resized making the pile no longer // valid. In this case just destroy the pile. - pile_.SetEmptyBounds(); + recording_source_->SetEmptyBounds(); } // Unlike other properties, invalidation must always be set on layer_impl. // See PictureLayerImpl::PushPropertiesTo for more details. layer_impl->invalidation_.Clear(); - layer_impl->invalidation_.Swap(&pile_invalidation_); - layer_impl->UpdateRasterSource(PicturePileImpl::CreateFromOther(&pile_)); + layer_impl->invalidation_.Swap(&recording_invalidation_); + layer_impl->UpdateRasterSource(recording_source_->CreateRasterSource()); } void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { Layer::SetLayerTreeHost(host); if (host) { - pile_.SetMinContentsScale(host->settings().minimum_contents_scale); - pile_.SetTileGridSize(host->settings().default_tile_grid_size); - pile_.set_slow_down_raster_scale_factor( + // TODO(hendrikw): Perhaps use and initialization function to do this work. + recording_source_->SetMinContentsScale( + host->settings().minimum_contents_scale); + recording_source_->SetTileGridSize(host->settings().default_tile_grid_size); + recording_source_->SetSlowdownRasterScaleFactor( host->debug_state().slow_down_raster_scale_factor); - pile_.set_show_debug_picture_borders( - host->debug_state().show_picture_borders); } } @@ -97,7 +98,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, gfx::Size layer_size = paint_properties().bounds; if (last_updated_visible_content_rect_ == visible_content_rect() && - pile_.tiling_size() == layer_size && pending_invalidation_.IsEmpty()) { + recording_source_->GetSize() == layer_size && + pending_invalidation_.IsEmpty()) { // Only early out if the visible content rect of this layer hasn't changed. return updated; } @@ -110,7 +112,7 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, // Calling paint in WebKit can sometimes cause invalidations, so save // off the invalidation prior to calling update. - pending_invalidation_.Swap(&pile_invalidation_); + pending_invalidation_.Swap(&recording_invalidation_); pending_invalidation_.Clear(); if (layer_tree_host()->settings().record_full_layer) { @@ -124,8 +126,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, // to the impl side so that it drops tiles that may not have a recording // for them. DCHECK(client_); - updated |= pile_.UpdateAndExpandInvalidation( - client_, &pile_invalidation_, SafeOpaqueBackgroundColor(), + updated |= recording_source_->UpdateAndExpandInvalidation( + client_, &recording_invalidation_, SafeOpaqueBackgroundColor(), contents_opaque(), client_->FillsBoundsCompletely(), layer_size, visible_layer_rect, update_source_frame_number_, Picture::RECORD_NORMALLY); @@ -136,14 +138,14 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, } else { // If this invalidation did not affect the pile, then it can be cleared as // an optimization. - pile_invalidation_.Clear(); + recording_invalidation_.Clear(); } return updated; } void PictureLayer::SetIsMask(bool is_mask) { - pile_.set_is_mask(is_mask); + recording_source_->SetIsMask(is_mask); } bool PictureLayer::SupportsLCDText() const { @@ -179,7 +181,7 @@ skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { } bool PictureLayer::IsSuitableForGpuRasterization() const { - return pile_.is_suitable_for_gpu_rasterization(); + return recording_source_->IsSuitableForGpuRasterization(); } void PictureLayer::ClearClient() { diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index 232dba2..3da9668 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -39,7 +39,9 @@ class CC_EXPORT PictureLayer : public Layer { ContentLayerClient* client() { return client_; } - PicturePile* GetPicturePileForTesting() { return &pile_; } + RecordingSource* GetRecordingSourceForTesting() { + return recording_source_.get(); + } protected: explicit PictureLayer(ContentLayerClient* client); @@ -50,13 +52,13 @@ class CC_EXPORT PictureLayer : public Layer { private: ContentLayerClient* client_; - PicturePile pile_; + scoped_ptr<RecordingSource> recording_source_; devtools_instrumentation:: ScopedLayerObjectTracker instrumentation_object_tracker_; // Invalidation to use the next time update is called. InvalidationRegion pending_invalidation_; // Invalidation from the last time update was called. - Region pile_invalidation_; + Region recording_invalidation_; gfx::Rect last_updated_visible_content_rect_; int update_source_frame_number_; diff --git a/cc/layers/picture_layer_impl_perftest.cc b/cc/layers/picture_layer_impl_perftest.cc index aeea2bb..7f1ce85 100644 --- a/cc/layers/picture_layer_impl_perftest.cc +++ b/cc/layers/picture_layer_impl_perftest.cc @@ -58,7 +58,7 @@ class PictureLayerImplPerfTest : public testing::Test { pending_tree->DetachLayerTree(); scoped_ptr<FakePictureLayerImpl> pending_layer = - FakePictureLayerImpl::CreateWithPile(pending_tree, 7, pile); + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7, pile); pending_layer->SetDrawsContent(true); pending_tree->SetRootLayer(pending_layer.Pass()); diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 07c991a..a75feb0 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -134,7 +134,7 @@ class PictureLayerImplTest : public testing::Test { pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); } - void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { + void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { host_impl_.CreatePendingTree(); host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.f, 0.25f, 100.f); LayerTreeImpl* pending_tree = host_impl_.pending_tree(); @@ -147,10 +147,10 @@ class PictureLayerImplTest : public testing::Test { if (old_pending_root) { pending_layer.reset( static_cast<FakePictureLayerImpl*>(old_pending_root.release())); - pending_layer->SetRasterSource(pile); + pending_layer->SetRasterSource(raster_source); } else { - pending_layer = - FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); + pending_layer = FakePictureLayerImpl::CreateWithRasterSource( + pending_tree, id_, raster_source); pending_layer->SetDrawsContent(true); } // The bounds() just mirror the pile size. @@ -2051,7 +2051,8 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { LayerTreeImpl* pending_tree = host_impl_.pending_tree(); scoped_ptr<FakePictureLayerImpl> pending_layer = - FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pending_pile); + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, + pending_pile); pending_layer->SetDrawsContent(true); pending_tree->SetRootLayer(pending_layer.Pass()); @@ -3716,8 +3717,9 @@ TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { scoped_refptr<FakePicturePileImpl> pending_pile = FakePicturePileImpl::CreateFilledPile(tile_size, bounds); pending_pile->SetIsMask(true); - scoped_ptr<FakePictureLayerImpl> mask = FakePictureLayerImpl::CreateWithPile( - host_impl_.pending_tree(), 3, pending_pile); + scoped_ptr<FakePictureLayerImpl> mask = + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3, + pending_pile); mask->SetBounds(bounds); mask->SetContentBounds(bounds); @@ -4492,7 +4494,7 @@ void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); host->SetRootLayer(layer); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); host_impl_.SetViewportSize(layer_bounds); @@ -4501,14 +4503,14 @@ void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { client.set_fill_with_nonsolid_color(!test_for_solid); Region invalidation(layer_rect); - pile->UpdateAndExpandInvalidation(&client, &invalidation, SK_ColorWHITE, - false, false, layer_bounds, layer_rect, - frame_number++, Picture::RECORD_NORMALLY); + recording_source->UpdateAndExpandInvalidation( + &client, &invalidation, SK_ColorWHITE, false, false, layer_bounds, + layer_rect, frame_number++, Picture::RECORD_NORMALLY); - scoped_refptr<PicturePileImpl> pending_pile = - PicturePileImpl::CreateFromOther(pile); + scoped_refptr<RasterSource> pending_raster_source = + recording_source->CreateRasterSource(); - SetupPendingTree(pending_pile); + SetupPendingTree(pending_raster_source); ActivateTree(); active_layer_->set_fixed_tile_size(tile_size); @@ -4559,7 +4561,7 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); host->SetRootLayer(layer); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); host_impl_.SetViewportSize(layer_bounds); @@ -4568,14 +4570,14 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { client.set_fill_with_nonsolid_color(true); Region invalidation1(layer_rect); - pile->UpdateAndExpandInvalidation(&client, &invalidation1, SK_ColorWHITE, - false, false, layer_bounds, layer_rect, - frame_number++, Picture::RECORD_NORMALLY); + recording_source->UpdateAndExpandInvalidation( + &client, &invalidation1, SK_ColorWHITE, false, false, layer_bounds, + layer_rect, frame_number++, Picture::RECORD_NORMALLY); - scoped_refptr<PicturePileImpl> pending_pile1 = - PicturePileImpl::CreateFromOther(pile); + scoped_refptr<RasterSource> raster_source1 = + recording_source->CreateRasterSource(); - SetupPendingTree(pending_pile1); + SetupPendingTree(raster_source1); ActivateTree(); host_impl_.active_tree()->UpdateDrawProperties(); @@ -4586,14 +4588,14 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { client.set_fill_with_nonsolid_color(false); Region invalidation2(layer_rect); - pile->UpdateAndExpandInvalidation(&client, &invalidation2, SK_ColorWHITE, - false, false, layer_bounds, layer_rect, - frame_number++, Picture::RECORD_NORMALLY); + recording_source->UpdateAndExpandInvalidation( + &client, &invalidation2, SK_ColorWHITE, false, false, layer_bounds, + layer_rect, frame_number++, Picture::RECORD_NORMALLY); - scoped_refptr<PicturePileImpl> pending_pile2 = - PicturePileImpl::CreateFromOther(pile); + scoped_refptr<RasterSource> raster_source2 = + recording_source->CreateRasterSource(); - SetupPendingTree(pending_pile2); + SetupPendingTree(raster_source2); ActivateTree(); // We've switched to a solid color, so we should end up with no tilings. diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index f967448..7873b48 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -74,15 +74,15 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { TEST(PictureLayerTest, SuitableForGpuRasterization) { MockContentLayerClient client; scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); // Layer is suitable for gpu rasterization by default. - EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); + EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); // Veto gpu rasterization. - pile->SetUnsuitableForGpuRasterizationForTesting(); - EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); + recording_source->SetUnsuitableForGpuRasterizationForTesting(); + EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); } @@ -99,7 +99,7 @@ TEST(PictureLayerTest, UseTileGridSize) { // Tile-grid is set according to its setting. SkTileGridFactory::TileGridInfo info = - layer->GetPicturePileForTesting()->GetTileGridInfoForTesting(); + layer->GetRecordingSourceForTesting()->GetTileGridInfoForTesting(); EXPECT_EQ(info.fTileInterval.width(), 123 - 2 * info.fMargin.width()); EXPECT_EQ(info.fTileInterval.height(), 123 - 2 * info.fMargin.height()); } diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index bc20945..7f80929 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -9,6 +9,7 @@ #include <vector> #include "cc/base/region.h" +#include "cc/resources/picture_pile_impl.h" #include "cc/resources/raster_worker_pool.h" #include "skia/ext/analysis_canvas.h" @@ -537,11 +538,51 @@ bool PicturePile::UpdateAndExpandInvalidation( return true; } +gfx::Size PicturePile::GetSize() const { + return tiling_size(); +} + void PicturePile::SetEmptyBounds() { tiling_.SetTilingSize(gfx::Size()); Clear(); } +void PicturePile::SetMinContentsScale(float min_contents_scale) { + PicturePileBase::SetMinContentsScale(min_contents_scale); +} + +void PicturePile::SetTileGridSize(const gfx::Size& tile_grid_size) { + PicturePileBase::SetTileGridSize(tile_grid_size); +} + +void PicturePile::SetSlowdownRasterScaleFactor(int factor) { + slow_down_raster_scale_factor_for_debug_ = factor; +} + +void PicturePile::SetShowDebugPictureBorders(bool show) { + show_debug_picture_borders_ = show; +} + +void PicturePile::SetIsMask(bool is_mask) { + set_is_mask(is_mask); +} + +void PicturePile::SetUnsuitableForGpuRasterizationForTesting() { + is_suitable_for_gpu_rasterization_ = false; +} + +bool PicturePile::IsSuitableForGpuRasterization() const { + return is_suitable_for_gpu_rasterization_; +} + +scoped_refptr<RasterSource> PicturePile::CreateRasterSource() const { + return PicturePileImpl::CreateFromOther(this); +} + +SkTileGridFactory::TileGridInfo PicturePile::GetTileGridInfoForTesting() const { + return PicturePileBase::GetTileGridInfoForTesting(); +} + bool PicturePile::CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const { bool include_borders = false; for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index 7621007..4ad57b3 100644 --- a/cc/resources/picture_pile.h +++ b/cc/resources/picture_pile.h @@ -7,49 +7,40 @@ #include "base/memory/ref_counted.h" #include "cc/resources/picture_pile_base.h" -#include "ui/gfx/geometry/rect.h" +#include "cc/resources/recording_source.h" namespace cc { +class ContentLayerClient; class PicturePileImpl; class Region; class RenderingStatsInstrumentation; -class CC_EXPORT PicturePile : public PicturePileBase { +class CC_EXPORT PicturePile : public PicturePileBase, public RecordingSource { public: PicturePile(); ~PicturePile() override; - // Re-record parts of the picture that are invalid. - // Invalidations are in layer space, and will be expanded to cover everything - // that was either recorded/changed or that has no recording, leaving out only - // pieces that we had a recording for and it was not changed. - // Return true iff the pile was modified. - bool UpdateAndExpandInvalidation(ContentLayerClient* painter, - Region* invalidation, - SkColor background_color, - bool contents_opaque, - bool contents_fill_bounds_completely, - const gfx::Size& layer_size, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode); - - void SetEmptyBounds(); - - void set_slow_down_raster_scale_factor(int factor) { - slow_down_raster_scale_factor_for_debug_ = factor; - } - - void set_show_debug_picture_borders(bool show) { - show_debug_picture_borders_ = show; - } - - bool is_suitable_for_gpu_rasterization() const { - return is_suitable_for_gpu_rasterization_; - } - void SetUnsuitableForGpuRasterizationForTesting() { - is_suitable_for_gpu_rasterization_ = false; - } + bool UpdateAndExpandInvalidation( + ContentLayerClient* painter, + Region* invalidation, + SkColor background_color, + bool contents_opaque, + bool contents_fill_bounds_completely, + const gfx::Size& layer_size, + const gfx::Rect& visible_layer_rect, + int frame_number, + Picture::RecordingMode recording_mode) override; + gfx::Size GetSize() const override; + void SetEmptyBounds() override; + void SetMinContentsScale(float min_contents_scale) override; + void SetTileGridSize(const gfx::Size& tile_grid_size) override; + void SetSlowdownRasterScaleFactor(int factor) override; + void SetShowDebugPictureBorders(bool show) override; + void SetIsMask(bool is_mask) override; + bool IsSuitableForGpuRasterization() const override; + scoped_refptr<RasterSource> CreateRasterSource() const override; + void SetUnsuitableForGpuRasterizationForTesting() override; + SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override; void SetPixelRecordDistanceForTesting(int d) { pixel_record_distance_ = d; } diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc index c5846c1..8ca060b 100644 --- a/cc/resources/picture_pile_unittest.cc +++ b/cc/resources/picture_pile_unittest.cc @@ -60,8 +60,8 @@ class PicturePileTestBase { UpdateAndExpandInvalidation(&invalidation, tiling_size, viewport_rect); } - gfx::Size tiling_size() const { return pile_.tiling_size(); } - gfx::Rect tiling_rect() const { return gfx::Rect(pile_.tiling_size()); } + gfx::Size tiling_size() const { return pile_.GetSize(); } + gfx::Rect tiling_rect() const { return gfx::Rect(pile_.GetSize()); } bool UpdateAndExpandInvalidation(Region* invalidation, const gfx::Size& layer_size, @@ -75,8 +75,8 @@ class PicturePileTestBase { bool UpdateWholePile() { Region invalidation = tiling_rect(); - bool result = UpdateAndExpandInvalidation( - &invalidation, tiling_size(), tiling_rect()); + bool result = UpdateAndExpandInvalidation(&invalidation, tiling_size(), + tiling_rect()); EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); return result; } @@ -208,7 +208,7 @@ TEST_F(PicturePileTest, LargeInvalidateInflated) { int expected_inflation = pile_.buffer_pixels(); const Picture* base_picture = picture_info.GetPicture(); - gfx::Rect base_picture_rect(pile_.tiling_size()); + gfx::Rect base_picture_rect(tiling_size()); base_picture_rect.Inset(-expected_inflation, -expected_inflation); EXPECT_EQ(base_picture_rect.ToString(), base_picture->LayerRect().ToString()); @@ -216,7 +216,7 @@ TEST_F(PicturePileTest, LargeInvalidateInflated) { TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) { gfx::Size new_tiling_size = - gfx::ToCeiledSize(gfx::ScaleSize(pile_.tiling_size(), 2.f)); + gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 2.f)); // This creates initial pictures. SetTilingSize(new_tiling_size); @@ -288,7 +288,7 @@ TEST_F(PicturePileTest, InvalidateOnFullLayer) { TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { gfx::Size new_tiling_size = - gfx::ToCeiledSize(gfx::ScaleSize(pile_.tiling_size(), 4.f)); + gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f)); SetTilingSize(new_tiling_size); gfx::Rect viewport(tiling_size().width(), 1); @@ -346,8 +346,8 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { // Now update with no invalidation and full viewport Region empty_invalidation; - UpdateAndExpandInvalidation( - &empty_invalidation, tiling_size(), tiling_rect()); + UpdateAndExpandInvalidation(&empty_invalidation, tiling_size(), + tiling_rect()); EXPECT_EQ(Region().ToString(), empty_invalidation.ToString()); for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { @@ -385,7 +385,7 @@ TEST_F(PicturePileTest, FrequentInvalidationCanRaster) { // tiles touching it, but is true for adjacent tiles, even if it // overlaps on borders (edge case). gfx::Size new_tiling_size = - gfx::ToCeiledSize(gfx::ScaleSize(pile_.tiling_size(), 4.f)); + gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f)); SetTilingSize(new_tiling_size); gfx::Rect tile01_borders = pile_.tiling().TileBoundsWithBorder(0, 1); @@ -451,8 +451,8 @@ TEST_F(PicturePileTest, NoInvalidationValidViewport) { // No invalidation, changing viewport. invalidation = Region(); - UpdateAndExpandInvalidation( - &invalidation, tiling_size(), gfx::Rect(5, 5, 5, 5)); + UpdateAndExpandInvalidation(&invalidation, tiling_size(), + gfx::Rect(5, 5, 5, 5)); EXPECT_TRUE(!pile_.recorded_viewport().IsEmpty()); EXPECT_EQ(Region().ToString(), invalidation.ToString()); } @@ -1561,12 +1561,12 @@ TEST_F(PicturePileTest, NonSolidRectangleOnOffsettedLayerIsNonSolid) { TEST_F(PicturePileTest, SetEmptyBounds) { EXPECT_TRUE(pile_.is_solid_color()); - EXPECT_FALSE(pile_.tiling_size().IsEmpty()); + EXPECT_FALSE(pile_.GetSize().IsEmpty()); EXPECT_FALSE(pile_.picture_map().empty()); EXPECT_TRUE(pile_.HasRecordings()); pile_.SetEmptyBounds(); EXPECT_FALSE(pile_.is_solid_color()); - EXPECT_TRUE(pile_.tiling_size().IsEmpty()); + EXPECT_TRUE(pile_.GetSize().IsEmpty()); EXPECT_TRUE(pile_.picture_map().empty()); EXPECT_FALSE(pile_.HasRecordings()); } diff --git a/cc/resources/recording_source.h b/cc/resources/recording_source.h new file mode 100644 index 0000000..3b3f2de --- /dev/null +++ b/cc/resources/recording_source.h @@ -0,0 +1,58 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_RESOURCES_RECORDING_SOURCE_H_ +#define CC_RESOURCES_RECORDING_SOURCE_H_ + +#include "cc/base/cc_export.h" +#include "cc/resources/picture.h" +#include "third_party/skia/include/core/SkBBHFactory.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" + +namespace cc { +class ContentLayerClient; +class PicturePileImpl; +class Region; +class RenderingStatsInstrumentation; +class RasterSource; + +class CC_EXPORT RecordingSource { + public: + virtual ~RecordingSource() {} + // Re-record parts of the picture that are invalid. + // Invalidations are in layer space, and will be expanded to cover everything + // that was either recorded/changed or that has no recording, leaving out only + // pieces that we had a recording for and it was not changed. + // Return true iff the pile was modified. + virtual bool UpdateAndExpandInvalidation( + ContentLayerClient* painter, + Region* invalidation, + SkColor background_color, + bool contents_opaque, + bool contents_fill_bounds_completely, + const gfx::Size& layer_size, + const gfx::Rect& visible_layer_rect, + int frame_number, + Picture::RecordingMode recording_mode) = 0; + + virtual gfx::Size GetSize() const = 0; + virtual void SetEmptyBounds() = 0; + virtual void SetMinContentsScale(float min_contents_scale) = 0; + virtual void SetTileGridSize(const gfx::Size& tile_grid_size) = 0; + virtual void SetSlowdownRasterScaleFactor(int factor) = 0; + virtual void SetShowDebugPictureBorders(bool show) = 0; + virtual void SetIsMask(bool is_mask) = 0; + virtual bool IsSuitableForGpuRasterization() const = 0; + + virtual scoped_refptr<RasterSource> CreateRasterSource() const = 0; + + // TODO(hendrikw): Figure out how to remove this. + virtual void SetUnsuitableForGpuRasterizationForTesting() = 0; + virtual SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const = 0; +}; +} + +#endif // CC_RESOURCES_RECORDING_SOURCE_H_ diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 43c1031..7262926 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -159,7 +159,7 @@ class TileManagerPerfTest : public testing::Test { pending_tree->DetachLayerTree(); scoped_ptr<FakePictureLayerImpl> pending_layer = - FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); pending_layer->SetDrawsContent(true); pending_tree->SetRootLayer(pending_layer.Pass()); @@ -361,8 +361,8 @@ class TileManagerPerfTest : public testing::Test { FakePicturePileImpl::CreateFilledPile(kDefaultTileSize, layer_bounds); while (static_cast<int>(layers.size()) < layer_count) { scoped_ptr<FakePictureLayerImpl> layer = - FakePictureLayerImpl::CreateWithPile(host_impl_.pending_tree(), - next_id, pile); + FakePictureLayerImpl::CreateWithRasterSource( + host_impl_.pending_tree(), next_id, pile); layer->SetBounds(layer_bounds); layers.push_back(layer.get()); pending_root_layer_->AddChild(layer.Pass()); diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 7b3a1e7..4a4c8b4 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -112,7 +112,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { pending_layer->SetRasterSource(pile); } else { pending_layer = - FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); + FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); pending_layer->SetDrawsContent(true); } // The bounds() just mirror the pile size. @@ -344,8 +344,8 @@ TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { scoped_refptr<FakePicturePileImpl> pending_pile = FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); scoped_ptr<FakePictureLayerImpl> pending_child = - FakePictureLayerImpl::CreateWithPile( - host_impl_.pending_tree(), id_ + 1, pending_pile); + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), + id_ + 1, pending_pile); pending_layer_->AddChild(pending_child.Pass()); FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>( host_impl_.pending_tree()->LayerById(id_ + 1)); @@ -566,8 +566,8 @@ TEST_F(TileManagerTilePriorityQueueTest, pending_layer_->CreateDefaultTilingsAndTiles(); scoped_ptr<FakePictureLayerImpl> pending_child = - FakePictureLayerImpl::CreateWithPile( - host_impl_.pending_tree(), 2, pending_pile); + FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, + pending_pile); pending_layer_->AddChild(pending_child.Pass()); FakePictureLayerImpl* pending_child_layer = diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h index 00dc799..b10b357 100644 --- a/cc/test/fake_picture_layer_impl.h +++ b/cc/test/fake_picture_layer_impl.h @@ -17,8 +17,8 @@ class FakePictureLayerImpl : public PictureLayerImpl { return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id)); } - // Create layer from a raster_source that covers the entire layer. - static scoped_ptr<FakePictureLayerImpl> CreateWithPile( + // Create layer from a raster source that covers the entire layer. + static scoped_ptr<FakePictureLayerImpl> CreateWithRasterSource( LayerTreeImpl* tree_impl, int id, scoped_refptr<RasterSource> raster_source) { @@ -26,8 +26,8 @@ class FakePictureLayerImpl : public PictureLayerImpl { new FakePictureLayerImpl(tree_impl, id, raster_source)); } - // Create layer from a raster_source that only covers part of the layer. - static scoped_ptr<FakePictureLayerImpl> CreateWithPartialPile( + // Create layer from a raster source that only covers part of the layer. + static scoped_ptr<FakePictureLayerImpl> CreateWithPartialRasterSource( LayerTreeImpl* tree_impl, int id, scoped_refptr<RasterSource> raster_source, diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index b8dca18..2a0bc32 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -6088,7 +6088,8 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { pile_tile_size, content_layer_bounds)); scoped_ptr<FakePictureLayerImpl> scoped_content_layer = - FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); + FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), + 3, pile); LayerImpl* content_layer = scoped_content_layer.get(); scrolling_layer->AddChild(scoped_content_layer.Pass()); content_layer->SetBounds(content_layer_bounds); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index a1137cf..5db3a70 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -4908,12 +4908,12 @@ class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { void BeginTest() override { Layer* root = layer_tree_host()->root_layer(); PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); // Verify default values. EXPECT_TRUE(root->IsSuitableForGpuRasterization()); EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); - EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); + EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); @@ -4964,12 +4964,12 @@ class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { void BeginTest() override { Layer* root = layer_tree_host()->root_layer(); PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); // Verify default values. EXPECT_TRUE(root->IsSuitableForGpuRasterization()); EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); - EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); + EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); EXPECT_FALSE(layer_tree_host()->UseGpuRasterization()); @@ -4979,8 +4979,8 @@ class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); // Content-based veto is relevant as well. - pile->SetUnsuitableForGpuRasterizationForTesting(); - EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); + recording_source->SetUnsuitableForGpuRasterizationForTesting(); + EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); // Veto will take effect when layers are updated. // The results will be verified after commit is completed below. @@ -5029,12 +5029,12 @@ class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { void BeginTest() override { Layer* root = layer_tree_host()->root_layer(); PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); - PicturePile* pile = layer->GetPicturePileForTesting(); + RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); // Verify default values. EXPECT_TRUE(root->IsSuitableForGpuRasterization()); EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); - EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization()); + EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); // With gpu rasterization forced, gpu rasterization trigger is irrelevant. @@ -5044,8 +5044,8 @@ class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { EXPECT_TRUE(layer_tree_host()->UseGpuRasterization()); // Content-based veto is irrelevant as well. - pile->SetUnsuitableForGpuRasterizationForTesting(); - EXPECT_FALSE(pile->is_suitable_for_gpu_rasterization()); + recording_source->SetUnsuitableForGpuRasterizationForTesting(); + EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); // Veto will take effect when layers are updated. // The results will be verified after commit is completed below. |