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