summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornyquist <nyquist@chromium.org>2015-12-01 16:08:35 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-02 00:09:10 +0000
commitb974b9aeec3ea5941d7e30f2db924fa637180ef2 (patch)
tree96dfbaa27ecf265957edca6b53a42d7d0c24b787
parente3e5b6f72c5cb7a669e2a11878c0c416a0cd0dd1 (diff)
downloadchromium_src-b974b9aeec3ea5941d7e30f2db924fa637180ef2.zip
chromium_src-b974b9aeec3ea5941d7e30f2db924fa637180ef2.tar.gz
chromium_src-b974b9aeec3ea5941d7e30f2db924fa637180ef2.tar.bz2
Added support for (de)serializing cc::RendererSettings
As part of serializing cc::LayerTreeHost, we also need to serialize the cc::LayerTreeSettings and the cc::RendererSettings. This CL focuses only on the renderer settings. BUG=561210 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1476753002 Cr-Commit-Position: refs/heads/master@{#362558}
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/output/renderer_settings.cc53
-rw-r--r--cc/output/renderer_settings.h9
-rw-r--r--cc/output/renderer_settings_unittest.cc58
-rw-r--r--cc/proto/BUILD.gn1
-rw-r--r--cc/proto/renderer_settings.proto25
8 files changed, 149 insertions, 0 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 2b24a2c..c0253ab 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -805,6 +805,7 @@ test("cc_unittests") {
"output/output_surface_unittest.cc",
"output/overlay_unittest.cc",
"output/renderer_pixeltest.cc",
+ "output/renderer_settings_unittest.cc",
"output/renderer_unittest.cc",
"output/shader_unittest.cc",
"output/software_renderer_unittest.cc",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index a6dfe61..745fd46 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -607,6 +607,7 @@
'proto/rect.proto',
'proto/rectf.proto',
'proto/region.proto',
+ 'proto/renderer_settings.proto',
'proto/scroll_offset.proto',
'proto/size.proto',
'proto/sizef.proto',
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index b892d97..b653057 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -79,6 +79,7 @@
'output/output_surface_unittest.cc',
'output/overlay_unittest.cc',
'output/renderer_pixeltest.cc',
+ 'output/renderer_settings_unittest.cc',
'output/renderer_unittest.cc',
'output/shader_unittest.cc',
'output/software_renderer_unittest.cc',
diff --git a/cc/output/renderer_settings.cc b/cc/output/renderer_settings.cc
index 7b18278..da79a48 100644
--- a/cc/output/renderer_settings.cc
+++ b/cc/output/renderer_settings.cc
@@ -7,6 +7,7 @@
#include <limits>
#include "base/logging.h"
+#include "cc/proto/renderer_settings.pb.h"
namespace cc {
@@ -28,4 +29,56 @@ RendererSettings::RendererSettings()
RendererSettings::~RendererSettings() {
}
+void RendererSettings::ToProtobuf(proto::RendererSettings* proto) const {
+ proto->set_allow_antialiasing(allow_antialiasing);
+ proto->set_force_antialiasing(force_antialiasing);
+ proto->set_force_blending_with_shaders(force_blending_with_shaders);
+ proto->set_partial_swap_enabled(partial_swap_enabled);
+ proto->set_finish_rendering_on_resize(finish_rendering_on_resize);
+ proto->set_should_clear_root_render_pass(should_clear_root_render_pass);
+ proto->set_disable_display_vsync(disable_display_vsync);
+ proto->set_delay_releasing_overlay_resources(
+ delay_releasing_overlay_resources);
+ proto->set_refresh_rate(refresh_rate);
+ proto->set_highp_threshold_min(highp_threshold_min);
+ proto->set_use_rgba_4444_textures(use_rgba_4444_textures);
+ proto->set_texture_id_allocation_chunk_size(texture_id_allocation_chunk_size);
+ proto->set_use_gpu_memory_buffer_resources(use_gpu_memory_buffer_resources);
+}
+
+void RendererSettings::FromProtobuf(const proto::RendererSettings& proto) {
+ allow_antialiasing = proto.allow_antialiasing();
+ force_antialiasing = proto.force_antialiasing();
+ force_blending_with_shaders = proto.force_blending_with_shaders();
+ partial_swap_enabled = proto.partial_swap_enabled();
+ finish_rendering_on_resize = proto.finish_rendering_on_resize();
+ should_clear_root_render_pass = proto.should_clear_root_render_pass();
+ disable_display_vsync = proto.disable_display_vsync();
+ delay_releasing_overlay_resources = proto.delay_releasing_overlay_resources();
+ refresh_rate = proto.refresh_rate();
+ highp_threshold_min = proto.highp_threshold_min();
+ use_rgba_4444_textures = proto.use_rgba_4444_textures();
+ texture_id_allocation_chunk_size = proto.texture_id_allocation_chunk_size();
+ use_gpu_memory_buffer_resources = proto.use_gpu_memory_buffer_resources();
+}
+
+bool RendererSettings::operator==(const RendererSettings& other) const {
+ return allow_antialiasing == other.allow_antialiasing &&
+ force_antialiasing == other.force_antialiasing &&
+ force_blending_with_shaders == other.force_blending_with_shaders &&
+ partial_swap_enabled == other.partial_swap_enabled &&
+ finish_rendering_on_resize == other.finish_rendering_on_resize &&
+ should_clear_root_render_pass == other.should_clear_root_render_pass &&
+ disable_display_vsync == other.disable_display_vsync &&
+ delay_releasing_overlay_resources ==
+ other.delay_releasing_overlay_resources &&
+ refresh_rate == other.refresh_rate &&
+ highp_threshold_min == other.highp_threshold_min &&
+ use_rgba_4444_textures == other.use_rgba_4444_textures &&
+ texture_id_allocation_chunk_size ==
+ other.texture_id_allocation_chunk_size &&
+ use_gpu_memory_buffer_resources ==
+ other.use_gpu_memory_buffer_resources;
+}
+
} // namespace cc
diff --git a/cc/output/renderer_settings.h b/cc/output/renderer_settings.h
index 3934139..4910a25 100644
--- a/cc/output/renderer_settings.h
+++ b/cc/output/renderer_settings.h
@@ -10,6 +10,10 @@
namespace cc {
+namespace proto {
+class RendererSettings;
+} // namespace proto
+
class CC_EXPORT RendererSettings {
public:
RendererSettings();
@@ -28,6 +32,11 @@ class CC_EXPORT RendererSettings {
bool use_rgba_4444_textures;
size_t texture_id_allocation_chunk_size;
bool use_gpu_memory_buffer_resources;
+
+ void ToProtobuf(proto::RendererSettings* proto) const;
+ void FromProtobuf(const proto::RendererSettings& proto);
+
+ bool operator==(const RendererSettings& other) const;
};
} // namespace cc
diff --git a/cc/output/renderer_settings_unittest.cc b/cc/output/renderer_settings_unittest.cc
new file mode 100644
index 0000000..b7febd4
--- /dev/null
+++ b/cc/output/renderer_settings_unittest.cc
@@ -0,0 +1,58 @@
+// 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/output/renderer_settings.h"
+
+#include "cc/proto/renderer_settings.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+void VerifySerializeAndDeserializeProto(const RendererSettings& settings1) {
+ proto::RendererSettings proto;
+ settings1.ToProtobuf(&proto);
+ RendererSettings settings2;
+ settings2.FromProtobuf(proto);
+ EXPECT_EQ(settings1, settings2);
+}
+
+TEST(RendererSettingsTest, AllFieldsFlipped) {
+ RendererSettings settings;
+ settings.allow_antialiasing = false;
+ settings.force_antialiasing = true;
+ settings.force_blending_with_shaders = true;
+ settings.partial_swap_enabled = true;
+ settings.finish_rendering_on_resize = true;
+ settings.should_clear_root_render_pass = false;
+ settings.disable_display_vsync = true;
+ settings.delay_releasing_overlay_resources = true;
+ settings.refresh_rate = 6.0;
+ settings.highp_threshold_min = 1;
+ settings.use_rgba_4444_textures = true;
+ settings.texture_id_allocation_chunk_size = 46;
+ settings.use_gpu_memory_buffer_resources = true;
+ VerifySerializeAndDeserializeProto(settings);
+}
+
+TEST(RendererSettingsTest, ArbitraryFieldValues) {
+ RendererSettings settings;
+ settings.allow_antialiasing = false;
+ settings.force_antialiasing = true;
+ settings.force_blending_with_shaders = false;
+ settings.partial_swap_enabled = true;
+ settings.finish_rendering_on_resize = false;
+ settings.should_clear_root_render_pass = false;
+ settings.disable_display_vsync = true;
+ settings.delay_releasing_overlay_resources = true;
+ settings.refresh_rate = 999.0;
+ settings.highp_threshold_min = 1;
+ settings.use_rgba_4444_textures = true;
+ settings.texture_id_allocation_chunk_size = 12;
+ settings.use_gpu_memory_buffer_resources = true;
+ VerifySerializeAndDeserializeProto(settings);
+}
+
+} // namespace
+} // namespace cc
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index f1b71ec..5b2f47a 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -41,6 +41,7 @@ proto_library("proto_internal") {
"rect.proto",
"rectf.proto",
"region.proto",
+ "renderer_settings.proto",
"scroll_offset.proto",
"size.proto",
"sizef.proto",
diff --git a/cc/proto/renderer_settings.proto b/cc/proto/renderer_settings.proto
new file mode 100644
index 0000000..6666f50
--- /dev/null
+++ b/cc/proto/renderer_settings.proto
@@ -0,0 +1,25 @@
+// 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 RendererSettings {
+ optional bool allow_antialiasing = 1;
+ optional bool force_antialiasing = 2;
+ optional bool force_blending_with_shaders = 3;
+ optional bool partial_swap_enabled = 4;
+ optional bool finish_rendering_on_resize = 5;
+ optional bool should_clear_root_render_pass = 6;
+ optional bool disable_display_vsync = 7;
+ optional bool delay_releasing_overlay_resources = 8;
+ optional double refresh_rate = 9;
+ optional uint32 highp_threshold_min = 10;
+ optional bool use_rgba_4444_textures = 11;
+ optional uint32 texture_id_allocation_chunk_size = 12;
+ optional bool use_gpu_memory_buffer_resources = 13;
+}