1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/host/renderer_settings_creation.h"
#include <string>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "components/viz/common/display/overlay_strategy.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/features.h"
#include "components/viz/common/switches.h"
#include "ui/base/ui_base_switches.h"
#if BUILDFLAG(IS_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
namespace viz {
namespace {
bool GetSwitchValueAsInt(const base::CommandLine* command_line,
const std::string& switch_string,
int min_value,
int max_value,
int* result) {
std::string string_value = command_line->GetSwitchValueASCII(switch_string);
int int_value;
if (base::StringToInt(string_value, &int_value) && int_value >= min_value &&
int_value <= max_value) {
*result = int_value;
return true;
} else {
LOG(WARNING) << "Failed to parse switch " << switch_string << ": "
<< string_value;
return false;
}
}
} // namespace
RendererSettings CreateRendererSettings() {
RendererSettings renderer_settings;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
renderer_settings.partial_swap_enabled =
!command_line->HasSwitch(switches::kUIDisablePartialSwap);
#if BUILDFLAG(IS_APPLE)
renderer_settings.release_overlay_resources_after_gpu_query = true;
renderer_settings.auto_resize_output_surface = false;
#elif BUILDFLAG(IS_CHROMEOS)
renderer_settings.auto_resize_output_surface = false;
#endif
renderer_settings.allow_antialiasing =
!command_line->HasSwitch(switches::kDisableCompositedAntialiasing);
if (command_line->HasSwitch(switches::kSlowDownCompositingScaleFactor)) {
const int kMinSlowDownScaleFactor = 1;
const int kMaxSlowDownScaleFactor = 1000;
GetSwitchValueAsInt(command_line, switches::kSlowDownCompositingScaleFactor,
kMinSlowDownScaleFactor, kMaxSlowDownScaleFactor,
&renderer_settings.slow_down_compositing_scale_factor);
}
#if BUILDFLAG(IS_CHROMEOS)
// Used finch experiment to determine the best value. See b:330617490 for
// details.
renderer_settings.occlusion_culler_settings.quad_split_limit = 12;
renderer_settings.occlusion_culler_settings
.generate_complex_occluder_for_rounded_corners = true;
#else
renderer_settings.occlusion_culler_settings.quad_split_limit =
features::DrawQuadSplitLimit();
#endif
#if BUILDFLAG(IS_OZONE)
if (command_line->HasSwitch(switches::kEnableHardwareOverlays)) {
renderer_settings.overlay_strategies = ParseOverlayStrategies(
command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays));
} else {
auto& host_properties =
ui::OzonePlatform::GetInstance()->GetPlatformRuntimeProperties();
if (host_properties.supports_overlays) {
renderer_settings.overlay_strategies = {OverlayStrategy::kFullscreen,
OverlayStrategy::kSingleOnTop,
OverlayStrategy::kUnderlay};
}
}
#endif
return renderer_settings;
}
DebugRendererSettings CreateDefaultDebugRendererSettings() {
DebugRendererSettings result;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
result.tint_composited_content =
command_line->HasSwitch(switches::kTintCompositedContent);
result.tint_composited_content_modulate =
command_line->HasSwitch(switches::kTintCompositedContentModulate);
result.show_overdraw_feedback =
command_line->HasSwitch(switches::kShowOverdrawFeedback);
result.show_dc_layer_debug_borders =
command_line->HasSwitch(switches::kShowDCLayerDebugBorders);
result.show_aggregated_damage =
command_line->HasSwitch(switches::kShowAggregatedDamage);
return result;
}
} // namespace viz
|