blob: 7abd9e000030aaf403063634d1ae0ef4985a8c89 (
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
|
// Copyright 2014 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/logging.h"
#include "cc/input/layer_selection_bound.h"
#include "cc/proto/gfx_conversions.h"
#include "cc/proto/layer_selection_bound.pb.h"
namespace cc {
namespace {
proto::SelectionBoundType SelectionBoundTypeToProtobuf(
const SelectionBoundType& type) {
switch (type) {
case SELECTION_BOUND_LEFT:
return proto::SelectionBoundType::LEFT;
case SELECTION_BOUND_RIGHT:
return proto::SelectionBoundType::RIGHT;
case SELECTION_BOUND_CENTER:
return proto::SelectionBoundType::CENTER;
case SELECTION_BOUND_EMPTY:
return proto::SelectionBoundType::EMPTY;
}
NOTREACHED() << "proto::SelectionBoundType::UNKNOWN";
return proto::SelectionBoundType::UNKNOWN;
}
SelectionBoundType SelectionBoundTypeFromProtobuf(
const proto::SelectionBoundType& type) {
switch (type) {
case proto::SelectionBoundType::LEFT:
return SELECTION_BOUND_LEFT;
case proto::SelectionBoundType::RIGHT:
return SELECTION_BOUND_RIGHT;
case proto::SelectionBoundType::CENTER:
return SELECTION_BOUND_CENTER;
case proto::SelectionBoundType::EMPTY:
return SELECTION_BOUND_EMPTY;
case proto::SelectionBoundType::UNKNOWN:
NOTREACHED() << "proto::SelectionBoundType::UNKNOWN";
return SELECTION_BOUND_EMPTY;
}
return SELECTION_BOUND_EMPTY;
}
} // namespace
LayerSelectionBound::LayerSelectionBound()
: type(SELECTION_BOUND_EMPTY), layer_id(0) {
}
LayerSelectionBound::~LayerSelectionBound() {
}
bool LayerSelectionBound::operator==(const LayerSelectionBound& other) const {
return type == other.type && layer_id == other.layer_id &&
edge_top == other.edge_top && edge_bottom == other.edge_bottom;
}
bool LayerSelectionBound::operator!=(const LayerSelectionBound& other) const {
return !(*this == other);
}
void LayerSelectionBound::ToProtobuf(proto::LayerSelectionBound* proto) const {
proto->set_type(SelectionBoundTypeToProtobuf(type));
PointToProto(edge_top, proto->mutable_edge_top());
PointToProto(edge_bottom, proto->mutable_edge_bottom());
proto->set_layer_id(layer_id);
}
void LayerSelectionBound::FromProtobuf(
const proto::LayerSelectionBound& proto) {
type = SelectionBoundTypeFromProtobuf(proto.type());
edge_top = ProtoToPoint(proto.edge_top());
edge_bottom = ProtoToPoint(proto.edge_bottom());
layer_id = proto.layer_id();
}
} // namespace cc
|