summaryrefslogtreecommitdiffstats
path: root/cc/proto
diff options
context:
space:
mode:
authorkhushalsagar <khushalsagar@chromium.org>2016-01-15 12:46:48 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-15 20:48:00 +0000
commit376942135fb8ad3d33340c506ff251f3c3afba3d (patch)
treed65d8ccbee3ffb1555508b03035f8fa65f8746e8 /cc/proto
parent272ad4a2612601ae1c7cd8aca68bf8ada4f5a494 (diff)
downloadchromium_src-376942135fb8ad3d33340c506ff251f3c3afba3d.zip
chromium_src-376942135fb8ad3d33340c506ff251f3c3afba3d.tar.gz
chromium_src-376942135fb8ad3d33340c506ff251f3c3afba3d.tar.bz2
(De)-serialize BeginMainFrameAndCommitState to protobuf.
BUG=550687 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1581773002 Cr-Commit-Position: refs/heads/master@{#369836}
Diffstat (limited to 'cc/proto')
-rw-r--r--cc/proto/BUILD.gn2
-rw-r--r--cc/proto/base_conversions.cc23
-rw-r--r--cc/proto/base_conversions.h21
-rw-r--r--cc/proto/base_conversions_unittest.cc30
-rw-r--r--cc/proto/begin_main_frame_and_commit_state.proto50
-rw-r--r--cc/proto/gfx_conversions.cc11
-rw-r--r--cc/proto/gfx_conversions.h6
-rw-r--r--cc/proto/gfx_conversions_unittest.cc14
-rw-r--r--cc/proto/vector2d.proto14
9 files changed, 171 insertions, 0 deletions
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index 60952ac..7a68e16 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -29,6 +29,7 @@ proto_library("proto_internal") {
sources = [
# TODO(dtrainor): Move protos to their correct packages once it's possible
# to include protos from other directories/targets (crbug.com/542423).
+ "begin_main_frame_and_commit_state.proto",
"commit_earlyout_reason.proto",
"compositor_message.proto",
"display_item.proto",
@@ -56,6 +57,7 @@ proto_library("proto_internal") {
"skrrect.proto",
"skxfermode.proto",
"transform.proto",
+ "vector2d.proto",
"vector2df.proto",
]
diff --git a/cc/proto/base_conversions.cc b/cc/proto/base_conversions.cc
new file mode 100644
index 0000000..119903b
--- /dev/null
+++ b/cc/proto/base_conversions.cc
@@ -0,0 +1,23 @@
+// 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 "cc/proto/base_conversions.h"
+
+namespace base {
+class TimeDelta;
+}
+
+namespace cc {
+
+int64_t TimeTicksToProto(base::TimeTicks ticks) {
+ base::TimeDelta diff = ticks - base::TimeTicks::UnixEpoch();
+ return diff.InMicroseconds();
+}
+
+CC_EXPORT base::TimeTicks ProtoToTimeTicks(int64_t ticks) {
+ base::TimeDelta diff = base::TimeDelta::FromMicroseconds(ticks);
+ return base::TimeTicks::UnixEpoch() + diff;
+}
+
+} // namespace cc
diff --git a/cc/proto/base_conversions.h b/cc/proto/base_conversions.h
new file mode 100644
index 0000000..b862e3a
--- /dev/null
+++ b/cc/proto/base_conversions.h
@@ -0,0 +1,21 @@
+// 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.
+
+#ifndef CC_PROTO_BASE_CONVERSIONS_H_
+#define CC_PROTO_BASE_CONVERSIONS_H_
+
+#include "base/time/time.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+// TODO(dtrainor): Move these to a class and make them static
+// (crbug.com/548432).
+// We should probably have a better way for sending these.
+CC_EXPORT int64_t TimeTicksToProto(base::TimeTicks ticks);
+CC_EXPORT base::TimeTicks ProtoToTimeTicks(int64_t ticks);
+
+} // namespace cc
+
+#endif // CC_PROTO_BASE_CONVERSIONS_H_
diff --git a/cc/proto/base_conversions_unittest.cc b/cc/proto/base_conversions_unittest.cc
new file mode 100644
index 0000000..57dd807
--- /dev/null
+++ b/cc/proto/base_conversions_unittest.cc
@@ -0,0 +1,30 @@
+// 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 "cc/proto/base_conversions.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+TEST(BaseProtoConversionsTest, SerializeTimeTicks) {
+ base::TimeTicks ticks;
+ base::TimeTicks new_ticks;
+
+ ticks = base::TimeTicks::FromInternalValue(2);
+ new_ticks = ProtoToTimeTicks(TimeTicksToProto(ticks));
+ EXPECT_EQ(ticks, new_ticks);
+
+ ticks = base::TimeTicks::Now();
+ new_ticks = ProtoToTimeTicks(TimeTicksToProto(ticks));
+ EXPECT_EQ(ticks, new_ticks);
+
+ ticks = base::TimeTicks::FromInternalValue(0);
+ new_ticks = ProtoToTimeTicks(TimeTicksToProto(ticks));
+ EXPECT_EQ(ticks, new_ticks);
+}
+
+} // namespace
+} // namespace cc
diff --git a/cc/proto/begin_main_frame_and_commit_state.proto b/cc/proto/begin_main_frame_and_commit_state.proto
new file mode 100644
index 0000000..9881131
--- /dev/null
+++ b/cc/proto/begin_main_frame_and_commit_state.proto
@@ -0,0 +1,50 @@
+// 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.
+
+syntax = "proto2";
+
+import "vector2d.proto";
+import "vector2df.proto";
+
+option optimize_for = LITE_RUNTIME;
+
+package cc.proto;
+
+message ScrollUpdateInfo {
+ optional int64 layer_id = 1;
+ optional Vector2d scroll_delta = 2;
+}
+
+message ScrollAndScaleSet {
+ repeated ScrollUpdateInfo scrolls = 1;
+ optional float page_scale_delta = 2;
+ optional Vector2dF elastic_overscroll_delta = 3;
+ optional float top_controls_delta = 4;
+
+ // TODO(khushalsagar): Do we need to send swap promises?
+ // See crbug/576999.
+}
+
+message BeginFrameArgs {
+ enum BeginFrameArgsType {
+ INVALID = 1;
+ NORMAL = 2;
+ MISSED = 3;
+ BEGIN_FRAME_ARGS_TYPE_MAX = 100;
+ }
+
+ optional int64 frame_time = 1;
+ optional int64 deadline = 2;
+ optional int64 interval = 3;
+ optional BeginFrameArgsType type = 4;
+ optional bool on_critical_path = 5;
+}
+
+message BeginMainFrameAndCommitState {
+ optional int64 begin_frame_id = 1;
+ optional BeginFrameArgs begin_frame_args = 2;
+ optional ScrollAndScaleSet scroll_info = 3;
+ optional int64 memory_allocation_limit_bytes = 4;
+ optional bool evicted_ui_resources = 5;
+} \ No newline at end of file
diff --git a/cc/proto/gfx_conversions.cc b/cc/proto/gfx_conversions.cc
index 8dac00c..3abc59f 100644
--- a/cc/proto/gfx_conversions.cc
+++ b/cc/proto/gfx_conversions.cc
@@ -13,6 +13,7 @@
#include "cc/proto/size.pb.h"
#include "cc/proto/sizef.pb.h"
#include "cc/proto/transform.pb.h"
+#include "cc/proto/vector2d.pb.h"
#include "cc/proto/vector2df.pb.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point3_f.h"
@@ -22,6 +23,7 @@
#include "ui/gfx/geometry/scroll_offset.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -137,4 +139,13 @@ gfx::ScrollOffset ProtoToScrollOffset(const proto::ScrollOffset& proto) {
return gfx::ScrollOffset(proto.x(), proto.y());
}
+void Vector2dToProto(const gfx::Vector2d& vector, proto::Vector2d* proto) {
+ proto->set_x(vector.x());
+ proto->set_y(vector.y());
+}
+
+gfx::Vector2d ProtoToVector2d(const proto::Vector2d& proto) {
+ return gfx::Vector2d(proto.x(), proto.y());
+}
+
} // namespace cc
diff --git a/cc/proto/gfx_conversions.h b/cc/proto/gfx_conversions.h
index b5caa3a..52a2c11 100644
--- a/cc/proto/gfx_conversions.h
+++ b/cc/proto/gfx_conversions.h
@@ -17,6 +17,7 @@ class ScrollOffset;
class Size;
class SizeF;
class Transform;
+class Vector2d;
class Vector2dF;
} // namespace gfx
@@ -32,6 +33,7 @@ class ScrollOffset;
class Size;
class SizeF;
class Transform;
+class Vector2d;
class Vector2dF;
} // namespace proto
@@ -71,6 +73,10 @@ CC_EXPORT void ScrollOffsetToProto(const gfx::ScrollOffset& scroll_offset,
CC_EXPORT gfx::ScrollOffset ProtoToScrollOffset(
const proto::ScrollOffset& proto);
+CC_EXPORT void Vector2dToProto(const gfx::Vector2d& vector,
+ proto::Vector2d* proto);
+CC_EXPORT gfx::Vector2d ProtoToVector2d(const proto::Vector2d& proto);
+
} // namespace cc
#endif // CC_PROTO_GFX_CONVERSIONS_H_
diff --git a/cc/proto/gfx_conversions_unittest.cc b/cc/proto/gfx_conversions_unittest.cc
index cf46be8..1132304 100644
--- a/cc/proto/gfx_conversions_unittest.cc
+++ b/cc/proto/gfx_conversions_unittest.cc
@@ -13,6 +13,7 @@
#include "cc/proto/size.pb.h"
#include "cc/proto/sizef.pb.h"
#include "cc/proto/transform.pb.h"
+#include "cc/proto/vector2d.pb.h"
#include "cc/proto/vector2df.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h"
@@ -269,5 +270,18 @@ TEST(GfxProtoConversionsTest, SerializeDeserializeScrollOffset) {
EXPECT_EQ(scroll_offset3, ProtoToScrollOffset(proto3));
}
+TEST(GfxProtoConversionsTest, SerializeDeserializeVector2d) {
+ const gfx::Vector2d vector(5, 10);
+
+ // Test Vector2dToProto
+ proto::Vector2d proto;
+ Vector2dToProto(vector, &proto);
+ EXPECT_EQ(vector.x(), proto.x());
+ EXPECT_EQ(vector.y(), proto.y());
+
+ // Test ProtoToVector2d
+ EXPECT_EQ(vector, ProtoToVector2d(proto));
+}
+
} // namespace
} // namespace cc
diff --git a/cc/proto/vector2d.proto b/cc/proto/vector2d.proto
new file mode 100644
index 0000000..15171844
--- /dev/null
+++ b/cc/proto/vector2d.proto
@@ -0,0 +1,14 @@
+// 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.
+
+syntax = "proto2";
+
+option optimize_for = LITE_RUNTIME;
+
+package cc.proto;
+
+message Vector2d {
+ optional int64 x = 1;
+ optional int64 y = 2;
+}