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 <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
10 #include "cc/test/fake_rendering_stats_instrumentation.h" | 10 #include "cc/test/fake_rendering_stats_instrumentation.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
13 #include "ui/gfx/size_conversions.h" | 13 #include "ui/gfx/size_conversions.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class TestPicturePile : public PicturePile { | 18 class TestPicturePile : public PicturePile { |
19 public: | 19 public: |
20 using PicturePile::buffer_pixels; | 20 using PicturePile::buffer_pixels; |
21 using PicturePile::CanRasterSlowTileCheck; | |
22 using PicturePile::Clear; | |
21 | 23 |
22 PictureMap& picture_map() { return picture_map_; } | 24 PictureMap& picture_map() { return picture_map_; } |
23 | 25 |
26 bool CanRasterLayerRect(const gfx::Rect& layer_rect) { | |
27 return CanRaster(1.f, layer_rect); | |
28 } | |
29 | |
24 typedef PicturePile::PictureInfo PictureInfo; | 30 typedef PicturePile::PictureInfo PictureInfo; |
25 typedef PicturePile::PictureMapKey PictureMapKey; | 31 typedef PicturePile::PictureMapKey PictureMapKey; |
26 typedef PicturePile::PictureMap PictureMap; | 32 typedef PicturePile::PictureMap PictureMap; |
27 | 33 |
28 protected: | 34 protected: |
29 virtual ~TestPicturePile() {} | 35 virtual ~TestPicturePile() {} |
30 }; | 36 }; |
31 | 37 |
32 TEST(PicturePileTest, SmallInvalidateInflated) { | 38 class PicturePileTest : public testing::Test { |
33 FakeContentLayerClient client; | 39 public: |
34 FakeRenderingStatsInstrumentation stats_instrumentation; | 40 PicturePileTest() |
35 scoped_refptr<TestPicturePile> pile = new TestPicturePile; | 41 : pile_(new TestPicturePile()), |
36 SkColor background_color = SK_ColorBLUE; | 42 background_color_(SK_ColorBLUE), |
43 min_scale_(0.125), | |
44 frame_number_(0), | |
45 contents_opaque_(false) { | |
46 pile_->Resize(pile_->tiling().max_texture_size()); | |
47 pile_->SetTileGridSize(gfx::Size(1000, 1000)); | |
48 pile_->SetMinContentsScale(min_scale_); | |
49 } | |
37 | 50 |
38 float min_scale = 0.125; | 51 gfx::Rect layer_rect() const { return gfx::Rect(pile_->size()); } |
39 gfx::Size base_picture_size = pile->tiling().max_texture_size(); | |
40 | 52 |
41 gfx::Size layer_size = base_picture_size; | 53 bool Update(const Region& invalidation, const gfx::Rect& visible_layer_rect) { |
42 pile->Resize(layer_size); | 54 frame_number_++; |
43 pile->SetTileGridSize(gfx::Size(1000, 1000)); | 55 return pile_->Update(&client_, |
44 pile->SetMinContentsScale(min_scale); | 56 background_color_, |
57 contents_opaque_, | |
58 invalidation, | |
59 visible_layer_rect, | |
60 frame_number_, | |
61 &stats_instrumentation_); | |
62 } | |
45 | 63 |
46 // Update the whole layer. | 64 bool UpdateWholeLayer() { return Update(layer_rect(), layer_rect()); } |
47 pile->Update(&client, | 65 |
48 background_color, | 66 FakeContentLayerClient client_; |
49 false, | 67 FakeRenderingStatsInstrumentation stats_instrumentation_; |
50 gfx::Rect(layer_size), | 68 scoped_refptr<TestPicturePile> pile_; |
51 gfx::Rect(layer_size), | 69 SkColor background_color_; |
52 1, | 70 float min_scale_; |
53 &stats_instrumentation); | 71 int frame_number_; |
72 bool contents_opaque_; | |
73 }; | |
74 | |
75 TEST_F(PicturePileTest, SmallInvalidateInflated) { | |
76 UpdateWholeLayer(); | |
54 | 77 |
55 // Invalidate something inside a tile. | 78 // Invalidate something inside a tile. |
56 gfx::Rect invalidate_rect(50, 50, 1, 1); | 79 gfx::Rect invalidate_rect(50, 50, 1, 1); |
57 pile->Update(&client, | 80 Update(invalidate_rect, layer_rect()); |
58 background_color, | |
59 false, | |
60 invalidate_rect, | |
61 gfx::Rect(layer_size), | |
62 2, | |
63 &stats_instrumentation); | |
64 | 81 |
65 EXPECT_EQ(1, pile->tiling().num_tiles_x()); | 82 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); |
66 EXPECT_EQ(1, pile->tiling().num_tiles_y()); | 83 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); |
67 | 84 |
68 TestPicturePile::PictureInfo& picture_info = | 85 TestPicturePile::PictureInfo& picture_info = |
69 pile->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; | 86 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; |
70 // We should have a picture. | 87 // We should have a picture. |
71 EXPECT_TRUE(!!picture_info.GetPicture()); | 88 EXPECT_TRUE(!!picture_info.GetPicture()); |
72 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect( | 89 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect( |
73 picture_info.GetPicture()->LayerRect(), min_scale); | 90 picture_info.GetPicture()->LayerRect(), min_scale_); |
74 | 91 |
75 // The the picture should be large enough that scaling it never makes a rect | 92 // The the picture should be large enough that scaling it never makes a rect |
76 // smaller than 1 px wide or tall. | 93 // smaller than 1 px wide or tall. |
77 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " << | 94 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " << |
78 picture_rect.ToString(); | 95 picture_rect.ToString(); |
79 } | 96 } |
80 | 97 |
81 TEST(PicturePileTest, LargeInvalidateInflated) { | 98 TEST_F(PicturePileTest, LargeInvalidateInflated) { |
82 FakeContentLayerClient client; | 99 UpdateWholeLayer(); |
83 FakeRenderingStatsInstrumentation stats_instrumentation; | |
84 scoped_refptr<TestPicturePile> pile = new TestPicturePile; | |
85 SkColor background_color = SK_ColorBLUE; | |
86 | |
87 float min_scale = 0.125; | |
88 gfx::Size base_picture_size = pile->tiling().max_texture_size(); | |
89 | |
90 gfx::Size layer_size = base_picture_size; | |
91 pile->Resize(layer_size); | |
92 pile->SetTileGridSize(gfx::Size(1000, 1000)); | |
93 pile->SetMinContentsScale(min_scale); | |
94 | |
95 // Update the whole layer. | |
96 pile->Update(&client, | |
97 background_color, | |
98 false, | |
99 gfx::Rect(layer_size), | |
100 gfx::Rect(layer_size), | |
101 1, | |
102 &stats_instrumentation); | |
103 | 100 |
104 // Invalidate something inside a tile. | 101 // Invalidate something inside a tile. |
105 gfx::Rect invalidate_rect(50, 50, 100, 100); | 102 gfx::Rect invalidate_rect(50, 50, 100, 100); |
106 pile->Update(&client, | 103 Update(invalidate_rect, layer_rect()); |
107 background_color, | |
108 false, | |
109 invalidate_rect, | |
110 gfx::Rect(layer_size), | |
111 2, | |
112 &stats_instrumentation); | |
113 | 104 |
114 EXPECT_EQ(1, pile->tiling().num_tiles_x()); | 105 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); |
115 EXPECT_EQ(1, pile->tiling().num_tiles_y()); | 106 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); |
116 | 107 |
117 TestPicturePile::PictureInfo& picture_info = | 108 TestPicturePile::PictureInfo& picture_info = |
118 pile->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; | 109 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; |
119 EXPECT_TRUE(!!picture_info.GetPicture()); | 110 EXPECT_TRUE(!!picture_info.GetPicture()); |
120 | 111 |
121 int expected_inflation = pile->buffer_pixels(); | 112 int expected_inflation = pile_->buffer_pixels(); |
122 | 113 |
123 Picture* base_picture = picture_info.GetPicture(); | 114 Picture* base_picture = picture_info.GetPicture(); |
124 gfx::Rect base_picture_rect(layer_size); | 115 gfx::Rect base_picture_rect(pile_->size()); |
125 base_picture_rect.Inset(-expected_inflation, -expected_inflation); | 116 base_picture_rect.Inset(-expected_inflation, -expected_inflation); |
126 EXPECT_EQ(base_picture_rect.ToString(), | 117 EXPECT_EQ(base_picture_rect.ToString(), |
127 base_picture->LayerRect().ToString()); | 118 base_picture->LayerRect().ToString()); |
128 } | 119 } |
129 | 120 |
130 TEST(PicturePileTest, InvalidateOnTileBoundaryInflated) { | 121 TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) { |
131 FakeContentLayerClient client; | 122 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 2.f)); |
132 FakeRenderingStatsInstrumentation stats_instrumentation; | 123 pile_->Resize(layer_size); |
133 scoped_refptr<TestPicturePile> pile = new TestPicturePile; | |
134 SkColor background_color = SK_ColorBLUE; | |
135 | |
136 float min_scale = 0.125; | |
137 gfx::Size base_picture_size = pile->tiling().max_texture_size(); | |
138 | |
139 gfx::Size layer_size = | |
140 gfx::ToFlooredSize(gfx::ScaleSize(base_picture_size, 2.f)); | |
141 pile->Resize(layer_size); | |
142 pile->SetTileGridSize(gfx::Size(1000, 1000)); | |
143 pile->SetMinContentsScale(min_scale); | |
144 | 124 |
145 // Due to border pixels, we should have 3 tiles. | 125 // Due to border pixels, we should have 3 tiles. |
146 EXPECT_EQ(3, pile->tiling().num_tiles_x()); | 126 EXPECT_EQ(3, pile_->tiling().num_tiles_x()); |
147 EXPECT_EQ(3, pile->tiling().num_tiles_y()); | 127 EXPECT_EQ(3, pile_->tiling().num_tiles_y()); |
148 | 128 |
149 // We should have 1/.125 - 1 = 7 border pixels. | 129 // We should have 1/.125 - 1 = 7 border pixels. |
150 EXPECT_EQ(7, pile->buffer_pixels()); | 130 EXPECT_EQ(7, pile_->buffer_pixels()); |
151 EXPECT_EQ(7, pile->tiling().border_texels()); | 131 EXPECT_EQ(7, pile_->tiling().border_texels()); |
152 | 132 |
153 // Update the whole layer to create initial pictures. | 133 // Update the whole layer to create initial pictures. |
154 pile->Update(&client, | 134 UpdateWholeLayer(); |
155 background_color, | |
156 false, | |
157 gfx::Rect(layer_size), | |
158 gfx::Rect(layer_size), | |
159 0, | |
160 &stats_instrumentation); | |
161 | 135 |
162 // Invalidate everything again to have a non zero invalidation | 136 // Invalidate everything again to have a non zero invalidation |
163 // frequency. | 137 // frequency. |
164 pile->Update(&client, | 138 UpdateWholeLayer(); |
165 background_color, | |
166 false, | |
167 gfx::Rect(layer_size), | |
168 gfx::Rect(layer_size), | |
169 1, | |
170 &stats_instrumentation); | |
171 | 139 |
172 // Invalidate something just over a tile boundary by a single pixel. | 140 // Invalidate something just over a tile boundary by a single pixel. |
173 // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0). | 141 // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0). |
174 gfx::Rect invalidate_rect( | 142 gfx::Rect invalidate_rect( |
175 pile->tiling().TileBoundsWithBorder(0, 0).right(), | 143 pile_->tiling().TileBoundsWithBorder(0, 0).right(), |
176 pile->tiling().TileBoundsWithBorder(0, 0).bottom() - 1, | 144 pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1, |
177 50, | 145 50, |
178 50); | 146 50); |
179 pile->Update(&client, | 147 Update(invalidate_rect, layer_rect()); |
180 background_color, | |
181 false, | |
182 invalidate_rect, | |
183 gfx::Rect(layer_size), | |
184 2, | |
185 &stats_instrumentation); | |
186 | 148 |
187 for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) { | 149 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
188 for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) { | 150 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
189 TestPicturePile::PictureInfo& picture_info = | 151 TestPicturePile::PictureInfo& picture_info = |
190 pile->picture_map().find( | 152 pile_->picture_map() |
191 TestPicturePile::PictureMapKey(i, j))->second; | 153 .find(TestPicturePile::PictureMapKey(i, j)) |
154 ->second; | |
192 | 155 |
193 // Expect (1, 1) and (1, 0) to be invalidated once more | 156 // Expect (1, 1) and (1, 0) to be invalidated once more |
194 // than the rest of the tiles. | 157 // than the rest of the tiles. |
195 if (i == 1 && (j == 0 || j == 1)) { | 158 if (i == 1 && (j == 0 || j == 1)) { |
196 EXPECT_FLOAT_EQ( | 159 EXPECT_FLOAT_EQ( |
197 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 160 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
198 picture_info.GetInvalidationFrequencyForTesting()); | 161 picture_info.GetInvalidationFrequencyForTesting()); |
199 } else { | 162 } else { |
200 EXPECT_FLOAT_EQ( | 163 EXPECT_FLOAT_EQ( |
201 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 164 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
202 picture_info.GetInvalidationFrequencyForTesting()); | 165 picture_info.GetInvalidationFrequencyForTesting()); |
203 } | 166 } |
204 } | 167 } |
205 } | 168 } |
206 } | 169 } |
207 | 170 |
208 TEST(PicturePileTest, StopRecordingOffscreenInvalidations) { | 171 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { |
209 FakeContentLayerClient client; | 172 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 4.f)); |
210 FakeRenderingStatsInstrumentation stats_instrumentation; | 173 pile_->Resize(layer_size); |
211 scoped_refptr<TestPicturePile> pile = new TestPicturePile; | |
212 SkColor background_color = SK_ColorBLUE; | |
213 | |
214 float min_scale = 0.125; | |
215 gfx::Size base_picture_size = pile->tiling().max_texture_size(); | |
216 | |
217 gfx::Size layer_size = | |
218 gfx::ToFlooredSize(gfx::ScaleSize(base_picture_size, 4.f)); | |
219 pile->Resize(layer_size); | |
220 pile->SetTileGridSize(gfx::Size(1000, 1000)); | |
221 pile->SetMinContentsScale(min_scale); | |
222 | 174 |
223 gfx::Rect viewport(0, 0, layer_size.width(), 1); | 175 gfx::Rect viewport(0, 0, layer_size.width(), 1); |
224 | 176 |
225 // Update the whole layer until the invalidation frequency is high. | 177 // Update the whole layer until the invalidation frequency is high. |
226 int frame; | 178 for (int frame = 0; frame < 33; ++frame) { |
227 for (frame = 0; frame < 33; ++frame) { | 179 UpdateWholeLayer(); |
228 pile->Update(&client, | |
229 background_color, | |
230 false, | |
231 gfx::Rect(layer_size), | |
232 viewport, | |
233 frame, | |
234 &stats_instrumentation); | |
235 } | 180 } |
236 | 181 |
237 // Make sure we have a high invalidation frequency. | 182 // Make sure we have a high invalidation frequency. |
238 for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) { | 183 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
239 for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) { | 184 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
240 TestPicturePile::PictureInfo& picture_info = | 185 TestPicturePile::PictureInfo& picture_info = |
241 pile->picture_map().find( | 186 pile_->picture_map() |
242 TestPicturePile::PictureMapKey(i, j))->second; | 187 .find(TestPicturePile::PictureMapKey(i, j)) |
188 ->second; | |
243 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) | 189 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) |
244 << "i " << i << " j " << j; | 190 << "i " << i << " j " << j; |
245 } | 191 } |
246 } | 192 } |
247 | 193 |
248 // Update once more with a small viewport 0,0 layer_width by 1 | 194 // Update once more with a small viewport 0,0 layer_width by 1 |
249 pile->Update(&client, | 195 Update(layer_rect(), viewport); |
250 background_color, | |
251 false, | |
252 gfx::Rect(layer_size), | |
253 viewport, | |
254 frame, | |
255 &stats_instrumentation); | |
256 | 196 |
257 for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) { | 197 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
258 for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) { | 198 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
259 TestPicturePile::PictureInfo& picture_info = | 199 TestPicturePile::PictureInfo& picture_info = |
260 pile->picture_map().find( | 200 pile_->picture_map() |
261 TestPicturePile::PictureMapKey(i, j))->second; | 201 .find(TestPicturePile::PictureMapKey(i, j)) |
202 ->second; | |
262 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); | 203 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); |
263 | 204 |
264 // If the y far enough away we expect to find no picture (no re-recording | 205 // If the y far enough away we expect to find no picture (no re-recording |
265 // happened). For close y, the picture should change. | 206 // happened). For close y, the picture should change. |
266 if (j >= 2) | 207 if (j >= 2) |
267 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; | 208 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; |
268 else | 209 else |
269 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; | 210 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; |
270 } | 211 } |
271 } | 212 } |
272 | 213 |
273 // Now update with no invalidation and full viewport | 214 // Now update with no invalidation and full viewport |
274 pile->Update(&client, | 215 Update(gfx::Rect(), layer_rect()); |
275 background_color, | |
276 false, | |
277 gfx::Rect(), | |
278 gfx::Rect(layer_size), | |
279 frame+1, | |
280 &stats_instrumentation); | |
281 | 216 |
282 for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) { | 217 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { |
283 for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) { | 218 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { |
284 TestPicturePile::PictureInfo& picture_info = | 219 TestPicturePile::PictureInfo& picture_info = |
285 pile->picture_map().find( | 220 pile_->picture_map() |
286 TestPicturePile::PictureMapKey(i, j))->second; | 221 .find(TestPicturePile::PictureMapKey(i, j)) |
222 ->second; | |
287 // Expect the invalidation frequency to be less than 1, since we just | 223 // Expect the invalidation frequency to be less than 1, since we just |
288 // updated with no invalidations. | 224 // updated with no invalidations. |
289 float expected_frequency = | 225 float expected_frequency = |
290 1.0f - | 226 1.0f - |
291 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED; | 227 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED; |
292 | 228 |
293 EXPECT_FLOAT_EQ(expected_frequency, | 229 EXPECT_FLOAT_EQ(expected_frequency, |
294 picture_info.GetInvalidationFrequencyForTesting()); | 230 picture_info.GetInvalidationFrequencyForTesting()); |
295 | 231 |
296 // We expect that there are pictures everywhere now. | 232 // We expect that there are pictures everywhere now. |
297 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; | 233 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; |
298 } | 234 } |
299 } | 235 } |
300 } | 236 } |
301 | 237 |
238 TEST_F(PicturePileTest, ClearingInvalidatesRecordedRect) { | |
239 UpdateWholeLayer(); | |
240 | |
241 gfx::Rect rect(0, 0, 5, 5); | |
242 EXPECT_TRUE(pile_->CanRasterLayerRect(rect)); | |
243 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(rect)); | |
244 | |
245 pile_->Clear(); | |
246 | |
247 // Make sure both the cache-aware check (using recorded region) and the normal | |
248 // check are both false after clearing. | |
249 EXPECT_FALSE(pile_->CanRasterLayerRect(rect)); | |
250 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(rect)); | |
251 } | |
252 | |
253 TEST_F(PicturePileTest, FrequentInvalidationCanRaster) { | |
254 // This test makes sure that if part of the page is frequently invalidated | |
255 // and doesn't get re-recorded, then CanRaster is not true for any | |
256 // tiles touching it, but is true for adjacent tiles, even if it | |
257 // overlaps on borders (edge case). | |
258 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 4.f)); | |
259 pile_->Resize(layer_size); | |
260 | |
261 gfx::Rect tile01_borders = pile_->tiling().TileBoundsWithBorder(0, 1); | |
262 gfx::Rect tile02_borders = pile_->tiling().TileBoundsWithBorder(0, 2); | |
263 gfx::Rect tile01_noborders = pile_->tiling().TileBounds(0, 1); | |
264 gfx::Rect tile02_noborders = pile_->tiling().TileBounds(0, 2); | |
265 | |
266 // Sanity check these two tiles are overlapping with borders, since this is | |
267 // what the test is trying to repro. | |
268 EXPECT_TRUE(tile01_borders.Intersects(tile02_borders)); | |
269 EXPECT_FALSE(tile01_noborders.Intersects(tile02_noborders)); | |
270 UpdateWholeLayer(); | |
271 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders)); | |
272 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders)); | |
273 EXPECT_TRUE(pile_->CanRasterLayerRect(tile02_noborders)); | |
274 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile02_noborders)); | |
275 | |
276 // Update the whole layer until the invalidation frequency is high. | |
277 for (int frame = 0; frame < 33; ++frame) { | |
278 UpdateWholeLayer(); | |
279 } | |
280 | |
281 // Update once more with a small viewport. | |
282 gfx::Rect viewport(0, 0, layer_size.width(), 1); | |
283 Update(layer_rect(), viewport); | |
284 | |
285 // Sanity check some pictures exist and others don't. | |
286 EXPECT_TRUE(pile_->picture_map() | |
287 .find(TestPicturePile::PictureMapKey(0, 1)) | |
288 ->second.GetPicture()); | |
289 EXPECT_FALSE(pile_->picture_map() | |
290 .find(TestPicturePile::PictureMapKey(0, 2)) | |
291 ->second.GetPicture()); | |
292 | |
293 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders)); | |
294 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders)); | |
295 EXPECT_FALSE(pile_->CanRasterLayerRect(tile02_noborders)); | |
enne (OOO)
2014/03/18 00:55:20
I'm not sure if there's a better way to clean this
| |
296 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(tile02_noborders)); | |
297 } | |
298 | |
302 } // namespace | 299 } // namespace |
303 } // namespace cc | 300 } // namespace cc |
OLD | NEW |