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

Side by Side Diff: cc/trees/transform_node.h

Issue 2118993002: Detemplatize cc property nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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/scroll_node.cc ('k') | cc/trees/transform_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_TREES_TRANSFORM_NODE_H_
6 #define CC_TREES_TRANSFORM_NODE_H_
7
8 #include "cc/base/cc_export.h"
9 #include "ui/gfx/geometry/point_f.h"
10 #include "ui/gfx/geometry/scroll_offset.h"
11 #include "ui/gfx/transform.h"
12
13 namespace base {
14 namespace trace_event {
15 class TracedValue;
16 } // namespace trace_event
17 } // namespace base
18
19 namespace cc {
20
21 namespace proto {
22 class TransformCachedNodeData;
23 class TreeNode;
24 } // namespace proto
25
26 struct CC_EXPORT TransformNode {
27 TransformNode();
28 TransformNode(const TransformNode&);
29
30 int id;
31 int parent_id;
32 int owner_id;
33
34 // The local transform information is combined to form to_parent (ignoring
35 // snapping) as follows:
36 //
37 // to_parent = M_post_local * T_scroll * M_local * M_pre_local.
38 //
39 // The pre/post may seem odd when read LTR, but we multiply our points from
40 // the right, so the pre_local matrix affects the result "first". This lines
41 // up with the notions of pre/post used in skia and gfx::Transform.
42 //
43 // TODO(vollick): The values labeled with "will be moved..." take up a lot of
44 // space, but are only necessary for animated or scrolled nodes (otherwise
45 // we'll just use the baked to_parent). These values will be ultimately stored
46 // directly on the transform/scroll display list items when that's possible,
47 // or potentially in a scroll tree.
48 //
49 // TODO(vollick): will be moved when accelerated effects are implemented.
50 gfx::Transform pre_local;
51 gfx::Transform local;
52 gfx::Transform post_local;
53
54 gfx::Transform to_parent;
55
56 // This is the node with respect to which source_offset is defined. This will
57 // not be needed once layerization moves to cc, but is needed in order to
58 // efficiently update the transform tree for changes to position in the layer
59 // tree.
60 int source_node_id;
61
62 // This id determines which 3d rendering context the node is in. 0 is a
63 // special value and indicates that the node is not in any 3d rendering
64 // context.
65 int sorting_context_id;
66
67 // TODO(vollick): will be moved when accelerated effects are implemented.
68 bool needs_local_transform_update : 1;
69
70 bool node_and_ancestors_are_animated_or_invertible : 1;
71
72 bool is_invertible : 1;
73 bool ancestors_are_invertible : 1;
74
75 bool has_potential_animation : 1;
76 bool is_currently_animating : 1;
77 bool to_screen_is_potentially_animated : 1;
78 bool has_only_translation_animations : 1;
79
80 // Flattening, when needed, is only applied to a node's inherited transform,
81 // never to its local transform.
82 bool flattens_inherited_transform : 1;
83
84 // This is true if the to_parent transform at every node on the path to the
85 // root is flat.
86 bool node_and_ancestors_are_flat : 1;
87
88 // This is needed to know if a layer can use lcd text.
89 bool node_and_ancestors_have_only_integer_translation : 1;
90
91 bool scrolls : 1;
92
93 bool needs_sublayer_scale : 1;
94
95 // These are used to position nodes wrt the right or bottom of the inner or
96 // outer viewport.
97 bool affected_by_inner_viewport_bounds_delta_x : 1;
98 bool affected_by_inner_viewport_bounds_delta_y : 1;
99 bool affected_by_outer_viewport_bounds_delta_x : 1;
100 bool affected_by_outer_viewport_bounds_delta_y : 1;
101
102 // Layer scale factor is used as a fallback when we either cannot adjust
103 // raster scale or if the raster scale cannot be extracted from the screen
104 // space transform. For layers in the subtree of the page scale layer, the
105 // layer scale factor should include the page scale factor.
106 bool in_subtree_of_page_scale_layer : 1;
107
108 // We need to track changes to to_screen transform to compute the damage rect.
109 bool transform_changed : 1;
110
111 // TODO(vollick): will be moved when accelerated effects are implemented.
112 float post_local_scale_factor;
113
114 gfx::Vector2dF sublayer_scale;
115
116 // TODO(vollick): will be moved when accelerated effects are implemented.
117 gfx::ScrollOffset scroll_offset;
118
119 // We scroll snap where possible, but this means fixed-pos elements must be
120 // adjusted. This value stores the snapped amount for this purpose.
121 gfx::Vector2dF scroll_snap;
122
123 // TODO(vollick): will be moved when accelerated effects are implemented.
124 gfx::Vector2dF source_offset;
125 gfx::Vector2dF source_to_parent;
126
127 bool operator==(const TransformNode& other) const;
128
129 void set_to_parent(const gfx::Transform& transform) {
130 to_parent = transform;
131 is_invertible = to_parent.IsInvertible();
132 }
133
134 void update_pre_local_transform(const gfx::Point3F& transform_origin);
135
136 void update_post_local_transform(const gfx::PointF& position,
137 const gfx::Point3F& transform_origin);
138
139 void ToProtobuf(proto::TreeNode* proto) const;
140 void FromProtobuf(const proto::TreeNode& proto);
141
142 void AsValueInto(base::trace_event::TracedValue* value) const;
143 };
144
145 // TODO(sunxd): move this into PropertyTrees::cached_data_.
146 struct CC_EXPORT TransformCachedNodeData {
147 TransformCachedNodeData();
148 TransformCachedNodeData(const TransformCachedNodeData& other);
149 ~TransformCachedNodeData();
150
151 gfx::Transform from_target;
152 gfx::Transform to_target;
153 gfx::Transform from_screen;
154 gfx::Transform to_screen;
155 int target_id;
156 // This id is used for all content that draws into a render surface associated
157 // with this transform node.
158 int content_target_id;
159
160 bool operator==(const TransformCachedNodeData& other) const;
161
162 void ToProtobuf(proto::TransformCachedNodeData* proto) const;
163 void FromProtobuf(const proto::TransformCachedNodeData& proto);
164 };
165
166 } // namespace cc
167
168 #endif // CC_TREES_TRANSFORM_NODE_H_
OLDNEW
« no previous file with comments | « cc/trees/scroll_node.cc ('k') | cc/trees/transform_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698