blob: dd383a69b0e5097af3b05e0a256286f7d6d7208e [file] [log] [blame]
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +01001// Copyright 2013 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
5#include "cc/test/fake_picture_layer_impl.h"
6
7namespace cc {
8
9FakePictureLayerImpl::FakePictureLayerImpl(
10 LayerTreeImpl* tree_impl,
11 int id,
12 scoped_refptr<PicturePileImpl> pile)
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010013 : PictureLayerImpl(tree_impl, id),
14 append_quads_count_(0) {
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010015 pile_ = pile;
16 SetBounds(pile_->size());
Ben Murdochbb1529c2013-08-08 10:24:53 +010017 CreateTilingSetIfNeeded();
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010018}
19
20FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id)
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010021 : PictureLayerImpl(tree_impl, id), append_quads_count_(0) {}
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010022
23scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl(
24 LayerTreeImpl* tree_impl) {
25 return make_scoped_ptr(
26 new FakePictureLayerImpl(tree_impl, id())).PassAs<LayerImpl>();
27}
28
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010029void FakePictureLayerImpl::AppendQuads(QuadSink* quad_sink,
30 AppendQuadsData* append_quads_data) {
31 PictureLayerImpl::AppendQuads(quad_sink, append_quads_data);
32 ++append_quads_count_;
33}
34
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010035gfx::Size FakePictureLayerImpl::CalculateTileSize(
36 gfx::Size content_bounds) const {
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010037 if (fixed_tile_size_.IsEmpty()) {
38 return PictureLayerImpl::CalculateTileSize(content_bounds);
39 }
40
41 return fixed_tile_size_;
42}
43
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010044PictureLayerTiling* FakePictureLayerImpl::HighResTiling() const {
45 PictureLayerTiling* result = NULL;
46 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
47 PictureLayerTiling* tiling = tilings_->tiling_at(i);
48 if (tiling->resolution() == HIGH_RESOLUTION) {
49 // There should be only one high res tiling.
50 CHECK(!result);
51 result = tiling;
52 }
53 }
54 return result;
55}
56
57PictureLayerTiling* FakePictureLayerImpl::LowResTiling() const {
58 PictureLayerTiling* result = NULL;
59 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
60 PictureLayerTiling* tiling = tilings_->tiling_at(i);
61 if (tiling->resolution() == LOW_RESOLUTION) {
62 // There should be only one low res tiling.
63 CHECK(!result);
64 result = tiling;
65 }
66 }
67 return result;
68}
69
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010070} // namespace cc