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

Unified Diff: cc/trees/layer_tree_host_common.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: Created 6 years, 9 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/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 5d0c9afc1929f57e8fa69ab66dd5e2d0b3069ff4..dd4724d53de10b57fa1e92922b613c186299e15c 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -907,10 +907,12 @@ static inline void CalculateContentsScale(LayerType* layer,
float contents_scale,
float device_scale_factor,
float page_scale_factor,
+ float maximum_animation_scale_factor,
bool animating_transform_to_screen) {
layer->CalculateContentsScale(contents_scale,
device_scale_factor,
page_scale_factor,
+ maximum_animation_scale_factor,
animating_transform_to_screen,
&layer->draw_properties().contents_scale_x,
&layer->draw_properties().contents_scale_y,
@@ -922,6 +924,7 @@ static inline void CalculateContentsScale(LayerType* layer,
contents_scale,
device_scale_factor,
page_scale_factor,
+ maximum_animation_scale_factor,
animating_transform_to_screen,
&mask_layer->draw_properties().contents_scale_x,
&mask_layer->draw_properties().contents_scale_y,
@@ -935,6 +938,7 @@ static inline void CalculateContentsScale(LayerType* layer,
contents_scale,
device_scale_factor,
page_scale_factor,
+ maximum_animation_scale_factor,
animating_transform_to_screen,
&replica_mask_layer->draw_properties().contents_scale_x,
&replica_mask_layer->draw_properties().contents_scale_y,
@@ -948,11 +952,13 @@ static inline void UpdateLayerContentsScale(
float ideal_contents_scale,
float device_scale_factor,
float page_scale_factor,
+ float maximum_animation_scale_factor,
bool animating_transform_to_screen) {
CalculateContentsScale(layer,
ideal_contents_scale,
device_scale_factor,
page_scale_factor,
+ maximum_animation_scale_factor,
animating_transform_to_screen);
}
@@ -962,6 +968,7 @@ static inline void UpdateLayerContentsScale(
float ideal_contents_scale,
float device_scale_factor,
float page_scale_factor,
+ float maximum_animation_scale_factor,
bool animating_transform_to_screen) {
if (can_adjust_raster_scale) {
float ideal_raster_scale =
@@ -998,6 +1005,7 @@ static inline void UpdateLayerContentsScale(
contents_scale,
device_scale_factor,
page_scale_factor,
+ maximum_animation_scale_factor,
animating_transform_to_screen);
if (layer->content_bounds() != old_content_bounds ||
@@ -1165,6 +1173,11 @@ struct DataForRecursion {
// passed down the recursion to the children that actually use it.
gfx::Rect clip_rect_of_target_surface_in_target_space;
+ // The maximum factor by which currently running animations will be
+ // scaling-up the layer during their lifetime.
+ float maximum_animation_scale_factor;
+
+ bool ancestor_is_animating_scale;
bool ancestor_clips_subtree;
typename LayerType::RenderSurfaceType*
nearest_occlusion_immune_ancestor_surface;
@@ -1546,6 +1559,36 @@ static void CalculateDrawPropertiesInternal(
ApplyPositionAdjustment(layer, data_from_ancestor.fixed_container,
data_from_ancestor.scroll_compensation_matrix, &combined_transform);
+ bool layer_is_animating_scale =
+ !layer->layer_animation_controller()->HasOnlyTranslationTransforms();
+ data_for_children.ancestor_is_animating_scale =
+ layer_is_animating_scale ||
+ data_from_ancestor.ancestor_is_animating_scale;
+ float layer_maximum_animated_scale = 0.f;
+ float layer_animation_scale_factor = 1.f;
+ if (!globals.can_adjust_raster_scales ||
Ian Vollick 2014/04/05 02:24:33 Can we avoid the HasOnlyTranslationTransforms work
ajuma 2014/04/07 15:27:00 Done.
+ !combined_transform.IsScaleOrTranslation()) {
+ layer_animation_scale_factor = 0.f;
+ } else if (layer_is_animating_scale) {
+ if (data_from_ancestor.ancestor_is_animating_scale ||
Ian Vollick 2014/04/05 02:24:33 Might be worth mentioning why aren't we supporting
ajuma 2014/04/07 15:27:00 Done.
+ !layer->layer_animation_controller()->MaximumScale(
+ &layer_maximum_animated_scale)) {
+ layer_animation_scale_factor = 0.f;
+ } else {
+ gfx::Vector2dF layer_transform_scales =
+ MathUtil::ComputeTransform2dScaleComponents(layer->transform(), 0.f);
+ DCHECK(layer_transform_scales != gfx::Vector2dF());
+ layer_animation_scale_factor =
Ian Vollick 2014/04/05 02:24:33 This could really use a comment. It took me a whil
ajuma 2014/04/07 15:27:00 Done.
+ layer_maximum_animated_scale /
+ std::max(layer_transform_scales.x(), layer_transform_scales.y());
+ }
+ }
+ float combined_maximum_animation_scale_factor =
+ layer_animation_scale_factor *
+ data_from_ancestor.maximum_animation_scale_factor;
Ian Vollick 2014/04/05 02:24:33 If I'm following along correctly, the point of thi
ajuma 2014/04/07 15:27:00 Removed the multiplication.
+ data_for_children.maximum_animation_scale_factor =
+ combined_maximum_animation_scale_factor;
+
// Compute the 2d scale components of the transform hierarchy up to the target
// surface. From there, we can decide on a contents scale for the layer.
float layer_scale_factors = globals.device_scale_factor;
@@ -1566,8 +1609,10 @@ static void CalculateDrawPropertiesInternal(
globals.can_adjust_raster_scales,
ideal_contents_scale,
globals.device_scale_factor,
- data_from_ancestor.in_subtree_of_page_scale_application_layer ?
- globals.page_scale_factor : 1.f,
+ data_from_ancestor.in_subtree_of_page_scale_application_layer
+ ? globals.page_scale_factor
+ : 1.f,
+ combined_maximum_animation_scale_factor,
animating_transform_to_screen);
// The draw_transform that gets computed below is effectively the layer's
@@ -2155,6 +2200,8 @@ void LayerTreeHostCommon::CalculateDrawProperties(
data_for_recursion.clip_rect_in_target_space = device_viewport_rect;
data_for_recursion.clip_rect_of_target_surface_in_target_space =
device_viewport_rect;
+ data_for_recursion.maximum_animation_scale_factor = 1.f;
+ data_for_recursion.ancestor_is_animating_scale = false;
data_for_recursion.ancestor_clips_subtree = true;
data_for_recursion.nearest_occlusion_immune_ancestor_surface = NULL;
data_for_recursion.in_subtree_of_page_scale_application_layer = false;
@@ -2213,6 +2260,8 @@ void LayerTreeHostCommon::CalculateDrawProperties(
data_for_recursion.clip_rect_in_target_space = device_viewport_rect;
data_for_recursion.clip_rect_of_target_surface_in_target_space =
device_viewport_rect;
+ data_for_recursion.maximum_animation_scale_factor = 1.f;
+ data_for_recursion.ancestor_is_animating_scale = false;
data_for_recursion.ancestor_clips_subtree = true;
data_for_recursion.nearest_occlusion_immune_ancestor_surface = NULL;
data_for_recursion.in_subtree_of_page_scale_application_layer = false;

Powered by Google App Engine
This is Rietveld 408576698