| 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 "CCRenderSurface.h" | 7 #include "CCRenderSurface.h" |
| 8 | 8 |
| 9 #include "CCAppendQuadsData.h" | 9 #include "CCAppendQuadsData.h" |
| 10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) | 36 TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) |
| 37 { | 37 { |
| 38 // | 38 // |
| 39 // This test checks that surfacePropertyChanged() has the correct behavior. | 39 // This test checks that surfacePropertyChanged() has the correct behavior. |
| 40 // | 40 // |
| 41 | 41 |
| 42 // This will fake that we are on the correct thread for testing purposes. | 42 // This will fake that we are on the correct thread for testing purposes. |
| 43 DebugScopedSetImplThread setImplThread; | 43 DebugScopedSetImplThread setImplThread; |
| 44 | 44 |
| 45 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(1); | 45 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(1); |
| 46 owningLayer->createRenderSurface(); | 46 owningLayer->createRenderSurface(); |
| 47 ASSERT_TRUE(owningLayer->renderSurface()); | 47 ASSERT_TRUE(owningLayer->renderSurface()); |
| 48 CCRenderSurface* renderSurface = owningLayer->renderSurface(); | 48 CCRenderSurface* renderSurface = owningLayer->renderSurface(); |
| 49 IntRect testRect = IntRect(IntPoint(3, 4), IntSize(5, 6)); | 49 IntRect testRect = IntRect(IntPoint(3, 4), IntSize(5, 6)); |
| 50 owningLayer->resetAllChangeTrackingForSubtree(); | 50 owningLayer->resetAllChangeTrackingForSubtree(); |
| 51 | 51 |
| 52 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang
ed() are | 52 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang
ed() are |
| 53 // the only sources of change. | 53 // the only sources of change. |
| 54 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect)); | 54 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect)); |
| 55 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect)); | 55 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect)); |
| 56 | 56 |
| 57 owningLayer->setOpacity(0.5f); | 57 owningLayer->setOpacity(0.5f); |
| 58 EXPECT_TRUE(renderSurface->surfacePropertyChanged()); | 58 EXPECT_TRUE(renderSurface->surfacePropertyChanged()); |
| 59 owningLayer->resetAllChangeTrackingForSubtree(); | 59 owningLayer->resetAllChangeTrackingForSubtree(); |
| 60 | 60 |
| 61 // Setting the surface properties to the same values again should not be con
sidered "change". | 61 // Setting the surface properties to the same values again should not be con
sidered "change". |
| 62 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec
t)); | 62 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec
t)); |
| 63 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test
Rect)); | 63 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test
Rect)); |
| 64 | 64 |
| 65 scoped_ptr<CCLayerImpl> dummyMask = CCLayerImpl::create(1); | 65 OwnPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1); |
| 66 WebTransformationMatrix dummyMatrix; | 66 WebTransformationMatrix dummyMatrix; |
| 67 dummyMatrix.translate(1.0, 2.0); | 67 dummyMatrix.translate(1.0, 2.0); |
| 68 | 68 |
| 69 // The rest of the surface properties are either internal and should not cau
se change, | 69 // The rest of the surface properties are either internal and should not cau
se change, |
| 70 // or they are already accounted for by the owninglayer->layerPropertyChange
d(). | 70 // or they are already accounted for by the owninglayer->layerPropertyChange
d(). |
| 71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5)
); | 71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5)
); |
| 72 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du
mmyMatrix)); | 72 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du
mmyMatrix)); |
| 73 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans
form(dummyMatrix)); | 73 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans
form(dummyMatrix)); |
| 74 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists()); | 74 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) | 77 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) |
| 78 { | 78 { |
| 79 // This will fake that we are on the correct thread for testing purposes. | 79 // This will fake that we are on the correct thread for testing purposes. |
| 80 DebugScopedSetImplThread setImplThread; | 80 DebugScopedSetImplThread setImplThread; |
| 81 | 81 |
| 82 scoped_ptr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); | 82 OwnPtr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); |
| 83 | 83 |
| 84 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); | 84 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); |
| 85 owningLayer->createRenderSurface(); | 85 owningLayer->createRenderSurface(); |
| 86 ASSERT_TRUE(owningLayer->renderSurface()); | 86 ASSERT_TRUE(owningLayer->renderSurface()); |
| 87 owningLayer->setRenderTarget(owningLayer.get()); | 87 owningLayer->setRenderTarget(owningLayer.get()); |
| 88 CCRenderSurface* renderSurface = owningLayer->renderSurface(); | 88 CCRenderSurface* renderSurface = owningLayer->renderSurface(); |
| 89 | 89 |
| 90 rootLayer->addChild(owningLayer.Pass()); | 90 rootLayer->addChild(owningLayer.release()); |
| 91 | 91 |
| 92 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); | 92 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); |
| 93 IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40)); | 93 IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40)); |
| 94 WebTransformationMatrix origin; | 94 WebTransformationMatrix origin; |
| 95 | 95 |
| 96 origin.translate(30, 40); | 96 origin.translate(30, 40); |
| 97 | 97 |
| 98 renderSurface->setDrawTransform(origin); | 98 renderSurface->setDrawTransform(origin); |
| 99 renderSurface->setContentRect(contentRect); | 99 renderSurface->setContentRect(contentRect); |
| 100 renderSurface->setClipRect(clipRect); | 100 renderSurface->setClipRect(clipRect); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 ScopedPtrVector<CCRenderPass> m_renderPasses; | 128 ScopedPtrVector<CCRenderPass> m_renderPasses; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) | 131 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) |
| 132 { | 132 { |
| 133 // This will fake that we are on the correct thread for testing purposes. | 133 // This will fake that we are on the correct thread for testing purposes. |
| 134 DebugScopedSetImplThread setImplThread; | 134 DebugScopedSetImplThread setImplThread; |
| 135 | 135 |
| 136 scoped_ptr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); | 136 OwnPtr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); |
| 137 | 137 |
| 138 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); | 138 OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); |
| 139 owningLayer->createRenderSurface(); | 139 owningLayer->createRenderSurface(); |
| 140 ASSERT_TRUE(owningLayer->renderSurface()); | 140 ASSERT_TRUE(owningLayer->renderSurface()); |
| 141 owningLayer->setRenderTarget(owningLayer.get()); | 141 owningLayer->setRenderTarget(owningLayer.get()); |
| 142 CCRenderSurface* renderSurface = owningLayer->renderSurface(); | 142 CCRenderSurface* renderSurface = owningLayer->renderSurface(); |
| 143 | 143 |
| 144 rootLayer->addChild(owningLayer.Pass()); | 144 rootLayer->addChild(owningLayer.release()); |
| 145 | 145 |
| 146 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); | 146 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); |
| 147 WebTransformationMatrix origin; | 147 WebTransformationMatrix origin; |
| 148 origin.translate(30, 40); | 148 origin.translate(30, 40); |
| 149 | 149 |
| 150 renderSurface->setScreenSpaceTransform(origin); | 150 renderSurface->setScreenSpaceTransform(origin); |
| 151 renderSurface->setContentRect(contentRect); | 151 renderSurface->setContentRect(contentRect); |
| 152 | 152 |
| 153 TestCCRenderPassSink passSink; | 153 TestCCRenderPassSink passSink; |
| 154 | 154 |
| 155 renderSurface->appendRenderPasses(passSink); | 155 renderSurface->appendRenderPasses(passSink); |
| 156 | 156 |
| 157 ASSERT_EQ(1u, passSink.renderPasses().size()); | 157 ASSERT_EQ(1u, passSink.renderPasses().size()); |
| 158 CCRenderPass* pass = passSink.renderPasses()[0]; | 158 CCRenderPass* pass = passSink.renderPasses()[0]; |
| 159 | 159 |
| 160 EXPECT_EQ(CCRenderPass::Id(2, 0), pass->id()); | 160 EXPECT_EQ(CCRenderPass::Id(2, 0), pass->id()); |
| 161 EXPECT_EQ(contentRect, pass->outputRect()); | 161 EXPECT_EQ(contentRect, pass->outputRect()); |
| 162 EXPECT_EQ(origin, pass->transformToRootTarget()); | 162 EXPECT_EQ(origin, pass->transformToRootTarget()); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace | 165 } // namespace |
| OLD | NEW |