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