OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/view.h" | 5 #include "views/view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 if (layer()) { | 645 if (layer()) { |
646 layer()->SchedulePaint(rect); | 646 layer()->SchedulePaint(rect); |
647 } else if (parent_) { | 647 } else if (parent_) { |
648 // Translate the requested paint rect to the parent's coordinate system | 648 // Translate the requested paint rect to the parent's coordinate system |
649 // then pass this notification up to the parent. | 649 // then pass this notification up to the parent. |
650 parent_->SchedulePaintInRect(ConvertRectToParent(rect)); | 650 parent_->SchedulePaintInRect(ConvertRectToParent(rect)); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 void View::Paint(gfx::Canvas* canvas) { | 654 void View::Paint(gfx::Canvas* canvas) { |
655 TRACE_EVENT0("View", "Paint"); | 655 TRACE_EVENT0("views", "View::Paint"); |
656 | 656 |
657 ScopedCanvas scoped_canvas(canvas); | 657 ScopedCanvas scoped_canvas(canvas); |
658 | 658 |
659 // Paint this View and its children, setting the clip rect to the bounds | 659 // Paint this View and its children, setting the clip rect to the bounds |
660 // of this View and translating the origin to the local bounds' top left | 660 // of this View and translating the origin to the local bounds' top left |
661 // point. | 661 // point. |
662 // | 662 // |
663 // Note that the X (or left) position we pass to ClipRectInt takes into | 663 // Note that the X (or left) position we pass to ClipRectInt takes into |
664 // consideration whether or not the view uses a right-to-left layout so that | 664 // consideration whether or not the view uses a right-to-left layout so that |
665 // we paint our view in its mirrored position if need be. | 665 // we paint our view in its mirrored position if need be. |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 if (focus_manager) { | 1037 if (focus_manager) { |
1038 RegisterPendingAccelerators(); | 1038 RegisterPendingAccelerators(); |
1039 accelerator_registration_delayed_ = false; | 1039 accelerator_registration_delayed_ = false; |
1040 } | 1040 } |
1041 } | 1041 } |
1042 } | 1042 } |
1043 | 1043 |
1044 // Painting -------------------------------------------------------------------- | 1044 // Painting -------------------------------------------------------------------- |
1045 | 1045 |
1046 void View::PaintChildren(gfx::Canvas* canvas) { | 1046 void View::PaintChildren(gfx::Canvas* canvas) { |
| 1047 TRACE_EVENT0("views", "View::PaintChildren"); |
1047 for (int i = 0, count = child_count(); i < count; ++i) | 1048 for (int i = 0, count = child_count(); i < count; ++i) |
1048 if (!child_at(i)->layer()) | 1049 if (!child_at(i)->layer()) |
1049 child_at(i)->Paint(canvas); | 1050 child_at(i)->Paint(canvas); |
1050 } | 1051 } |
1051 | 1052 |
1052 void View::OnPaint(gfx::Canvas* canvas) { | 1053 void View::OnPaint(gfx::Canvas* canvas) { |
| 1054 TRACE_EVENT0("views", "View::OnPaint"); |
1053 OnPaintBackground(canvas); | 1055 OnPaintBackground(canvas); |
1054 OnPaintFocusBorder(canvas); | 1056 OnPaintFocusBorder(canvas); |
1055 OnPaintBorder(canvas); | 1057 OnPaintBorder(canvas); |
1056 } | 1058 } |
1057 | 1059 |
1058 void View::OnPaintBackground(gfx::Canvas* canvas) { | 1060 void View::OnPaintBackground(gfx::Canvas* canvas) { |
1059 if (background_.get()) | 1061 if (background_.get()) { |
| 1062 TRACE_EVENT2("views", "View::OnPaintBackground", |
| 1063 "width", canvas->GetSkCanvas()->getDevice()->width(), |
| 1064 "height", canvas->GetSkCanvas()->getDevice()->height()); |
1060 background_->Paint(canvas, this); | 1065 background_->Paint(canvas, this); |
| 1066 } |
1061 } | 1067 } |
1062 | 1068 |
1063 void View::OnPaintBorder(gfx::Canvas* canvas) { | 1069 void View::OnPaintBorder(gfx::Canvas* canvas) { |
1064 if (border_.get()) | 1070 if (border_.get()) { |
| 1071 TRACE_EVENT2("views", "View::OnPaintBorder", |
| 1072 "width", canvas->GetSkCanvas()->getDevice()->width(), |
| 1073 "height", canvas->GetSkCanvas()->getDevice()->height()); |
1065 border_->Paint(*this, canvas); | 1074 border_->Paint(*this, canvas); |
| 1075 } |
1066 } | 1076 } |
1067 | 1077 |
1068 void View::OnPaintFocusBorder(gfx::Canvas* canvas) { | 1078 void View::OnPaintFocusBorder(gfx::Canvas* canvas) { |
1069 if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) | 1079 if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) { |
| 1080 TRACE_EVENT2("views", "views::OnPaintFocusBorder", |
| 1081 "width", canvas->GetSkCanvas()->getDevice()->width(), |
| 1082 "height", canvas->GetSkCanvas()->getDevice()->height()); |
1070 canvas->DrawFocusRect(GetLocalBounds()); | 1083 canvas->DrawFocusRect(GetLocalBounds()); |
| 1084 } |
1071 } | 1085 } |
1072 | 1086 |
1073 // Accelerated Painting -------------------------------------------------------- | 1087 // Accelerated Painting -------------------------------------------------------- |
1074 | 1088 |
1075 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { | 1089 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { |
1076 // This method should not have the side-effect of creating the layer. | 1090 // This method should not have the side-effect of creating the layer. |
1077 if (layer()) | 1091 if (layer()) |
1078 layer()->SetFillsBoundsOpaquely(fills_bounds_opaquely); | 1092 layer()->SetFillsBoundsOpaquely(fills_bounds_opaquely); |
1079 } | 1093 } |
1080 | 1094 |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 | 2070 |
2057 OSExchangeData data; | 2071 OSExchangeData data; |
2058 WriteDragData(press_pt, &data); | 2072 WriteDragData(press_pt, &data); |
2059 | 2073 |
2060 // Message the RootView to do the drag and drop. That way if we're removed | 2074 // Message the RootView to do the drag and drop. That way if we're removed |
2061 // the RootView can detect it and avoid calling us back. | 2075 // the RootView can detect it and avoid calling us back. |
2062 GetWidget()->RunShellDrag(this, data, drag_operations); | 2076 GetWidget()->RunShellDrag(this, data, drag_operations); |
2063 } | 2077 } |
2064 | 2078 |
2065 } // namespace views | 2079 } // namespace views |
OLD | NEW |