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>(1); |
weiliangc
2017/03/14 22:04:29
Avoid raw number.
jaydasika
2017/03/16 20:33:30
Done.
| |
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 accumulated_rect_in_screen_space = other.accumulated_rect_in_screen_space; | |
48 } | 36 } |
49 | 37 |
50 ClipNode& ClipNode::operator=(const ClipNode& other) { | 38 ClipNode& ClipNode::operator=(const ClipNode& other) { |
51 id = other.id; | 39 id = other.id; |
52 parent_id = other.parent_id; | 40 parent_id = other.parent_id; |
53 owning_layer_id = other.owning_layer_id; | 41 owning_layer_id = other.owning_layer_id; |
54 clip_type = other.clip_type; | 42 clip_type = other.clip_type; |
55 clip = other.clip; | 43 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; | 44 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 | 45 |
68 if (other.clip_expander) { | 46 if (other.clip_expander) { |
69 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); | 47 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP); |
70 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); | 48 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander); |
71 } else { | 49 } else { |
72 clip_expander.reset(); | 50 clip_expander.reset(); |
73 } | 51 } |
74 | 52 cached_clip_rects = other.cached_clip_rects; |
53 accumulated_rect_in_screen_space = other.accumulated_rect_in_screen_space; | |
75 return *this; | 54 return *this; |
76 } | 55 } |
77 | 56 |
78 ClipNode::~ClipNode() {} | 57 ClipNode::~ClipNode() {} |
79 | 58 |
80 bool ClipNode::operator==(const ClipNode& other) const { | 59 bool ClipNode::operator==(const ClipNode& other) const { |
81 if (clip_expander && other.clip_expander && | 60 if (clip_expander && other.clip_expander && |
82 *clip_expander != *other.clip_expander) | 61 *clip_expander != *other.clip_expander) |
83 return false; | 62 return false; |
84 if ((clip_expander && !other.clip_expander) || | 63 if ((clip_expander && !other.clip_expander) || |
85 (!clip_expander && other.clip_expander)) | 64 (!clip_expander && other.clip_expander)) |
86 return false; | 65 return false; |
87 return id == other.id && parent_id == other.parent_id && | 66 return id == other.id && parent_id == other.parent_id && |
88 owning_layer_id == other.owning_layer_id && | 67 owning_layer_id == other.owning_layer_id && |
89 clip_type == other.clip_type && clip == other.clip && | 68 clip_type == other.clip_type && clip == other.clip && |
90 combined_clip_in_target_space == other.combined_clip_in_target_space && | 69 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 } | 70 } |
102 | 71 |
103 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { | 72 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { |
104 value->SetInteger("id", id); | 73 value->SetInteger("id", id); |
105 value->SetInteger("parent_id", parent_id); | 74 value->SetInteger("parent_id", parent_id); |
106 value->SetInteger("owning_layer_id", owning_layer_id); | 75 value->SetInteger("owning_layer_id", owning_layer_id); |
107 value->SetInteger("clip_type", static_cast<int>(clip_type)); | 76 value->SetInteger("clip_type", static_cast<int>(clip_type)); |
108 MathUtil::AddToTracedValue("clip", clip, value); | 77 MathUtil::AddToTracedValue("clip", clip, value); |
109 value->SetInteger("transform_id", transform_id); | 78 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 } | 79 } |
119 | 80 |
120 } // namespace cc | 81 } // namespace cc |
OLD | NEW |