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

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

Issue 1088773003: Reuse property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unrelated change Created 5 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 unified diff | Download patch
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 <set> 5 #include <set>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/trees/property_tree.h" 10 #include "cc/trees/property_tree.h"
(...skipping 14 matching lines...) Expand all
25 template <typename T> 25 template <typename T>
26 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) { 26 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) {
27 DCHECK_GT(nodes_.size(), 0u); 27 DCHECK_GT(nodes_.size(), 0u);
28 nodes_.push_back(tree_node); 28 nodes_.push_back(tree_node);
29 T& node = nodes_.back(); 29 T& node = nodes_.back();
30 node.parent_id = parent_id; 30 node.parent_id = parent_id;
31 node.id = static_cast<int>(nodes_.size()) - 1; 31 node.id = static_cast<int>(nodes_.size()) - 1;
32 return node.id; 32 return node.id;
33 } 33 }
34 34
35 template <typename T>
36 void PropertyTree<T>::clear() {
37 nodes_.clear();
38 nodes_.push_back(T());
39 back()->id = 0;
40 back()->parent_id = -1;
41 }
42
35 template class PropertyTree<TransformNode>; 43 template class PropertyTree<TransformNode>;
36 template class PropertyTree<ClipNode>; 44 template class PropertyTree<ClipNode>;
37 template class PropertyTree<OpacityNode>; 45 template class PropertyTree<OpacityNode>;
38 46
39 TransformNodeData::TransformNodeData() 47 TransformNodeData::TransformNodeData()
40 : target_id(-1), 48 : target_id(-1),
41 content_target_id(-1), 49 content_target_id(-1),
42 needs_local_transform_update(true), 50 needs_local_transform_update(true),
43 is_invertible(true), 51 is_invertible(true),
44 ancestors_are_invertible(true), 52 ancestors_are_invertible(true),
45 is_animated(false), 53 is_animated(false),
46 to_screen_is_animated(false), 54 to_screen_is_animated(false),
47 flattens_inherited_transform(false), 55 flattens_inherited_transform(false),
48 node_and_ancestors_are_flat(true), 56 node_and_ancestors_are_flat(true),
49 scrolls(false), 57 scrolls(false),
50 needs_sublayer_scale(false), 58 needs_sublayer_scale(false),
51 layer_scale_factor(1.0f) { 59 layer_scale_factor(1.0f) {
52 } 60 }
53 61
54 TransformNodeData::~TransformNodeData() { 62 TransformNodeData::~TransformNodeData() {
55 } 63 }
56 64
65 void TransformNodeData::update_post_local_transform(
66 const gfx::PointF& position,
67 const gfx::Point3F& transform_origin) {
68 post_local.MakeIdentity();
69 post_local.Scale(post_local_scale_factor, post_local_scale_factor);
70 post_local.Translate3d(
71 position.x() + parent_offset.x() + transform_origin.x(),
72 position.y() + parent_offset.y() + transform_origin.y(),
73 transform_origin.z());
74 }
75
57 ClipNodeData::ClipNodeData() : transform_id(-1), target_id(-1) { 76 ClipNodeData::ClipNodeData() : transform_id(-1), target_id(-1) {
58 } 77 }
59 78
60 bool TransformTree::ComputeTransform(int source_id, 79 bool TransformTree::ComputeTransform(int source_id,
61 int dest_id, 80 int dest_id,
62 gfx::Transform* transform) const { 81 gfx::Transform* transform) const {
63 transform->MakeIdentity(); 82 transform->MakeIdentity();
64 83
65 if (source_id == dest_id) 84 if (source_id == dest_id)
66 return true; 85 return true;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 node->data.to_target.Translate(translation.x(), translation.y()); 337 node->data.to_target.Translate(translation.x(), translation.y());
319 node->data.from_target.matrix().postTranslate(-translation.x(), 338 node->data.from_target.matrix().postTranslate(-translation.x(),
320 -translation.y(), 0); 339 -translation.y(), 0);
321 node->data.to_screen.Translate(translation.x(), translation.y()); 340 node->data.to_screen.Translate(translation.x(), translation.y());
322 node->data.from_screen.matrix().postTranslate(-translation.x(), 341 node->data.from_screen.matrix().postTranslate(-translation.x(),
323 -translation.y(), 0); 342 -translation.y(), 0);
324 343
325 node->data.scroll_snap = translation; 344 node->data.scroll_snap = translation;
326 } 345 }
327 346
347 PropertyTrees::PropertyTrees() : needs_rebuild(true) {
348 }
349
328 } // namespace cc 350 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698