OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 high_res->set_resolution(HIGH_RESOLUTION); | 1016 high_res->set_resolution(HIGH_RESOLUTION); |
1017 | 1017 |
1018 SanityCheckTilingState(); | 1018 SanityCheckTilingState(); |
1019 } | 1019 } |
1020 | 1020 |
1021 bool PictureLayerImpl::ShouldAdjustRasterScale() const { | 1021 bool PictureLayerImpl::ShouldAdjustRasterScale() const { |
1022 if (was_screen_space_transform_animating_ != | 1022 if (was_screen_space_transform_animating_ != |
1023 draw_properties().screen_space_transform_is_animating) | 1023 draw_properties().screen_space_transform_is_animating) |
1024 return true; | 1024 return true; |
1025 | 1025 |
1026 if (draw_properties().screen_space_transform_is_animating && | |
1027 raster_contents_scale_ != ideal_contents_scale_ && | |
1028 ShouldAdjustRasterScaleDuringScaleAnimations()) | |
1029 return true; | |
1030 | |
1026 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 1031 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
1027 if (is_pinching && raster_page_scale_) { | 1032 if (is_pinching && raster_page_scale_) { |
1028 // We change our raster scale when it is: | 1033 // We change our raster scale when it is: |
1029 // - Higher than ideal (need a lower-res tiling available) | 1034 // - Higher than ideal (need a lower-res tiling available) |
1030 // - Too far from ideal (need a higher-res tiling available) | 1035 // - Too far from ideal (need a higher-res tiling available) |
1031 float ratio = ideal_page_scale_ / raster_page_scale_; | 1036 float ratio = ideal_page_scale_ / raster_page_scale_; |
1032 if (raster_page_scale_ > ideal_page_scale_ || | 1037 if (raster_page_scale_ > ideal_page_scale_ || |
1033 ratio > kMaxScaleRatioDuringPinch) | 1038 ratio > kMaxScaleRatioDuringPinch) |
1034 return true; | 1039 return true; |
1035 } | 1040 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch | 1115 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch |
1111 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; | 1116 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; |
1112 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); | 1117 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); |
1113 raster_page_scale_ = | 1118 raster_page_scale_ = |
1114 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1119 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
1115 } | 1120 } |
1116 | 1121 |
1117 raster_contents_scale_ = | 1122 raster_contents_scale_ = |
1118 std::max(raster_contents_scale_, MinimumContentsScale()); | 1123 std::max(raster_contents_scale_, MinimumContentsScale()); |
1119 | 1124 |
1120 // Since we're not re-rasterizing during animation, rasterize at the maximum | 1125 // If we're not re-rasterizing during animation, rasterize at the maximum |
1121 // scale that will occur during the animation, if the maximum scale is | 1126 // scale that will occur during the animation, if the maximum scale is |
1122 // known. However, to avoid excessive memory use, don't rasterize at a scale | 1127 // known. However, to avoid excessive memory use, don't rasterize at a scale |
1123 // at which this layer would become larger than the viewport. | 1128 // at which this layer would become larger than the viewport. |
1124 if (draw_properties().screen_space_transform_is_animating) { | 1129 if (draw_properties().screen_space_transform_is_animating && |
1130 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | |
1125 bool can_raster_at_maximum_scale = false; | 1131 bool can_raster_at_maximum_scale = false; |
1126 if (draw_properties().maximum_animation_contents_scale > 0.f) { | 1132 if (draw_properties().maximum_animation_contents_scale > 0.f) { |
1127 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize(gfx::ScaleSize( | 1133 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize(gfx::ScaleSize( |
1128 bounds(), draw_properties().maximum_animation_contents_scale)); | 1134 bounds(), draw_properties().maximum_animation_contents_scale)); |
1129 if (bounds_at_maximum_scale.GetArea() <= | 1135 if (bounds_at_maximum_scale.GetArea() <= |
1130 layer_tree_impl()->device_viewport_size().GetArea()) | 1136 layer_tree_impl()->device_viewport_size().GetArea()) |
1131 can_raster_at_maximum_scale = true; | 1137 can_raster_at_maximum_scale = true; |
1132 } | 1138 } |
1133 if (can_raster_at_maximum_scale) { | 1139 if (can_raster_at_maximum_scale) { |
1134 raster_contents_scale_ = | 1140 raster_contents_scale_ = |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1292 } | 1298 } |
1293 if (tilings_->num_tilings() == 0) | 1299 if (tilings_->num_tilings() == 0) |
1294 return; | 1300 return; |
1295 | 1301 |
1296 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1302 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1297 // tiling to mark its tiles as being required for activation. | 1303 // tiling to mark its tiles as being required for activation. |
1298 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1304 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
1299 #endif | 1305 #endif |
1300 } | 1306 } |
1301 | 1307 |
1308 bool PictureLayerImpl::ShouldAdjustRasterScaleDuringScaleAnimations() const { | |
1309 if (!layer_tree_impl()->use_gpu_rasterization()) | |
1310 return false; | |
1311 if (pile_->has_text()) | |
enne (OOO)
2014/08/20 18:15:49
Can you add some comments about why this is needed
ajuma
2014/08/20 18:51:29
Done.
| |
1312 return false; | |
1313 | |
1314 return true; | |
1315 } | |
1316 | |
1302 float PictureLayerImpl::MaximumTilingContentsScale() const { | 1317 float PictureLayerImpl::MaximumTilingContentsScale() const { |
1303 float max_contents_scale = MinimumContentsScale(); | 1318 float max_contents_scale = MinimumContentsScale(); |
1304 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1319 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1305 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1320 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1306 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 1321 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
1307 } | 1322 } |
1308 return max_contents_scale; | 1323 return max_contents_scale; |
1309 } | 1324 } |
1310 | 1325 |
1311 void PictureLayerImpl::UpdateIdealScales() { | 1326 void PictureLayerImpl::UpdateIdealScales() { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1697 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1712 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1698 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1713 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1699 return tiling_range.end - 1 - current_tiling_range_offset; | 1714 return tiling_range.end - 1 - current_tiling_range_offset; |
1700 } | 1715 } |
1701 } | 1716 } |
1702 NOTREACHED(); | 1717 NOTREACHED(); |
1703 return 0; | 1718 return 0; |
1704 } | 1719 } |
1705 | 1720 |
1706 } // namespace cc | 1721 } // namespace cc |
OLD | NEW |