Index: views/view.cc |
diff --git a/views/view.cc b/views/view.cc |
index 9105c9194528208c68f102fd6fd598cf64992d05..f6c87be5d01c0388ab60c7bc2e846bbe2bb96511 100644 |
--- a/views/view.cc |
+++ b/views/view.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
+#include "base/debug/trace_event.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop.h" |
@@ -115,6 +116,7 @@ View::View() |
previous_focusable_view_(NULL), |
focusable_(false), |
accessibility_focusable_(false), |
+ painting_enabled_(true), |
context_menu_controller_(NULL), |
drag_controller_(NULL) { |
} |
@@ -411,6 +413,14 @@ void View::OnEnabledChanged() { |
SchedulePaint(); |
} |
+void View::SetPaintingEnabled(bool enabled) { |
+ painting_enabled_ = enabled; |
+} |
+ |
+bool View::IsPaintingEnabled() const { |
+ return painting_enabled_; |
+} |
+ |
// Transformations ------------------------------------------------------------- |
const ui::Transform& View::GetTransform() const { |
@@ -431,11 +441,6 @@ void View::SetTransform(const ui::Transform& transform) { |
SchedulePaint(); |
} else { |
- // Make sure if the view didn't have its own texture and was painting onto |
- // something else, that gets refreshed too. |
- if (!ShouldPaintToLayer()) |
- MarkLayerDirty(); |
- |
if (!layer_helper_.get()) |
layer_helper_.reset(new internal::LayerHelper()); |
layer_helper_->SetTransform(transform); |
@@ -444,15 +449,7 @@ void View::SetTransform(const ui::Transform& transform) { |
SchedulePaint(); |
} else { |
layer_helper_->property_setter()->SetTransform(layer(), transform); |
- // We have a layer. When the transform changes and the layer is up to |
- // date we don't want to SchedulePaint as it'll trigger painting to the |
- // layer. Instead we tell the Widget to paint, which makes the |
- // compositor draw using the existing layer. |
- // We schedule paint the complete bounds as compositor generally don't |
- // support partial painting. |
- Widget* widget = GetWidget(); |
- if (widget) |
- widget->SchedulePaintInRect(widget->GetRootView()->bounds()); |
+ ScheduleComposite(); |
} |
} |
} |
@@ -518,6 +515,7 @@ int View::GetMirroredXWithWidthInView(int x, int w) const { |
// Layout ---------------------------------------------------------------------- |
void View::Layout() { |
+ TRACE_EVENT0("View", "Layout"); |
needs_layout_ = false; |
// If we have a layout manager, let it handle the layout for us. |
@@ -686,8 +684,20 @@ void View::SchedulePaintInRect(const gfx::Rect& rect) { |
SchedulePaintInternal(rect); |
} |
+void View::ScheduleComposite() { |
+ ScheduleCompositeInRect(GetLocalBounds()); |
+} |
+ |
+void View::ScheduleCompositeInRect(const gfx::Rect& rect) { |
+ if (!IsVisible()) |
+ return; |
+ |
+ SchedulePaintInternal(rect); |
+} |
+ |
void View::Paint(gfx::Canvas* canvas) { |
- if (!IsVisible()) |
+ TRACE_EVENT0("View", "Paint"); |
+ if (!IsVisible() || !IsPaintingEnabled()) |
return; |
ScopedCanvas scoped_canvas(NULL); |
@@ -1156,6 +1166,7 @@ void View::OnPaintFocusBorder(gfx::Canvas* canvas) { |
// Accelerated Painting -------------------------------------------------------- |
void View::PaintComposite() { |
+ TRACE_EVENT0("View", "PaintComposite"); |
if (!IsVisible()) |
return; |