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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 548 } |
549 | 549 |
550 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, | 550 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, |
551 int right, | 551 int right, |
552 int top, | 552 int top, |
553 int width) const { | 553 int width) const { |
554 std::string status; | 554 std::string status; |
555 SkColor color = SK_ColorRED; | 555 SkColor color = SK_ColorRED; |
556 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { | 556 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { |
557 case GpuRasterizationStatus::ON: | 557 case GpuRasterizationStatus::ON: |
558 status = "GPU raster: on"; | 558 status = "on"; |
559 color = SK_ColorGREEN; | 559 color = SK_ColorGREEN; |
560 break; | 560 break; |
561 case GpuRasterizationStatus::ON_FORCED: | 561 case GpuRasterizationStatus::ON_FORCED: |
562 status = "GPU raster: on (forced)"; | 562 status = "on (forced)"; |
563 color = SK_ColorGREEN; | 563 color = SK_ColorGREEN; |
564 break; | 564 break; |
565 case GpuRasterizationStatus::OFF_DEVICE: | 565 case GpuRasterizationStatus::OFF_DEVICE: |
566 status = "GPU raster: off (device)"; | 566 status = "off (device)"; |
567 color = SK_ColorRED; | 567 color = SK_ColorRED; |
568 break; | 568 break; |
569 case GpuRasterizationStatus::OFF_VIEWPORT: | 569 case GpuRasterizationStatus::OFF_VIEWPORT: |
570 status = "GPU raster: off (viewport)"; | 570 status = "off (viewport)"; |
571 color = SK_ColorYELLOW; | 571 color = SK_ColorYELLOW; |
572 break; | 572 break; |
573 case GpuRasterizationStatus::OFF_CONTENT: | 573 case GpuRasterizationStatus::OFF_CONTENT: |
574 status = "GPU raster: off (content)"; | 574 status = "off (content)"; |
575 color = SK_ColorYELLOW; | 575 color = SK_ColorYELLOW; |
576 break; | 576 break; |
577 } | 577 } |
578 | 578 |
579 if (status.empty()) | 579 if (status.empty()) |
580 return SkRect::MakeEmpty(); | 580 return SkRect::MakeEmpty(); |
581 | 581 |
582 const int kPadding = 4; | 582 const int kPadding = 4; |
583 const int kFontHeight = 13; | 583 const int kFontHeight = 13; |
584 | 584 |
585 const int height = kFontHeight + 2 * kPadding; | 585 const int height = 2 * kFontHeight + 3 * kPadding; |
586 const int left = bounds().width() - width - right; | 586 const int left = bounds().width() - width - right; |
587 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 587 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
588 | 588 |
589 SkPaint paint = CreatePaint(); | 589 SkPaint paint = CreatePaint(); |
590 DrawGraphBackground(canvas, &paint, area); | 590 DrawGraphBackground(canvas, &paint, area); |
591 | 591 |
592 SkPoint gpu_status_pos = SkPoint::Make(left + kPadding, top + kFontHeight); | 592 SkPoint gpu_status_pos = SkPoint::Make(left + width - kPadding, |
| 593 top + 2 * kFontHeight + 2 * kPadding); |
593 | 594 |
594 paint.setColor(color); | 595 paint.setColor(color); |
595 DrawText(canvas, &paint, status, SkPaint::kLeft_Align, kFontHeight, | 596 DrawText(canvas, &paint, "GPU raster: ", SkPaint::kLeft_Align, kFontHeight, |
| 597 left + kPadding, top + kFontHeight + kPadding); |
| 598 DrawText(canvas, &paint, status, SkPaint::kRight_Align, kFontHeight, |
596 gpu_status_pos); | 599 gpu_status_pos); |
597 | 600 |
598 return area; | 601 return area; |
599 } | 602 } |
600 | 603 |
601 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( | 604 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( |
602 SkCanvas* canvas, | 605 SkCanvas* canvas, |
603 const PaintTimeCounter* paint_time_counter, | 606 const PaintTimeCounter* paint_time_counter, |
604 int right, | 607 int right, |
605 int top) const { | 608 int top) const { |
606 const int kPadding = 4; | 609 const int kPadding = 4; |
607 const int kFontHeight = 15; | 610 const int kFontHeight = 14; |
608 | 611 |
609 const int kGraphWidth = paint_time_counter->HistorySize(); | 612 const int kGraphWidth = paint_time_counter->HistorySize(); |
610 const int kGraphHeight = 40; | 613 const int kGraphHeight = 40; |
611 | 614 |
612 const int width = kGraphWidth + 2 * kPadding; | 615 const int width = kGraphWidth + 2 * kPadding; |
613 const int height = | 616 const int height = |
614 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding; | 617 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding; |
615 const int left = bounds().width() - width - right; | 618 const int left = bounds().width() - width - right; |
616 | 619 |
617 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 620 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
(...skipping 11 matching lines...) Expand all Loading... |
629 text_bounds2.bottom() + 2 * kPadding, | 632 text_bounds2.bottom() + 2 * kPadding, |
630 kGraphWidth, | 633 kGraphWidth, |
631 kGraphHeight); | 634 kGraphHeight); |
632 | 635 |
633 const std::string value_text = | 636 const std::string value_text = |
634 base::StringPrintf("%.1f", paint_time_graph_.value); | 637 base::StringPrintf("%.1f", paint_time_graph_.value); |
635 const std::string min_max_text = base::StringPrintf( | 638 const std::string min_max_text = base::StringPrintf( |
636 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max); | 639 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max); |
637 | 640 |
638 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor()); | 641 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor()); |
639 DrawText(canvas, &paint, "Compositor frame time (ms)", SkPaint::kLeft_Align, | 642 DrawText(canvas, &paint, "Compositor frame time(ms)", SkPaint::kLeft_Align, |
640 kFontHeight, text_bounds.left(), text_bounds.bottom()); | 643 kFontHeight, text_bounds.left(), text_bounds.bottom()); |
641 DrawText(canvas, | 644 DrawText(canvas, |
642 &paint, | 645 &paint, |
643 value_text, | 646 value_text, |
644 SkPaint::kLeft_Align, | 647 SkPaint::kLeft_Align, |
645 kFontHeight, | 648 kFontHeight, |
646 text_bounds2.left(), | 649 text_bounds2.left(), |
647 text_bounds2.bottom()); | 650 text_bounds2.bottom()); |
648 DrawText(canvas, | 651 DrawText(canvas, |
649 &paint, | 652 &paint, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 return "cc::HeadsUpDisplayLayerImpl"; | 842 return "cc::HeadsUpDisplayLayerImpl"; |
840 } | 843 } |
841 | 844 |
842 void HeadsUpDisplayLayerImpl::AsValueInto( | 845 void HeadsUpDisplayLayerImpl::AsValueInto( |
843 base::trace_event::TracedValue* dict) const { | 846 base::trace_event::TracedValue* dict) const { |
844 LayerImpl::AsValueInto(dict); | 847 LayerImpl::AsValueInto(dict); |
845 dict->SetString("layer_name", "Heads Up Display Layer"); | 848 dict->SetString("layer_name", "Heads Up Display Layer"); |
846 } | 849 } |
847 | 850 |
848 } // namespace cc | 851 } // namespace cc |
OLD | NEW |