diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/layer_impl.h | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 178 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.h | 3 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 56 | ||||
-rw-r--r-- | cc/resources/tile_manager.cc | 77 | ||||
-rw-r--r-- | cc/resources/tile_manager.h | 25 | ||||
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager_unittest.cc | 45 | ||||
-rw-r--r-- | cc/test/fake_tile_manager.cc | 13 | ||||
-rw-r--r-- | cc/test/fake_tile_manager.h | 3 | ||||
-rw-r--r-- | cc/test/fake_tile_manager_client.h | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 10 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 2 |
13 files changed, 269 insertions, 149 deletions
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 99642cb..c97ae12 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -188,7 +188,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; virtual void UpdateTilePriorities() {} - virtual void NotifyTileInitialized(const Tile* tile) {} + virtual void NotifyTileStateChanged(const Tile* tile) {} virtual ScrollbarLayerImplBase* ToScrollbarLayer(); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 250dafa..76ab5bb6 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -233,7 +233,8 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, // unused can be considered for removal. std::vector<PictureLayerTiling*> seen_tilings; - bool had_checkerboard_quads = false; + size_t missing_tile_count = 0u; + size_t on_demand_missing_tile_count = 0u; for (PictureLayerTilingSet::CoverageIterator iter( tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); iter; @@ -247,8 +248,75 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, append_quads_data->visible_content_area += visible_geometry_rect.width() * visible_geometry_rect.height(); - if (!*iter || !iter->IsReadyToDraw()) { - had_checkerboard_quads = true; + scoped_ptr<DrawQuad> draw_quad; + if (*iter && iter->IsReadyToDraw()) { + const ManagedTileState::TileVersion& tile_version = + iter->GetTileVersionForDrawing(); + switch (tile_version.mode()) { + case ManagedTileState::TileVersion::RESOURCE_MODE: { + gfx::RectF texture_rect = iter.texture_rect(); + gfx::Rect opaque_rect = iter->opaque_rect(); + opaque_rect.Intersect(geometry_rect); + + if (iter->contents_scale() != ideal_contents_scale_) + append_quads_data->had_incomplete_tile = true; + + scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); + quad->SetNew(shared_quad_state, + geometry_rect, + opaque_rect, + visible_geometry_rect, + tile_version.get_resource_id(), + texture_rect, + iter.texture_size(), + tile_version.contents_swizzled()); + draw_quad = quad.PassAs<DrawQuad>(); + break; + } + case ManagedTileState::TileVersion::PICTURE_PILE_MODE: { + if (!layer_tree_impl() + ->GetRendererCapabilities() + .allow_rasterize_on_demand) { + ++on_demand_missing_tile_count; + break; + } + + gfx::RectF texture_rect = iter.texture_rect(); + gfx::Rect opaque_rect = iter->opaque_rect(); + opaque_rect.Intersect(geometry_rect); + + ResourceProvider* resource_provider = + layer_tree_impl()->resource_provider(); + ResourceFormat format = + resource_provider->memory_efficient_texture_format(); + scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); + quad->SetNew(shared_quad_state, + geometry_rect, + opaque_rect, + visible_geometry_rect, + texture_rect, + iter.texture_size(), + format, + iter->content_rect(), + iter->contents_scale(), + pile_); + draw_quad = quad.PassAs<DrawQuad>(); + break; + } + case ManagedTileState::TileVersion::SOLID_COLOR_MODE: { + scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); + quad->SetNew(shared_quad_state, + geometry_rect, + visible_geometry_rect, + tile_version.get_solid_color(), + false); + draw_quad = quad.PassAs<DrawQuad>(); + break; + } + } + } + + if (!draw_quad) { if (draw_checkerboard_for_missing_tiles()) { scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); SkColor color = DebugColors::DefaultCheckerboardColor(); @@ -270,69 +338,10 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, append_quads_data->had_incomplete_tile = true; append_quads_data->approximated_visible_content_area += visible_geometry_rect.width() * visible_geometry_rect.height(); + ++missing_tile_count; continue; } - const ManagedTileState::TileVersion& tile_version = - iter->GetTileVersionForDrawing(); - scoped_ptr<DrawQuad> draw_quad; - switch (tile_version.mode()) { - case ManagedTileState::TileVersion::RESOURCE_MODE: { - gfx::RectF texture_rect = iter.texture_rect(); - gfx::Rect opaque_rect = iter->opaque_rect(); - opaque_rect.Intersect(geometry_rect); - - if (iter->contents_scale() != ideal_contents_scale_) - append_quads_data->had_incomplete_tile = true; - - scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); - quad->SetNew(shared_quad_state, - geometry_rect, - opaque_rect, - visible_geometry_rect, - tile_version.get_resource_id(), - texture_rect, - iter.texture_size(), - tile_version.contents_swizzled()); - draw_quad = quad.PassAs<DrawQuad>(); - break; - } - case ManagedTileState::TileVersion::PICTURE_PILE_MODE: { - gfx::RectF texture_rect = iter.texture_rect(); - gfx::Rect opaque_rect = iter->opaque_rect(); - opaque_rect.Intersect(geometry_rect); - - ResourceProvider* resource_provider = - layer_tree_impl()->resource_provider(); - ResourceFormat format = - resource_provider->memory_efficient_texture_format(); - scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); - quad->SetNew(shared_quad_state, - geometry_rect, - opaque_rect, - visible_geometry_rect, - texture_rect, - iter.texture_size(), - format, - iter->content_rect(), - iter->contents_scale(), - pile_); - draw_quad = quad.PassAs<DrawQuad>(); - break; - } - case ManagedTileState::TileVersion::SOLID_COLOR_MODE: { - scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); - quad->SetNew(shared_quad_state, - geometry_rect, - visible_geometry_rect, - tile_version.get_solid_color(), - false); - draw_quad = quad.PassAs<DrawQuad>(); - break; - } - } - - DCHECK(draw_quad); quad_sink->Append(draw_quad.Pass()); if (iter->priority(ACTIVE_TREE).resolution != HIGH_RESOLUTION) { @@ -344,10 +353,14 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, seen_tilings.push_back(iter.CurrentTiling()); } - if (had_checkerboard_quads) { - TRACE_EVENT_INSTANT0("cc", + if (missing_tile_count) { + TRACE_EVENT_INSTANT2("cc", "PictureLayerImpl::AppendQuads checkerboard", - TRACE_EVENT_SCOPE_THREAD); + TRACE_EVENT_SCOPE_THREAD, + "missing_tile_count", + missing_tile_count, + "on_demand_missing_tile_count", + on_demand_missing_tile_count); } // Aggressively remove any tilings that are not seen to save memory. Note @@ -429,7 +442,7 @@ void PictureLayerImpl::UpdateTilePriorities() { layer_tree_impl()->DidModifyTilePriorities(); } -void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { +void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { if (layer_tree_impl()->IsActiveTree()) { gfx::RectF layer_damage_rect = gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); @@ -1354,6 +1367,37 @@ bool PictureLayerImpl::IsOnActiveOrPendingTree() const { return !layer_tree_impl()->IsRecycleTree(); } +bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { + if (!layer_tree_impl()->IsPendingTree()) + return true; + + if (!tilings_) + return true; + + for (size_t i = 0; i < tilings_->num_tilings(); ++i) { + PictureLayerTiling* tiling = tilings_->tiling_at(i); + if (tiling->resolution() != HIGH_RESOLUTION && + tiling->resolution() != LOW_RESOLUTION) + continue; + + gfx::Rect rect(visible_content_rect()); + for (PictureLayerTiling::CoverageIterator iter( + tiling, contents_scale_x(), rect); + iter; + ++iter) { + const Tile* tile = *iter; + // A null tile (i.e. missing recording) can just be skipped. + if (!tile) + continue; + + if (tile->required_for_activation() && !tile->IsReadyToDraw()) + return false; + } + } + + return true; +} + PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator() : layer_(NULL) {} diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index afd96aa..9609ccf 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -92,7 +92,7 @@ class CC_EXPORT PictureLayerImpl virtual void AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) OVERRIDE; virtual void UpdateTilePriorities() OVERRIDE; - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE; + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE; virtual void DidBecomeActive() OVERRIDE; virtual void DidBeginTracing() OVERRIDE; virtual void ReleaseResources() OVERRIDE; @@ -136,6 +136,7 @@ class CC_EXPORT PictureLayerImpl PictureLayerImpl* GetTwinLayer() { return twin_layer_; } WhichTree GetTree() const; bool IsOnActiveOrPendingTree() const; + bool AllTilesRequiredForActivationAreReadyToDraw() const; protected: friend class LayerRasterTileIterator; diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index d919298..64454ae 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -2391,5 +2391,61 @@ TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); } +TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { + gfx::Size tile_size(100, 100); + gfx::Size layer_bounds(1000, 1000); + + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + + // Make sure some tiles are not shared. + pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); + + CreateHighLowResAndSetAllTilesVisible(); + active_layer_->SetAllTilesReady(); + pending_layer_->MarkVisibleResourcesAsRequired(); + + // All pending layer tiles required are not ready. + EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); + + // Initialize all low-res tiles. + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); + + // Low-res tiles should not be enough. + EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); + + // Initialize remaining tiles. + pending_layer_->SetAllTilesReady(); + + EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); +} + +TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { + gfx::Size tile_size(100, 100); + gfx::Size layer_bounds(1000, 1000); + + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + + // Make sure some tiles are not shared. + pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); + + CreateHighLowResAndSetAllTilesVisible(); + active_layer_->SetAllTilesReady(); + pending_layer_->MarkVisibleResourcesAsRequired(); + + // All pending layer tiles required are not ready. + EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); + + // Initialize all high-res tiles. + pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); + + // High-res tiles should not be enough. + EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); + + // Initialize remaining tiles. + pending_layer_->SetAllTilesReady(); + + EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); +} + } // namespace } // namespace cc diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 2b3e652..416c4e6 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -365,24 +365,25 @@ scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( // static scoped_ptr<TileManager> TileManager::Create( TileManagerClient* client, + base::SequencedTaskRunner* task_runner, ResourcePool* resource_pool, Rasterizer* rasterizer, - bool use_rasterize_on_demand, RenderingStatsInstrumentation* rendering_stats_instrumentation) { return make_scoped_ptr(new TileManager(client, + task_runner, resource_pool, rasterizer, - use_rasterize_on_demand, rendering_stats_instrumentation)); } TileManager::TileManager( TileManagerClient* client, + base::SequencedTaskRunner* task_runner, ResourcePool* resource_pool, Rasterizer* rasterizer, - bool use_rasterize_on_demand, RenderingStatsInstrumentation* rendering_stats_instrumentation) : client_(client), + task_runner_(task_runner), resource_pool_(resource_pool), rasterizer_(rasterizer), prioritized_tiles_dirty_(false), @@ -396,7 +397,8 @@ TileManager::TileManager( rendering_stats_instrumentation_(rendering_stats_instrumentation), did_initialize_visible_tile_(false), did_check_for_completed_tasks_since_last_schedule_tasks_(true), - use_rasterize_on_demand_(use_rasterize_on_demand) { + check_if_ready_to_activate_pending_(false), + weak_ptr_factory_(this) { rasterizer_->SetClient(this); } @@ -528,12 +530,14 @@ void TileManager::DidFinishRunningTasks() { // If we can't raster on demand, give up early (and don't activate). if (!allow_rasterize_on_demand) return; - if (use_rasterize_on_demand_) - tile_version.set_rasterize_on_demand(); + + tile_version.set_rasterize_on_demand(); + client_->NotifyTileStateChanged(tile); } } - client_->NotifyReadyToActivate(); + DCHECK(IsReadyToActivate()); + ScheduleCheckIfReadyToActivate(); } void TileManager::DidFinishRunningTasksRequiredForActivation() { @@ -545,7 +549,7 @@ void TileManager::DidFinishRunningTasksRequiredForActivation() { if (!all_tiles_required_for_activation_have_memory_) return; - client_->NotifyReadyToActivate(); + ScheduleCheckIfReadyToActivate(); } void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { @@ -664,7 +668,7 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { // can visit it. if (mts.bin == NEVER_BIN && !mts.tile_versions[mts.raster_mode].raster_task_) { - FreeResourcesForTile(tile); + FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); continue; } @@ -853,7 +857,7 @@ void TileManager::AssignGpuMemoryToTiles( // If the tile is not needed, free it up. if (mts.bin == NEVER_BIN) { - FreeResourcesForTile(tile); + FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); continue; } @@ -895,14 +899,19 @@ void TileManager::AssignGpuMemoryToTiles( // Tile is OOM. if (tile_bytes > tile_bytes_left || tile_resources > resources_left) { + bool was_ready_to_draw = tile->IsReadyToDraw(); + FreeResourcesForTile(tile); // This tile was already on screen and now its resources have been // released. In order to prevent checkerboarding, set this tile as // rasterize on demand immediately. - if (mts.visible_and_ready_to_draw && use_rasterize_on_demand_) + if (mts.visible_and_ready_to_draw) tile_version.set_rasterize_on_demand(); + if (was_ready_to_draw) + client_->NotifyTileStateChanged(tile); + oomed_soft = true; if (tile_uses_hard_limit) { oomed_hard = true; @@ -997,6 +1006,14 @@ void TileManager::FreeUnusedResourcesForTile(Tile* tile) { } } +void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( + Tile* tile) { + bool was_ready_to_draw = tile->IsReadyToDraw(); + FreeResourcesForTile(tile); + if (was_ready_to_draw) + client_->NotifyTileStateChanged(tile); +} + void TileManager::ScheduleTasks( const TileVector& tiles_that_need_to_be_rasterized) { TRACE_EVENT1("cc", @@ -1189,11 +1206,11 @@ void TileManager::OnRasterTaskCompleted( ++resources_releasable_; } - client_->NotifyTileInitialized(tile); - FreeUnusedResourcesForTile(tile); if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) did_initialize_visible_tile_ = true; + + client_->NotifyTileStateChanged(tile); } scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, @@ -1627,4 +1644,38 @@ void TileManager::SetRasterizerForTesting(Rasterizer* rasterizer) { rasterizer_->SetClient(this); } +bool TileManager::IsReadyToActivate() const { + for (std::vector<PictureLayerImpl*>::const_iterator it = layers_.begin(); + it != layers_.end(); + ++it) { + if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) + return false; + } + + return true; +} + +void TileManager::ScheduleCheckIfReadyToActivate() { + if (check_if_ready_to_activate_pending_) + return; + + task_runner_->PostTask(FROM_HERE, + base::Bind(&TileManager::CheckIfReadyToActivate, + weak_ptr_factory_.GetWeakPtr())); + check_if_ready_to_activate_pending_ = true; +} + +void TileManager::CheckIfReadyToActivate() { + TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); + + DCHECK(check_if_ready_to_activate_pending_); + check_if_ready_to_activate_pending_ = false; + + rasterizer_->CheckForCompletedTasks(); + did_check_for_completed_tasks_since_last_schedule_tasks_ = true; + + if (IsReadyToActivate()) + client_->NotifyReadyToActivate(); +} + } // namespace cc diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index cdc7d1e..0881e6f 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -30,8 +30,15 @@ class ResourceProvider; class CC_EXPORT TileManagerClient { public: + // Called when all tiles marked as required for activation are ready to draw. virtual void NotifyReadyToActivate() = 0; - virtual void NotifyTileInitialized(const Tile* tile) = 0; + + // Called when the visible representation of a tile might have changed. Some + // examples are: + // - Tile version initialized. + // - Tile resources freed. + // - Tile marked for on-demand raster. + virtual void NotifyTileStateChanged(const Tile* tile) = 0; protected: virtual ~TileManagerClient() {} @@ -154,9 +161,9 @@ class CC_EXPORT TileManager : public RasterizerClient, static scoped_ptr<TileManager> Create( TileManagerClient* client, + base::SequencedTaskRunner* task_runner, ResourcePool* resource_pool, Rasterizer* rasterizer, - bool use_rasterize_on_demand, RenderingStatsInstrumentation* rendering_stats_instrumentation); virtual ~TileManager(); @@ -228,9 +235,9 @@ class CC_EXPORT TileManager : public RasterizerClient, protected: TileManager(TileManagerClient* client, + base::SequencedTaskRunner* task_runner, ResourcePool* resource_pool, Rasterizer* rasterizer, - bool use_rasterize_on_demand, RenderingStatsInstrumentation* rendering_stats_instrumentation); // Methods called by Tile @@ -276,6 +283,7 @@ class CC_EXPORT TileManager : public RasterizerClient, void FreeResourceForTile(Tile* tile, RasterMode mode); void FreeResourcesForTile(Tile* tile); void FreeUnusedResourcesForTile(Tile* tile); + void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, SkPixelRef* pixel_ref); scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); @@ -283,7 +291,12 @@ class CC_EXPORT TileManager : public RasterizerClient, void UpdatePrioritizedTileSetIfNeeded(); void CleanUpLayers(); + bool IsReadyToActivate() const; + void ScheduleCheckIfReadyToActivate(); + void CheckIfReadyToActivate(); + TileManagerClient* client_; + scoped_refptr<base::SequencedTaskRunner> task_runner_; ResourcePool* resource_pool_; Rasterizer* rasterizer_; GlobalStateThatImpactsTilePriority global_state_; @@ -323,8 +336,6 @@ class CC_EXPORT TileManager : public RasterizerClient, std::vector<Tile*> released_tiles_; - bool use_rasterize_on_demand_; - ResourceFormat resource_format_; // Queue used when scheduling raster tasks. @@ -334,6 +345,10 @@ class CC_EXPORT TileManager : public RasterizerClient, std::vector<PictureLayerImpl*> layers_; + bool check_if_ready_to_activate_pending_; + + base::WeakPtrFactory<TileManager> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(TileManager); }; diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 22e7c66..c7fa68f 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -293,7 +293,7 @@ class TileManagerPerfTest : public testing::Test, public TileManagerClient { // TileManagerClient implementation. virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE {} + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} TileManager* tile_manager() { return host_impl_.tile_manager(); } diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 5a1837f..ce54d38 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -32,8 +32,7 @@ class TileManagerTest : public testing::TestWithParam<bool>, void Initialize(int max_tiles, TileMemoryLimitPolicy memory_limit_policy, - TreePriority tree_priority, - bool allow_on_demand_raster = true) { + TreePriority tree_priority) { output_surface_ = FakeOutputSurface::Create3d(); CHECK(output_surface_->BindToClient(&output_surface_client_)); @@ -43,8 +42,8 @@ class TileManagerTest : public testing::TestWithParam<bool>, false); resource_pool_ = ResourcePool::Create( resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); - tile_manager_ = make_scoped_ptr(new FakeTileManager( - this, resource_pool_.get(), allow_on_demand_raster)); + tile_manager_ = + make_scoped_ptr(new FakeTileManager(this, resource_pool_.get())); memory_limit_policy_ = memory_limit_policy; max_tiles_ = max_tiles; @@ -85,7 +84,7 @@ class TileManagerTest : public testing::TestWithParam<bool>, // TileManagerClient implementation. virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE {} + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} TileVector CreateTilesWithSize(int count, TilePriority active_priority, @@ -614,40 +613,6 @@ TEST_P(TileManagerTest, RespectMemoryLimit) { EXPECT_LE(memory_allocated_bytes, global_state_.hard_memory_limit_in_bytes); } -TEST_P(TileManagerTest, AllowRasterizeOnDemand) { - // Not enough memory to initialize tiles required for activation. - Initialize(0, ALLOW_ANYTHING, SAME_PRIORITY_FOR_BOTH_TREES); - TileVector tiles = - CreateTiles(2, TilePriority(), TilePriorityRequiredForActivation()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - // This should make required tiles ready to draw by marking them as - // required tiles for on-demand raster. - tile_manager()->DidFinishRunningTasksForTesting(); - - EXPECT_TRUE(ready_to_activate()); - for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it) - EXPECT_TRUE((*it)->IsReadyToDraw()); -} - -TEST_P(TileManagerTest, PreventRasterizeOnDemand) { - // Not enough memory to initialize tiles required for activation. - Initialize(0, ALLOW_ANYTHING, SAME_PRIORITY_FOR_BOTH_TREES, false); - TileVector tiles = - CreateTiles(2, TilePriority(), TilePriorityRequiredForActivation()); - - tile_manager()->AssignMemoryToTiles(global_state_); - - // This should make required tiles ready to draw by marking them as - // required tiles for on-demand raster. - tile_manager()->DidFinishRunningTasksForTesting(); - - EXPECT_TRUE(ready_to_activate()); - for (TileVector::iterator it = tiles.begin(); it != tiles.end(); ++it) - EXPECT_FALSE((*it)->IsReadyToDraw()); -} - // If true, the max tile limit should be applied as bytes; if false, // as num_resources_limit. INSTANTIATE_TEST_CASE_P(TileManagerTests, @@ -754,7 +719,7 @@ class TileManagerTileIteratorTest : public testing::Test, // TileManagerClient implementation. virtual void NotifyReadyToActivate() OVERRIDE { ready_to_activate_ = true; } - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE {} + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} TileManager* tile_manager() { return host_impl_.tile_manager(); } diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc index 496baea..1fc2e43 100644 --- a/cc/test/fake_tile_manager.cc +++ b/cc/test/fake_tile_manager.cc @@ -63,26 +63,17 @@ base::LazyInstance<FakeRasterizerImpl> g_fake_rasterizer = FakeTileManager::FakeTileManager(TileManagerClient* client) : TileManager(client, + base::MessageLoopProxy::current(), NULL, g_fake_rasterizer.Pointer(), - true, NULL) {} FakeTileManager::FakeTileManager(TileManagerClient* client, ResourcePool* resource_pool) : TileManager(client, + base::MessageLoopProxy::current(), resource_pool, g_fake_rasterizer.Pointer(), - true, - NULL) {} - -FakeTileManager::FakeTileManager(TileManagerClient* client, - ResourcePool* resource_pool, - bool allow_on_demand_raster) - : TileManager(client, - resource_pool, - g_fake_rasterizer.Pointer(), - allow_on_demand_raster, NULL) {} FakeTileManager::~FakeTileManager() {} diff --git a/cc/test/fake_tile_manager.h b/cc/test/fake_tile_manager.h index c5c7a25..05dbe61 100644 --- a/cc/test/fake_tile_manager.h +++ b/cc/test/fake_tile_manager.h @@ -16,9 +16,6 @@ class FakeTileManager : public TileManager { public: explicit FakeTileManager(TileManagerClient* client); FakeTileManager(TileManagerClient* client, ResourcePool* resource_pool); - FakeTileManager(TileManagerClient* client, - ResourcePool* resource_pool, - bool allow_on_demand_raster); virtual ~FakeTileManager(); bool HasBeenAssignedMemory(Tile* tile); diff --git a/cc/test/fake_tile_manager_client.h b/cc/test/fake_tile_manager_client.h index dd368b9..7faa30e 100644 --- a/cc/test/fake_tile_manager_client.h +++ b/cc/test/fake_tile_manager_client.h @@ -15,7 +15,7 @@ class FakeTileManagerClient : public TileManagerClient { // TileManagerClient implementation. virtual void NotifyReadyToActivate() OVERRIDE {} - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE {} + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE {} }; } // namespace cc diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 219ea89..803c414 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1240,21 +1240,21 @@ void LayerTreeHostImpl::NotifyReadyToActivate() { client_->NotifyReadyToActivate(); } -void LayerTreeHostImpl::NotifyTileInitialized(const Tile* tile) { - TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileInitialized"); +void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { + TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); if (active_tree_) { LayerImpl* layer_impl = active_tree_->FindActiveTreeLayerById(tile->layer_id()); if (layer_impl) - layer_impl->NotifyTileInitialized(tile); + layer_impl->NotifyTileStateChanged(tile); } if (pending_tree_) { LayerImpl* layer_impl = pending_tree_->FindPendingTreeLayerById(tile->layer_id()); if (layer_impl) - layer_impl->NotifyTileInitialized(tile); + layer_impl->NotifyTileStateChanged(tile); } } @@ -1922,9 +1922,9 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { tile_manager_ = TileManager::Create(this, + proxy_->ImplThreadTaskRunner(), resource_pool_.get(), raster_worker_pool_->AsRasterizer(), - GetRendererCapabilities().allow_rasterize_on_demand, rendering_stats_instrumentation_); UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 494342e..45fefe5 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -232,7 +232,7 @@ class CC_EXPORT LayerTreeHostImpl // TileManagerClient implementation. virtual void NotifyReadyToActivate() OVERRIDE; - virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE; + virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE; // ScrollbarAnimationControllerClient implementation. virtual void PostDelayedScrollbarFade(const base::Closure& start_fade, |