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

Side by Side Diff: cc/proto/gfx_conversions.cc

Issue 1417963011: Added serialization to protobufs for property trees. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/proto/gfx_conversions.h" 5 #include "cc/proto/gfx_conversions.h"
6 6
7 #include "cc/proto/point.pb.h" 7 #include "cc/proto/point.pb.h"
8 #include "cc/proto/pointf.pb.h" 8 #include "cc/proto/pointf.pb.h"
9 #include "cc/proto/rect.pb.h" 9 #include "cc/proto/rect.pb.h"
10 #include "cc/proto/rectf.pb.h" 10 #include "cc/proto/rectf.pb.h"
11 #include "cc/proto/scroll_offset.pb.h"
11 #include "cc/proto/size.pb.h" 12 #include "cc/proto/size.pb.h"
12 #include "cc/proto/sizef.pb.h" 13 #include "cc/proto/sizef.pb.h"
13 #include "cc/proto/transform.pb.h" 14 #include "cc/proto/transform.pb.h"
15 #include "cc/proto/vector2df.pb.h"
14 #include "ui/gfx/geometry/point.h" 16 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/point_f.h" 17 #include "ui/gfx/geometry/point_f.h"
16 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/rect_f.h" 19 #include "ui/gfx/geometry/rect_f.h"
20 #include "ui/gfx/geometry/scroll_offset.h"
18 #include "ui/gfx/geometry/size.h" 21 #include "ui/gfx/geometry/size.h"
19 #include "ui/gfx/geometry/size_f.h" 22 #include "ui/gfx/geometry/size_f.h"
23 #include "ui/gfx/geometry/vector2d_f.h"
20 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
21 25
22 namespace cc { 26 namespace cc {
23 27
24 void PointToProto(const gfx::Point& point, proto::Point* proto) { 28 void PointToProto(const gfx::Point& point, proto::Point* proto) {
25 proto->set_x(point.x()); 29 proto->set_x(point.x());
26 proto->set_y(point.y()); 30 proto->set_y(point.y());
27 } 31 }
28 32
29 gfx::Point ProtoToPoint(const proto::Point& proto) { 33 gfx::Point ProtoToPoint(const proto::Point& proto) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 gfx::Transform transform; 98 gfx::Transform transform;
95 DCHECK_EQ(16, proto.matrix_size()); 99 DCHECK_EQ(16, proto.matrix_size());
96 for (int i = 0; i < 4; i++) { 100 for (int i = 0; i < 4; i++) {
97 for (int j = 0; j < 4; j++) { 101 for (int j = 0; j < 4; j++) {
98 transform.matrix().set(i, j, proto.matrix(i * 4 + j)); 102 transform.matrix().set(i, j, proto.matrix(i * 4 + j));
99 } 103 }
100 } 104 }
101 return transform; 105 return transform;
102 } 106 }
103 107
108 void Vector2dFToProto(const gfx::Vector2dF& vector, proto::Vector2dF* proto) {
109 proto->set_x(vector.x());
110 proto->set_y(vector.y());
111 }
112
113 gfx::Vector2dF ProtoToVector2dF(const proto::Vector2dF& proto) {
114 return gfx::Vector2dF(proto.x(), proto.y());
115 }
116
117 void ScrollOffsetToProto(const gfx::ScrollOffset& scroll_offset,
118 proto::ScrollOffset* proto) {
119 proto->set_x(scroll_offset.x());
120 proto->set_y(scroll_offset.y());
121 }
122
123 gfx::ScrollOffset ProtoToScrollOffset(const proto::ScrollOffset& proto) {
124 return gfx::ScrollOffset(proto.x(), proto.y());
125 }
126
104 } // namespace cc 127 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698