| 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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 rootLayer->setPosition(FloatPoint(150, 150)); | 816 rootLayer->setPosition(FloatPoint(150, 150)); |
| 817 childLayer->setBounds(contentBounds); | 817 childLayer->setBounds(contentBounds); |
| 818 childLayer->setPosition(FloatPoint(150, 150)); | 818 childLayer->setPosition(FloatPoint(150, 150)); |
| 819 rootLayer->invalidateRect(contentRect); | 819 rootLayer->invalidateRect(contentRect); |
| 820 childLayer->invalidateRect(contentRect); | 820 childLayer->invalidateRect(contentRect); |
| 821 | 821 |
| 822 CCTextureUpdater updater; | 822 CCTextureUpdater updater; |
| 823 | 823 |
| 824 ccLayerTreeHost->setRootLayer(rootLayer); | 824 ccLayerTreeHost->setRootLayer(rootLayer); |
| 825 ccLayerTreeHost->setViewportSize(IntSize(300, 300)); | 825 ccLayerTreeHost->setViewportSize(IntSize(300, 300)); |
| 826 textureManager->setMaxMemoryLimitBytes(memoryLimit); | 826 ccLayerTreeHost->updateLayers(updater, memoryLimit); |
| 827 ccLayerTreeHost->updateLayers(updater); | |
| 828 | 827 |
| 829 // We'll skip the root layer. | 828 // We'll skip the root layer. |
| 830 EXPECT_TRUE(rootLayer->skipsDraw()); | 829 EXPECT_TRUE(rootLayer->skipsDraw()); |
| 831 EXPECT_FALSE(childLayer->skipsDraw()); | 830 EXPECT_FALSE(childLayer->skipsDraw()); |
| 832 | 831 |
| 833 ccLayerTreeHost->commitComplete(); | 832 ccLayerTreeHost->commitComplete(); |
| 834 textureManager->unprotectAllTextures(); // CCLayerTreeHost::commitComplete()
normally does this, but since we're mocking out the manager we have to do it. | 833 textureManager->unprotectAllTextures(); // CCLayerTreeHost::commitComplete()
normally does this, but since we're mocking out the manager we have to do it. |
| 835 | 834 |
| 836 // Remove the child layer. | 835 // Remove the child layer. |
| 837 rootLayer->removeAllChildren(); | 836 rootLayer->removeAllChildren(); |
| 838 | 837 |
| 839 ccLayerTreeHost->updateLayers(updater); | 838 ccLayerTreeHost->updateLayers(updater, memoryLimit); |
| 840 EXPECT_FALSE(rootLayer->skipsDraw()); | 839 EXPECT_FALSE(rootLayer->skipsDraw()); |
| 841 | 840 |
| 842 ccLayerTreeHost->setRootLayer(0); | 841 ccLayerTreeHost->setRootLayer(0); |
| 843 ccLayerTreeHost.clear(); | 842 ccLayerTreeHost.clear(); |
| 844 WebKit::WebCompositor::shutdown(); | 843 WebKit::WebCompositor::shutdown(); |
| 845 } | 844 } |
| 846 | 845 |
| 847 TEST(TiledLayerChromiumTest, resizeToSmaller) | 846 TEST(TiledLayerChromiumTest, resizeToSmaller) |
| 848 { | 847 { |
| 849 OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024,
60*1024*1024, 1024); | 848 OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024,
60*1024*1024, 1024); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 895 |
| 897 CCTextureUpdater updater; | 896 CCTextureUpdater updater; |
| 898 FakeTextureAllocator allocator; | 897 FakeTextureAllocator allocator; |
| 899 FakeTextureCopier copier; | 898 FakeTextureCopier copier; |
| 900 FakeTextureUploader uploader; | 899 FakeTextureUploader uploader; |
| 901 | 900 |
| 902 ccLayerTreeHost->setRootLayer(layer); | 901 ccLayerTreeHost->setRootLayer(layer); |
| 903 ccLayerTreeHost->setViewportSize(IntSize(300, 200)); | 902 ccLayerTreeHost->setViewportSize(IntSize(300, 200)); |
| 904 | 903 |
| 905 // Full update of all 6 tiles. | 904 // Full update of all 6 tiles. |
| 906 ccLayerTreeHost->updateLayers(updater); | 905 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); |
| 907 { | 906 { |
| 908 DebugScopedSetImplThread implThread; | 907 DebugScopedSetImplThread implThread; |
| 909 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 908 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 910 updater.update(0, &allocator, &copier, &uploader, 4); | 909 updater.update(0, &allocator, &copier, &uploader, 4); |
| 911 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 910 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 912 EXPECT_TRUE(updater.hasMoreUpdates()); | 911 EXPECT_TRUE(updater.hasMoreUpdates()); |
| 913 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 912 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 914 updater.update(0, &allocator, &copier, &uploader, 4); | 913 updater.update(0, &allocator, &copier, &uploader, 4); |
| 915 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 914 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 916 EXPECT_FALSE(updater.hasMoreUpdates()); | 915 EXPECT_FALSE(updater.hasMoreUpdates()); |
| 917 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 916 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 918 layer->pushPropertiesTo(layerImpl.get()); | 917 layer->pushPropertiesTo(layerImpl.get()); |
| 919 } | 918 } |
| 920 ccLayerTreeHost->commitComplete(); | 919 ccLayerTreeHost->commitComplete(); |
| 921 | 920 |
| 922 // Full update of 3 tiles and partial update of 3 tiles. | 921 // Full update of 3 tiles and partial update of 3 tiles. |
| 923 layer->invalidateRect(IntRect(0, 0, 300, 150)); | 922 layer->invalidateRect(IntRect(0, 0, 300, 150)); |
| 924 ccLayerTreeHost->updateLayers(updater); | 923 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max()); |
| 925 { | 924 { |
| 926 DebugScopedSetImplThread implThread; | 925 DebugScopedSetImplThread implThread; |
| 927 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 926 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 928 updater.update(0, &allocator, &copier, &uploader, 4); | 927 updater.update(0, &allocator, &copier, &uploader, 4); |
| 929 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | 928 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); |
| 930 EXPECT_TRUE(updater.hasMoreUpdates()); | 929 EXPECT_TRUE(updater.hasMoreUpdates()); |
| 931 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 930 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 932 updater.update(0, &allocator, &copier, &uploader, 4); | 931 updater.update(0, &allocator, &copier, &uploader, 4); |
| 933 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | 932 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); |
| 934 EXPECT_FALSE(updater.hasMoreUpdates()); | 933 EXPECT_FALSE(updater.hasMoreUpdates()); |
| 935 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 934 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 936 layer->pushPropertiesTo(layerImpl.get()); | 935 layer->pushPropertiesTo(layerImpl.get()); |
| 937 } | 936 } |
| 938 ccLayerTreeHost->commitComplete(); | 937 ccLayerTreeHost->commitComplete(); |
| 939 | 938 |
| 940 // Partial update of 6 tiles. | 939 // Partial update of 6 tiles. |
| 941 layer->invalidateRect(IntRect(50, 50, 200, 100)); | 940 layer->invalidateRect(IntRect(50, 50, 200, 100)); |
| 942 { | 941 { |
| 943 DebugScopedSetImplThread implThread; | 942 DebugScopedSetImplThread implThread; |
| 944 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 943 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 945 ccLayerTreeHost->updateLayers(updater); | 944 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max(
)); |
| 946 updater.update(0, &allocator, &copier, &uploader, 4); | 945 updater.update(0, &allocator, &copier, &uploader, 4); |
| 947 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 946 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 948 EXPECT_TRUE(updater.hasMoreUpdates()); | 947 EXPECT_TRUE(updater.hasMoreUpdates()); |
| 949 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 948 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 950 updater.update(0, &allocator, &copier, &uploader, 4); | 949 updater.update(0, &allocator, &copier, &uploader, 4); |
| 951 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 950 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 952 EXPECT_FALSE(updater.hasMoreUpdates()); | 951 EXPECT_FALSE(updater.hasMoreUpdates()); |
| 953 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 952 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 954 layer->pushPropertiesTo(layerImpl.get()); | 953 layer->pushPropertiesTo(layerImpl.get()); |
| 955 } | 954 } |
| 956 ccLayerTreeHost->commitComplete(); | 955 ccLayerTreeHost->commitComplete(); |
| 957 | 956 |
| 958 // Checkerboard all tiles. | 957 // Checkerboard all tiles. |
| 959 layer->invalidateRect(IntRect(0, 0, 300, 200)); | 958 layer->invalidateRect(IntRect(0, 0, 300, 200)); |
| 960 { | 959 { |
| 961 DebugScopedSetImplThread implThread; | 960 DebugScopedSetImplThread implThread; |
| 962 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 961 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 963 layer->pushPropertiesTo(layerImpl.get()); | 962 layer->pushPropertiesTo(layerImpl.get()); |
| 964 } | 963 } |
| 965 ccLayerTreeHost->commitComplete(); | 964 ccLayerTreeHost->commitComplete(); |
| 966 | 965 |
| 967 // Partial update of 6 checkerboard tiles. | 966 // Partial update of 6 checkerboard tiles. |
| 968 layer->invalidateRect(IntRect(50, 50, 200, 100)); | 967 layer->invalidateRect(IntRect(50, 50, 200, 100)); |
| 969 { | 968 { |
| 970 DebugScopedSetImplThread implThread; | 969 DebugScopedSetImplThread implThread; |
| 971 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 970 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 972 ccLayerTreeHost->updateLayers(updater); | 971 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max(
)); |
| 973 updater.update(0, &allocator, &copier, &uploader, 4); | 972 updater.update(0, &allocator, &copier, &uploader, 4); |
| 974 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 973 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 975 EXPECT_TRUE(updater.hasMoreUpdates()); | 974 EXPECT_TRUE(updater.hasMoreUpdates()); |
| 976 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 975 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 977 updater.update(0, &allocator, &copier, &uploader, 4); | 976 updater.update(0, &allocator, &copier, &uploader, 4); |
| 978 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 977 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 979 EXPECT_FALSE(updater.hasMoreUpdates()); | 978 EXPECT_FALSE(updater.hasMoreUpdates()); |
| 980 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 979 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 981 layer->pushPropertiesTo(layerImpl.get()); | 980 layer->pushPropertiesTo(layerImpl.get()); |
| 982 } | 981 } |
| 983 ccLayerTreeHost->commitComplete(); | 982 ccLayerTreeHost->commitComplete(); |
| 984 | 983 |
| 985 // Partial update of 4 tiles. | 984 // Partial update of 4 tiles. |
| 986 layer->invalidateRect(IntRect(50, 50, 100, 100)); | 985 layer->invalidateRect(IntRect(50, 50, 100, 100)); |
| 987 { | 986 { |
| 988 DebugScopedSetImplThread implThread; | 987 DebugScopedSetImplThread implThread; |
| 989 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); | 988 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(0))); |
| 990 ccLayerTreeHost->updateLayers(updater); | 989 ccLayerTreeHost->updateLayers(updater, std::numeric_limits<size_t>::max(
)); |
| 991 updater.update(0, &allocator, &copier, &uploader, 4); | 990 updater.update(0, &allocator, &copier, &uploader, 4); |
| 992 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 991 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 993 EXPECT_FALSE(updater.hasMoreUpdates()); | 992 EXPECT_FALSE(updater.hasMoreUpdates()); |
| 994 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 993 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 995 layer->pushPropertiesTo(layerImpl.get()); | 994 layer->pushPropertiesTo(layerImpl.get()); |
| 996 } | 995 } |
| 997 ccLayerTreeHost->commitComplete(); | 996 ccLayerTreeHost->commitComplete(); |
| 998 | 997 |
| 999 ccLayerTreeHost->setRootLayer(0); | 998 ccLayerTreeHost->setRootLayer(0); |
| 1000 ccLayerTreeHost.clear(); | 999 ccLayerTreeHost.clear(); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 | 1371 |
| 1373 // The middle tile was painted even though not invalidated. | 1372 // The middle tile was painted even though not invalidated. |
| 1374 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; | 1373 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; |
| 1375 // The pixels uploaded will not include the non-invalidated tile in the midd
le. | 1374 // The pixels uploaded will not include the non-invalidated tile in the midd
le. |
| 1376 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1375 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1377 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); | 1376 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); |
| 1378 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1377 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1379 } | 1378 } |
| 1380 | 1379 |
| 1381 } // namespace | 1380 } // namespace |
| OLD | NEW |