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

Side by Side Diff: cc/trees/property_tree.cc

Issue 2191983002: cc : Use dynamically calculated target space transforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 1.0 / effect_node->surface_contents_scale.y()); 1979 1.0 / effect_node->surface_contents_scale.y());
1980 return screen_space_transform; 1980 return screen_space_transform;
1981 } 1981 }
1982 1982
1983 bool PropertyTrees::ComputeTransformToTarget(int transform_id, 1983 bool PropertyTrees::ComputeTransformToTarget(int transform_id,
1984 int effect_id, 1984 int effect_id,
1985 gfx::Transform* transform) const { 1985 gfx::Transform* transform) const {
1986 transform->MakeIdentity(); 1986 transform->MakeIdentity();
1987 1987
1988 int target_transform_id; 1988 int target_transform_id;
1989 const EffectNode* effect_node = effect_tree.Node(effect_id);
1989 if (effect_id == EffectTree::kInvalidNodeId) { 1990 if (effect_id == EffectTree::kInvalidNodeId) {
1990 // This can happen when PaintArtifactCompositor builds property trees as 1991 // This can happen when PaintArtifactCompositor builds property trees as
1991 // it doesn't set effect ids on clip nodes. We want to compute transform 1992 // it doesn't set effect ids on clip nodes. We want to compute transform
1992 // to the root in this case. 1993 // to the root in this case.
1993 target_transform_id = TransformTree::kRootNodeId; 1994 target_transform_id = TransformTree::kRootNodeId;
1994 } else { 1995 } else {
1995 const EffectNode* effect_node = effect_tree.Node(effect_id);
1996 DCHECK(effect_node->has_render_surface || 1996 DCHECK(effect_node->has_render_surface ||
1997 effect_node->id == EffectTree::kRootNodeId); 1997 effect_node->id == EffectTree::kRootNodeId);
1998 target_transform_id = effect_node->transform_id; 1998 target_transform_id = effect_node->transform_id;
1999 } 1999 }
2000 2000
2001 return transform_tree.ComputeTransform(transform_id, target_transform_id, 2001 bool success = transform_tree.ComputeTransform(
2002 transform); 2002 transform_id, target_transform_id, transform);
2003 if (verify_transform_tree_calculations &&
2004 transform_id > target_transform_id) {
2005 gfx::Transform to_target;
2006 to_target.ConcatTransform(
2007 GetDrawTransforms(transform_id, effect_id).to_target);
2008 if (effect_node->surface_contents_scale.x() != 0.f &&
2009 effect_node->surface_contents_scale.y() != 0.f)
2010 to_target.matrix().postScale(
2011 1.0f / effect_node->surface_contents_scale.x(),
2012 1.0f / effect_node->surface_contents_scale.y(), 1.0f);
2013 DCHECK(to_target.ApproximatelyEqual(*transform));
2014 }
2015 return success;
2003 } 2016 }
2004 2017
2005 bool PropertyTrees::ComputeTransformFromTarget( 2018 bool PropertyTrees::ComputeTransformFromTarget(
2006 int transform_id, 2019 int transform_id,
2007 int effect_id, 2020 int effect_id,
2008 gfx::Transform* transform) const { 2021 gfx::Transform* transform) const {
2009 transform->MakeIdentity(); 2022 transform->MakeIdentity();
2010 2023
2011 int target_transform_id; 2024 int target_transform_id;
2025 const EffectNode* effect_node = effect_tree.Node(effect_id);
2012 if (effect_id == EffectTree::kInvalidNodeId) { 2026 if (effect_id == EffectTree::kInvalidNodeId) {
2013 // This can happen when PaintArtifactCompositor builds property trees as 2027 // This can happen when PaintArtifactCompositor builds property trees as
2014 // it doesn't set effect ids on clip nodes. We want to compute transform 2028 // it doesn't set effect ids on clip nodes. We want to compute transform
2015 // to the root in this case. 2029 // to the root in this case.
2016 target_transform_id = TransformTree::kRootNodeId; 2030 target_transform_id = TransformTree::kRootNodeId;
2017 } else { 2031 } else {
2018 const EffectNode* effect_node = effect_tree.Node(effect_id);
2019 DCHECK(effect_node->has_render_surface || 2032 DCHECK(effect_node->has_render_surface ||
2020 effect_node->id == EffectTree::kRootNodeId); 2033 effect_node->id == EffectTree::kRootNodeId);
2021 target_transform_id = effect_node->transform_id; 2034 target_transform_id = effect_node->transform_id;
2022 } 2035 }
2023 2036
2024 return transform_tree.ComputeTransform(target_transform_id, transform_id, 2037 bool success = transform_tree.ComputeTransform(target_transform_id,
2025 transform); 2038 transform_id, transform);
2039 if (verify_transform_tree_calculations &&
2040 transform_id < target_transform_id) {
2041 auto draw_transforms = GetDrawTransforms(transform_id, effect_id);
2042 gfx::Transform from_target;
2043 from_target.ConcatTransform(draw_transforms.from_target);
2044 from_target.Scale(effect_node->surface_contents_scale.x(),
2045 effect_node->surface_contents_scale.y());
2046 DCHECK(from_target.ApproximatelyEqual(*transform) ||
2047 !draw_transforms.invertible);
2048 }
2049 return success;
2026 } 2050 }
2027 2051
2028 } // namespace cc 2052 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698