Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: cc/picture_layer.cc

Issue 11574026: cc: Add some more infrastructure for two trees (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 80 columns /o\ Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/picture_layer.h" 5 #include "cc/picture_layer.h"
6
7 #include "cc/layer_tree_impl.h"
6 #include "cc/picture_layer_impl.h" 8 #include "cc/picture_layer_impl.h"
7 #include "ui/gfx/rect_conversions.h" 9 #include "ui/gfx/rect_conversions.h"
8 10
9 namespace cc { 11 namespace cc {
10 12
11 scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { 13 scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) {
12 return make_scoped_refptr(new PictureLayer(client)); 14 return make_scoped_refptr(new PictureLayer(client));
13 } 15 }
14 16
15 PictureLayer::PictureLayer(ContentLayerClient* client) : 17 PictureLayer::PictureLayer(ContentLayerClient* client) :
16 client_(client) { 18 client_(client) {
17 } 19 }
18 20
19 PictureLayer::~PictureLayer() { 21 PictureLayer::~PictureLayer() {
20 } 22 }
21 23
22 bool PictureLayer::drawsContent() const { 24 bool PictureLayer::drawsContent() const {
23 return Layer::drawsContent() && client_; 25 return Layer::drawsContent() && client_;
24 } 26 }
25 27
26 scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) { 28 scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) {
27 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); 29 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>();
28 } 30 }
29 31
30 void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { 32 void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) {
31 Layer::pushPropertiesTo(base_layer); 33 Layer::pushPropertiesTo(base_layer);
34
32 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 35 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
33 layer_impl->didUpdateBounds(); 36 layer_impl->tilings_.SetLayerBounds(bounds());
37 layer_impl->invalidation_.Clear();
38 layer_impl->invalidation_.Swap(pile_invalidation_);
34 pile_.PushPropertiesTo(layer_impl->pile_); 39 pile_.PushPropertiesTo(layer_impl->pile_);
35 40
36 // TODO(enne): Once we have two trees on the impl side, we need to 41 // TODO(enne): Remove this once syncing happens to the pending tree rather
37 // sync the active layer's tiles prior to this Invalidate call since it 42 // than the active one.
38 // will make new tiles for anything intersecting the invalidation. 43 if (layer_impl->layerTreeImpl()->IsActiveTree()) {
39 layer_impl->tilings_.Invalidate(pile_invalidation_); 44 layer_impl->tilings_.Invalidate(layer_impl->invalidation_);
40 pile_invalidation_.Clear(); 45 return;
46 }
47
48 if (drawsContent()) {
nduca 2012/12/14 02:18:43 can this be a method on the picture layer impl? Di
enne (OOO) 2012/12/14 17:30:53 Do you mean without having to instantiate an activ
49 // If there is an active tree version of this layer, get a copy of its
50 // tiles. This needs to be done last, after setting invalidation and the
51 // pile.
52 DCHECK(layer_impl->layerTreeImpl()->IsPendingTree());
53 PictureLayerImpl* active_twin = static_cast<PictureLayerImpl*>(
54 base_layer->layerTreeImpl()->ActiveTreeLayerById(id()));
55 if (active_twin)
56 layer_impl->SyncFromActiveLayer(active_twin);
57 }
41 } 58 }
42 59
43 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { 60 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) {
44 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); 61 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect);
45 pending_invalidation_.Union(rect); 62 pending_invalidation_.Union(rect);
46 Layer::setNeedsDisplayRect(layer_rect); 63 Layer::setNeedsDisplayRect(layer_rect);
47 } 64 }
48 65
49 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, 66 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
50 RenderingStats& stats) { 67 RenderingStats& stats) {
51 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) 68 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty())
52 return; 69 return;
53 70
54 pile_.Resize(bounds()); 71 pile_.Resize(bounds());
55 72
56 // Calling paint in WebKit can sometimes cause invalidations, so save 73 // Calling paint in WebKit can sometimes cause invalidations, so save
57 // off the invalidation prior to calling update. 74 // off the invalidation prior to calling update.
58 pile_invalidation_.Swap(pending_invalidation_); 75 pile_invalidation_.Swap(pending_invalidation_);
59 pending_invalidation_.Clear(); 76 pending_invalidation_.Clear();
60 77
61 pile_.Update(client_, pile_invalidation_, stats); 78 pile_.Update(client_, pile_invalidation_, stats);
62 } 79 }
63 80
64 } // namespace cc 81 } // namespace cc
OLDNEW
« cc/layer_tree_impl.h ('K') | « cc/layer_tree_impl.cc ('k') | cc/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698