Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: cc/resources/picture_pile_unittest.cc

Issue 235753002: cc: Give TilingData a Rect instead of a Size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 26 matching lines...) Expand all
37 }; 37 };
38 38
39 class PicturePileTest : public testing::Test { 39 class PicturePileTest : public testing::Test {
40 public: 40 public:
41 PicturePileTest() 41 PicturePileTest()
42 : pile_(new TestPicturePile()), 42 : pile_(new TestPicturePile()),
43 background_color_(SK_ColorBLUE), 43 background_color_(SK_ColorBLUE),
44 min_scale_(0.125), 44 min_scale_(0.125),
45 frame_number_(0), 45 frame_number_(0),
46 contents_opaque_(false) { 46 contents_opaque_(false) {
47 pile_->Resize(pile_->tiling().max_texture_size()); 47 pile_->SetTilingRect(gfx::Rect(pile_->tiling().max_texture_size()));
48 pile_->SetTileGridSize(gfx::Size(1000, 1000)); 48 pile_->SetTileGridSize(gfx::Size(1000, 1000));
49 pile_->SetMinContentsScale(min_scale_); 49 pile_->SetMinContentsScale(min_scale_);
50 } 50 }
51 51
52 gfx::Rect layer_rect() const { return gfx::Rect(pile_->size()); } 52 gfx::Rect tiling_rect() const { return pile_->tiling_rect(); }
53 53
54 bool Update(const Region& invalidation, const gfx::Rect& visible_layer_rect) { 54 bool Update(const Region& invalidation, const gfx::Rect& visible_layer_rect) {
55 frame_number_++; 55 frame_number_++;
56 return pile_->Update(&client_, 56 return pile_->Update(&client_,
57 background_color_, 57 background_color_,
58 contents_opaque_, 58 contents_opaque_,
59 false, 59 false,
60 invalidation, 60 invalidation,
61 visible_layer_rect, 61 visible_layer_rect,
62 frame_number_, 62 frame_number_,
63 &stats_instrumentation_); 63 &stats_instrumentation_);
64 } 64 }
65 65
66 bool UpdateWholeLayer() { return Update(layer_rect(), layer_rect()); } 66 bool UpdateWholePile() { return Update(tiling_rect(), tiling_rect()); }
67 67
68 FakeContentLayerClient client_; 68 FakeContentLayerClient client_;
69 FakeRenderingStatsInstrumentation stats_instrumentation_; 69 FakeRenderingStatsInstrumentation stats_instrumentation_;
70 scoped_refptr<TestPicturePile> pile_; 70 scoped_refptr<TestPicturePile> pile_;
71 SkColor background_color_; 71 SkColor background_color_;
72 float min_scale_; 72 float min_scale_;
73 int frame_number_; 73 int frame_number_;
74 bool contents_opaque_; 74 bool contents_opaque_;
75 }; 75 };
76 76
77 TEST_F(PicturePileTest, SmallInvalidateInflated) { 77 TEST_F(PicturePileTest, SmallInvalidateInflated) {
78 UpdateWholeLayer(); 78 UpdateWholePile();
79 79
80 // Invalidate something inside a tile. 80 // Invalidate something inside a tile.
81 gfx::Rect invalidate_rect(50, 50, 1, 1); 81 gfx::Rect invalidate_rect(50, 50, 1, 1);
82 Update(invalidate_rect, layer_rect()); 82 Update(invalidate_rect, tiling_rect());
83 83
84 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); 84 EXPECT_EQ(1, pile_->tiling().num_tiles_x());
85 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); 85 EXPECT_EQ(1, pile_->tiling().num_tiles_y());
86 86
87 TestPicturePile::PictureInfo& picture_info = 87 TestPicturePile::PictureInfo& picture_info =
88 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; 88 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second;
89 // We should have a picture. 89 // We should have a picture.
90 EXPECT_TRUE(!!picture_info.GetPicture()); 90 EXPECT_TRUE(!!picture_info.GetPicture());
91 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect( 91 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect(
92 picture_info.GetPicture()->LayerRect(), min_scale_); 92 picture_info.GetPicture()->LayerRect(), min_scale_);
93 93
94 // The the picture should be large enough that scaling it never makes a rect 94 // The the picture should be large enough that scaling it never makes a rect
95 // smaller than 1 px wide or tall. 95 // smaller than 1 px wide or tall.
96 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " << 96 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " <<
97 picture_rect.ToString(); 97 picture_rect.ToString();
98 } 98 }
99 99
100 TEST_F(PicturePileTest, LargeInvalidateInflated) { 100 TEST_F(PicturePileTest, LargeInvalidateInflated) {
101 UpdateWholeLayer(); 101 UpdateWholePile();
102 102
103 // Invalidate something inside a tile. 103 // Invalidate something inside a tile.
104 gfx::Rect invalidate_rect(50, 50, 100, 100); 104 gfx::Rect invalidate_rect(50, 50, 100, 100);
105 Update(invalidate_rect, layer_rect()); 105 Update(invalidate_rect, tiling_rect());
106 106
107 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); 107 EXPECT_EQ(1, pile_->tiling().num_tiles_x());
108 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); 108 EXPECT_EQ(1, pile_->tiling().num_tiles_y());
109 109
110 TestPicturePile::PictureInfo& picture_info = 110 TestPicturePile::PictureInfo& picture_info =
111 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; 111 pile_->picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second;
112 EXPECT_TRUE(!!picture_info.GetPicture()); 112 EXPECT_TRUE(!!picture_info.GetPicture());
113 113
114 int expected_inflation = pile_->buffer_pixels(); 114 int expected_inflation = pile_->buffer_pixels();
115 115
116 Picture* base_picture = picture_info.GetPicture(); 116 Picture* base_picture = picture_info.GetPicture();
117 gfx::Rect base_picture_rect(pile_->size()); 117 gfx::Rect base_picture_rect = pile_->tiling_rect();
118 base_picture_rect.Inset(-expected_inflation, -expected_inflation); 118 base_picture_rect.Inset(-expected_inflation, -expected_inflation);
119 EXPECT_EQ(base_picture_rect.ToString(), 119 EXPECT_EQ(base_picture_rect.ToString(),
120 base_picture->LayerRect().ToString()); 120 base_picture->LayerRect().ToString());
121 } 121 }
122 122
123 TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) { 123 TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) {
124 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 2.f)); 124 gfx::Rect new_tiling_rect = gfx::ToEnclosedRect(
125 pile_->Resize(layer_size); 125 gfx::ScaleRect(pile_->tiling_rect(), 2.f));
126 pile_->SetTilingRect(new_tiling_rect);
126 127
127 // Due to border pixels, we should have 3 tiles. 128 // Due to border pixels, we should have 3 tiles.
128 EXPECT_EQ(3, pile_->tiling().num_tiles_x()); 129 EXPECT_EQ(3, pile_->tiling().num_tiles_x());
129 EXPECT_EQ(3, pile_->tiling().num_tiles_y()); 130 EXPECT_EQ(3, pile_->tiling().num_tiles_y());
130 131
131 // We should have 1/.125 - 1 = 7 border pixels. 132 // We should have 1/.125 - 1 = 7 border pixels.
132 EXPECT_EQ(7, pile_->buffer_pixels()); 133 EXPECT_EQ(7, pile_->buffer_pixels());
133 EXPECT_EQ(7, pile_->tiling().border_texels()); 134 EXPECT_EQ(7, pile_->tiling().border_texels());
134 135
135 // Update the whole layer to create initial pictures. 136 // Update the whole layer to create initial pictures.
136 UpdateWholeLayer(); 137 UpdateWholePile();
137 138
138 // Invalidate everything again to have a non zero invalidation 139 // Invalidate everything again to have a non zero invalidation
139 // frequency. 140 // frequency.
140 UpdateWholeLayer(); 141 UpdateWholePile();
141 142
142 // Invalidate something just over a tile boundary by a single pixel. 143 // Invalidate something just over a tile boundary by a single pixel.
143 // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0). 144 // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0).
144 gfx::Rect invalidate_rect( 145 gfx::Rect invalidate_rect(
145 pile_->tiling().TileBoundsWithBorder(0, 0).right(), 146 pile_->tiling().TileBoundsWithBorder(0, 0).right(),
146 pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1, 147 pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1,
147 50, 148 50,
148 50); 149 50);
149 Update(invalidate_rect, layer_rect()); 150 Update(invalidate_rect, tiling_rect());
150 151
151 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { 152 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
152 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { 153 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
153 TestPicturePile::PictureInfo& picture_info = 154 TestPicturePile::PictureInfo& picture_info =
154 pile_->picture_map() 155 pile_->picture_map()
155 .find(TestPicturePile::PictureMapKey(i, j)) 156 .find(TestPicturePile::PictureMapKey(i, j))
156 ->second; 157 ->second;
157 158
158 // Expect (1, 1) and (1, 0) to be invalidated once more 159 // Expect (1, 1) and (1, 0) to be invalidated once more
159 // than the rest of the tiles. 160 // than the rest of the tiles.
160 if (i == 1 && (j == 0 || j == 1)) { 161 if (i == 1 && (j == 0 || j == 1)) {
161 EXPECT_FLOAT_EQ( 162 EXPECT_FLOAT_EQ(
162 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, 163 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED,
163 picture_info.GetInvalidationFrequencyForTesting()); 164 picture_info.GetInvalidationFrequencyForTesting());
164 } else { 165 } else {
165 EXPECT_FLOAT_EQ( 166 EXPECT_FLOAT_EQ(
166 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, 167 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED,
167 picture_info.GetInvalidationFrequencyForTesting()); 168 picture_info.GetInvalidationFrequencyForTesting());
168 } 169 }
169 } 170 }
170 } 171 }
171 } 172 }
172 173
173 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { 174 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) {
174 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 4.f)); 175 gfx::Rect new_tiling_rect = gfx::ToEnclosedRect(
175 pile_->Resize(layer_size); 176 gfx::ScaleRect(pile_->tiling_rect(), 4.f));
177 pile_->SetTilingRect(new_tiling_rect);
176 178
177 gfx::Rect viewport(0, 0, layer_size.width(), 1); 179 gfx::Rect viewport(tiling_rect().x(), tiling_rect().y(),
180 tiling_rect().width(), 1);
178 181
179 // Update the whole layer until the invalidation frequency is high. 182 // Update the whole pile until the invalidation frequency is high.
180 for (int frame = 0; frame < 33; ++frame) { 183 for (int frame = 0; frame < 33; ++frame) {
181 UpdateWholeLayer(); 184 UpdateWholePile();
182 } 185 }
183 186
184 // Make sure we have a high invalidation frequency. 187 // Make sure we have a high invalidation frequency.
185 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { 188 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
186 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { 189 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
187 TestPicturePile::PictureInfo& picture_info = 190 TestPicturePile::PictureInfo& picture_info =
188 pile_->picture_map() 191 pile_->picture_map()
189 .find(TestPicturePile::PictureMapKey(i, j)) 192 .find(TestPicturePile::PictureMapKey(i, j))
190 ->second; 193 ->second;
191 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) 194 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting())
192 << "i " << i << " j " << j; 195 << "i " << i << " j " << j;
193 } 196 }
194 } 197 }
195 198
196 // Update once more with a small viewport 0,0 layer_width by 1 199 // Update once more with a small viewport tiilng_rect.x(), tiilng_rect.y(),
197 Update(layer_rect(), viewport); 200 // tiling_rect.width() by 1
201 Update(tiling_rect(), viewport);
198 202
199 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { 203 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
200 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { 204 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
201 TestPicturePile::PictureInfo& picture_info = 205 TestPicturePile::PictureInfo& picture_info =
202 pile_->picture_map() 206 pile_->picture_map()
203 .find(TestPicturePile::PictureMapKey(i, j)) 207 .find(TestPicturePile::PictureMapKey(i, j))
204 ->second; 208 ->second;
205 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); 209 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting());
206 210
207 // If the y far enough away we expect to find no picture (no re-recording 211 // If the y far enough away we expect to find no picture (no re-recording
208 // happened). For close y, the picture should change. 212 // happened). For close y, the picture should change.
209 if (j >= 2) 213 if (j >= 2)
210 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; 214 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j;
211 else 215 else
212 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; 216 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j;
213 } 217 }
214 } 218 }
215 219
216 // Now update with no invalidation and full viewport 220 // Now update with no invalidation and full viewport
217 Update(gfx::Rect(), layer_rect()); 221 Update(gfx::Rect(), tiling_rect());
218 222
219 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) { 223 for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
220 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) { 224 for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
221 TestPicturePile::PictureInfo& picture_info = 225 TestPicturePile::PictureInfo& picture_info =
222 pile_->picture_map() 226 pile_->picture_map()
223 .find(TestPicturePile::PictureMapKey(i, j)) 227 .find(TestPicturePile::PictureMapKey(i, j))
224 ->second; 228 ->second;
225 // Expect the invalidation frequency to be less than 1, since we just 229 // Expect the invalidation frequency to be less than 1, since we just
226 // updated with no invalidations. 230 // updated with no invalidations.
227 float expected_frequency = 231 float expected_frequency =
228 1.0f - 232 1.0f -
229 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED; 233 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED;
230 234
231 EXPECT_FLOAT_EQ(expected_frequency, 235 EXPECT_FLOAT_EQ(expected_frequency,
232 picture_info.GetInvalidationFrequencyForTesting()); 236 picture_info.GetInvalidationFrequencyForTesting());
233 237
234 // We expect that there are pictures everywhere now. 238 // We expect that there are pictures everywhere now.
235 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; 239 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j;
236 } 240 }
237 } 241 }
238 } 242 }
239 243
240 TEST_F(PicturePileTest, ClearingInvalidatesRecordedRect) { 244 TEST_F(PicturePileTest, ClearingInvalidatesRecordedRect) {
241 UpdateWholeLayer(); 245 UpdateWholePile();
242 246
243 gfx::Rect rect(0, 0, 5, 5); 247 gfx::Rect rect(0, 0, 5, 5);
244 EXPECT_TRUE(pile_->CanRasterLayerRect(rect)); 248 EXPECT_TRUE(pile_->CanRasterLayerRect(rect));
245 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(rect)); 249 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(rect));
246 250
247 pile_->Clear(); 251 pile_->Clear();
248 252
249 // Make sure both the cache-aware check (using recorded region) and the normal 253 // Make sure both the cache-aware check (using recorded region) and the normal
250 // check are both false after clearing. 254 // check are both false after clearing.
251 EXPECT_FALSE(pile_->CanRasterLayerRect(rect)); 255 EXPECT_FALSE(pile_->CanRasterLayerRect(rect));
252 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(rect)); 256 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(rect));
253 } 257 }
254 258
255 TEST_F(PicturePileTest, FrequentInvalidationCanRaster) { 259 TEST_F(PicturePileTest, FrequentInvalidationCanRaster) {
256 // This test makes sure that if part of the page is frequently invalidated 260 // This test makes sure that if part of the page is frequently invalidated
257 // and doesn't get re-recorded, then CanRaster is not true for any 261 // and doesn't get re-recorded, then CanRaster is not true for any
258 // tiles touching it, but is true for adjacent tiles, even if it 262 // tiles touching it, but is true for adjacent tiles, even if it
259 // overlaps on borders (edge case). 263 // overlaps on borders (edge case).
260 gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 4.f)); 264 gfx::Rect new_tiling_rect = gfx::ToEnclosedRect(
261 pile_->Resize(layer_size); 265 gfx::ScaleRect(pile_->tiling_rect(), 4.f));
266 pile_->SetTilingRect(new_tiling_rect);
262 267
263 gfx::Rect tile01_borders = pile_->tiling().TileBoundsWithBorder(0, 1); 268 gfx::Rect tile01_borders = pile_->tiling().TileBoundsWithBorder(0, 1);
264 gfx::Rect tile02_borders = pile_->tiling().TileBoundsWithBorder(0, 2); 269 gfx::Rect tile02_borders = pile_->tiling().TileBoundsWithBorder(0, 2);
265 gfx::Rect tile01_noborders = pile_->tiling().TileBounds(0, 1); 270 gfx::Rect tile01_noborders = pile_->tiling().TileBounds(0, 1);
266 gfx::Rect tile02_noborders = pile_->tiling().TileBounds(0, 2); 271 gfx::Rect tile02_noborders = pile_->tiling().TileBounds(0, 2);
267 272
268 // Sanity check these two tiles are overlapping with borders, since this is 273 // Sanity check these two tiles are overlapping with borders, since this is
269 // what the test is trying to repro. 274 // what the test is trying to repro.
270 EXPECT_TRUE(tile01_borders.Intersects(tile02_borders)); 275 EXPECT_TRUE(tile01_borders.Intersects(tile02_borders));
271 EXPECT_FALSE(tile01_noborders.Intersects(tile02_noborders)); 276 EXPECT_FALSE(tile01_noborders.Intersects(tile02_noborders));
272 UpdateWholeLayer(); 277 UpdateWholePile();
273 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders)); 278 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders));
274 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders)); 279 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders));
275 EXPECT_TRUE(pile_->CanRasterLayerRect(tile02_noborders)); 280 EXPECT_TRUE(pile_->CanRasterLayerRect(tile02_noborders));
276 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile02_noborders)); 281 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile02_noborders));
277 // Sanity check that an initial paint goes down the fast path of having 282 // Sanity check that an initial paint goes down the fast path of having
278 // a valid recorded viewport. 283 // a valid recorded viewport.
279 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); 284 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
280 285
281 // Update the whole layer until the invalidation frequency is high. 286 // Update the whole layer until the invalidation frequency is high.
282 for (int frame = 0; frame < 33; ++frame) { 287 for (int frame = 0; frame < 33; ++frame) {
283 UpdateWholeLayer(); 288 UpdateWholePile();
284 } 289 }
285 290
286 // Update once more with a small viewport. 291 // Update once more with a small viewport.
287 gfx::Rect viewport(0, 0, layer_size.width(), 1); 292 gfx::Rect viewport(0, 0, tiling_rect().width(), 1);
288 Update(layer_rect(), viewport); 293 Update(tiling_rect(), viewport);
289 294
290 // Sanity check some pictures exist and others don't. 295 // Sanity check some pictures exist and others don't.
291 EXPECT_TRUE(pile_->picture_map() 296 EXPECT_TRUE(pile_->picture_map()
292 .find(TestPicturePile::PictureMapKey(0, 1)) 297 .find(TestPicturePile::PictureMapKey(0, 1))
293 ->second.GetPicture()); 298 ->second.GetPicture());
294 EXPECT_FALSE(pile_->picture_map() 299 EXPECT_FALSE(pile_->picture_map()
295 .find(TestPicturePile::PictureMapKey(0, 2)) 300 .find(TestPicturePile::PictureMapKey(0, 2))
296 ->second.GetPicture()); 301 ->second.GetPicture());
297 302
298 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders)); 303 EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders));
299 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders)); 304 EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders));
300 EXPECT_FALSE(pile_->CanRasterLayerRect(tile02_noborders)); 305 EXPECT_FALSE(pile_->CanRasterLayerRect(tile02_noborders));
301 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(tile02_noborders)); 306 EXPECT_FALSE(pile_->CanRasterSlowTileCheck(tile02_noborders));
302 } 307 }
303 308
304 TEST_F(PicturePileTest, NoInvalidationValidViewport) { 309 TEST_F(PicturePileTest, NoInvalidationValidViewport) {
305 // This test validates that the recorded_viewport cache of full tiles 310 // This test validates that the recorded_viewport cache of full tiles
306 // is still valid for some use cases. If it's not, it's a performance 311 // is still valid for some use cases. If it's not, it's a performance
307 // issue because CanRaster checks will go down the slow path. 312 // issue because CanRaster checks will go down the slow path.
308 UpdateWholeLayer(); 313 UpdateWholePile();
309 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); 314 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
310 315
311 // No invalidation, same viewport. 316 // No invalidation, same viewport.
312 Update(gfx::Rect(), layer_rect()); 317 Update(gfx::Rect(), tiling_rect());
313 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); 318 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
314 319
315 // Partial invalidation, same viewport. 320 // Partial invalidation, same viewport.
316 Update(gfx::Rect(gfx::Rect(0, 0, 1, 1)), layer_rect()); 321 Update(gfx::Rect(gfx::Rect(0, 0, 1, 1)), tiling_rect());
317 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); 322 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
318 323
319 // No invalidation, changing viewport. 324 // No invalidation, changing viewport.
320 Update(gfx::Rect(), gfx::Rect(5, 5, 5, 5)); 325 Update(gfx::Rect(), gfx::Rect(5, 5, 5, 5));
321 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); 326 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
322 } 327 }
323 328
324 } // namespace 329 } // namespace
325 } // namespace cc 330 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698