summaryrefslogtreecommitdiffstats
path: root/cc/layers/layer_position_constraint.cc
blob: 5d8824e24213b68658a66d176fadfb8246c32c5e (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
// Copyright 2013 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 "cc/layers/layer_position_constraint.h"
#include "cc/proto/layer_position_constraint.pb.h"

namespace cc {

LayerPositionConstraint::LayerPositionConstraint()
    : is_fixed_position_(false),
      is_fixed_to_right_edge_(false),
      is_fixed_to_bottom_edge_(false) {
}

void LayerPositionConstraint::ToProtobuf(
    proto::LayerPositionConstraint* proto) const {
  proto->set_is_fixed_position(is_fixed_position_);
  proto->set_is_fixed_to_right_edge(is_fixed_to_right_edge_);
  proto->set_is_fixed_to_bottom_edge(is_fixed_to_bottom_edge_);
}

void LayerPositionConstraint::FromProtobuf(
    const proto::LayerPositionConstraint& proto) {
  is_fixed_position_ = proto.is_fixed_position();
  is_fixed_to_right_edge_ = proto.is_fixed_to_right_edge();
  is_fixed_to_bottom_edge_ = proto.is_fixed_to_bottom_edge();
}

bool LayerPositionConstraint::operator==(
    const LayerPositionConstraint& other) const {
  if (!is_fixed_position_ && !other.is_fixed_position_)
    return true;
  return is_fixed_position_ == other.is_fixed_position_ &&
          is_fixed_to_right_edge_ == other.is_fixed_to_right_edge_ &&
          is_fixed_to_bottom_edge_ == other.is_fixed_to_bottom_edge_;
}

bool LayerPositionConstraint::operator!=(
    const LayerPositionConstraint& other) const {
  return !(*this == other);
}

}  // namespace cc