OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
6 #include "base/trace_event/trace_event_argument.h" | 6 #include "base/trace_event/trace_event_argument.h" |
7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/trees/clip_node.h" | 9 #include "cc/trees/clip_node.h" |
10 #include "cc/trees/property_tree.h" | 10 #include "cc/trees/property_tree.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 ClipNode::ClipNode() | 14 ClipNode::ClipNode() |
15 : id(ClipTree::kInvalidNodeId), | 15 : id(ClipTree::kInvalidNodeId), |
16 parent_id(ClipTree::kInvalidNodeId), | 16 parent_id(ClipTree::kInvalidNodeId), |
17 owning_layer_id(Layer::INVALID_ID), | 17 owning_layer_id(Layer::INVALID_ID), |
18 clip_type(ClipType::NONE), | 18 clip_type(ClipType::APPLIES_LOCAL_CLIP), |
19 transform_id(TransformTree::kInvalidNodeId), | 19 transform_id(TransformTree::kInvalidNodeId) { |
20 target_transform_id(TransformTree::kInvalidNodeId), | 20 cached_clip_rects = std::vector<ClipRectData>(defaultCachedClipsSize); |
21 target_effect_id(EffectTree::kInvalidNodeId), | 21 } |
22 layer_clipping_uses_only_local_clip(false), | |
23 layers_are_clipped(false), | |
24 layers_are_clipped_when_surfaces_disabled(false), | |
25 resets_clip(false) {} | |
26 | 22 |
27 ClipNode::ClipNode(const ClipNode& other) | 23 ClipNode::ClipNode(const ClipNode& other) |
28 : id(other.id), | 24 : id(other.id), |
29 parent_id(other.parent_id), | 25 parent_id(other.parent_id), |
30 owning_layer_id(other.owning_layer_id), | 26 owning_layer_id(other.owning_layer_id), |
31 clip_type(other.clip_type), | 27 clip_type(other.clip_type), |
32 clip(other.clip), | 28 clip(other.clip), |
33 combined_clip_in_target_space(other.combined_clip_in_target_space), | 29 transform_id(other.transform_id) { |
34 clip_in_target_space(other.clip_in_target_space), | |
35 transform_id(other.transform_id), | |
36 target_transform_id(other.target_transform_id), | |
37 target_effect_id(other.target_effect_id), | |
38 layer_clipping_uses_only_local_clip( | |
39 other.layer_clipping_uses_only_local_clip), | |
40 layers_are_clipped(other.layers_are_clipped), | |
41 layers_are_clipped_when_surfaces_disabled( | |
42 other.layers_are_clipped_when_surfaces_disabled), | |
43 resets_clip(other.resets_clip) { | |
44 if (other.clip_expander) { | 30 if (other.clip_expander) { |
45 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); | 31 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); |
46 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); | 32 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); |
47 } | 33 } |
| 34 cached_clip_rects = other.cached_clip_rects; |
| 35 cached_accumulated_rect_in_screen_space = |
| 36 other.cached_accumulated_rect_in_screen_space; |
48 } | 37 } |
49 | 38 |
50 ClipNode& ClipNode::operator=(const ClipNode& other) { | 39 ClipNode& ClipNode::operator=(const ClipNode& other) { |
51 id = other.id; | 40 id = other.id; |
52 parent_id = other.parent_id; | 41 parent_id = other.parent_id; |
53 owning_layer_id = other.owning_layer_id; | 42 owning_layer_id = other.owning_layer_id; |
54 clip_type = other.clip_type; | 43 clip_type = other.clip_type; |
55 clip = other.clip; | 44 clip = other.clip; |
56 combined_clip_in_target_space = other.combined_clip_in_target_space; | |
57 clip_in_target_space = other.clip_in_target_space; | |
58 transform_id = other.transform_id; | 45 transform_id = other.transform_id; |
59 target_transform_id = other.target_transform_id; | |
60 target_effect_id = other.target_effect_id; | |
61 layer_clipping_uses_only_local_clip = | |
62 other.layer_clipping_uses_only_local_clip; | |
63 layers_are_clipped = other.layers_are_clipped; | |
64 layers_are_clipped_when_surfaces_disabled = | |
65 other.layers_are_clipped_when_surfaces_disabled; | |
66 resets_clip = other.resets_clip; | |
67 | 46 |
68 if (other.clip_expander) { | 47 if (other.clip_expander) { |
69 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); | 48 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); |
70 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); | 49 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); |
71 } else { | 50 } else { |
72 clip_expander.reset(); | 51 clip_expander.reset(); |
73 } | 52 } |
74 | 53 cached_clip_rects = other.cached_clip_rects; |
| 54 cached_accumulated_rect_in_screen_space = |
| 55 other.cached_accumulated_rect_in_screen_space; |
75 return *this; | 56 return *this; |
76 } | 57 } |
77 | 58 |
78 ClipNode::~ClipNode() {} | 59 ClipNode::~ClipNode() {} |
79 | 60 |
80 bool ClipNode::operator==(const ClipNode& other) const { | 61 bool ClipNode::operator==(const ClipNode& other) const { |
81 if (clip_expander && other.clip_expander && | 62 if (clip_expander && other.clip_expander && |
82 *clip_expander != *other.clip_expander) | 63 *clip_expander != *other.clip_expander) |
83 return false; | 64 return false; |
84 if ((clip_expander && !other.clip_expander) || | 65 if ((clip_expander && !other.clip_expander) || |
85 (!clip_expander && other.clip_expander)) | 66 (!clip_expander && other.clip_expander)) |
86 return false; | 67 return false; |
87 return id == other.id && parent_id == other.parent_id && | 68 return id == other.id && parent_id == other.parent_id && |
88 owning_layer_id == other.owning_layer_id && | 69 owning_layer_id == other.owning_layer_id && |
89 clip_type == other.clip_type && clip == other.clip && | 70 clip_type == other.clip_type && clip == other.clip && |
90 combined_clip_in_target_space == other.combined_clip_in_target_space && | 71 transform_id == other.transform_id; |
91 clip_in_target_space == other.clip_in_target_space && | |
92 transform_id == other.transform_id && | |
93 target_transform_id == other.target_transform_id && | |
94 target_effect_id == other.target_effect_id && | |
95 layer_clipping_uses_only_local_clip == | |
96 other.layer_clipping_uses_only_local_clip && | |
97 layers_are_clipped == other.layers_are_clipped && | |
98 layers_are_clipped_when_surfaces_disabled == | |
99 other.layers_are_clipped_when_surfaces_disabled && | |
100 resets_clip == other.resets_clip; | |
101 } | 72 } |
102 | 73 |
103 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { | 74 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { |
104 value->SetInteger("id", id); | 75 value->SetInteger("id", id); |
105 value->SetInteger("parent_id", parent_id); | 76 value->SetInteger("parent_id", parent_id); |
106 value->SetInteger("owning_layer_id", owning_layer_id); | 77 value->SetInteger("owning_layer_id", owning_layer_id); |
107 value->SetInteger("clip_type", static_cast<int>(clip_type)); | 78 value->SetInteger("clip_type", static_cast<int>(clip_type)); |
108 MathUtil::AddToTracedValue("clip", clip, value); | 79 MathUtil::AddToTracedValue("clip", clip, value); |
109 value->SetInteger("transform_id", transform_id); | 80 value->SetInteger("transform_id", transform_id); |
110 value->SetInteger("target_transform_id", target_transform_id); | |
111 value->SetInteger("target_effect_id", target_effect_id); | |
112 value->SetBoolean("layer_clipping_uses_only_local_clip", | |
113 layer_clipping_uses_only_local_clip); | |
114 value->SetBoolean("layers_are_clipped", layers_are_clipped); | |
115 value->SetBoolean("layers_are_clipped_when_surfaces_disabled", | |
116 layers_are_clipped_when_surfaces_disabled); | |
117 value->SetBoolean("resets_clip", resets_clip); | |
118 } | 81 } |
119 | 82 |
120 } // namespace cc | 83 } // namespace cc |
OLD | NEW |