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" |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 677 } |
678 } | 678 } |
679 | 679 |
680 void HeadsUpDisplayLayerImpl::DrawDebugRects( | 680 void HeadsUpDisplayLayerImpl::DrawDebugRects( |
681 SkCanvas* canvas, | 681 SkCanvas* canvas, |
682 DebugRectHistory* debug_rect_history) { | 682 DebugRectHistory* debug_rect_history) { |
683 SkPaint paint = CreatePaint(); | 683 SkPaint paint = CreatePaint(); |
684 | 684 |
685 const std::vector<DebugRect>& debug_rects = debug_rect_history->debug_rects(); | 685 const std::vector<DebugRect>& debug_rects = debug_rect_history->debug_rects(); |
686 std::vector<DebugRect> new_paint_rects; | 686 std::vector<DebugRect> new_paint_rects; |
| 687 std::vector<DebugRect> new_first_paint_rects; |
687 | 688 |
688 for (size_t i = 0; i < debug_rects.size(); ++i) { | 689 for (size_t i = 0; i < debug_rects.size(); ++i) { |
689 SkColor stroke_color = 0; | 690 SkColor stroke_color = 0; |
690 SkColor fill_color = 0; | 691 SkColor fill_color = 0; |
691 float stroke_width = 0.f; | 692 float stroke_width = 0.f; |
692 std::string label_text; | 693 std::string label_text; |
693 | 694 |
694 switch (debug_rects[i].type) { | 695 switch (debug_rects[i].type) { |
695 case PAINT_RECT_TYPE: | 696 case PAINT_RECT_TYPE: |
696 new_paint_rects.push_back(debug_rects[i]); | 697 new_paint_rects.push_back(debug_rects[i]); |
697 continue; | 698 continue; |
| 699 case FIRST_PAINT_RECT_TYPE: |
| 700 new_first_paint_rects.push_back(debug_rects[i]); |
| 701 continue; |
698 case PROPERTY_CHANGED_RECT_TYPE: | 702 case PROPERTY_CHANGED_RECT_TYPE: |
699 stroke_color = DebugColors::PropertyChangedRectBorderColor(); | 703 stroke_color = DebugColors::PropertyChangedRectBorderColor(); |
700 fill_color = DebugColors::PropertyChangedRectFillColor(); | 704 fill_color = DebugColors::PropertyChangedRectFillColor(); |
701 stroke_width = DebugColors::PropertyChangedRectBorderWidth(); | 705 stroke_width = DebugColors::PropertyChangedRectBorderWidth(); |
702 break; | 706 break; |
703 case SURFACE_DAMAGE_RECT_TYPE: | 707 case SURFACE_DAMAGE_RECT_TYPE: |
704 stroke_color = DebugColors::SurfaceDamageRectBorderColor(); | 708 stroke_color = DebugColors::SurfaceDamageRectBorderColor(); |
705 fill_color = DebugColors::SurfaceDamageRectFillColor(); | 709 fill_color = DebugColors::SurfaceDamageRectFillColor(); |
706 stroke_width = DebugColors::SurfaceDamageRectBorderWidth(); | 710 stroke_width = DebugColors::SurfaceDamageRectBorderWidth(); |
707 break; | 711 break; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 label_text); | 770 label_text); |
767 } | 771 } |
768 | 772 |
769 if (new_paint_rects.size()) { | 773 if (new_paint_rects.size()) { |
770 paint_rects_.swap(new_paint_rects); | 774 paint_rects_.swap(new_paint_rects); |
771 fade_step_ = DebugColors::kFadeSteps; | 775 fade_step_ = DebugColors::kFadeSteps; |
772 } | 776 } |
773 if (fade_step_ > 0) { | 777 if (fade_step_ > 0) { |
774 fade_step_--; | 778 fade_step_--; |
775 for (size_t i = 0; i < paint_rects_.size(); ++i) { | 779 for (size_t i = 0; i < paint_rects_.size(); ++i) { |
776 DrawDebugRect(canvas, | 780 bool is_first_paint = paint_rects_[i].type == FIRST_PAINT_RECT_TYPE; |
777 &paint, | 781 DrawDebugRect( |
778 paint_rects_[i], | 782 canvas, |
779 DebugColors::PaintRectBorderColor(fade_step_), | 783 &paint, |
780 DebugColors::PaintRectFillColor(fade_step_), | 784 paint_rects_[i], |
781 DebugColors::PaintRectBorderWidth(), | 785 DebugColors::PaintRectBorderColor(fade_step_, is_first_paint), |
782 ""); | 786 DebugColors::PaintRectFillColor(fade_step_, is_first_paint), |
| 787 DebugColors::PaintRectBorderWidth(), |
| 788 ""); |
| 789 } |
| 790 } |
| 791 |
| 792 // TODO(kouhei) |
| 793 if (new_first_paint_rects.size()) { |
| 794 first_paint_rects_.swap(new_first_paint_rects); |
| 795 fade_step_f_ = DebugColors::kFadeSteps; |
| 796 } |
| 797 if (fade_step_f_ > 0) { |
| 798 fade_step_f_--; |
| 799 for (size_t i = 0; i < first_paint_rects_.size(); ++i) { |
| 800 bool is_first_paint = first_paint_rects_[i].type == FIRST_PAINT_RECT_TYPE; |
| 801 DrawDebugRect( |
| 802 canvas, |
| 803 &paint, |
| 804 first_paint_rects_[i], |
| 805 DebugColors::PaintRectBorderColor(fade_step_f_, is_first_paint), |
| 806 DebugColors::PaintRectFillColor(fade_step_f_, is_first_paint), |
| 807 DebugColors::PaintRectBorderWidth(), |
| 808 ""); |
783 } | 809 } |
784 } | 810 } |
785 } | 811 } |
786 | 812 |
787 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { | 813 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { |
788 return "cc::HeadsUpDisplayLayerImpl"; | 814 return "cc::HeadsUpDisplayLayerImpl"; |
789 } | 815 } |
790 | 816 |
791 void HeadsUpDisplayLayerImpl::AsValueInto( | 817 void HeadsUpDisplayLayerImpl::AsValueInto( |
792 base::debug::TracedValue* dict) const { | 818 base::debug::TracedValue* dict) const { |
793 LayerImpl::AsValueInto(dict); | 819 LayerImpl::AsValueInto(dict); |
794 dict->SetString("layer_name", "Heads Up Display Layer"); | 820 dict->SetString("layer_name", "Heads Up Display Layer"); |
795 } | 821 } |
796 | 822 |
797 } // namespace cc | 823 } // namespace cc |
OLD | NEW |