| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_pile_impl.h" | 5 #include "cc/test/fake_picture_pile_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "cc/resources/picture_pile.h" | 11 #include "cc/resources/picture_pile.h" |
| 12 #include "cc/test/fake_picture_pile.h" |
| 12 #include "cc/test/impl_side_painting_settings.h" | 13 #include "cc/test/impl_side_painting_settings.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 FakePicturePileImpl::FakePicturePileImpl() {} | 18 FakePicturePileImpl::FakePicturePileImpl() {} |
| 18 | 19 |
| 19 FakePicturePileImpl::FakePicturePileImpl(const PicturePileBase* other) | 20 FakePicturePileImpl::FakePicturePileImpl(const PicturePile* other) |
| 20 : PicturePileImpl(other), | 21 : PicturePileImpl(other), |
| 21 tile_grid_info_(other->GetTileGridInfoForTesting()) { | 22 tile_grid_info_(other->GetTileGridInfoForTesting()) { |
| 22 } | 23 } |
| 23 | 24 |
| 24 FakePicturePileImpl::~FakePicturePileImpl() {} | 25 FakePicturePileImpl::~FakePicturePileImpl() {} |
| 25 | 26 |
| 26 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( | 27 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( |
| 27 const gfx::Size& tile_size, | 28 const gfx::Size& tile_size, |
| 28 const gfx::Size& layer_bounds) { | 29 const gfx::Size& layer_bounds) { |
| 29 PicturePile pile; | 30 FakePicturePile pile; |
| 30 pile.tiling().SetTilingSize(layer_bounds); | 31 pile.tiling().SetTilingSize(layer_bounds); |
| 31 pile.tiling().SetMaxTextureSize(tile_size); | 32 pile.tiling().SetMaxTextureSize(tile_size); |
| 32 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); | 33 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); |
| 33 pile.SetRecordedViewportForTesting(gfx::Rect(layer_bounds)); | 34 pile.SetRecordedViewport(gfx::Rect(layer_bounds)); |
| 34 pile.SetHasAnyRecordingsForTesting(true); | 35 pile.SetHasAnyRecordings(true); |
| 35 | 36 |
| 36 auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile)); | 37 auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile)); |
| 37 for (int x = 0; x < pile_impl->tiling().num_tiles_x(); ++x) { | 38 for (int x = 0; x < pile_impl->tiling().num_tiles_x(); ++x) { |
| 38 for (int y = 0; y < pile_impl->tiling().num_tiles_y(); ++y) | 39 for (int y = 0; y < pile_impl->tiling().num_tiles_y(); ++y) |
| 39 pile_impl->AddRecordingAt(x, y); | 40 pile_impl->AddRecordingAt(x, y); |
| 40 } | 41 } |
| 41 return pile_impl; | 42 return pile_impl; |
| 42 } | 43 } |
| 43 | 44 |
| 44 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile( | 45 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile( |
| 45 const gfx::Size& tile_size, | 46 const gfx::Size& tile_size, |
| 46 const gfx::Size& layer_bounds) { | 47 const gfx::Size& layer_bounds) { |
| 47 PicturePile pile; | 48 FakePicturePile pile; |
| 48 pile.tiling().SetTilingSize(layer_bounds); | 49 pile.tiling().SetTilingSize(layer_bounds); |
| 49 pile.tiling().SetMaxTextureSize(tile_size); | 50 pile.tiling().SetMaxTextureSize(tile_size); |
| 50 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); | 51 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); |
| 51 pile.SetRecordedViewportForTesting(gfx::Rect()); | 52 pile.SetRecordedViewport(gfx::Rect()); |
| 52 pile.SetHasAnyRecordingsForTesting(false); | 53 pile.SetHasAnyRecordings(false); |
| 53 return make_scoped_refptr(new FakePicturePileImpl(&pile)); | 54 return make_scoped_refptr(new FakePicturePileImpl(&pile)); |
| 54 } | 55 } |
| 55 | 56 |
| 56 scoped_refptr<FakePicturePileImpl> | 57 scoped_refptr<FakePicturePileImpl> |
| 57 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 58 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
| 58 const gfx::Size& tile_size, | 59 const gfx::Size& tile_size, |
| 59 const gfx::Size& layer_bounds) { | 60 const gfx::Size& layer_bounds) { |
| 60 PicturePile pile; | 61 FakePicturePile pile; |
| 61 pile.tiling().SetTilingSize(layer_bounds); | 62 pile.tiling().SetTilingSize(layer_bounds); |
| 62 pile.tiling().SetMaxTextureSize(tile_size); | 63 pile.tiling().SetMaxTextureSize(tile_size); |
| 63 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); | 64 pile.SetTileGridSize(ImplSidePaintingSettings().default_tile_grid_size); |
| 64 // This simulates a false positive for this flag. | 65 // This simulates a false positive for this flag. |
| 65 pile.SetRecordedViewportForTesting(gfx::Rect()); | 66 pile.SetRecordedViewport(gfx::Rect()); |
| 66 pile.SetHasAnyRecordingsForTesting(true); | 67 pile.SetHasAnyRecordings(true); |
| 67 return make_scoped_refptr(new FakePicturePileImpl(&pile)); | 68 return make_scoped_refptr(new FakePicturePileImpl(&pile)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 scoped_refptr<FakePicturePileImpl> | 71 scoped_refptr<FakePicturePileImpl> |
| 71 FakePicturePileImpl::CreateInfiniteFilledPile() { | 72 FakePicturePileImpl::CreateInfiniteFilledPile() { |
| 72 PicturePile pile; | 73 FakePicturePile pile; |
| 73 gfx::Size size(std::numeric_limits<int>::max(), | 74 gfx::Size size(std::numeric_limits<int>::max(), |
| 74 std::numeric_limits<int>::max()); | 75 std::numeric_limits<int>::max()); |
| 75 pile.tiling().SetTilingSize(size); | 76 pile.tiling().SetTilingSize(size); |
| 76 pile.tiling().SetMaxTextureSize(size); | 77 pile.tiling().SetMaxTextureSize(size); |
| 77 pile.SetTileGridSize(size); | 78 pile.SetTileGridSize(size); |
| 78 pile.SetRecordedViewportForTesting(gfx::Rect(size)); | 79 pile.SetRecordedViewport(gfx::Rect(size)); |
| 79 pile.SetHasAnyRecordingsForTesting(true); | 80 pile.SetHasAnyRecordings(true); |
| 80 | 81 |
| 81 auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile)); | 82 auto pile_impl = make_scoped_refptr(new FakePicturePileImpl(&pile)); |
| 82 pile_impl->AddRecordingAt(0, 0); | 83 pile_impl->AddRecordingAt(0, 0); |
| 83 return pile_impl; | 84 return pile_impl; |
| 84 } | 85 } |
| 85 | 86 |
| 86 void FakePicturePileImpl::AddRecordingAt(int x, int y) { | 87 void FakePicturePileImpl::AddRecordingAt(int x, int y) { |
| 87 EXPECT_GE(x, 0); | 88 EXPECT_GE(x, 0); |
| 88 EXPECT_GE(y, 0); | 89 EXPECT_GE(y, 0); |
| 89 EXPECT_LT(x, tiling_.num_tiles_x()); | 90 EXPECT_LT(x, tiling_.num_tiles_x()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 Clear(); | 158 Clear(); |
| 158 tiling_.SetBorderTexels(new_buffer_pixels); | 159 tiling_.SetBorderTexels(new_buffer_pixels); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void FakePicturePileImpl::Clear() { | 162 void FakePicturePileImpl::Clear() { |
| 162 picture_map_.clear(); | 163 picture_map_.clear(); |
| 163 recorded_viewport_ = gfx::Rect(); | 164 recorded_viewport_ = gfx::Rect(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace cc | 167 } // namespace cc |
| OLD | NEW |