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