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

Side by Side Diff: cc/TiledLayerChromiumTest.cpp

Issue 10990116: [cc] Color evicted vs. invalidated checkerboard tiles differently (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « cc/TiledLayerChromium.cpp ('k') | cc/test/CCTiledLayerTestCommon.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "config.h" 5 #include "config.h"
6 6
7 #include "TiledLayerChromium.h" 7 #include "TiledLayerChromium.h"
8 8
9 #include "BitmapCanvasLayerTextureUpdater.h" 9 #include "BitmapCanvasLayerTextureUpdater.h"
10 #include "CCAnimationTestCommon.h" 10 #include "CCAnimationTestCommon.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 174 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
175 ScopedFakeCCTiledLayerImpl layerImpl(1); 175 ScopedFakeCCTiledLayerImpl layerImpl(1);
176 176
177 // The tile size is 100x100, so this invalidates and then paints two tiles. 177 // The tile size is 100x100, so this invalidates and then paints two tiles.
178 layer->setBounds(IntSize(100, 200)); 178 layer->setBounds(IntSize(100, 200));
179 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 179 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
180 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 180 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
181 updateAndPush(layer.get(), layerImpl.get()); 181 updateAndPush(layer.get(), layerImpl.get());
182 182
183 // We should have both tiles on the impl side. 183 // We should have both tiles on the impl side.
184 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 184 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
185 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 185 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
186 186
187 // Invalidates both tiles, but then only update one of them. 187 // Invalidates both tiles, but then only update one of them.
188 layer->setBounds(IntSize(100, 200)); 188 layer->setBounds(IntSize(100, 200));
189 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 189 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
190 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 190 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
191 updateAndPush(layer.get(), layerImpl.get()); 191 updateAndPush(layer.get(), layerImpl.get());
192 192
193 // We should only have the first tile since the other tile was invalidated b ut not painted. 193 // We should only have the first tile since the other tile was invalidated b ut not painted.
194 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
195 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); 195 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
196 } 196 }
197 197
198 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) 198 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
199 { 199 {
200 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 200 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
201 ScopedFakeCCTiledLayerImpl layerImpl(1); 201 ScopedFakeCCTiledLayerImpl layerImpl(1);
202 TestCCOcclusionTracker occluded; 202 TestCCOcclusionTracker occluded;
203 m_occlusion = &occluded; 203 m_occlusion = &occluded;
204 204
205 // The tile size is 100x100, so this invalidates and then paints two tiles. 205 // The tile size is 100x100, so this invalidates and then paints two tiles.
206 layer->setBounds(IntSize(100, 200)); 206 layer->setBounds(IntSize(100, 200));
207 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 207 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
208 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 208 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
209 updateAndPush(layer.get(), layerImpl.get()); 209 updateAndPush(layer.get(), layerImpl.get());
210 210
211 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 211 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
212 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 ); 212 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 );
213 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 213 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
214 214
215 // We should have both tiles on the impl side. 215 // We should have both tiles on the impl side.
216 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
217 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 217 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
218 218
219 // Invalidates part of the top tile... 219 // Invalidates part of the top tile...
220 layer->invalidateContentRect(IntRect(0, 0, 50, 50)); 220 layer->invalidateContentRect(IntRect(0, 0, 50, 50));
221 // ....but the area is occluded. 221 // ....but the area is occluded.
222 occluded.setOcclusion(IntRect(0, 0, 50, 50)); 222 occluded.setOcclusion(IntRect(0, 0, 50, 50));
223 updateAndPush(layer.get(), layerImpl.get()); 223 updateAndPush(layer.get(), layerImpl.get());
224 224
225 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); 225 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1);
226 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1); 226 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1);
227 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); 227 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload());
228 228
229 // We should still have both tiles, as part of the top tile is still unocclu ded. 229 // We should still have both tiles, as part of the top tile is still unocclu ded.
230 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 230 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
231 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 231 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
232 } 232 }
233 233
234 TEST_F(TiledLayerChromiumTest, pushDeletedTiles) 234 TEST_F(TiledLayerChromiumTest, pushDeletedTiles)
235 { 235 {
236 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 236 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
237 ScopedFakeCCTiledLayerImpl layerImpl(1); 237 ScopedFakeCCTiledLayerImpl layerImpl(1);
238 238
239 // The tile size is 100x100, so this invalidates and then paints two tiles. 239 // The tile size is 100x100, so this invalidates and then paints two tiles.
240 layer->setBounds(IntSize(100, 200)); 240 layer->setBounds(IntSize(100, 200));
241 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 241 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
242 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); 242 layer->invalidateContentRect(IntRect(0, 0, 100, 200));
243 updateAndPush(layer.get(), layerImpl.get()); 243 updateAndPush(layer.get(), layerImpl.get());
244 244
245 // We should have both tiles on the impl side. 245 // We should have both tiles on the impl side.
246 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 246 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
247 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 247 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
248 248
249 m_textureManager->clearPriorities(); 249 m_textureManager->clearPriorities();
250 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get( )); 250 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get( ));
251 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); 251 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024);
252 252
253 // This should drop the tiles on the impl thread. 253 // This should drop the tiles on the impl thread.
254 layerPushPropertiesTo(layer.get(), layerImpl.get()); 254 layerPushPropertiesTo(layer.get(), layerImpl.get());
255 255
256 // We should now have no textures on the impl thread. 256 // We should now have no textures on the impl thread.
257 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); 257 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
258 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); 258 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
259 259
260 // This should recreate and update one of the deleted textures. 260 // This should recreate and update one of the deleted textures.
261 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 261 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
262 updateAndPush(layer.get(), layerImpl.get()); 262 updateAndPush(layer.get(), layerImpl.get());
263 263
264 // We should have one tiles on the impl side. 264 // We should have one tiles on the impl side.
265 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 265 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
266 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); 266 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
267 } 267 }
268 268
269 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) 269 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles)
270 { 270 {
271 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 271 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
272 ScopedFakeCCTiledLayerImpl layerImpl(1); 272 ScopedFakeCCTiledLayerImpl layerImpl(1);
273 273
274 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. 274 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter.
275 // This paints 1 visible of the 25 invalid tiles. 275 // This paints 1 visible of the 25 invalid tiles.
276 layer->setBounds(IntSize(500, 500)); 276 layer->setBounds(IntSize(500, 500));
277 layer->setVisibleContentRect(IntRect(200, 200, 100, 100)); 277 layer->setVisibleContentRect(IntRect(200, 200, 100, 100));
278 layer->invalidateContentRect(IntRect(0, 0, 500, 500)); 278 layer->invalidateContentRect(IntRect(0, 0, 500, 500));
279 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 279 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
280 // We should need idle-painting for surrounding tiles. 280 // We should need idle-painting for surrounding tiles.
281 EXPECT_TRUE(needsUpdate); 281 EXPECT_TRUE(needsUpdate);
282 282
283 // We should have one tile on the impl side. 283 // We should have one tile on the impl side.
284 EXPECT_TRUE(layerImpl->hasTileAt(2, 2)); 284 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2));
285 285
286 // For the next four updates, we should detect we still need idle painting. 286 // For the next four updates, we should detect we still need idle painting.
287 for (int i = 0; i < 4; i++) { 287 for (int i = 0; i < 4; i++) {
288 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 288 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
289 EXPECT_TRUE(needsUpdate); 289 EXPECT_TRUE(needsUpdate);
290 } 290 }
291 291
292 // We should have one tile surrounding the visible tile on all sides, but no other tiles. 292 // We should have one tile surrounding the visible tile on all sides, but no other tiles.
293 IntRect idlePaintTiles(1, 1, 3, 3); 293 IntRect idlePaintTiles(1, 1, 3, 3);
294 for (int i = 0; i < 5; i++) { 294 for (int i = 0; i < 5; i++) {
295 for (int j = 0; j < 5; j++) 295 for (int j = 0; j < 5; j++)
296 EXPECT_EQ(layerImpl->hasTileAt(i, j), idlePaintTiles.contains(i, j)) ; 296 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), idlePaintTiles.co ntains(i, j));
297 } 297 }
298 298
299 // We should always finish painting eventually. 299 // We should always finish painting eventually.
300 for (int i = 0; i < 20; i++) 300 for (int i = 0; i < 20; i++)
301 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 301 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
302 EXPECT_FALSE(needsUpdate); 302 EXPECT_FALSE(needsUpdate);
303 } 303 }
304 304
305 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) 305 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed)
306 { 306 {
(...skipping 28 matching lines...) Expand all
335 m_textureManager->setMaxMemoryLimitBytes(1024 * 1024); 335 m_textureManager->setMaxMemoryLimitBytes(1024 * 1024);
336 336
337 // Now idle paint layer2. We are going to run out of memory though! 337 // Now idle paint layer2. We are going to run out of memory though!
338 // Oh well, commit the frame and push. 338 // Oh well, commit the frame and push.
339 for (int i = 0; i < 4; i++) { 339 for (int i = 0; i < 4; i++) {
340 needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), 340 needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(),
341 layer2.get(), layerImpl2.get()); 341 layer2.get(), layerImpl2.get());
342 } 342 }
343 343
344 // Sanity check, we should have textures for the big layer. 344 // Sanity check, we should have textures for the big layer.
345 EXPECT_TRUE(layerImpl1->hasTextureIdForTileAt(0, 0)); 345 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 0));
346 EXPECT_TRUE(layerImpl1->hasTextureIdForTileAt(0, 23)); 346 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 23));
347 347
348 // We should only have the first two tiles from layer2 since 348 // We should only have the first two tiles from layer2 since
349 // it failed to idle update the last tile. 349 // it failed to idle update the last tile.
350 EXPECT_TRUE(layerImpl2->hasTileAt(0, 0)); 350 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0));
351 EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 0)); 351 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0));
352 EXPECT_TRUE(layerImpl2->hasTileAt(0, 1)); 352 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
353 EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 1)); 353 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1));
354 354
355 EXPECT_FALSE(needsUpdate); 355 EXPECT_FALSE(needsUpdate);
356 EXPECT_FALSE(layerImpl2->hasTileAt(0, 2)); 356 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2));
357 } 357 }
358 358
359 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) 359 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
360 { 360 {
361 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 361 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
362 ScopedFakeCCTiledLayerImpl layerImpl(1); 362 ScopedFakeCCTiledLayerImpl layerImpl(1);
363 TestCCOcclusionTracker occluded; 363 TestCCOcclusionTracker occluded;
364 m_occlusion = &occluded; 364 m_occlusion = &occluded;
365 365
366 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. 366 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
367 occluded.setOcclusion(IntRect(0, 0, 100, 100)); 367 occluded.setOcclusion(IntRect(0, 0, 100, 100));
368 368
369 layer->setBounds(IntSize(100, 100)); 369 layer->setBounds(IntSize(100, 100));
370 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); 370 layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
371 updateAndPush(layer.get(), layerImpl.get()); 371 updateAndPush(layer.get(), layerImpl.get());
372 372
373 // We should have the prepainted tile on the impl side, but culled it during paint. 373 // We should have the prepainted tile on the impl side, but culled it during paint.
374 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 374 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
375 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); 375 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload());
376 } 376 }
377 377
378 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) 378 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint)
379 { 379 {
380 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 380 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
381 ScopedFakeCCTiledLayerImpl layerImpl(1); 381 ScopedFakeCCTiledLayerImpl layerImpl(1);
382 382
383 // The tile size is 100x100, so this invalidates and then paints two tiles. 383 // The tile size is 100x100, so this invalidates and then paints two tiles.
384 // However, during the paint, we invalidate one of the tiles. This should 384 // However, during the paint, we invalidate one of the tiles. This should
385 // not prevent the tile from being pushed. 385 // not prevent the tile from being pushed.
386 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50 ), layer.get()); 386 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50 ), layer.get());
387 layer->setBounds(IntSize(100, 200)); 387 layer->setBounds(IntSize(100, 200));
388 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 388 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
389 updateAndPush(layer.get(), layerImpl.get()); 389 updateAndPush(layer.get(), layerImpl.get());
390 390
391 // We should have both tiles on the impl side. 391 // We should have both tiles on the impl side.
392 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 392 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
393 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 393 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
394 } 394 }
395 395
396 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) 396 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
397 { 397 {
398 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get())); 398 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get()));
399 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get())); 399 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get()));
400 ScopedFakeCCTiledLayerImpl layer1Impl(1); 400 ScopedFakeCCTiledLayerImpl layer1Impl(1);
401 ScopedFakeCCTiledLayerImpl layer2Impl(2); 401 ScopedFakeCCTiledLayerImpl layer2Impl(2);
402 402
403 // Invalidate a tile on layer1, during update of layer 2. 403 // Invalidate a tile on layer1, during update of layer 2.
404 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer1.get()); 404 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer1.get());
405 layer1->setBounds(IntSize(100, 200)); 405 layer1->setBounds(IntSize(100, 200));
406 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); 406 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
407 layer2->setBounds(IntSize(100, 200)); 407 layer2->setBounds(IntSize(100, 200));
408 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); 408 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
409 updateAndPush(layer1.get(), layer1Impl.get(), 409 updateAndPush(layer1.get(), layer1Impl.get(),
410 layer2.get(), layer2Impl.get()); 410 layer2.get(), layer2Impl.get());
411 411
412 // We should have both tiles on the impl side for all layers. 412 // We should have both tiles on the impl side for all layers.
413 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); 413 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
414 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); 414 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
415 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); 415 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
416 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); 416 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
417 } 417 }
418 418
419 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay er) 419 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay er)
420 { 420 {
421 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get())); 421 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get()));
422 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get())); 422 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium( m_textureManager.get()));
423 ScopedFakeCCTiledLayerImpl layer1Impl(1); 423 ScopedFakeCCTiledLayerImpl layer1Impl(1);
424 ScopedFakeCCTiledLayerImpl layer2Impl(2); 424 ScopedFakeCCTiledLayerImpl layer2Impl(2);
425 425
426 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer2.get()); 426 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5 0), layer2.get());
427 layer1->setBounds(IntSize(100, 200)); 427 layer1->setBounds(IntSize(100, 200));
428 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); 428 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200));
429 layer2->setBounds(IntSize(100, 200)); 429 layer2->setBounds(IntSize(100, 200));
430 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); 430 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200));
431 updateAndPush(layer1.get(), layer1Impl.get(), 431 updateAndPush(layer1.get(), layer1Impl.get(),
432 layer2.get(), layer2Impl.get()); 432 layer2.get(), layer2Impl.get());
433 433
434 // We should have both tiles on the impl side for all layers. 434 // We should have both tiles on the impl side for all layers.
435 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); 435 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
436 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); 436 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
437 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); 437 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
438 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); 438 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
439 } 439 }
440 440
441 TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) 441 TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately)
442 { 442 {
443 // Create a CCLayerTreeHost that has the right viewportsize, 443 // Create a CCLayerTreeHost that has the right viewportsize,
444 // so the layer is considered small enough. 444 // so the layer is considered small enough.
445 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 445 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient;
446 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay erTreeHostClient, CCLayerTreeSettings()); 446 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay erTreeHostClient, CCLayerTreeSettings());
447 447
448 bool runOutOfMemory[2] = {false, true}; 448 bool runOutOfMemory[2] = {false, true};
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 layer->update(*m_queue.get(), 0, m_stats); 482 layer->update(*m_queue.get(), 0, m_stats);
483 updateTextures(); 483 updateTextures();
484 layerPushPropertiesTo(layer.get(), layerImpl.get()); 484 layerPushPropertiesTo(layer.get(), layerImpl.get());
485 485
486 // We should have all the tiles for the small animated layer. 486 // We should have all the tiles for the small animated layer.
487 // We should still have the visible tiles when we didn't 487 // We should still have the visible tiles when we didn't
488 // have enough memory for all the tiles. 488 // have enough memory for all the tiles.
489 if (!runOutOfMemory[i]) { 489 if (!runOutOfMemory[i]) {
490 for (int i = 0; i < 4; ++i) { 490 for (int i = 0; i < 4; ++i) {
491 for (int j = 0; j < 4; ++j) 491 for (int j = 0; j < 4; ++j)
492 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); 492 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j));
493 } 493 }
494 } else { 494 } else {
495 for (int i = 0; i < 8; ++i) { 495 for (int i = 0; i < 8; ++i) {
496 for (int j = 0; j < 4; ++j) 496 for (int j = 0; j < 4; ++j)
497 EXPECT_EQ(layerImpl->hasTileAt(i, j), i < 4); 497 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 4);
498 } 498 }
499 } 499 }
500 } 500 }
501 ccLayerTreeHost.clear(); 501 ccLayerTreeHost.clear();
502 } 502 }
503 503
504 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) 504 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory)
505 { 505 {
506 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 506 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
507 ScopedFakeCCTiledLayerImpl layerImpl(1); 507 ScopedFakeCCTiledLayerImpl layerImpl(1);
508 508
509 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. 509 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint.
510 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. 510 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
511 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); 511 m_textureManager->setMaxMemoryLimitBytes(memoryLimit);
512 512
513 // The tile size is 100x100, so this invalidates and then paints two tiles. 513 // The tile size is 100x100, so this invalidates and then paints two tiles.
514 bool needsUpdate = false; 514 bool needsUpdate = false;
515 layer->setBounds(IntSize(300, 300)); 515 layer->setBounds(IntSize(300, 300));
516 layer->setVisibleContentRect(IntRect(100, 100, 100, 100)); 516 layer->setVisibleContentRect(IntRect(100, 100, 100, 100));
517 for (int i = 0; i < 2; i++) 517 for (int i = 0; i < 2; i++)
518 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 518 needsUpdate = updateAndPush(layer.get(), layerImpl.get());
519 519
520 // Idle-painting should see no more priority tiles for painting. 520 // Idle-painting should see no more priority tiles for painting.
521 EXPECT_FALSE(needsUpdate); 521 EXPECT_FALSE(needsUpdate);
522 522
523 // We should have one tile on the impl side. 523 // We should have one tile on the impl side.
524 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); 524 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
525 } 525 }
526 526
527 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) 527 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer)
528 { 528 {
529 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 529 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
530 ScopedFakeCCTiledLayerImpl layerImpl(1); 530 ScopedFakeCCTiledLayerImpl layerImpl(1);
531 531
532 bool animating[2] = {false, true}; 532 bool animating[2] = {false, true};
533 for (int i = 0; i < 2; i++) { 533 for (int i = 0; i < 2; i++) {
534 // Pretend the layer is animating. 534 // Pretend the layer is animating.
535 layer->setDrawTransformIsAnimating(animating[i]); 535 layer->setDrawTransformIsAnimating(animating[i]);
536 536
537 // The layer's bounds are empty. 537 // The layer's bounds are empty.
538 // Empty layers don't paint or idle-paint. 538 // Empty layers don't paint or idle-paint.
539 layer->setBounds(IntSize()); 539 layer->setBounds(IntSize());
540 layer->setVisibleContentRect(IntRect()); 540 layer->setVisibleContentRect(IntRect());
541 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 541 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
542 542
543 // Empty layers don't have tiles. 543 // Empty layers don't have tiles.
544 EXPECT_EQ(0u, layer->numPaintedTiles()); 544 EXPECT_EQ(0u, layer->numPaintedTiles());
545 545
546 // Empty layers don't need prepaint. 546 // Empty layers don't need prepaint.
547 EXPECT_FALSE(needsUpdate); 547 EXPECT_FALSE(needsUpdate);
548 548
549 // Empty layers don't have tiles. 549 // Empty layers don't have tiles.
550 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); 550 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
551 } 551 }
552 } 552 }
553 553
554 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) 554 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers)
555 { 555 {
556 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 556 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
557 ScopedFakeCCTiledLayerImpl layerImpl(1); 557 ScopedFakeCCTiledLayerImpl layerImpl(1);
558 558
559 // Alternate between not visible and visible. 559 // Alternate between not visible and visible.
560 IntRect v(0, 0, 100, 100); 560 IntRect v(0, 0, 100, 100);
561 IntRect nv(0, 0, 0, 0); 561 IntRect nv(0, 0, 0, 0);
562 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; 562 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv};
563 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; 563 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false };
564 564
565 // We should not have any tiles except for when the layer was visible 565 // We should not have any tiles except for when the layer was visible
566 // or after the layer was visible and we didn't invalidate. 566 // or after the layer was visible and we didn't invalidate.
567 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; 567 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true };
568 568
569 for (int i = 0; i < 10; i++) { 569 for (int i = 0; i < 10; i++) {
570 layer->setBounds(IntSize(100, 100)); 570 layer->setBounds(IntSize(100, 100));
571 layer->setVisibleContentRect(visibleRect[i]); 571 layer->setVisibleContentRect(visibleRect[i]);
572 572
573 if (invalidate[i]) 573 if (invalidate[i])
574 layer->invalidateContentRect(IntRect(0, 0, 100, 100)); 574 layer->invalidateContentRect(IntRect(0, 0, 100, 100));
575 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); 575 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get());
576 576
577 // We should never signal idle paint, as we painted the entire layer 577 // We should never signal idle paint, as we painted the entire layer
578 // or the layer was not visible. 578 // or the layer was not visible.
579 EXPECT_FALSE(needsUpdate); 579 EXPECT_FALSE(needsUpdate);
580 EXPECT_EQ(layerImpl->hasTileAt(0, 0), haveTile[i]); 580 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]);
581 } 581 }
582 } 582 }
583 583
584 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) 584 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare)
585 { 585 {
586 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get())); 586 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m _textureManager.get()));
587 ScopedFakeCCTiledLayerImpl layerImpl(1); 587 ScopedFakeCCTiledLayerImpl layerImpl(1);
588 588
589 // The tile size is 100x100, so this invalidates and then paints two tiles. 589 // The tile size is 100x100, so this invalidates and then paints two tiles.
590 layer->setBounds(IntSize(100, 200)); 590 layer->setBounds(IntSize(100, 200));
591 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); 591 layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
592 updateAndPush(layer.get(), layerImpl.get()); 592 updateAndPush(layer.get(), layerImpl.get());
593 593
594 // We should have both tiles on the impl side. 594 // We should have both tiles on the impl side.
595 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 595 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
596 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 596 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
597 597
598 layer->fakeLayerTextureUpdater()->clearPrepareCount(); 598 layer->fakeLayerTextureUpdater()->clearPrepareCount();
599 // Invoke update again. As the layer is valid update shouldn't be invoked on 599 // Invoke update again. As the layer is valid update shouldn't be invoked on
600 // the LayerTextureUpdater. 600 // the LayerTextureUpdater.
601 updateAndPush(layer.get(), layerImpl.get()); 601 updateAndPush(layer.get(), layerImpl.get());
602 EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount()); 602 EXPECT_EQ(0, layer->fakeLayerTextureUpdater()->prepareCount());
603 603
604 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate. 604 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate.
605 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50 ), layer.get()); 605 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50 ), layer.get());
606 layer->fakeLayerTextureUpdater()->clearPrepareCount(); 606 layer->fakeLayerTextureUpdater()->clearPrepareCount();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // Invalidate the entire layer. 666 // Invalidate the entire layer.
667 layer->setNeedsDisplay(); 667 layer->setNeedsDisplay();
668 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( )); 668 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( ));
669 669
670 // Push the tiles to the impl side and check that there is exactly one. 670 // Push the tiles to the impl side and check that there is exactly one.
671 layer->setTexturePriorities(m_priorityCalculator); 671 layer->setTexturePriorities(m_priorityCalculator);
672 m_textureManager->prioritizeTextures(); 672 m_textureManager->prioritizeTextures();
673 layer->update(*m_queue.get(), 0, m_stats); 673 layer->update(*m_queue.get(), 0, m_stats);
674 updateTextures(); 674 updateTextures();
675 layerPushPropertiesTo(layer.get(), layerImpl.get()); 675 layerPushPropertiesTo(layer.get(), layerImpl.get());
676 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 676 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
677 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); 677 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
678 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); 678 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
679 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); 679 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
680 680
681 // Change the contents scale and verify that the content rectangle requiring painting 681 // Change the contents scale and verify that the content rectangle requiring painting
682 // is not scaled. 682 // is not scaled.
683 layer->setContentsScale(2); 683 layer->setContentsScale(2);
684 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); 684 layer->setVisibleContentRect(IntRect(0, 0, 200, 200));
685 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( )); 685 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect( ));
686 686
687 // The impl side should get 2x2 tiles now. 687 // The impl side should get 2x2 tiles now.
688 layer->setTexturePriorities(m_priorityCalculator); 688 layer->setTexturePriorities(m_priorityCalculator);
689 m_textureManager->prioritizeTextures(); 689 m_textureManager->prioritizeTextures();
690 layer->update(*m_queue.get(), 0, m_stats); 690 layer->update(*m_queue.get(), 0, m_stats);
691 updateTextures(); 691 updateTextures();
692 layerPushPropertiesTo(layer.get(), layerImpl.get()); 692 layerPushPropertiesTo(layer.get(), layerImpl.get());
693 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); 693 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
694 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); 694 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
695 EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); 695 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0));
696 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); 696 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
697 697
698 // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the 698 // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the
699 // impl side. 699 // impl side.
700 layer->setNeedsDisplay(); 700 layer->setNeedsDisplay();
701 layer->setTexturePriorities(m_priorityCalculator); 701 layer->setTexturePriorities(m_priorityCalculator);
702 m_textureManager->prioritizeTextures(); 702 m_textureManager->prioritizeTextures();
703 703
704 layerPushPropertiesTo(layer.get(), layerImpl.get()); 704 layerPushPropertiesTo(layer.get(), layerImpl.get());
705 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); 705 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
706 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); 706 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
707 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); 707 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
708 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); 708 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
709 } 709 }
710 710
711 TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) 711 TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset)
712 { 712 {
713 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 713 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient;
714 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay erTreeHostClient, CCLayerTreeSettings()); 714 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay erTreeHostClient, CCLayerTreeSettings());
715 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); 715 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded());
716 716
717 // Create two 300 x 300 tiled layers. 717 // Create two 300 x 300 tiled layers.
718 IntSize contentBounds(300, 300); 718 IntSize contentBounds(300, 300);
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1368
1369 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1369 ScopedFakeCCTiledLayerImpl rootImpl(root->id());
1370 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1370 ScopedFakeCCTiledLayerImpl childImpl(child->id());
1371 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1371 ScopedFakeCCTiledLayerImpl child2Impl(child2->id());
1372 layerPushPropertiesTo(root.get(), rootImpl.get()); 1372 layerPushPropertiesTo(root.get(), rootImpl.get());
1373 layerPushPropertiesTo(child.get(), childImpl.get()); 1373 layerPushPropertiesTo(child.get(), childImpl.get());
1374 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1374 layerPushPropertiesTo(child2.get(), child2Impl.get());
1375 1375
1376 for (unsigned i = 0; i < 3; ++i) { 1376 for (unsigned i = 0; i < 3; ++i) {
1377 for (unsigned j = 0; j < 2; ++j) 1377 for (unsigned j = 0; j < 2; ++j)
1378 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); 1378 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1379 EXPECT_TRUE(childImpl->hasTextureIdForTileAt(i, 0)); 1379 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1380 EXPECT_TRUE(child2Impl->hasTextureIdForTileAt(i, 0)); 1380 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1381 } 1381 }
1382 } 1382 }
1383 ccLayerTreeHost->commitComplete(); 1383 ccLayerTreeHost->commitComplete();
1384 1384
1385 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that 1385 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that
1386 // the child layers draw into, the child layers will not be allocated. If th e surface isn't 1386 // the child layers draw into, the child layers will not be allocated. If th e surface isn't
1387 // accounted for, then one of the children would fit within the memory limit . 1387 // accounted for, then one of the children would fit within the memory limit .
1388 root->invalidateContentRect(rootRect); 1388 root->invalidateContentRect(rootRect);
1389 child->invalidateContentRect(childRect); 1389 child->invalidateContentRect(childRect);
1390 child2->invalidateContentRect(child2Rect); 1390 child2->invalidateContentRect(child2Rect);
(...skipping 12 matching lines...) Expand all
1403 1403
1404 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1404 ScopedFakeCCTiledLayerImpl rootImpl(root->id());
1405 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1405 ScopedFakeCCTiledLayerImpl childImpl(child->id());
1406 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1406 ScopedFakeCCTiledLayerImpl child2Impl(child2->id());
1407 layerPushPropertiesTo(root.get(), rootImpl.get()); 1407 layerPushPropertiesTo(root.get(), rootImpl.get());
1408 layerPushPropertiesTo(child.get(), childImpl.get()); 1408 layerPushPropertiesTo(child.get(), childImpl.get());
1409 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1409 layerPushPropertiesTo(child2.get(), child2Impl.get());
1410 1410
1411 for (unsigned i = 0; i < 3; ++i) { 1411 for (unsigned i = 0; i < 3; ++i) {
1412 for (unsigned j = 0; j < 2; ++j) 1412 for (unsigned j = 0; j < 2; ++j)
1413 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); 1413 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1414 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); 1414 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1415 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); 1415 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1416 } 1416 }
1417 } 1417 }
1418 ccLayerTreeHost->commitComplete(); 1418 ccLayerTreeHost->commitComplete();
1419 1419
1420 // With a memory limit that includes only half the root layer, no contents w ill be 1420 // With a memory limit that includes only half the root layer, no contents w ill be
1421 // allocated. If render surface memory wasn't accounted for, there is enough space 1421 // allocated. If render surface memory wasn't accounted for, there is enough space
1422 // for one of the children layers, but they draw into a surface that can't b e 1422 // for one of the children layers, but they draw into a surface that can't b e
1423 // allocated. 1423 // allocated.
1424 root->invalidateContentRect(rootRect); 1424 root->invalidateContentRect(rootRect);
1425 child->invalidateContentRect(childRect); 1425 child->invalidateContentRect(childRect);
(...skipping 13 matching lines...) Expand all
1439 1439
1440 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); 1440 ScopedFakeCCTiledLayerImpl rootImpl(root->id());
1441 ScopedFakeCCTiledLayerImpl childImpl(child->id()); 1441 ScopedFakeCCTiledLayerImpl childImpl(child->id());
1442 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); 1442 ScopedFakeCCTiledLayerImpl child2Impl(child2->id());
1443 layerPushPropertiesTo(root.get(), rootImpl.get()); 1443 layerPushPropertiesTo(root.get(), rootImpl.get());
1444 layerPushPropertiesTo(child.get(), childImpl.get()); 1444 layerPushPropertiesTo(child.get(), childImpl.get());
1445 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1445 layerPushPropertiesTo(child2.get(), child2Impl.get());
1446 1446
1447 for (unsigned i = 0; i < 3; ++i) { 1447 for (unsigned i = 0; i < 3; ++i) {
1448 for (unsigned j = 0; j < 2; ++j) 1448 for (unsigned j = 0; j < 2; ++j)
1449 EXPECT_FALSE(rootImpl->hasTextureIdForTileAt(i, j)); 1449 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1450 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); 1450 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1451 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); 1451 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1452 } 1452 }
1453 } 1453 }
1454 ccLayerTreeHost->commitComplete(); 1454 ccLayerTreeHost->commitComplete();
1455 1455
1456 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re sourceProvider.get()); 1456 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re sourceProvider.get());
1457 ccLayerTreeHost->setRootLayer(0); 1457 ccLayerTreeHost->setRootLayer(0);
1458 ccLayerTreeHost.clear(); 1458 ccLayerTreeHost.clear();
1459 } 1459 }
1460 1460
1461 class TrackingLayerPainter : public LayerPainterChromium { 1461 class TrackingLayerPainter : public LayerPainterChromium {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 updateTextures(); 1552 updateTextures();
1553 1553
1554 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1554 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1555 layer->setNeedsDisplayRect(layerRect); 1555 layer->setNeedsDisplayRect(layerRect);
1556 layer->update(*m_queue.get(), 0, m_stats); 1556 layer->update(*m_queue.get(), 0, m_stats);
1557 1557
1558 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1558 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1559 } 1559 }
1560 1560
1561 } // namespace 1561 } // namespace
OLDNEW
« no previous file with comments | « cc/TiledLayerChromium.cpp ('k') | cc/test/CCTiledLayerTestCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698