| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" |
| 5 #include "base/macros.h" | 6 #include "base/macros.h" |
| 6 | 7 |
| 7 #include "cc/debug/debug_colors.h" | 8 #include "cc/debug/debug_colors.h" |
| 8 | 9 |
| 9 #include "cc/trees/layer_tree_impl.h" | |
| 10 | |
| 11 namespace cc { | 10 namespace cc { |
| 12 | 11 |
| 13 static float Scale(float width, const LayerTreeImpl* tree_impl) { | 12 static float Scale(float width, float device_scale_factor) { |
| 14 return width * (tree_impl ? tree_impl->device_scale_factor() : 1); | 13 return width * device_scale_factor; |
| 15 } | 14 } |
| 16 | 15 |
| 17 // ======= Layer border colors ======= | 16 // ======= Layer border colors ======= |
| 18 | 17 |
| 19 // Tiled content layers are orange. | 18 // Tiled content layers are orange. |
| 20 SkColor DebugColors::TiledContentLayerBorderColor() { | 19 SkColor DebugColors::TiledContentLayerBorderColor() { |
| 21 return SkColorSetARGB(128, 255, 128, 0); | 20 return SkColorSetARGB(128, 255, 128, 0); |
| 22 } | 21 } |
| 23 int DebugColors::TiledContentLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 22 int DebugColors::TiledContentLayerBorderWidth(float device_scale_factor) { |
| 24 return Scale(2, tree_impl); | 23 return Scale(2, device_scale_factor); |
| 25 } | 24 } |
| 26 | 25 |
| 27 // Image layers are olive. | 26 // Image layers are olive. |
| 28 SkColor DebugColors::ImageLayerBorderColor() { | 27 SkColor DebugColors::ImageLayerBorderColor() { |
| 29 return SkColorSetARGB(128, 128, 128, 0); | 28 return SkColorSetARGB(128, 128, 128, 0); |
| 30 } | 29 } |
| 31 int DebugColors::ImageLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 30 int DebugColors::ImageLayerBorderWidth(float device_scale_factor) { |
| 32 return Scale(2, tree_impl); | 31 return Scale(2, device_scale_factor); |
| 33 } | 32 } |
| 34 | 33 |
| 35 // Non-tiled content layers area green. | 34 // Non-tiled content layers area green. |
| 36 SkColor DebugColors::ContentLayerBorderColor() { | 35 SkColor DebugColors::ContentLayerBorderColor() { |
| 37 return SkColorSetARGB(128, 0, 128, 32); | 36 return SkColorSetARGB(128, 0, 128, 32); |
| 38 } | 37 } |
| 39 int DebugColors::ContentLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 38 int DebugColors::ContentLayerBorderWidth(float device_scale_factor) { |
| 40 return Scale(2, tree_impl); | 39 return Scale(2, device_scale_factor); |
| 41 } | 40 } |
| 42 | 41 |
| 43 // Masking layers are pale blue and wide. | 42 // Masking layers are pale blue and wide. |
| 44 SkColor DebugColors::MaskingLayerBorderColor() { | 43 SkColor DebugColors::MaskingLayerBorderColor() { |
| 45 return SkColorSetARGB(48, 128, 255, 255); | 44 return SkColorSetARGB(48, 128, 255, 255); |
| 46 } | 45 } |
| 47 int DebugColors::MaskingLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 46 int DebugColors::MaskingLayerBorderWidth(float device_scale_factor) { |
| 48 return Scale(20, tree_impl); | 47 return Scale(20, device_scale_factor); |
| 49 } | 48 } |
| 50 | 49 |
| 51 // Other container layers are yellow. | 50 // Other container layers are yellow. |
| 52 SkColor DebugColors::ContainerLayerBorderColor() { | 51 SkColor DebugColors::ContainerLayerBorderColor() { |
| 53 return SkColorSetARGB(192, 255, 255, 0); | 52 return SkColorSetARGB(192, 255, 255, 0); |
| 54 } | 53 } |
| 55 int DebugColors::ContainerLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 54 int DebugColors::ContainerLayerBorderWidth(float device_scale_factor) { |
| 56 return Scale(2, tree_impl); | 55 return Scale(2, device_scale_factor); |
| 57 } | 56 } |
| 58 | 57 |
| 59 // Surface layers are a blue-ish green. | 58 // Surface layers are a blue-ish green. |
| 60 SkColor DebugColors::SurfaceLayerBorderColor() { | 59 SkColor DebugColors::SurfaceLayerBorderColor() { |
| 61 return SkColorSetARGB(128, 0, 255, 136); | 60 return SkColorSetARGB(128, 0, 255, 136); |
| 62 } | 61 } |
| 63 int DebugColors::SurfaceLayerBorderWidth(const LayerTreeImpl* tree_impl) { | 62 int DebugColors::SurfaceLayerBorderWidth(float device_scale_factor) { |
| 64 return Scale(2, tree_impl); | 63 return Scale(2, device_scale_factor); |
| 65 } | 64 } |
| 66 | 65 |
| 67 // Render surfaces are blue. | 66 // Render surfaces are blue. |
| 68 SkColor DebugColors::SurfaceBorderColor() { | 67 SkColor DebugColors::SurfaceBorderColor() { |
| 69 return SkColorSetARGB(100, 0, 0, 255); | 68 return SkColorSetARGB(100, 0, 0, 255); |
| 70 } | 69 } |
| 71 int DebugColors::SurfaceBorderWidth(const LayerTreeImpl* tree_impl) { | 70 int DebugColors::SurfaceBorderWidth(float device_scale_factor) { |
| 72 return Scale(2, tree_impl); | 71 return Scale(2, device_scale_factor); |
| 73 } | 72 } |
| 74 | 73 |
| 75 // ======= Tile colors ======= | 74 // ======= Tile colors ======= |
| 76 | 75 |
| 77 // High-res tile borders are cyan. | 76 // High-res tile borders are cyan. |
| 78 SkColor DebugColors::HighResTileBorderColor() { | 77 SkColor DebugColors::HighResTileBorderColor() { |
| 79 return SkColorSetARGB(100, 80, 200, 200); | 78 return SkColorSetARGB(100, 80, 200, 200); |
| 80 } | 79 } |
| 81 int DebugColors::HighResTileBorderWidth(const LayerTreeImpl* tree_impl) { | 80 int DebugColors::HighResTileBorderWidth(float device_scale_factor) { |
| 82 return Scale(1, tree_impl); | 81 return Scale(1, device_scale_factor); |
| 83 } | 82 } |
| 84 | 83 |
| 85 // Low-res tile borders are purple. | 84 // Low-res tile borders are purple. |
| 86 SkColor DebugColors::LowResTileBorderColor() { | 85 SkColor DebugColors::LowResTileBorderColor() { |
| 87 return SkColorSetARGB(100, 212, 83, 192); | 86 return SkColorSetARGB(100, 212, 83, 192); |
| 88 } | 87 } |
| 89 int DebugColors::LowResTileBorderWidth(const LayerTreeImpl* tree_impl) { | 88 int DebugColors::LowResTileBorderWidth(float device_scale_factor) { |
| 90 return Scale(2, tree_impl); | 89 return Scale(2, device_scale_factor); |
| 91 } | 90 } |
| 92 | 91 |
| 93 // Other high-resolution tile borders are yellow. | 92 // Other high-resolution tile borders are yellow. |
| 94 SkColor DebugColors::ExtraHighResTileBorderColor() { | 93 SkColor DebugColors::ExtraHighResTileBorderColor() { |
| 95 return SkColorSetARGB(100, 239, 231, 20); | 94 return SkColorSetARGB(100, 239, 231, 20); |
| 96 } | 95 } |
| 97 int DebugColors::ExtraHighResTileBorderWidth(const LayerTreeImpl* tree_impl) { | 96 int DebugColors::ExtraHighResTileBorderWidth(float device_scale_factor) { |
| 98 return Scale(2, tree_impl); | 97 return Scale(2, device_scale_factor); |
| 99 } | 98 } |
| 100 | 99 |
| 101 // Other low-resolution tile borders are green. | 100 // Other low-resolution tile borders are green. |
| 102 SkColor DebugColors::ExtraLowResTileBorderColor() { | 101 SkColor DebugColors::ExtraLowResTileBorderColor() { |
| 103 return SkColorSetARGB(100, 93, 186, 18); | 102 return SkColorSetARGB(100, 93, 186, 18); |
| 104 } | 103 } |
| 105 int DebugColors::ExtraLowResTileBorderWidth(const LayerTreeImpl* tree_impl) { | 104 int DebugColors::ExtraLowResTileBorderWidth(float device_scale_factor) { |
| 106 return Scale(2, tree_impl); | 105 return Scale(2, device_scale_factor); |
| 107 } | 106 } |
| 108 | 107 |
| 109 // Missing tile borders are dark grey. | 108 // Missing tile borders are dark grey. |
| 110 SkColor DebugColors::MissingTileBorderColor() { | 109 SkColor DebugColors::MissingTileBorderColor() { |
| 111 return SkColorSetARGB(64, 64, 64, 0); | 110 return SkColorSetARGB(64, 64, 64, 0); |
| 112 } | 111 } |
| 113 int DebugColors::MissingTileBorderWidth(const LayerTreeImpl* tree_impl) { | 112 int DebugColors::MissingTileBorderWidth(float device_scale_factor) { |
| 114 return Scale(1, tree_impl); | 113 return Scale(1, device_scale_factor); |
| 115 } | 114 } |
| 116 | 115 |
| 117 // Solid color tile borders are grey. | 116 // Solid color tile borders are grey. |
| 118 SkColor DebugColors::SolidColorTileBorderColor() { | 117 SkColor DebugColors::SolidColorTileBorderColor() { |
| 119 return SkColorSetARGB(128, 128, 128, 128); | 118 return SkColorSetARGB(128, 128, 128, 128); |
| 120 } | 119 } |
| 121 int DebugColors::SolidColorTileBorderWidth(const LayerTreeImpl* tree_impl) { | 120 int DebugColors::SolidColorTileBorderWidth(float device_scale_factor) { |
| 122 return Scale(1, tree_impl); | 121 return Scale(1, device_scale_factor); |
| 123 } | 122 } |
| 124 | 123 |
| 125 // OOM tile borders are red. | 124 // OOM tile borders are red. |
| 126 SkColor DebugColors::OOMTileBorderColor() { | 125 SkColor DebugColors::OOMTileBorderColor() { |
| 127 return SkColorSetARGB(100, 255, 0, 0); | 126 return SkColorSetARGB(100, 255, 0, 0); |
| 128 } | 127 } |
| 129 int DebugColors::OOMTileBorderWidth(const LayerTreeImpl* tree_impl) { | 128 int DebugColors::OOMTileBorderWidth(float device_scale_factor) { |
| 130 return Scale(1, tree_impl); | 129 return Scale(1, device_scale_factor); |
| 131 } | 130 } |
| 132 | 131 |
| 133 // Direct picture borders are chartreuse. | 132 // Direct picture borders are chartreuse. |
| 134 SkColor DebugColors::DirectPictureBorderColor() { | 133 SkColor DebugColors::DirectPictureBorderColor() { |
| 135 return SkColorSetARGB(255, 127, 255, 0); | 134 return SkColorSetARGB(255, 127, 255, 0); |
| 136 } | 135 } |
| 137 int DebugColors::DirectPictureBorderWidth(const LayerTreeImpl* tree_impl) { | 136 int DebugColors::DirectPictureBorderWidth(float device_scale_factor) { |
| 138 return Scale(1, tree_impl); | 137 return Scale(1, device_scale_factor); |
| 139 } | 138 } |
| 140 | 139 |
| 141 // Borders added to GL composited draw quads. This is useful to debug HW | 140 // Borders added to GL composited draw quads. This is useful to debug HW |
| 142 // overlays. When the border disappears, it means we're using an overlay. | 141 // overlays. When the border disappears, it means we're using an overlay. |
| 143 // We draw borders in different colors to be able to distinguish neighboring | 142 // We draw borders in different colors to be able to distinguish neighboring |
| 144 // quads (often shadows). | 143 // quads (often shadows). |
| 145 SkColor DebugColors::GLCompositedTextureQuadBorderColor(int index) { | 144 SkColor DebugColors::GLCompositedTextureQuadBorderColor(int index) { |
| 146 const SkColor kColors[] = {SK_ColorBLUE, SK_ColorGREEN, SK_ColorRED, | 145 const SkColor kColors[] = {SK_ColorBLUE, SK_ColorGREEN, SK_ColorRED, |
| 147 SK_ColorYELLOW, SK_ColorCYAN, SK_ColorMAGENTA}; | 146 SK_ColorYELLOW, SK_ColorCYAN, SK_ColorMAGENTA}; |
| 148 return kColors[index % arraysize(kColors)]; | 147 return kColors[index % arraysize(kColors)]; |
| 149 } | 148 } |
| 150 int DebugColors::GLCompositedTextureQuadBoderWidth() { | 149 int DebugColors::GLCompositedTextureQuadBoderWidth() { |
| 151 return 6; | 150 return 6; |
| 152 } | 151 } |
| 153 | 152 |
| 154 // Compressed tile borders are blue. | 153 // Compressed tile borders are blue. |
| 155 SkColor DebugColors::CompressedTileBorderColor() { | 154 SkColor DebugColors::CompressedTileBorderColor() { |
| 156 return SkColorSetARGB(100, 20, 20, 240); | 155 return SkColorSetARGB(100, 20, 20, 240); |
| 157 } | 156 } |
| 158 int DebugColors::CompressedTileBorderWidth(const LayerTreeImpl* tree_impl) { | 157 int DebugColors::CompressedTileBorderWidth(float device_scale_factor) { |
| 159 return Scale(2, tree_impl); | 158 return Scale(2, device_scale_factor); |
| 160 } | 159 } |
| 161 | 160 |
| 162 // ======= Checkerboard colors ======= | 161 // ======= Checkerboard colors ======= |
| 163 | 162 |
| 164 // Non-debug checkerboards are grey. | 163 // Non-debug checkerboards are grey. |
| 165 SkColor DebugColors::DefaultCheckerboardColor() { | 164 SkColor DebugColors::DefaultCheckerboardColor() { |
| 166 return SkColorSetRGB(241, 241, 241); | 165 return SkColorSetRGB(241, 241, 241); |
| 167 } | 166 } |
| 168 | 167 |
| 169 // Invalidated tiles get sky blue checkerboards. | 168 // Invalidated tiles get sky blue checkerboards. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 SkColor DebugColors::MemoryDisplayTextColor() { | 302 SkColor DebugColors::MemoryDisplayTextColor() { |
| 304 return SK_ColorCYAN; | 303 return SK_ColorCYAN; |
| 305 } | 304 } |
| 306 | 305 |
| 307 // Paint time display in green (similar to paint times in the WebInspector) | 306 // Paint time display in green (similar to paint times in the WebInspector) |
| 308 SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() { | 307 SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() { |
| 309 return SkColorSetRGB(75, 155, 55); | 308 return SkColorSetRGB(75, 155, 55); |
| 310 } | 309 } |
| 311 | 310 |
| 312 } // namespace cc | 311 } // namespace cc |
| OLD | NEW |