| 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/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
| 6 #include "cc/base/math_util.h" | 6 #include "cc/base/math_util.h" |
| 7 #include "cc/proto/cc_conversions.h" |
| 7 #include "cc/proto/gfx_conversions.h" | 8 #include "cc/proto/gfx_conversions.h" |
| 8 #include "cc/proto/property_tree.pb.h" | 9 #include "cc/proto/property_tree.pb.h" |
| 9 #include "cc/trees/clip_node.h" | 10 #include "cc/trees/clip_node.h" |
| 10 | 11 |
| 11 namespace cc { | 12 namespace cc { |
| 12 | 13 |
| 13 ClipNode::ClipNode() | 14 ClipNode::ClipNode() |
| 14 : id(-1), | 15 : id(-1), |
| 15 parent_id(-1), | 16 parent_id(-1), |
| 16 owner_id(-1), | 17 owner_id(-1), |
| 18 clip_type(ClipType::NONE), |
| 17 transform_id(-1), | 19 transform_id(-1), |
| 18 target_transform_id(-1), | 20 target_transform_id(-1), |
| 19 target_effect_id(-1), | 21 target_effect_id(-1), |
| 20 applies_local_clip(true), | |
| 21 layer_clipping_uses_only_local_clip(false), | 22 layer_clipping_uses_only_local_clip(false), |
| 22 target_is_clipped(false), | 23 target_is_clipped(false), |
| 23 layers_are_clipped(false), | 24 layers_are_clipped(false), |
| 24 layers_are_clipped_when_surfaces_disabled(false), | 25 layers_are_clipped_when_surfaces_disabled(false), |
| 25 resets_clip(false) {} | 26 resets_clip(false) {} |
| 26 | 27 |
| 27 ClipNode::ClipNode(const ClipNode& other) = default; | 28 ClipNode::ClipNode(const ClipNode& other) = default; |
| 28 | 29 |
| 29 bool ClipNode::operator==(const ClipNode& other) const { | 30 bool ClipNode::operator==(const ClipNode& other) const { |
| 30 return id == other.id && parent_id == other.parent_id && | 31 return id == other.id && parent_id == other.parent_id && |
| 31 owner_id == other.owner_id && clip == other.clip && | 32 owner_id == other.owner_id && clip_type == other.clip_type && |
| 33 clip == other.clip && |
| 32 combined_clip_in_target_space == other.combined_clip_in_target_space && | 34 combined_clip_in_target_space == other.combined_clip_in_target_space && |
| 33 clip_in_target_space == other.clip_in_target_space && | 35 clip_in_target_space == other.clip_in_target_space && |
| 34 transform_id == other.transform_id && | 36 transform_id == other.transform_id && |
| 35 target_transform_id == other.target_transform_id && | 37 target_transform_id == other.target_transform_id && |
| 36 target_effect_id == other.target_effect_id && | 38 target_effect_id == other.target_effect_id && |
| 37 applies_local_clip == other.applies_local_clip && | |
| 38 layer_clipping_uses_only_local_clip == | 39 layer_clipping_uses_only_local_clip == |
| 39 other.layer_clipping_uses_only_local_clip && | 40 other.layer_clipping_uses_only_local_clip && |
| 40 target_is_clipped == other.target_is_clipped && | 41 target_is_clipped == other.target_is_clipped && |
| 41 layers_are_clipped == other.layers_are_clipped && | 42 layers_are_clipped == other.layers_are_clipped && |
| 42 layers_are_clipped_when_surfaces_disabled == | 43 layers_are_clipped_when_surfaces_disabled == |
| 43 other.layers_are_clipped_when_surfaces_disabled && | 44 other.layers_are_clipped_when_surfaces_disabled && |
| 44 resets_clip == other.resets_clip; | 45 resets_clip == other.resets_clip; |
| 45 } | 46 } |
| 46 | 47 |
| 47 void ClipNode::ToProtobuf(proto::TreeNode* proto) const { | 48 void ClipNode::ToProtobuf(proto::TreeNode* proto) const { |
| 48 proto->set_id(id); | 49 proto->set_id(id); |
| 49 proto->set_parent_id(parent_id); | 50 proto->set_parent_id(parent_id); |
| 50 proto->set_owner_id(owner_id); | 51 proto->set_owner_id(owner_id); |
| 51 | 52 |
| 52 DCHECK(!proto->has_clip_node_data()); | 53 DCHECK(!proto->has_clip_node_data()); |
| 53 proto::ClipNodeData* data = proto->mutable_clip_node_data(); | 54 proto::ClipNodeData* data = proto->mutable_clip_node_data(); |
| 54 | 55 |
| 56 data->set_clip_type(ClipNodeTypeToProto(clip_type)); |
| 57 |
| 55 RectFToProto(clip, data->mutable_clip()); | 58 RectFToProto(clip, data->mutable_clip()); |
| 56 RectFToProto(combined_clip_in_target_space, | 59 RectFToProto(combined_clip_in_target_space, |
| 57 data->mutable_combined_clip_in_target_space()); | 60 data->mutable_combined_clip_in_target_space()); |
| 58 RectFToProto(clip_in_target_space, data->mutable_clip_in_target_space()); | 61 RectFToProto(clip_in_target_space, data->mutable_clip_in_target_space()); |
| 59 | 62 |
| 60 data->set_transform_id(transform_id); | 63 data->set_transform_id(transform_id); |
| 61 data->set_target_transform_id(target_transform_id); | 64 data->set_target_transform_id(target_transform_id); |
| 62 data->set_target_effect_id(target_effect_id); | 65 data->set_target_effect_id(target_effect_id); |
| 63 data->set_applies_local_clip(applies_local_clip); | |
| 64 data->set_layer_clipping_uses_only_local_clip( | 66 data->set_layer_clipping_uses_only_local_clip( |
| 65 layer_clipping_uses_only_local_clip); | 67 layer_clipping_uses_only_local_clip); |
| 66 data->set_target_is_clipped(target_is_clipped); | 68 data->set_target_is_clipped(target_is_clipped); |
| 67 data->set_layers_are_clipped(layers_are_clipped); | 69 data->set_layers_are_clipped(layers_are_clipped); |
| 68 data->set_layers_are_clipped_when_surfaces_disabled( | 70 data->set_layers_are_clipped_when_surfaces_disabled( |
| 69 layers_are_clipped_when_surfaces_disabled); | 71 layers_are_clipped_when_surfaces_disabled); |
| 70 data->set_resets_clip(resets_clip); | 72 data->set_resets_clip(resets_clip); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void ClipNode::FromProtobuf(const proto::TreeNode& proto) { | 75 void ClipNode::FromProtobuf(const proto::TreeNode& proto) { |
| 74 id = proto.id(); | 76 id = proto.id(); |
| 75 parent_id = proto.parent_id(); | 77 parent_id = proto.parent_id(); |
| 76 owner_id = proto.owner_id(); | 78 owner_id = proto.owner_id(); |
| 77 | 79 |
| 78 DCHECK(proto.has_clip_node_data()); | 80 DCHECK(proto.has_clip_node_data()); |
| 79 const proto::ClipNodeData& data = proto.clip_node_data(); | 81 const proto::ClipNodeData& data = proto.clip_node_data(); |
| 80 | 82 |
| 83 clip_type = ClipNodeTypeFromProto(data.clip_type()); |
| 81 clip = ProtoToRectF(data.clip()); | 84 clip = ProtoToRectF(data.clip()); |
| 82 combined_clip_in_target_space = | 85 combined_clip_in_target_space = |
| 83 ProtoToRectF(data.combined_clip_in_target_space()); | 86 ProtoToRectF(data.combined_clip_in_target_space()); |
| 84 clip_in_target_space = ProtoToRectF(data.clip_in_target_space()); | 87 clip_in_target_space = ProtoToRectF(data.clip_in_target_space()); |
| 85 | 88 |
| 86 transform_id = data.transform_id(); | 89 transform_id = data.transform_id(); |
| 87 target_transform_id = data.target_transform_id(); | 90 target_transform_id = data.target_transform_id(); |
| 88 target_effect_id = data.target_effect_id(); | 91 target_effect_id = data.target_effect_id(); |
| 89 applies_local_clip = data.applies_local_clip(); | |
| 90 layer_clipping_uses_only_local_clip = | 92 layer_clipping_uses_only_local_clip = |
| 91 data.layer_clipping_uses_only_local_clip(); | 93 data.layer_clipping_uses_only_local_clip(); |
| 92 target_is_clipped = data.target_is_clipped(); | 94 target_is_clipped = data.target_is_clipped(); |
| 93 layers_are_clipped = data.layers_are_clipped(); | 95 layers_are_clipped = data.layers_are_clipped(); |
| 94 layers_are_clipped_when_surfaces_disabled = | 96 layers_are_clipped_when_surfaces_disabled = |
| 95 data.layers_are_clipped_when_surfaces_disabled(); | 97 data.layers_are_clipped_when_surfaces_disabled(); |
| 96 resets_clip = data.resets_clip(); | 98 resets_clip = data.resets_clip(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { | 101 void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const { |
| 100 value->SetInteger("id", id); | 102 value->SetInteger("id", id); |
| 101 value->SetInteger("parent_id", parent_id); | 103 value->SetInteger("parent_id", parent_id); |
| 102 value->SetInteger("owner_id", owner_id); | 104 value->SetInteger("owner_id", owner_id); |
| 105 value->SetInteger("clip_type", static_cast<int>(clip_type)); |
| 103 MathUtil::AddToTracedValue("clip", clip, value); | 106 MathUtil::AddToTracedValue("clip", clip, value); |
| 104 value->SetInteger("transform_id", transform_id); | 107 value->SetInteger("transform_id", transform_id); |
| 105 value->SetInteger("target_transform_id", target_transform_id); | 108 value->SetInteger("target_transform_id", target_transform_id); |
| 106 value->SetInteger("target_effect_id", target_effect_id); | 109 value->SetInteger("target_effect_id", target_effect_id); |
| 107 value->SetBoolean("applies_local_clip", applies_local_clip); | |
| 108 value->SetBoolean("layer_clipping_uses_only_local_clip", | 110 value->SetBoolean("layer_clipping_uses_only_local_clip", |
| 109 layer_clipping_uses_only_local_clip); | 111 layer_clipping_uses_only_local_clip); |
| 110 value->SetBoolean("target_is_clipped", target_is_clipped); | 112 value->SetBoolean("target_is_clipped", target_is_clipped); |
| 111 value->SetBoolean("layers_are_clipped", layers_are_clipped); | 113 value->SetBoolean("layers_are_clipped", layers_are_clipped); |
| 112 value->SetBoolean("layers_are_clipped_when_surfaces_disabled", | 114 value->SetBoolean("layers_are_clipped_when_surfaces_disabled", |
| 113 layers_are_clipped_when_surfaces_disabled); | 115 layers_are_clipped_when_surfaces_disabled); |
| 114 value->SetBoolean("resets_clip", resets_clip); | 116 value->SetBoolean("resets_clip", resets_clip); |
| 115 } | 117 } |
| 116 | 118 |
| 117 } // namespace cc | 119 } // namespace cc |
| OLD | NEW |