Chromium Code Reviews| 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 "CCLayerTreeHostImpl.h" | 7 #include "CCLayerTreeHostImpl.h" |
| 8 | 8 |
| 9 #include "CCAnimationTestCommon.h" | 9 #include "CCAnimationTestCommon.h" |
| 10 #include "CCDelegatedRendererLayerImpl.h" | 10 #include "CCDelegatedRendererLayerImpl.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 virtual void didLoseContextOnImplThread() OVERRIDE { } | 68 virtual void didLoseContextOnImplThread() OVERRIDE { } |
| 69 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 69 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
| 70 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } | 70 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } |
| 71 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } | 71 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } |
| 72 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } | 72 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } |
| 73 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } | 73 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } |
| 74 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { } | 74 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { } |
| 75 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } | 75 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } |
| 76 | 76 |
| 77 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped _ptr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) | 77 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped _ptr<CCGraphicsContext> graphicsContext, scoped_ptr<CCLayerImpl> root) |
| 78 { | 78 { |
| 79 CCSettings::setPartialSwapEnabled(partialSwap); | 79 CCSettings::setPartialSwapEnabled(partialSwap); |
| 80 | 80 |
| 81 CCLayerTreeSettings settings; | 81 CCLayerTreeSettings settings; |
| 82 settings.minimumOcclusionTrackingSize = IntSize(); | 82 settings.minimumOcclusionTrackingSize = IntSize(); |
| 83 | 83 |
| 84 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create (settings, this); | 84 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create (settings, this); |
| 85 | 85 |
| 86 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 86 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
| 87 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 87 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
| 88 | 88 |
| 89 OwnPtr<CCLayerImpl> root = rootPtr; | |
| 90 | |
| 91 root->setAnchorPoint(FloatPoint(0, 0)); | 89 root->setAnchorPoint(FloatPoint(0, 0)); |
| 92 root->setPosition(FloatPoint(0, 0)); | 90 root->setPosition(FloatPoint(0, 0)); |
| 93 root->setBounds(IntSize(10, 10)); | 91 root->setBounds(IntSize(10, 10)); |
| 94 root->setContentBounds(IntSize(10, 10)); | 92 root->setContentBounds(IntSize(10, 10)); |
| 95 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); | 93 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); |
| 96 root->setDrawsContent(true); | 94 root->setDrawsContent(true); |
| 97 myHostImpl->setRootLayer(root.release()); | 95 myHostImpl->setRootLayer(root.Pass()); |
| 98 return myHostImpl.Pass(); | 96 return myHostImpl.Pass(); |
| 99 } | 97 } |
| 100 | 98 |
| 101 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) | 99 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) |
| 102 { | 100 { |
| 103 ASSERT_EQ(layer->scrollDelta(), IntSize()); | 101 ASSERT_EQ(layer->scrollDelta(), IntSize()); |
| 104 for (size_t i = 0; i < layer->children().size(); ++i) | 102 for (size_t i = 0; i < layer->children().size(); ++i) |
| 105 expectClearedScrollDeltasRecursive(layer->children()[i]); | 103 expectClearedScrollDeltasRecursive(layer->children()[i]); |
| 106 } | 104 } |
| 107 | 105 |
| 108 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co nst IntSize& scrollDelta) | 106 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co nst IntSize& scrollDelta) |
| 109 { | 107 { |
| 110 int timesEncountered = 0; | 108 int timesEncountered = 0; |
| 111 | 109 |
| 112 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { | 110 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { |
| 113 if (scrollInfo.scrolls[i].layerId != id) | 111 if (scrollInfo.scrolls[i].layerId != id) |
| 114 continue; | 112 continue; |
| 115 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th()); | 113 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th()); |
| 116 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight()); | 114 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight()); |
| 117 timesEncountered++; | 115 timesEncountered++; |
| 118 } | 116 } |
| 119 | 117 |
| 120 ASSERT_EQ(timesEncountered, 1); | 118 ASSERT_EQ(timesEncountered, 1); |
| 121 } | 119 } |
| 122 | 120 |
| 123 void setupScrollAndContentsLayers(const IntSize& contentSize) | 121 void setupScrollAndContentsLayers(const IntSize& contentSize) |
| 124 { | 122 { |
| 125 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 123 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 126 root->setScrollable(true); | 124 root->setScrollable(true); |
| 127 root->setScrollPosition(IntPoint(0, 0)); | 125 root->setScrollPosition(IntPoint(0, 0)); |
| 128 root->setMaxScrollPosition(contentSize); | 126 root->setMaxScrollPosition(contentSize); |
| 129 root->setBounds(contentSize); | 127 root->setBounds(contentSize); |
| 130 root->setContentBounds(contentSize); | 128 root->setContentBounds(contentSize); |
| 131 root->setPosition(FloatPoint(0, 0)); | 129 root->setPosition(FloatPoint(0, 0)); |
| 132 root->setAnchorPoint(FloatPoint(0, 0)); | 130 root->setAnchorPoint(FloatPoint(0, 0)); |
| 133 | 131 |
| 134 OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2); | 132 scoped_ptr<CCLayerImpl> contents = CCLayerImpl::create(2); |
| 135 contents->setDrawsContent(true); | 133 contents->setDrawsContent(true); |
| 136 contents->setBounds(contentSize); | 134 contents->setBounds(contentSize); |
| 137 contents->setContentBounds(contentSize); | 135 contents->setContentBounds(contentSize); |
| 138 contents->setPosition(FloatPoint(0, 0)); | 136 contents->setPosition(FloatPoint(0, 0)); |
| 139 contents->setAnchorPoint(FloatPoint(0, 0)); | 137 contents->setAnchorPoint(FloatPoint(0, 0)); |
| 140 root->addChild(contents.release()); | 138 root->addChild(contents.Pass()); |
| 141 m_hostImpl->setRootLayer(root.release()); | 139 m_hostImpl->setRootLayer(root.Pass()); |
| 142 } | 140 } |
| 143 | 141 |
| 144 static PassOwnPtr<CCLayerImpl> createScrollableLayer(int id, const IntSize& size) | 142 static scoped_ptr<CCLayerImpl> createScrollableLayer(int id, const IntSize& size) |
| 145 { | 143 { |
| 146 OwnPtr<CCLayerImpl> layer = CCLayerImpl::create(id); | 144 scoped_ptr<CCLayerImpl> layer = CCLayerImpl::create(id); |
| 147 layer->setScrollable(true); | 145 layer->setScrollable(true); |
| 148 layer->setDrawsContent(true); | 146 layer->setDrawsContent(true); |
| 149 layer->setBounds(size); | 147 layer->setBounds(size); |
| 150 layer->setContentBounds(size); | 148 layer->setContentBounds(size); |
| 151 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) ); | 149 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) ); |
| 152 return layer.release(); | 150 return layer.Pass(); |
| 153 } | 151 } |
| 154 | 152 |
| 155 void initializeRendererAndDrawFrame() | 153 void initializeRendererAndDrawFrame() |
| 156 { | 154 { |
| 157 m_hostImpl->initializeRenderer(createContext()); | 155 m_hostImpl->initializeRenderer(createContext()); |
| 158 CCLayerTreeHostImpl::FrameData frame; | 156 CCLayerTreeHostImpl::FrameData frame; |
| 159 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 157 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 160 m_hostImpl->drawLayers(frame); | 158 m_hostImpl->drawLayers(frame); |
| 161 m_hostImpl->didDrawAllLayers(frame); | 159 m_hostImpl->didDrawAllLayers(frame); |
| 162 } | 160 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 189 // that canDraw changed. | 187 // that canDraw changed. |
| 190 EXPECT_FALSE(m_hostImpl->canDraw()); | 188 EXPECT_FALSE(m_hostImpl->canDraw()); |
| 191 m_onCanDrawStateChangedCalled = false; | 189 m_onCanDrawStateChangedCalled = false; |
| 192 | 190 |
| 193 setupScrollAndContentsLayers(IntSize(100, 100)); | 191 setupScrollAndContentsLayers(IntSize(100, 100)); |
| 194 EXPECT_TRUE(m_hostImpl->canDraw()); | 192 EXPECT_TRUE(m_hostImpl->canDraw()); |
| 195 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 193 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
| 196 m_onCanDrawStateChangedCalled = false; | 194 m_onCanDrawStateChangedCalled = false; |
| 197 | 195 |
| 198 // Toggle the root layer to make sure it toggles canDraw | 196 // Toggle the root layer to make sure it toggles canDraw |
| 199 m_hostImpl->setRootLayer(adoptPtr<CCLayerImpl>(0)); | 197 m_hostImpl->setRootLayer(scoped_ptr<CCLayerImpl>()); |
| 200 EXPECT_FALSE(m_hostImpl->canDraw()); | 198 EXPECT_FALSE(m_hostImpl->canDraw()); |
| 201 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 199 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
| 202 m_onCanDrawStateChangedCalled = false; | 200 m_onCanDrawStateChangedCalled = false; |
| 203 | 201 |
| 204 setupScrollAndContentsLayers(IntSize(100, 100)); | 202 setupScrollAndContentsLayers(IntSize(100, 100)); |
| 205 EXPECT_TRUE(m_hostImpl->canDraw()); | 203 EXPECT_TRUE(m_hostImpl->canDraw()); |
| 206 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 204 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
| 207 m_onCanDrawStateChangedCalled = false; | 205 m_onCanDrawStateChangedCalled = false; |
| 208 | 206 |
| 209 // Toggle the device viewport size to make sure it toggles canDraw. | 207 // Toggle the device viewport size to make sure it toggles canDraw. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 233 { | 231 { |
| 234 ASSERT_FALSE(m_hostImpl->rootLayer()); | 232 ASSERT_FALSE(m_hostImpl->rootLayer()); |
| 235 | 233 |
| 236 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 234 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
| 237 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 235 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 238 } | 236 } |
| 239 | 237 |
| 240 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 238 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
| 241 { | 239 { |
| 242 { | 240 { |
| 243 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 241 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 244 root->addChild(CCLayerImpl::create(2)); | 242 root->addChild(CCLayerImpl::create(2)); |
| 245 root->addChild(CCLayerImpl::create(3)); | 243 root->addChild(CCLayerImpl::create(3)); |
| 246 root->children()[1]->addChild(CCLayerImpl::create(4)); | 244 root->children()[1]->addChild(CCLayerImpl::create(4)); |
| 247 root->children()[1]->addChild(CCLayerImpl::create(5)); | 245 root->children()[1]->addChild(CCLayerImpl::create(5)); |
| 248 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); | 246 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); |
| 249 m_hostImpl->setRootLayer(root.release()); | 247 m_hostImpl->setRootLayer(root.Pass()); |
| 250 } | 248 } |
| 251 CCLayerImpl* root = m_hostImpl->rootLayer(); | 249 CCLayerImpl* root = m_hostImpl->rootLayer(); |
| 252 | 250 |
| 253 expectClearedScrollDeltasRecursive(root); | 251 expectClearedScrollDeltasRecursive(root); |
| 254 | 252 |
| 255 OwnPtr<CCScrollAndScaleSet> scrollInfo; | 253 OwnPtr<CCScrollAndScaleSet> scrollInfo; |
| 256 | 254 |
| 257 scrollInfo = m_hostImpl->processScrollDeltas(); | 255 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 258 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 256 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 259 expectClearedScrollDeltasRecursive(root); | 257 expectClearedScrollDeltasRecursive(root); |
| 260 | 258 |
| 261 scrollInfo = m_hostImpl->processScrollDeltas(); | 259 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 262 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 260 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 263 expectClearedScrollDeltasRecursive(root); | 261 expectClearedScrollDeltasRecursive(root); |
| 264 } | 262 } |
| 265 | 263 |
| 266 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 264 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
| 267 { | 265 { |
| 268 IntPoint scrollPosition(20, 30); | 266 IntPoint scrollPosition(20, 30); |
| 269 IntSize scrollDelta(11, -15); | 267 IntSize scrollDelta(11, -15); |
| 270 { | 268 { |
| 271 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 269 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 272 root->setScrollPosition(scrollPosition); | 270 root->setScrollPosition(scrollPosition); |
| 273 root->setScrollable(true); | 271 root->setScrollable(true); |
| 274 root->setMaxScrollPosition(IntSize(100, 100)); | 272 root->setMaxScrollPosition(IntSize(100, 100)); |
| 275 root->scrollBy(scrollDelta); | 273 root->scrollBy(scrollDelta); |
| 276 m_hostImpl->setRootLayer(root.release()); | 274 m_hostImpl->setRootLayer(root.Pass()); |
| 277 } | 275 } |
| 278 CCLayerImpl* root = m_hostImpl->rootLayer(); | 276 CCLayerImpl* root = m_hostImpl->rootLayer(); |
| 279 | 277 |
| 280 OwnPtr<CCScrollAndScaleSet> scrollInfo; | 278 OwnPtr<CCScrollAndScaleSet> scrollInfo; |
| 281 | 279 |
| 282 scrollInfo = m_hostImpl->processScrollDeltas(); | 280 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 283 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 281 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
| 284 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); | 282 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); |
| 285 expectContains(*scrollInfo, root->id(), scrollDelta); | 283 expectContains(*scrollInfo, root->id(), scrollDelta); |
| 286 | 284 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 // The final page scale and scroll deltas should match what we got | 671 // The final page scale and scroll deltas should match what we got |
| 674 // earlier. | 672 // earlier. |
| 675 m_hostImpl->animate(endTime, endTime); | 673 m_hostImpl->animate(endTime, endTime); |
| 676 scrollInfo = m_hostImpl->processScrollDeltas(); | 674 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 677 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 675 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 678 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 676 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
| 679 } | 677 } |
| 680 | 678 |
| 681 class DidDrawCheckLayer : public CCTiledLayerImpl { | 679 class DidDrawCheckLayer : public CCTiledLayerImpl { |
| 682 public: | 680 public: |
| 683 static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new Di dDrawCheckLayer(id)); } | 681 static scoped_ptr<CCLayerImpl> create(int id) { return make_scoped_ptr(new D idDrawCheckLayer(id)).PassAs<CCLayerImpl>(); } |
|
jamesr
2012/10/07 22:27:19
just "return scoped_ptr<T>(...)" as below would be
enne (OOO)
2012/10/07 22:44:57
Done.
| |
| 684 | 682 |
| 685 virtual void didDraw(CCResourceProvider*) OVERRIDE | 683 virtual void didDraw(CCResourceProvider*) OVERRIDE |
| 686 { | 684 { |
| 687 m_didDrawCalled = true; | 685 m_didDrawCalled = true; |
| 688 } | 686 } |
| 689 | 687 |
| 690 virtual void willDraw(CCResourceProvider*) OVERRIDE | 688 virtual void willDraw(CCResourceProvider*) OVERRIDE |
| 691 { | 689 { |
| 692 m_willDrawCalled = true; | 690 m_willDrawCalled = true; |
| 693 } | 691 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 EXPECT_TRUE(root->didDrawCalled()); | 828 EXPECT_TRUE(root->didDrawCalled()); |
| 831 EXPECT_TRUE(layer1->didDrawCalled()); | 829 EXPECT_TRUE(layer1->didDrawCalled()); |
| 832 EXPECT_TRUE(layer2->didDrawCalled()); | 830 EXPECT_TRUE(layer2->didDrawCalled()); |
| 833 | 831 |
| 834 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); | 832 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); |
| 835 EXPECT_TRUE(!!layer1->renderSurface()); | 833 EXPECT_TRUE(!!layer1->renderSurface()); |
| 836 } | 834 } |
| 837 | 835 |
| 838 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 836 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
| 839 public: | 837 public: |
| 840 static PassOwnPtr<MissingTextureAnimatingLayer> create(int id, bool tileMiss ing, bool skipsDraw, bool animating, CCResourceProvider* resourceProvider) { ret urn adoptPtr(new MissingTextureAnimatingLayer(id, tileMissing, skipsDraw, animat ing, resourceProvider)); } | 838 static scoped_ptr<CCLayerImpl> create(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider) |
| 839 { | |
| 840 return scoped_ptr<CCLayerImpl>(new MissingTextureAnimatingLayer(id, tile Missing, skipsDraw, animating, resourceProvider)); | |
| 841 } | |
| 841 | 842 |
| 842 private: | 843 private: |
| 843 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider) | 844 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider) |
| 844 : DidDrawCheckLayer(id) | 845 : DidDrawCheckLayer(id) |
| 845 { | 846 { |
| 846 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize (10, 10), CCLayerTilingData::NoBorderTexels); | 847 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize (10, 10), CCLayerTilingData::NoBorderTexels); |
| 847 tilingData->setBounds(bounds()); | 848 tilingData->setBounds(bounds()); |
| 848 setTilingData(*tilingData.get()); | 849 setTilingData(*tilingData.get()); |
| 849 setSkipsDraw(skipsDraw); | 850 setSkipsDraw(skipsDraw); |
| 850 if (!tileMissing) { | 851 if (!tileMissing) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 893 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
| 893 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider())); | 894 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider())); |
| 894 | 895 |
| 895 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 896 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 896 m_hostImpl->drawLayers(frame); | 897 m_hostImpl->drawLayers(frame); |
| 897 m_hostImpl->didDrawAllLayers(frame); | 898 m_hostImpl->didDrawAllLayers(frame); |
| 898 } | 899 } |
| 899 | 900 |
| 900 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) | 901 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) |
| 901 { | 902 { |
| 902 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 903 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 903 root->setScrollable(false); | 904 root->setScrollable(false); |
| 904 m_hostImpl->setRootLayer(root.release()); | 905 m_hostImpl->setRootLayer(root.Pass()); |
| 905 initializeRendererAndDrawFrame(); | 906 initializeRendererAndDrawFrame(); |
| 906 | 907 |
| 907 // Scroll event is ignored because layer is not scrollable. | 908 // Scroll event is ignored because layer is not scrollable. |
| 908 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); | 909 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); |
| 909 EXPECT_FALSE(m_didRequestRedraw); | 910 EXPECT_FALSE(m_didRequestRedraw); |
| 910 EXPECT_FALSE(m_didRequestCommit); | 911 EXPECT_FALSE(m_didRequestCommit); |
| 911 } | 912 } |
| 912 | 913 |
| 913 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot) | 914 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot) |
| 914 { | 915 { |
| 915 // Test the configuration where a non-composited root layer is embedded in a | 916 // Test the configuration where a non-composited root layer is embedded in a |
| 916 // scrollable outer layer. | 917 // scrollable outer layer. |
| 917 IntSize surfaceSize(10, 10); | 918 IntSize surfaceSize(10, 10); |
| 918 | 919 |
| 919 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); | 920 scoped_ptr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); |
| 920 contentLayer->setUseLCDText(true); | 921 contentLayer->setUseLCDText(true); |
| 921 contentLayer->setDrawsContent(true); | 922 contentLayer->setDrawsContent(true); |
| 922 contentLayer->setPosition(FloatPoint(0, 0)); | 923 contentLayer->setPosition(FloatPoint(0, 0)); |
| 923 contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 924 contentLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 924 contentLayer->setBounds(surfaceSize); | 925 contentLayer->setBounds(surfaceSize); |
| 925 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize. height() * 2)); | 926 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize. height() * 2)); |
| 926 | 927 |
| 927 OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); | 928 scoped_ptr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); |
| 928 scrollLayer->setScrollable(true); | 929 scrollLayer->setScrollable(true); |
| 929 scrollLayer->setMaxScrollPosition(surfaceSize); | 930 scrollLayer->setMaxScrollPosition(surfaceSize); |
| 930 scrollLayer->setBounds(surfaceSize); | 931 scrollLayer->setBounds(surfaceSize); |
| 931 scrollLayer->setContentBounds(surfaceSize); | 932 scrollLayer->setContentBounds(surfaceSize); |
| 932 scrollLayer->setPosition(FloatPoint(0, 0)); | 933 scrollLayer->setPosition(FloatPoint(0, 0)); |
| 933 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); | 934 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 934 scrollLayer->addChild(contentLayer.release()); | 935 scrollLayer->addChild(contentLayer.Pass()); |
| 935 | 936 |
| 936 m_hostImpl->setRootLayer(scrollLayer.release()); | 937 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
| 937 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 938 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 938 initializeRendererAndDrawFrame(); | 939 initializeRendererAndDrawFrame(); |
| 939 | 940 |
| 940 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 941 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
| 941 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 942 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
| 942 m_hostImpl->scrollEnd(); | 943 m_hostImpl->scrollEnd(); |
| 943 EXPECT_TRUE(m_didRequestRedraw); | 944 EXPECT_TRUE(m_didRequestRedraw); |
| 944 EXPECT_TRUE(m_didRequestCommit); | 945 EXPECT_TRUE(m_didRequestCommit); |
| 945 } | 946 } |
| 946 | 947 |
| 947 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 948 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
| 948 { | 949 { |
| 949 IntSize surfaceSize(10, 10); | 950 IntSize surfaceSize(10, 10); |
| 950 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 951 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 951 root->setBounds(surfaceSize); | 952 root->setBounds(surfaceSize); |
| 952 root->setContentBounds(surfaceSize); | 953 root->setContentBounds(surfaceSize); |
| 953 root->addChild(createScrollableLayer(2, surfaceSize)); | 954 root->addChild(createScrollableLayer(2, surfaceSize)); |
| 954 m_hostImpl->setRootLayer(root.release()); | 955 m_hostImpl->setRootLayer(root.Pass()); |
| 955 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 956 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 956 initializeRendererAndDrawFrame(); | 957 initializeRendererAndDrawFrame(); |
| 957 | 958 |
| 958 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 959 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
| 959 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 960 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
| 960 m_hostImpl->scrollEnd(); | 961 m_hostImpl->scrollEnd(); |
| 961 EXPECT_TRUE(m_didRequestRedraw); | 962 EXPECT_TRUE(m_didRequestRedraw); |
| 962 EXPECT_TRUE(m_didRequestCommit); | 963 EXPECT_TRUE(m_didRequestCommit); |
| 963 } | 964 } |
| 964 | 965 |
| 965 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) | 966 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) |
| 966 { | 967 { |
| 967 IntSize surfaceSize(10, 10); | 968 IntSize surfaceSize(10, 10); |
| 968 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 969 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 969 root->addChild(createScrollableLayer(2, surfaceSize)); | 970 root->addChild(createScrollableLayer(2, surfaceSize)); |
| 970 m_hostImpl->setRootLayer(root.release()); | 971 m_hostImpl->setRootLayer(root.Pass()); |
| 971 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 972 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 972 initializeRendererAndDrawFrame(); | 973 initializeRendererAndDrawFrame(); |
| 973 | 974 |
| 974 // Scroll event is ignored because the input coordinate is outside the layer boundaries. | 975 // Scroll event is ignored because the input coordinate is outside the layer boundaries. |
| 975 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe el), CCInputHandlerClient::ScrollIgnored); | 976 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe el), CCInputHandlerClient::ScrollIgnored); |
| 976 EXPECT_FALSE(m_didRequestRedraw); | 977 EXPECT_FALSE(m_didRequestRedraw); |
| 977 EXPECT_FALSE(m_didRequestCommit); | 978 EXPECT_FALSE(m_didRequestCommit); |
| 978 } | 979 } |
| 979 | 980 |
| 980 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) | 981 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) |
| 981 { | 982 { |
| 982 IntSize surfaceSize(10, 10); | 983 IntSize surfaceSize(10, 10); |
| 983 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 984 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 984 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 985 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 985 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 986 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 986 | 987 |
| 987 WebTransformationMatrix matrix; | 988 WebTransformationMatrix matrix; |
| 988 matrix.rotate3d(180, 0, 0); | 989 matrix.rotate3d(180, 0, 0); |
| 989 child->setTransform(matrix); | 990 child->setTransform(matrix); |
| 990 child->setDoubleSided(false); | 991 child->setDoubleSided(false); |
| 991 | 992 |
| 992 root->addChild(child.release()); | 993 root->addChild(child.Pass()); |
| 993 m_hostImpl->setRootLayer(root.release()); | 994 m_hostImpl->setRootLayer(root.Pass()); |
| 994 initializeRendererAndDrawFrame(); | 995 initializeRendererAndDrawFrame(); |
| 995 | 996 |
| 996 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is | 997 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is |
| 997 // nothing scrollable behind it. | 998 // nothing scrollable behind it. |
| 998 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); | 999 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); |
| 999 EXPECT_FALSE(m_didRequestRedraw); | 1000 EXPECT_FALSE(m_didRequestRedraw); |
| 1000 EXPECT_FALSE(m_didRequestCommit); | 1001 EXPECT_FALSE(m_didRequestCommit); |
| 1001 } | 1002 } |
| 1002 | 1003 |
| 1003 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) | 1004 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) |
| 1004 { | 1005 { |
| 1005 IntSize surfaceSize(10, 10); | 1006 IntSize surfaceSize(10, 10); |
| 1006 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1007 scoped_ptr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize) ; |
| 1007 contentLayer->setShouldScrollOnMainThread(true); | 1008 contentLayer->setShouldScrollOnMainThread(true); |
| 1008 contentLayer->setScrollable(false); | 1009 contentLayer->setScrollable(false); |
| 1009 | 1010 |
| 1010 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1011 scoped_ptr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
| 1011 scrollLayer->addChild(contentLayer.release()); | 1012 scrollLayer->addChild(contentLayer.Pass()); |
| 1012 | 1013 |
| 1013 m_hostImpl->setRootLayer(scrollLayer.release()); | 1014 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
| 1014 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1015 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1015 initializeRendererAndDrawFrame(); | 1016 initializeRendererAndDrawFrame(); |
| 1016 | 1017 |
| 1017 // Scrolling fails because the content layer is asking to be scrolled on the main thread. | 1018 // Scrolling fails because the content layer is asking to be scrolled on the main thread. |
| 1018 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollOnMainThread); | 1019 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollOnMainThread); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1022 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
| 1022 { | 1023 { |
| 1023 IntSize surfaceSize(10, 10); | 1024 IntSize surfaceSize(10, 10); |
| 1024 float pageScale = 2; | 1025 float pageScale = 2; |
| 1025 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1026 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1026 m_hostImpl->setRootLayer(root.release()); | 1027 m_hostImpl->setRootLayer(root.Pass()); |
| 1027 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1028 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1028 initializeRendererAndDrawFrame(); | 1029 initializeRendererAndDrawFrame(); |
| 1029 | 1030 |
| 1030 IntSize scrollDelta(0, 10); | 1031 IntSize scrollDelta(0, 10); |
| 1031 IntSize expectedScrollDelta(scrollDelta); | 1032 IntSize expectedScrollDelta(scrollDelta); |
| 1032 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1033 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
| 1033 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1034 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
| 1034 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1035 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| 1035 m_hostImpl->scrollEnd(); | 1036 m_hostImpl->scrollEnd(); |
| 1036 | 1037 |
| 1037 // Set new page scale from main thread. | 1038 // Set new page scale from main thread. |
| 1038 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1039 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
| 1039 | 1040 |
| 1040 // The scale should apply to the scroll delta. | 1041 // The scale should apply to the scroll delta. |
| 1041 expectedScrollDelta.scale(pageScale); | 1042 expectedScrollDelta.scale(pageScale); |
| 1042 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 1043 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
| 1043 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 1044 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
| 1044 | 1045 |
| 1045 // The scroll range should also have been updated. | 1046 // The scroll range should also have been updated. |
| 1046 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1047 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
| 1047 | 1048 |
| 1048 // The page scale delta remains constant because the impl thread did not sca le. | 1049 // The page scale delta remains constant because the impl thread did not sca le. |
| 1049 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); | 1050 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1053 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
| 1053 { | 1054 { |
| 1054 IntSize surfaceSize(10, 10); | 1055 IntSize surfaceSize(10, 10); |
| 1055 float pageScale = 2; | 1056 float pageScale = 2; |
| 1056 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1057 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1057 m_hostImpl->setRootLayer(root.release()); | 1058 m_hostImpl->setRootLayer(root.Pass()); |
| 1058 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1059 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1059 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1060 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
| 1060 initializeRendererAndDrawFrame(); | 1061 initializeRendererAndDrawFrame(); |
| 1061 | 1062 |
| 1062 IntSize scrollDelta(0, 10); | 1063 IntSize scrollDelta(0, 10); |
| 1063 IntSize expectedScrollDelta(scrollDelta); | 1064 IntSize expectedScrollDelta(scrollDelta); |
| 1064 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1065 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
| 1065 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1066 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
| 1066 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1067 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| 1067 m_hostImpl->scrollEnd(); | 1068 m_hostImpl->scrollEnd(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1086 { | 1087 { |
| 1087 IntSize surfaceSize(10, 10); | 1088 IntSize surfaceSize(10, 10); |
| 1088 float defaultPageScale = 1; | 1089 float defaultPageScale = 1; |
| 1089 float newPageScale = 2; | 1090 float newPageScale = 2; |
| 1090 | 1091 |
| 1091 // Create a normal scrollable root layer and another scrollable child layer. | 1092 // Create a normal scrollable root layer and another scrollable child layer. |
| 1092 setupScrollAndContentsLayers(surfaceSize); | 1093 setupScrollAndContentsLayers(surfaceSize); |
| 1093 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1094 CCLayerImpl* root = m_hostImpl->rootLayer(); |
| 1094 CCLayerImpl* child = root->children()[0]; | 1095 CCLayerImpl* child = root->children()[0]; |
| 1095 | 1096 |
| 1096 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); | 1097 scoped_ptr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSi ze); |
| 1097 child->addChild(scrollableChild.release()); | 1098 child->addChild(scrollableChild.Pass()); |
| 1098 CCLayerImpl* grandChild = child->children()[0]; | 1099 CCLayerImpl* grandChild = child->children()[0]; |
| 1099 | 1100 |
| 1100 // Set new page scale on impl thread by pinching. | 1101 // Set new page scale on impl thread by pinching. |
| 1101 m_hostImpl->pinchGestureBegin(); | 1102 m_hostImpl->pinchGestureBegin(); |
| 1102 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); | 1103 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); |
| 1103 m_hostImpl->pinchGestureEnd(); | 1104 m_hostImpl->pinchGestureEnd(); |
| 1104 | 1105 |
| 1105 // The page scale delta should only be applied to the scrollable root layer. | 1106 // The page scale delta should only be applied to the scrollable root layer. |
| 1106 EXPECT_EQ(root->pageScaleDelta(), newPageScale); | 1107 EXPECT_EQ(root->pageScaleDelta(), newPageScale); |
| 1107 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); | 1108 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1118 EXPECT_EQ(root->drawTransform().m22(), newPageScale); | 1119 EXPECT_EQ(root->drawTransform().m22(), newPageScale); |
| 1119 EXPECT_EQ(child->drawTransform().m11(), newPageScale); | 1120 EXPECT_EQ(child->drawTransform().m11(), newPageScale); |
| 1120 EXPECT_EQ(child->drawTransform().m22(), newPageScale); | 1121 EXPECT_EQ(child->drawTransform().m22(), newPageScale); |
| 1121 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); | 1122 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); |
| 1122 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); | 1123 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); |
| 1123 } | 1124 } |
| 1124 | 1125 |
| 1125 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1126 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
| 1126 { | 1127 { |
| 1127 IntSize surfaceSize(10, 10); | 1128 IntSize surfaceSize(10, 10); |
| 1128 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1129 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 1129 root->setBounds(surfaceSize); | 1130 root->setBounds(surfaceSize); |
| 1130 root->setContentBounds(surfaceSize); | 1131 root->setContentBounds(surfaceSize); |
| 1131 // Also mark the root scrollable so it becomes the root scroll layer. | 1132 // Also mark the root scrollable so it becomes the root scroll layer. |
| 1132 root->setScrollable(true); | 1133 root->setScrollable(true); |
| 1133 int scrollLayerId = 2; | 1134 int scrollLayerId = 2; |
| 1134 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1135 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
| 1135 m_hostImpl->setRootLayer(root.release()); | 1136 m_hostImpl->setRootLayer(root.Pass()); |
| 1136 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1137 initializeRendererAndDrawFrame(); | 1138 initializeRendererAndDrawFrame(); |
| 1138 | 1139 |
| 1139 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1140 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
| 1140 | 1141 |
| 1141 IntSize scrollDelta(0, 10); | 1142 IntSize scrollDelta(0, 10); |
| 1142 IntSize expectedScrollDelta(scrollDelta); | 1143 IntSize expectedScrollDelta(scrollDelta); |
| 1143 IntSize expectedMaxScroll(child->maxScrollPosition()); | 1144 IntSize expectedMaxScroll(child->maxScrollPosition()); |
| 1144 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); | 1145 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); |
| 1145 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1146 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1159 // The page scale delta remains constant because the impl thread did not sca le. | 1160 // The page scale delta remains constant because the impl thread did not sca le. |
| 1160 EXPECT_EQ(child->pageScaleDelta(), 1); | 1161 EXPECT_EQ(child->pageScaleDelta(), 1); |
| 1161 } | 1162 } |
| 1162 | 1163 |
| 1163 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) | 1164 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) |
| 1164 { | 1165 { |
| 1165 // Scroll a child layer beyond its maximum scroll range and make sure the | 1166 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 1166 // parent layer is scrolled on the axis on which the child was unable to | 1167 // parent layer is scrolled on the axis on which the child was unable to |
| 1167 // scroll. | 1168 // scroll. |
| 1168 IntSize surfaceSize(10, 10); | 1169 IntSize surfaceSize(10, 10); |
| 1169 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1170 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1170 | 1171 |
| 1171 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1172 scoped_ptr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
| 1172 grandChild->setScrollPosition(IntPoint(0, 5)); | 1173 grandChild->setScrollPosition(IntPoint(0, 5)); |
| 1173 | 1174 |
| 1174 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1175 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1175 child->setScrollPosition(IntPoint(3, 0)); | 1176 child->setScrollPosition(IntPoint(3, 0)); |
| 1176 child->addChild(grandChild.release()); | 1177 child->addChild(grandChild.Pass()); |
| 1177 | 1178 |
| 1178 root->addChild(child.release()); | 1179 root->addChild(child.Pass()); |
| 1179 m_hostImpl->setRootLayer(root.release()); | 1180 m_hostImpl->setRootLayer(root.Pass()); |
| 1180 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1181 initializeRendererAndDrawFrame(); | 1182 initializeRendererAndDrawFrame(); |
| 1182 { | 1183 { |
| 1183 IntSize scrollDelta(-8, -7); | 1184 IntSize scrollDelta(-8, -7); |
| 1184 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); | 1185 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); |
| 1185 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1186 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| 1186 m_hostImpl->scrollEnd(); | 1187 m_hostImpl->scrollEnd(); |
| 1187 | 1188 |
| 1188 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 1189 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
| 1189 | 1190 |
| 1190 // The grand child should have scrolled up to its limit. | 1191 // The grand child should have scrolled up to its limit. |
| 1191 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1192 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
| 1192 CCLayerImpl* grandChild = child->children()[0]; | 1193 CCLayerImpl* grandChild = child->children()[0]; |
| 1193 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); | 1194 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); |
| 1194 | 1195 |
| 1195 // The child should have only scrolled on the other axis. | 1196 // The child should have only scrolled on the other axis. |
| 1196 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); | 1197 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); |
| 1197 } | 1198 } |
| 1198 } | 1199 } |
| 1199 | 1200 |
| 1200 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) | 1201 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) |
| 1201 { | 1202 { |
| 1202 // When we try to scroll a non-scrollable child layer, the scroll delta | 1203 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 1203 // should be applied to one of its ancestors if possible. | 1204 // should be applied to one of its ancestors if possible. |
| 1204 IntSize surfaceSize(10, 10); | 1205 IntSize surfaceSize(10, 10); |
| 1205 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1206 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1206 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1207 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1207 | 1208 |
| 1208 child->setScrollable(false); | 1209 child->setScrollable(false); |
| 1209 root->addChild(child.release()); | 1210 root->addChild(child.Pass()); |
| 1210 | 1211 |
| 1211 m_hostImpl->setRootLayer(root.release()); | 1212 m_hostImpl->setRootLayer(root.Pass()); |
| 1212 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1213 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1213 initializeRendererAndDrawFrame(); | 1214 initializeRendererAndDrawFrame(); |
| 1214 { | 1215 { |
| 1215 IntSize scrollDelta(0, 4); | 1216 IntSize scrollDelta(0, 4); |
| 1216 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); | 1217 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); |
| 1217 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1218 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
| 1218 m_hostImpl->scrollEnd(); | 1219 m_hostImpl->scrollEnd(); |
| 1219 | 1220 |
| 1220 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); | 1221 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); |
| 1221 | 1222 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); | 1276 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); |
| 1276 } | 1277 } |
| 1277 | 1278 |
| 1278 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1279 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
| 1279 { | 1280 { |
| 1280 setupScrollAndContentsLayers(IntSize(100, 100)); | 1281 setupScrollAndContentsLayers(IntSize(100, 100)); |
| 1281 int childLayerId = 3; | 1282 int childLayerId = 3; |
| 1282 float childLayerAngle = -20; | 1283 float childLayerAngle = -20; |
| 1283 | 1284 |
| 1284 // Create a child layer that is rotated to a non-axis-aligned angle. | 1285 // Create a child layer that is rotated to a non-axis-aligned angle. |
| 1285 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl-> rootLayer()->contentBounds()); | 1286 scoped_ptr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostIm pl->rootLayer()->contentBounds()); |
| 1286 WebTransformationMatrix rotateTransform; | 1287 WebTransformationMatrix rotateTransform; |
| 1287 rotateTransform.translate(-50, -50); | 1288 rotateTransform.translate(-50, -50); |
| 1288 rotateTransform.rotate(childLayerAngle); | 1289 rotateTransform.rotate(childLayerAngle); |
| 1289 rotateTransform.translate(50, 50); | 1290 rotateTransform.translate(50, 50); |
| 1290 child->setTransform(rotateTransform); | 1291 child->setTransform(rotateTransform); |
| 1291 | 1292 |
| 1292 // Only allow vertical scrolling. | 1293 // Only allow vertical scrolling. |
| 1293 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); | 1294 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); |
| 1294 m_hostImpl->rootLayer()->addChild(child.release()); | 1295 m_hostImpl->rootLayer()->addChild(child.Pass()); |
| 1295 | 1296 |
| 1296 IntSize surfaceSize(50, 50); | 1297 IntSize surfaceSize(50, 50); |
| 1297 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1298 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1298 initializeRendererAndDrawFrame(); | 1299 initializeRendererAndDrawFrame(); |
| 1299 | 1300 |
| 1300 { | 1301 { |
| 1301 // Scroll down in screen coordinates with a gesture. | 1302 // Scroll down in screen coordinates with a gesture. |
| 1302 IntSize gestureScrollDelta(0, 10); | 1303 IntSize gestureScrollDelta(0, 10); |
| 1303 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted); | 1304 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted); |
| 1304 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1305 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1389 } | 1390 } |
| 1390 | 1391 |
| 1391 bool blend() const { return m_blend; } | 1392 bool blend() const { return m_blend; } |
| 1392 | 1393 |
| 1393 private: | 1394 private: |
| 1394 bool m_blend; | 1395 bool m_blend; |
| 1395 }; | 1396 }; |
| 1396 | 1397 |
| 1397 class BlendStateCheckLayer : public CCLayerImpl { | 1398 class BlendStateCheckLayer : public CCLayerImpl { |
| 1398 public: | 1399 public: |
| 1399 static PassOwnPtr<BlendStateCheckLayer> create(int id, CCResourceProvider* r esourceProvider) { return adoptPtr(new BlendStateCheckLayer(id, resourceProvider )); } | 1400 static scoped_ptr<CCLayerImpl> create(int id, CCResourceProvider* resourcePr ovider) { return scoped_ptr<CCLayerImpl>(new BlendStateCheckLayer(id, resourcePr ovider)); } |
| 1400 | 1401 |
| 1401 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE | 1402 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE |
| 1402 { | 1403 { |
| 1403 m_quadsAppended = true; | 1404 m_quadsAppended = true; |
| 1404 | 1405 |
| 1405 IntRect opaqueRect; | 1406 IntRect opaqueRect; |
| 1406 if (contentsOpaque()) | 1407 if (contentsOpaque()) |
| 1407 opaqueRect = m_quadRect; | 1408 opaqueRect = m_quadRect; |
| 1408 else | 1409 else |
| 1409 opaqueRect = m_opaqueContentRect; | 1410 opaqueRect = m_opaqueContentRect; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 bool m_quadsAppended; | 1451 bool m_quadsAppended; |
| 1451 IntRect m_quadRect; | 1452 IntRect m_quadRect; |
| 1452 IntRect m_opaqueContentRect; | 1453 IntRect m_opaqueContentRect; |
| 1453 IntRect m_quadVisibleRect; | 1454 IntRect m_quadVisibleRect; |
| 1454 CCResourceProvider::ResourceId m_resourceId; | 1455 CCResourceProvider::ResourceId m_resourceId; |
| 1455 }; | 1456 }; |
| 1456 | 1457 |
| 1457 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1458 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
| 1458 { | 1459 { |
| 1459 { | 1460 { |
| 1460 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1461 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 1461 root->setAnchorPoint(FloatPoint(0, 0)); | 1462 root->setAnchorPoint(FloatPoint(0, 0)); |
| 1462 root->setBounds(IntSize(10, 10)); | 1463 root->setBounds(IntSize(10, 10)); |
| 1463 root->setContentBounds(root->bounds()); | 1464 root->setContentBounds(root->bounds()); |
| 1464 root->setDrawsContent(false); | 1465 root->setDrawsContent(false); |
| 1465 m_hostImpl->setRootLayer(root.release()); | 1466 m_hostImpl->setRootLayer(root.Pass()); |
| 1466 } | 1467 } |
| 1467 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1468 CCLayerImpl* root = m_hostImpl->rootLayer(); |
| 1468 | 1469 |
| 1469 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( ))); | 1470 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( ))); |
| 1470 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]); | 1471 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]); |
| 1471 layer1->setPosition(FloatPoint(2, 2)); | 1472 layer1->setPosition(FloatPoint(2, 2)); |
| 1472 | 1473 |
| 1473 CCLayerTreeHostImpl::FrameData frame; | 1474 CCLayerTreeHostImpl::FrameData frame; |
| 1474 | 1475 |
| 1475 // Opaque layer, drawn without blending. | 1476 // Opaque layer, drawn without blending. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1742 } | 1743 } |
| 1743 | 1744 |
| 1744 bool reshapeCalled() const { return m_reshapeCalled; } | 1745 bool reshapeCalled() const { return m_reshapeCalled; } |
| 1745 | 1746 |
| 1746 private: | 1747 private: |
| 1747 bool m_reshapeCalled; | 1748 bool m_reshapeCalled; |
| 1748 }; | 1749 }; |
| 1749 | 1750 |
| 1750 class FakeDrawableCCLayerImpl: public CCLayerImpl { | 1751 class FakeDrawableCCLayerImpl: public CCLayerImpl { |
| 1751 public: | 1752 public: |
| 1753 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new FakeDrawableCCLayerImpl(id)); } | |
| 1754 protected: | |
| 1752 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } | 1755 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } |
| 1753 }; | 1756 }; |
| 1754 | 1757 |
| 1755 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1758 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 1756 // can leave the window at the wrong size if we never draw and the proper | 1759 // can leave the window at the wrong size if we never draw and the proper |
| 1757 // viewport size is never set. | 1760 // viewport size is never set. |
| 1758 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1761 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
| 1759 { | 1762 { |
| 1760 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>(); | 1763 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>(); |
| 1761 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D()); | 1764 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D()); |
| 1762 m_hostImpl->initializeRenderer(ccContext.Pass()); | 1765 m_hostImpl->initializeRenderer(ccContext.Pass()); |
| 1763 | 1766 |
| 1764 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1767 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
| 1765 root->setAnchorPoint(FloatPoint(0, 0)); | 1768 root->setAnchorPoint(FloatPoint(0, 0)); |
| 1766 root->setBounds(IntSize(10, 10)); | 1769 root->setBounds(IntSize(10, 10)); |
| 1767 root->setDrawsContent(true); | 1770 root->setDrawsContent(true); |
| 1768 m_hostImpl->setRootLayer(adoptPtr(root)); | 1771 m_hostImpl->setRootLayer(root.Pass()); |
| 1769 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 1772 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
| 1770 | 1773 |
| 1771 CCLayerTreeHostImpl::FrameData frame; | 1774 CCLayerTreeHostImpl::FrameData frame; |
| 1772 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1775 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1773 m_hostImpl->drawLayers(frame); | 1776 m_hostImpl->drawLayers(frame); |
| 1774 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 1777 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
| 1775 m_hostImpl->didDrawAllLayers(frame); | 1778 m_hostImpl->didDrawAllLayers(frame); |
| 1776 } | 1779 } |
| 1777 | 1780 |
| 1778 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { | 1781 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1804 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D()); | 1807 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D()); |
| 1805 | 1808 |
| 1806 // This test creates its own CCLayerTreeHostImpl, so | 1809 // This test creates its own CCLayerTreeHostImpl, so |
| 1807 // that we can force partial swap enabled. | 1810 // that we can force partial swap enabled. |
| 1808 CCLayerTreeSettings settings; | 1811 CCLayerTreeSettings settings; |
| 1809 CCSettings::setPartialSwapEnabled(true); | 1812 CCSettings::setPartialSwapEnabled(true); |
| 1810 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre ate(settings, this); | 1813 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre ate(settings, this); |
| 1811 layerTreeHostImpl->initializeRenderer(ccContext.Pass()); | 1814 layerTreeHostImpl->initializeRenderer(ccContext.Pass()); |
| 1812 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); | 1815 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); |
| 1813 | 1816 |
| 1814 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1817 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
| 1815 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 1818 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); |
| 1816 child->setPosition(FloatPoint(12, 13)); | 1819 child->setPosition(FloatPoint(12, 13)); |
| 1817 child->setAnchorPoint(FloatPoint(0, 0)); | 1820 child->setAnchorPoint(FloatPoint(0, 0)); |
| 1818 child->setBounds(IntSize(14, 15)); | 1821 child->setBounds(IntSize(14, 15)); |
| 1819 child->setContentBounds(IntSize(14, 15)); | 1822 child->setContentBounds(IntSize(14, 15)); |
| 1820 child->setDrawsContent(true); | 1823 child->setDrawsContent(true); |
| 1821 root->setAnchorPoint(FloatPoint(0, 0)); | 1824 root->setAnchorPoint(FloatPoint(0, 0)); |
| 1822 root->setBounds(IntSize(500, 500)); | 1825 root->setBounds(IntSize(500, 500)); |
| 1823 root->setContentBounds(IntSize(500, 500)); | 1826 root->setContentBounds(IntSize(500, 500)); |
| 1824 root->setDrawsContent(true); | 1827 root->setDrawsContent(true); |
| 1825 root->addChild(adoptPtr(child)); | 1828 root->addChild(child.Pass()); |
| 1826 layerTreeHostImpl->setRootLayer(adoptPtr(root)); | 1829 layerTreeHostImpl->setRootLayer(root.Pass()); |
| 1827 | 1830 |
| 1828 CCLayerTreeHostImpl::FrameData frame; | 1831 CCLayerTreeHostImpl::FrameData frame; |
| 1829 | 1832 |
| 1830 // First frame, the entire screen should get swapped. | 1833 // First frame, the entire screen should get swapped. |
| 1831 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 1834 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
| 1832 layerTreeHostImpl->drawLayers(frame); | 1835 layerTreeHostImpl->drawLayers(frame); |
| 1833 layerTreeHostImpl->didDrawAllLayers(frame); | 1836 layerTreeHostImpl->didDrawAllLayers(frame); |
| 1834 layerTreeHostImpl->swapBuffers(); | 1837 layerTreeHostImpl->swapBuffers(); |
| 1835 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); | 1838 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); |
| 1836 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); | 1839 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1867 actualSwapRect = partialSwapTracker->partialSwapRect(); | 1870 actualSwapRect = partialSwapTracker->partialSwapRect(); |
| 1868 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); | 1871 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); |
| 1869 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 1872 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
| 1870 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 1873 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
| 1871 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 1874 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
| 1872 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 1875 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
| 1873 } | 1876 } |
| 1874 | 1877 |
| 1875 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 1878 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
| 1876 { | 1879 { |
| 1877 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1880 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
| 1878 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 1881 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); |
| 1879 child->setAnchorPoint(FloatPoint(0, 0)); | 1882 child->setAnchorPoint(FloatPoint(0, 0)); |
| 1880 child->setBounds(IntSize(10, 10)); | 1883 child->setBounds(IntSize(10, 10)); |
| 1881 child->setContentBounds(IntSize(10, 10)); | 1884 child->setContentBounds(IntSize(10, 10)); |
| 1882 child->setDrawsContent(true); | 1885 child->setDrawsContent(true); |
| 1883 root->setAnchorPoint(FloatPoint(0, 0)); | 1886 root->setAnchorPoint(FloatPoint(0, 0)); |
| 1884 root->setBounds(IntSize(10, 10)); | 1887 root->setBounds(IntSize(10, 10)); |
| 1885 root->setContentBounds(IntSize(10, 10)); | 1888 root->setContentBounds(IntSize(10, 10)); |
| 1886 root->setDrawsContent(true); | 1889 root->setDrawsContent(true); |
| 1887 root->setOpacity(0.7f); | 1890 root->setOpacity(0.7f); |
| 1888 root->addChild(adoptPtr(child)); | 1891 root->addChild(child.Pass()); |
| 1889 | 1892 |
| 1890 m_hostImpl->setRootLayer(adoptPtr(root)); | 1893 m_hostImpl->setRootLayer(root.Pass()); |
| 1891 | 1894 |
| 1892 CCLayerTreeHostImpl::FrameData frame; | 1895 CCLayerTreeHostImpl::FrameData frame; |
| 1893 | 1896 |
| 1894 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1897 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1895 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 1898 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
| 1896 EXPECT_EQ(1u, frame.renderPasses.size()); | 1899 EXPECT_EQ(1u, frame.renderPasses.size()); |
| 1897 m_hostImpl->didDrawAllLayers(frame); | 1900 m_hostImpl->didDrawAllLayers(frame); |
| 1898 } | 1901 } |
| 1899 | 1902 |
| 1900 } // namespace | 1903 } // namespace |
| 1901 | 1904 |
| 1902 class FakeLayerWithQuads : public CCLayerImpl { | 1905 class FakeLayerWithQuads : public CCLayerImpl { |
| 1903 public: | 1906 public: |
| 1904 static PassOwnPtr<FakeLayerWithQuads> create(int id) { return adoptPtr(new F akeLayerWithQuads(id)); } | 1907 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new FakeLayerWithQuads(id)); } |
| 1905 | 1908 |
| 1906 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE | 1909 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE |
| 1907 { | 1910 { |
| 1908 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS haredQuadState()); | 1911 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS haredQuadState()); |
| 1909 | 1912 |
| 1910 SkColor gray = SkColorSetRGB(100, 100, 100); | 1913 SkColor gray = SkColorSetRGB(100, 100, 100); |
| 1911 IntRect quadRect(IntPoint(0, 0), contentBounds()); | 1914 IntRect quadRect(IntPoint(0, 0), contentBounds()); |
| 1912 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s haredQuadState, quadRect, gray); | 1915 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s haredQuadState, quadRect, gray); |
| 1913 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData); | 1916 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData); |
| 1914 } | 1917 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2109 | | | 3 | | 2112 | | | 3 | |
| 2110 | | +-------------------+ | 2113 | | +-------------------+ |
| 2111 | | | | | 2114 | | | | |
| 2112 | +-----------+ | | 2115 | +-----------+ | |
| 2113 | | | 2116 | | |
| 2114 | | | 2117 | | |
| 2115 +--------------------+ | 2118 +--------------------+ |
| 2116 | 2119 |
| 2117 Layers 1, 2 have render surfaces | 2120 Layers 1, 2 have render surfaces |
| 2118 */ | 2121 */ |
| 2119 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2122 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2120 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); | 2123 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
| 2121 OwnPtr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3); | 2124 scoped_ptr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3); |
| 2122 | 2125 |
| 2123 IntRect rootRect(0, 0, 100, 100); | 2126 IntRect rootRect(0, 0, 100, 100); |
| 2124 IntRect childRect(10, 10, 50, 50); | 2127 IntRect childRect(10, 10, 50, 50); |
| 2125 IntRect grandChildRect(5, 5, 150, 150); | 2128 IntRect grandChildRect(5, 5, 150, 150); |
| 2126 | 2129 |
| 2127 root->createRenderSurface(); | 2130 root->createRenderSurface(); |
| 2128 root->setAnchorPoint(FloatPoint(0, 0)); | 2131 root->setAnchorPoint(FloatPoint(0, 0)); |
| 2129 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 2132 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); |
| 2130 root->setBounds(IntSize(rootRect.width(), rootRect.height())); | 2133 root->setBounds(IntSize(rootRect.width(), rootRect.height())); |
| 2131 root->setContentBounds(root->bounds()); | 2134 root->setContentBounds(root->bounds()); |
| 2132 root->setVisibleContentRect(rootRect); | 2135 root->setVisibleContentRect(rootRect); |
| 2133 root->setDrawsContent(false); | 2136 root->setDrawsContent(false); |
| 2134 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w idth(), rootRect.height()))); | 2137 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w idth(), rootRect.height()))); |
| 2135 | 2138 |
| 2136 child->setAnchorPoint(FloatPoint(0, 0)); | 2139 child->setAnchorPoint(FloatPoint(0, 0)); |
| 2137 child->setPosition(FloatPoint(childRect.x(), childRect.y())); | 2140 child->setPosition(FloatPoint(childRect.x(), childRect.y())); |
| 2138 child->setOpacity(0.5f); | 2141 child->setOpacity(0.5f); |
| 2139 child->setBounds(IntSize(childRect.width(), childRect.height())); | 2142 child->setBounds(IntSize(childRect.width(), childRect.height())); |
| 2140 child->setContentBounds(child->bounds()); | 2143 child->setContentBounds(child->bounds()); |
| 2141 child->setVisibleContentRect(childRect); | 2144 child->setVisibleContentRect(childRect); |
| 2142 child->setDrawsContent(false); | 2145 child->setDrawsContent(false); |
| 2143 | 2146 |
| 2144 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 2147 grandChild->setAnchorPoint(FloatPoint(0, 0)); |
| 2145 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 2148 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); |
| 2146 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); | 2149 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); |
| 2147 grandChild->setContentBounds(grandChild->bounds()); | 2150 grandChild->setContentBounds(grandChild->bounds()); |
| 2148 grandChild->setVisibleContentRect(grandChildRect); | 2151 grandChild->setVisibleContentRect(grandChildRect); |
| 2149 grandChild->setDrawsContent(true); | 2152 grandChild->setDrawsContent(true); |
| 2150 | 2153 |
| 2151 child->addChild(grandChild.release()); | 2154 child->addChild(grandChild.Pass()); |
| 2152 root->addChild(child.release()); | 2155 root->addChild(child.Pass()); |
| 2153 | 2156 |
| 2154 myHostImpl->setRootLayer(root.release()); | 2157 myHostImpl->setRootLayer(root.Pass()); |
| 2155 return myHostImpl.Pass(); | 2158 return myHostImpl.Pass(); |
| 2156 } | 2159 } |
| 2157 | 2160 |
| 2158 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2161 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
| 2159 { | 2162 { |
| 2160 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi s); | 2163 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi s); |
| 2161 | 2164 |
| 2162 { | 2165 { |
| 2163 CCLayerTreeHostImpl::FrameData frame; | 2166 CCLayerTreeHostImpl::FrameData frame; |
| 2164 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2167 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2193 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 2196 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
| 2194 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 2197 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
| 2195 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material()); | 2198 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material()); |
| 2196 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material()); | 2199 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material()); |
| 2197 } | 2200 } |
| 2198 } | 2201 } |
| 2199 | 2202 |
| 2200 // Make sure that context lost notifications are propagated through the tree. | 2203 // Make sure that context lost notifications are propagated through the tree. |
| 2201 class ContextLostNotificationCheckLayer : public CCLayerImpl { | 2204 class ContextLostNotificationCheckLayer : public CCLayerImpl { |
| 2202 public: | 2205 public: |
| 2203 static PassOwnPtr<ContextLostNotificationCheckLayer> create(int id) { return adoptPtr(new ContextLostNotificationCheckLayer(id)); } | 2206 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new ContextLostNotificationCheckLayer(id)); } |
| 2204 | 2207 |
| 2205 virtual void didLoseContext() OVERRIDE | 2208 virtual void didLoseContext() OVERRIDE |
| 2206 { | 2209 { |
| 2207 m_didLoseContextCalled = true; | 2210 m_didLoseContextCalled = true; |
| 2208 } | 2211 } |
| 2209 | 2212 |
| 2210 bool didLoseContextCalled() const { return m_didLoseContextCalled; } | 2213 bool didLoseContextCalled() const { return m_didLoseContextCalled; } |
| 2211 | 2214 |
| 2212 private: | 2215 private: |
| 2213 explicit ContextLostNotificationCheckLayer(int id) | 2216 explicit ContextLostNotificationCheckLayer(int id) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2468 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT rack, WebRect& thumb, WebRect& endTrack) OVERRIDE | 2471 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT rack, WebRect& thumb, WebRect& endTrack) OVERRIDE |
| 2469 { | 2472 { |
| 2470 thumb = WebRect(0, 5, 5, 2); | 2473 thumb = WebRect(0, 5, 5, 2); |
| 2471 startTrack = WebRect(0, 5, 0, 5); | 2474 startTrack = WebRect(0, 5, 0, 5); |
| 2472 endTrack = WebRect(0, 0, 0, 5); | 2475 endTrack = WebRect(0, 0, 0, 5); |
| 2473 } | 2476 } |
| 2474 }; | 2477 }; |
| 2475 | 2478 |
| 2476 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl { | 2479 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl { |
| 2477 public: | 2480 public: |
| 2478 static PassOwnPtr<FakeScrollbarLayerImpl> create(int id) | 2481 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) |
| 2479 { | 2482 { |
| 2480 return adoptPtr(new FakeScrollbarLayerImpl(id)); | 2483 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); |
| 2481 } | 2484 } |
| 2482 | 2485 |
| 2483 void createResources(CCResourceProvider* provider) | 2486 void createResources(CCResourceProvider* provider) |
| 2484 { | 2487 { |
| 2485 ASSERT(provider); | 2488 ASSERT(provider); |
| 2486 int pool = 0; | 2489 int pool = 0; |
| 2487 IntSize size(10, 10); | 2490 IntSize size(10, 10); |
| 2488 GC3Denum format = GraphicsContext3D::RGBA; | 2491 GC3Denum format = GraphicsContext3D::RGBA; |
| 2489 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU sageAny; | 2492 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU sageAny; |
| 2490 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll barThemeGeometryNonEmpty::create())); | 2493 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll barThemeGeometryNonEmpty::create())); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 2512 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass()); | 2515 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass()); |
| 2513 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>()); | 2516 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>()); |
| 2514 | 2517 |
| 2515 return pass.Pass(); | 2518 return pass.Pass(); |
| 2516 } | 2519 } |
| 2517 | 2520 |
| 2518 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2521 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
| 2519 { | 2522 { |
| 2520 int layerId = 1; | 2523 int layerId = 1; |
| 2521 | 2524 |
| 2522 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); | 2525 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); |
| 2523 rootLayer->setBounds(IntSize(10, 10)); | 2526 rootLayer->setBounds(IntSize(10, 10)); |
| 2524 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2527 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2525 | 2528 |
| 2526 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); | 2529 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++) ; |
| 2527 tileLayer->setBounds(IntSize(10, 10)); | 2530 tileLayer->setBounds(IntSize(10, 10)); |
| 2528 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2531 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2529 tileLayer->setContentBounds(IntSize(10, 10)); | 2532 tileLayer->setContentBounds(IntSize(10, 10)); |
| 2530 tileLayer->setDrawsContent(true); | 2533 tileLayer->setDrawsContent(true); |
| 2531 tileLayer->setSkipsDraw(false); | 2534 tileLayer->setSkipsDraw(false); |
| 2532 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); | 2535 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); |
| 2533 tilingData->setBounds(IntSize(10, 10)); | 2536 tilingData->setBounds(IntSize(10, 10)); |
| 2534 tileLayer->setTilingData(*tilingData); | 2537 tileLayer->setTilingData(*tilingData); |
| 2535 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2538 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
| 2536 rootLayer->addChild(tileLayer.release()); | 2539 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); |
| 2537 | 2540 |
| 2538 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(layerId ++); | 2541 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(lay erId++); |
| 2539 textureLayer->setBounds(IntSize(10, 10)); | 2542 textureLayer->setBounds(IntSize(10, 10)); |
| 2540 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2543 textureLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2541 textureLayer->setContentBounds(IntSize(10, 10)); | 2544 textureLayer->setContentBounds(IntSize(10, 10)); |
| 2542 textureLayer->setDrawsContent(true); | 2545 textureLayer->setDrawsContent(true); |
| 2543 textureLayer->setTextureId(1); | 2546 textureLayer->setTextureId(1); |
| 2544 rootLayer->addChild(textureLayer.release()); | 2547 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); |
| 2545 | 2548 |
| 2546 OwnPtr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++); | 2549 scoped_ptr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++) ; |
| 2547 maskLayer->setBounds(IntSize(10, 10)); | 2550 maskLayer->setBounds(IntSize(10, 10)); |
| 2548 maskLayer->setAnchorPoint(FloatPoint(0, 0)); | 2551 maskLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2549 maskLayer->setContentBounds(IntSize(10, 10)); | 2552 maskLayer->setContentBounds(IntSize(10, 10)); |
| 2550 maskLayer->setDrawsContent(true); | 2553 maskLayer->setDrawsContent(true); |
| 2551 maskLayer->setSkipsDraw(false); | 2554 maskLayer->setSkipsDraw(false); |
| 2552 maskLayer->setTilingData(*tilingData); | 2555 maskLayer->setTilingData(*tilingData); |
| 2553 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2556 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
| 2554 | 2557 |
| 2555 OwnPtr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::create (layerId++); | 2558 scoped_ptr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::cr eate(layerId++); |
| 2556 textureLayerWithMask->setBounds(IntSize(10, 10)); | 2559 textureLayerWithMask->setBounds(IntSize(10, 10)); |
| 2557 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); | 2560 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); |
| 2558 textureLayerWithMask->setContentBounds(IntSize(10, 10)); | 2561 textureLayerWithMask->setContentBounds(IntSize(10, 10)); |
| 2559 textureLayerWithMask->setDrawsContent(true); | 2562 textureLayerWithMask->setDrawsContent(true); |
| 2560 textureLayerWithMask->setTextureId(1); | 2563 textureLayerWithMask->setTextureId(1); |
| 2561 textureLayerWithMask->setMaskLayer(maskLayer.release()); | 2564 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<CCLayerImpl>()); |
| 2562 rootLayer->addChild(textureLayerWithMask.release()); | 2565 rootLayer->addChild(textureLayerWithMask.PassAs<CCLayerImpl>()); |
| 2563 | 2566 |
| 2564 FakeVideoFrame videoFrame; | 2567 FakeVideoFrame videoFrame; |
| 2565 FakeVideoFrameProvider provider; | 2568 FakeVideoFrameProvider provider; |
| 2566 provider.setFrame(&videoFrame); | 2569 provider.setFrame(&videoFrame); |
| 2567 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++, &p rovider); | 2570 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++ , &provider); |
| 2568 videoLayer->setBounds(IntSize(10, 10)); | 2571 videoLayer->setBounds(IntSize(10, 10)); |
| 2569 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2572 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2570 videoLayer->setContentBounds(IntSize(10, 10)); | 2573 videoLayer->setContentBounds(IntSize(10, 10)); |
| 2571 videoLayer->setDrawsContent(true); | 2574 videoLayer->setDrawsContent(true); |
| 2572 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2575 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2573 rootLayer->addChild(videoLayer.release()); | 2576 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); |
| 2574 | 2577 |
| 2575 FakeVideoFrame hwVideoFrame; | 2578 FakeVideoFrame hwVideoFrame; |
| 2576 FakeVideoFrameProvider hwProvider; | 2579 FakeVideoFrameProvider hwProvider; |
| 2577 hwProvider.setFrame(&hwVideoFrame); | 2580 hwProvider.setFrame(&hwVideoFrame); |
| 2578 OwnPtr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId++, &hwProvider); | 2581 scoped_ptr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId ++, &hwProvider); |
| 2579 hwVideoLayer->setBounds(IntSize(10, 10)); | 2582 hwVideoLayer->setBounds(IntSize(10, 10)); |
| 2580 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2583 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2581 hwVideoLayer->setContentBounds(IntSize(10, 10)); | 2584 hwVideoLayer->setContentBounds(IntSize(10, 10)); |
| 2582 hwVideoLayer->setDrawsContent(true); | 2585 hwVideoLayer->setDrawsContent(true); |
| 2583 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2586 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2584 rootLayer->addChild(hwVideoLayer.release()); | 2587 rootLayer->addChild(hwVideoLayer.PassAs<CCLayerImpl>()); |
| 2585 | 2588 |
| 2586 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(l ayerId++); | 2589 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea te(layerId++); |
| 2587 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2590 ioSurfaceLayer->setBounds(IntSize(10, 10)); |
| 2588 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2591 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2589 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2592 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); |
| 2590 ioSurfaceLayer->setDrawsContent(true); | 2593 ioSurfaceLayer->setDrawsContent(true); |
| 2591 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2594 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); |
| 2592 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2595 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2593 rootLayer->addChild(ioSurfaceLayer.release()); | 2596 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); |
| 2594 | 2597 |
| 2595 OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::crea te(layerId++); | 2598 scoped_ptr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl:: create(layerId++); |
| 2596 hudLayer->setBounds(IntSize(10, 10)); | 2599 hudLayer->setBounds(IntSize(10, 10)); |
| 2597 hudLayer->setAnchorPoint(FloatPoint(0, 0)); | 2600 hudLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2598 hudLayer->setContentBounds(IntSize(10, 10)); | 2601 hudLayer->setContentBounds(IntSize(10, 10)); |
| 2599 hudLayer->setDrawsContent(true); | 2602 hudLayer->setDrawsContent(true); |
| 2600 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2603 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2601 rootLayer->addChild(hudLayer.release()); | 2604 rootLayer->addChild(hudLayer.PassAs<CCLayerImpl>()); |
| 2602 | 2605 |
| 2603 OwnPtr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::create (layerId++)); | 2606 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++)); |
| 2604 scrollbarLayer->setBounds(IntSize(10, 10)); | 2607 scrollbarLayer->setBounds(IntSize(10, 10)); |
| 2605 scrollbarLayer->setContentBounds(IntSize(10, 10)); | 2608 scrollbarLayer->setContentBounds(IntSize(10, 10)); |
| 2606 scrollbarLayer->setDrawsContent(true); | 2609 scrollbarLayer->setDrawsContent(true); |
| 2607 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2610 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2608 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); | 2611 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); |
| 2609 rootLayer->addChild(scrollbarLayer.release()); | 2612 rootLayer->addChild(scrollbarLayer.PassAs<CCLayerImpl>()); |
| 2610 | 2613 |
| 2611 OwnPtr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedRende rerLayerImpl::create(layerId++)); | 2614 scoped_ptr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedR endererLayerImpl::create(layerId++)); |
| 2612 delegatedRendererLayer->setBounds(IntSize(10, 10)); | 2615 delegatedRendererLayer->setBounds(IntSize(10, 10)); |
| 2613 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); | 2616 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); |
| 2614 delegatedRendererLayer->setDrawsContent(true); | 2617 delegatedRendererLayer->setDrawsContent(true); |
| 2615 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2618 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2616 ScopedPtrVector<CCRenderPass> passList; | 2619 ScopedPtrVector<CCRenderPass> passList; |
| 2617 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); | 2620 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); |
| 2618 delegatedRendererLayer->setRenderPasses(passList); | 2621 delegatedRendererLayer->setRenderPasses(passList); |
| 2619 EXPECT_TRUE(passList.isEmpty()); | 2622 EXPECT_TRUE(passList.isEmpty()); |
| 2620 rootLayer->addChild(delegatedRendererLayer.release()); | 2623 rootLayer->addChild(delegatedRendererLayer.PassAs<CCLayerImpl>()); |
| 2621 | 2624 |
| 2622 // Use a context that supports IOSurfaces | 2625 // Use a context that supports IOSurfaces |
| 2623 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>()); | 2626 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>()); |
| 2624 | 2627 |
| 2625 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture()); | 2628 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture()); |
| 2626 | 2629 |
| 2627 m_hostImpl->setRootLayer(rootLayer.release()); | 2630 m_hostImpl->setRootLayer(rootLayer.Pass()); |
| 2628 | 2631 |
| 2629 CCLayerTreeHostImpl::FrameData frame; | 2632 CCLayerTreeHostImpl::FrameData frame; |
| 2630 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2633 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2631 m_hostImpl->drawLayers(frame); | 2634 m_hostImpl->drawLayers(frame); |
| 2632 m_hostImpl->didDrawAllLayers(frame); | 2635 m_hostImpl->didDrawAllLayers(frame); |
| 2633 m_hostImpl->swapBuffers(); | 2636 m_hostImpl->swapBuffers(); |
| 2634 | 2637 |
| 2635 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2638 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
| 2636 | 2639 |
| 2637 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur face, | 2640 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur face, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2697 | 2700 |
| 2698 unsigned numTextures() const { return m_numTextures; } | 2701 unsigned numTextures() const { return m_numTextures; } |
| 2699 | 2702 |
| 2700 private: | 2703 private: |
| 2701 HashMap<WebGLId, bool> m_textures; | 2704 HashMap<WebGLId, bool> m_textures; |
| 2702 unsigned m_numTextures; | 2705 unsigned m_numTextures; |
| 2703 }; | 2706 }; |
| 2704 | 2707 |
| 2705 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) | 2708 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) |
| 2706 { | 2709 { |
| 2707 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); | 2710 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); |
| 2708 rootLayer->setBounds(IntSize(10, 10)); | 2711 rootLayer->setBounds(IntSize(10, 10)); |
| 2709 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2712 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2710 | 2713 |
| 2711 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); | 2714 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); |
| 2712 tileLayer->setBounds(IntSize(10, 10)); | 2715 tileLayer->setBounds(IntSize(10, 10)); |
| 2713 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2716 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2714 tileLayer->setContentBounds(IntSize(10, 10)); | 2717 tileLayer->setContentBounds(IntSize(10, 10)); |
| 2715 tileLayer->setDrawsContent(true); | 2718 tileLayer->setDrawsContent(true); |
| 2716 tileLayer->setSkipsDraw(false); | 2719 tileLayer->setSkipsDraw(false); |
| 2717 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); | 2720 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); |
| 2718 tilingData->setBounds(IntSize(10, 10)); | 2721 tilingData->setBounds(IntSize(10, 10)); |
| 2719 tileLayer->setTilingData(*tilingData); | 2722 tileLayer->setTilingData(*tilingData); |
| 2720 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2723 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
| 2721 rootLayer->addChild(tileLayer.release()); | 2724 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); |
| 2722 | 2725 |
| 2723 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); | 2726 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); |
| 2724 textureLayer->setBounds(IntSize(10, 10)); | 2727 textureLayer->setBounds(IntSize(10, 10)); |
| 2725 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2728 textureLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2726 textureLayer->setContentBounds(IntSize(10, 10)); | 2729 textureLayer->setContentBounds(IntSize(10, 10)); |
| 2727 textureLayer->setDrawsContent(true); | 2730 textureLayer->setDrawsContent(true); |
| 2728 textureLayer->setTextureId(1); | 2731 textureLayer->setTextureId(1); |
| 2729 rootLayer->addChild(textureLayer.release()); | 2732 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); |
| 2730 | 2733 |
| 2731 FakeVideoFrameProvider provider; | 2734 FakeVideoFrameProvider provider; |
| 2732 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider) ; | 2735 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provi der); |
| 2733 videoLayer->setBounds(IntSize(10, 10)); | 2736 videoLayer->setBounds(IntSize(10, 10)); |
| 2734 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2737 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2735 videoLayer->setContentBounds(IntSize(10, 10)); | 2738 videoLayer->setContentBounds(IntSize(10, 10)); |
| 2736 videoLayer->setDrawsContent(true); | 2739 videoLayer->setDrawsContent(true); |
| 2737 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2740 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2738 rootLayer->addChild(videoLayer.release()); | 2741 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); |
| 2739 | 2742 |
| 2740 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5 ); | 2743 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea te(5); |
| 2741 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2744 ioSurfaceLayer->setBounds(IntSize(10, 10)); |
| 2742 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2745 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2743 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2746 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); |
| 2744 ioSurfaceLayer->setDrawsContent(true); | 2747 ioSurfaceLayer->setDrawsContent(true); |
| 2745 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2748 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); |
| 2746 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2749 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2747 rootLayer->addChild(ioSurfaceLayer.release()); | 2750 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); |
| 2748 | 2751 |
| 2749 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of). | 2752 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of). |
| 2750 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new TrackingWebGraphicsContext3D))); | 2753 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new TrackingWebGraphicsContext3D))); |
| 2751 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(ccContext->context3D()); | 2754 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(ccContext->context3D()); |
| 2752 m_hostImpl->initializeRenderer(ccContext.Pass()); | 2755 m_hostImpl->initializeRenderer(ccContext.Pass()); |
| 2753 | 2756 |
| 2754 m_hostImpl->setRootLayer(rootLayer.release()); | 2757 m_hostImpl->setRootLayer(rootLayer.Pass()); |
| 2755 | 2758 |
| 2756 CCLayerTreeHostImpl::FrameData frame; | 2759 CCLayerTreeHostImpl::FrameData frame; |
| 2757 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2760 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2758 m_hostImpl->drawLayers(frame); | 2761 m_hostImpl->drawLayers(frame); |
| 2759 m_hostImpl->didDrawAllLayers(frame); | 2762 m_hostImpl->didDrawAllLayers(frame); |
| 2760 m_hostImpl->swapBuffers(); | 2763 m_hostImpl->swapBuffers(); |
| 2761 | 2764 |
| 2762 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); | 2765 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); |
| 2763 | 2766 |
| 2764 // Kill the layer tree. | 2767 // Kill the layer tree. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2797 // Verify no quads are drawn when transparent background is set. | 2800 // Verify no quads are drawn when transparent background is set. |
| 2798 myHostImpl->setHasTransparentBackground(true); | 2801 myHostImpl->setHasTransparentBackground(true); |
| 2799 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2802 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2800 myHostImpl->drawLayers(frame); | 2803 myHostImpl->drawLayers(frame); |
| 2801 myHostImpl->didDrawAllLayers(frame); | 2804 myHostImpl->didDrawAllLayers(frame); |
| 2802 Mock::VerifyAndClearExpectations(&mockContext); | 2805 Mock::VerifyAndClearExpectations(&mockContext); |
| 2803 } | 2806 } |
| 2804 | 2807 |
| 2805 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR ect, CCLayerImpl** result) | 2808 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR ect, CCLayerImpl** result) |
| 2806 { | 2809 { |
| 2807 OwnPtr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); | 2810 scoped_ptr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); |
| 2808 CCLayerImpl* layerPtr = layer.get(); | 2811 CCLayerImpl* layerPtr = layer.get(); |
| 2809 layerPtr->setAnchorPoint(FloatPoint(0, 0)); | 2812 layerPtr->setAnchorPoint(FloatPoint(0, 0)); |
| 2810 layerPtr->setPosition(FloatPoint(layerRect.location())); | 2813 layerPtr->setPosition(FloatPoint(layerRect.location())); |
| 2811 layerPtr->setBounds(layerRect.size()); | 2814 layerPtr->setBounds(layerRect.size()); |
| 2812 layerPtr->setContentBounds(layerRect.size()); | 2815 layerPtr->setContentBounds(layerRect.size()); |
| 2813 layerPtr->setDrawsContent(true); // only children draw content | 2816 layerPtr->setDrawsContent(true); // only children draw content |
| 2814 layerPtr->setContentsOpaque(true); | 2817 layerPtr->setContentsOpaque(true); |
| 2815 parent->addChild(layer.release()); | 2818 parent->addChild(layer.Pass()); |
| 2816 if (result) | 2819 if (result) |
| 2817 *result = layerPtr; | 2820 *result = layerPtr; |
| 2818 } | 2821 } |
| 2819 | 2822 |
| 2820 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) | 2823 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) |
| 2821 { | 2824 { |
| 2822 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 2825 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 2823 | 2826 |
| 2824 layerTreeHostImpl->initializeRenderer(context.Pass()); | 2827 layerTreeHostImpl->initializeRenderer(context.Pass()); |
| 2825 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 2828 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
| 2826 | 2829 |
| 2827 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2830 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2828 rootPtr = root.get(); | 2831 rootPtr = root.get(); |
| 2829 | 2832 |
| 2830 root->setAnchorPoint(FloatPoint(0, 0)); | 2833 root->setAnchorPoint(FloatPoint(0, 0)); |
| 2831 root->setPosition(FloatPoint(0, 0)); | 2834 root->setPosition(FloatPoint(0, 0)); |
| 2832 root->setBounds(rootSize); | 2835 root->setBounds(rootSize); |
| 2833 root->setContentBounds(rootSize); | 2836 root->setContentBounds(rootSize); |
| 2834 root->setDrawsContent(true); | 2837 root->setDrawsContent(true); |
| 2835 layerTreeHostImpl->setRootLayer(root.release()); | 2838 layerTreeHostImpl->setRootLayer(root.Pass()); |
| 2836 | 2839 |
| 2837 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei ght()), &intermediateLayerPtr); | 2840 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei ght()), &intermediateLayerPtr); |
| 2838 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 2841 intermediateLayerPtr->setDrawsContent(false); // only children draw content |
| 2839 | 2842 |
| 2840 // Surface layer is the layer that changes its opacity | 2843 // Surface layer is the layer that changes its opacity |
| 2841 // It will contain other layers that draw content. | 2844 // It will contain other layers that draw content. |
| 2842 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr); | 2845 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr); |
| 2843 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 2846 surfaceLayerPtr->setDrawsContent(false); // only children draw content |
| 2844 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 2847 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
| 2845 | 2848 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2863 CCLayerImpl* rootPtr; | 2866 CCLayerImpl* rootPtr; |
| 2864 CCLayerImpl* surfaceLayerPtr; | 2867 CCLayerImpl* surfaceLayerPtr; |
| 2865 | 2868 |
| 2866 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 2869 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 2867 | 2870 |
| 2868 IntSize rootSize(100, 100); | 2871 IntSize rootSize(100, 100); |
| 2869 | 2872 |
| 2870 myHostImpl->initializeRenderer(context.Pass()); | 2873 myHostImpl->initializeRenderer(context.Pass()); |
| 2871 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 2874 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 2872 | 2875 |
| 2873 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2876 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2874 rootPtr = root.get(); | 2877 rootPtr = root.get(); |
| 2875 | 2878 |
| 2876 root->setAnchorPoint(FloatPoint(0, 0)); | 2879 root->setAnchorPoint(FloatPoint(0, 0)); |
| 2877 root->setPosition(FloatPoint(0, 0)); | 2880 root->setPosition(FloatPoint(0, 0)); |
| 2878 root->setBounds(rootSize); | 2881 root->setBounds(rootSize); |
| 2879 root->setContentBounds(rootSize); | 2882 root->setContentBounds(rootSize); |
| 2880 root->setDrawsContent(true); | 2883 root->setDrawsContent(true); |
| 2881 root->setMasksToBounds(true); | 2884 root->setMasksToBounds(true); |
| 2882 myHostImpl->setRootLayer(root.release()); | 2885 myHostImpl->setRootLayer(root.Pass()); |
| 2883 | 2886 |
| 2884 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh t()), &surfaceLayerPtr); | 2887 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh t()), &surfaceLayerPtr); |
| 2885 surfaceLayerPtr->setDrawsContent(false); | 2888 surfaceLayerPtr->setDrawsContent(false); |
| 2886 | 2889 |
| 2887 // Surface layer is the layer that changes its opacity | 2890 // Surface layer is the layer that changes its opacity |
| 2888 // It will contain other layers that draw content. | 2891 // It will contain other layers that draw content. |
| 2889 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 2892 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
| 2890 | 2893 |
| 2891 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); | 2894 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); |
| 2892 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); | 2895 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2975 CCLayerImpl* layerS1Ptr; | 2978 CCLayerImpl* layerS1Ptr; |
| 2976 CCLayerImpl* layerS2Ptr; | 2979 CCLayerImpl* layerS2Ptr; |
| 2977 | 2980 |
| 2978 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 2981 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 2979 | 2982 |
| 2980 IntSize rootSize(1000, 1000); | 2983 IntSize rootSize(1000, 1000); |
| 2981 | 2984 |
| 2982 myHostImpl->initializeRenderer(context.Pass()); | 2985 myHostImpl->initializeRenderer(context.Pass()); |
| 2983 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 2986 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 2984 | 2987 |
| 2985 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2988 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 2986 rootPtr = root.get(); | 2989 rootPtr = root.get(); |
| 2987 | 2990 |
| 2988 root->setAnchorPoint(FloatPoint(0, 0)); | 2991 root->setAnchorPoint(FloatPoint(0, 0)); |
| 2989 root->setPosition(FloatPoint(0, 0)); | 2992 root->setPosition(FloatPoint(0, 0)); |
| 2990 root->setBounds(rootSize); | 2993 root->setBounds(rootSize); |
| 2991 root->setContentBounds(rootSize); | 2994 root->setContentBounds(rootSize); |
| 2992 root->setDrawsContent(true); | 2995 root->setDrawsContent(true); |
| 2993 root->setMasksToBounds(true); | 2996 root->setMasksToBounds(true); |
| 2994 myHostImpl->setRootLayer(root.release()); | 2997 myHostImpl->setRootLayer(root.Pass()); |
| 2995 | 2998 |
| 2996 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 2999 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); |
| 2997 layerS1Ptr->setForceRenderSurface(true); | 3000 layerS1Ptr->setForceRenderSurface(true); |
| 2998 | 3001 |
| 2999 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3002 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 |
| 3000 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3003 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 |
| 3001 | 3004 |
| 3002 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3005 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); |
| 3003 layerS2Ptr->setForceRenderSurface(true); | 3006 layerS2Ptr->setForceRenderSurface(true); |
| 3004 | 3007 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3088 CCLayerImpl* layerS1Ptr; | 3091 CCLayerImpl* layerS1Ptr; |
| 3089 CCLayerImpl* layerS2Ptr; | 3092 CCLayerImpl* layerS2Ptr; |
| 3090 | 3093 |
| 3091 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3094 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 3092 | 3095 |
| 3093 IntSize rootSize(1000, 1000); | 3096 IntSize rootSize(1000, 1000); |
| 3094 | 3097 |
| 3095 myHostImpl->initializeRenderer(context.Pass()); | 3098 myHostImpl->initializeRenderer(context.Pass()); |
| 3096 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 3099 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 3097 | 3100 |
| 3098 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3101 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3099 rootPtr = root.get(); | 3102 rootPtr = root.get(); |
| 3100 | 3103 |
| 3101 root->setAnchorPoint(FloatPoint(0, 0)); | 3104 root->setAnchorPoint(FloatPoint(0, 0)); |
| 3102 root->setPosition(FloatPoint(0, 0)); | 3105 root->setPosition(FloatPoint(0, 0)); |
| 3103 root->setBounds(rootSize); | 3106 root->setBounds(rootSize); |
| 3104 root->setContentBounds(rootSize); | 3107 root->setContentBounds(rootSize); |
| 3105 root->setDrawsContent(true); | 3108 root->setDrawsContent(true); |
| 3106 root->setMasksToBounds(true); | 3109 root->setMasksToBounds(true); |
| 3107 myHostImpl->setRootLayer(root.release()); | 3110 myHostImpl->setRootLayer(root.Pass()); |
| 3108 | 3111 |
| 3109 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); | 3112 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); |
| 3110 layerS1Ptr->setForceRenderSurface(true); | 3113 layerS1Ptr->setForceRenderSurface(true); |
| 3111 layerS1Ptr->setDrawsContent(false); | 3114 layerS1Ptr->setDrawsContent(false); |
| 3112 | 3115 |
| 3113 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3116 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 |
| 3114 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 | 3117 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 |
| 3115 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 | 3118 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 |
| 3116 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 | 3119 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 |
| 3117 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 | 3120 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3202 CCLayerImpl* layerS1Ptr; | 3205 CCLayerImpl* layerS1Ptr; |
| 3203 CCLayerImpl* layerS2Ptr; | 3206 CCLayerImpl* layerS2Ptr; |
| 3204 | 3207 |
| 3205 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3208 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 3206 | 3209 |
| 3207 IntSize rootSize(1000, 1000); | 3210 IntSize rootSize(1000, 1000); |
| 3208 | 3211 |
| 3209 myHostImpl->initializeRenderer(context.Pass()); | 3212 myHostImpl->initializeRenderer(context.Pass()); |
| 3210 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 3213 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 3211 | 3214 |
| 3212 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3215 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3213 rootPtr = root.get(); | 3216 rootPtr = root.get(); |
| 3214 | 3217 |
| 3215 root->setAnchorPoint(FloatPoint(0, 0)); | 3218 root->setAnchorPoint(FloatPoint(0, 0)); |
| 3216 root->setPosition(FloatPoint(0, 0)); | 3219 root->setPosition(FloatPoint(0, 0)); |
| 3217 root->setBounds(rootSize); | 3220 root->setBounds(rootSize); |
| 3218 root->setContentBounds(rootSize); | 3221 root->setContentBounds(rootSize); |
| 3219 root->setDrawsContent(true); | 3222 root->setDrawsContent(true); |
| 3220 root->setMasksToBounds(true); | 3223 root->setMasksToBounds(true); |
| 3221 myHostImpl->setRootLayer(root.release()); | 3224 myHostImpl->setRootLayer(root.Pass()); |
| 3222 | 3225 |
| 3223 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3226 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); |
| 3224 layerS1Ptr->setForceRenderSurface(true); | 3227 layerS1Ptr->setForceRenderSurface(true); |
| 3225 | 3228 |
| 3226 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3229 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 |
| 3227 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 | 3230 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 |
| 3228 | 3231 |
| 3229 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); | 3232 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); |
| 3230 layerS2Ptr->setForceRenderSurface(true); | 3233 layerS2Ptr->setForceRenderSurface(true); |
| 3231 | 3234 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3285 CCLayerImpl* rootPtr; | 3288 CCLayerImpl* rootPtr; |
| 3286 CCLayerImpl* layerS1Ptr; | 3289 CCLayerImpl* layerS1Ptr; |
| 3287 | 3290 |
| 3288 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3291 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 3289 | 3292 |
| 3290 IntSize rootSize(1000, 1000); | 3293 IntSize rootSize(1000, 1000); |
| 3291 | 3294 |
| 3292 myHostImpl->initializeRenderer(context.Pass()); | 3295 myHostImpl->initializeRenderer(context.Pass()); |
| 3293 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 3296 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 3294 | 3297 |
| 3295 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3298 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3296 rootPtr = root.get(); | 3299 rootPtr = root.get(); |
| 3297 | 3300 |
| 3298 root->setAnchorPoint(FloatPoint(0, 0)); | 3301 root->setAnchorPoint(FloatPoint(0, 0)); |
| 3299 root->setPosition(FloatPoint(0, 0)); | 3302 root->setPosition(FloatPoint(0, 0)); |
| 3300 root->setBounds(rootSize); | 3303 root->setBounds(rootSize); |
| 3301 root->setContentBounds(rootSize); | 3304 root->setContentBounds(rootSize); |
| 3302 root->setDrawsContent(true); | 3305 root->setDrawsContent(true); |
| 3303 root->setMasksToBounds(true); | 3306 root->setMasksToBounds(true); |
| 3304 myHostImpl->setRootLayer(root.release()); | 3307 myHostImpl->setRootLayer(root.Pass()); |
| 3305 | 3308 |
| 3306 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3309 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); |
| 3307 layerS1Ptr->setForceRenderSurface(true); | 3310 layerS1Ptr->setForceRenderSurface(true); |
| 3308 WebTransformationMatrix transform = layerS1Ptr->transform(); | 3311 WebTransformationMatrix transform = layerS1Ptr->transform(); |
| 3309 transform.translate(200, 200); | 3312 transform.translate(200, 200); |
| 3310 transform.rotate(45); | 3313 transform.rotate(45); |
| 3311 transform.translate(-200, -200); | 3314 transform.translate(-200, -200); |
| 3312 layerS1Ptr->setTransform(transform); | 3315 layerS1Ptr->setTransform(transform); |
| 3313 | 3316 |
| 3314 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 | 3317 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3370 CCLayerImpl* layerS1Ptr; | 3373 CCLayerImpl* layerS1Ptr; |
| 3371 CCLayerImpl* layerS2Ptr; | 3374 CCLayerImpl* layerS2Ptr; |
| 3372 | 3375 |
| 3373 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3376 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 3374 | 3377 |
| 3375 IntSize rootSize(1000, 1000); | 3378 IntSize rootSize(1000, 1000); |
| 3376 | 3379 |
| 3377 myHostImpl->initializeRenderer(context.Pass()); | 3380 myHostImpl->initializeRenderer(context.Pass()); |
| 3378 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); | 3381 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); |
| 3379 | 3382 |
| 3380 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3383 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3381 rootPtr = root.get(); | 3384 rootPtr = root.get(); |
| 3382 | 3385 |
| 3383 root->setAnchorPoint(FloatPoint(0, 0)); | 3386 root->setAnchorPoint(FloatPoint(0, 0)); |
| 3384 root->setPosition(FloatPoint(0, 0)); | 3387 root->setPosition(FloatPoint(0, 0)); |
| 3385 root->setBounds(rootSize); | 3388 root->setBounds(rootSize); |
| 3386 root->setContentBounds(rootSize); | 3389 root->setContentBounds(rootSize); |
| 3387 root->setDrawsContent(true); | 3390 root->setDrawsContent(true); |
| 3388 root->setMasksToBounds(true); | 3391 root->setMasksToBounds(true); |
| 3389 myHostImpl->setRootLayer(root.release()); | 3392 myHostImpl->setRootLayer(root.Pass()); |
| 3390 | 3393 |
| 3391 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 3394 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); |
| 3392 layerS1Ptr->setForceRenderSurface(true); | 3395 layerS1Ptr->setForceRenderSurface(true); |
| 3393 | 3396 |
| 3394 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3397 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 |
| 3395 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3398 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 |
| 3396 | 3399 |
| 3397 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3400 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); |
| 3398 layerS2Ptr->setForceRenderSurface(true); | 3401 layerS2Ptr->setForceRenderSurface(true); |
| 3399 | 3402 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3476 | | | 3 | | 3479 | | | 3 | |
| 3477 | | +-------------------+ | 3480 | | +-------------------+ |
| 3478 | | | | | 3481 | | | | |
| 3479 | +-----------+ | | 3482 | +-----------+ | |
| 3480 | | | 3483 | | |
| 3481 | | | 3484 | | |
| 3482 +--------------------+ | 3485 +--------------------+ |
| 3483 | 3486 |
| 3484 Layers 1, 2 have render surfaces | 3487 Layers 1, 2 have render surfaces |
| 3485 */ | 3488 */ |
| 3486 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3489 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
| 3487 OwnPtr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2); | 3490 scoped_ptr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2); |
| 3488 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3); | 3491 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); |
| 3489 | 3492 |
| 3490 IntRect rootRect(0, 0, 100, 100); | 3493 IntRect rootRect(0, 0, 100, 100); |
| 3491 IntRect childRect(10, 10, 50, 50); | 3494 IntRect childRect(10, 10, 50, 50); |
| 3492 IntRect grandChildRect(5, 5, 150, 150); | 3495 IntRect grandChildRect(5, 5, 150, 150); |
| 3493 | 3496 |
| 3494 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3497 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
| 3495 myHostImpl->initializeRenderer(context.Pass()); | 3498 myHostImpl->initializeRenderer(context.Pass()); |
| 3496 | 3499 |
| 3497 root->setAnchorPoint(FloatPoint(0, 0)); | 3500 root->setAnchorPoint(FloatPoint(0, 0)); |
| 3498 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 3501 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3516 | 3519 |
| 3517 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 3520 grandChild->setAnchorPoint(FloatPoint(0, 0)); |
| 3518 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 3521 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); |
| 3519 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); | 3522 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); |
| 3520 grandChild->setContentBounds(grandChild->bounds()); | 3523 grandChild->setContentBounds(grandChild->bounds()); |
| 3521 grandChild->setDrawsContent(true); | 3524 grandChild->setDrawsContent(true); |
| 3522 | 3525 |
| 3523 CCTiledLayerImpl* childPtr = child.get(); | 3526 CCTiledLayerImpl* childPtr = child.get(); |
| 3524 CCRenderPass::Id childPassId(childPtr->id(), 0); | 3527 CCRenderPass::Id childPassId(childPtr->id(), 0); |
| 3525 | 3528 |
| 3526 child->addChild(grandChild.release()); | 3529 child->addChild(grandChild.Pass()); |
| 3527 root->addChild(child.release()); | 3530 root->addChild(child.PassAs<CCLayerImpl>()); |
| 3528 myHostImpl->setRootLayer(root.release()); | 3531 myHostImpl->setRootLayer(root.Pass()); |
| 3529 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3532 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
| 3530 | 3533 |
| 3531 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId)); | 3534 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId)); |
| 3532 | 3535 |
| 3533 { | 3536 { |
| 3534 CCLayerTreeHostImpl::FrameData frame; | 3537 CCLayerTreeHostImpl::FrameData frame; |
| 3535 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3538 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3536 myHostImpl->drawLayers(frame); | 3539 myHostImpl->drawLayers(frame); |
| 3537 myHostImpl->didDrawAllLayers(frame); | 3540 myHostImpl->didDrawAllLayers(frame); |
| 3538 } | 3541 } |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4215 while (removeRenderPassesCases[testCaseIndex].name) { | 4218 while (removeRenderPassesCases[testCaseIndex].name) { |
| 4216 RenderPassRemovalTestData testData; | 4219 RenderPassRemovalTestData testData; |
| 4217 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); | 4220 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); |
| 4218 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); | 4221 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); |
| 4219 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); | 4222 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); |
| 4220 testCaseIndex++; | 4223 testCaseIndex++; |
| 4221 } | 4224 } |
| 4222 } | 4225 } |
| 4223 | 4226 |
| 4224 } // namespace | 4227 } // namespace |
| OLD | NEW |