Commit bf792fc2 authored by xingliu's avatar xingliu Committed by Commit bot

Start to refactor renderer LayerTreeSettings generating code to common.

The goal is to let Blimp reuse this logic on browser process, since
Blimp client doesn't have renderer process.

BUG=577985

Review-Url: https://codereview.chromium.org/2285083004
Cr-Commit-Position: refs/heads/master@{#415366}
parent 9f38f74b
// 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 "content/common/layer_tree_settings_factory.h"
#include "base/strings/string_number_conversions.h"
#include "cc/base/switches.h"
namespace content {
// static
void LayerTreeSettingsFactory::SetTopControlsSettings(
cc::LayerTreeSettings& settings,
const base::CommandLine& cmd) {
if (cmd.HasSwitch(cc::switches::kTopControlsShowThreshold)) {
std::string top_threshold_str =
cmd.GetSwitchValueASCII(cc::switches::kTopControlsShowThreshold);
double show_threshold;
if (base::StringToDouble(top_threshold_str, &show_threshold) &&
show_threshold >= 0.f && show_threshold <= 1.f)
settings.top_controls_show_threshold = show_threshold;
}
if (cmd.HasSwitch(cc::switches::kTopControlsHideThreshold)) {
std::string top_threshold_str =
cmd.GetSwitchValueASCII(cc::switches::kTopControlsHideThreshold);
double hide_threshold;
if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
hide_threshold >= 0.f && hide_threshold <= 1.f)
settings.top_controls_hide_threshold = hide_threshold;
}
}
} // namespace content
// 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 CONTENT_COMMON_LAYER_TREE_SETTINGS_FACTORY_H_
#define CONTENT_COMMON_LAYER_TREE_SETTINGS_FACTORY_H_
#include "base/command_line.h"
#include "base/macros.h"
#include "cc/trees/layer_tree_settings.h"
#include "content/common/content_export.h"
namespace content {
// LayerTreeSettingsFactory holds utilities functions to generate
// LayerTreeSettings.
class CONTENT_EXPORT LayerTreeSettingsFactory {
// TODO(xingliu): Refactor LayerTreeSettings generation logic.
// crbug.com/577985
public:
static void SetTopControlsSettings(cc::LayerTreeSettings& settings,
const base::CommandLine& command_line);
};
} // namespace content
#endif // CONTENT_COMMON_LAYER_TREE_SETTINGS_FACTORY_H_
......@@ -398,6 +398,8 @@
'common/input_messages.h',
'common/inter_process_time_ticks_converter.cc',
'common/inter_process_time_ticks_converter.h',
'common/layer_tree_settings_factory.cc',
'common/layer_tree_settings_factory.h',
'common/mac/attributed_string_coder.h',
'common/mac/attributed_string_coder.mm',
'common/mac/font_descriptor.h',
......
......@@ -43,6 +43,7 @@
#include "cc/trees/remote_proto_channel.h"
#include "content/common/content_switches_internal.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/layer_tree_settings_factory.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/gpu/render_widget_compositor_delegate.h"
......@@ -344,23 +345,8 @@ cc::LayerTreeSettings RenderWidgetCompositor::GenerateLayerTreeSettings(
settings.image_decode_tasks_enabled =
compositor_deps->AreImageDecodeTasksEnabled();
if (cmd.HasSwitch(cc::switches::kTopControlsShowThreshold)) {
std::string top_threshold_str =
cmd.GetSwitchValueASCII(cc::switches::kTopControlsShowThreshold);
double show_threshold;
if (base::StringToDouble(top_threshold_str, &show_threshold) &&
show_threshold >= 0.f && show_threshold <= 1.f)
settings.top_controls_show_threshold = show_threshold;
}
if (cmd.HasSwitch(cc::switches::kTopControlsHideThreshold)) {
std::string top_threshold_str =
cmd.GetSwitchValueASCII(cc::switches::kTopControlsHideThreshold);
double hide_threshold;
if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
hide_threshold >= 0.f && hide_threshold <= 1.f)
settings.top_controls_hide_threshold = hide_threshold;
}
// Build LayerTreeSettings from command line args.
LayerTreeSettingsFactory::SetTopControlsSettings(settings, cmd);
settings.use_layer_lists = cmd.HasSwitch(cc::switches::kEnableLayerLists);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment