Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1 | // 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 | |
| 7 | namespace cc { |
| 8 | |
| 9 | FakePictureLayerImpl::FakePictureLayerImpl( |
| 10 | LayerTreeImpl* tree_impl, |
| 11 | int id, |
| 12 | scoped_refptr<PicturePileImpl> pile) |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 13 | : PictureLayerImpl(tree_impl, id), |
| 14 | append_quads_count_(0) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 15 | pile_ = pile; |
| 16 | SetBounds(pile_->size()); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 17 | CreateTilingSetIfNeeded(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 21 | : PictureLayerImpl(tree_impl, id), append_quads_count_(0) {} |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 22 | |
| 23 | scoped_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) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 29 | void 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) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 35 | gfx::Size FakePictureLayerImpl::CalculateTileSize( |
| 36 | gfx::Size content_bounds) const { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 37 | if (fixed_tile_size_.IsEmpty()) { |
| 38 | return PictureLayerImpl::CalculateTileSize(content_bounds); |
| 39 | } |
| 40 | |
| 41 | return fixed_tile_size_; |
| 42 | } |
| 43 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 44 | PictureLayerTiling* 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 | |
| 57 | PictureLayerTiling* 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) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 70 | } // namespace cc |