| 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) {} |
| 31 | 34 |
| 32 FakePictureLayerTilingClient::FakePictureLayerTilingClient( | 35 FakePictureLayerTilingClient::FakePictureLayerTilingClient( |
| 33 ResourceProvider* resource_provider) | 36 ResourceProvider* resource_provider) |
| 34 : tile_manager_( | 37 : tile_manager_( |
| 35 new FakeTileManager(&tile_manager_client_, resource_provider)), | 38 new FakeTileManager(&tile_manager_client_, resource_provider)), |
| 39 set_tile_manager_(NULL), |
| 36 pile_(new FakeInfinitePicturePileImpl()), | 40 pile_(new FakeInfinitePicturePileImpl()), |
| 37 twin_tiling_(NULL), | 41 twin_tiling_(NULL), |
| 38 allow_create_tile_(true) {} | 42 allow_create_tile_(true), |
| 43 is_active_(false), |
| 44 is_pending_(false) {} |
| 39 | 45 |
| 40 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() { | 46 FakePictureLayerTilingClient::~FakePictureLayerTilingClient() { |
| 41 } | 47 } |
| 42 | 48 |
| 43 scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( | 49 scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile( |
| 44 PictureLayerTiling*, | 50 PictureLayerTiling*, |
| 45 gfx::Rect rect) { | 51 gfx::Rect rect) { |
| 46 if (!allow_create_tile_) | 52 if (!allow_create_tile_) |
| 47 return scoped_refptr<Tile>(); | 53 return scoped_refptr<Tile>(); |
| 48 return tile_manager_->CreateTile( | 54 return tile_manager()->CreateTile( |
| 49 pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, true); | 55 pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, true); |
| 50 } | 56 } |
| 51 | 57 |
| 58 scoped_refptr<TileBundle> FakePictureLayerTilingClient::CreateTileBundle( |
| 59 int width, |
| 60 int height, |
| 61 int offset_x, |
| 62 int offset_y) { |
| 63 return tile_manager()->CreateTileBundle(width, height, offset_x, offset_y); |
| 64 } |
| 65 |
| 52 void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { | 66 void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) { |
| 53 tile_size_ = tile_size; | 67 tile_size_ = tile_size; |
| 54 } | 68 } |
| 55 | 69 |
| 56 gfx::Size FakePictureLayerTilingClient::CalculateTileSize( | 70 gfx::Size FakePictureLayerTilingClient::CalculateTileSize( |
| 57 gfx::Size /* content_bounds */) const { | 71 gfx::Size /* content_bounds */) const { |
| 58 return tile_size_; | 72 return tile_size_; |
| 59 } | 73 } |
| 60 | 74 |
| 61 const Region* FakePictureLayerTilingClient::GetInvalidation() { | 75 const Region* FakePictureLayerTilingClient::GetInvalidation() { |
| 62 return &invalidation_; | 76 return &invalidation_; |
| 63 } | 77 } |
| 64 | 78 |
| 65 const PictureLayerTiling* FakePictureLayerTilingClient::GetTwinTiling( | 79 const PictureLayerTiling* FakePictureLayerTilingClient::GetTwinTiling( |
| 66 const PictureLayerTiling* tiling) { | 80 const PictureLayerTiling* tiling) { |
| 67 return twin_tiling_; | 81 return twin_tiling_; |
| 68 } | 82 } |
| 69 | 83 |
| 70 } // namespace cc | 84 } // namespace cc |
| OLD | NEW |