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 "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "cc/resources/picture_pile.h" | 12 #include "cc/resources/picture_pile.h" |
13 #include "cc/test/fake_picture_pile.h" | 13 #include "cc/test/fake_picture_pile.h" |
14 #include "cc/test/impl_side_painting_settings.h" | 14 #include "cc/test/impl_side_painting_settings.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 FakePicturePileImpl::FakePicturePileImpl() : playback_allowed_event_(nullptr) { | 19 FakePicturePileImpl::FakePicturePileImpl() : playback_allowed_event_(nullptr) { |
20 } | 20 } |
21 | 21 |
22 FakePicturePileImpl::FakePicturePileImpl( | 22 FakePicturePileImpl::FakePicturePileImpl( |
23 const PicturePile* other, | 23 const PicturePile* other, |
24 base::WaitableEvent* playback_allowed_event) | 24 base::WaitableEvent* playback_allowed_event) |
25 : PicturePileImpl(other), | 25 : PicturePileImpl(other), |
26 playback_allowed_event_(playback_allowed_event), | 26 playback_allowed_event_(playback_allowed_event), |
27 tile_grid_info_(other->GetTileGridInfoForTesting()) { | 27 tile_grid_size_(other->GetTileGridSizeForTesting()) { |
28 } | 28 } |
29 | 29 |
30 FakePicturePileImpl::~FakePicturePileImpl() {} | 30 FakePicturePileImpl::~FakePicturePileImpl() {} |
31 | 31 |
32 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( | 32 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( |
33 const gfx::Size& tile_size, | 33 const gfx::Size& tile_size, |
34 const gfx::Size& layer_bounds) { | 34 const gfx::Size& layer_bounds) { |
35 FakePicturePile pile; | 35 FakePicturePile pile; |
36 pile.tiling().SetTilingSize(layer_bounds); | 36 pile.tiling().SetTilingSize(layer_bounds); |
37 pile.tiling().SetMaxTextureSize(tile_size); | 37 pile.tiling().SetMaxTextureSize(tile_size); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 EXPECT_GE(y, 0); | 111 EXPECT_GE(y, 0); |
112 EXPECT_LT(x, tiling_.num_tiles_x()); | 112 EXPECT_LT(x, tiling_.num_tiles_x()); |
113 EXPECT_LT(y, tiling_.num_tiles_y()); | 113 EXPECT_LT(y, tiling_.num_tiles_y()); |
114 | 114 |
115 if (HasRecordingAt(x, y)) | 115 if (HasRecordingAt(x, y)) |
116 return; | 116 return; |
117 gfx::Rect bounds(tiling().TileBounds(x, y)); | 117 gfx::Rect bounds(tiling().TileBounds(x, y)); |
118 bounds.Inset(-buffer_pixels(), -buffer_pixels()); | 118 bounds.Inset(-buffer_pixels(), -buffer_pixels()); |
119 | 119 |
120 scoped_refptr<Picture> picture(Picture::Create( | 120 scoped_refptr<Picture> picture(Picture::Create( |
121 bounds, &client_, tile_grid_info_, true, Picture::RECORD_NORMALLY)); | 121 bounds, &client_, tile_grid_size_, true, Picture::RECORD_NORMALLY)); |
122 picture_map_[std::pair<int, int>(x, y)].SetPicture(picture); | 122 picture_map_[std::pair<int, int>(x, y)].SetPicture(picture); |
123 EXPECT_TRUE(HasRecordingAt(x, y)); | 123 EXPECT_TRUE(HasRecordingAt(x, y)); |
124 | 124 |
125 has_any_recordings_ = true; | 125 has_any_recordings_ = true; |
126 } | 126 } |
127 | 127 |
128 void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { | 128 void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { |
129 EXPECT_GE(x, 0); | 129 EXPECT_GE(x, 0); |
130 EXPECT_GE(y, 0); | 130 EXPECT_GE(y, 0); |
131 EXPECT_LT(x, tiling_.num_tiles_x()); | 131 EXPECT_LT(x, tiling_.num_tiles_x()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 Clear(); | 180 Clear(); |
181 tiling_.SetBorderTexels(new_buffer_pixels); | 181 tiling_.SetBorderTexels(new_buffer_pixels); |
182 } | 182 } |
183 | 183 |
184 void FakePicturePileImpl::Clear() { | 184 void FakePicturePileImpl::Clear() { |
185 picture_map_.clear(); | 185 picture_map_.clear(); |
186 recorded_viewport_ = gfx::Rect(); | 186 recorded_viewport_ = gfx::Rect(); |
187 } | 187 } |
188 | 188 |
189 } // namespace cc | 189 } // namespace cc |
OLD | NEW |