diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 03:29:17 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 03:29:17 +0000 |
commit | 0e630ea38167c0cafbba79e8d8043dbb3487b980 (patch) | |
tree | 5426e58c6c86a0025468e239131a50850ef43736 /cc | |
parent | 89590681f899dfe06878dcc7b87855bd9e4d6f8e (diff) | |
download | chromium_src-0e630ea38167c0cafbba79e8d8043dbb3487b980.zip chromium_src-0e630ea38167c0cafbba79e8d8043dbb3487b980.tar.gz chromium_src-0e630ea38167c0cafbba79e8d8043dbb3487b980.tar.bz2 |
cc: Clean up invalidation behavior in PicturePile / PictureLayer
BUG=155209
Review URL: https://chromiumcodereview.appspot.com/11416217
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/picture_layer.cc | 21 | ||||
-rw-r--r-- | cc/picture_layer.h | 5 | ||||
-rw-r--r-- | cc/picture_layer_tiling_set.cc | 3 | ||||
-rw-r--r-- | cc/picture_pile.cc | 46 | ||||
-rw-r--r-- | cc/picture_pile.h | 18 |
5 files changed, 40 insertions, 53 deletions
diff --git a/cc/picture_layer.cc b/cc/picture_layer.cc index 86842df..cac70f7 100644 --- a/cc/picture_layer.cc +++ b/cc/picture_layer.cc @@ -32,20 +32,31 @@ void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); pile_.PushPropertiesTo(layer_impl->pile_); - // TODO(enne): Need to sync tiling from active tree prior to this. - layer_impl->tilings_.Invalidate(invalidation_); - invalidation_.Clear(); + // TODO(enne): Once we have two trees on the impl side, we need to + // sync the active layer's tiles prior to this Invalidate call since it + // will make new tiles for anything intersecting the invalidation. + layer_impl->tilings_.Invalidate(pile_invalidation_); + pile_invalidation_.Clear(); } void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); - invalidation_.Union(rect); + pending_invalidation_.Union(rect); } void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats& stats) { + if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) + return; + pile_.Resize(bounds()); - pile_.Update(client_, stats); + + // Calling paint in WebKit can sometimes cause invalidations, so save + // off the invalidation prior to calling update. + pile_invalidation_.Swap(pending_invalidation_); + pending_invalidation_.Clear(); + + pile_.Update(client_, pile_invalidation_, stats); } } // namespace cc diff --git a/cc/picture_layer.h b/cc/picture_layer.h index 54c83c5..1517687 100644 --- a/cc/picture_layer.h +++ b/cc/picture_layer.h @@ -36,7 +36,10 @@ protected: private: ContentLayerClient* client_; PicturePile pile_; - Region invalidation_; + // Invalidation to use the next time update is called. + Region pending_invalidation_; + // Invalidation from the last time update was called. + Region pile_invalidation_; }; } // namespace cc diff --git a/cc/picture_layer_tiling_set.cc b/cc/picture_layer_tiling_set.cc index b5d97fe..5b49a03 100644 --- a/cc/picture_layer_tiling_set.cc +++ b/cc/picture_layer_tiling_set.cc @@ -34,6 +34,9 @@ gfx::Size PictureLayerTilingSet::LayerBounds() const { } void PictureLayerTilingSet::Invalidate(const Region& invalidation) { + if (invalidation.IsEmpty()) + return; + for (size_t i = 0; i < tilings_.size(); ++i) tilings_[i]->Invalidate(invalidation); } diff --git a/cc/picture_pile.cc b/cc/picture_pile.cc index 3c4bd52..afd8a79 100644 --- a/cc/picture_pile.cc +++ b/cc/picture_pile.cc @@ -16,10 +16,6 @@ PicturePile::PicturePile() { PicturePile::~PicturePile() { } -void PicturePile::Invalidate(gfx::Rect rect) { - invalidation_.Union(rect); -} - class OutOfBoundsPredicate { public: OutOfBoundsPredicate(gfx::Size size) : layer_rect_(gfx::Point(), size) { } @@ -30,23 +26,6 @@ public: }; void PicturePile::Resize(gfx::Size size) { - if (size.width() > size_.width()) { - gfx::Rect invalid( - size_.width(), - 0, - size.width() - size_.width(), - size.height()); - Invalidate(invalid); - } - if (size.height() > size_.height()) { - gfx::Rect invalid( - 0, - size_.height(), - size.width(), - size.height() - size_.height()); - Invalidate(invalid); - } - // Remove pictures that aren't in bounds anymore. if (size.width() < size_.width() || size.height() < size_.height()) { OutOfBoundsPredicate oob(size); @@ -56,27 +35,22 @@ void PicturePile::Resize(gfx::Size size) { size_ = size; } -void PicturePile::Update(ContentLayerClient* painter, RenderingStats& stats) { - // WebKit paints (i.e. recording) can cause invalidations, so record previous. - invalidation_.Swap(prev_invalidation_); - invalidation_.Clear(); - +void PicturePile::Update( + ContentLayerClient* painter, + const Region&, + RenderingStats& stats) { // TODO(enne): Add things to the pile, consolidate if needed, etc... + // TODO(enne): Only re-record invalidated areas. + // TODO(enne): Also re-record areas that have been newly exposed by resize. + + // Always re-record the entire layer into a single picture, just to get + // this class up and running. if (pile_.size() == 0) pile_.push_back(Picture::Create()); pile_[0]->Record(painter, gfx::Rect(gfx::Point(), size_), stats); } -void PicturePile::CopyAllButPile( - const PicturePile& from, PicturePile& to) const { - to.size_ = from.size_; - to.invalidation_ = from.invalidation_; - to.prev_invalidation_ = from.prev_invalidation_; -} - void PicturePile::PushPropertiesTo(PicturePile& other) { - CopyAllButPile(*this, other); - other.pile_.resize(pile_.size()); for (size_t i = 0; i < pile_.size(); ++i) other.pile_[i] = pile_[i]; @@ -85,8 +59,6 @@ void PicturePile::PushPropertiesTo(PicturePile& other) { scoped_ptr<PicturePile> PicturePile::CloneForDrawing() const { TRACE_EVENT0("cc", "PicturePile::CloneForDrawing"); scoped_ptr<PicturePile> clone = make_scoped_ptr(new PicturePile); - CopyAllButPile(*this, *clone); - clone->pile_.resize(pile_.size()); for (size_t i = 0; i < pile_.size(); ++i) clone->pile_[i] = pile_[i]->Clone(); diff --git a/cc/picture_pile.h b/cc/picture_pile.h index 0755d7d..8ec7093 100644 --- a/cc/picture_pile.h +++ b/cc/picture_pile.h @@ -22,15 +22,17 @@ public: PicturePile(); ~PicturePile(); - // Mark a portion of the PicturePile as invalid and needing to be re-recorded - // the next time update is called. - void Invalidate(gfx::Rect); - - // Resize the PicturePile, invalidating / dropping recorded pictures as necessary. + // Resize the PicturePile, invalidating / dropping recorded pictures as + // necessary. void Resize(gfx::Size); + gfx::Size size() const { return size_; } // Re-record parts of the picture that are invalid. - void Update(ContentLayerClient* painter, RenderingStats&); + // Invalidations are in layer space. + void Update( + ContentLayerClient* painter, + const Region& invalidation, + RenderingStats& stats); // Update other with a shallow copy of this (main => compositor thread commit) void PushPropertiesTo(PicturePile& other); @@ -44,12 +46,8 @@ public: void Raster(SkCanvas* canvas, gfx::Rect rect); private: - void CopyAllButPile(const PicturePile& from, PicturePile& to) const; - std::vector<scoped_refptr<Picture> > pile_; gfx::Size size_; - Region invalidation_; - Region prev_invalidation_; DISALLOW_COPY_AND_ASSIGN(PicturePile); }; |