OLD | NEW |
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 layer_impl->SyncFromActiveLayer(); |
41 } | 49 } |
42 | 50 |
43 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { | 51 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { |
44 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); | 52 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); |
45 pending_invalidation_.Union(rect); | 53 pending_invalidation_.Union(rect); |
46 Layer::setNeedsDisplayRect(layer_rect); | 54 Layer::setNeedsDisplayRect(layer_rect); |
47 } | 55 } |
48 | 56 |
49 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, | 57 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, |
50 RenderingStats& stats) { | 58 RenderingStats& stats) { |
51 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) | 59 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) |
52 return; | 60 return; |
53 | 61 |
54 pile_.Resize(bounds()); | 62 pile_.Resize(bounds()); |
55 | 63 |
56 // Calling paint in WebKit can sometimes cause invalidations, so save | 64 // Calling paint in WebKit can sometimes cause invalidations, so save |
57 // off the invalidation prior to calling update. | 65 // off the invalidation prior to calling update. |
58 pile_invalidation_.Swap(pending_invalidation_); | 66 pile_invalidation_.Swap(pending_invalidation_); |
59 pending_invalidation_.Clear(); | 67 pending_invalidation_.Clear(); |
60 | 68 |
61 pile_.Update(client_, pile_invalidation_, stats); | 69 pile_.Update(client_, pile_invalidation_, stats); |
62 } | 70 } |
63 | 71 |
64 } // namespace cc | 72 } // namespace cc |
OLD | NEW |