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 | 6 |
7 #include "cc/layer_tree_impl.h" | 7 #include "cc/layer_tree_impl.h" |
8 #include "cc/picture_layer_impl.h" | 8 #include "cc/picture_layer_impl.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { | 13 scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { |
14 return make_scoped_refptr(new PictureLayer(client)); | 14 return make_scoped_refptr(new PictureLayer(client)); |
15 } | 15 } |
16 | 16 |
17 PictureLayer::PictureLayer(ContentLayerClient* client) : | 17 PictureLayer::PictureLayer(ContentLayerClient* client) : |
18 client_(client) { | 18 client_(client), |
| 19 is_mask_(false) { |
19 } | 20 } |
20 | 21 |
21 PictureLayer::~PictureLayer() { | 22 PictureLayer::~PictureLayer() { |
22 } | 23 } |
23 | 24 |
24 bool PictureLayer::drawsContent() const { | 25 bool PictureLayer::drawsContent() const { |
25 return Layer::drawsContent() && client_; | 26 return Layer::drawsContent() && client_; |
26 } | 27 } |
27 | 28 |
28 scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) { | 29 scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) { |
29 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); | 30 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); |
30 } | 31 } |
31 | 32 |
32 void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { | 33 void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { |
33 Layer::pushPropertiesTo(base_layer); | 34 Layer::pushPropertiesTo(base_layer); |
34 | 35 |
35 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 36 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
| 37 layer_impl->SetIsMask(is_mask_); |
36 layer_impl->tilings_.SetLayerBounds(bounds()); | 38 layer_impl->tilings_.SetLayerBounds(bounds()); |
37 layer_impl->invalidation_.Clear(); | 39 layer_impl->invalidation_.Clear(); |
38 layer_impl->invalidation_.Swap(pile_invalidation_); | 40 layer_impl->invalidation_.Swap(pile_invalidation_); |
39 pile_.PushPropertiesTo(layer_impl->pile_); | 41 pile_.PushPropertiesTo(layer_impl->pile_); |
40 | 42 |
41 layer_impl->SyncFromActiveLayer(); | 43 layer_impl->SyncFromActiveLayer(); |
42 } | 44 } |
43 | 45 |
44 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { | 46 void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) { |
45 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); | 47 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect); |
46 pending_invalidation_.Union(rect); | 48 pending_invalidation_.Union(rect); |
47 Layer::setNeedsDisplayRect(layer_rect); | 49 Layer::setNeedsDisplayRect(layer_rect); |
48 } | 50 } |
49 | 51 |
50 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, | 52 void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, |
51 RenderingStats& stats) { | 53 RenderingStats& stats) { |
52 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) | 54 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty()) |
53 return; | 55 return; |
54 | 56 |
55 pile_.Resize(bounds()); | 57 pile_.Resize(bounds()); |
56 | 58 |
57 // Calling paint in WebKit can sometimes cause invalidations, so save | 59 // Calling paint in WebKit can sometimes cause invalidations, so save |
58 // off the invalidation prior to calling update. | 60 // off the invalidation prior to calling update. |
59 pile_invalidation_.Swap(pending_invalidation_); | 61 pile_invalidation_.Swap(pending_invalidation_); |
60 pending_invalidation_.Clear(); | 62 pending_invalidation_.Clear(); |
61 | 63 |
62 pile_.Update(client_, pile_invalidation_, stats); | 64 pile_.Update(client_, pile_invalidation_, stats); |
63 } | 65 } |
64 | 66 |
| 67 void PictureLayer::setIsMask(bool is_mask) { |
| 68 is_mask_ = is_mask; |
| 69 } |
| 70 |
65 } // namespace cc | 71 } // namespace cc |
OLD | NEW |