blob: d00f54b74e87e549a9d583bfe36cda9550f5c6cb [file] [log] [blame]
[email protected]d98c0242012-11-08 06:22:351// 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]d98c0242012-11-08 06:22:355#include "cc/picture_layer.h"
[email protected]f117a4c2012-12-16 04:53:106
7#include "cc/layer_tree_impl.h"
[email protected]d98c0242012-11-08 06:22:358#include "cc/picture_layer_impl.h"
[email protected]3621e182012-11-09 22:37:099#include "ui/gfx/rect_conversions.h"
[email protected]d98c0242012-11-08 06:22:3510
11namespace cc {
12
13scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) {
14 return make_scoped_refptr(new PictureLayer(client));
15}
16
17PictureLayer::PictureLayer(ContentLayerClient* client) :
[email protected]f6776532012-12-21 20:24:3318 client_(client),
19 is_mask_(false) {
[email protected]d98c0242012-11-08 06:22:3520}
21
22PictureLayer::~PictureLayer() {
23}
24
25bool PictureLayer::drawsContent() const {
26 return Layer::drawsContent() && client_;
27}
28
[email protected]8bef40572012-12-11 21:38:0829scoped_ptr<LayerImpl> PictureLayer::createLayerImpl(LayerTreeImpl* treeImpl) {
30 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>();
[email protected]d98c0242012-11-08 06:22:3531}
32
[email protected]3621e182012-11-09 22:37:0933void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) {
[email protected]c96e8212012-11-27 22:48:0834 Layer::pushPropertiesTo(base_layer);
[email protected]f117a4c2012-12-16 04:53:1035
[email protected]3621e182012-11-09 22:37:0936 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
[email protected]f6776532012-12-21 20:24:3337 layer_impl->SetIsMask(is_mask_);
[email protected]f117a4c2012-12-16 04:53:1038 layer_impl->tilings_.SetLayerBounds(bounds());
39 layer_impl->invalidation_.Clear();
40 layer_impl->invalidation_.Swap(pile_invalidation_);
[email protected]3621e182012-11-09 22:37:0941 pile_.PushPropertiesTo(layer_impl->pile_);
42
[email protected]f117a4c2012-12-16 04:53:1043 layer_impl->SyncFromActiveLayer();
[email protected]3621e182012-11-09 22:37:0944}
45
46void PictureLayer::setNeedsDisplayRect(const gfx::RectF& layer_rect) {
47 gfx::Rect rect = gfx::ToEnclosedRect(layer_rect);
[email protected]0e630ea32012-11-28 03:29:1748 pending_invalidation_.Union(rect);
[email protected]0c4271a2012-11-30 01:40:3149 Layer::setNeedsDisplayRect(layer_rect);
[email protected]3621e182012-11-09 22:37:0950}
51
52void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
53 RenderingStats& stats) {
[email protected]0e630ea32012-11-28 03:29:1754 if (pile_.size() == bounds() && pending_invalidation_.IsEmpty())
55 return;
56
[email protected]3621e182012-11-09 22:37:0957 pile_.Resize(bounds());
[email protected]0e630ea32012-11-28 03:29:1758
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]d98c0242012-11-08 06:22:3565}
66
[email protected]f6776532012-12-21 20:24:3367void PictureLayer::setIsMask(bool is_mask) {
68 is_mask_ = is_mask;
69}
70
[email protected]d98c0242012-11-08 06:22:3571} // namespace cc