1 // Copyright 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/debug/debug_colors.h"
6
7 #include "cc/trees/layer_tree_impl.h"
8
9 namespace cc {
10
Scale(float width,const LayerTreeImpl * tree_impl)11 static float Scale(float width, const LayerTreeImpl* tree_impl) {
12 return width * (tree_impl ? tree_impl->device_scale_factor() : 1);
13 }
14
15 // ======= Layer border colors =======
16
17 // Tiled content layers are orange.
TiledContentLayerBorderColor()18 SkColor DebugColors::TiledContentLayerBorderColor() {
19 return SkColorSetARGB(128, 255, 128, 0);
20 }
TiledContentLayerBorderWidth(const LayerTreeImpl * tree_impl)21 int DebugColors::TiledContentLayerBorderWidth(const LayerTreeImpl* tree_impl) {
22 return Scale(2, tree_impl);
23 }
24
25 // Image layers are olive.
ImageLayerBorderColor()26 SkColor DebugColors::ImageLayerBorderColor() {
27 return SkColorSetARGB(128, 128, 128, 0);
28 }
ImageLayerBorderWidth(const LayerTreeImpl * tree_impl)29 int DebugColors::ImageLayerBorderWidth(const LayerTreeImpl* tree_impl) {
30 return Scale(2, tree_impl);
31 }
32
33 // Non-tiled content layers area green.
ContentLayerBorderColor()34 SkColor DebugColors::ContentLayerBorderColor() {
35 return SkColorSetARGB(128, 0, 128, 32);
36 }
ContentLayerBorderWidth(const LayerTreeImpl * tree_impl)37 int DebugColors::ContentLayerBorderWidth(const LayerTreeImpl* tree_impl) {
38 return Scale(2, tree_impl);
39 }
40
41 // Masking layers are pale blue and wide.
MaskingLayerBorderColor()42 SkColor DebugColors::MaskingLayerBorderColor() {
43 return SkColorSetARGB(48, 128, 255, 255);
44 }
MaskingLayerBorderWidth(const LayerTreeImpl * tree_impl)45 int DebugColors::MaskingLayerBorderWidth(const LayerTreeImpl* tree_impl) {
46 return Scale(20, tree_impl);
47 }
48
49 // Other container layers are yellow.
ContainerLayerBorderColor()50 SkColor DebugColors::ContainerLayerBorderColor() {
51 return SkColorSetARGB(192, 255, 255, 0);
52 }
ContainerLayerBorderWidth(const LayerTreeImpl * tree_impl)53 int DebugColors::ContainerLayerBorderWidth(const LayerTreeImpl* tree_impl) {
54 return Scale(2, tree_impl);
55 }
56
57 // Render surfaces are blue.
SurfaceBorderColor()58 SkColor DebugColors::SurfaceBorderColor() {
59 return SkColorSetARGB(100, 0, 0, 255);
60 }
SurfaceBorderWidth(const LayerTreeImpl * tree_impl)61 int DebugColors::SurfaceBorderWidth(const LayerTreeImpl* tree_impl) {
62 return Scale(2, tree_impl);
63 }
64
65 // Replicas of render surfaces are purple.
SurfaceReplicaBorderColor()66 SkColor DebugColors::SurfaceReplicaBorderColor() {
67 return SkColorSetARGB(100, 160, 0, 255);
68 }
SurfaceReplicaBorderWidth(const LayerTreeImpl * tree_impl)69 int DebugColors::SurfaceReplicaBorderWidth(const LayerTreeImpl* tree_impl) {
70 return Scale(2, tree_impl);
71 }
72
73 // ======= Tile colors =======
74
75 // High-res tile borders are cyan.
HighResTileBorderColor()76 SkColor DebugColors::HighResTileBorderColor() {
77 return SkColorSetARGB(100, 80, 200, 200);
78 }
HighResTileBorderWidth(const LayerTreeImpl * tree_impl)79 int DebugColors::HighResTileBorderWidth(const LayerTreeImpl* tree_impl) {
80 return Scale(1, tree_impl);
81 }
82
83 // Low-res tile borders are purple.
LowResTileBorderColor()84 SkColor DebugColors::LowResTileBorderColor() {
85 return SkColorSetARGB(100, 212, 83, 192);
86 }
LowResTileBorderWidth(const LayerTreeImpl * tree_impl)87 int DebugColors::LowResTileBorderWidth(const LayerTreeImpl* tree_impl) {
88 return Scale(2, tree_impl);
89 }
90
91 // Other high-resolution tile borders are yellow.
ExtraHighResTileBorderColor()92 SkColor DebugColors::ExtraHighResTileBorderColor() {
93 return SkColorSetARGB(100, 239, 231, 20);
94 }
ExtraHighResTileBorderWidth(const LayerTreeImpl * tree_impl)95 int DebugColors::ExtraHighResTileBorderWidth(const LayerTreeImpl* tree_impl) {
96 return Scale(2, tree_impl);
97 }
98
99 // Other low-resolution tile borders are green.
ExtraLowResTileBorderColor()100 SkColor DebugColors::ExtraLowResTileBorderColor() {
101 return SkColorSetARGB(100, 93, 186, 18);
102 }
ExtraLowResTileBorderWidth(const LayerTreeImpl * tree_impl)103 int DebugColors::ExtraLowResTileBorderWidth(const LayerTreeImpl* tree_impl) {
104 return Scale(2, tree_impl);
105 }
106
107 // Missing tile borders are red.
MissingTileBorderColor()108 SkColor DebugColors::MissingTileBorderColor() {
109 return SkColorSetARGB(100, 255, 0, 0);
110 }
MissingTileBorderWidth(const LayerTreeImpl * tree_impl)111 int DebugColors::MissingTileBorderWidth(const LayerTreeImpl* tree_impl) {
112 return Scale(1, tree_impl);
113 }
114
115 // Culled tile borders are brown.
CulledTileBorderColor()116 SkColor DebugColors::CulledTileBorderColor() {
117 return SkColorSetARGB(120, 160, 100, 0);
118 }
CulledTileBorderWidth(const LayerTreeImpl * tree_impl)119 int DebugColors::CulledTileBorderWidth(const LayerTreeImpl* tree_impl) {
120 return Scale(1, tree_impl);
121 }
122
123 // Solid color tile borders are grey.
SolidColorTileBorderColor()124 SkColor DebugColors::SolidColorTileBorderColor() {
125 return SkColorSetARGB(128, 128, 128, 128);
126 }
SolidColorTileBorderWidth(const LayerTreeImpl * tree_impl)127 int DebugColors::SolidColorTileBorderWidth(const LayerTreeImpl* tree_impl) {
128 return Scale(1, tree_impl);
129 }
130
131 // Picture tile borders are dark grey.
PictureTileBorderColor()132 SkColor DebugColors::PictureTileBorderColor() {
133 return SkColorSetARGB(64, 64, 64, 0);
134 }
PictureTileBorderWidth(const LayerTreeImpl * tree_impl)135 int DebugColors::PictureTileBorderWidth(const LayerTreeImpl* tree_impl) {
136 return Scale(1, tree_impl);
137 }
138
139 // Direct picture borders are chartreuse.
DirectPictureBorderColor()140 SkColor DebugColors::DirectPictureBorderColor() {
141 return SkColorSetARGB(255, 127, 255, 0);
142 }
DirectPictureBorderWidth(const LayerTreeImpl * tree_impl)143 int DebugColors::DirectPictureBorderWidth(const LayerTreeImpl* tree_impl) {
144 return Scale(1, tree_impl);
145 }
146
147 // ======= Checkerboard colors =======
148
149 // Non-debug checkerboards are grey.
DefaultCheckerboardColor()150 SkColor DebugColors::DefaultCheckerboardColor() {
151 return SkColorSetRGB(241, 241, 241);
152 }
153
154 // Invalidated tiles get sky blue checkerboards.
InvalidatedTileCheckerboardColor()155 SkColor DebugColors::InvalidatedTileCheckerboardColor() {
156 return SkColorSetRGB(128, 200, 245);
157 }
158
159 // Evicted tiles get pale red checkerboards.
EvictedTileCheckerboardColor()160 SkColor DebugColors::EvictedTileCheckerboardColor() {
161 return SkColorSetRGB(255, 200, 200);
162 }
163
164 // ======= Debug rect colors =======
165
166 // Paint rects in red.
PaintRectBorderColor()167 SkColor DebugColors::PaintRectBorderColor() {
168 return SkColorSetARGB(255, 255, 0, 0);
169 }
PaintRectBorderWidth()170 int DebugColors::PaintRectBorderWidth() { return 2; }
PaintRectFillColor()171 SkColor DebugColors::PaintRectFillColor() {
172 return SkColorSetARGB(30, 255, 0, 0);
173 }
174
175 // Property-changed rects in blue.
PropertyChangedRectBorderColor()176 SkColor DebugColors::PropertyChangedRectBorderColor() {
177 return SkColorSetARGB(255, 0, 0, 255);
178 }
PropertyChangedRectBorderWidth()179 int DebugColors::PropertyChangedRectBorderWidth() { return 2; }
PropertyChangedRectFillColor()180 SkColor DebugColors::PropertyChangedRectFillColor() {
181 return SkColorSetARGB(30, 0, 0, 255);
182 }
183
184 // Surface damage rects in yellow-orange.
SurfaceDamageRectBorderColor()185 SkColor DebugColors::SurfaceDamageRectBorderColor() {
186 return SkColorSetARGB(255, 200, 100, 0);
187 }
SurfaceDamageRectBorderWidth()188 int DebugColors::SurfaceDamageRectBorderWidth() { return 2; }
SurfaceDamageRectFillColor()189 SkColor DebugColors::SurfaceDamageRectFillColor() {
190 return SkColorSetARGB(30, 200, 100, 0);
191 }
192
193 // Surface replica screen space rects in green.
ScreenSpaceLayerRectBorderColor()194 SkColor DebugColors::ScreenSpaceLayerRectBorderColor() {
195 return SkColorSetARGB(255, 100, 200, 0);
196 }
ScreenSpaceLayerRectBorderWidth()197 int DebugColors::ScreenSpaceLayerRectBorderWidth() { return 2; }
ScreenSpaceLayerRectFillColor()198 SkColor DebugColors::ScreenSpaceLayerRectFillColor() {
199 return SkColorSetARGB(30, 100, 200, 0);
200 }
201
202 // Layer screen space rects in purple.
ScreenSpaceSurfaceReplicaRectBorderColor()203 SkColor DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor() {
204 return SkColorSetARGB(255, 100, 0, 200);
205 }
ScreenSpaceSurfaceReplicaRectBorderWidth()206 int DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth() { return 2; }
ScreenSpaceSurfaceReplicaRectFillColor()207 SkColor DebugColors::ScreenSpaceSurfaceReplicaRectFillColor() {
208 return SkColorSetARGB(10, 100, 0, 200);
209 }
210
211 // Occluding rects in pink.
OccludingRectBorderColor()212 SkColor DebugColors::OccludingRectBorderColor() {
213 return SkColorSetARGB(255, 245, 136, 255);
214 }
OccludingRectBorderWidth()215 int DebugColors::OccludingRectBorderWidth() { return 2; }
OccludingRectFillColor()216 SkColor DebugColors::OccludingRectFillColor() {
217 return SkColorSetARGB(10, 245, 136, 255);
218 }
219
220 // Non-Occluding rects in a reddish color.
NonOccludingRectBorderColor()221 SkColor DebugColors::NonOccludingRectBorderColor() {
222 return SkColorSetARGB(255, 200, 0, 100);
223 }
NonOccludingRectBorderWidth()224 int DebugColors::NonOccludingRectBorderWidth() { return 2; }
NonOccludingRectFillColor()225 SkColor DebugColors::NonOccludingRectFillColor() {
226 return SkColorSetARGB(10, 200, 0, 100);
227 }
228
229 // Touch-event-handler rects in yellow.
TouchEventHandlerRectBorderColor()230 SkColor DebugColors::TouchEventHandlerRectBorderColor() {
231 return SkColorSetARGB(255, 239, 229, 60);
232 }
TouchEventHandlerRectBorderWidth()233 int DebugColors::TouchEventHandlerRectBorderWidth() { return 2; }
TouchEventHandlerRectFillColor()234 SkColor DebugColors::TouchEventHandlerRectFillColor() {
235 return SkColorSetARGB(30, 239, 229, 60);
236 }
237
238 // Wheel-event-handler rects in green.
WheelEventHandlerRectBorderColor()239 SkColor DebugColors::WheelEventHandlerRectBorderColor() {
240 return SkColorSetARGB(255, 189, 209, 57);
241 }
WheelEventHandlerRectBorderWidth()242 int DebugColors::WheelEventHandlerRectBorderWidth() { return 2; }
WheelEventHandlerRectFillColor()243 SkColor DebugColors::WheelEventHandlerRectFillColor() {
244 return SkColorSetARGB(30, 189, 209, 57);
245 }
246
247 // Non-fast-scrollable rects in orange.
NonFastScrollableRectBorderColor()248 SkColor DebugColors::NonFastScrollableRectBorderColor() {
249 return SkColorSetARGB(255, 238, 163, 59);
250 }
NonFastScrollableRectBorderWidth()251 int DebugColors::NonFastScrollableRectBorderWidth() { return 2; }
NonFastScrollableRectFillColor()252 SkColor DebugColors::NonFastScrollableRectFillColor() {
253 return SkColorSetARGB(30, 238, 163, 59);
254 }
255
256 // Animation bounds are lime-green.
LayerAnimationBoundsBorderColor()257 SkColor DebugColors::LayerAnimationBoundsBorderColor() {
258 return SkColorSetARGB(255, 112, 229, 0);
259 }
LayerAnimationBoundsBorderWidth()260 int DebugColors::LayerAnimationBoundsBorderWidth() { return 2; }
LayerAnimationBoundsFillColor()261 SkColor DebugColors::LayerAnimationBoundsFillColor() {
262 return SkColorSetARGB(30, 112, 229, 0);
263 }
264
265 // Non-Painted rects in cyan.
NonPaintedFillColor()266 SkColor DebugColors::NonPaintedFillColor() { return SK_ColorCYAN; }
267
268 // Missing picture rects in magenta.
MissingPictureFillColor()269 SkColor DebugColors::MissingPictureFillColor() { return SK_ColorMAGENTA; }
270
271 // Picture borders in transparent blue.
PictureBorderColor()272 SkColor DebugColors::PictureBorderColor() {
273 return SkColorSetARGB(100, 0, 0, 200);
274 }
275
276 // ======= HUD widget colors =======
277
HUDBackgroundColor()278 SkColor DebugColors::HUDBackgroundColor() {
279 return SkColorSetARGB(215, 17, 17, 17);
280 }
HUDSeparatorLineColor()281 SkColor DebugColors::HUDSeparatorLineColor() {
282 return SkColorSetARGB(255, 130, 130, 130);
283 }
HUDIndicatorLineColor()284 SkColor DebugColors::HUDIndicatorLineColor() {
285 return SkColorSetARGB(255, 80, 80, 80);
286 }
287
PlatformLayerTreeTextColor()288 SkColor DebugColors::PlatformLayerTreeTextColor() { return SK_ColorRED; }
FPSDisplayTextAndGraphColor()289 SkColor DebugColors::FPSDisplayTextAndGraphColor() { return SK_ColorRED; }
MemoryDisplayTextColor()290 SkColor DebugColors::MemoryDisplayTextColor() {
291 return SkColorSetARGB(255, 220, 220, 220);
292 }
293
294 // Paint time display in green (similar to paint times in the WebInspector)
PaintTimeDisplayTextAndGraphColor()295 SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() {
296 return SkColorSetRGB(75, 155, 55);
297 }
298
299 } // namespace cc
300