Skip to content

Commit

Permalink
Added support for (de)serializing cc::LayerTreeDebugState
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
tommynyquist authored and Commit bot committed Dec 1, 2015
1 parent 4cd65b1 commit 74a9aca
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
1 change: 1 addition & 0 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
41 changes: 41 additions & 0 deletions cc/debug/layer_tree_debug_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 (
Expand Down
7 changes: 7 additions & 0 deletions cc/debug/layer_tree_debug_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace cc {

namespace proto {
class LayerTreeDebugState;
} // namespace proto

class CC_EXPORT LayerTreeDebugState {
public:
LayerTreeDebugState();
Expand Down Expand Up @@ -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);
Expand Down
64 changes: 64 additions & 0 deletions cc/debug/layer_tree_debug_state_unittest.cc
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cc/proto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 31 additions & 0 deletions cc/proto/layer_tree_debug_state.proto
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 74a9aca

Please sign in to comment.