| OLD | NEW |
| 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 "cc/tiled_layer.h" | 5 #include "cc/tiled_layer.h" |
| 6 | 6 |
| 7 #include "cc/bitmap_content_layer_updater.h" | 7 #include "cc/bitmap_content_layer_updater.h" |
| 8 #include "cc/layer_painter.h" | 8 #include "cc/layer_painter.h" |
| 9 #include "cc/overdraw_metrics.h" | 9 #include "cc/overdraw_metrics.h" |
| 10 #include "cc/prioritized_resource_manager.h" | 10 #include "cc/prioritized_resource_manager.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; | 189 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; |
| 190 scoped_ptr<LayerTreeHost> layer_tree_host_; | 190 scoped_ptr<LayerTreeHost> layer_tree_host_; |
| 191 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; | 191 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; |
| 192 scoped_ptr<PrioritizedResourceManager> m_resourceManager; | 192 scoped_ptr<PrioritizedResourceManager> m_resourceManager; |
| 193 TestOcclusionTracker* m_occlusion; | 193 TestOcclusionTracker* m_occlusion; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 TEST_F(TiledLayerTest, pushDirtyTiles) | 196 TEST_F(TiledLayerTest, pushDirtyTiles) |
| 197 { | 197 { |
| 198 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 198 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 199 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 199 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 200 | 200 |
| 201 // The tile size is 100x100, so this invalidates and then paints two tiles. | 201 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 202 layer->SetBounds(gfx::Size(100, 200)); | 202 layer->SetBounds(gfx::Size(100, 200)); |
| 203 calcDrawProps(layer); | 203 calcDrawProps(layer); |
| 204 updateAndPush(layer, layerImpl); | 204 updateAndPush(layer, layerImpl); |
| 205 | 205 |
| 206 // We should have both tiles on the impl side. | 206 // We should have both tiles on the impl side. |
| 207 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 207 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 208 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 208 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 209 | 209 |
| 210 // Invalidates both tiles, but then only update one of them. | 210 // Invalidates both tiles, but then only update one of them. |
| 211 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 211 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
| 212 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 212 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 213 updateAndPush(layer, layerImpl); | 213 updateAndPush(layer, layerImpl); |
| 214 | 214 |
| 215 // We should only have the first tile since the other tile was invalidated b
ut not painted. | 215 // We should only have the first tile since the other tile was invalidated b
ut not painted. |
| 216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 217 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 217 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) | 220 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) |
| 221 { | 221 { |
| 222 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 222 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 223 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 223 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 224 TestOcclusionTracker occluded; | 224 TestOcclusionTracker occluded; |
| 225 m_occlusion = &occluded; | 225 m_occlusion = &occluded; |
| 226 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 100
0)); | 226 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 100
0)); |
| 227 | 227 |
| 228 // The tile size is 100x100, so this invalidates and then paints two tiles. | 228 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 229 layer->SetBounds(gfx::Size(100, 200)); | 229 layer->SetBounds(gfx::Size(100, 200)); |
| 230 calcDrawProps(layer); | 230 calcDrawProps(layer); |
| 231 updateAndPush(layer, layerImpl); | 231 updateAndPush(layer, layerImpl); |
| 232 | 232 |
| 233 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 233 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 250 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 250 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
| 251 | 251 |
| 252 // We should still have both tiles, as part of the top tile is still unocclu
ded. | 252 // We should still have both tiles, as part of the top tile is still unocclu
ded. |
| 253 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 253 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 254 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 254 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 TEST_F(TiledLayerTest, pushDeletedTiles) | 257 TEST_F(TiledLayerTest, pushDeletedTiles) |
| 258 { | 258 { |
| 259 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 259 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 260 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 260 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 261 | 261 |
| 262 // The tile size is 100x100, so this invalidates and then paints two tiles. | 262 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 263 layer->SetBounds(gfx::Size(100, 200)); | 263 layer->SetBounds(gfx::Size(100, 200)); |
| 264 calcDrawProps(layer); | 264 calcDrawProps(layer); |
| 265 updateAndPush(layer, layerImpl); | 265 updateAndPush(layer, layerImpl); |
| 266 | 266 |
| 267 // We should have both tiles on the impl side. | 267 // We should have both tiles on the impl side. |
| 268 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 268 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 269 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 269 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 270 | 270 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 284 updateAndPush(layer, layerImpl); | 284 updateAndPush(layer, layerImpl); |
| 285 | 285 |
| 286 // We should have one tiles on the impl side. | 286 // We should have one tiles on the impl side. |
| 287 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 287 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 288 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 288 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 289 } | 289 } |
| 290 | 290 |
| 291 TEST_F(TiledLayerTest, pushIdlePaintTiles) | 291 TEST_F(TiledLayerTest, pushIdlePaintTiles) |
| 292 { | 292 { |
| 293 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 293 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 294 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 294 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 295 | 295 |
| 296 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. | 296 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. |
| 297 // This paints 1 visible of the 25 invalid tiles. | 297 // This paints 1 visible of the 25 invalid tiles. |
| 298 layer->SetBounds(gfx::Size(500, 500)); | 298 layer->SetBounds(gfx::Size(500, 500)); |
| 299 calcDrawProps(layer); | 299 calcDrawProps(layer); |
| 300 layer->draw_properties().visible_content_rect = gfx::Rect(200, 200, 100, 100
); | 300 layer->draw_properties().visible_content_rect = gfx::Rect(200, 200, 100, 100
); |
| 301 bool needsUpdate = updateAndPush(layer, layerImpl); | 301 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 302 // We should need idle-painting for surrounding tiles. | 302 // We should need idle-painting for surrounding tiles. |
| 303 EXPECT_TRUE(needsUpdate); | 303 EXPECT_TRUE(needsUpdate); |
| 304 | 304 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 320 for (int j = 0; j < 5; j++) | 320 for (int j = 0; j < 5; j++) |
| 321 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); | 321 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 EXPECT_FALSE(needsUpdate); | 324 EXPECT_FALSE(needsUpdate); |
| 325 } | 325 } |
| 326 | 326 |
| 327 TEST_F(TiledLayerTest, predictivePainting) | 327 TEST_F(TiledLayerTest, predictivePainting) |
| 328 { | 328 { |
| 329 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 329 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 330 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 330 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 331 | 331 |
| 332 // Prepainting should occur in the scroll direction first, and the | 332 // Prepainting should occur in the scroll direction first, and the |
| 333 // visible rect should be extruded only along the dominant axis. | 333 // visible rect should be extruded only along the dominant axis. |
| 334 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), | 334 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), |
| 335 gfx::Vector2d(10, 0), | 335 gfx::Vector2d(10, 0), |
| 336 gfx::Vector2d(0, -10), | 336 gfx::Vector2d(0, -10), |
| 337 gfx::Vector2d(0, 10), | 337 gfx::Vector2d(0, 10), |
| 338 gfx::Vector2d(10, 20), | 338 gfx::Vector2d(10, 20), |
| 339 gfx::Vector2d(-20, 10) }; | 339 gfx::Vector2d(-20, 10) }; |
| 340 // We should push all tiles that touch the extruded visible rect. | 340 // We should push all tiles that touch the extruded visible rect. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 needsUpdate = updateAndPush(layer, layerImpl); | 393 needsUpdate = updateAndPush(layer, layerImpl); |
| 394 EXPECT_FALSE(needsUpdate); | 394 EXPECT_FALSE(needsUpdate); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) | 398 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) |
| 399 { | 399 { |
| 400 // Start with 2mb of memory, but the test is going to try to use just more t
han 1mb, so we reduce to 1mb later. | 400 // Start with 2mb of memory, but the test is going to try to use just more t
han 1mb, so we reduce to 1mb later. |
| 401 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); | 401 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); |
| 402 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 402 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 403 scoped_ptr<FakeTiledLayerImpl> layerImpl1 = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 1)); | 403 scoped_ptr<FakeTiledLayerImpl> layerImpl1 = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 1)); |
| 404 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 404 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 405 scoped_ptr<FakeTiledLayerImpl> layerImpl2 = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 2)); | 405 scoped_ptr<FakeTiledLayerImpl> layerImpl2 = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 2)); |
| 406 | 406 |
| 407 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from | 407 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from |
| 408 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint | 408 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint |
| 409 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. | 409 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. |
| 410 | 410 |
| 411 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. | 411 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. |
| 412 gfx::Rect layer1Rect(0, 0, 100, 2400); | 412 gfx::Rect layer1Rect(0, 0, 100, 2400); |
| 413 | 413 |
| 414 // This requires 4*30000 bytes of memory. | 414 // This requires 4*30000 bytes of memory. |
| 415 gfx::Rect layer2Rect(0, 0, 100, 300); | 415 gfx::Rect layer2Rect(0, 0, 100, 300); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 446 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 446 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
| 447 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 447 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
| 448 | 448 |
| 449 EXPECT_FALSE(needsUpdate); | 449 EXPECT_FALSE(needsUpdate); |
| 450 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); | 450 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) | 453 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) |
| 454 { | 454 { |
| 455 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 455 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 456 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 456 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 457 TestOcclusionTracker occluded; | 457 TestOcclusionTracker occluded; |
| 458 m_occlusion = &occluded; | 458 m_occlusion = &occluded; |
| 459 | 459 |
| 460 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. | 460 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. |
| 461 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); | 461 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); |
| 462 | 462 |
| 463 layer->SetBounds(gfx::Size(100, 100)); | 463 layer->SetBounds(gfx::Size(100, 100)); |
| 464 calcDrawProps(layer); | 464 calcDrawProps(layer); |
| 465 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 465 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 466 updateAndPush(layer, layerImpl); | 466 updateAndPush(layer, layerImpl); |
| 467 | 467 |
| 468 // We should have the prepainted tile on the impl side, but culled it during
paint. | 468 // We should have the prepainted tile on the impl side, but culled it during
paint. |
| 469 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 469 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 470 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 470 EXPECT_EQ(1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
| 471 } | 471 } |
| 472 | 472 |
| 473 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) | 473 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) |
| 474 { | 474 { |
| 475 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 475 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 476 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 476 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 477 | 477 |
| 478 // The tile size is 100x100, so this invalidates and then paints two tiles. | 478 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 479 // However, during the paint, we invalidate one of the tiles. This should | 479 // However, during the paint, we invalidate one of the tiles. This should |
| 480 // not prevent the tile from being pushed. | 480 // not prevent the tile from being pushed. |
| 481 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); | 481 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); |
| 482 layer->SetBounds(gfx::Size(100, 200)); | 482 layer->SetBounds(gfx::Size(100, 200)); |
| 483 calcDrawProps(layer); | 483 calcDrawProps(layer); |
| 484 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 484 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 485 updateAndPush(layer, layerImpl); | 485 updateAndPush(layer, layerImpl); |
| 486 | 486 |
| 487 // We should have both tiles on the impl side. | 487 // We should have both tiles on the impl side. |
| 488 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 488 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 489 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 489 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 490 } | 490 } |
| 491 | 491 |
| 492 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 492 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
| 493 { | 493 { |
| 494 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 494 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 495 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 495 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 496 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 1)); | 496 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 1)); |
| 497 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 2)); | 497 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 2)); |
| 498 | 498 |
| 499 // Invalidate a tile on layer1, during update of layer 2. | 499 // Invalidate a tile on layer1, during update of layer 2. |
| 500 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); | 500 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); |
| 501 layer1->SetBounds(gfx::Size(100, 200)); | 501 layer1->SetBounds(gfx::Size(100, 200)); |
| 502 layer2->SetBounds(gfx::Size(100, 200)); | 502 layer2->SetBounds(gfx::Size(100, 200)); |
| 503 calcDrawProps(layer1, layer2); | 503 calcDrawProps(layer1, layer2); |
| 504 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 504 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 505 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 505 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 506 updateAndPush(layer1, layer1Impl, | 506 updateAndPush(layer1, layer1Impl, |
| 507 layer2, layer2Impl); | 507 layer2, layer2Impl); |
| 508 | 508 |
| 509 // We should have both tiles on the impl side for all layers. | 509 // We should have both tiles on the impl side for all layers. |
| 510 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 510 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
| 511 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 511 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
| 512 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 512 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
| 513 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 513 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
| 514 } | 514 } |
| 515 | 515 |
| 516 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) | 516 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) |
| 517 { | 517 { |
| 518 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 518 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 519 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 519 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
| 520 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 1)); | 520 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 1)); |
| 521 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->activeTree(), 2)); | 521 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay
erImpl(m_hostImpl->active_tree(), 2)); |
| 522 | 522 |
| 523 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); | 523 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); |
| 524 layer1->SetBounds(gfx::Size(100, 200)); | 524 layer1->SetBounds(gfx::Size(100, 200)); |
| 525 layer2->SetBounds(gfx::Size(100, 200)); | 525 layer2->SetBounds(gfx::Size(100, 200)); |
| 526 calcDrawProps(layer1, layer2); | 526 calcDrawProps(layer1, layer2); |
| 527 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 527 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 528 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 528 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 529 updateAndPush(layer1, layer1Impl, | 529 updateAndPush(layer1, layer1Impl, |
| 530 layer2, layer2Impl); | 530 layer2, layer2Impl); |
| 531 | 531 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 552 int memoryForLayer = layerWidth * layerHeight * 4; | 552 int memoryForLayer = layerWidth * layerHeight * 4; |
| 553 layer_tree_host_->SetViewportSize(gfx::Size(layerWidth, layerHeight), gf
x::Size(layerWidth, layerHeight)); | 553 layer_tree_host_->SetViewportSize(gfx::Size(layerWidth, layerHeight), gf
x::Size(layerWidth, layerHeight)); |
| 554 | 554 |
| 555 // Use 10x5 tiles to run out of memory. | 555 // Use 10x5 tiles to run out of memory. |
| 556 if (runOutOfMemory[i]) | 556 if (runOutOfMemory[i]) |
| 557 layerWidth *= 2; | 557 layerWidth *= 2; |
| 558 | 558 |
| 559 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); | 559 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); |
| 560 | 560 |
| 561 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); | 561 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); |
| 562 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 562 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 563 | 563 |
| 564 // Full size layer with half being visible. | 564 // Full size layer with half being visible. |
| 565 layer->SetBounds(gfx::Size(layerWidth, layerHeight)); | 565 layer->SetBounds(gfx::Size(layerWidth, layerHeight)); |
| 566 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); | 566 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); |
| 567 calcDrawProps(layer); | 567 calcDrawProps(layer); |
| 568 | 568 |
| 569 // Pretend the layer is animating. | 569 // Pretend the layer is animating. |
| 570 layer->draw_properties().target_space_transform_is_animating = true; | 570 layer->draw_properties().target_space_transform_is_animating = true; |
| 571 layer->draw_properties().visible_content_rect = visibleRect; | 571 layer->draw_properties().visible_content_rect = visibleRect; |
| 572 layer->SetLayerTreeHost(layer_tree_host_.get()); | 572 layer->SetLayerTreeHost(layer_tree_host_.get()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 592 for (int j = 0; j < 5; ++j) | 592 for (int j = 0; j < 5; ++j) |
| 593 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); | 593 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 | 598 |
| 599 TEST_F(TiledLayerTest, idlePaintOutOfMemory) | 599 TEST_F(TiledLayerTest, idlePaintOutOfMemory) |
| 600 { | 600 { |
| 601 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 601 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 602 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 602 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 603 | 603 |
| 604 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 604 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. |
| 605 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. | 605 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
| 606 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); | 606 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); |
| 607 | 607 |
| 608 // The tile size is 100x100, so this invalidates and then paints two tiles. | 608 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 609 bool needsUpdate = false; | 609 bool needsUpdate = false; |
| 610 layer->SetBounds(gfx::Size(300, 300)); | 610 layer->SetBounds(gfx::Size(300, 300)); |
| 611 calcDrawProps(layer); | 611 calcDrawProps(layer); |
| 612 layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100
); | 612 layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100
); |
| 613 for (int i = 0; i < 2; i++) | 613 for (int i = 0; i < 2; i++) |
| 614 needsUpdate = updateAndPush(layer, layerImpl); | 614 needsUpdate = updateAndPush(layer, layerImpl); |
| 615 | 615 |
| 616 // Idle-painting should see no more priority tiles for painting. | 616 // Idle-painting should see no more priority tiles for painting. |
| 617 EXPECT_FALSE(needsUpdate); | 617 EXPECT_FALSE(needsUpdate); |
| 618 | 618 |
| 619 // We should have one tile on the impl side. | 619 // We should have one tile on the impl side. |
| 620 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); | 620 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); |
| 621 } | 621 } |
| 622 | 622 |
| 623 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) | 623 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) |
| 624 { | 624 { |
| 625 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 625 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 626 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 626 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 627 | 627 |
| 628 bool animating[2] = {false, true}; | 628 bool animating[2] = {false, true}; |
| 629 for (int i = 0; i < 2; i++) { | 629 for (int i = 0; i < 2; i++) { |
| 630 // Pretend the layer is animating. | 630 // Pretend the layer is animating. |
| 631 layer->draw_properties().target_space_transform_is_animating = animating
[i]; | 631 layer->draw_properties().target_space_transform_is_animating = animating
[i]; |
| 632 | 632 |
| 633 // The layer's bounds are empty. | 633 // The layer's bounds are empty. |
| 634 // Empty layers don't paint or idle-paint. | 634 // Empty layers don't paint or idle-paint. |
| 635 layer->SetBounds(gfx::Size()); | 635 layer->SetBounds(gfx::Size()); |
| 636 calcDrawProps(layer); | 636 calcDrawProps(layer); |
| 637 layer->draw_properties().visible_content_rect = gfx::Rect(); | 637 layer->draw_properties().visible_content_rect = gfx::Rect(); |
| 638 bool needsUpdate = updateAndPush(layer, layerImpl); | 638 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 639 | 639 |
| 640 // Empty layers don't have tiles. | 640 // Empty layers don't have tiles. |
| 641 EXPECT_EQ(0u, layer->numPaintedTiles()); | 641 EXPECT_EQ(0u, layer->numPaintedTiles()); |
| 642 | 642 |
| 643 // Empty layers don't need prepaint. | 643 // Empty layers don't need prepaint. |
| 644 EXPECT_FALSE(needsUpdate); | 644 EXPECT_FALSE(needsUpdate); |
| 645 | 645 |
| 646 // Empty layers don't have tiles. | 646 // Empty layers don't have tiles. |
| 647 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 647 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 | 650 |
| 651 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) | 651 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) |
| 652 { | 652 { |
| 653 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 653 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 654 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 654 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 655 | 655 |
| 656 // Alternate between not visible and visible. | 656 // Alternate between not visible and visible. |
| 657 gfx::Rect v(0, 0, 100, 100); | 657 gfx::Rect v(0, 0, 100, 100); |
| 658 gfx::Rect nv(0, 0, 0, 0); | 658 gfx::Rect nv(0, 0, 0, 0); |
| 659 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 659 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; |
| 660 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; | 660 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; |
| 661 | 661 |
| 662 // We should not have any tiles except for when the layer was visible | 662 // We should not have any tiles except for when the layer was visible |
| 663 // or after the layer was visible and we didn't invalidate. | 663 // or after the layer was visible and we didn't invalidate. |
| 664 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; | 664 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 675 // We should never signal idle paint, as we painted the entire layer | 675 // We should never signal idle paint, as we painted the entire layer |
| 676 // or the layer was not visible. | 676 // or the layer was not visible. |
| 677 EXPECT_FALSE(needsUpdate); | 677 EXPECT_FALSE(needsUpdate); |
| 678 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); | 678 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); |
| 679 } | 679 } |
| 680 } | 680 } |
| 681 | 681 |
| 682 TEST_F(TiledLayerTest, invalidateFromPrepare) | 682 TEST_F(TiledLayerTest, invalidateFromPrepare) |
| 683 { | 683 { |
| 684 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 684 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 685 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 685 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 686 | 686 |
| 687 // The tile size is 100x100, so this invalidates and then paints two tiles. | 687 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 688 layer->SetBounds(gfx::Size(100, 200)); | 688 layer->SetBounds(gfx::Size(100, 200)); |
| 689 calcDrawProps(layer); | 689 calcDrawProps(layer); |
| 690 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 690 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 691 updateAndPush(layer, layerImpl); | 691 updateAndPush(layer, layerImpl); |
| 692 | 692 |
| 693 // We should have both tiles on the impl side. | 693 // We should have both tiles on the impl side. |
| 694 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 694 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 695 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 695 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 layer->invalidateContentRect(partialDamage); | 749 layer->invalidateContentRect(partialDamage); |
| 750 layer->SetTexturePriorities(m_priorityCalculator); | 750 layer->SetTexturePriorities(m_priorityCalculator); |
| 751 m_resourceManager->prioritizeTextures(); | 751 m_resourceManager->prioritizeTextures(); |
| 752 layer->Update(m_queue.get(), 0, NULL); | 752 layer->Update(m_queue.get(), 0, NULL); |
| 753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); | 753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); |
| 754 } | 754 } |
| 755 | 755 |
| 756 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 756 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
| 757 { | 757 { |
| 758 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 758 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
| 759 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->activeTree(), 1)); | 759 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye
rImpl(m_hostImpl->active_tree(), 1)); |
| 760 | 760 |
| 761 // Create a layer with one tile. | 761 // Create a layer with one tile. |
| 762 layer->SetBounds(gfx::Size(100, 100)); | 762 layer->SetBounds(gfx::Size(100, 100)); |
| 763 calcDrawProps(layer); | 763 calcDrawProps(layer); |
| 764 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 764 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 765 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); | 765 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
| 766 | 766 |
| 767 // Push the tiles to the impl side and check that there is exactly one. | 767 // Push the tiles to the impl side and check that there is exactly one. |
| 768 layer->SetTexturePriorities(m_priorityCalculator); | 768 layer->SetTexturePriorities(m_priorityCalculator); |
| 769 m_resourceManager->prioritizeTextures(); | 769 m_resourceManager->prioritizeTextures(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 layer->draw_properties().visible_content_rect = contentRect; | 904 layer->draw_properties().visible_content_rect = contentRect; |
| 905 layer->invalidateContentRect(contentRect); | 905 layer->invalidateContentRect(contentRect); |
| 906 | 906 |
| 907 layer_tree_host_->SetRootLayer(layer); | 907 layer_tree_host_->SetRootLayer(layer); |
| 908 layer_tree_host_->SetViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 908 layer_tree_host_->SetViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
| 909 | 909 |
| 910 // Full update of all 6 tiles. | 910 // Full update of all 6 tiles. |
| 911 layer_tree_host_->UpdateLayers(m_queue.get(), | 911 layer_tree_host_->UpdateLayers(m_queue.get(), |
| 912 std::numeric_limits<size_t>::max()); | 912 std::numeric_limits<size_t>::max()); |
| 913 { | 913 { |
| 914 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 914 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 915 EXPECT_EQ(6, m_queue->fullUploadSize()); | 915 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 916 EXPECT_EQ(0, m_queue->partialUploadSize()); | 916 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 917 updateTextures(); | 917 updateTextures(); |
| 918 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 918 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 919 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 919 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 920 layer->fakeLayerUpdater()->clearUpdateCount(); | 920 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 921 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 921 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 922 } | 922 } |
| 923 layer_tree_host_->CommitComplete(); | 923 layer_tree_host_->CommitComplete(); |
| 924 | 924 |
| 925 // Full update of 3 tiles and partial update of 3 tiles. | 925 // Full update of 3 tiles and partial update of 3 tiles. |
| 926 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); | 926 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); |
| 927 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); | 927 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); |
| 928 { | 928 { |
| 929 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 929 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 930 EXPECT_EQ(3, m_queue->fullUploadSize()); | 930 EXPECT_EQ(3, m_queue->fullUploadSize()); |
| 931 EXPECT_EQ(3, m_queue->partialUploadSize()); | 931 EXPECT_EQ(3, m_queue->partialUploadSize()); |
| 932 updateTextures(); | 932 updateTextures(); |
| 933 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 933 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 934 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 934 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 935 layer->fakeLayerUpdater()->clearUpdateCount(); | 935 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 936 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 936 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 937 } | 937 } |
| 938 layer_tree_host_->CommitComplete(); | 938 layer_tree_host_->CommitComplete(); |
| 939 | 939 |
| 940 // Partial update of 6 tiles. | 940 // Partial update of 6 tiles. |
| 941 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 941 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
| 942 { | 942 { |
| 943 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 943 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 944 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 944 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 945 EXPECT_EQ(2, m_queue->fullUploadSize()); | 945 EXPECT_EQ(2, m_queue->fullUploadSize()); |
| 946 EXPECT_EQ(4, m_queue->partialUploadSize()); | 946 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 947 updateTextures(); | 947 updateTextures(); |
| 948 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 948 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 949 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 949 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 950 layer->fakeLayerUpdater()->clearUpdateCount(); | 950 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 951 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 951 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 952 } | 952 } |
| 953 layer_tree_host_->CommitComplete(); | 953 layer_tree_host_->CommitComplete(); |
| 954 | 954 |
| 955 // Checkerboard all tiles. | 955 // Checkerboard all tiles. |
| 956 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); | 956 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); |
| 957 { | 957 { |
| 958 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 958 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 959 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 959 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 960 } | 960 } |
| 961 layer_tree_host_->CommitComplete(); | 961 layer_tree_host_->CommitComplete(); |
| 962 | 962 |
| 963 // Partial update of 6 checkerboard tiles. | 963 // Partial update of 6 checkerboard tiles. |
| 964 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 964 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
| 965 { | 965 { |
| 966 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 966 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 967 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 967 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 968 EXPECT_EQ(6, m_queue->fullUploadSize()); | 968 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 969 EXPECT_EQ(0, m_queue->partialUploadSize()); | 969 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 970 updateTextures(); | 970 updateTextures(); |
| 971 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 971 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 972 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 972 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 973 layer->fakeLayerUpdater()->clearUpdateCount(); | 973 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 974 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 974 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 975 } | 975 } |
| 976 layer_tree_host_->CommitComplete(); | 976 layer_tree_host_->CommitComplete(); |
| 977 | 977 |
| 978 // Partial update of 4 tiles. | 978 // Partial update of 4 tiles. |
| 979 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); | 979 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); |
| 980 { | 980 { |
| 981 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), 1)); | 981 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
| 982 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 982 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 983 EXPECT_EQ(0, m_queue->fullUploadSize()); | 983 EXPECT_EQ(0, m_queue->fullUploadSize()); |
| 984 EXPECT_EQ(4, m_queue->partialUploadSize()); | 984 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 985 updateTextures(); | 985 updateTextures(); |
| 986 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); | 986 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); |
| 987 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 987 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 988 layer->fakeLayerUpdater()->clearUpdateCount(); | 988 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 989 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 989 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 990 } | 990 } |
| 991 layer_tree_host_->CommitComplete(); | 991 layer_tree_host_->CommitComplete(); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 updateTextures(); | 1471 updateTextures(); |
| 1472 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1472 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
| 1473 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); | 1473 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); |
| 1474 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); | 1474 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); |
| 1475 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1475 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1476 | 1476 |
| 1477 root->fakeLayerUpdater()->clearUpdateCount(); | 1477 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1478 child->fakeLayerUpdater()->clearUpdateCount(); | 1478 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1479 child2->fakeLayerUpdater()->clearUpdateCount(); | 1479 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1480 | 1480 |
| 1481 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->activeTree(), root->id())); | 1481 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
| 1482 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), child->id())); | 1482 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
| 1483 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->activeTree(), child2->id())); | 1483 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
| 1484 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1484 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1485 layerPushPropertiesTo(child.get(), childImpl.get()); | 1485 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1486 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1486 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1487 | 1487 |
| 1488 for (unsigned i = 0; i < 3; ++i) { | 1488 for (unsigned i = 0; i < 3; ++i) { |
| 1489 for (unsigned j = 0; j < 2; ++j) | 1489 for (unsigned j = 0; j < 2; ++j) |
| 1490 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1490 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1491 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); | 1491 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1492 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1492 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1493 } | 1493 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1505 updateTextures(); | 1505 updateTextures(); |
| 1506 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1506 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
| 1507 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1507 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
| 1508 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1508 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
| 1509 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1509 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1510 | 1510 |
| 1511 root->fakeLayerUpdater()->clearUpdateCount(); | 1511 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1512 child->fakeLayerUpdater()->clearUpdateCount(); | 1512 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1513 child2->fakeLayerUpdater()->clearUpdateCount(); | 1513 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1514 | 1514 |
| 1515 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->activeTree(), root->id())); | 1515 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
| 1516 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), child->id())); | 1516 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
| 1517 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->activeTree(), child2->id())); | 1517 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
| 1518 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1518 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1519 layerPushPropertiesTo(child.get(), childImpl.get()); | 1519 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1520 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1520 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1521 | 1521 |
| 1522 for (unsigned i = 0; i < 3; ++i) { | 1522 for (unsigned i = 0; i < 3; ++i) { |
| 1523 for (unsigned j = 0; j < 2; ++j) | 1523 for (unsigned j = 0; j < 2; ++j) |
| 1524 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1524 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1525 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1525 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1526 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1526 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1527 } | 1527 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1540 updateTextures(); | 1540 updateTextures(); |
| 1541 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); | 1541 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); |
| 1542 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1542 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
| 1543 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1543 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
| 1544 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1544 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1545 | 1545 |
| 1546 root->fakeLayerUpdater()->clearUpdateCount(); | 1546 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1547 child->fakeLayerUpdater()->clearUpdateCount(); | 1547 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1548 child2->fakeLayerUpdater()->clearUpdateCount(); | 1548 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1549 | 1549 |
| 1550 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->activeTree(), root->id())); | 1550 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
| 1551 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->activeTree(), child->id())); | 1551 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
| 1552 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->activeTree(), child2->id())); | 1552 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
| 1553 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1553 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1554 layerPushPropertiesTo(child.get(), childImpl.get()); | 1554 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1555 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1555 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1556 | 1556 |
| 1557 for (unsigned i = 0; i < 3; ++i) { | 1557 for (unsigned i = 0; i < 3; ++i) { |
| 1558 for (unsigned j = 0; j < 2; ++j) | 1558 for (unsigned j = 0; j < 2; ++j) |
| 1559 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); | 1559 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1560 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1560 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1561 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1561 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1562 } | 1562 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 | 1663 |
| 1664 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1664 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
| 1665 layer->SetNeedsDisplayRect(layerRect); | 1665 layer->SetNeedsDisplayRect(layerRect); |
| 1666 layer->Update(m_queue.get(), 0, NULL); | 1666 layer->Update(m_queue.get(), 0, NULL); |
| 1667 | 1667 |
| 1668 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1668 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 } // namespace | 1671 } // namespace |
| 1672 } // namespace cc | 1672 } // namespace cc |
| OLD | NEW |