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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 DCHECK(info.colorType() == kN32_SkColorType); | 216 DCHECK(info.colorType() == kN32_SkColorType); |
217 resource_provider->CopyToResource(resources_.back()->id(), | 217 resource_provider->CopyToResource(resources_.back()->id(), |
218 static_cast<const uint8_t*>(pixels), | 218 static_cast<const uint8_t*>(pixels), |
219 internal_content_bounds_); | 219 internal_content_bounds_); |
220 } | 220 } |
221 | 221 |
222 void HeadsUpDisplayLayerImpl::ReleaseResources() { | 222 void HeadsUpDisplayLayerImpl::ReleaseResources() { |
223 resources_.clear(); | 223 resources_.clear(); |
224 } | 224 } |
225 | 225 |
| 226 gfx::Rect HeadsUpDisplayLayerImpl::GetEnclosingRectInTargetSpace() const { |
| 227 return GetScaledEnclosingRectInTargetSpace(internal_contents_scale_); |
| 228 } |
| 229 |
226 void HeadsUpDisplayLayerImpl::UpdateHudContents() { | 230 void HeadsUpDisplayLayerImpl::UpdateHudContents() { |
227 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); | 231 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); |
228 | 232 |
229 // Don't update numbers every frame so text is readable. | 233 // Don't update numbers every frame so text is readable. |
230 base::TimeTicks now = layer_tree_impl()->CurrentBeginFrameArgs().frame_time; | 234 base::TimeTicks now = layer_tree_impl()->CurrentBeginFrameArgs().frame_time; |
231 if (base::TimeDelta(now - time_of_last_graph_update_).InSecondsF() > 0.25f) { | 235 if (base::TimeDelta(now - time_of_last_graph_update_).InSecondsF() > 0.25f) { |
232 time_of_last_graph_update_ = now; | 236 time_of_last_graph_update_ = now; |
233 | 237 |
234 if (debug_state.show_fps_counter) { | 238 if (debug_state.show_fps_counter) { |
235 FrameRateCounter* fps_counter = layer_tree_impl()->frame_rate_counter(); | 239 FrameRateCounter* fps_counter = layer_tree_impl()->frame_rate_counter(); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 548 } |
545 | 549 |
546 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, | 550 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, |
547 int right, | 551 int right, |
548 int top, | 552 int top, |
549 int width) const { | 553 int width) const { |
550 std::string status; | 554 std::string status; |
551 SkColor color = SK_ColorRED; | 555 SkColor color = SK_ColorRED; |
552 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { | 556 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { |
553 case GpuRasterizationStatus::ON: | 557 case GpuRasterizationStatus::ON: |
554 status = "GPU raster: on"; | 558 status = "on"; |
555 color = SK_ColorGREEN; | 559 color = SK_ColorGREEN; |
556 break; | 560 break; |
557 case GpuRasterizationStatus::ON_FORCED: | 561 case GpuRasterizationStatus::ON_FORCED: |
558 status = "GPU raster: on (forced)"; | 562 status = "on (forced)"; |
559 color = SK_ColorGREEN; | 563 color = SK_ColorGREEN; |
560 break; | 564 break; |
561 case GpuRasterizationStatus::OFF_DEVICE: | 565 case GpuRasterizationStatus::OFF_DEVICE: |
562 status = "GPU raster: off (device)"; | 566 status = "off (device)"; |
563 color = SK_ColorRED; | 567 color = SK_ColorRED; |
564 break; | 568 break; |
565 case GpuRasterizationStatus::OFF_VIEWPORT: | 569 case GpuRasterizationStatus::OFF_VIEWPORT: |
566 status = "GPU raster: off (viewport)"; | 570 status = "off (viewport)"; |
567 color = SK_ColorYELLOW; | 571 color = SK_ColorYELLOW; |
568 break; | 572 break; |
569 case GpuRasterizationStatus::OFF_CONTENT: | 573 case GpuRasterizationStatus::OFF_CONTENT: |
570 status = "GPU raster: off (content)"; | 574 status = "off (content)"; |
571 color = SK_ColorYELLOW; | 575 color = SK_ColorYELLOW; |
572 break; | 576 break; |
573 } | 577 } |
574 | 578 |
575 if (status.empty()) | 579 if (status.empty()) |
576 return SkRect::MakeEmpty(); | 580 return SkRect::MakeEmpty(); |
577 | 581 |
578 const int kPadding = 4; | 582 const int kPadding = 4; |
579 const int kFontHeight = 13; | 583 const int kFontHeight = 13; |
580 | 584 |
581 const int height = kFontHeight + 2 * kPadding; | 585 const int height = 2 * kFontHeight + 3 * kPadding; |
582 const int left = bounds().width() - width - right; | 586 const int left = bounds().width() - width - right; |
583 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 587 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
584 | 588 |
585 SkPaint paint = CreatePaint(); | 589 SkPaint paint = CreatePaint(); |
586 DrawGraphBackground(canvas, &paint, area); | 590 DrawGraphBackground(canvas, &paint, area); |
587 | 591 |
588 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); |
589 | 594 |
590 paint.setColor(color); | 595 paint.setColor(color); |
591 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, |
592 gpu_status_pos); | 599 gpu_status_pos); |
593 | 600 |
594 return area; | 601 return area; |
595 } | 602 } |
596 | 603 |
597 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( | 604 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( |
598 SkCanvas* canvas, | 605 SkCanvas* canvas, |
599 const PaintTimeCounter* paint_time_counter, | 606 const PaintTimeCounter* paint_time_counter, |
600 int right, | 607 int right, |
601 int top) const { | 608 int top) const { |
602 const int kPadding = 4; | 609 const int kPadding = 4; |
603 const int kFontHeight = 15; | 610 const int kFontHeight = 14; |
604 | 611 |
605 const int kGraphWidth = paint_time_counter->HistorySize(); | 612 const int kGraphWidth = paint_time_counter->HistorySize(); |
606 const int kGraphHeight = 40; | 613 const int kGraphHeight = 40; |
607 | 614 |
608 const int width = kGraphWidth + 2 * kPadding; | 615 const int width = kGraphWidth + 2 * kPadding; |
609 const int height = | 616 const int height = |
610 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding; | 617 kFontHeight + kGraphHeight + 4 * kPadding + 2 + kFontHeight + kPadding; |
611 const int left = bounds().width() - width - right; | 618 const int left = bounds().width() - width - right; |
612 | 619 |
613 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... |
625 text_bounds2.bottom() + 2 * kPadding, | 632 text_bounds2.bottom() + 2 * kPadding, |
626 kGraphWidth, | 633 kGraphWidth, |
627 kGraphHeight); | 634 kGraphHeight); |
628 | 635 |
629 const std::string value_text = | 636 const std::string value_text = |
630 base::StringPrintf("%.1f", paint_time_graph_.value); | 637 base::StringPrintf("%.1f", paint_time_graph_.value); |
631 const std::string min_max_text = base::StringPrintf( | 638 const std::string min_max_text = base::StringPrintf( |
632 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max); | 639 "%.1f-%.1f", paint_time_graph_.min, paint_time_graph_.max); |
633 | 640 |
634 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor()); | 641 paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor()); |
635 DrawText(canvas, &paint, "Compositor frame time (ms)", SkPaint::kLeft_Align, | 642 DrawText(canvas, &paint, "Compositor frame time(ms)", SkPaint::kLeft_Align, |
636 kFontHeight, text_bounds.left(), text_bounds.bottom()); | 643 kFontHeight, text_bounds.left(), text_bounds.bottom()); |
637 DrawText(canvas, | 644 DrawText(canvas, |
638 &paint, | 645 &paint, |
639 value_text, | 646 value_text, |
640 SkPaint::kLeft_Align, | 647 SkPaint::kLeft_Align, |
641 kFontHeight, | 648 kFontHeight, |
642 text_bounds2.left(), | 649 text_bounds2.left(), |
643 text_bounds2.bottom()); | 650 text_bounds2.bottom()); |
644 DrawText(canvas, | 651 DrawText(canvas, |
645 &paint, | 652 &paint, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return "cc::HeadsUpDisplayLayerImpl"; | 842 return "cc::HeadsUpDisplayLayerImpl"; |
836 } | 843 } |
837 | 844 |
838 void HeadsUpDisplayLayerImpl::AsValueInto( | 845 void HeadsUpDisplayLayerImpl::AsValueInto( |
839 base::trace_event::TracedValue* dict) const { | 846 base::trace_event::TracedValue* dict) const { |
840 LayerImpl::AsValueInto(dict); | 847 LayerImpl::AsValueInto(dict); |
841 dict->SetString("layer_name", "Heads Up Display Layer"); | 848 dict->SetString("layer_name", "Heads Up Display Layer"); |
842 } | 849 } |
843 | 850 |
844 } // namespace cc | 851 } // namespace cc |
OLD | NEW |