OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 for (int i = 0; i < 5; i++) { | 275 for (int i = 0; i < 5; i++) { |
276 for (int j = 0; j < 5; j++) { | 276 for (int j = 0; j < 5; j++) { |
277 if (idlePaintTiles.contains(i, j)) | 277 if (idlePaintTiles.contains(i, j)) |
278 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); | 278 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); |
279 else | 279 else |
280 EXPECT_FALSE(layerImpl->hasTileAt(i, j)); | 280 EXPECT_FALSE(layerImpl->hasTileAt(i, j)); |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
| 285 TEST(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) |
| 286 { |
| 287 OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024,
2*1024*1024, 1024); |
| 288 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(t
extureManager.get())); |
| 289 DebugScopedSetImplThread implThread; |
| 290 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0))
); |
| 291 |
| 292 FakeTextureAllocator textureAllocator; |
| 293 CCTextureUpdater updater(&textureAllocator); |
| 294 |
| 295 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 296 // However, during the paint, we invalidate one of the tiles. This should |
| 297 // not prevent the tile from being pushed. |
| 298 layer->setBounds(IntSize(100, 200)); |
| 299 layer->invalidateRect(IntRect(0, 0, 100, 200)); |
| 300 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50
), layer.get()); |
| 301 layer->prepareToUpdate(IntRect(0, 0, 100, 200)); |
| 302 layer->updateCompositorResources(0, updater); |
| 303 layer->pushPropertiesTo(layerImpl.get()); |
| 304 |
| 305 // We should have both tiles on the impl side. |
| 306 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 307 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 308 } |
| 309 |
| 310 TEST(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
| 311 { |
| 312 OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024,
2*1024*1024, 1024); |
| 313 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
textureManager.get())); |
| 314 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
textureManager.get())); |
| 315 DebugScopedSetImplThread implThread; |
| 316 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)
)); |
| 317 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)
)); |
| 318 |
| 319 FakeTextureAllocator textureAllocator; |
| 320 CCTextureUpdater updater(&textureAllocator); |
| 321 |
| 322 layer1->setBounds(IntSize(100, 200)); |
| 323 layer1->invalidateRect(IntRect(0, 0, 100, 200)); |
| 324 layer2->setBounds(IntSize(100, 200)); |
| 325 layer2->invalidateRect(IntRect(0, 0, 100, 200)); |
| 326 |
| 327 layer1->prepareToUpdate(IntRect(0, 0, 100, 200)); |
| 328 |
| 329 // Invalidate a tile on layer1 |
| 330 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer1.get()); |
| 331 layer2->prepareToUpdate(IntRect(0, 0, 100, 200)); |
| 332 |
| 333 layer1->updateCompositorResources(0, updater); |
| 334 layer2->updateCompositorResources(0, updater); |
| 335 |
| 336 layer1->pushPropertiesTo(layer1Impl.get()); |
| 337 layer2->pushPropertiesTo(layer2Impl.get()); |
| 338 |
| 339 // We should have both tiles on the impl side for all layers. |
| 340 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); |
| 341 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); |
| 342 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); |
| 343 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); |
| 344 } |
| 345 |
| 346 TEST(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer
) |
| 347 { |
| 348 OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024,
2*1024*1024, 1024); |
| 349 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
textureManager.get())); |
| 350 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
textureManager.get())); |
| 351 DebugScopedSetImplThread implThread; |
| 352 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)
)); |
| 353 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)
)); |
| 354 |
| 355 FakeTextureAllocator textureAllocator; |
| 356 CCTextureUpdater updater(&textureAllocator); |
| 357 |
| 358 layer1->setBounds(IntSize(100, 200)); |
| 359 layer1->invalidateRect(IntRect(0, 0, 100, 200)); |
| 360 layer2->setBounds(IntSize(100, 200)); |
| 361 layer2->invalidateRect(IntRect(0, 0, 100, 200)); |
| 362 |
| 363 // Invalidate a tile on layer2 |
| 364 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer2.get()); |
| 365 layer1->prepareToUpdate(IntRect(0, 0, 100, 200)); |
| 366 |
| 367 layer2->prepareToUpdate(IntRect(0, 0, 100, 200)); |
| 368 |
| 369 layer1->updateCompositorResources(0, updater); |
| 370 layer2->updateCompositorResources(0, updater); |
| 371 |
| 372 layer1->pushPropertiesTo(layer1Impl.get()); |
| 373 layer2->pushPropertiesTo(layer2Impl.get()); |
| 374 |
| 375 // We should have both tiles on the impl side for all layers. |
| 376 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); |
| 377 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); |
| 378 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); |
| 379 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); |
| 380 } |
285 | 381 |
286 TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) | 382 TEST(TiledLayerChromiumTest, idlePaintOutOfMemory) |
287 { | 383 { |
288 // The tile size is 100x100. Setup 5x5 tiles with one 1x1 visible tile in th
e center. | 384 // The tile size is 100x100. Setup 5x5 tiles with one 1x1 visible tile in th
e center. |
289 IntSize contentBounds(300, 300); | 385 IntSize contentBounds(300, 300); |
290 IntRect contentRect(IntPoint::zero(), contentBounds); | 386 IntRect contentRect(IntPoint::zero(), contentBounds); |
291 IntRect visibleRect(100, 100, 100, 100); | 387 IntRect visibleRect(100, 100, 100, 100); |
292 | 388 |
293 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 389 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. |
294 int memoryLimit = 4 * 100 * 100; // 2 tiles, 4 bytes per pixel. | 390 int memoryLimit = 4 * 100 * 100; // 2 tiles, 4 bytes per pixel. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimi
t); | 550 ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimi
t); |
455 ccLayerTreeHost->updateLayers(); | 551 ccLayerTreeHost->updateLayers(); |
456 EXPECT_FALSE(rootLayer->skipsDraw()); | 552 EXPECT_FALSE(rootLayer->skipsDraw()); |
457 | 553 |
458 ccLayerTreeHost->setRootLayer(0); | 554 ccLayerTreeHost->setRootLayer(0); |
459 ccLayerTreeHost.clear(); | 555 ccLayerTreeHost.clear(); |
460 WebKit::WebCompositor::shutdown(); | 556 WebKit::WebCompositor::shutdown(); |
461 } | 557 } |
462 | 558 |
463 } // namespace | 559 } // namespace |
OLD | NEW |