OLD | NEW |
(Empty) | |
| 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_pile_impl.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "cc/test/impl_side_painting_settings.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 FakePicturePileImpl::FakePicturePileImpl() |
| 15 : PicturePileImpl(false) {} |
| 16 |
| 17 FakePicturePileImpl::~FakePicturePileImpl() {} |
| 18 |
| 19 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( |
| 20 gfx::Size tile_size, |
| 21 gfx::Size layer_bounds) { |
| 22 scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl()); |
| 23 pile->tiling().SetTotalSize(layer_bounds); |
| 24 pile->tiling().SetMaxTextureSize(tile_size); |
| 25 pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); |
| 26 for (int x = 0; x < pile->tiling().num_tiles_x(); ++x) { |
| 27 for (int y = 0; y < pile->tiling().num_tiles_y(); ++y) |
| 28 pile->AddRecordingAt(x, y); |
| 29 } |
| 30 pile->UpdateRecordedRegion(); |
| 31 return pile; |
| 32 } |
| 33 |
| 34 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile( |
| 35 gfx::Size tile_size, |
| 36 gfx::Size layer_bounds) { |
| 37 scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl()); |
| 38 pile->tiling().SetTotalSize(layer_bounds); |
| 39 pile->tiling().SetMaxTextureSize(tile_size); |
| 40 pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); |
| 41 pile->UpdateRecordedRegion(); |
| 42 return pile; |
| 43 } |
| 44 |
| 45 void FakePicturePileImpl::AddRecordingAt(int x, int y) { |
| 46 EXPECT_GE(x, 0); |
| 47 EXPECT_GE(y, 0); |
| 48 EXPECT_LT(x, tiling_.num_tiles_x()); |
| 49 EXPECT_LT(y, tiling_.num_tiles_y()); |
| 50 |
| 51 if (HasRecordingAt(x, y)) |
| 52 return; |
| 53 gfx::Rect bounds(tiling().TileBounds(x, y)); |
| 54 scoped_refptr<Picture> picture(Picture::Create(bounds)); |
| 55 picture->Record(&client_, NULL, tile_grid_info_); |
| 56 picture_list_map_[std::pair<int, int>(x, y)].push_back(picture); |
| 57 EXPECT_TRUE(HasRecordingAt(x, y)); |
| 58 |
| 59 UpdateRecordedRegion(); |
| 60 } |
| 61 |
| 62 void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { |
| 63 EXPECT_GE(x, 0); |
| 64 EXPECT_GE(y, 0); |
| 65 EXPECT_LT(x, tiling_.num_tiles_x()); |
| 66 EXPECT_LT(y, tiling_.num_tiles_y()); |
| 67 |
| 68 if (!HasRecordingAt(x, y)) |
| 69 return; |
| 70 picture_list_map_.erase(std::pair<int, int>(x, y)); |
| 71 EXPECT_FALSE(HasRecordingAt(x, y)); |
| 72 |
| 73 UpdateRecordedRegion(); |
| 74 } |
| 75 |
| 76 } // namespace cc |
OLD | NEW |