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: . 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 if (!verify_transform_tree_calculations || transform_id < target_transform_id)
2002 transform); 2002 return transform_tree.ComputeTransform(transform_id, target_transform_id,
2003 transform);
2004 transform->ConcatTransform(
2005 GetDrawTransforms(transform_id, effect_id).to_target);
2006 if (effect_node->surface_contents_scale.x() != 0.f &&
2007 effect_node->surface_contents_scale.y() != 0.f)
2008 transform->matrix().postScale(
2009 1.0f / effect_node->surface_contents_scale.x(),
2010 1.0f / effect_node->surface_contents_scale.y(), 1.0f);
2011 #if DCHECK_IS_ON()
2012 gfx::Transform expected;
2013 transform_tree.ComputeTransform(transform_id, target_transform_id, &expected);
2014 DCHECK(expected.ApproximatelyEqual(*transform));
ajuma 2016/07/29 18:03:18 Since this has a relatively large tolerance for er
jaydasika 2016/07/29 18:20:16 Done.
2015 #endif
2016 return true;
2003 } 2017 }
2004 2018
2005 bool PropertyTrees::ComputeTransformFromTarget( 2019 bool PropertyTrees::ComputeTransformFromTarget(
2006 int transform_id, 2020 int transform_id,
2007 int effect_id, 2021 int effect_id,
2008 gfx::Transform* transform) const { 2022 gfx::Transform* transform) const {
2009 transform->MakeIdentity(); 2023 transform->MakeIdentity();
2010 2024
2011 int target_transform_id; 2025 int target_transform_id;
2026 const EffectNode* effect_node = effect_tree.Node(effect_id);
2012 if (effect_id == EffectTree::kInvalidNodeId) { 2027 if (effect_id == EffectTree::kInvalidNodeId) {
2013 // This can happen when PaintArtifactCompositor builds property trees as 2028 // This can happen when PaintArtifactCompositor builds property trees as
2014 // it doesn't set effect ids on clip nodes. We want to compute transform 2029 // it doesn't set effect ids on clip nodes. We want to compute transform
2015 // to the root in this case. 2030 // to the root in this case.
2016 target_transform_id = TransformTree::kRootNodeId; 2031 target_transform_id = TransformTree::kRootNodeId;
2017 } else { 2032 } else {
2018 const EffectNode* effect_node = effect_tree.Node(effect_id);
2019 DCHECK(effect_node->has_render_surface || 2033 DCHECK(effect_node->has_render_surface ||
2020 effect_node->id == EffectTree::kRootNodeId); 2034 effect_node->id == EffectTree::kRootNodeId);
2021 target_transform_id = effect_node->transform_id; 2035 target_transform_id = effect_node->transform_id;
2022 } 2036 }
2023 2037
2024 return transform_tree.ComputeTransform(target_transform_id, transform_id, 2038 if (!verify_transform_tree_calculations || transform_id > target_transform_id)
2025 transform); 2039 return transform_tree.ComputeTransform(target_transform_id, transform_id,
2040 transform);
2041
2042 auto draw_transforms = GetDrawTransforms(transform_id, effect_id);
2043 transform->ConcatTransform(draw_transforms.from_target);
2044 transform->Scale(effect_node->surface_contents_scale.x(),
2045 effect_node->surface_contents_scale.y());
ajuma 2016/07/29 18:03:18 Same comment here about setting |transform| to the
jaydasika 2016/07/29 18:20:16 Done.
2046 #if DCHECK_IS_ON()
2047 gfx::Transform expected;
2048 transform_tree.ComputeTransform(target_transform_id, transform_id, &expected);
2049 DCHECK(expected.ApproximatelyEqual(*transform) ||
2050 !draw_transforms.invertible);
2051 #endif
2052 return draw_transforms.invertible;
2026 } 2053 }
2027 2054
2028 } // namespace cc 2055 } // 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