| Index: ui/compositor/compositor_util.cc
|
| diff --git a/ui/compositor/compositor_util.cc b/ui/compositor/compositor_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8ef1130eb92ef363f48b29f771c587aea33b5f15
|
| --- /dev/null
|
| +++ b/ui/compositor/compositor_util.cc
|
| @@ -0,0 +1,54 @@
|
| +// Copyright 2017 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 "ui/compositor/compositor_util.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "cc/base/switches.h"
|
| +#include "cc/output/renderer_settings.h"
|
| +#include "ui/compositor/compositor_switches.h"
|
| +#include "ui/display/display_switches.h"
|
| +#include "ui/gfx/switches.h"
|
| +
|
| +namespace ui {
|
| +
|
| +void InitializeRendererSettings(
|
| + const base::Callback<uint32_t(gfx::BufferFormat, gfx::BufferUsage)>&
|
| + texture_target_callback,
|
| + cc::RendererSettings* renderer_settings) {
|
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
| + renderer_settings->partial_swap_enabled =
|
| + !command_line->HasSwitch(switches::kUIDisablePartialSwap);
|
| +#if defined(OS_WIN)
|
| + renderer_settings->finish_rendering_on_resize = true;
|
| +#elif defined(OS_MACOSX)
|
| + renderer_settings->release_overlay_resources_after_gpu_query = true;
|
| +#endif
|
| + renderer_settings->gl_composited_texture_quad_border =
|
| + command_line->HasSwitch(cc::switches::kGlCompositedTextureQuadBorder);
|
| + renderer_settings->show_overdraw_feedback =
|
| + command_line->HasSwitch(cc::switches::kShowOverdrawFeedback);
|
| + if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures))
|
| + renderer_settings->preferred_tile_format = cc::RGBA_4444;
|
| + renderer_settings->enable_color_correct_rendering =
|
| + command_line->HasSwitch(switches::kEnableColorCorrectRendering) ||
|
| + command_line->HasSwitch(switches::kEnableHDR);
|
| + // Populate buffer_to_texture_target_map for all buffer usage/formats.
|
| + for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST);
|
| + ++usage_idx) {
|
| + gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx);
|
| + for (int format_idx = 0;
|
| + format_idx <= static_cast<int>(gfx::BufferFormat::LAST);
|
| + ++format_idx) {
|
| + gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx);
|
| + renderer_settings
|
| + ->buffer_to_texture_target_map[std::make_pair(usage, format)] =
|
| + texture_target_callback.Run(format, usage);
|
| + }
|
| + }
|
| + renderer_settings->disallow_non_exact_resource_reuse =
|
| + command_line->HasSwitch(cc::switches::kDisallowNonExactResourceReuse);
|
| +}
|
| +
|
| +} // namespace ui
|
|
|