| 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/layers/heads_up_display_layer_impl.h" | 5 #include "cc/layers/heads_up_display_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/debug/trace_event_argument.h" | 11 #include "base/debug/trace_event_argument.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "cc/debug/debug_colors.h" | 13 #include "cc/debug/debug_colors.h" |
| 14 #include "cc/debug/frame_rate_counter.h" | 14 #include "cc/debug/frame_rate_counter.h" |
| 15 #include "cc/debug/paint_time_counter.h" | 15 #include "cc/debug/paint_time_counter.h" |
| 16 #include "cc/output/begin_frame_args.h" | 16 #include "cc/output/begin_frame_args.h" |
| 17 #include "cc/output/renderer.h" | 17 #include "cc/output/renderer.h" |
| 18 #include "cc/quads/texture_draw_quad.h" | 18 #include "cc/quads/texture_draw_quad.h" |
| 19 #include "cc/resources/memory_history.h" | 19 #include "cc/resources/memory_history.h" |
| 20 #include "cc/trees/layer_tree_host_impl.h" |
| 20 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
| 21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
| 22 #include "third_party/khronos/GLES2/gl2.h" | 23 #include "third_party/khronos/GLES2/gl2.h" |
| 23 #include "third_party/khronos/GLES2/gl2ext.h" | 24 #include "third_party/khronos/GLES2/gl2ext.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "third_party/skia/include/core/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
| 26 #include "third_party/skia/include/core/SkTypeface.h" | 27 #include "third_party/skia/include/core/SkTypeface.h" |
| 27 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 28 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
| 28 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
| 29 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (debug_state.continuous_painting) { | 270 if (debug_state.continuous_painting) { |
| 270 area = DrawPaintTimeDisplay( | 271 area = DrawPaintTimeDisplay( |
| 271 canvas, layer_tree_impl()->paint_time_counter(), 0, 0); | 272 canvas, layer_tree_impl()->paint_time_counter(), 0, 0); |
| 272 } else if (debug_state.show_fps_counter) { | 273 } else if (debug_state.show_fps_counter) { |
| 273 // Don't show the FPS display when continuous painting is enabled, because | 274 // Don't show the FPS display when continuous painting is enabled, because |
| 274 // it would show misleading numbers. | 275 // it would show misleading numbers. |
| 275 area = | 276 area = |
| 276 DrawFPSDisplay(canvas, layer_tree_impl()->frame_rate_counter(), 0, 0); | 277 DrawFPSDisplay(canvas, layer_tree_impl()->frame_rate_counter(), 0, 0); |
| 277 } | 278 } |
| 278 | 279 |
| 280 area = DrawGpuRasterizationStatus(canvas, 0, area.bottom(), |
| 281 SkMaxScalar(area.width(), 150)); |
| 282 |
| 279 if (debug_state.ShowMemoryStats()) | 283 if (debug_state.ShowMemoryStats()) |
| 280 DrawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150)); | 284 DrawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150)); |
| 281 } | 285 } |
| 282 | 286 |
| 283 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, | 287 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, |
| 284 SkPaint* paint, | 288 SkPaint* paint, |
| 285 const std::string& text, | 289 const std::string& text, |
| 286 SkPaint::Align align, | 290 SkPaint::Align align, |
| 287 int size, | 291 int size, |
| 288 int x, | 292 int x, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 526 |
| 523 if (!memory_entry_.had_enough_memory) | 527 if (!memory_entry_.had_enough_memory) |
| 524 paint.setColor(SK_ColorRED); | 528 paint.setColor(SK_ColorRED); |
| 525 text = base::StringPrintf("%6.1f MB max ", | 529 text = base::StringPrintf("%6.1f MB max ", |
| 526 memory_entry_.total_budget_in_bytes / kMegabyte); | 530 memory_entry_.total_budget_in_bytes / kMegabyte); |
| 527 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); | 531 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); |
| 528 | 532 |
| 529 return area; | 533 return area; |
| 530 } | 534 } |
| 531 | 535 |
| 536 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, |
| 537 int right, |
| 538 int top, |
| 539 int width) const { |
| 540 std::string status; |
| 541 SkColor color = SK_ColorRED; |
| 542 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { |
| 543 case GpuRasterizationStatus::ON: |
| 544 status = "GPU raster: on"; |
| 545 color = SK_ColorGREEN; |
| 546 break; |
| 547 case GpuRasterizationStatus::ON_FORCED: |
| 548 status = "GPU raster: on (forced)"; |
| 549 color = SK_ColorGREEN; |
| 550 break; |
| 551 case GpuRasterizationStatus::OFF_DEVICE: |
| 552 status = "GPU raster: off (device)"; |
| 553 color = SK_ColorRED; |
| 554 break; |
| 555 case GpuRasterizationStatus::OFF_VIEWPORT: |
| 556 status = "GPU raster: off (viewport)"; |
| 557 color = SK_ColorYELLOW; |
| 558 break; |
| 559 case GpuRasterizationStatus::OFF_CONTENT: |
| 560 status = "GPU raster: off (content)"; |
| 561 color = SK_ColorYELLOW; |
| 562 break; |
| 563 } |
| 564 |
| 565 if (status.empty()) |
| 566 return SkRect::MakeEmpty(); |
| 567 |
| 568 const int kPadding = 4; |
| 569 const int kFontHeight = 13; |
| 570 |
| 571 const int height = kFontHeight + 2 * kPadding; |
| 572 const int left = bounds().width() - width - right; |
| 573 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
| 574 |
| 575 SkPaint paint = CreatePaint(); |
| 576 DrawGraphBackground(canvas, &paint, area); |
| 577 |
| 578 SkPoint gpu_status_pos = SkPoint::Make(left + kPadding, top + kFontHeight); |
| 579 |
| 580 paint.setColor(color); |
| 581 DrawText(canvas, &paint, status, SkPaint::kLeft_Align, kFontHeight, |
| 582 gpu_status_pos); |
| 583 |
| 584 return area; |
| 585 } |
| 586 |
| 532 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( | 587 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( |
| 533 SkCanvas* canvas, | 588 SkCanvas* canvas, |
| 534 const PaintTimeCounter* paint_time_counter, | 589 const PaintTimeCounter* paint_time_counter, |
| 535 int right, | 590 int right, |
| 536 int top) const { | 591 int top) const { |
| 537 const int kPadding = 4; | 592 const int kPadding = 4; |
| 538 const int kFontHeight = 15; | 593 const int kFontHeight = 15; |
| 539 | 594 |
| 540 const int kGraphWidth = paint_time_counter->HistorySize(); | 595 const int kGraphWidth = paint_time_counter->HistorySize(); |
| 541 const int kGraphHeight = 40; | 596 const int kGraphHeight = 40; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 return "cc::HeadsUpDisplayLayerImpl"; | 834 return "cc::HeadsUpDisplayLayerImpl"; |
| 780 } | 835 } |
| 781 | 836 |
| 782 void HeadsUpDisplayLayerImpl::AsValueInto( | 837 void HeadsUpDisplayLayerImpl::AsValueInto( |
| 783 base::debug::TracedValue* dict) const { | 838 base::debug::TracedValue* dict) const { |
| 784 LayerImpl::AsValueInto(dict); | 839 LayerImpl::AsValueInto(dict); |
| 785 dict->SetString("layer_name", "Heads Up Display Layer"); | 840 dict->SetString("layer_name", "Heads Up Display Layer"); |
| 786 } | 841 } |
| 787 | 842 |
| 788 } // namespace cc | 843 } // namespace cc |
| OLD | NEW |