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