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

Side by Side Diff: blimp/client/support/compositor/blimp_layer_tree_settings.cc

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/client/support/compositor/blimp_layer_tree_settings.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h"
12 #include "base/sys_info.h"
13 #include "blimp/client/support/compositor/blimp_gpu_memory_buffer_manager.h"
14 #include "cc/base/switches.h"
15 #include "cc/trees/layer_tree_settings.h"
16 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/gfx/buffer_types.h"
18 #include "ui/gl/gl_switches.h"
19
20 namespace blimp {
21 namespace client {
22
23 // TODO(dtrainor): This is temporary to get the compositor up and running.
24 // Much of this will either have to be pulled from the server or refactored to
25 // share the settings from render_widget_compositor.cc.
26 void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) {
27 // For web contents, layer transforms should scale up the contents of layers
28 // to keep content always crisp when possible.
29 settings->layer_transforms_should_scale_layer_contents = true;
30
31 settings->main_frame_before_activation_enabled = false;
32 settings->default_tile_size = gfx::Size(256, 256);
33 settings->gpu_rasterization_msaa_sample_count = 0;
34 settings->gpu_rasterization_forced = false;
35 settings->gpu_rasterization_enabled = false;
36 settings->can_use_lcd_text = false;
37 settings->use_distance_field_text = false;
38 #if defined(OS_MACOSX)
39 settings->use_zero_copy = true;
40 #else
41 settings->use_zero_copy = false;
42 #endif
43 settings->enable_elastic_overscroll = false;
44 settings->image_decode_tasks_enabled = false;
45 settings->single_thread_proxy_scheduler = false;
46 settings->initial_debug_state.show_debug_borders = false;
47 settings->initial_debug_state.show_fps_counter = false;
48 settings->initial_debug_state.show_layer_animation_bounds_rects = false;
49 settings->initial_debug_state.show_paint_rects = false;
50 settings->initial_debug_state.show_property_changed_rects = false;
51 settings->initial_debug_state.show_surface_damage_rects = false;
52 settings->initial_debug_state.show_screen_space_rects = false;
53 settings->initial_debug_state.SetRecordRenderingStats(false);
54
55 #if defined(OS_ANDROID)
56 if (base::SysInfo::IsLowEndDevice())
57 settings->gpu_rasterization_enabled = false;
58 settings->using_synchronous_renderer_compositor = false;
59 settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE;
60 settings->scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300);
61 settings->scrollbar_fade_resize_delay = base::TimeDelta::FromSeconds(2);
62 settings->scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300);
63 settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
64 settings->renderer_settings.highp_threshold_min = 2048;
65 settings->ignore_root_layer_flings = false;
66 bool use_low_memory_policy = base::SysInfo::IsLowEndDevice();
67 if (use_low_memory_policy) {
68 // On low-end we want to be very carefull about killing other
69 // apps. So initially we use 50% more memory to avoid flickering
70 // or raster-on-demand.
71 settings->max_memory_for_prepaint_percentage = 67;
72
73 settings->renderer_settings.preferred_tile_format = cc::RGBA_4444;
74 } else {
75 // On other devices we have increased memory excessively to avoid
76 // raster-on-demand already, so now we reserve 50% _only_ to avoid
77 // raster-on-demand, and use 50% of the memory otherwise.
78 settings->max_memory_for_prepaint_percentage = 50;
79 }
80 settings->renderer_settings.should_clear_root_render_pass = true;
81
82 // TODO(danakj): Only do this on low end devices.
83 settings->create_low_res_tiling = true;
84
85 #elif !defined(OS_MACOSX)
86 settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE;
87 settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
88 settings->scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500);
89 settings->scrollbar_fade_resize_delay =
90 base::TimeDelta::FromMilliseconds(500);
91 settings->scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300);
92
93 // When pinching in, only show the pinch-viewport overlay scrollbars if the
94 // page scale is at least some threshold away from the minimum. i.e. don't
95 // show the pinch scrollbars when at minimum scale.
96 // TODO(dtrainor): Update this since https://crrev.com/1267603004 landed.
97 // settings->scrollbar_show_scale_threshold = 1.05f;
98 #endif
99
100 // Set the gpu memory policy.
101 cc::ManagedMemoryPolicy& memory_policy = settings->gpu_memory_policy;
102 memory_policy.bytes_limit_when_visible = 0;
103
104 #if defined(OS_ANDROID)
105 // We can't query available GPU memory from the system on Android.
106 // Physical memory is also mis-reported sometimes (eg. Nexus 10 reports
107 // 1262MB when it actually has 2GB, while Razr M has 1GB but only reports
108 // 128MB java heap size). First we estimate physical memory using both.
109 size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB();
110 size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB();
111 size_t physical_memory_mb = 0;
112 if (dalvik_mb >= 256)
113 physical_memory_mb = dalvik_mb * 4;
114 else
115 physical_memory_mb = std::max(dalvik_mb * 4, (physical_mb * 4) / 3);
116
117 // Now we take a default of 1/8th of memory on high-memory devices,
118 // and gradually scale that back for low-memory devices (to be nicer
119 // to other apps so they don't get killed). Examples:
120 // Nexus 4/10(2GB) 256MB (normally 128MB)
121 // Droid Razr M(1GB) 114MB (normally 57MB)
122 // Galaxy Nexus(1GB) 100MB (normally 50MB)
123 // Xoom(1GB) 100MB (normally 50MB)
124 // Nexus S(low-end) 8MB (normally 8MB)
125 // Note that the compositor now uses only some of this memory for
126 // pre-painting and uses the rest only for 'emergencies'.
127 if (memory_policy.bytes_limit_when_visible == 0) {
128 // NOTE: Non-low-end devices use only 50% of these limits,
129 // except during 'emergencies' where 100% can be used.
130 if (!base::SysInfo::IsLowEndDevice()) {
131 if (physical_memory_mb >= 1536)
132 memory_policy.bytes_limit_when_visible =
133 physical_memory_mb / 8; // >192MB
134 else if (physical_memory_mb >= 1152)
135 memory_policy.bytes_limit_when_visible =
136 physical_memory_mb / 8; // >144MB
137 else if (physical_memory_mb >= 768)
138 memory_policy.bytes_limit_when_visible =
139 physical_memory_mb / 10; // >76MB
140 else
141 memory_policy.bytes_limit_when_visible =
142 physical_memory_mb / 12; // <64MB
143 } else {
144 // Low-end devices have 512MB or less memory by definition
145 // so we hard code the limit rather than relying on the heuristics
146 // above. Low-end devices use 4444 textures so we can use a lower limit.
147 memory_policy.bytes_limit_when_visible = 8;
148 }
149 memory_policy.bytes_limit_when_visible =
150 memory_policy.bytes_limit_when_visible * 1024 * 1024;
151 // Clamp the observed value to a specific range on Android.
152 memory_policy.bytes_limit_when_visible =
153 std::max(memory_policy.bytes_limit_when_visible,
154 static_cast<size_t>(8 * 1024 * 1024));
155 memory_policy.bytes_limit_when_visible =
156 std::min(memory_policy.bytes_limit_when_visible,
157 static_cast<size_t>(256 * 1024 * 1024));
158 }
159 memory_policy.priority_cutoff_when_visible =
160 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING;
161 #else
162 // Ignore what the system said and give all clients the same maximum
163 // allocation on desktop platforms.
164 memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024;
165 memory_policy.priority_cutoff_when_visible =
166 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
167 #endif
168
169 int default_tile_size = 256;
170 settings->default_tile_size.SetSize(default_tile_size, default_tile_size);
171
172 settings->renderer_settings.buffer_to_texture_target_map =
173 BlimpGpuMemoryBufferManager::GetDefaultBufferToTextureTargetMap();
174 }
175
176 } // namespace client
177 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698