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