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/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include "cc/debug/overdraw_metrics.h" | 7 #include "cc/debug/overdraw_metrics.h" |
8 #include "cc/resources/bitmap_content_layer_updater.h" | 8 #include "cc/resources/bitmap_content_layer_updater.h" |
9 #include "cc/resources/layer_painter.h" | 9 #include "cc/resources/layer_painter.h" |
10 #include "cc/resources/prioritized_resource_manager.h" | 10 #include "cc/resources/prioritized_resource_manager.h" |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 layer->InvalidateContentRect(contentRect); | 904 layer->InvalidateContentRect(contentRect); |
905 | 905 |
906 layer_tree_host_->SetRootLayer(layer); | 906 layer_tree_host_->SetRootLayer(layer); |
907 layer_tree_host_->SetViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 907 layer_tree_host_->SetViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
908 | 908 |
909 // Full update of all 6 tiles. | 909 // Full update of all 6 tiles. |
910 layer_tree_host_->UpdateLayers(m_queue.get(), | 910 layer_tree_host_->UpdateLayers(m_queue.get(), |
911 std::numeric_limits<size_t>::max()); | 911 std::numeric_limits<size_t>::max()); |
912 { | 912 { |
913 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 913 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
914 EXPECT_EQ(6, m_queue->fullUploadSize()); | 914 EXPECT_EQ(6, m_queue->FullUploadSize()); |
915 EXPECT_EQ(0, m_queue->partialUploadSize()); | 915 EXPECT_EQ(0, m_queue->PartialUploadSize()); |
916 updateTextures(); | 916 updateTextures(); |
917 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 917 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
918 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 918 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
919 layer->fakeLayerUpdater()->clearUpdateCount(); | 919 layer->fakeLayerUpdater()->clearUpdateCount(); |
920 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 920 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
921 } | 921 } |
922 layer_tree_host_->CommitComplete(); | 922 layer_tree_host_->CommitComplete(); |
923 | 923 |
924 // Full update of 3 tiles and partial update of 3 tiles. | 924 // Full update of 3 tiles and partial update of 3 tiles. |
925 layer->InvalidateContentRect(gfx::Rect(0, 0, 300, 150)); | 925 layer->InvalidateContentRect(gfx::Rect(0, 0, 300, 150)); |
926 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); | 926 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); |
927 { | 927 { |
928 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 928 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
929 EXPECT_EQ(3, m_queue->fullUploadSize()); | 929 EXPECT_EQ(3, m_queue->FullUploadSize()); |
930 EXPECT_EQ(3, m_queue->partialUploadSize()); | 930 EXPECT_EQ(3, m_queue->PartialUploadSize()); |
931 updateTextures(); | 931 updateTextures(); |
932 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 932 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
933 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 933 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
934 layer->fakeLayerUpdater()->clearUpdateCount(); | 934 layer->fakeLayerUpdater()->clearUpdateCount(); |
935 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 935 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
936 } | 936 } |
937 layer_tree_host_->CommitComplete(); | 937 layer_tree_host_->CommitComplete(); |
938 | 938 |
939 // Partial update of 6 tiles. | 939 // Partial update of 6 tiles. |
940 layer->InvalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 940 layer->InvalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
941 { | 941 { |
942 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 942 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
943 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 943 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
944 EXPECT_EQ(2, m_queue->fullUploadSize()); | 944 EXPECT_EQ(2, m_queue->FullUploadSize()); |
945 EXPECT_EQ(4, m_queue->partialUploadSize()); | 945 EXPECT_EQ(4, m_queue->PartialUploadSize()); |
946 updateTextures(); | 946 updateTextures(); |
947 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 947 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
948 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 948 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
949 layer->fakeLayerUpdater()->clearUpdateCount(); | 949 layer->fakeLayerUpdater()->clearUpdateCount(); |
950 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 950 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
951 } | 951 } |
952 layer_tree_host_->CommitComplete(); | 952 layer_tree_host_->CommitComplete(); |
953 | 953 |
954 // Checkerboard all tiles. | 954 // Checkerboard all tiles. |
955 layer->InvalidateContentRect(gfx::Rect(0, 0, 300, 200)); | 955 layer->InvalidateContentRect(gfx::Rect(0, 0, 300, 200)); |
956 { | 956 { |
957 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 957 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
958 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 958 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
959 } | 959 } |
960 layer_tree_host_->CommitComplete(); | 960 layer_tree_host_->CommitComplete(); |
961 | 961 |
962 // Partial update of 6 checkerboard tiles. | 962 // Partial update of 6 checkerboard tiles. |
963 layer->InvalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 963 layer->InvalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
964 { | 964 { |
965 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 965 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
966 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 966 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
967 EXPECT_EQ(6, m_queue->fullUploadSize()); | 967 EXPECT_EQ(6, m_queue->FullUploadSize()); |
968 EXPECT_EQ(0, m_queue->partialUploadSize()); | 968 EXPECT_EQ(0, m_queue->PartialUploadSize()); |
969 updateTextures(); | 969 updateTextures(); |
970 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 970 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
971 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 971 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
972 layer->fakeLayerUpdater()->clearUpdateCount(); | 972 layer->fakeLayerUpdater()->clearUpdateCount(); |
973 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 973 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
974 } | 974 } |
975 layer_tree_host_->CommitComplete(); | 975 layer_tree_host_->CommitComplete(); |
976 | 976 |
977 // Partial update of 4 tiles. | 977 // Partial update of 4 tiles. |
978 layer->InvalidateContentRect(gfx::Rect(50, 50, 100, 100)); | 978 layer->InvalidateContentRect(gfx::Rect(50, 50, 100, 100)); |
979 { | 979 { |
980 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); | 980 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), 1)); |
981 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); | 981 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t
>::max()); |
982 EXPECT_EQ(0, m_queue->fullUploadSize()); | 982 EXPECT_EQ(0, m_queue->FullUploadSize()); |
983 EXPECT_EQ(4, m_queue->partialUploadSize()); | 983 EXPECT_EQ(4, m_queue->PartialUploadSize()); |
984 updateTextures(); | 984 updateTextures(); |
985 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); | 985 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); |
986 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 986 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
987 layer->fakeLayerUpdater()->clearUpdateCount(); | 987 layer->fakeLayerUpdater()->clearUpdateCount(); |
988 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 988 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
989 } | 989 } |
990 layer_tree_host_->CommitComplete(); | 990 layer_tree_host_->CommitComplete(); |
991 | 991 |
992 resourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(),
m_resourceProvider.get()); | 992 resourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(),
m_resourceProvider.get()); |
993 layer_tree_host_->SetRootLayer(NULL); | 993 layer_tree_host_->SetRootLayer(NULL); |
994 } | 994 } |
995 | 995 |
996 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) | 996 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 // With a huge memory limit, all layers should update and push their texture
s. | 1464 // With a huge memory limit, all layers should update and push their texture
s. |
1465 root->InvalidateContentRect(rootRect); | 1465 root->InvalidateContentRect(rootRect); |
1466 child->InvalidateContentRect(childRect); | 1466 child->InvalidateContentRect(childRect); |
1467 child2->InvalidateContentRect(child2Rect); | 1467 child2->InvalidateContentRect(child2Rect); |
1468 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); | 1468 layer_tree_host_->UpdateLayers(m_queue.get(), std::numeric_limits<size_t>::m
ax()); |
1469 { | 1469 { |
1470 updateTextures(); | 1470 updateTextures(); |
1471 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1471 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
1472 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); | 1472 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); |
1473 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); | 1473 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); |
1474 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1474 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
1475 | 1475 |
1476 root->fakeLayerUpdater()->clearUpdateCount(); | 1476 root->fakeLayerUpdater()->clearUpdateCount(); |
1477 child->fakeLayerUpdater()->clearUpdateCount(); | 1477 child->fakeLayerUpdater()->clearUpdateCount(); |
1478 child2->fakeLayerUpdater()->clearUpdateCount(); | 1478 child2->fakeLayerUpdater()->clearUpdateCount(); |
1479 | 1479 |
1480 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); | 1480 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
1481 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); | 1481 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
1482 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); | 1482 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
1483 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1483 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1484 layerPushPropertiesTo(child.get(), childImpl.get()); | 1484 layerPushPropertiesTo(child.get(), childImpl.get()); |
(...skipping 13 matching lines...) Expand all Loading... |
1498 // accounted for, then one of the children would fit within the memory limit
. | 1498 // accounted for, then one of the children would fit within the memory limit
. |
1499 root->InvalidateContentRect(rootRect); | 1499 root->InvalidateContentRect(rootRect); |
1500 child->InvalidateContentRect(childRect); | 1500 child->InvalidateContentRect(childRect); |
1501 child2->InvalidateContentRect(child2Rect); | 1501 child2->InvalidateContentRect(child2Rect); |
1502 layer_tree_host_->UpdateLayers(m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100)
* 4); | 1502 layer_tree_host_->UpdateLayers(m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100)
* 4); |
1503 { | 1503 { |
1504 updateTextures(); | 1504 updateTextures(); |
1505 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1505 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
1506 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1506 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
1507 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1507 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
1508 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1508 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
1509 | 1509 |
1510 root->fakeLayerUpdater()->clearUpdateCount(); | 1510 root->fakeLayerUpdater()->clearUpdateCount(); |
1511 child->fakeLayerUpdater()->clearUpdateCount(); | 1511 child->fakeLayerUpdater()->clearUpdateCount(); |
1512 child2->fakeLayerUpdater()->clearUpdateCount(); | 1512 child2->fakeLayerUpdater()->clearUpdateCount(); |
1513 | 1513 |
1514 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); | 1514 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
1515 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); | 1515 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
1516 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); | 1516 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
1517 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1517 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1518 layerPushPropertiesTo(child.get(), childImpl.get()); | 1518 layerPushPropertiesTo(child.get(), childImpl.get()); |
(...skipping 14 matching lines...) Expand all Loading... |
1533 // allocated. | 1533 // allocated. |
1534 root->InvalidateContentRect(rootRect); | 1534 root->InvalidateContentRect(rootRect); |
1535 child->InvalidateContentRect(childRect); | 1535 child->InvalidateContentRect(childRect); |
1536 child2->InvalidateContentRect(child2Rect); | 1536 child2->InvalidateContentRect(child2Rect); |
1537 layer_tree_host_->UpdateLayers(m_queue.get(), (3 * 1) * (100 * 100) * 4); | 1537 layer_tree_host_->UpdateLayers(m_queue.get(), (3 * 1) * (100 * 100) * 4); |
1538 { | 1538 { |
1539 updateTextures(); | 1539 updateTextures(); |
1540 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); | 1540 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); |
1541 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1541 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
1542 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1542 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
1543 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1543 EXPECT_FALSE(m_queue->HasMoreUpdates()); |
1544 | 1544 |
1545 root->fakeLayerUpdater()->clearUpdateCount(); | 1545 root->fakeLayerUpdater()->clearUpdateCount(); |
1546 child->fakeLayerUpdater()->clearUpdateCount(); | 1546 child->fakeLayerUpdater()->clearUpdateCount(); |
1547 child2->fakeLayerUpdater()->clearUpdateCount(); | 1547 child2->fakeLayerUpdater()->clearUpdateCount(); |
1548 | 1548 |
1549 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); | 1549 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL
ayerImpl(m_hostImpl->active_tree(), root->id())); |
1550 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); | 1550 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled
LayerImpl(m_hostImpl->active_tree(), child->id())); |
1551 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); | 1551 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile
dLayerImpl(m_hostImpl->active_tree(), child2->id())); |
1552 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1552 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1553 layerPushPropertiesTo(child.get(), childImpl.get()); | 1553 layerPushPropertiesTo(child.get(), childImpl.get()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 | 1662 |
1663 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1663 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
1664 layer->SetNeedsDisplayRect(layerRect); | 1664 layer->SetNeedsDisplayRect(layerRect); |
1665 layer->Update(m_queue.get(), 0, NULL); | 1665 layer->Update(m_queue.get(), 0, NULL); |
1666 | 1666 |
1667 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1667 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1668 } | 1668 } |
1669 | 1669 |
1670 } // namespace | 1670 } // namespace |
1671 } // namespace cc | 1671 } // namespace cc |
OLD | NEW |