Chromium Code Reviews| Index: cc/layers/picture_layer_impl.cc |
| diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc |
| index fc8647c06672435caf30524513c896e74b9ba2d7..9646cfe59e4a491d9eace906dbe4d4fdd66ce588 100644 |
| --- a/cc/layers/picture_layer_impl.cc |
| +++ b/cc/layers/picture_layer_impl.cc |
| @@ -54,7 +54,7 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
| is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), |
| needs_post_commit_initialization_(true), |
| should_update_tile_priorities_(false), |
| - should_use_gpu_rasterization_(tree_impl->settings().gpu_rasterization) {} |
| + has_gpu_rasterization_hint_(false) {} |
| PictureLayerImpl::~PictureLayerImpl() {} |
| @@ -91,6 +91,7 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { |
| layer_impl->SetIsMask(is_mask_); |
| layer_impl->pile_ = pile_; |
| + layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_); |
| // Tilings would be expensive to push, so we swap. This optimization requires |
| // an extra invalidation in SyncFromActiveLayer. |
| @@ -449,13 +450,21 @@ skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| return pile_->GetFlattenedPicture(); |
| } |
| -void PictureLayerImpl::SetShouldUseGpuRasterization( |
| - bool should_use_gpu_rasterization) { |
| - if (should_use_gpu_rasterization != should_use_gpu_rasterization_) { |
| - should_use_gpu_rasterization_ = should_use_gpu_rasterization; |
| +void PictureLayerImpl::SetHasGpuRasterizationHint(bool has_hint) { |
| + bool old_should_use_gpu_rasterization = ShouldUseGpuRasterization(); |
| + has_gpu_rasterization_hint_ = has_hint; |
| + if (ShouldUseGpuRasterization() != old_should_use_gpu_rasterization) |
| RemoveAllTilings(); |
| - } else { |
| - should_use_gpu_rasterization_ = should_use_gpu_rasterization; |
| +} |
| + |
| +bool PictureLayerImpl::ShouldUseGpuRasterization() const { |
| + switch (layer_tree_impl()->settings().gpu_rasterization_state) { |
| + case LayerTreeSettings::SoftwareRasterization: |
| + return false; |
| + case LayerTreeSettings::HybridGpuRasterization: |
| + return has_gpu_rasterization_hint_; |
| + case LayerTreeSettings::UniversalGpuRasterization: |
| + return true; |
| } |
| } |
| @@ -467,7 +476,7 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
| int flags = 0; |
| if (is_using_lcd_text_) |
| flags |= Tile::USE_LCD_TEXT; |
| - if (should_use_gpu_rasterization()) |
| + if (ShouldUseGpuRasterization()) |
| flags |= Tile::USE_GPU_RASTERIZATION; |
| return layer_tree_impl()->tile_manager()->CreateTile( |
| pile_.get(), |
| @@ -491,8 +500,8 @@ const Region* PictureLayerImpl::GetInvalidation() { |
| const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( |
| const PictureLayerTiling* tiling) const { |
| - if (!twin_layer_ || twin_layer_->should_use_gpu_rasterization() != |
| - should_use_gpu_rasterization()) |
| + if (!twin_layer_ || |
| + twin_layer_->ShouldUseGpuRasterization() != ShouldUseGpuRasterization()) |
| return NULL; |
| for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) |
| if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == |
| @@ -841,8 +850,8 @@ PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| const Region& recorded = pile_->recorded_region(); |
| DCHECK(!recorded.IsEmpty()); |
| - if (twin_layer_ && twin_layer_->should_use_gpu_rasterization() == |
| - should_use_gpu_rasterization()) |
| + if (twin_layer_ && |
| + twin_layer_->ShouldUseGpuRasterization() == ShouldUseGpuRasterization()) |
| twin_layer_->SyncTiling(tiling); |
| return tiling; |
| @@ -862,7 +871,8 @@ void PictureLayerImpl::RemoveTiling(float contents_scale) { |
| } |
| void PictureLayerImpl::RemoveAllTilings() { |
| - tilings_->RemoveAllTilings(); |
| + if (tilings_) |
|
enne (OOO)
2014/03/06 21:28:46
When can this be NULL?
ajuma
2014/03/06 21:44:28
One situation is during the initial commit. During
|
| + tilings_->RemoveAllTilings(); |
| // If there are no tilings, then raster scales are no longer meaningful. |
| ResetRasterScale(); |
| } |
| @@ -1217,6 +1227,7 @@ void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| } |
| state->Set("coverage_tiles", coverage_tiles.release()); |
| state->SetBoolean("is_using_lcd_text", is_using_lcd_text_); |
| + state->SetBoolean("using_gpu_rasterization", ShouldUseGpuRasterization()); |
| } |
| size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |