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
3// found in the LICENSE file.
4
5#include "cc/base/switches.h"
6
7#include "base/command_line.h"
8
9namespace cc {
10namespace switches {
11
12// On platforms where checkerboards are used, prefer background colors instead
13// of checkerboards.
14const char kBackgroundColorInsteadOfCheckerboard[] =
15    "background-color-instead-of-checkerboard";
16
17// Disables LCD text.
18const char kDisableLCDText[] = "disable-lcd-text";
19
20const char kDisableThreadedAnimation[] = "disable-threaded-animation";
21
22// Disables layer-edge anti-aliasing in the compositor.
23const char kDisableCompositedAntialiasing[] =
24    "disable-composited-antialiasing";
25
26// Paint content on the main thread instead of the compositor thread.
27// Overrides the kEnableImplSidePainting flag.
28const char kDisableImplSidePainting[] = "disable-impl-side-painting";
29
30// Enables LCD text.
31const char kEnableLCDText[] = "enable-lcd-text";
32
33// Paint content on the compositor thread instead of the main thread.
34const char kEnableImplSidePainting[] = "enable-impl-side-painting";
35
36const char kEnableTopControlsPositionCalculation[] =
37    "enable-top-controls-position-calculation";
38
39// Allow heuristics to determine when a layer tile should be drawn with
40// the Skia GPU backend.  Only valid with GPU accelerated compositing +
41// impl-side painting.
42const char kEnableGPURasterization[] = "enable-gpu-rasterization";
43
44// The height of the movable top controls.
45const char kTopControlsHeight[] = "top-controls-height";
46
47// Percentage of the top controls need to be hidden before they will auto hide.
48const char kTopControlsHideThreshold[] = "top-controls-hide-threshold";
49
50// Percentage of the top controls need to be shown before they will auto show.
51const char kTopControlsShowThreshold[] = "top-controls-show-threshold";
52
53// Number of worker threads used to rasterize content.
54const char kNumRasterThreads[] = "num-raster-threads";
55
56// Show metrics about overdraw in about:tracing recordings, such as the number
57// of pixels culled, and the number of pixels drawn, for each frame.
58const char kTraceOverdraw[] = "trace-overdraw";
59
60// Re-rasters everything multiple times to simulate a much slower machine.
61// Give a scale factor to cause raster to take that many times longer to
62// complete, such as --slow-down-raster-scale-factor=25.
63const char kSlowDownRasterScaleFactor[] = "slow-down-raster-scale-factor";
64
65// Max tiles allowed for each tilings interest area.
66const char kMaxTilesForInterestArea[] = "max-tiles-for-interest-area";
67
68// The amount of unused resource memory compositor is allowed to keep around.
69const char kMaxUnusedResourceMemoryUsagePercentage[] =
70    "max-unused-resource-memory-usage-percentage";
71
72// Causes the compositor to render to textures which are then sent to the parent
73// through the texture mailbox mechanism.
74// Requires --enable-compositor-frame-message.
75const char kCompositeToMailbox[] = "composite-to-mailbox";
76
77// Check that property changes during paint do not occur.
78const char kStrictLayerPropertyChangeChecking[] =
79    "strict-layer-property-change-checking";
80
81// Virtual viewport for fixed-position elements, scrollbars during pinch.
82const char kEnablePinchVirtualViewport[] = "enable-pinch-virtual-viewport";
83
84const char kEnablePartialSwap[] = "enable-partial-swap";
85// Disable partial swap which is needed for some OpenGL drivers / emulators.
86const char kUIDisablePartialSwap[] = "ui-disable-partial-swap";
87
88const char kEnablePerTilePainting[] = "enable-per-tile-painting";
89const char kUIEnablePerTilePainting[] = "ui-enable-per-tile-painting";
90
91// Renders a border around compositor layers to help debug and study
92// layer compositing.
93const char kShowCompositedLayerBorders[] = "show-composited-layer-borders";
94const char kUIShowCompositedLayerBorders[] = "ui-show-layer-borders";
95
96// Draws a FPS indicator
97const char kShowFPSCounter[] = "show-fps-counter";
98const char kUIShowFPSCounter[] = "ui-show-fps-counter";
99
100// Renders a border that represents the bounding box for the layer's animation.
101const char kShowLayerAnimationBounds[] = "show-layer-animation-bounds";
102const char kUIShowLayerAnimationBounds[] = "ui-show-layer-animation-bounds";
103
104// Show rects in the HUD around layers whose properties have changed.
105const char kShowPropertyChangedRects[] = "show-property-changed-rects";
106const char kUIShowPropertyChangedRects[] = "ui-show-property-changed-rects";
107
108// Show rects in the HUD around damage as it is recorded into each render
109// surface.
110const char kShowSurfaceDamageRects[] = "show-surface-damage-rects";
111const char kUIShowSurfaceDamageRects[] = "ui-show-surface-damage-rects";
112
113// Show rects in the HUD around the screen-space transformed bounds of every
114// layer.
115const char kShowScreenSpaceRects[] = "show-screenspace-rects";
116const char kUIShowScreenSpaceRects[] = "ui-show-screenspace-rects";
117
118// Show rects in the HUD around the screen-space transformed bounds of every
119// layer's replica, when they have one.
120const char kShowReplicaScreenSpaceRects[] = "show-replica-screenspace-rects";
121const char kUIShowReplicaScreenSpaceRects[] =
122    "ui-show-replica-screenspace-rects";
123
124// Show rects in the HUD wherever something is known to be drawn opaque and is
125// considered occluding the pixels behind it.
126const char kShowOccludingRects[] = "show-occluding-rects";
127const char kUIShowOccludingRects[] = "ui-show-occluding-rects";
128
129// Show rects in the HUD wherever something is not known to be drawn opaque and
130// is not considered to be occluding the pixels behind it.
131const char kShowNonOccludingRects[] = "show-nonoccluding-rects";
132const char kUIShowNonOccludingRects[] = "ui-show-nonoccluding-rects";
133
134// Enable rasterizer that writes directly to GPU memory.
135const char kEnableMapImage[] = "enable-map-image";
136
137// Disable rasterizer that writes directly to GPU memory.
138// Overrides the kEnableMapImage flag.
139const char kDisableMapImage[] = "disable-map-image";
140
141// Prevents the layer tree unit tests from timing out.
142const char kCCLayerTreeTestNoTimeout[] = "cc-layer-tree-test-no-timeout";
143
144// Makes pixel tests write their output instead of read it.
145const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests";
146
147// Disable textures using RGBA_4444 layout.
148const char kDisable4444Textures[] = "disable-4444-textures";
149
150// Disable touch hit testing in the compositor.
151const char kDisableCompositorTouchHitTesting[] =
152    "disable-compositor-touch-hit-testing";
153
154bool IsLCDTextEnabled() {
155  const CommandLine* command_line = CommandLine::ForCurrentProcess();
156  if (command_line->HasSwitch(switches::kDisableLCDText))
157    return false;
158  else if (command_line->HasSwitch(switches::kEnableLCDText))
159    return true;
160
161#if defined(OS_ANDROID)
162  return false;
163#else
164  return true;
165#endif
166}
167
168namespace {
169bool CheckImplSidePaintingStatus() {
170  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
171
172  if (command_line.HasSwitch(switches::kDisableImplSidePainting))
173    return false;
174  else if (command_line.HasSwitch(switches::kEnableImplSidePainting))
175    return true;
176
177#if defined(OS_ANDROID)
178  return true;
179#else
180  return false;
181#endif
182}
183
184bool CheckGPURasterizationStatus() {
185  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
186  return command_line.HasSwitch(switches::kEnableGPURasterization);
187}
188
189}  // namespace
190
191bool IsImplSidePaintingEnabled() {
192  static bool enabled = CheckImplSidePaintingStatus();
193  return enabled;
194}
195
196bool IsGPURasterizationEnabled() {
197  static bool enabled = CheckGPURasterizationStatus();
198  return enabled;
199}
200
201bool IsMapImageEnabled() {
202  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
203
204  if (command_line.HasSwitch(switches::kDisableMapImage))
205    return false;
206  else if (command_line.HasSwitch(switches::kEnableMapImage))
207    return true;
208
209  return false;
210}
211
212}  // namespace switches
213}  // namespace cc
214