Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "third_party/skia/include/core/SkRect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
| 14 #include "ui/base/accessibility/accessibility_types.h" | 15 #include "ui/base/accessibility/accessibility_types.h" |
| 15 #include "ui/base/dragdrop/drag_drop_types.h" | 16 #include "ui/base/dragdrop/drag_drop_types.h" |
| 16 #include "ui/gfx/canvas_skia.h" | 17 #include "ui/gfx/canvas_skia.h" |
| 17 #include "ui/gfx/compositor/compositor.h" | 18 #include "ui/gfx/compositor/compositor.h" |
| 18 #include "ui/gfx/compositor/layer.h" | 19 #include "ui/gfx/compositor/layer.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 101 |
| 101 // Creation and lifetime ------------------------------------------------------- | 102 // Creation and lifetime ------------------------------------------------------- |
| 102 | 103 |
| 103 View::View() | 104 View::View() |
| 104 : parent_owned_(true), | 105 : parent_owned_(true), |
| 105 id_(0), | 106 id_(0), |
| 106 group_(-1), | 107 group_(-1), |
| 107 parent_(NULL), | 108 parent_(NULL), |
| 108 visible_(true), | 109 visible_(true), |
| 109 enabled_(true), | 110 enabled_(true), |
| 111 painting_enabled_(true), | |
| 110 registered_for_visible_bounds_notification_(false), | 112 registered_for_visible_bounds_notification_(false), |
| 111 clip_x_(0.0), | 113 clip_x_(0.0), |
| 112 clip_y_(0.0), | 114 clip_y_(0.0), |
| 113 needs_layout_(true), | 115 needs_layout_(true), |
| 114 flip_canvas_on_paint_for_rtl_ui_(false), | 116 flip_canvas_on_paint_for_rtl_ui_(false), |
| 115 accelerator_registration_delayed_(false), | 117 accelerator_registration_delayed_(false), |
| 116 accelerator_focus_manager_(NULL), | 118 accelerator_focus_manager_(NULL), |
| 117 registered_accelerator_count_(0), | 119 registered_accelerator_count_(0), |
| 118 next_focusable_view_(NULL), | 120 next_focusable_view_(NULL), |
| 119 previous_focusable_view_(NULL), | 121 previous_focusable_view_(NULL), |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 return x_rect; | 680 return x_rect; |
| 679 } | 681 } |
| 680 | 682 |
| 681 // Painting -------------------------------------------------------------------- | 683 // Painting -------------------------------------------------------------------- |
| 682 | 684 |
| 683 void View::SchedulePaint() { | 685 void View::SchedulePaint() { |
| 684 SchedulePaintInRect(GetLocalBounds()); | 686 SchedulePaintInRect(GetLocalBounds()); |
| 685 } | 687 } |
| 686 | 688 |
| 687 void View::SchedulePaintInRect(const gfx::Rect& rect) { | 689 void View::SchedulePaintInRect(const gfx::Rect& rect) { |
| 688 if (!IsVisible()) | 690 if (!IsVisible() || !painting_enabled_) |
| 689 return; | 691 return; |
| 690 | 692 |
| 691 MarkLayerDirty(); | 693 MarkLayerDirty(); |
| 692 SchedulePaintInternal(rect); | 694 SchedulePaintInternal(rect); |
| 693 } | 695 } |
| 694 | 696 |
| 695 void View::Paint(gfx::Canvas* canvas) { | 697 void View::Paint(gfx::Canvas* canvas) { |
| 696 if (!IsVisible()) | 698 TRACE_EVENT0("View", "Paint"); |
| 699 if (!IsVisible() || !painting_enabled_) | |
|
sky
2011/08/25 21:10:12
You also need to update SchedulePaintInternal.
| |
| 697 return; | 700 return; |
| 698 | 701 |
| 699 ScopedCanvas scoped_canvas(NULL); | 702 ScopedCanvas scoped_canvas(NULL); |
| 700 scoped_ptr<gfx::Canvas> layer_canvas; | 703 scoped_ptr<gfx::Canvas> layer_canvas; |
| 701 gfx::Rect layer_rect; | 704 gfx::Rect layer_rect; |
| 702 | 705 |
| 703 if (layer()) { | 706 if (layer()) { |
| 704 gfx::Rect dirty_rect; | 707 gfx::Rect dirty_rect; |
| 705 if (!layer_helper_->clip_rect().IsEmpty()) { | 708 if (!layer_helper_->clip_rect().IsEmpty()) { |
| 706 dirty_rect = layer_helper_->clip_rect(); | 709 dirty_rect = layer_helper_->clip_rect(); |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2071 result.append(child_at(i)->PrintViewGraph(false)); | 2074 result.append(child_at(i)->PrintViewGraph(false)); |
| 2072 | 2075 |
| 2073 if (first) | 2076 if (first) |
| 2074 result.append("}\n"); | 2077 result.append("}\n"); |
| 2075 | 2078 |
| 2076 return result; | 2079 return result; |
| 2077 } | 2080 } |
| 2078 #endif | 2081 #endif |
| 2079 | 2082 |
| 2080 } // namespace views | 2083 } // namespace views |
| OLD | NEW |