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

Unified Diff: cc/trees/property_tree.cc

Issue 2266223002: cc: Compute draw transforms dynamically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error Created 4 years, 3 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
« no previous file with comments | « cc/trees/property_tree.h ('k') | tools/perf/benchmarks/draw_properties.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree.cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index 912226b25e525f0e9045e26070783bbe0cb7c5eb..25764dd7db51bb5c197d0354406f20bbc940f278 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -258,7 +258,8 @@ void TransformTree::UpdateTransforms(int id) {
UpdateSurfaceContentsScale(node);
UpdateAnimationProperties(node, parent_node);
UpdateSnapping(node);
- UpdateTargetSpaceTransform(node, target_node);
+ if (!property_trees()->verify_transform_tree_calculations)
+ UpdateTargetSpaceTransform(node, target_node);
UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node);
UpdateTransformChanged(node, parent_node, source_node);
UpdateNodeAndAncestorsAreAnimatedOrInvertible(node, parent_node);
@@ -315,19 +316,11 @@ void TransformTree::CombineTransformsBetween(int source_id,
dest->surface_contents_scale.y() != 0.f;
DCHECK(destination_has_non_zero_surface_contents_scale ||
!dest->ancestors_are_invertible);
- for (; current && current->id > dest_id; current = parent(current)) {
- if (destination_has_non_zero_surface_contents_scale &&
- TargetId(current->id) == dest_id &&
- ContentTargetId(current->id) == dest_id)
- break;
+ for (; current && current->id > dest_id; current = parent(current))
source_to_destination.push_back(current->id);
- }
gfx::Transform combined_transform;
if (current->id > dest_id) {
- // TODO(sunxd): Instead of using target space transform, only use to_parent
- // here when we fully implement computing draw transforms on demand.
- combined_transform = ToTarget(current->id, kInvalidNodeId);
jaydasika 2016/09/02 18:10:01 This is not behind a flag. Is it fine to remove it
sunxd 2016/09/02 18:13:10 Removing it does make performance suffer. I can ma
// The stored target space transform has surface contents scale baked in,
// but we need the unscaled transform.
combined_transform.matrix().postScale(
@@ -670,9 +663,7 @@ const gfx::Transform& TransformTree::FromTarget(int node_id,
DCHECK(static_cast<int>(cached_data_.size()) > node_id);
if (effect_id != kInvalidNodeId &&
property_trees()->verify_transform_tree_calculations) {
- const gfx::Transform& transform =
- property_trees()->GetDrawTransforms(node_id, effect_id).from_target;
- CHECK(transform.ApproximatelyEqual(cached_data_[node_id].from_target));
+ return property_trees()->GetDrawTransforms(node_id, effect_id).from_target;
}
return cached_data_[node_id].from_target;
}
@@ -688,12 +679,7 @@ const gfx::Transform& TransformTree::ToTarget(int node_id,
DCHECK(static_cast<int>(cached_data_.size()) > node_id);
if (effect_id != kInvalidNodeId &&
property_trees()->verify_transform_tree_calculations) {
- const gfx::Transform& transform =
- property_trees()->GetDrawTransforms(node_id, effect_id).to_target;
- if (property_trees()->non_root_surfaces_enabled)
- CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_target));
- else
- CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_screen));
+ return property_trees()->GetDrawTransforms(node_id, effect_id).to_target;
}
return cached_data_[node_id].to_target;
}
@@ -1946,8 +1932,7 @@ CombinedAnimationScale PropertyTrees::GetAnimationScales(
// Computing maximum animated scale in the presence of non-scale/translation
// transforms isn't supported.
bool failed_for_non_scale_or_translation =
- !transform_tree.Node(transform_node_id)
- ->to_parent.IsScaleOrTranslation();
+ !node->to_parent.IsScaleOrTranslation();
// We don't attempt to accumulate animation scale from multiple nodes with
// scale animations, because of the risk of significant overestimation. For
@@ -2137,10 +2122,8 @@ void PropertyTrees::ResetCachedData() {
cached_data_.property_tree_update_number = 0;
cached_data_.animation_scales = std::vector<AnimationScaleData>(
transform_tree.nodes().size(), AnimationScaleData());
- cached_data_.draw_transforms =
- std::vector<std::unordered_map<int, DrawTransformData>>(
- effect_tree.nodes().size(),
- std::unordered_map<int, DrawTransformData>());
+ cached_data_.draw_transforms = std::vector<std::map<int, DrawTransformData>>(
+ effect_tree.nodes().size(), std::map<int, DrawTransformData>());
}
void PropertyTrees::UpdateCachedNumber() {
@@ -2185,18 +2168,19 @@ bool PropertyTrees::ComputeTransformToTarget(int transform_id,
target_transform_id = effect_node->transform_id;
}
- bool success = transform_tree.ComputeTransform(
- transform_id, target_transform_id, transform);
+ bool success = true;
if (verify_transform_tree_calculations) {
- gfx::Transform to_target;
- to_target.ConcatTransform(
- GetDrawTransforms(transform_id, effect_id).to_target);
+ auto draw_transforms = GetDrawTransforms(transform_id, effect_id);
+ success = draw_transforms.invertible;
+ transform->ConcatTransform(draw_transforms.to_target);
if (effect_node->surface_contents_scale.x() != 0.f &&
effect_node->surface_contents_scale.y() != 0.f)
- to_target.matrix().postScale(
+ transform->matrix().postScale(
1.0f / effect_node->surface_contents_scale.x(),
1.0f / effect_node->surface_contents_scale.y(), 1.0f);
- DCHECK(to_target.ApproximatelyEqual(*transform));
+ } else {
+ success = transform_tree.ComputeTransform(transform_id, target_transform_id,
+ transform);
}
return success;
}
@@ -2223,16 +2207,16 @@ bool PropertyTrees::ComputeTransformFromTarget(
target_transform_id = effect_node->transform_id;
}
- bool success = transform_tree.ComputeTransform(target_transform_id,
- transform_id, transform);
+ bool success = true;
if (verify_transform_tree_calculations) {
auto draw_transforms = GetDrawTransforms(transform_id, effect_id);
- gfx::Transform from_target;
- from_target.ConcatTransform(draw_transforms.from_target);
- from_target.Scale(effect_node->surface_contents_scale.x(),
- effect_node->surface_contents_scale.y());
- DCHECK(from_target.ApproximatelyEqual(*transform) ||
- !draw_transforms.invertible);
+ success = draw_transforms.invertible;
+ transform->ConcatTransform(draw_transforms.from_target);
+ transform->Scale(effect_node->surface_contents_scale.x(),
+ effect_node->surface_contents_scale.y());
+ } else {
+ success = transform_tree.ComputeTransform(target_transform_id, transform_id,
+ transform);
}
return success;
}
« no previous file with comments | « cc/trees/property_tree.h ('k') | tools/perf/benchmarks/draw_properties.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698