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 "cc/heads_up_display_layer_impl.h" | 5 #include "cc/heads_up_display_layer_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "cc/debug_colors.h" |
10 #include "cc/debug_rect_history.h" | 11 #include "cc/debug_rect_history.h" |
11 #include "cc/font_atlas.h" | 12 #include "cc/font_atlas.h" |
12 #include "cc/frame_rate_counter.h" | 13 #include "cc/frame_rate_counter.h" |
13 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
14 #include "cc/quad_sink.h" | 15 #include "cc/quad_sink.h" |
15 #include "cc/texture_draw_quad.h" | 16 #include "cc/texture_draw_quad.h" |
16 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
17 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
19 #include "third_party/khronos/GLES2/gl2ext.h" | 20 #include "third_party/khronos/GLES2/gl2ext.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 canvas->drawPath(path, paint); | 311 canvas->drawPath(path, paint); |
311 } | 312 } |
312 | 313 |
313 void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
debugRectHistory) | 314 void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
debugRectHistory) |
314 { | 315 { |
315 const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects(); | 316 const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects(); |
316 | 317 |
317 for (size_t i = 0; i < debugRects.size(); ++i) { | 318 for (size_t i = 0; i < debugRects.size(); ++i) { |
318 SkColor strokeColor = 0; | 319 SkColor strokeColor = 0; |
319 SkColor fillColor = 0; | 320 SkColor fillColor = 0; |
| 321 float strokeWidth = 0; |
320 | 322 |
321 switch (debugRects[i].type) { | 323 switch (debugRects[i].type) { |
322 case PaintRectType: | 324 case PaintRectType: |
323 // Paint rects in red | 325 strokeColor = DebugColors::PaintRectBorderColor(); |
324 strokeColor = SkColorSetARGB(255, 255, 0, 0); | 326 fillColor = DebugColors::PaintRectFillColor(); |
325 fillColor = SkColorSetARGB(30, 255, 0, 0); | 327 strokeWidth = DebugColors::PaintRectBorderWidth(layerTreeHostImpl())
; |
326 break; | 328 break; |
327 case PropertyChangedRectType: | 329 case PropertyChangedRectType: |
328 // Property-changed rects in blue | 330 strokeColor = DebugColors::PropertyChangedRectBorderColor(); |
329 strokeColor = SkColorSetARGB(255, 255, 0, 0); | 331 fillColor = DebugColors::PropertyChangedRectFillColor(); |
330 fillColor = SkColorSetARGB(30, 0, 0, 255); | 332 strokeWidth = DebugColors::PropertyChangedRectBorderWidth(layerTreeH
ostImpl()); |
331 break; | 333 break; |
332 case SurfaceDamageRectType: | 334 case SurfaceDamageRectType: |
333 // Surface damage rects in yellow-orange | 335 strokeColor = DebugColors::SurfaceDamageRectBorderColor(); |
334 strokeColor = SkColorSetARGB(255, 200, 100, 0); | 336 fillColor = DebugColors::SurfaceDamageRectFillColor(); |
335 fillColor = SkColorSetARGB(30, 200, 100, 0); | 337 strokeWidth = DebugColors::SurfaceDamageRectBorderWidth(layerTreeHos
tImpl()); |
336 break; | 338 break; |
337 case ReplicaScreenSpaceRectType: | 339 case ReplicaScreenSpaceRectType: |
338 // Screen space rects in green. | 340 strokeColor = DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor(
); |
339 strokeColor = SkColorSetARGB(255, 100, 200, 0); | 341 fillColor = DebugColors::ScreenSpaceSurfaceReplicaRectFillColor(); |
340 fillColor = SkColorSetARGB(30, 100, 200, 0); | 342 strokeWidth = DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(
layerTreeHostImpl()); |
341 break; | 343 break; |
342 case ScreenSpaceRectType: | 344 case ScreenSpaceRectType: |
343 // Screen space rects in purple. | 345 strokeColor = DebugColors::ScreenSpaceLayerRectBorderColor(); |
344 strokeColor = SkColorSetARGB(255, 100, 0, 200); | 346 fillColor = DebugColors::ScreenSpaceLayerRectFillColor(); |
345 fillColor = SkColorSetARGB(10, 100, 0, 200); | 347 strokeWidth = DebugColors::ScreenSpaceLayerRectBorderWidth(layerTree
HostImpl()); |
346 break; | 348 break; |
347 case OccludingRectType: | 349 case OccludingRectType: |
348 // Occluding rects in pink. | 350 strokeColor = DebugColors::OccludingRectBorderColor(); |
349 strokeColor = SkColorSetARGB(255, 245, 136, 255); | 351 fillColor = DebugColors::OccludingRectFillColor(); |
350 fillColor = SkColorSetARGB(10, 245, 136, 255); | 352 strokeWidth = DebugColors::OccludingRectBorderWidth(layerTreeHostImp
l()); |
351 break; | 353 break; |
352 case NonOccludingRectType: | 354 case NonOccludingRectType: |
353 // Non-Occluding rects in a reddish color. | 355 strokeColor = DebugColors::NonOccludingRectBorderColor(); |
354 strokeColor = SkColorSetARGB(255, 200, 0, 100); | 356 fillColor = DebugColors::NonOccludingRectFillColor(); |
355 fillColor = SkColorSetARGB(10, 200, 0, 100); | 357 strokeWidth = DebugColors::NonOccludingRectBorderWidth(layerTreeHost
Impl()); |
356 break; | 358 break; |
357 } | 359 } |
358 | 360 |
359 const gfx::RectF& rect = debugRects[i].rect; | 361 const gfx::RectF& rect = debugRects[i].rect; |
360 SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.
height()); | 362 SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.
height()); |
361 SkPaint paint = createPaint(); | 363 SkPaint paint = createPaint(); |
362 paint.setColor(fillColor); | 364 paint.setColor(fillColor); |
363 canvas->drawRect(skRect, paint); | 365 canvas->drawRect(skRect, paint); |
364 | 366 |
365 paint.setColor(strokeColor); | 367 paint.setColor(strokeColor); |
366 paint.setStyle(SkPaint::kStroke_Style); | 368 paint.setStyle(SkPaint::kStroke_Style); |
367 paint.setStrokeWidth(2); | 369 paint.setStrokeWidth(SkFloatToScalar(strokeWidth)); |
368 canvas->drawRect(skRect, paint); | 370 canvas->drawRect(skRect, paint); |
369 } | 371 } |
370 } | 372 } |
371 | 373 |
372 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const | 374 const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const |
373 { | 375 { |
374 return "HeadsUpDisplayLayer"; | 376 return "HeadsUpDisplayLayer"; |
375 } | 377 } |
376 | 378 |
377 } // namespace cc | 379 } // namespace cc |
OLD | NEW |