| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 IntRect m_layerClipRectInTarget; | 47 IntRect m_layerClipRectInTarget; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class TiledLayerChromiumTest : public testing::Test { | 50 class TiledLayerChromiumTest : public testing::Test { |
| 51 public: | 51 public: |
| 52 TiledLayerChromiumTest() | 52 TiledLayerChromiumTest() |
| 53 : m_compositorInitializer(0) | 53 : m_compositorInitializer(0) |
| 54 , m_context(WebKit::createFakeCCGraphicsContext()) | 54 , m_context(WebKit::createFakeCCGraphicsContext()) |
| 55 , m_queue(adoptPtr(new CCTextureUpdateQueue)) |
| 55 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) | 56 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) |
| 56 , m_occlusion(0) | 57 , m_occlusion(0) |
| 57 { | 58 { |
| 58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 59 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 59 m_resourceProvider = CCResourceProvider::create(m_context.get(), Unthrot
tledUploader); | 60 m_resourceProvider = CCResourceProvider::create(m_context.get(), Unthrot
tledUploader); |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual ~TiledLayerChromiumTest() | 63 virtual ~TiledLayerChromiumTest() |
| 63 { | 64 { |
| 64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.
get()); | 65 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.
get()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 92 FakeCCTiledLayerImpl* m_layerImpl; | 93 FakeCCTiledLayerImpl* m_layerImpl; |
| 93 }; | 94 }; |
| 94 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage
r, CCResourceProvider* resourceProvider) | 95 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage
r, CCResourceProvider* resourceProvider) |
| 95 { | 96 { |
| 96 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 97 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 97 textureManager->clearAllMemory(resourceProvider); | 98 textureManager->clearAllMemory(resourceProvider); |
| 98 } | 99 } |
| 99 void updateTextures() | 100 void updateTextures() |
| 100 { | 101 { |
| 101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 102 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 102 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_u
ploader, &m_queue); | 103 ASSERT(m_queue); |
| 104 OwnPtr<CCTextureUpdateController> updateController = |
| 105 CCTextureUpdateController::create( |
| 106 NULL, |
| 107 CCProxy::implThread(), |
| 108 m_queue.release(), |
| 109 m_resourceProvider.get(), |
| 110 &m_uploader); |
| 111 updateController->finalize(); |
| 112 m_queue = adoptPtr(new CCTextureUpdateQueue); |
| 103 } | 113 } |
| 104 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm
pl* layerImpl) | 114 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm
pl* layerImpl) |
| 105 { | 115 { |
| 106 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; | 116 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 107 layer->pushPropertiesTo(layerImpl); | 117 layer->pushPropertiesTo(layerImpl); |
| 108 } | 118 } |
| 109 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl
uded) | 119 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl
uded) |
| 110 { | 120 { |
| 111 DebugScopedSetMainThread mainThread; | 121 DebugScopedSetMainThread mainThread; |
| 112 layer->update(m_queue, occluded, m_stats); | 122 layer->update(*m_queue.get(), occluded, m_stats); |
| 113 } | 123 } |
| 114 | 124 |
| 115 bool updateAndPush(FakeTiledLayerChromium* layer1, | 125 bool updateAndPush(FakeTiledLayerChromium* layer1, |
| 116 FakeCCTiledLayerImpl* layerImpl1, | 126 FakeCCTiledLayerImpl* layerImpl1, |
| 117 FakeTiledLayerChromium* layer2 = 0, | 127 FakeTiledLayerChromium* layer2 = 0, |
| 118 FakeCCTiledLayerImpl* layerImpl2 = 0) | 128 FakeCCTiledLayerImpl* layerImpl2 = 0) |
| 119 { | 129 { |
| 120 // Get textures | 130 // Get textures |
| 121 m_textureManager->clearPriorities(); | 131 m_textureManager->clearPriorities(); |
| 122 if (layer1) | 132 if (layer1) |
| 123 layer1->setTexturePriorities(m_priorityCalculator); | 133 layer1->setTexturePriorities(m_priorityCalculator); |
| 124 if (layer2) | 134 if (layer2) |
| 125 layer2->setTexturePriorities(m_priorityCalculator); | 135 layer2->setTexturePriorities(m_priorityCalculator); |
| 126 m_textureManager->prioritizeTextures(); | 136 m_textureManager->prioritizeTextures(); |
| 127 | 137 |
| 128 // Update content | 138 // Update content |
| 129 if (layer1) | 139 if (layer1) |
| 130 layer1->update(m_queue, m_occlusion, m_stats); | 140 layer1->update(*m_queue.get(), m_occlusion, m_stats); |
| 131 if (layer2) | 141 if (layer2) |
| 132 layer2->update(m_queue, m_occlusion, m_stats); | 142 layer2->update(*m_queue.get(), m_occlusion, m_stats); |
| 133 | 143 |
| 134 bool needsUpdate = false; | 144 bool needsUpdate = false; |
| 135 if (layer1) | 145 if (layer1) |
| 136 needsUpdate |= layer1->needsIdlePaint(); | 146 needsUpdate |= layer1->needsIdlePaint(); |
| 137 if (layer2) | 147 if (layer2) |
| 138 needsUpdate |= layer2->needsIdlePaint(); | 148 needsUpdate |= layer2->needsIdlePaint(); |
| 139 | 149 |
| 140 // Update textures and push. | 150 // Update textures and push. |
| 141 updateTextures(); | 151 updateTextures(); |
| 142 if (layer1) | 152 if (layer1) |
| 143 layerPushPropertiesTo(layer1, layerImpl1); | 153 layerPushPropertiesTo(layer1, layerImpl1); |
| 144 if (layer2) | 154 if (layer2) |
| 145 layerPushPropertiesTo(layer2, layerImpl2); | 155 layerPushPropertiesTo(layer2, layerImpl2); |
| 146 | 156 |
| 147 return needsUpdate; | 157 return needsUpdate; |
| 148 } | 158 } |
| 149 | 159 |
| 150 public: | 160 public: |
| 151 WebKitTests::WebCompositorInitializer m_compositorInitializer; | 161 WebKitTests::WebCompositorInitializer m_compositorInitializer; |
| 152 OwnPtr<CCGraphicsContext> m_context; | 162 OwnPtr<CCGraphicsContext> m_context; |
| 153 OwnPtr<CCResourceProvider> m_resourceProvider; | 163 OwnPtr<CCResourceProvider> m_resourceProvider; |
| 154 CCTextureUpdateQueue m_queue; | 164 OwnPtr<CCTextureUpdateQueue> m_queue; |
| 155 CCRenderingStats m_stats; | 165 CCRenderingStats m_stats; |
| 156 FakeTextureUploader m_uploader; | 166 FakeTextureUploader m_uploader; |
| 157 CCPriorityCalculator m_priorityCalculator; | 167 CCPriorityCalculator m_priorityCalculator; |
| 158 OwnPtr<CCPrioritizedTextureManager> m_textureManager; | 168 OwnPtr<CCPrioritizedTextureManager> m_textureManager; |
| 159 TestCCOcclusionTracker* m_occlusion; | 169 TestCCOcclusionTracker* m_occlusion; |
| 160 }; | 170 }; |
| 161 | 171 |
| 162 TEST_F(TiledLayerChromiumTest, pushDirtyTiles) | 172 TEST_F(TiledLayerChromiumTest, pushDirtyTiles) |
| 163 { | 173 { |
| 164 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 174 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 layer->setDrawTransformIsAnimating(true); | 472 layer->setDrawTransformIsAnimating(true); |
| 463 layer->setBounds(contentBounds); | 473 layer->setBounds(contentBounds); |
| 464 layer->setVisibleContentRect(visibleRect); | 474 layer->setVisibleContentRect(visibleRect); |
| 465 layer->invalidateContentRect(contentRect); | 475 layer->invalidateContentRect(contentRect); |
| 466 layer->setLayerTreeHost(ccLayerTreeHost.get()); | 476 layer->setLayerTreeHost(ccLayerTreeHost.get()); |
| 467 | 477 |
| 468 // The layer should paint it's entire contents on the first paint | 478 // The layer should paint it's entire contents on the first paint |
| 469 // if it is close to the viewport size and has the available memory. | 479 // if it is close to the viewport size and has the available memory. |
| 470 layer->setTexturePriorities(m_priorityCalculator); | 480 layer->setTexturePriorities(m_priorityCalculator); |
| 471 m_textureManager->prioritizeTextures(); | 481 m_textureManager->prioritizeTextures(); |
| 472 layer->update(m_queue, 0, m_stats); | 482 layer->update(*m_queue.get(), 0, m_stats); |
| 473 updateTextures(); | 483 updateTextures(); |
| 474 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 484 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 475 | 485 |
| 476 // We should have all the tiles for the small animated layer. | 486 // We should have all the tiles for the small animated layer. |
| 477 // We should still have the visible tiles when we didn't | 487 // We should still have the visible tiles when we didn't |
| 478 // have enough memory for all the tiles. | 488 // have enough memory for all the tiles. |
| 479 if (!runOutOfMemory[i]) { | 489 if (!runOutOfMemory[i]) { |
| 480 for (int i = 0; i < 4; ++i) { | 490 for (int i = 0; i < 4; ++i) { |
| 481 for (int j = 0; j < 4; ++j) | 491 for (int j = 0; j < 4; ++j) |
| 482 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); | 492 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 layer->setBounds(layerBounds.size()); | 626 layer->setBounds(layerBounds.size()); |
| 617 layer->setContentBounds(contentBounds.size()); | 627 layer->setContentBounds(contentBounds.size()); |
| 618 layer->setVisibleContentRect(contentBounds); | 628 layer->setVisibleContentRect(contentBounds); |
| 619 | 629 |
| 620 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. | 630 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. |
| 621 // However, it should still be in layer space, not content space. | 631 // However, it should still be in layer space, not content space. |
| 622 layer->invalidateContentRect(contentBounds); | 632 layer->invalidateContentRect(contentBounds); |
| 623 | 633 |
| 624 layer->setTexturePriorities(m_priorityCalculator); | 634 layer->setTexturePriorities(m_priorityCalculator); |
| 625 m_textureManager->prioritizeTextures(); | 635 m_textureManager->prioritizeTextures(); |
| 626 layer->update(m_queue, 0, m_stats); | 636 layer->update(*m_queue.get(), 0, m_stats); |
| 627 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); | 637 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); |
| 628 updateTextures(); | 638 updateTextures(); |
| 629 | 639 |
| 630 // After the tiles are updated once, another invalidate only needs to update
the bounds of the layer. | 640 // After the tiles are updated once, another invalidate only needs to update
the bounds of the layer. |
| 631 layer->setTexturePriorities(m_priorityCalculator); | 641 layer->setTexturePriorities(m_priorityCalculator); |
| 632 m_textureManager->prioritizeTextures(); | 642 m_textureManager->prioritizeTextures(); |
| 633 layer->invalidateContentRect(contentBounds); | 643 layer->invalidateContentRect(contentBounds); |
| 634 layer->update(m_queue, 0, m_stats); | 644 layer->update(*m_queue.get(), 0, m_stats); |
| 635 EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); | 645 EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); |
| 636 updateTextures(); | 646 updateTextures(); |
| 637 | 647 |
| 638 // Partial re-paint should also be represented by the updateRect in layer sp
ace, not content space. | 648 // Partial re-paint should also be represented by the updateRect in layer sp
ace, not content space. |
| 639 IntRect partialDamage(30, 100, 10, 10); | 649 IntRect partialDamage(30, 100, 10, 10); |
| 640 layer->invalidateContentRect(partialDamage); | 650 layer->invalidateContentRect(partialDamage); |
| 641 layer->setTexturePriorities(m_priorityCalculator); | 651 layer->setTexturePriorities(m_priorityCalculator); |
| 642 m_textureManager->prioritizeTextures(); | 652 m_textureManager->prioritizeTextures(); |
| 643 layer->update(m_queue, 0, m_stats); | 653 layer->update(*m_queue.get(), 0, m_stats); |
| 644 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); | 654 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); |
| 645 } | 655 } |
| 646 | 656 |
| 647 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) | 657 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) |
| 648 { | 658 { |
| 649 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 659 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 650 ScopedFakeCCTiledLayerImpl layerImpl(1); | 660 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 651 | 661 |
| 652 // Create a layer with one tile. | 662 // Create a layer with one tile. |
| 653 layer->setBounds(IntSize(100, 100)); | 663 layer->setBounds(IntSize(100, 100)); |
| 654 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 664 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); |
| 655 | 665 |
| 656 // Invalidate the entire layer. | 666 // Invalidate the entire layer. |
| 657 layer->setNeedsDisplay(); | 667 layer->setNeedsDisplay(); |
| 658 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 668 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); |
| 659 | 669 |
| 660 // Push the tiles to the impl side and check that there is exactly one. | 670 // Push the tiles to the impl side and check that there is exactly one. |
| 661 layer->setTexturePriorities(m_priorityCalculator); | 671 layer->setTexturePriorities(m_priorityCalculator); |
| 662 m_textureManager->prioritizeTextures(); | 672 m_textureManager->prioritizeTextures(); |
| 663 layer->update(m_queue, 0, m_stats); | 673 layer->update(*m_queue.get(), 0, m_stats); |
| 664 updateTextures(); | 674 updateTextures(); |
| 665 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 675 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 666 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 676 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 667 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 677 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 668 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); | 678 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); |
| 669 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); | 679 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); |
| 670 | 680 |
| 671 // Change the contents scale and verify that the content rectangle requiring
painting | 681 // Change the contents scale and verify that the content rectangle requiring
painting |
| 672 // is not scaled. | 682 // is not scaled. |
| 673 layer->setContentsScale(2); | 683 layer->setContentsScale(2); |
| 674 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); | 684 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); |
| 675 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 685 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); |
| 676 | 686 |
| 677 // The impl side should get 2x2 tiles now. | 687 // The impl side should get 2x2 tiles now. |
| 678 layer->setTexturePriorities(m_priorityCalculator); | 688 layer->setTexturePriorities(m_priorityCalculator); |
| 679 m_textureManager->prioritizeTextures(); | 689 m_textureManager->prioritizeTextures(); |
| 680 layer->update(m_queue, 0, m_stats); | 690 layer->update(*m_queue.get(), 0, m_stats); |
| 681 updateTextures(); | 691 updateTextures(); |
| 682 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 692 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 683 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 693 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 684 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 694 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 685 EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); | 695 EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); |
| 686 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); | 696 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); |
| 687 | 697 |
| 688 // Invalidate the entire layer again, but do not paint. All tiles should be
gone now from the | 698 // Invalidate the entire layer again, but do not paint. All tiles should be
gone now from the |
| 689 // impl side. | 699 // impl side. |
| 690 layer->setNeedsDisplay(); | 700 layer->setNeedsDisplay(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 720 rootLayer->setPosition(FloatPoint(0, 0)); | 730 rootLayer->setPosition(FloatPoint(0, 0)); |
| 721 childLayer->setBounds(contentBounds); | 731 childLayer->setBounds(contentBounds); |
| 722 childLayer->setVisibleContentRect(contentRect); | 732 childLayer->setVisibleContentRect(contentRect); |
| 723 childLayer->setPosition(FloatPoint(0, 0)); | 733 childLayer->setPosition(FloatPoint(0, 0)); |
| 724 rootLayer->invalidateContentRect(contentRect); | 734 rootLayer->invalidateContentRect(contentRect); |
| 725 childLayer->invalidateContentRect(contentRect); | 735 childLayer->invalidateContentRect(contentRect); |
| 726 | 736 |
| 727 ccLayerTreeHost->setRootLayer(rootLayer); | 737 ccLayerTreeHost->setRootLayer(rootLayer); |
| 728 ccLayerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300)); | 738 ccLayerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300)); |
| 729 | 739 |
| 730 ccLayerTreeHost->updateLayers(m_queue, memoryLimit); | 740 ccLayerTreeHost->updateLayers(*m_queue.get(), memoryLimit); |
| 731 | 741 |
| 732 // We'll skip the root layer. | 742 // We'll skip the root layer. |
| 733 EXPECT_TRUE(rootLayer->skipsDraw()); | 743 EXPECT_TRUE(rootLayer->skipsDraw()); |
| 734 EXPECT_FALSE(childLayer->skipsDraw()); | 744 EXPECT_FALSE(childLayer->skipsDraw()); |
| 735 | 745 |
| 736 ccLayerTreeHost->commitComplete(); | 746 ccLayerTreeHost->commitComplete(); |
| 737 | 747 |
| 738 // Remove the child layer. | 748 // Remove the child layer. |
| 739 rootLayer->removeAllChildren(); | 749 rootLayer->removeAllChildren(); |
| 740 | 750 |
| 741 ccLayerTreeHost->updateLayers(m_queue, memoryLimit); | 751 ccLayerTreeHost->updateLayers(*m_queue.get(), memoryLimit); |
| 742 EXPECT_FALSE(rootLayer->skipsDraw()); | 752 EXPECT_FALSE(rootLayer->skipsDraw()); |
| 743 | 753 |
| 744 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); | 754 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 745 ccLayerTreeHost->setRootLayer(0); | 755 ccLayerTreeHost->setRootLayer(0); |
| 746 ccLayerTreeHost.clear(); | 756 ccLayerTreeHost.clear(); |
| 747 } | 757 } |
| 748 | 758 |
| 749 TEST_F(TiledLayerChromiumTest, resizeToSmaller) | 759 TEST_F(TiledLayerChromiumTest, resizeToSmaller) |
| 750 { | 760 { |
| 751 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 761 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 752 | 762 |
| 753 layer->setBounds(IntSize(700, 700)); | 763 layer->setBounds(IntSize(700, 700)); |
| 754 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); | 764 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); |
| 755 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); | 765 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); |
| 756 | 766 |
| 757 layer->setTexturePriorities(m_priorityCalculator); | 767 layer->setTexturePriorities(m_priorityCalculator); |
| 758 m_textureManager->prioritizeTextures(); | 768 m_textureManager->prioritizeTextures(); |
| 759 layer->update(m_queue, 0, m_stats); | 769 layer->update(*m_queue.get(), 0, m_stats); |
| 760 | 770 |
| 761 layer->setBounds(IntSize(200, 200)); | 771 layer->setBounds(IntSize(200, 200)); |
| 762 layer->invalidateContentRect(IntRect(0, 0, 200, 200)); | 772 layer->invalidateContentRect(IntRect(0, 0, 200, 200)); |
| 763 } | 773 } |
| 764 | 774 |
| 765 TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) | 775 TEST_F(TiledLayerChromiumTest, hugeLayerUpdateCrash) |
| 766 { | 776 { |
| 767 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 777 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 768 | 778 |
| 769 int size = 1 << 30; | 779 int size = 1 << 30; |
| 770 layer->setBounds(IntSize(size, size)); | 780 layer->setBounds(IntSize(size, size)); |
| 771 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); | 781 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); |
| 772 layer->invalidateContentRect(IntRect(0, 0, size, size)); | 782 layer->invalidateContentRect(IntRect(0, 0, size, size)); |
| 773 | 783 |
| 774 // Ensure no crash for bounds where size * size would overflow an int. | 784 // Ensure no crash for bounds where size * size would overflow an int. |
| 775 layer->setTexturePriorities(m_priorityCalculator); | 785 layer->setTexturePriorities(m_priorityCalculator); |
| 776 m_textureManager->prioritizeTextures(); | 786 m_textureManager->prioritizeTextures(); |
| 777 layer->update(m_queue, 0, m_stats); | 787 layer->update(*m_queue.get(), 0, m_stats); |
| 778 } | 788 } |
| 779 | 789 |
| 780 TEST_F(TiledLayerChromiumTest, partialUpdates) | 790 TEST_F(TiledLayerChromiumTest, partialUpdates) |
| 781 { | 791 { |
| 782 CCLayerTreeSettings settings; | 792 CCLayerTreeSettings settings; |
| 783 settings.maxPartialTextureUpdates = 4; | 793 settings.maxPartialTextureUpdates = 4; |
| 784 | 794 |
| 785 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; | 795 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; |
| 786 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); | 796 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); |
| 787 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); | 797 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); |
| 788 | 798 |
| 789 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 799 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
| 790 IntSize contentBounds(300, 200); | 800 IntSize contentBounds(300, 200); |
| 791 IntRect contentRect(IntPoint::zero(), contentBounds); | 801 IntRect contentRect(IntPoint::zero(), contentBounds); |
| 792 | 802 |
| 793 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(c
cLayerTreeHost->contentsTextureManager())); | 803 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(c
cLayerTreeHost->contentsTextureManager())); |
| 794 layer->setBounds(contentBounds); | 804 layer->setBounds(contentBounds); |
| 795 layer->setPosition(FloatPoint(0, 0)); | 805 layer->setPosition(FloatPoint(0, 0)); |
| 796 layer->setVisibleContentRect(contentRect); | 806 layer->setVisibleContentRect(contentRect); |
| 797 layer->invalidateContentRect(contentRect); | 807 layer->invalidateContentRect(contentRect); |
| 798 | 808 |
| 799 ccLayerTreeHost->setRootLayer(layer); | 809 ccLayerTreeHost->setRootLayer(layer); |
| 800 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); | 810 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); |
| 801 | 811 |
| 802 // Full update of all 6 tiles. | 812 // Full update of all 6 tiles. |
| 803 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 813 ccLayerTreeHost->updateLayers( |
| 814 *m_queue.get(), std::numeric_limits<size_t>::max()); |
| 804 { | 815 { |
| 805 ScopedFakeCCTiledLayerImpl layerImpl(1); | 816 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 806 EXPECT_EQ(6, m_queue.fullUploadSize()); | 817 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 807 EXPECT_EQ(0, m_queue.partialUploadSize()); | 818 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 808 updateTextures(); | 819 updateTextures(); |
| 809 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); | 820 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 810 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 821 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 811 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 822 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 812 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 823 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 813 } | 824 } |
| 814 ccLayerTreeHost->commitComplete(); | 825 ccLayerTreeHost->commitComplete(); |
| 815 | 826 |
| 816 // Full update of 3 tiles and partial update of 3 tiles. | 827 // Full update of 3 tiles and partial update of 3 tiles. |
| 817 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); | 828 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); |
| 818 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 829 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m
ax()); |
| 819 { | 830 { |
| 820 ScopedFakeCCTiledLayerImpl layerImpl(1); | 831 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 821 EXPECT_EQ(3, m_queue.fullUploadSize()); | 832 EXPECT_EQ(3, m_queue->fullUploadSize()); |
| 822 EXPECT_EQ(3, m_queue.partialUploadSize()); | 833 EXPECT_EQ(3, m_queue->partialUploadSize()); |
| 823 updateTextures(); | 834 updateTextures(); |
| 824 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); | 835 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 825 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 836 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 826 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 837 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 827 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 838 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 828 } | 839 } |
| 829 ccLayerTreeHost->commitComplete(); | 840 ccLayerTreeHost->commitComplete(); |
| 830 | 841 |
| 831 // Partial update of 6 tiles. | 842 // Partial update of 6 tiles. |
| 832 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 843 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 833 { | 844 { |
| 834 ScopedFakeCCTiledLayerImpl layerImpl(1); | 845 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 835 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 846 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 836 EXPECT_EQ(2, m_queue.fullUploadSize()); | 847 EXPECT_EQ(2, m_queue->fullUploadSize()); |
| 837 EXPECT_EQ(4, m_queue.partialUploadSize()); | 848 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 838 updateTextures(); | 849 updateTextures(); |
| 839 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); | 850 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 840 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 851 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 841 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 852 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 842 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 853 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 843 } | 854 } |
| 844 ccLayerTreeHost->commitComplete(); | 855 ccLayerTreeHost->commitComplete(); |
| 845 | 856 |
| 846 // Checkerboard all tiles. | 857 // Checkerboard all tiles. |
| 847 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); | 858 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); |
| 848 { | 859 { |
| 849 ScopedFakeCCTiledLayerImpl layerImpl(1); | 860 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 850 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 861 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 851 } | 862 } |
| 852 ccLayerTreeHost->commitComplete(); | 863 ccLayerTreeHost->commitComplete(); |
| 853 | 864 |
| 854 // Partial update of 6 checkerboard tiles. | 865 // Partial update of 6 checkerboard tiles. |
| 855 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 866 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 856 { | 867 { |
| 857 ScopedFakeCCTiledLayerImpl layerImpl(1); | 868 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 858 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 869 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 859 EXPECT_EQ(6, m_queue.fullUploadSize()); | 870 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 860 EXPECT_EQ(0, m_queue.partialUploadSize()); | 871 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 861 updateTextures(); | 872 updateTextures(); |
| 862 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); | 873 EXPECT_EQ(6, layer->fakeLayerTextureUpdater()->updateCount()); |
| 863 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 874 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 864 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 875 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 865 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 876 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 866 } | 877 } |
| 867 ccLayerTreeHost->commitComplete(); | 878 ccLayerTreeHost->commitComplete(); |
| 868 | 879 |
| 869 // Partial update of 4 tiles. | 880 // Partial update of 4 tiles. |
| 870 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); | 881 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); |
| 871 { | 882 { |
| 872 ScopedFakeCCTiledLayerImpl layerImpl(1); | 883 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 873 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 884 ccLayerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
| 874 EXPECT_EQ(0, m_queue.fullUploadSize()); | 885 EXPECT_EQ(0, m_queue->fullUploadSize()); |
| 875 EXPECT_EQ(4, m_queue.partialUploadSize()); | 886 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 876 updateTextures(); | 887 updateTextures(); |
| 877 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 888 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 878 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 889 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 879 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 890 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 880 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 891 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 881 } | 892 } |
| 882 ccLayerTreeHost->commitComplete(); | 893 ccLayerTreeHost->commitComplete(); |
| 883 | 894 |
| 884 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); | 895 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 885 ccLayerTreeHost->setRootLayer(0); | 896 ccLayerTreeHost->setRootLayer(0); |
| 886 ccLayerTreeHost.clear(); | 897 ccLayerTreeHost.clear(); |
| 887 } | 898 } |
| 888 | 899 |
| 889 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) | 900 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) |
| 890 { | 901 { |
| 891 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 902 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 892 | 903 |
| 893 // The tile size is 100x100, so this invalidates and then paints two tiles. | 904 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 894 layer->setBounds(IntSize(100, 200)); | 905 layer->setBounds(IntSize(100, 200)); |
| 895 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); | 906 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); |
| 896 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 907 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 897 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 908 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); |
| 898 | 909 |
| 899 layer->setTexturePriorities(m_priorityCalculator); | 910 layer->setTexturePriorities(m_priorityCalculator); |
| 900 m_textureManager->prioritizeTextures(); | 911 m_textureManager->prioritizeTextures(); |
| 901 layer->update(m_queue, 0, m_stats); | 912 layer->update(*m_queue.get(), 0, m_stats); |
| 902 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 913 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 903 } | 914 } |
| 904 | 915 |
| 905 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) | 916 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion) |
| 906 { | 917 { |
| 907 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 918 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 908 TestCCOcclusionTracker occluded; | 919 TestCCOcclusionTracker occluded; |
| 909 | 920 |
| 910 // The tile size is 100x100. | 921 // The tile size is 100x100. |
| 911 | 922 |
| 912 layer->setBounds(IntSize(600, 600)); | 923 layer->setBounds(IntSize(600, 600)); |
| 913 | 924 |
| 914 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 925 occluded.setOcclusion(IntRect(200, 200, 300, 100)); |
| 915 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 926 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 916 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 927 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 917 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 928 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 918 | 929 |
| 919 layer->setTexturePriorities(m_priorityCalculator); | 930 layer->setTexturePriorities(m_priorityCalculator); |
| 920 m_textureManager->prioritizeTextures(); | 931 m_textureManager->prioritizeTextures(); |
| 921 layer->update(m_queue, &occluded, m_stats); | 932 layer->update(*m_queue.get(), &occluded, m_stats); |
| 922 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 933 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 923 | 934 |
| 924 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 935 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 925 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 936 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
| 926 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 937 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 927 | 938 |
| 928 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 939 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 929 layer->setTexturePriorities(m_priorityCalculator); | 940 layer->setTexturePriorities(m_priorityCalculator); |
| 930 m_textureManager->prioritizeTextures(); | 941 m_textureManager->prioritizeTextures(); |
| 931 | 942 |
| 932 occluded.setOcclusion(IntRect(250, 200, 300, 100)); | 943 occluded.setOcclusion(IntRect(250, 200, 300, 100)); |
| 933 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 944 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 934 layer->update(m_queue, &occluded, m_stats); | 945 layer->update(*m_queue.get(), &occluded, m_stats); |
| 935 EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 946 EXPECT_EQ(36-2, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 936 | 947 |
| 937 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 948 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 938 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000, 1); | 949 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000, 1); |
| 939 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); | 950 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 940 | 951 |
| 941 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 952 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 942 layer->setTexturePriorities(m_priorityCalculator); | 953 layer->setTexturePriorities(m_priorityCalculator); |
| 943 m_textureManager->prioritizeTextures(); | 954 m_textureManager->prioritizeTextures(); |
| 944 | 955 |
| 945 occluded.setOcclusion(IntRect(250, 250, 300, 100)); | 956 occluded.setOcclusion(IntRect(250, 250, 300, 100)); |
| 946 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 957 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 947 layer->update(m_queue, &occluded, m_stats); | 958 layer->update(*m_queue.get(), &occluded, m_stats); |
| 948 EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 959 EXPECT_EQ(36, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 949 | 960 |
| 950 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 961 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 951 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000 + 360000, 1); | 962 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000 + 360000, 1); |
| 952 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); | 963 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 953 } | 964 } |
| 954 | 965 |
| 955 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) | 966 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints) |
| 956 { | 967 { |
| 957 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 968 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 958 TestCCOcclusionTracker occluded; | 969 TestCCOcclusionTracker occluded; |
| 959 | 970 |
| 960 // The tile size is 100x100. | 971 // The tile size is 100x100. |
| 961 | 972 |
| 962 layer->setBounds(IntSize(600, 600)); | 973 layer->setBounds(IntSize(600, 600)); |
| 963 | 974 |
| 964 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. | 975 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. |
| 965 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 976 occluded.setOcclusion(IntRect(200, 200, 300, 150)); |
| 966 layer->setDrawableContentRect(IntRect(0, 0, 600, 360)); | 977 layer->setDrawableContentRect(IntRect(0, 0, 600, 360)); |
| 967 layer->setVisibleContentRect(IntRect(0, 0, 600, 360)); | 978 layer->setVisibleContentRect(IntRect(0, 0, 600, 360)); |
| 968 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 979 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 969 | 980 |
| 970 layer->setTexturePriorities(m_priorityCalculator); | 981 layer->setTexturePriorities(m_priorityCalculator); |
| 971 m_textureManager->prioritizeTextures(); | 982 m_textureManager->prioritizeTextures(); |
| 972 layer->update(m_queue, &occluded, m_stats); | 983 layer->update(*m_queue.get(), &occluded, m_stats); |
| 973 EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 984 EXPECT_EQ(24-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 974 | 985 |
| 975 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 986 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 976 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); | 987 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); |
| 977 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 988 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 978 | 989 |
| 979 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 990 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 980 | 991 |
| 981 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. | 992 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. |
| 982 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 993 occluded.setOcclusion(IntRect(200, 200, 300, 150)); |
| 983 layer->setDrawableContentRect(IntRect(0, 0, 600, 350)); | 994 layer->setDrawableContentRect(IntRect(0, 0, 600, 350)); |
| 984 layer->setVisibleContentRect(IntRect(0, 0, 600, 350)); | 995 layer->setVisibleContentRect(IntRect(0, 0, 600, 350)); |
| 985 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 996 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 986 layer->setTexturePriorities(m_priorityCalculator); | 997 layer->setTexturePriorities(m_priorityCalculator); |
| 987 m_textureManager->prioritizeTextures(); | 998 m_textureManager->prioritizeTextures(); |
| 988 layer->update(m_queue, &occluded, m_stats); | 999 layer->update(*m_queue.get(), &occluded, m_stats); |
| 989 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1000 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 990 | 1001 |
| 991 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1002 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 992 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); | 1003 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); |
| 993 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1004 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 994 | 1005 |
| 995 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 1006 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 996 | 1007 |
| 997 // Now the visible region is even smaller than the occlusion, it should have
the same result. | 1008 // Now the visible region is even smaller than the occlusion, it should have
the same result. |
| 998 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 1009 occluded.setOcclusion(IntRect(200, 200, 300, 150)); |
| 999 layer->setDrawableContentRect(IntRect(0, 0, 600, 340)); | 1010 layer->setDrawableContentRect(IntRect(0, 0, 600, 340)); |
| 1000 layer->setVisibleContentRect(IntRect(0, 0, 600, 340)); | 1011 layer->setVisibleContentRect(IntRect(0, 0, 600, 340)); |
| 1001 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1012 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1002 layer->setTexturePriorities(m_priorityCalculator); | 1013 layer->setTexturePriorities(m_priorityCalculator); |
| 1003 m_textureManager->prioritizeTextures(); | 1014 m_textureManager->prioritizeTextures(); |
| 1004 layer->update(m_queue, &occluded, m_stats); | 1015 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1005 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1016 EXPECT_EQ(24-6, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1006 | 1017 |
| 1007 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1018 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1008 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); | 1019 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); |
| 1009 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1020 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1010 | 1021 |
| 1011 } | 1022 } |
| 1012 | 1023 |
| 1013 TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) | 1024 TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation) |
| 1014 { | 1025 { |
| 1015 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1026 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 1016 TestCCOcclusionTracker occluded; | 1027 TestCCOcclusionTracker occluded; |
| 1017 | 1028 |
| 1018 // The tile size is 100x100. | 1029 // The tile size is 100x100. |
| 1019 | 1030 |
| 1020 layer->setBounds(IntSize(600, 600)); | 1031 layer->setBounds(IntSize(600, 600)); |
| 1021 | 1032 |
| 1022 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 1033 occluded.setOcclusion(IntRect(200, 200, 300, 100)); |
| 1023 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); | 1034 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); |
| 1024 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); | 1035 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); |
| 1025 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1036 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1026 layer->setTexturePriorities(m_priorityCalculator); | 1037 layer->setTexturePriorities(m_priorityCalculator); |
| 1027 m_textureManager->prioritizeTextures(); | 1038 m_textureManager->prioritizeTextures(); |
| 1028 layer->update(m_queue, &occluded, m_stats); | 1039 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1029 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1040 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1030 { | 1041 { |
| 1031 updateTextures(); | 1042 updateTextures(); |
| 1032 } | 1043 } |
| 1033 | 1044 |
| 1034 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1045 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1035 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1046 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
| 1036 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1047 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1037 | 1048 |
| 1038 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 1049 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 1039 layer->setTexturePriorities(m_priorityCalculator); | 1050 layer->setTexturePriorities(m_priorityCalculator); |
| 1040 m_textureManager->prioritizeTextures(); | 1051 m_textureManager->prioritizeTextures(); |
| 1041 | 1052 |
| 1042 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted
now. | 1053 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted
now. |
| 1043 layer->update(m_queue, &occluded, m_stats); | 1054 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1044 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1055 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1045 | 1056 |
| 1046 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1057 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1047 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1058 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
| 1048 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1059 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1049 } | 1060 } |
| 1050 | 1061 |
| 1051 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) | 1062 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms) |
| 1052 { | 1063 { |
| 1053 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1064 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 1054 TestCCOcclusionTracker occluded; | 1065 TestCCOcclusionTracker occluded; |
| 1055 | 1066 |
| 1056 // The tile size is 100x100. | 1067 // The tile size is 100x100. |
| 1057 | 1068 |
| 1058 // This makes sure the painting works when the occluded region (in screen sp
ace) | 1069 // This makes sure the painting works when the occluded region (in screen sp
ace) |
| 1059 // is transformed differently than the layer. | 1070 // is transformed differently than the layer. |
| 1060 layer->setBounds(IntSize(600, 600)); | 1071 layer->setBounds(IntSize(600, 600)); |
| 1061 WebTransformationMatrix screenTransform; | 1072 WebTransformationMatrix screenTransform; |
| 1062 screenTransform.scale(0.5); | 1073 screenTransform.scale(0.5); |
| 1063 layer->setScreenSpaceTransform(screenTransform); | 1074 layer->setScreenSpaceTransform(screenTransform); |
| 1064 layer->setDrawTransform(screenTransform); | 1075 layer->setDrawTransform(screenTransform); |
| 1065 | 1076 |
| 1066 occluded.setOcclusion(IntRect(100, 100, 150, 50)); | 1077 occluded.setOcclusion(IntRect(100, 100, 150, 50)); |
| 1067 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1078 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1068 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1079 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1069 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1080 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1070 layer->setTexturePriorities(m_priorityCalculator); | 1081 layer->setTexturePriorities(m_priorityCalculator); |
| 1071 m_textureManager->prioritizeTextures(); | 1082 m_textureManager->prioritizeTextures(); |
| 1072 layer->update(m_queue, &occluded, m_stats); | 1083 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1073 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1084 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1074 | 1085 |
| 1075 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1086 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1076 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1087 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
| 1077 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1088 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1078 } | 1089 } |
| 1079 | 1090 |
| 1080 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) | 1091 TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling) |
| 1081 { | 1092 { |
| 1082 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1093 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1093 drawTransform.scale(1 / layer->contentsScale()); | 1104 drawTransform.scale(1 / layer->contentsScale()); |
| 1094 layer->setDrawTransform(drawTransform); | 1105 layer->setDrawTransform(drawTransform); |
| 1095 layer->setScreenSpaceTransform(drawTransform); | 1106 layer->setScreenSpaceTransform(drawTransform); |
| 1096 | 1107 |
| 1097 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 1108 occluded.setOcclusion(IntRect(200, 200, 300, 100)); |
| 1098 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1109 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1099 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1110 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1100 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1111 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1101 layer->setTexturePriorities(m_priorityCalculator); | 1112 layer->setTexturePriorities(m_priorityCalculator); |
| 1102 m_textureManager->prioritizeTextures(); | 1113 m_textureManager->prioritizeTextures(); |
| 1103 layer->update(m_queue, &occluded, m_stats); | 1114 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1104 // The content is half the size of the layer (so the number of tiles is fewe
r). | 1115 // The content is half the size of the layer (so the number of tiles is fewe
r). |
| 1105 // In this case, the content is 300x300, and since the tile size is 100, the | 1116 // In this case, the content is 300x300, and since the tile size is 100, the |
| 1106 // number of tiles 3x3. | 1117 // number of tiles 3x3. |
| 1107 EXPECT_EQ(9, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1118 EXPECT_EQ(9, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1108 | 1119 |
| 1109 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1120 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1110 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); | 1121 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); |
| 1111 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1122 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1112 | 1123 |
| 1113 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 1124 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 1114 | 1125 |
| 1115 // This makes sure the painting works when the content space is scaled to | 1126 // This makes sure the painting works when the content space is scaled to |
| 1116 // a different layer space. In this case the occluded region catches the | 1127 // a different layer space. In this case the occluded region catches the |
| 1117 // blown up tiles. | 1128 // blown up tiles. |
| 1118 occluded.setOcclusion(IntRect(200, 200, 300, 200)); | 1129 occluded.setOcclusion(IntRect(200, 200, 300, 200)); |
| 1119 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1130 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1120 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1131 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1121 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1132 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1122 layer->setTexturePriorities(m_priorityCalculator); | 1133 layer->setTexturePriorities(m_priorityCalculator); |
| 1123 m_textureManager->prioritizeTextures(); | 1134 m_textureManager->prioritizeTextures(); |
| 1124 layer->update(m_queue, &occluded, m_stats); | 1135 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1125 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1136 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1126 | 1137 |
| 1127 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1138 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1128 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); | 1139 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); |
| 1129 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1140 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1130 | 1141 |
| 1131 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 1142 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 1132 | 1143 |
| 1133 // This makes sure content scaling and transforms work together. | 1144 // This makes sure content scaling and transforms work together. |
| 1134 WebTransformationMatrix screenTransform; | 1145 WebTransformationMatrix screenTransform; |
| 1135 screenTransform.scale(0.5); | 1146 screenTransform.scale(0.5); |
| 1136 layer->setScreenSpaceTransform(screenTransform); | 1147 layer->setScreenSpaceTransform(screenTransform); |
| 1137 layer->setDrawTransform(screenTransform); | 1148 layer->setDrawTransform(screenTransform); |
| 1138 | 1149 |
| 1139 occluded.setOcclusion(IntRect(100, 100, 150, 100)); | 1150 occluded.setOcclusion(IntRect(100, 100, 150, 100)); |
| 1140 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1151 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1141 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1152 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); |
| 1142 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1153 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1143 layer->setTexturePriorities(m_priorityCalculator); | 1154 layer->setTexturePriorities(m_priorityCalculator); |
| 1144 m_textureManager->prioritizeTextures(); | 1155 m_textureManager->prioritizeTextures(); |
| 1145 layer->update(m_queue, &occluded, m_stats); | 1156 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1146 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1157 EXPECT_EQ(9-1, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1147 | 1158 |
| 1148 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1159 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1149 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); | 1160 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); |
| 1150 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1161 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1151 } | 1162 } |
| 1152 | 1163 |
| 1153 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) | 1164 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) |
| 1154 { | 1165 { |
| 1155 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1166 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1167 layer->setDrawableContentRect(visibleBounds); | 1178 layer->setDrawableContentRect(visibleBounds); |
| 1168 layer->setVisibleContentRect(visibleBounds); | 1179 layer->setVisibleContentRect(visibleBounds); |
| 1169 layer->setDrawOpacity(1); | 1180 layer->setDrawOpacity(1); |
| 1170 | 1181 |
| 1171 layer->setTexturePriorities(m_priorityCalculator); | 1182 layer->setTexturePriorities(m_priorityCalculator); |
| 1172 m_textureManager->prioritizeTextures(); | 1183 m_textureManager->prioritizeTextures(); |
| 1173 | 1184 |
| 1174 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. | 1185 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. |
| 1175 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1186 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1176 layer->invalidateContentRect(contentBounds); | 1187 layer->invalidateContentRect(contentBounds); |
| 1177 layer->update(m_queue, &occluded, m_stats); | 1188 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1178 opaqueContents = layer->visibleContentOpaqueRegion(); | 1189 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1179 EXPECT_TRUE(opaqueContents.isEmpty()); | 1190 EXPECT_TRUE(opaqueContents.isEmpty()); |
| 1180 | 1191 |
| 1181 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000, 1); | 1192 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000, 1); |
| 1182 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1193 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1183 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); | 1194 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); |
| 1184 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1195 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1185 | 1196 |
| 1186 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. | 1197 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. |
| 1187 opaquePaintRect = IntRect(10, 10, 90, 190); | 1198 opaquePaintRect = IntRect(10, 10, 90, 190); |
| 1188 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); | 1199 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); |
| 1189 layer->invalidateContentRect(contentBounds); | 1200 layer->invalidateContentRect(contentBounds); |
| 1190 layer->update(m_queue, &occluded, m_stats); | 1201 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1191 updateTextures(); | 1202 updateTextures(); |
| 1192 opaqueContents = layer->visibleContentOpaqueRegion(); | 1203 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1193 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1204 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1194 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1205 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1195 | 1206 |
| 1196 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1207 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
| 1197 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1208 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1198 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1209 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
| 1199 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1210 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1200 | 1211 |
| 1201 // If we paint again without invalidating, the same stuff should be opaque. | 1212 // If we paint again without invalidating, the same stuff should be opaque. |
| 1202 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1213 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1203 layer->update(m_queue, &occluded, m_stats); | 1214 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1204 updateTextures(); | 1215 updateTextures(); |
| 1205 opaqueContents = layer->visibleContentOpaqueRegion(); | 1216 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1206 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1217 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1207 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1218 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1208 | 1219 |
| 1209 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1220 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
| 1210 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1221 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1211 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1222 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
| 1212 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1223 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1213 | 1224 |
| 1214 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should | 1225 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should |
| 1215 // not be affected. | 1226 // not be affected. |
| 1216 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1227 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1217 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); | 1228 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); |
| 1218 layer->update(m_queue, &occluded, m_stats); | 1229 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1219 updateTextures(); | 1230 updateTextures(); |
| 1220 opaqueContents = layer->visibleContentOpaqueRegion(); | 1231 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1221 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1232 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1222 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1233 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1223 | 1234 |
| 1224 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); | 1235 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); |
| 1225 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1236 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1226 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); | 1237 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); |
| 1227 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1238 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1228 | 1239 |
| 1229 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still | 1240 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still |
| 1230 // not be affected. | 1241 // not be affected. |
| 1231 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1242 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1232 layer->invalidateContentRect(IntRect(10, 10, 1, 1)); | 1243 layer->invalidateContentRect(IntRect(10, 10, 1, 1)); |
| 1233 layer->update(m_queue, &occluded, m_stats); | 1244 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1234 updateTextures(); | 1245 updateTextures(); |
| 1235 opaqueContents = layer->visibleContentOpaqueRegion(); | 1246 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1236 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu
eContents.bounds()); | 1247 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu
eContents.bounds()); |
| 1237 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1248 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1238 | 1249 |
| 1239 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); | 1250 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); |
| 1240 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1251 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1241 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); | 1252 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); |
| 1242 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1253 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1243 } | 1254 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1259 layer->setDrawableContentRect(visibleBounds); | 1270 layer->setDrawableContentRect(visibleBounds); |
| 1260 layer->setVisibleContentRect(visibleBounds); | 1271 layer->setVisibleContentRect(visibleBounds); |
| 1261 layer->setDrawOpacity(1); | 1272 layer->setDrawOpacity(1); |
| 1262 | 1273 |
| 1263 layer->setTexturePriorities(m_priorityCalculator); | 1274 layer->setTexturePriorities(m_priorityCalculator); |
| 1264 m_textureManager->prioritizeTextures(); | 1275 m_textureManager->prioritizeTextures(); |
| 1265 | 1276 |
| 1266 // Invalidates and paints the whole layer. | 1277 // Invalidates and paints the whole layer. |
| 1267 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1278 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1268 layer->invalidateContentRect(contentBounds); | 1279 layer->invalidateContentRect(contentBounds); |
| 1269 layer->update(m_queue, &occluded, m_stats); | 1280 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1270 updateTextures(); | 1281 updateTextures(); |
| 1271 opaqueContents = layer->visibleContentOpaqueRegion(); | 1282 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1272 EXPECT_TRUE(opaqueContents.isEmpty()); | 1283 EXPECT_TRUE(opaqueContents.isEmpty()); |
| 1273 | 1284 |
| 1274 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000, 1); | 1285 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000, 1); |
| 1275 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1286 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1276 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000, 1
); | 1287 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000, 1
); |
| 1277 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1288 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1278 | 1289 |
| 1279 // Invalidates an area on the top and bottom tile, which will cause us to pa
int the tile in the middle, | 1290 // Invalidates an area on the top and bottom tile, which will cause us to pa
int the tile in the middle, |
| 1280 // even though it is not dirty and will not be uploaded. | 1291 // even though it is not dirty and will not be uploaded. |
| 1281 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1292 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1282 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); | 1293 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); |
| 1283 layer->invalidateContentRect(IntRect(50, 200, 10, 10)); | 1294 layer->invalidateContentRect(IntRect(50, 200, 10, 10)); |
| 1284 layer->update(m_queue, &occluded, m_stats); | 1295 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1285 updateTextures(); | 1296 updateTextures(); |
| 1286 opaqueContents = layer->visibleContentOpaqueRegion(); | 1297 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1287 EXPECT_TRUE(opaqueContents.isEmpty()); | 1298 EXPECT_TRUE(opaqueContents.isEmpty()); |
| 1288 | 1299 |
| 1289 // The middle tile was painted even though not invalidated. | 1300 // The middle tile was painted even though not invalidated. |
| 1290 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; | 1301 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; |
| 1291 // The pixels uploaded will not include the non-invalidated tile in the midd
le. | 1302 // The pixels uploaded will not include the non-invalidated tile in the midd
le. |
| 1292 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1303 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1293 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); | 1304 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); |
| 1294 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1305 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 child2->setVisibleContentRect(child2Rect); | 1346 child2->setVisibleContentRect(child2Rect); |
| 1336 child2->setDrawableContentRect(rootRect); | 1347 child2->setDrawableContentRect(rootRect); |
| 1337 | 1348 |
| 1338 ccLayerTreeHost->setRootLayer(root); | 1349 ccLayerTreeHost->setRootLayer(root); |
| 1339 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); | 1350 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); |
| 1340 | 1351 |
| 1341 // With a huge memory limit, all layers should update and push their texture
s. | 1352 // With a huge memory limit, all layers should update and push their texture
s. |
| 1342 root->invalidateContentRect(rootRect); | 1353 root->invalidateContentRect(rootRect); |
| 1343 child->invalidateContentRect(childRect); | 1354 child->invalidateContentRect(childRect); |
| 1344 child2->invalidateContentRect(child2Rect); | 1355 child2->invalidateContentRect(child2Rect); |
| 1345 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 1356 ccLayerTreeHost->updateLayers( |
| 1357 *m_queue.get(), std::numeric_limits<size_t>::max()); |
| 1346 { | 1358 { |
| 1347 updateTextures(); | 1359 updateTextures(); |
| 1348 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1360 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1349 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); | 1361 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); |
| 1350 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); | 1362 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1351 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1363 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1352 | 1364 |
| 1353 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1365 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1354 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1366 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1355 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1367 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1356 | 1368 |
| 1357 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1369 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1358 ScopedFakeCCTiledLayerImpl childImpl(child->id()); | 1370 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1359 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); | 1371 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1360 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1372 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1361 layerPushPropertiesTo(child.get(), childImpl.get()); | 1373 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1362 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1374 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1363 | 1375 |
| 1364 for (unsigned i = 0; i < 3; ++i) { | 1376 for (unsigned i = 0; i < 3; ++i) { |
| 1365 for (unsigned j = 0; j < 2; ++j) | 1377 for (unsigned j = 0; j < 2; ++j) |
| 1366 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); | 1378 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); |
| 1367 EXPECT_TRUE(childImpl->hasTextureIdForTileAt(i, 0)); | 1379 EXPECT_TRUE(childImpl->hasTextureIdForTileAt(i, 0)); |
| 1368 EXPECT_TRUE(child2Impl->hasTextureIdForTileAt(i, 0)); | 1380 EXPECT_TRUE(child2Impl->hasTextureIdForTileAt(i, 0)); |
| 1369 } | 1381 } |
| 1370 } | 1382 } |
| 1371 ccLayerTreeHost->commitComplete(); | 1383 ccLayerTreeHost->commitComplete(); |
| 1372 | 1384 |
| 1373 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that | 1385 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that |
| 1374 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't | 1386 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't |
| 1375 // accounted for, then one of the children would fit within the memory limit
. | 1387 // accounted for, then one of the children would fit within the memory limit
. |
| 1376 root->invalidateContentRect(rootRect); | 1388 root->invalidateContentRect(rootRect); |
| 1377 child->invalidateContentRect(childRect); | 1389 child->invalidateContentRect(childRect); |
| 1378 child2->invalidateContentRect(child2Rect); | 1390 child2->invalidateContentRect(child2Rect); |
| 1379 ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); | 1391 ccLayerTreeHost->updateLayers( |
| 1392 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); |
| 1380 { | 1393 { |
| 1381 updateTextures(); | 1394 updateTextures(); |
| 1382 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1395 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1383 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1396 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1384 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1397 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1385 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1398 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1386 | 1399 |
| 1387 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1400 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1388 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1401 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1389 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1402 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1390 | 1403 |
| 1391 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1404 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1392 ScopedFakeCCTiledLayerImpl childImpl(child->id()); | 1405 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1393 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); | 1406 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1394 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1407 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1395 layerPushPropertiesTo(child.get(), childImpl.get()); | 1408 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1396 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1409 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1397 | 1410 |
| 1398 for (unsigned i = 0; i < 3; ++i) { | 1411 for (unsigned i = 0; i < 3; ++i) { |
| 1399 for (unsigned j = 0; j < 2; ++j) | 1412 for (unsigned j = 0; j < 2; ++j) |
| 1400 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); | 1413 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); |
| 1401 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); | 1414 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); |
| 1402 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); | 1415 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); |
| 1403 } | 1416 } |
| 1404 } | 1417 } |
| 1405 ccLayerTreeHost->commitComplete(); | 1418 ccLayerTreeHost->commitComplete(); |
| 1406 | 1419 |
| 1407 // With a memory limit that includes only half the root layer, no contents w
ill be | 1420 // With a memory limit that includes only half the root layer, no contents w
ill be |
| 1408 // allocated. If render surface memory wasn't accounted for, there is enough
space | 1421 // allocated. If render surface memory wasn't accounted for, there is enough
space |
| 1409 // for one of the children layers, but they draw into a surface that can't b
e | 1422 // for one of the children layers, but they draw into a surface that can't b
e |
| 1410 // allocated. | 1423 // allocated. |
| 1411 root->invalidateContentRect(rootRect); | 1424 root->invalidateContentRect(rootRect); |
| 1412 child->invalidateContentRect(childRect); | 1425 child->invalidateContentRect(childRect); |
| 1413 child2->invalidateContentRect(child2Rect); | 1426 child2->invalidateContentRect(child2Rect); |
| 1414 ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); | 1427 ccLayerTreeHost->updateLayers( |
| 1428 *m_queue.get(), (3 * 1) * (100 * 100) * 4); |
| 1415 { | 1429 { |
| 1416 updateTextures(); | 1430 updateTextures(); |
| 1417 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); | 1431 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); |
| 1418 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1432 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1419 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1433 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1420 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1434 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1421 | 1435 |
| 1422 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1436 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1423 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1437 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1424 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1438 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1425 | 1439 |
| 1426 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); | 1440 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1427 ScopedFakeCCTiledLayerImpl childImpl(child->id()); | 1441 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1428 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); | 1442 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1429 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1443 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1430 layerPushPropertiesTo(child.get(), childImpl.get()); | 1444 layerPushPropertiesTo(child.get(), childImpl.get()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 | 1508 |
| 1495 IntRect contentRect(0, 0, 45, 47); | 1509 IntRect contentRect(0, 0, 45, 47); |
| 1496 EXPECT_EQ(contentRect.size(), layer->contentBounds()); | 1510 EXPECT_EQ(contentRect.size(), layer->contentBounds()); |
| 1497 layer->setVisibleContentRect(contentRect); | 1511 layer->setVisibleContentRect(contentRect); |
| 1498 layer->setDrawableContentRect(contentRect); | 1512 layer->setDrawableContentRect(contentRect); |
| 1499 | 1513 |
| 1500 layer->setTexturePriorities(m_priorityCalculator); | 1514 layer->setTexturePriorities(m_priorityCalculator); |
| 1501 m_textureManager->prioritizeTextures(); | 1515 m_textureManager->prioritizeTextures(); |
| 1502 | 1516 |
| 1503 // Update the whole tile. | 1517 // Update the whole tile. |
| 1504 layer->update(m_queue, 0, m_stats); | 1518 layer->update(*m_queue.get(), 0, m_stats); |
| 1505 layer->trackingLayerPainter()->resetPaintedRect(); | 1519 layer->trackingLayerPainter()->resetPaintedRect(); |
| 1506 | 1520 |
| 1507 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1521 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); |
| 1508 updateTextures(); | 1522 updateTextures(); |
| 1509 | 1523 |
| 1510 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. | 1524 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. |
| 1511 layer->invalidateContentRect(contentRect); | 1525 layer->invalidateContentRect(contentRect); |
| 1512 layer->update(m_queue, 0, m_stats); | 1526 layer->update(*m_queue.get(), 0, m_stats); |
| 1513 | 1527 |
| 1514 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1528 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1515 } | 1529 } |
| 1516 | 1530 |
| 1517 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
dation) | 1531 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
dation) |
| 1518 { | 1532 { |
| 1519 RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTracking
TiledLayerChromium(m_textureManager.get())); | 1533 RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTracking
TiledLayerChromium(m_textureManager.get())); |
| 1520 | 1534 |
| 1521 IntRect layerRect(0, 0, 30, 31); | 1535 IntRect layerRect(0, 0, 30, 31); |
| 1522 layer->setPosition(layerRect.location()); | 1536 layer->setPosition(layerRect.location()); |
| 1523 layer->setBounds(layerRect.size()); | 1537 layer->setBounds(layerRect.size()); |
| 1524 layer->setContentsScale(1.3f); | 1538 layer->setContentsScale(1.3f); |
| 1525 | 1539 |
| 1526 IntRect contentRect(IntPoint(), layer->contentBounds()); | 1540 IntRect contentRect(IntPoint(), layer->contentBounds()); |
| 1527 layer->setVisibleContentRect(contentRect); | 1541 layer->setVisibleContentRect(contentRect); |
| 1528 layer->setDrawableContentRect(contentRect); | 1542 layer->setDrawableContentRect(contentRect); |
| 1529 | 1543 |
| 1530 layer->setTexturePriorities(m_priorityCalculator); | 1544 layer->setTexturePriorities(m_priorityCalculator); |
| 1531 m_textureManager->prioritizeTextures(); | 1545 m_textureManager->prioritizeTextures(); |
| 1532 | 1546 |
| 1533 // Update the whole tile. | 1547 // Update the whole tile. |
| 1534 layer->update(m_queue, 0, m_stats); | 1548 layer->update(*m_queue.get(), 0, m_stats); |
| 1535 layer->trackingLayerPainter()->resetPaintedRect(); | 1549 layer->trackingLayerPainter()->resetPaintedRect(); |
| 1536 | 1550 |
| 1537 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1551 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); |
| 1538 updateTextures(); | 1552 updateTextures(); |
| 1539 | 1553 |
| 1540 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1554 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
| 1541 layer->setNeedsDisplayRect(layerRect); | 1555 layer->setNeedsDisplayRect(layerRect); |
| 1542 layer->update(m_queue, 0, m_stats); | 1556 layer->update(*m_queue.get(), 0, m_stats); |
| 1543 | 1557 |
| 1544 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1558 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1545 } | 1559 } |
| 1546 | 1560 |
| 1547 } // namespace | 1561 } // namespace |
| OLD | NEW |