Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: ui/compositor/compositor.cc

Issue 2879463002: Initialize RendererSettings in ContextFactory (Closed)
Patch Set: const RendererSettings Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <deque> 10 #include <deque>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // This will ensure PictureLayers always can have LCD text, to match the 76 // This will ensure PictureLayers always can have LCD text, to match the
77 // previous behaviour with ContentLayers, where LCD-not-allowed notifications 77 // previous behaviour with ContentLayers, where LCD-not-allowed notifications
78 // were ignored. 78 // were ignored.
79 settings.layers_always_allowed_lcd_text = true; 79 settings.layers_always_allowed_lcd_text = true;
80 // Use occlusion to allow more overlapping windows to take less memory. 80 // Use occlusion to allow more overlapping windows to take less memory.
81 settings.use_occlusion_for_tile_prioritization = true; 81 settings.use_occlusion_for_tile_prioritization = true;
82 refresh_rate_ = settings.renderer_settings.refresh_rate = 82 refresh_rate_ = settings.renderer_settings.refresh_rate =
83 context_factory_->GetRefreshRate(); 83 context_factory_->GetRefreshRate();
84 settings.main_frame_before_activation_enabled = false; 84 settings.main_frame_before_activation_enabled = false;
85 settings.renderer_settings.partial_swap_enabled =
86 !command_line->HasSwitch(switches::kUIDisablePartialSwap);
87 #if defined(OS_WIN)
88 settings.renderer_settings.finish_rendering_on_resize = true;
89 #elif defined(OS_MACOSX)
90 settings.renderer_settings.release_overlay_resources_after_gpu_query = true;
91 #endif
92 settings.renderer_settings.gl_composited_texture_quad_border =
93 command_line->HasSwitch(cc::switches::kGlCompositedTextureQuadBorder);
94 settings.renderer_settings.show_overdraw_feedback =
95 command_line->HasSwitch(cc::switches::kShowOverdrawFeedback);
96 85
97 if (command_line->HasSwitch(cc::switches::kUIShowCompositedLayerBorders)) { 86 if (command_line->HasSwitch(cc::switches::kUIShowCompositedLayerBorders)) {
98 std::string layer_borders_string = command_line->GetSwitchValueASCII( 87 std::string layer_borders_string = command_line->GetSwitchValueASCII(
99 cc::switches::kUIShowCompositedLayerBorders); 88 cc::switches::kUIShowCompositedLayerBorders);
100 std::vector<base::StringPiece> entries = base::SplitStringPiece( 89 std::vector<base::StringPiece> entries = base::SplitStringPiece(
101 layer_borders_string, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 90 layer_borders_string, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
102 if (entries.empty()) { 91 if (entries.empty()) {
103 settings.initial_debug_state.show_debug_borders.set(); 92 settings.initial_debug_state.show_debug_borders.set();
104 } else { 93 } else {
105 for (const auto& entry : entries) { 94 for (const auto& entry : entries) {
(...skipping 28 matching lines...) Expand all
134 settings.initial_debug_state.show_screen_space_rects = 123 settings.initial_debug_state.show_screen_space_rects =
135 command_line->HasSwitch(cc::switches::kUIShowScreenSpaceRects); 124 command_line->HasSwitch(cc::switches::kUIShowScreenSpaceRects);
136 125
137 settings.initial_debug_state.SetRecordRenderingStats( 126 settings.initial_debug_state.SetRecordRenderingStats(
138 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking)); 127 command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
139 settings.enable_surface_synchronization = 128 settings.enable_surface_synchronization =
140 command_line->HasSwitch(cc::switches::kEnableSurfaceSynchronization); 129 command_line->HasSwitch(cc::switches::kEnableSurfaceSynchronization);
141 130
142 settings.use_zero_copy = IsUIZeroCopyEnabled(); 131 settings.use_zero_copy = IsUIZeroCopyEnabled();
143 132
144 if (command_line->HasSwitch(switches::kUIEnableRGBA4444Textures))
145 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444;
146
147 settings.use_layer_lists = 133 settings.use_layer_lists =
148 command_line->HasSwitch(cc::switches::kUIEnableLayerLists); 134 command_line->HasSwitch(cc::switches::kUIEnableLayerLists);
149 135
150 settings.enable_color_correct_rasterization = 136 settings.enable_color_correct_rasterization =
151 command_line->HasSwitch(switches::kEnableColorCorrectRendering); 137 command_line->HasSwitch(switches::kEnableColorCorrectRendering);
152 settings.renderer_settings.enable_color_correct_rendering =
153 settings.enable_color_correct_rasterization ||
154 command_line->HasSwitch(switches::kEnableHDR);
155 138
156 // UI compositor always uses partial raster if not using zero-copy. Zero copy 139 // UI compositor always uses partial raster if not using zero-copy. Zero copy
157 // doesn't currently support partial raster. 140 // doesn't currently support partial raster.
158 settings.use_partial_raster = !settings.use_zero_copy; 141 settings.use_partial_raster = !settings.use_zero_copy;
159 142
160 // Populate buffer_to_texture_target_map for all buffer usage/formats.
161 for (int usage_idx = 0; usage_idx <= static_cast<int>(gfx::BufferUsage::LAST);
162 ++usage_idx) {
163 gfx::BufferUsage usage = static_cast<gfx::BufferUsage>(usage_idx);
164 for (int format_idx = 0;
165 format_idx <= static_cast<int>(gfx::BufferFormat::LAST);
166 ++format_idx) {
167 gfx::BufferFormat format = static_cast<gfx::BufferFormat>(format_idx);
168 uint32_t target = context_factory_->GetImageTextureTarget(format, usage);
169 settings.renderer_settings
170 .buffer_to_texture_target_map[std::make_pair(usage, format)] = target;
171 }
172 }
173
174 settings.gpu_memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024; 143 settings.gpu_memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024;
175 settings.gpu_memory_policy.priority_cutoff_when_visible = 144 settings.gpu_memory_policy.priority_cutoff_when_visible =
176 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 145 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
177 146
178 settings.disallow_non_exact_resource_reuse = 147 settings.disallow_non_exact_resource_reuse =
179 command_line->HasSwitch(cc::switches::kDisallowNonExactResourceReuse); 148 command_line->HasSwitch(cc::switches::kDisallowNonExactResourceReuse);
180 settings.renderer_settings.disallow_non_exact_resource_reuse = 149
181 settings.disallow_non_exact_resource_reuse; 150 // TODO(staraz): LayerTreeSettings shouldn't have a RendererSettings.
151 settings.renderer_settings = context_factory_->GetRendererSettings();
182 152
183 base::TimeTicks before_create = base::TimeTicks::Now(); 153 base::TimeTicks before_create = base::TimeTicks::Now();
184 154
185 animation_host_ = cc::AnimationHost::CreateMainInstance(); 155 animation_host_ = cc::AnimationHost::CreateMainInstance();
186 156
187 cc::LayerTreeHost::InitParams params; 157 cc::LayerTreeHost::InitParams params;
188 params.client = this; 158 params.client = this;
189 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); 159 params.task_graph_runner = context_factory_->GetTaskGraphRunner();
190 params.settings = &settings; 160 params.settings = &settings;
191 params.main_task_runner = task_runner_; 161 params.main_task_runner = task_runner_;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 505
536 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 506 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
537 return host_->GetDebugState(); 507 return host_->GetDebugState();
538 } 508 }
539 509
540 void Compositor::SetLayerTreeDebugState( 510 void Compositor::SetLayerTreeDebugState(
541 const cc::LayerTreeDebugState& debug_state) { 511 const cc::LayerTreeDebugState& debug_state) {
542 host_->SetDebugState(debug_state); 512 host_->SetDebugState(debug_state);
543 } 513 }
544 514
545 const cc::RendererSettings& Compositor::GetRendererSettings() const {
546 return host_->GetSettings().renderer_settings;
547 }
548
549 std::unique_ptr<CompositorLock> Compositor::GetCompositorLock( 515 std::unique_ptr<CompositorLock> Compositor::GetCompositorLock(
550 CompositorLockClient* client, 516 CompositorLockClient* client,
551 base::TimeDelta timeout) { 517 base::TimeDelta timeout) {
552 // This uses the main WeakPtrFactory to break the connection from the lock to 518 // This uses the main WeakPtrFactory to break the connection from the lock to
553 // the Compositor when the Compositor is destroyed. 519 // the Compositor when the Compositor is destroyed.
554 auto lock = 520 auto lock =
555 base::MakeUnique<CompositorLock>(client, weak_ptr_factory_.GetWeakPtr()); 521 base::MakeUnique<CompositorLock>(client, weak_ptr_factory_.GetWeakPtr());
556 bool was_empty = active_locks_.empty(); 522 bool was_empty = active_locks_.empty();
557 active_locks_.push_back(lock.get()); 523 active_locks_.push_back(lock.get());
558 524
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 void Compositor::TimeoutLocks() { 568 void Compositor::TimeoutLocks() {
603 // Make a copy, we're going to cause |active_locks_| to become 569 // Make a copy, we're going to cause |active_locks_| to become
604 // empty. 570 // empty.
605 std::vector<CompositorLock*> locks = active_locks_; 571 std::vector<CompositorLock*> locks = active_locks_;
606 for (auto* lock : locks) 572 for (auto* lock : locks)
607 lock->TimeoutLock(); 573 lock->TimeoutLock();
608 DCHECK(active_locks_.empty()); 574 DCHECK(active_locks_.empty());
609 } 575 }
610 576
611 } // namespace ui 577 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698