Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 226283004: Rasterize at maximum scale for scale animations on CPU-rasterized layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename maximum_animation_scale_factor to maximum_animation_contents_scale Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/layers/picture_layer_impl.cc
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 7017d864c2ea5030090005425d7fa26726d91c70..7b4cdffb1a192cdf584439a6c8f1fc3f6f94bcd8 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -413,6 +413,7 @@ void PictureLayerImpl::CalculateContentsScale(
float ideal_contents_scale,
float device_scale_factor,
float page_scale_factor,
+ float maximum_animation_contents_scale,
bool animating_transform_to_screen,
float* contents_scale_x,
float* contents_scale_y,
@@ -455,7 +456,8 @@ void PictureLayerImpl::CalculateContentsScale(
ideal_device_scale_ = ideal_device_scale;
ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
- ManageTilings(animating_transform_to_screen);
+ ManageTilings(animating_transform_to_screen,
+ maximum_animation_contents_scale);
// The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
// There are (usually) several tilings at different scales. However, the
@@ -917,7 +919,8 @@ inline float PositiveRatio(float float1, float float2) {
} // namespace
-void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) {
+void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen,
+ float maximum_animation_contents_scale) {
DCHECK(ideal_contents_scale_);
DCHECK(ideal_page_scale_);
DCHECK(ideal_device_scale_);
@@ -947,7 +950,8 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) {
if (!layer_tree_impl()->device_viewport_valid_for_tile_management())
return;
- RecalculateRasterScales(animating_transform_to_screen);
+ RecalculateRasterScales(animating_transform_to_screen,
+ maximum_animation_contents_scale);
PictureLayerTiling* high_res = NULL;
PictureLayerTiling* low_res = NULL;
@@ -1000,7 +1004,7 @@ bool PictureLayerImpl::ShouldAdjustRasterScale(
// tree. This will allow CSS scale changes to get re-rastered at an
// appropriate rate.
- if (raster_source_scale_was_animating_ && !animating_transform_to_screen)
+ if (raster_source_scale_was_animating_ != animating_transform_to_screen)
return true;
if (animating_transform_to_screen &&
@@ -1048,7 +1052,8 @@ float PictureLayerImpl::SnappedContentsScale(float scale) {
}
void PictureLayerImpl::RecalculateRasterScales(
- bool animating_transform_to_screen) {
+ bool animating_transform_to_screen,
+ float maximum_animation_contents_scale) {
raster_device_scale_ = ideal_device_scale_;
raster_source_scale_ = ideal_source_scale_;
@@ -1072,11 +1077,18 @@ void PictureLayerImpl::RecalculateRasterScales(
raster_contents_scale_ =
std::max(raster_contents_scale_, MinimumContentsScale());
- // Don't allow animating CSS scales to drop below 1 if we're not
- // re-rasterizing during the animation.
+ // If we're not re-rasterizing during animation, rasterize at the maximum
+ // scale that will occur during the animation, if the maximum scale is
+ // known.
if (animating_transform_to_screen && !ShouldUseGpuRasterization()) {
- raster_contents_scale_ = std::max(
- raster_contents_scale_, 1.f * ideal_page_scale_ * ideal_device_scale_);
+ if (maximum_animation_contents_scale > 0.f) {
+ raster_contents_scale_ =
+ std::max(raster_contents_scale_, maximum_animation_contents_scale);
+ } else {
+ raster_contents_scale_ =
+ std::max(raster_contents_scale_,
+ 1.f * ideal_page_scale_ * ideal_device_scale_);
+ }
}
// If this layer would only create one tile at this content scale,

Powered by Google App Engine
This is Rietveld 408576698