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 fd4a85ae1caa3b84baf979acd5d26efc89d90fb5..8f0b51f76e109f1d265c698a0a219d16b7ee3c33 100644 |
| --- a/cc/layers/picture_layer_impl.cc |
| +++ b/cc/layers/picture_layer_impl.cc |
| @@ -33,10 +33,10 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
| is_mask_(false), |
| ideal_page_scale_(0.f), |
| ideal_device_scale_(0.f), |
| - ideal_source_scale_(0.f), |
| raster_page_scale_(0.f), |
| raster_device_scale_(0.f), |
| - raster_source_scale_(0.f), |
| + raster_contents_scale_(0.f), |
| + low_res_raster_contents_scale_(0.f), |
| raster_source_scale_was_animating_(false) { |
| } |
| @@ -78,7 +78,7 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { |
| layer_impl->raster_page_scale_ = raster_page_scale_; |
| layer_impl->raster_device_scale_ = raster_device_scale_; |
| - layer_impl->raster_source_scale_ = raster_source_scale_; |
| + layer_impl->raster_contents_scale_ = raster_contents_scale_; |
| } |
| @@ -282,18 +282,13 @@ void PictureLayerImpl::CalculateContentsScale( |
| float min_contents_scale = MinimumContentsScale(); |
| float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
| float min_device_scale = 1.f; |
| - float min_source_scale = |
| - min_contents_scale / min_page_scale / min_device_scale; |
| float ideal_page_scale = layer_tree_impl()->total_page_scale_factor(); |
| float ideal_device_scale = layer_tree_impl()->device_scale_factor(); |
| - float ideal_source_scale = |
| - ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
| ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
| ideal_page_scale_ = ideal_page_scale; |
| ideal_device_scale_ = ideal_device_scale; |
| - ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
| ManageTilings(animating_transform_to_screen); |
| @@ -391,7 +386,7 @@ void PictureLayerImpl::SyncFromActiveLayer() { |
| if (!DrawsContent()) { |
| raster_page_scale_ = 0; |
| raster_device_scale_ = 0; |
| - raster_source_scale_ = 0; |
| + raster_contents_scale_ = 0; |
| return; |
| } |
| @@ -405,7 +400,7 @@ void PictureLayerImpl::SyncFromActiveLayer() { |
| void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
| raster_page_scale_ = other->raster_page_scale_; |
| raster_device_scale_ = other->raster_device_scale_; |
| - raster_source_scale_ = other->raster_source_scale_; |
| + raster_contents_scale_ = other->raster_contents_scale_; |
| // Add synthetic invalidations for any recordings that were dropped. As |
| // tiles are updated to point to this new pile, this will force the dropping |
| @@ -488,30 +483,19 @@ bool PictureLayerImpl::AreVisibleResourcesReady() const { |
| const gfx::Rect& rect = visible_content_rect(); |
| - float raster_contents_scale = |
| - raster_page_scale_ * |
| - raster_device_scale_ * |
| - raster_source_scale_; |
| - |
| float min_acceptable_scale = |
| - std::min(raster_contents_scale, ideal_contents_scale_); |
| + std::min(raster_contents_scale_, ideal_contents_scale_); |
| - TreePriority tree_priority = |
| - layer_tree_impl()->tile_manager()->GlobalState().tree_priority; |
| + TreePriority tree_priority = layer_tree_impl()->tile_manager()->GlobalState().tree_priority; |
| bool should_force_uploads = |
| tree_priority != SMOOTHNESS_TAKES_PRIORITY && |
| layer_tree_impl()->animationRegistrar()-> |
| active_animation_controllers().empty(); |
| if (PictureLayerImpl* twin = ActiveTwin()) { |
| - float twin_raster_contents_scale = |
| - twin->raster_page_scale_ * |
| - twin->raster_device_scale_ * |
| - twin->raster_source_scale_; |
| - |
| min_acceptable_scale = std::min( |
| min_acceptable_scale, |
| - std::min(twin->ideal_contents_scale_, twin_raster_contents_scale)); |
| + std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_)); |
| } |
| Region missing_region = rect; |
| @@ -593,7 +577,6 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| DCHECK(ideal_contents_scale_); |
| DCHECK(ideal_page_scale_); |
| DCHECK(ideal_device_scale_); |
| - DCHECK(ideal_source_scale_); |
| if (pile_->recorded_region().IsEmpty()) |
| return; |
| @@ -603,13 +586,11 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| bool change_target_tiling = false; |
| - if (!raster_page_scale_ || !raster_device_scale_ || !raster_source_scale_) |
| + if (!raster_page_scale_ || !raster_device_scale_ || !raster_contents_scale_) |
|
enne (OOO)
2013/03/23 00:47:32
I think this is wrong. The previous check was if
Xianzhu
2013/03/25 16:05:07
I'm confused. How did the previous check deal with
danakj
2013/03/25 16:44:44
It seems like you're just getting rid of raster so
|
| change_target_tiling = true; |
| - // TODO(danakj): Adjust raster_source_scale_ closer to ideal_source_scale_ at |
| - // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending |
| - // tree. This will allow CSS scale changes to get re-rastered at an |
| - // appropriate rate. |
| + if (ShouldAdjustRasterSourceScale()) |
| + change_target_tiling = true; |
| if (is_active_layer) { |
| if (raster_source_scale_was_animating_ && !animating_transform_to_screen) |
| @@ -640,22 +621,16 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| raster_page_scale_ = ideal_page_scale_; |
| raster_device_scale_ = ideal_device_scale_; |
| - raster_source_scale_ = ideal_source_scale_; |
| - |
| - float raster_contents_scale; |
| - float low_res_raster_contents_scale; |
| - CalculateRasterContentsScale(animating_transform_to_screen, |
| - &raster_contents_scale, |
| - &low_res_raster_contents_scale); |
| + CalculateRasterContentsScale(animating_transform_to_screen); |
|
enne (OOO)
2013/03/23 00:47:32
I like the previous version where rather you had a
|
| PictureLayerTiling* high_res = NULL; |
| PictureLayerTiling* low_res = NULL; |
| for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| - if (tiling->contents_scale() == raster_contents_scale) |
| + if (tiling->contents_scale() == raster_contents_scale_) |
| high_res = tiling; |
| - if (tiling->contents_scale() == low_res_raster_contents_scale) |
| + if (tiling->contents_scale() == low_res_raster_contents_scale_) |
| low_res = tiling; |
| // Reset all tilings to non-ideal until the end of this function. |
| @@ -663,12 +638,12 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| } |
| if (!high_res) { |
| - high_res = AddTiling(raster_contents_scale); |
| - if (raster_contents_scale == low_res_raster_contents_scale) |
| + high_res = AddTiling(raster_contents_scale_); |
| + if (raster_contents_scale_ == low_res_raster_contents_scale_) |
| low_res = high_res; |
| } |
| if (!low_res && low_res != high_res) |
| - low_res = AddTiling(low_res_raster_contents_scale); |
| + low_res = AddTiling(low_res_raster_contents_scale_); |
| if (high_res) |
| high_res->set_resolution(HIGH_RESOLUTION); |
| @@ -676,22 +651,28 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| low_res->set_resolution(LOW_RESOLUTION); |
| } |
| +bool PictureLayerImpl::ShouldAdjustRasterSourceScale() const { |
| + // TODO(danakj): Adjust raster source scale closer to ideal source scale at |
| + // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending |
| + // tree. This will allow CSS scale changes to get re-rastered at an |
| + // appropriate rate. |
| + return false; |
| +} |
| + |
| void PictureLayerImpl::CalculateRasterContentsScale( |
| - bool animating_transform_to_screen, |
| - float* raster_contents_scale, |
| - float* low_res_raster_contents_scale) { |
| - *raster_contents_scale = ideal_contents_scale_; |
| + bool animating_transform_to_screen) { |
| + raster_contents_scale_ = ideal_contents_scale_; |
| // Don't allow animating CSS scales to drop below 1. |
| if (animating_transform_to_screen) { |
| - *raster_contents_scale = std::max( |
| - *raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_); |
| + raster_contents_scale_ = std::max( |
| + raster_contents_scale_, 1.f * ideal_page_scale_ * ideal_device_scale_); |
| } |
| float low_res_factor = |
| layer_tree_impl()->settings().low_res_contents_scale_factor; |
| - *low_res_raster_contents_scale = std::max( |
| - *raster_contents_scale * low_res_factor, |
| + low_res_raster_contents_scale_ = std::max( |
| + raster_contents_scale_ * low_res_factor, |
| MinimumContentsScale()); |
| } |
| @@ -699,27 +680,19 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
| std::vector<PictureLayerTiling*> used_tilings) { |
| DCHECK(layer_tree_impl()->IsActiveTree()); |
| - float raster_contents_scale = |
| - raster_page_scale_ * raster_device_scale_ * raster_source_scale_; |
| - |
| float min_acceptable_high_res_scale = std::min( |
| - raster_contents_scale, ideal_contents_scale_); |
| + raster_contents_scale_, ideal_contents_scale_); |
| float max_acceptable_high_res_scale = std::max( |
| - raster_contents_scale, ideal_contents_scale_); |
| + raster_contents_scale_, ideal_contents_scale_); |
| PictureLayerImpl* twin = PendingTwin(); |
| if (twin) { |
| - float twin_raster_contents_scale = |
| - twin->raster_page_scale_ * |
| - twin->raster_device_scale_ * |
| - twin->raster_source_scale_; |
| - |
| min_acceptable_high_res_scale = std::min( |
| min_acceptable_high_res_scale, |
| - std::min(twin_raster_contents_scale, twin->ideal_contents_scale_)); |
| + std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
| max_acceptable_high_res_scale = std::max( |
| max_acceptable_high_res_scale, |
| - std::max(twin_raster_contents_scale, twin->ideal_contents_scale_)); |
| + std::max(twin->raster_contents_scale_, twin->ideal_contents_scale_)); |
| } |
| float low_res_factor = |