diff options
author | wjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-03 21:19:32 +0000 |
---|---|---|
committer | wjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-03 21:19:32 +0000 |
commit | 6483195d6640a3727cc6e6e717718bd08036154b (patch) | |
tree | 06e3051b10858270a1e33c1ddf601f8259bbe21d /views | |
parent | c80ae8e8d69a89f9f97133ac076b6904c0a27fee (diff) | |
download | chromium_src-6483195d6640a3727cc6e6e717718bd08036154b.zip chromium_src-6483195d6640a3727cc6e6e717718bd08036154b.tar.gz chromium_src-6483195d6640a3727cc6e6e717718bd08036154b.tar.bz2 |
First draft of patch for setting texture_needs_updating_.
BUG=
TEST=
Review URL: http://codereview.chromium.org/7058019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 34 | ||||
-rw-r--r-- | views/view.h | 13 | ||||
-rw-r--r-- | views/widget/root_view.cc | 7 | ||||
-rw-r--r-- | views/widget/root_view.h | 3 |
4 files changed, 55 insertions, 2 deletions
diff --git a/views/view.cc b/views/view.cc index 039c70c..b74d26c 100644 --- a/views/view.cc +++ b/views/view.cc @@ -178,6 +178,9 @@ void View::AddChildViewAt(View* view, int index) { if (layout_manager_.get()) layout_manager_->ViewAdded(this, view); +#if defined(COMPOSITOR_2) + view->MarkTextureDirty(); +#endif } void View::RemoveChildView(View* view) { @@ -637,6 +640,10 @@ void View::SchedulePaintInRect(const gfx::Rect& rect) { if (!IsVisible()) return; +#if defined(COMPOSITOR_2) + MarkTextureDirty(); + SchedulePaintInternal(rect); +#else if (parent_) { // Translate the requested paint rect to the parent's coordinate system // then pass this notification up to the parent. @@ -644,6 +651,7 @@ void View::SchedulePaintInRect(const gfx::Rect& rect) { paint_rect.Offset(GetMirroredPosition()); parent_->SchedulePaintInRect(paint_rect); } +#endif } void View::Paint(gfx::Canvas* canvas) { @@ -672,8 +680,10 @@ void View::Paint(gfx::Canvas* canvas) { if (dirty_rect.IsEmpty()) return; - if (!texture_.get()) + if (!texture_.get()) { texture_.reset(GetCompositor()->CreateTexture()); + texture_needs_updating_ = true; + } if (!texture_needs_updating_) { // We don't need to be painted. Iterate over descendants in case one of @@ -689,7 +699,6 @@ void View::Paint(gfx::Canvas* canvas) { texture_canvas->TranslateInt(-dirty_rect.x(), -dirty_rect.y()); canvas = texture_canvas.get(); texture_rect = dirty_rect; - // TODO: set texture_needs_updating_ to false. #endif } else { // We're going to modify the canvas, save its state first. @@ -745,6 +754,7 @@ void View::Paint(gfx::Canvas* canvas) { texture_canvas->AsCanvasSkia()->getDevice()->accessBitmap(false), texture_rect.origin(), size()); + texture_needs_updating_ = false; } #endif } @@ -1177,6 +1187,16 @@ void View::PaintComposite() { GetChildViewAt(i)->PaintComposite(); } +void View::SchedulePaintInternal(const gfx::Rect& rect) { + if (parent_) { + // Translate the requested paint rect to the parent's coordinate system + // then pass this notification up to the parent. + gfx::Rect paint_rect = ConvertRectToParent(rect); + paint_rect.Offset(GetMirroredPosition()); + parent_->SchedulePaintInternal(paint_rect); + } +} + void View::PaintToTexture(const gfx::Rect& dirty_region) { if (!IsVisible()) return; @@ -1594,6 +1614,16 @@ bool View::ConvertPointFromAncestor(const View* ancestor, // Accelerated painting -------------------------------------------------------- +#if defined(COMPOSITOR_2) +void View::MarkTextureDirty() { + View* owner = this; + while (!((owner->transform_.get() && owner->transform_->HasChange()) || + owner->paint_to_texture_) && owner->parent()) + owner = owner->parent(); + owner->texture_needs_updating_ = true; +} +#endif + void View::ResetTexture() { #if defined(COMPOSITOR_2) texture_.reset(); diff --git a/views/view.h b/views/view.h index d60fa43..f000b85 100644 --- a/views/view.h +++ b/views/view.h @@ -1009,9 +1009,17 @@ class View : public AcceleratorTarget { // Accelerated painting ------------------------------------------------------ #if !defined(COMPOSITOR_2) + // Performs accelerated painting using the compositor. virtual void PaintComposite(ui::Compositor* compositor); #else + + // Invoked from SchedulePaintInRect. Invokes SchedulePaintInternal on the + // parent. This does not mark the texture as dirty. It's assumed the caller + // has done this. You should not need to invoke this, use SchedulePaint or + // SchedulePaintInRect instead. + virtual void SchedulePaintInternal(const gfx::Rect& r); + // If our texture is out of date invokes Paint() with a canvas that is then // copied to the texture. If the texture is not out of date recursively // descends in case any children needed their textures updated. @@ -1222,6 +1230,11 @@ class View : public AcceleratorTarget { // Accelerated painting ------------------------------------------------------ +#if defined(COMPOSITOR_2) + // Marks the texture this view draws into as dirty. + void MarkTextureDirty(); +#endif + // Releases the texture of this and recurses through all children. void ResetTexture(); diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 0b64f4e..cdc44a8 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -157,6 +157,13 @@ std::string RootView::GetClassName() const { } void RootView::SchedulePaintInRect(const gfx::Rect& rect) { +#if defined(COMPOSITOR_2) + MarkTextureDirty(); + SchedulePaintInternal(rect); +} + +void RootView::SchedulePaintInternal(const gfx::Rect& rect) { +#endif gfx::Rect xrect = ConvertRectToParent(rect); gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); if (!invalid_rect.IsEmpty()) diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 18b08f8..6bb9795 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -102,6 +102,9 @@ class RootView : public View, virtual bool IsVisibleInRootView() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; +#if defined(COMPOSITOR_2) + virtual void SchedulePaintInternal(const gfx::Rect& rect) OVERRIDE; +#endif virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |