summaryrefslogtreecommitdiff
path: root/chromium/cc/trees/clip_node.cc
blob: d3c1863d4482247acccae0ab4e2fc76a680e262d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event_argument.h"
#include "cc/base/math_util.h"
#include "cc/layers/layer.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/property_tree.h"

namespace cc {

ClipNode::ClipNode()
    : id(ClipTree::kInvalidNodeId),
      parent_id(ClipTree::kInvalidNodeId),
      owning_layer_id(Layer::INVALID_ID),
      clip_type(ClipType::NONE),
      transform_id(TransformTree::kInvalidNodeId),
      target_transform_id(TransformTree::kInvalidNodeId),
      target_effect_id(EffectTree::kInvalidNodeId),
      layer_clipping_uses_only_local_clip(false),
      layers_are_clipped(false),
      layers_are_clipped_when_surfaces_disabled(false),
      resets_clip(false) {}

ClipNode::ClipNode(const ClipNode& other)
    : id(other.id),
      parent_id(other.parent_id),
      owning_layer_id(other.owning_layer_id),
      clip_type(other.clip_type),
      clip(other.clip),
      combined_clip_in_target_space(other.combined_clip_in_target_space),
      clip_in_target_space(other.clip_in_target_space),
      transform_id(other.transform_id),
      target_transform_id(other.target_transform_id),
      target_effect_id(other.target_effect_id),
      layer_clipping_uses_only_local_clip(
          other.layer_clipping_uses_only_local_clip),
      layers_are_clipped(other.layers_are_clipped),
      layers_are_clipped_when_surfaces_disabled(
          other.layers_are_clipped_when_surfaces_disabled),
      resets_clip(other.resets_clip) {
  if (other.clip_expander) {
    DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP);
    clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander);
  }
}

ClipNode& ClipNode::operator=(const ClipNode& other) {
  id = other.id;
  parent_id = other.parent_id;
  owning_layer_id = other.owning_layer_id;
  clip_type = other.clip_type;
  clip = other.clip;
  combined_clip_in_target_space = other.combined_clip_in_target_space;
  clip_in_target_space = other.clip_in_target_space;
  transform_id = other.transform_id;
  target_transform_id = other.target_transform_id;
  target_effect_id = other.target_effect_id;
  layer_clipping_uses_only_local_clip =
      other.layer_clipping_uses_only_local_clip;
  layers_are_clipped = other.layers_are_clipped;
  layers_are_clipped_when_surfaces_disabled =
      other.layers_are_clipped_when_surfaces_disabled;
  resets_clip = other.resets_clip;

  if (other.clip_expander) {
    DCHECK_EQ(clip_type, ClipType::EXPANDS_CLIP);
    clip_expander = base::MakeUnique<ClipExpander>(*other.clip_expander);
  } else {
    clip_expander.reset();
  }

  return *this;
}

ClipNode::~ClipNode() {}

bool ClipNode::operator==(const ClipNode& other) const {
  if (clip_expander && other.clip_expander &&
      *clip_expander != *other.clip_expander)
    return false;
  if ((clip_expander && !other.clip_expander) ||
      (!clip_expander && other.clip_expander))
    return false;
  return id == other.id && parent_id == other.parent_id &&
         owning_layer_id == other.owning_layer_id &&
         clip_type == other.clip_type && clip == other.clip &&
         combined_clip_in_target_space == other.combined_clip_in_target_space &&
         clip_in_target_space == other.clip_in_target_space &&
         transform_id == other.transform_id &&
         target_transform_id == other.target_transform_id &&
         target_effect_id == other.target_effect_id &&
         layer_clipping_uses_only_local_clip ==
             other.layer_clipping_uses_only_local_clip &&
         layers_are_clipped == other.layers_are_clipped &&
         layers_are_clipped_when_surfaces_disabled ==
             other.layers_are_clipped_when_surfaces_disabled &&
         resets_clip == other.resets_clip;
}

void ClipNode::AsValueInto(base::trace_event::TracedValue* value) const {
  value->SetInteger("id", id);
  value->SetInteger("parent_id", parent_id);
  value->SetInteger("owning_layer_id", owning_layer_id);
  value->SetInteger("clip_type", static_cast<int>(clip_type));
  MathUtil::AddToTracedValue("clip", clip, value);
  value->SetInteger("transform_id", transform_id);
  value->SetInteger("target_transform_id", target_transform_id);
  value->SetInteger("target_effect_id", target_effect_id);
  value->SetBoolean("layer_clipping_uses_only_local_clip",
                    layer_clipping_uses_only_local_clip);
  value->SetBoolean("layers_are_clipped", layers_are_clipped);
  value->SetBoolean("layers_are_clipped_when_surfaces_disabled",
                    layers_are_clipped_when_surfaces_disabled);
  value->SetBoolean("resets_clip", resets_clip);
}

}  // namespace cc