| 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 "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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return m_layerImpl; | 89 return m_layerImpl; |
| 90 } | 90 } |
| 91 private: | 91 private: |
| 92 FakeCCTiledLayerImpl* m_layerImpl; | 92 FakeCCTiledLayerImpl* m_layerImpl; |
| 93 }; | 93 }; |
| 94 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage
r, CCResourceProvider* resourceProvider) | 94 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage
r, CCResourceProvider* resourceProvider) |
| 95 { | 95 { |
| 96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 97 textureManager->clearAllMemory(resourceProvider); | 97 textureManager->clearAllMemory(resourceProvider); |
| 98 } | 98 } |
| 99 void updateTextures(int count = 500) | 99 void updateTextures() |
| 100 { | 100 { |
| 101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 102 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_u
ploader, &m_queue, count); | 102 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_u
ploader, &m_queue); |
| 103 } | 103 } |
| 104 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm
pl* layerImpl) | 104 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm
pl* layerImpl) |
| 105 { | 105 { |
| 106 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 106 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 107 layer->pushPropertiesTo(layerImpl); | 107 layer->pushPropertiesTo(layerImpl); |
| 108 } | 108 } |
| 109 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl
uded) | 109 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl
uded) |
| 110 { | 110 { |
| 111 DebugScopedSetMainThread mainThread; | 111 DebugScopedSetMainThread mainThread; |
| 112 layer->update(m_queue, occluded, m_stats); | 112 layer->update(m_queue, occluded, m_stats); |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 layer->setVisibleContentRect(contentRect); | 796 layer->setVisibleContentRect(contentRect); |
| 797 layer->invalidateContentRect(contentRect); | 797 layer->invalidateContentRect(contentRect); |
| 798 | 798 |
| 799 ccLayerTreeHost->setRootLayer(layer); | 799 ccLayerTreeHost->setRootLayer(layer); |
| 800 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); | 800 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); |
| 801 | 801 |
| 802 // Full update of all 6 tiles. | 802 // Full update of all 6 tiles. |
| 803 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 803 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 804 { | 804 { |
| 805 ScopedFakeCCTiledLayerImpl layerImpl(1); | 805 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 806 updateTextures(4); | 806 EXPECT_EQ(6, m_queue.fullUploadSize()); |
| 807 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 807 EXPECT_EQ(0, m_queue.partialUploadSize()); |
| 808 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 808 updateTextures(); |
| 809 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 809 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 810 updateTextures(4); | |
| 811 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | |
| 812 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 810 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 813 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 811 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 814 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 812 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 815 } | 813 } |
| 816 ccLayerTreeHost->commitComplete(); | 814 ccLayerTreeHost->commitComplete(); |
| 817 | 815 |
| 818 // Full update of 3 tiles and partial update of 3 tiles. | 816 // Full update of 3 tiles and partial update of 3 tiles. |
| 819 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); | 817 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); |
| 820 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 818 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 821 { | 819 { |
| 822 ScopedFakeCCTiledLayerImpl layerImpl(1); | 820 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 823 updateTextures(4); | 821 EXPECT_EQ(3, m_queue.fullUploadSize()); |
| 824 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | 822 EXPECT_EQ(3, m_queue.partialUploadSize()); |
| 825 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 823 updateTextures(); |
| 826 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 824 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 827 updateTextures(4); | |
| 828 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | |
| 829 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 825 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 830 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 826 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 831 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 827 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 832 } | 828 } |
| 833 ccLayerTreeHost->commitComplete(); | 829 ccLayerTreeHost->commitComplete(); |
| 834 | 830 |
| 835 // Partial update of 6 tiles. | 831 // Partial update of 6 tiles. |
| 836 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 832 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 837 { | 833 { |
| 838 ScopedFakeCCTiledLayerImpl layerImpl(1); | 834 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 839 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 835 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 840 updateTextures(4); | 836 EXPECT_EQ(2, m_queue.fullUploadSize()); |
| 841 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 837 EXPECT_EQ(4, m_queue.partialUploadSize()); |
| 842 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 838 updateTextures(); |
| 843 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 839 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 844 updateTextures(4); | |
| 845 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | |
| 846 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 840 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 847 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 841 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 848 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 842 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 849 } | 843 } |
| 850 ccLayerTreeHost->commitComplete(); | 844 ccLayerTreeHost->commitComplete(); |
| 851 | 845 |
| 852 // Checkerboard all tiles. | 846 // Checkerboard all tiles. |
| 853 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); | 847 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); |
| 854 { | 848 { |
| 855 ScopedFakeCCTiledLayerImpl layerImpl(1); | 849 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 856 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 850 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 857 } | 851 } |
| 858 ccLayerTreeHost->commitComplete(); | 852 ccLayerTreeHost->commitComplete(); |
| 859 | 853 |
| 860 // Partial update of 6 checkerboard tiles. | 854 // Partial update of 6 checkerboard tiles. |
| 861 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 855 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 862 { | 856 { |
| 863 ScopedFakeCCTiledLayerImpl layerImpl(1); | 857 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 864 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 858 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 865 updateTextures(4); | 859 EXPECT_EQ(6, m_queue.fullUploadSize()); |
| 866 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 860 EXPECT_EQ(0, m_queue.partialUploadSize()); |
| 867 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 861 updateTextures(); |
| 868 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 862 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 869 updateTextures(4); | |
| 870 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | |
| 871 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 863 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 872 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 864 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 873 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 865 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 874 } | 866 } |
| 875 ccLayerTreeHost->commitComplete(); | 867 ccLayerTreeHost->commitComplete(); |
| 876 | 868 |
| 877 // Partial update of 4 tiles. | 869 // Partial update of 4 tiles. |
| 878 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); | 870 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); |
| 879 { | 871 { |
| 880 ScopedFakeCCTiledLayerImpl layerImpl(1); | 872 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 881 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 873 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 882 updateTextures(4); | 874 EXPECT_EQ(0, m_queue.fullUploadSize()); |
| 875 EXPECT_EQ(4, m_queue.partialUploadSize()); |
| 876 updateTextures(); |
| 883 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 877 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 884 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 878 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 885 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 879 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 886 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 880 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 887 } | 881 } |
| 888 ccLayerTreeHost->commitComplete(); | 882 ccLayerTreeHost->commitComplete(); |
| 889 | 883 |
| 890 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); | 884 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 891 ccLayerTreeHost->setRootLayer(0); | 885 ccLayerTreeHost->setRootLayer(0); |
| 892 ccLayerTreeHost.clear(); | 886 ccLayerTreeHost.clear(); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 | 1337 |
| 1344 ccLayerTreeHost->setRootLayer(root); | 1338 ccLayerTreeHost->setRootLayer(root); |
| 1345 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); | 1339 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); |
| 1346 | 1340 |
| 1347 // With a huge memory limit, all layers should update and push their texture
s. | 1341 // With a huge memory limit, all layers should update and push their texture
s. |
| 1348 root->invalidateContentRect(rootRect); | 1342 root->invalidateContentRect(rootRect); |
| 1349 child->invalidateContentRect(childRect); | 1343 child->invalidateContentRect(childRect); |
| 1350 child2->invalidateContentRect(child2Rect); | 1344 child2->invalidateContentRect(child2Rect); |
| 1351 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 1345 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 1352 { | 1346 { |
| 1353 updateTextures(1000); | 1347 updateTextures(); |
| 1354 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1348 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1355 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); | 1349 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); |
| 1356 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); | 1350 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1357 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1351 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1358 | 1352 |
| 1359 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1353 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1360 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1354 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1361 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1355 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1362 | 1356 |
| 1363 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1357 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1377 ccLayerTreeHost->commitComplete(); | 1371 ccLayerTreeHost->commitComplete(); |
| 1378 | 1372 |
| 1379 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that | 1373 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that |
| 1380 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't | 1374 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't |
| 1381 // accounted for, then one of the children would fit within the memory limit
. | 1375 // accounted for, then one of the children would fit within the memory limit
. |
| 1382 root->invalidateContentRect(rootRect); | 1376 root->invalidateContentRect(rootRect); |
| 1383 child->invalidateContentRect(childRect); | 1377 child->invalidateContentRect(childRect); |
| 1384 child2->invalidateContentRect(child2Rect); | 1378 child2->invalidateContentRect(child2Rect); |
| 1385 ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); | 1379 ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); |
| 1386 { | 1380 { |
| 1387 updateTextures(1000); | 1381 updateTextures(); |
| 1388 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1382 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1389 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1383 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1390 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1384 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1391 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1385 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1392 | 1386 |
| 1393 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1387 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1394 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1388 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1395 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1389 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1396 | 1390 |
| 1397 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1391 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1412 | 1406 |
| 1413 // With a memory limit that includes only half the root layer, no contents w
ill be | 1407 // With a memory limit that includes only half the root layer, no contents w
ill be |
| 1414 // allocated. If render surface memory wasn't accounted for, there is enough
space | 1408 // allocated. If render surface memory wasn't accounted for, there is enough
space |
| 1415 // for one of the children layers, but they draw into a surface that can't b
e | 1409 // for one of the children layers, but they draw into a surface that can't b
e |
| 1416 // allocated. | 1410 // allocated. |
| 1417 root->invalidateContentRect(rootRect); | 1411 root->invalidateContentRect(rootRect); |
| 1418 child->invalidateContentRect(childRect); | 1412 child->invalidateContentRect(childRect); |
| 1419 child2->invalidateContentRect(child2Rect); | 1413 child2->invalidateContentRect(child2Rect); |
| 1420 ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); | 1414 ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); |
| 1421 { | 1415 { |
| 1422 updateTextures(1000); | 1416 updateTextures(); |
| 1423 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); | 1417 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); |
| 1424 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1418 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1425 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1419 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1426 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1420 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1427 | 1421 |
| 1428 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1422 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1429 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1423 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1430 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1424 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1431 | 1425 |
| 1432 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1426 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 updateTextures(); | 1538 updateTextures(); |
| 1545 | 1539 |
| 1546 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1540 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
| 1547 layer->setNeedsDisplayRect(layerRect); | 1541 layer->setNeedsDisplayRect(layerRect); |
| 1548 layer->update(m_queue, 0, m_stats); | 1542 layer->update(m_queue, 0, m_stats); |
| 1549 | 1543 |
| 1550 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1544 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1551 } | 1545 } |
| 1552 | 1546 |
| 1553 } // namespace | 1547 } // namespace |
| OLD | NEW |