summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authornyquist <nyquist@chromium.org>2015-12-01 14:39:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 22:44:14 +0000
commit74a9acaec8e89e24a85e24f03cfe7b5dacee5c51 (patch)
treedd732700c95b4d7b823528a2a3b2af78cc2dc56f /cc
parent4cd65b10a47d0ecb28bdc851799d71e4c60241fa (diff)
downloadchromium_src-74a9acaec8e89e24a85e24f03cfe7b5dacee5c51.zip
chromium_src-74a9acaec8e89e24a85e24f03cfe7b5dacee5c51.tar.gz
chromium_src-74a9acaec8e89e24a85e24f03cfe7b5dacee5c51.tar.bz2
Added support for (de)serializing cc::LayerTreeDebugState
As part of serializing cc::LayerTreeHost, we also need to serialize the cc::LayerTreeSettings and the cc::LayerTreeDebugState. This CL focuses only on the debug state. BUG=561210 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1469393004 Cr-Commit-Position: refs/heads/master@{#362534}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/debug/layer_tree_debug_state.cc41
-rw-r--r--cc/debug/layer_tree_debug_state.h7
-rw-r--r--cc/debug/layer_tree_debug_state_unittest.cc64
-rw-r--r--cc/proto/BUILD.gn1
-rw-r--r--cc/proto/layer_tree_debug_state.proto31
8 files changed, 147 insertions, 0 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 60ac70c..67981ef 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -755,6 +755,7 @@ test("cc_unittests") {
"base/tiling_data_unittest.cc",
"base/unique_notifier_unittest.cc",
"debug/frame_timing_tracker_unittest.cc",
+ "debug/layer_tree_debug_state_unittest.cc",
"debug/micro_benchmark_controller_unittest.cc",
"debug/rendering_stats_unittest.cc",
"input/scroll_state_unittest.cc",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index aee7e9b..a6dfe61 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -599,6 +599,7 @@
'proto/display_item.proto',
'proto/layer.proto',
'proto/layer_position_constraint.proto',
+ 'proto/layer_tree_debug_state.proto',
'proto/point.proto',
'proto/point3f.proto',
'proto/pointf.proto',
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 39feb66..9bcfccc 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -31,6 +31,7 @@
'base/tiling_data_unittest.cc',
'base/unique_notifier_unittest.cc',
'debug/frame_timing_tracker_unittest.cc',
+ 'debug/layer_tree_debug_state_unittest.cc',
'debug/micro_benchmark_controller_unittest.cc',
'debug/rendering_stats_unittest.cc',
'input/scroll_state_unittest.cc',
diff --git a/cc/debug/layer_tree_debug_state.cc b/cc/debug/layer_tree_debug_state.cc
index a084bf3..a7ea1d6 100644
--- a/cc/debug/layer_tree_debug_state.cc
+++ b/cc/debug/layer_tree_debug_state.cc
@@ -5,6 +5,7 @@
#include "cc/debug/layer_tree_debug_state.h"
#include "base/logging.h"
+#include "cc/proto/layer_tree_debug_state.pb.h"
namespace cc {
@@ -53,6 +54,46 @@ bool LayerTreeDebugState::ShowMemoryStats() const {
return show_fps_counter;
}
+void LayerTreeDebugState::ToProtobuf(proto::LayerTreeDebugState* proto) const {
+ proto->set_show_fps_counter(show_fps_counter);
+ proto->set_show_debug_borders(show_debug_borders);
+ proto->set_show_paint_rects(show_paint_rects);
+ proto->set_show_property_changed_rects(show_property_changed_rects);
+ proto->set_show_surface_damage_rects(show_surface_damage_rects);
+ proto->set_show_screen_space_rects(show_screen_space_rects);
+ proto->set_show_replica_screen_space_rects(show_replica_screen_space_rects);
+ proto->set_show_touch_event_handler_rects(show_touch_event_handler_rects);
+ proto->set_show_wheel_event_handler_rects(show_wheel_event_handler_rects);
+ proto->set_show_scroll_event_handler_rects(show_scroll_event_handler_rects);
+ proto->set_show_non_fast_scrollable_rects(show_non_fast_scrollable_rects);
+ proto->set_show_layer_animation_bounds_rects(
+ show_layer_animation_bounds_rects);
+ proto->set_slow_down_raster_scale_factor(slow_down_raster_scale_factor);
+ proto->set_rasterize_only_visible_content(rasterize_only_visible_content);
+ proto->set_show_picture_borders(show_picture_borders);
+ proto->set_record_rendering_stats(record_rendering_stats_);
+}
+
+void LayerTreeDebugState::FromProtobuf(
+ const proto::LayerTreeDebugState& proto) {
+ show_fps_counter = proto.show_fps_counter();
+ show_debug_borders = proto.show_debug_borders();
+ show_paint_rects = proto.show_paint_rects();
+ show_property_changed_rects = proto.show_property_changed_rects();
+ show_surface_damage_rects = proto.show_surface_damage_rects();
+ show_screen_space_rects = proto.show_screen_space_rects();
+ show_replica_screen_space_rects = proto.show_replica_screen_space_rects();
+ show_touch_event_handler_rects = proto.show_touch_event_handler_rects();
+ show_wheel_event_handler_rects = proto.show_wheel_event_handler_rects();
+ show_scroll_event_handler_rects = proto.show_scroll_event_handler_rects();
+ show_non_fast_scrollable_rects = proto.show_non_fast_scrollable_rects();
+ show_layer_animation_bounds_rects = proto.show_layer_animation_bounds_rects();
+ slow_down_raster_scale_factor = proto.slow_down_raster_scale_factor();
+ rasterize_only_visible_content = proto.rasterize_only_visible_content();
+ show_picture_borders = proto.show_picture_borders();
+ record_rendering_stats_ = proto.record_rendering_stats();
+}
+
bool LayerTreeDebugState::Equal(const LayerTreeDebugState& a,
const LayerTreeDebugState& b) {
return (
diff --git a/cc/debug/layer_tree_debug_state.h b/cc/debug/layer_tree_debug_state.h
index 13db0ce..d2f13d4 100644
--- a/cc/debug/layer_tree_debug_state.h
+++ b/cc/debug/layer_tree_debug_state.h
@@ -10,6 +10,10 @@
namespace cc {
+namespace proto {
+class LayerTreeDebugState;
+} // namespace proto
+
class CC_EXPORT LayerTreeDebugState {
public:
LayerTreeDebugState();
@@ -40,6 +44,9 @@ class CC_EXPORT LayerTreeDebugState {
bool ShowHudRects() const;
bool ShowMemoryStats() const;
+ void ToProtobuf(proto::LayerTreeDebugState* proto) const;
+ void FromProtobuf(const proto::LayerTreeDebugState& proto);
+
static bool Equal(const LayerTreeDebugState& a, const LayerTreeDebugState& b);
static LayerTreeDebugState Unite(const LayerTreeDebugState& a,
const LayerTreeDebugState& b);
diff --git a/cc/debug/layer_tree_debug_state_unittest.cc b/cc/debug/layer_tree_debug_state_unittest.cc
new file mode 100644
index 0000000..c62313d
--- /dev/null
+++ b/cc/debug/layer_tree_debug_state_unittest.cc
@@ -0,0 +1,64 @@
+// Copyright 2015 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/debug/layer_tree_debug_state.h"
+
+#include "cc/proto/layer_tree_debug_state.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+void VerifySerializeAndDeserializeProto(const LayerTreeDebugState& state1) {
+ proto::LayerTreeDebugState proto;
+ state1.ToProtobuf(&proto);
+ LayerTreeDebugState state2;
+ state2.FromProtobuf(proto);
+ EXPECT_TRUE(LayerTreeDebugState::Equal(state1, state2));
+}
+
+TEST(LayerTreeDebugStateTest, AllFieldsTrue) {
+ LayerTreeDebugState state;
+ state.show_fps_counter = true;
+ state.show_debug_borders = true;
+ state.show_paint_rects = true;
+ state.show_property_changed_rects = true;
+ state.show_surface_damage_rects = true;
+ state.show_screen_space_rects = true;
+ state.show_replica_screen_space_rects = true;
+ state.show_touch_event_handler_rects = true;
+ state.show_wheel_event_handler_rects = true;
+ state.show_scroll_event_handler_rects = true;
+ state.show_non_fast_scrollable_rects = true;
+ state.show_layer_animation_bounds_rects = true;
+ state.slow_down_raster_scale_factor = 1;
+ state.rasterize_only_visible_content = true;
+ state.show_picture_borders = true;
+ state.SetRecordRenderingStats(true);
+ VerifySerializeAndDeserializeProto(state);
+}
+
+TEST(LayerTreeDebugStateTest, ArbitraryFieldValues) {
+ LayerTreeDebugState state;
+ state.show_fps_counter = true;
+ state.show_debug_borders = true;
+ state.show_paint_rects = false;
+ state.show_property_changed_rects = true;
+ state.show_surface_damage_rects = false;
+ state.show_screen_space_rects = false;
+ state.show_replica_screen_space_rects = true;
+ state.show_touch_event_handler_rects = true;
+ state.show_wheel_event_handler_rects = true;
+ state.show_scroll_event_handler_rects = false;
+ state.show_non_fast_scrollable_rects = true;
+ state.show_layer_animation_bounds_rects = true;
+ state.slow_down_raster_scale_factor = 42;
+ state.rasterize_only_visible_content = false;
+ state.show_picture_borders = false;
+ state.SetRecordRenderingStats(true);
+ VerifySerializeAndDeserializeProto(state);
+}
+
+} // namespace
+} // namespace cc
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index 884045f..f1b71ec 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -33,6 +33,7 @@ proto_library("proto_internal") {
"display_item.proto",
"layer.proto",
"layer_position_constraint.proto",
+ "layer_tree_debug_state.proto",
"point.proto",
"point3f.proto",
"pointf.proto",
diff --git a/cc/proto/layer_tree_debug_state.proto b/cc/proto/layer_tree_debug_state.proto
new file mode 100644
index 0000000..ea2970d
--- /dev/null
+++ b/cc/proto/layer_tree_debug_state.proto
@@ -0,0 +1,31 @@
+// Copyright 2015 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";
+
+package cc.proto;
+
+option optimize_for = LITE_RUNTIME;
+
+message LayerTreeDebugState {
+ optional bool show_fps_counter = 1;
+ optional bool show_debug_borders = 2;
+
+ optional bool show_paint_rects = 3;
+ optional bool show_property_changed_rects = 4;
+ optional bool show_surface_damage_rects = 5;
+ optional bool show_screen_space_rects = 6;
+ optional bool show_replica_screen_space_rects = 7;
+ optional bool show_touch_event_handler_rects = 8;
+ optional bool show_wheel_event_handler_rects = 9;
+ optional bool show_scroll_event_handler_rects = 10;
+ optional bool show_non_fast_scrollable_rects = 11;
+ optional bool show_layer_animation_bounds_rects = 12;
+
+ optional int32 slow_down_raster_scale_factor = 13;
+ optional bool rasterize_only_visible_content = 14;
+ optional bool show_picture_borders = 15;
+
+ optional bool record_rendering_stats = 16;
+}