| 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/test/fake_picture_layer_tiling_client.h" | 5 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "cc/test/fake_tile_manager.h" | 9 #include "cc/test/fake_tile_manager.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 class FakeInfinitePicturePileImpl : public PicturePileImpl { | 13 class FakeInfinitePicturePileImpl : public PicturePileImpl { |
| 14 public: | 14 public: |
| 15 FakeInfinitePicturePileImpl() { | 15 FakeInfinitePicturePileImpl() { |
| 16 gfx::Size size(std::numeric_limits<int>::max(), | 16 gfx::Size size(std::numeric_limits<int>::max(), |
| 17 std::numeric_limits<int>::max()); | 17 std::numeric_limits<int>::max()); |
| 18 Resize(size); | 18 Resize(size); |
| 19 recorded_region_ = Region(gfx::Rect(size)); | 19 recorded_region_ = Region(gfx::Rect(size)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 protected: | 22 protected: |
| 23 virtual ~FakeInfinitePicturePileImpl() {} | 23 virtual ~FakeInfinitePicturePileImpl() {} |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 FakePictureLayerTilingClient::FakePictureLayerTilingClient() | 26 FakePictureLayerTilingClient::FakePictureLayerTilingClient() |
| 27 : tile_manager_(new FakeTileManager(&tile_manager_client_)), | 27 : tile_manager_(new FakeTileManager(&tile_manager_client_)), |
| 28 set_tile_manager_(NULL), |
| 28 pile_(new FakeInfinitePicturePileImpl()), | 29 pile_(new FakeInfinitePicturePileImpl()), |
| 29 twin_tiling_(NULL), | 30 twin_tiling_(NULL), |
| 30 allow_create_tile_(true) {} | 31 allow_create_tile_(true), |
| 32 is_active_(false), |
| 33 is_pending_(false), |
| 34 is_recycled_(false) {} |
| 31 | 35 |
| 32 FakePictureLayerTilingClient::FakePictureLayerTilingClient( | 36 FakePictureLayerTilingClient::FakePictureLayerTilingClient( |
| 33 ResourceProvider* resource_provider) | 37 ResourceProvider* resource_provider) |
| 34 : tile_manager_( | 38 : tile_manager_( |
| 35 new FakeTileManager(&tile_manager_client_, resource_provider)), | 39 new FakeTileManager(&tile_manager_client_, resource_provider)), |
| 40 set_tile_manager_(NULL), |
| 36 pile_(new FakeInfinitePicturePileImpl()), | 41 pile_(new FakeInfinitePicturePileImpl()), |
| 37 twin_tiling_(NULL), | 42 twin_tiling_(NULL), |
| 38 allow_create_tile_(true) {} | 43 allow_create_tile_(true), |
| 44 is_active_(false), |
| 45 is_pending_(false), |
| 46 is_recycled_(false) {} |
| 39 | 47 |
| 40 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() { | 48 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() { |
| 41 } | 49 } |
| 42 | 50 |
| 43 scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( | 51 scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( |
| 44 PictureLayerTiling*, | 52 PictureLayerTiling*, |
| 45 gfx::Rect rect) { | 53 gfx::Rect rect) { |
| 46 if (!allow_create_tile_) | 54 if (!allow_create_tile_) |
| 47 return scoped_refptr<Tile>(); | 55 return scoped_refptr<Tile>(); |
| 48 return tile_manager_->CreateTile( | 56 return tile_manager_->CreateTile( |
| 49 pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, true); | 57 pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, true); |
| 50 } | 58 } |
| 51 | 59 |
| 60 scoped_refptr<TileBundle> FakePictureLayerTilingClient::CreateTileBundle( |
| 61 int width, |
| 62 int height, |
| 63 int offset_x, |
| 64 int offset_y) { |
| 65 scoped_refptr<TileBundle> bundle = |
| 66 tile_manager_->CreateTileBundle(width, height, offset_x, offset_y); |
| 67 bundle->SetClient(this); |
| 68 return bundle; |
| 69 } |
| 70 |
| 52 void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { | 71 void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { |
| 53 tile_size_ = tile_size; | 72 tile_size_ = tile_size; |
| 54 } | 73 } |
| 55 | 74 |
| 56 gfx::Size FakePictureLayerTilingClient::CalculateTileSize( | 75 gfx::Size FakePictureLayerTilingClient::CalculateTileSize( |
| 57 gfx::Size /* content_bounds */) const { | 76 gfx::Size /* content_bounds */) const { |
| 58 return tile_size_; | 77 return tile_size_; |
| 59 } | 78 } |
| 60 | 79 |
| 61 const Region* FakePictureLayerTilingClient::GetInvalidation() { | 80 const Region* FakePictureLayerTilingClient::GetInvalidation() { |
| 62 return &invalidation_; | 81 return &invalidation_; |
| 63 } | 82 } |
| 64 | 83 |
| 65 const PictureLayerTiling* FakePictureLayerTilingClient::GetTwinTiling( | 84 const PictureLayerTiling* FakePictureLayerTilingClient::GetTwinTiling( |
| 66 const PictureLayerTiling* tiling) { | 85 const PictureLayerTiling* tiling) { |
| 67 return twin_tiling_; | 86 return twin_tiling_; |
| 68 } | 87 } |
| 69 | 88 |
| 70 } // namespace cc | 89 } // namespace cc |
| OLD | NEW |