| OLD | NEW |
| 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 #ifndef CC_TREES_PROPERTY_TREE_H_ | 5 #ifndef CC_TREES_PROPERTY_TREE_H_ |
| 6 #define CC_TREES_PROPERTY_TREE_H_ | 6 #define CC_TREES_PROPERTY_TREE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "ui/gfx/geometry/rect_f.h" | 12 #include "ui/gfx/geometry/rect_f.h" |
| 13 #include "ui/gfx/geometry/scroll_offset.h" | 13 #include "ui/gfx/geometry/scroll_offset.h" |
| 14 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 namespace proto { |
| 19 class ClipNodeData; |
| 20 class ClipTree; |
| 21 class EffectNodeData; |
| 22 class EffectTree; |
| 23 class PropertyTree; |
| 24 class PropertyTrees; |
| 25 class TranformNodeData; |
| 26 class TransformTree; |
| 27 class TreeNode; |
| 28 } |
| 29 |
| 18 template <typename T> | 30 template <typename T> |
| 19 struct CC_EXPORT TreeNode { | 31 struct CC_EXPORT TreeNode { |
| 20 TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} | 32 TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} |
| 21 int id; | 33 int id; |
| 22 int parent_id; | 34 int parent_id; |
| 23 int owner_id; | 35 int owner_id; |
| 24 T data; | 36 T data; |
| 37 |
| 38 void ToProtobuf(proto::TreeNode* proto) const; |
| 39 void FromProtobuf(const proto::TreeNode& proto); |
| 25 }; | 40 }; |
| 26 | 41 |
| 27 struct CC_EXPORT TransformNodeData { | 42 struct CC_EXPORT TransformNodeData { |
| 28 TransformNodeData(); | 43 TransformNodeData(); |
| 29 ~TransformNodeData(); | 44 ~TransformNodeData(); |
| 30 | 45 |
| 31 // The local transform information is combined to form to_parent (ignoring | 46 // The local transform information is combined to form to_parent (ignoring |
| 32 // snapping) as follows: | 47 // snapping) as follows: |
| 33 // | 48 // |
| 34 // to_parent = M_post_local * T_scroll * M_local * M_pre_local. | 49 // to_parent = M_post_local * T_scroll * M_local * M_pre_local. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 158 |
| 144 void set_to_parent(const gfx::Transform& transform) { | 159 void set_to_parent(const gfx::Transform& transform) { |
| 145 to_parent = transform; | 160 to_parent = transform; |
| 146 is_invertible = to_parent.IsInvertible(); | 161 is_invertible = to_parent.IsInvertible(); |
| 147 } | 162 } |
| 148 | 163 |
| 149 void update_pre_local_transform(const gfx::Point3F& transform_origin); | 164 void update_pre_local_transform(const gfx::Point3F& transform_origin); |
| 150 | 165 |
| 151 void update_post_local_transform(const gfx::PointF& position, | 166 void update_post_local_transform(const gfx::PointF& position, |
| 152 const gfx::Point3F& transform_origin); | 167 const gfx::Point3F& transform_origin); |
| 168 |
| 169 void ToProtobuf(proto::TreeNode* proto) const; |
| 170 void FromProtobuf(const proto::TreeNode& proto); |
| 153 }; | 171 }; |
| 154 | 172 |
| 155 typedef TreeNode<TransformNodeData> TransformNode; | 173 typedef TreeNode<TransformNodeData> TransformNode; |
| 156 | 174 |
| 157 struct CC_EXPORT ClipNodeData { | 175 struct CC_EXPORT ClipNodeData { |
| 158 ClipNodeData(); | 176 ClipNodeData(); |
| 159 | 177 |
| 160 // The clip rect that this node contributes, expressed in the space of its | 178 // The clip rect that this node contributes, expressed in the space of its |
| 161 // transform node. | 179 // transform node. |
| 162 gfx::RectF clip; | 180 gfx::RectF clip; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 // True if target surface needs to be drawn with a clip applied. | 209 // True if target surface needs to be drawn with a clip applied. |
| 192 bool target_is_clipped : 1; | 210 bool target_is_clipped : 1; |
| 193 | 211 |
| 194 // True if layers with this clip tree node need to be drawn with a clip | 212 // True if layers with this clip tree node need to be drawn with a clip |
| 195 // applied. | 213 // applied. |
| 196 bool layers_are_clipped : 1; | 214 bool layers_are_clipped : 1; |
| 197 bool layers_are_clipped_when_surfaces_disabled : 1; | 215 bool layers_are_clipped_when_surfaces_disabled : 1; |
| 198 | 216 |
| 199 // Nodes that correspond to unclipped surfaces disregard ancestor clips. | 217 // Nodes that correspond to unclipped surfaces disregard ancestor clips. |
| 200 bool resets_clip : 1; | 218 bool resets_clip : 1; |
| 219 |
| 220 void ToProtobuf(proto::TreeNode* proto) const; |
| 221 void FromProtobuf(const proto::TreeNode& proto); |
| 201 }; | 222 }; |
| 202 | 223 |
| 203 typedef TreeNode<ClipNodeData> ClipNode; | 224 typedef TreeNode<ClipNodeData> ClipNode; |
| 204 | 225 |
| 205 struct CC_EXPORT EffectNodeData { | 226 struct CC_EXPORT EffectNodeData { |
| 206 EffectNodeData(); | 227 EffectNodeData(); |
| 207 | 228 |
| 208 float opacity; | 229 float opacity; |
| 209 float screen_space_opacity; | 230 float screen_space_opacity; |
| 210 | 231 |
| 211 bool has_render_surface; | 232 bool has_render_surface; |
| 212 int transform_id; | 233 int transform_id; |
| 213 int clip_id; | 234 int clip_id; |
| 235 |
| 236 bool operator==(const EffectNodeData& other) const; |
| 237 |
| 238 void ToProtobuf(proto::TreeNode* proto) const; |
| 239 void FromProtobuf(const proto::TreeNode& proto); |
| 214 }; | 240 }; |
| 215 | 241 |
| 216 typedef TreeNode<EffectNodeData> EffectNode; | 242 typedef TreeNode<EffectNodeData> EffectNode; |
| 217 | 243 |
| 218 template <typename T> | 244 template <typename T> |
| 219 class CC_EXPORT PropertyTree { | 245 class CC_EXPORT PropertyTree { |
| 220 public: | 246 public: |
| 221 PropertyTree(); | 247 PropertyTree(); |
| 222 virtual ~PropertyTree(); | 248 virtual ~PropertyTree(); |
| 223 | 249 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 243 } | 269 } |
| 244 | 270 |
| 245 virtual void clear(); | 271 virtual void clear(); |
| 246 size_t size() const { return nodes_.size(); } | 272 size_t size() const { return nodes_.size(); } |
| 247 | 273 |
| 248 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } | 274 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } |
| 249 bool needs_update() const { return needs_update_; } | 275 bool needs_update() const { return needs_update_; } |
| 250 | 276 |
| 251 int next_available_id() const { return static_cast<int>(size()); } | 277 int next_available_id() const { return static_cast<int>(size()); } |
| 252 | 278 |
| 279 void ToProtobuf(proto::PropertyTree* proto) const; |
| 280 void FromProtobuf(const proto::PropertyTree& proto); |
| 281 |
| 253 private: | 282 private: |
| 254 // Copy and assign are permitted. This is how we do tree sync. | 283 // Copy and assign are permitted. This is how we do tree sync. |
| 255 std::vector<T> nodes_; | 284 std::vector<T> nodes_; |
| 256 | 285 |
| 257 bool needs_update_; | 286 bool needs_update_; |
| 258 }; | 287 }; |
| 259 | 288 |
| 260 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 289 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| 261 public: | 290 public: |
| 262 TransformTree(); | 291 TransformTree(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 gfx::Vector2dF outer_viewport_bounds_delta() const { | 370 gfx::Vector2dF outer_viewport_bounds_delta() const { |
| 342 return outer_viewport_bounds_delta_; | 371 return outer_viewport_bounds_delta_; |
| 343 } | 372 } |
| 344 | 373 |
| 345 void AddNodeAffectedByInnerViewportBoundsDelta(int node_id); | 374 void AddNodeAffectedByInnerViewportBoundsDelta(int node_id); |
| 346 void AddNodeAffectedByOuterViewportBoundsDelta(int node_id); | 375 void AddNodeAffectedByOuterViewportBoundsDelta(int node_id); |
| 347 | 376 |
| 348 bool HasNodesAffectedByInnerViewportBoundsDelta() const; | 377 bool HasNodesAffectedByInnerViewportBoundsDelta() const; |
| 349 bool HasNodesAffectedByOuterViewportBoundsDelta() const; | 378 bool HasNodesAffectedByOuterViewportBoundsDelta() const; |
| 350 | 379 |
| 380 void ToProtobuf(proto::TransformTree* proto) const; |
| 381 void FromProtobuf(const proto::TransformTree& proto); |
| 382 |
| 351 private: | 383 private: |
| 352 // Returns true iff the node at |desc_id| is a descendant of the node at | 384 // Returns true iff the node at |desc_id| is a descendant of the node at |
| 353 // |anc_id|. | 385 // |anc_id|. |
| 354 bool IsDescendant(int desc_id, int anc_id) const; | 386 bool IsDescendant(int desc_id, int anc_id) const; |
| 355 | 387 |
| 356 // Computes the combined transform between |source_id| and |dest_id| and | 388 // Computes the combined transform between |source_id| and |dest_id| and |
| 357 // returns false if the inverse of a singular transform was used. These two | 389 // returns false if the inverse of a singular transform was used. These two |
| 358 // nodes must be on the same ancestor chain. | 390 // nodes must be on the same ancestor chain. |
| 359 bool CombineTransformsBetween(int source_id, | 391 bool CombineTransformsBetween(int source_id, |
| 360 int dest_id, | 392 int dest_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 gfx::Vector2dF inner_viewport_bounds_delta_; | 425 gfx::Vector2dF inner_viewport_bounds_delta_; |
| 394 gfx::Vector2dF outer_viewport_bounds_delta_; | 426 gfx::Vector2dF outer_viewport_bounds_delta_; |
| 395 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; | 427 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; |
| 396 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; | 428 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; |
| 397 }; | 429 }; |
| 398 | 430 |
| 399 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { | 431 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
| 400 public: | 432 public: |
| 401 void SetViewportClip(gfx::RectF viewport_rect); | 433 void SetViewportClip(gfx::RectF viewport_rect); |
| 402 gfx::RectF ViewportClip(); | 434 gfx::RectF ViewportClip(); |
| 435 |
| 436 void ToProtobuf(proto::ClipTree* proto) const; |
| 437 void FromProtobuf(const proto::ClipTree& proto); |
| 403 }; | 438 }; |
| 404 | 439 |
| 405 class CC_EXPORT EffectTree final : public PropertyTree<EffectNode> { | 440 class CC_EXPORT EffectTree final : public PropertyTree<EffectNode> { |
| 406 public: | 441 public: |
| 407 void UpdateOpacities(int id); | 442 void UpdateOpacities(int id); |
| 443 |
| 444 void ToProtobuf(proto::EffectTree* proto) const; |
| 445 void FromProtobuf(const proto::EffectTree& proto); |
| 408 }; | 446 }; |
| 409 | 447 |
| 410 class CC_EXPORT PropertyTrees final { | 448 class CC_EXPORT PropertyTrees final { |
| 411 public: | 449 public: |
| 412 PropertyTrees(); | 450 PropertyTrees(); |
| 413 | 451 |
| 452 static PropertyTrees CreateFromProtobuf(const proto::PropertyTrees& proto); |
| 453 void ToProtobuf(proto::PropertyTrees* proto) const; |
| 454 |
| 414 TransformTree transform_tree; | 455 TransformTree transform_tree; |
| 415 EffectTree effect_tree; | 456 EffectTree effect_tree; |
| 416 ClipTree clip_tree; | 457 ClipTree clip_tree; |
| 417 bool needs_rebuild; | 458 bool needs_rebuild; |
| 418 bool non_root_surfaces_enabled; | 459 bool non_root_surfaces_enabled; |
| 419 int sequence_number; | 460 int sequence_number; |
| 420 }; | 461 }; |
| 421 | 462 |
| 422 } // namespace cc | 463 } // namespace cc |
| 423 | 464 |
| 424 #endif // CC_TREES_PROPERTY_TREE_H_ | 465 #endif // CC_TREES_PROPERTY_TREE_H_ |
| OLD | NEW |