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

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

Issue 2423483003: cc: Make visible rect computation aware of pixel-moving filters (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 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/trace_event/trace_event_argument.h" 6 #include "base/trace_event/trace_event_argument.h"
6 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
7 #include "cc/proto/cc_conversions.h" 8 #include "cc/proto/cc_conversions.h"
8 #include "cc/proto/gfx_conversions.h" 9 #include "cc/proto/gfx_conversions.h"
9 #include "cc/proto/property_tree.pb.h" 10 #include "cc/proto/property_tree.pb.h"
10 #include "cc/trees/clip_node.h" 11 #include "cc/trees/clip_node.h"
12 #include "cc/trees/property_tree.h"
11 13
12 namespace cc { 14 namespace cc {
13 15
14 ClipNode::ClipNode() 16 ClipNode::ClipNode()
15 : id(-1), 17 : id(-1),
16 parent_id(-1), 18 parent_id(-1),
17 owner_id(-1), 19 owner_id(-1),
18 clip_type(ClipType::NONE), 20 clip_type(ClipType::NONE),
19 transform_id(-1), 21 transform_id(-1),
20 target_transform_id(-1), 22 target_transform_id(-1),
21 target_effect_id(-1), 23 target_effect_id(-1),
22 layer_clipping_uses_only_local_clip(false), 24 layer_clipping_uses_only_local_clip(false),
23 target_is_clipped(false), 25 target_is_clipped(false),
24 layers_are_clipped(false), 26 layers_are_clipped(false),
25 layers_are_clipped_when_surfaces_disabled(false), 27 layers_are_clipped_when_surfaces_disabled(false),
26 resets_clip(false) {} 28 resets_clip(false) {}
27 29
28 ClipNode::ClipNode(const ClipNode& other) = default; 30 ClipNode::ClipNode(const ClipNode& other)
31 : id(other.id),
32 parent_id(other.parent_id),
33 owner_id(other.owner_id),
34 clip_type(other.clip_type),
35 clip(other.clip),
36 combined_clip_in_target_space(other.combined_clip_in_target_space),
37 clip_in_target_space(other.clip_in_target_space),
38 transform_id(other.transform_id),
39 target_transform_id(other.target_transform_id),
40 target_effect_id(other.target_effect_id),
41 layer_clipping_uses_only_local_clip(
42 other.layer_clipping_uses_only_local_clip),
43 target_is_clipped(other.target_is_clipped),
44 layers_are_clipped(other.layers_are_clipped),
45 layers_are_clipped_when_surfaces_disabled(
46 other.layers_are_clipped_when_surfaces_disabled),
47 resets_clip(other.resets_clip) {
48 if (other.clip_expander) {
49 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP);
50 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander);
51 }
52 }
53
54 ClipNode& ClipNode::operator=(const ClipNode& other) {
55 id = other.id;
56 parent_id = other.parent_id;
57 owner_id = other.owner_id;
58 clip_type = other.clip_type;
59 clip = other.clip;
60 combined_clip_in_target_space = other.combined_clip_in_target_space;
61 clip_in_target_space = other.clip_in_target_space;
62 transform_id = other.transform_id;
63 target_transform_id = other.target_transform_id;
64 target_effect_id = other.target_effect_id;
65 layer_clipping_uses_only_local_clip =
66 other.layer_clipping_uses_only_local_clip;
67 target_is_clipped = other.target_is_clipped;
68 layers_are_clipped = other.layers_are_clipped;
69 layers_are_clipped_when_surfaces_disabled =
70 other.layers_are_clipped_when_surfaces_disabled;
71 resets_clip = other.resets_clip;
72
73 if (other.clip_expander) {
74 DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP);
75 clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander);
76 } else {
77 clip_expander.reset();
78 }
79
80 return *this;
81 }
82
83 ClipNode::~ClipNode() {}
29 84
30 bool ClipNode::operator==(const ClipNode& other) const { 85 bool ClipNode::operator==(const ClipNode& other) const {
86 if (clip_expander && other.clip_expander &&
87 *clip_expander != *other.clip_expander)
88 return false;
89 if ((clip_expander && !other.clip_expander) ||
90 (!clip_expander && other.clip_expander))
91 return false;
31 return id == other.id && parent_id == other.parent_id && 92 return id == other.id && parent_id == other.parent_id &&
32 owner_id == other.owner_id && clip_type == other.clip_type && 93 owner_id == other.owner_id && clip_type == other.clip_type &&
33 clip == other.clip && 94 clip == other.clip &&
34 combined_clip_in_target_space == other.combined_clip_in_target_space && 95 combined_clip_in_target_space == other.combined_clip_in_target_space &&
35 clip_in_target_space == other.clip_in_target_space && 96 clip_in_target_space == other.clip_in_target_space &&
36 transform_id == other.transform_id && 97 transform_id == other.transform_id &&
37 target_transform_id == other.target_transform_id && 98 target_transform_id == other.target_transform_id &&
38 target_effect_id == other.target_effect_id && 99 target_effect_id == other.target_effect_id &&
39 layer_clipping_uses_only_local_clip == 100 layer_clipping_uses_only_local_clip ==
40 other.layer_clipping_uses_only_local_clip && 101 other.layer_clipping_uses_only_local_clip &&
41 target_is_clipped == other.target_is_clipped && 102 target_is_clipped == other.target_is_clipped &&
42 layers_are_clipped == other.layers_are_clipped && 103 layers_are_clipped == other.layers_are_clipped &&
43 layers_are_clipped_when_surfaces_disabled == 104 layers_are_clipped_when_surfaces_disabled ==
44 other.layers_are_clipped_when_surfaces_disabled && 105 other.layers_are_clipped_when_surfaces_disabled &&
45 resets_clip == other.resets_clip; 106 resets_clip == other.resets_clip;
46 } 107 }
47 108
48 void ClipNode::ToProtobuf(proto::TreeNode* proto) const { 109 void ClipNode::ToProtobuf(proto::TreeNode* proto) const {
49 proto->set_id(id); 110 proto->set_id(id);
50 proto->set_parent_id(parent_id); 111 proto->set_parent_id(parent_id);
51 proto->set_owner_id(owner_id); 112 proto->set_owner_id(owner_id);
52 113
53 DCHECK(!proto->has_clip_node_data()); 114 DCHECK(!proto->has_clip_node_data());
54 proto::ClipNodeData* data = proto->mutable_clip_node_data(); 115 proto::ClipNodeData* data = proto->mutable_clip_node_data();
55 116
56 data->set_clip_type(ClipNodeTypeToProto(clip_type)); 117 data->set_clip_type(ClipNodeTypeToProto(clip_type));
118 if (clip_type == ClipType::EXPANDS_CLIP)
119 data->set_clip_expander_effect_id(clip_expander->target_effect_id());
120 else
121 data->set_clip_expander_effect_id(EffectTree::kInvalidNodeId);
57 122
58 RectFToProto(clip, data->mutable_clip()); 123 RectFToProto(clip, data->mutable_clip());
59 RectFToProto(combined_clip_in_target_space, 124 RectFToProto(combined_clip_in_target_space,
60 data->mutable_combined_clip_in_target_space()); 125 data->mutable_combined_clip_in_target_space());
61 RectFToProto(clip_in_target_space, data->mutable_clip_in_target_space()); 126 RectFToProto(clip_in_target_space, data->mutable_clip_in_target_space());
62 127
63 data->set_transform_id(transform_id); 128 data->set_transform_id(transform_id);
64 data->set_target_transform_id(target_transform_id); 129 data->set_target_transform_id(target_transform_id);
65 data->set_target_effect_id(target_effect_id); 130 data->set_target_effect_id(target_effect_id);
66 data->set_layer_clipping_uses_only_local_clip( 131 data->set_layer_clipping_uses_only_local_clip(
67 layer_clipping_uses_only_local_clip); 132 layer_clipping_uses_only_local_clip);
68 data->set_target_is_clipped(target_is_clipped); 133 data->set_target_is_clipped(target_is_clipped);
69 data->set_layers_are_clipped(layers_are_clipped); 134 data->set_layers_are_clipped(layers_are_clipped);
70 data->set_layers_are_clipped_when_surfaces_disabled( 135 data->set_layers_are_clipped_when_surfaces_disabled(
71 layers_are_clipped_when_surfaces_disabled); 136 layers_are_clipped_when_surfaces_disabled);
72 data->set_resets_clip(resets_clip); 137 data->set_resets_clip(resets_clip);
73 } 138 }
74 139
75 void ClipNode::FromProtobuf(const proto::TreeNode& proto) { 140 void ClipNode::FromProtobuf(const proto::TreeNode& proto) {
76 id = proto.id(); 141 id = proto.id();
77 parent_id = proto.parent_id(); 142 parent_id = proto.parent_id();
78 owner_id = proto.owner_id(); 143 owner_id = proto.owner_id();
79 144
80 DCHECK(proto.has_clip_node_data()); 145 DCHECK(proto.has_clip_node_data());
81 const proto::ClipNodeData& data = proto.clip_node_data(); 146 const proto::ClipNodeData& data = proto.clip_node_data();
82 147
83 clip_type = ClipNodeTypeFromProto(data.clip_type()); 148 clip_type = ClipNodeTypeFromProto(data.clip_type());
149 if (clip_type == ClipNode::ClipType::EXPANDS_CLIP) {
150 clip_expander = base::MakeUnique<ClipExpander>(
151 ClipExpander::ExpanderType::FILTER, data.clip_expander_effect_id());
152 } else {
153 clip_expander.reset();
154 }
84 clip = ProtoToRectF(data.clip()); 155 clip = ProtoToRectF(data.clip());
85 combined_clip_in_target_space = 156 combined_clip_in_target_space =
86 ProtoToRectF(data.combined_clip_in_target_space()); 157 ProtoToRectF(data.combined_clip_in_target_space());
87 clip_in_target_space = ProtoToRectF(data.clip_in_target_space()); 158 clip_in_target_space = ProtoToRectF(data.clip_in_target_space());
88 159
89 transform_id = data.transform_id(); 160 transform_id = data.transform_id();
90 target_transform_id = data.target_transform_id(); 161 target_transform_id = data.target_transform_id();
91 target_effect_id = data.target_effect_id(); 162 target_effect_id = data.target_effect_id();
92 layer_clipping_uses_only_local_clip = 163 layer_clipping_uses_only_local_clip =
93 data.layer_clipping_uses_only_local_clip(); 164 data.layer_clipping_uses_only_local_clip();
(...skipping 16 matching lines...) Expand all
110 value->SetBoolean("layer_clipping_uses_only_local_clip", 181 value->SetBoolean("layer_clipping_uses_only_local_clip",
111 layer_clipping_uses_only_local_clip); 182 layer_clipping_uses_only_local_clip);
112 value->SetBoolean("target_is_clipped", target_is_clipped); 183 value->SetBoolean("target_is_clipped", target_is_clipped);
113 value->SetBoolean("layers_are_clipped", layers_are_clipped); 184 value->SetBoolean("layers_are_clipped", layers_are_clipped);
114 value->SetBoolean("layers_are_clipped_when_surfaces_disabled", 185 value->SetBoolean("layers_are_clipped_when_surfaces_disabled",
115 layers_are_clipped_when_surfaces_disabled); 186 layers_are_clipped_when_surfaces_disabled);
116 value->SetBoolean("resets_clip", resets_clip); 187 value->SetBoolean("resets_clip", resets_clip);
117 } 188 }
118 189
119 } // namespace cc 190 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698