Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: cc/render_surface_unittest.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 #define EXECUTE_AND_VERIFY_SURFACE_CHANGED(codeToTest) \ 25 #define EXECUTE_AND_VERIFY_SURFACE_CHANGED(codeToTest) \
26 renderSurface->resetPropertyChangedFlag(); \ 26 renderSurface->resetPropertyChangedFlag(); \
27 codeToTest; \ 27 codeToTest; \
28 EXPECT_TRUE(renderSurface->surfacePropertyChanged()) 28 EXPECT_TRUE(renderSurface->surfacePropertyChanged())
29 29
30 #define EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(codeToTest) \ 30 #define EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(codeToTest) \
31 renderSurface->resetPropertyChangedFlag(); \ 31 renderSurface->resetPropertyChangedFlag(); \
32 codeToTest; \ 32 codeToTest; \
33 EXPECT_FALSE(renderSurface->surfacePropertyChanged()) 33 EXPECT_FALSE(renderSurface->surfacePropertyChanged())
34 34
35 TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) 35 TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
36 { 36 {
37 // 37 //
38 // This test checks that surfacePropertyChanged() has the correct behavior. 38 // This test checks that surfacePropertyChanged() has the correct behavior.
39 // 39 //
40 40
41 // This will fake that we are on the correct thread for testing purposes. 41 // This will fake that we are on the correct thread for testing purposes.
42 DebugScopedSetImplThread setImplThread; 42 DebugScopedSetImplThread setImplThread;
43 43
44 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(1); 44 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(1);
45 owningLayer->createRenderSurface(); 45 owningLayer->createRenderSurface();
46 ASSERT_TRUE(owningLayer->renderSurface()); 46 ASSERT_TRUE(owningLayer->renderSurface());
47 CCRenderSurface* renderSurface = owningLayer->renderSurface(); 47 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
48 IntRect testRect = IntRect(IntPoint(3, 4), IntSize(5, 6)); 48 IntRect testRect = IntRect(IntPoint(3, 4), IntSize(5, 6));
49 owningLayer->resetAllChangeTrackingForSubtree(); 49 owningLayer->resetAllChangeTrackingForSubtree();
50 50
51 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are 51 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are
52 // the only sources of change. 52 // the only sources of change.
53 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect)); 53 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect));
54 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect)); 54 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect));
55 55
56 owningLayer->setOpacity(0.5f); 56 owningLayer->setOpacity(0.5f);
57 EXPECT_TRUE(renderSurface->surfacePropertyChanged()); 57 EXPECT_TRUE(renderSurface->surfacePropertyChanged());
58 owningLayer->resetAllChangeTrackingForSubtree(); 58 owningLayer->resetAllChangeTrackingForSubtree();
59 59
60 // Setting the surface properties to the same values again should not be con sidered "change". 60 // Setting the surface properties to the same values again should not be con sidered "change".
61 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec t)); 61 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec t));
62 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test Rect)); 62 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test Rect));
63 63
64 scoped_ptr<CCLayerImpl> dummyMask = CCLayerImpl::create(1); 64 scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(1);
65 WebTransformationMatrix dummyMatrix; 65 WebTransformationMatrix dummyMatrix;
66 dummyMatrix.translate(1.0, 2.0); 66 dummyMatrix.translate(1.0, 2.0);
67 67
68 // The rest of the surface properties are either internal and should not cau se change, 68 // The rest of the surface properties are either internal and should not cau se change,
69 // or they are already accounted for by the owninglayer->layerPropertyChange d(). 69 // or they are already accounted for by the owninglayer->layerPropertyChange d().
70 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) ); 70 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) );
71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix)); 71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix));
72 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix)); 72 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix));
73 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists()); 73 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists());
74 } 74 }
75 75
76 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) 76 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
77 { 77 {
78 // This will fake that we are on the correct thread for testing purposes. 78 // This will fake that we are on the correct thread for testing purposes.
79 DebugScopedSetImplThread setImplThread; 79 DebugScopedSetImplThread setImplThread;
80 80
81 scoped_ptr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); 81 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
82 82
83 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); 83 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
84 owningLayer->createRenderSurface(); 84 owningLayer->createRenderSurface();
85 ASSERT_TRUE(owningLayer->renderSurface()); 85 ASSERT_TRUE(owningLayer->renderSurface());
86 owningLayer->setRenderTarget(owningLayer.get()); 86 owningLayer->setRenderTarget(owningLayer.get());
87 CCRenderSurface* renderSurface = owningLayer->renderSurface(); 87 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
88 88
89 rootLayer->addChild(owningLayer.Pass()); 89 rootLayer->addChild(owningLayer.Pass());
90 90
91 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); 91 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50));
92 IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40)); 92 IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40));
93 WebTransformationMatrix origin; 93 WebTransformationMatrix origin;
94 94
95 origin.translate(30, 40); 95 origin.translate(30, 40);
96 96
97 renderSurface->setDrawTransform(origin); 97 renderSurface->setDrawTransform(origin);
98 renderSurface->setContentRect(contentRect); 98 renderSurface->setContentRect(contentRect);
99 renderSurface->setClipRect(clipRect); 99 renderSurface->setClipRect(clipRect);
100 renderSurface->setDrawOpacity(1); 100 renderSurface->setDrawOpacity(1);
101 101
102 CCQuadList quadList; 102 QuadList quadList;
103 CCSharedQuadStateList sharedStateList; 103 SharedQuadStateList sharedStateList;
104 MockCCQuadCuller mockQuadCuller(quadList, sharedStateList); 104 MockQuadCuller mockQuadCuller(quadList, sharedStateList);
105 CCAppendQuadsData appendQuadsData; 105 AppendQuadsData appendQuadsData;
106 106
107 bool forReplica = false; 107 bool forReplica = false;
108 renderSurface->appendQuads(mockQuadCuller, appendQuadsData, forReplica, CCRe nderPass::Id(2, 0)); 108 renderSurface->appendQuads(mockQuadCuller, appendQuadsData, forReplica, Rend erPass::Id(2, 0));
109 109
110 ASSERT_EQ(1u, sharedStateList.size()); 110 ASSERT_EQ(1u, sharedStateList.size());
111 CCSharedQuadState* sharedQuadState = sharedStateList[0]; 111 SharedQuadState* sharedQuadState = sharedStateList[0];
112 112
113 EXPECT_EQ(30, sharedQuadState->quadTransform.m41()); 113 EXPECT_EQ(30, sharedQuadState->quadTransform.m41());
114 EXPECT_EQ(40, sharedQuadState->quadTransform.m42()); 114 EXPECT_EQ(40, sharedQuadState->quadTransform.m42());
115 EXPECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect)); 115 EXPECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect));
116 EXPECT_EQ(1, sharedQuadState->opacity); 116 EXPECT_EQ(1, sharedQuadState->opacity);
117 EXPECT_FALSE(sharedQuadState->opaque); 117 EXPECT_FALSE(sharedQuadState->opaque);
118 } 118 }
119 119
120 class TestCCRenderPassSink : public CCRenderPassSink { 120 class TestRenderPassSink : public RenderPassSink {
121 public: 121 public:
122 virtual void appendRenderPass(scoped_ptr<CCRenderPass> renderPass) OVERRIDE { m_renderPasses.append(renderPass.Pass()); } 122 virtual void appendRenderPass(scoped_ptr<RenderPass> renderPass) OVERRIDE { m_renderPasses.append(renderPass.Pass()); }
123 123
124 const ScopedPtrVector<CCRenderPass>& renderPasses() const { return m_renderP asses; } 124 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; }
125 125
126 private: 126 private:
127 ScopedPtrVector<CCRenderPass> m_renderPasses; 127 ScopedPtrVector<RenderPass> m_renderPasses;
128 }; 128 };
129 129
130 TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) 130 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
131 { 131 {
132 // This will fake that we are on the correct thread for testing purposes. 132 // This will fake that we are on the correct thread for testing purposes.
133 DebugScopedSetImplThread setImplThread; 133 DebugScopedSetImplThread setImplThread;
134 134
135 scoped_ptr<CCLayerImpl> rootLayer = CCLayerImpl::create(1); 135 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
136 136
137 scoped_ptr<CCLayerImpl> owningLayer = CCLayerImpl::create(2); 137 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
138 owningLayer->createRenderSurface(); 138 owningLayer->createRenderSurface();
139 ASSERT_TRUE(owningLayer->renderSurface()); 139 ASSERT_TRUE(owningLayer->renderSurface());
140 owningLayer->setRenderTarget(owningLayer.get()); 140 owningLayer->setRenderTarget(owningLayer.get());
141 CCRenderSurface* renderSurface = owningLayer->renderSurface(); 141 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
142 142
143 rootLayer->addChild(owningLayer.Pass()); 143 rootLayer->addChild(owningLayer.Pass());
144 144
145 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); 145 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50));
146 WebTransformationMatrix origin; 146 WebTransformationMatrix origin;
147 origin.translate(30, 40); 147 origin.translate(30, 40);
148 148
149 renderSurface->setScreenSpaceTransform(origin); 149 renderSurface->setScreenSpaceTransform(origin);
150 renderSurface->setContentRect(contentRect); 150 renderSurface->setContentRect(contentRect);
151 151
152 TestCCRenderPassSink passSink; 152 TestRenderPassSink passSink;
153 153
154 renderSurface->appendRenderPasses(passSink); 154 renderSurface->appendRenderPasses(passSink);
155 155
156 ASSERT_EQ(1u, passSink.renderPasses().size()); 156 ASSERT_EQ(1u, passSink.renderPasses().size());
157 CCRenderPass* pass = passSink.renderPasses()[0]; 157 RenderPass* pass = passSink.renderPasses()[0];
158 158
159 EXPECT_EQ(CCRenderPass::Id(2, 0), pass->id()); 159 EXPECT_EQ(RenderPass::Id(2, 0), pass->id());
160 EXPECT_EQ(contentRect, pass->outputRect()); 160 EXPECT_EQ(contentRect, pass->outputRect());
161 EXPECT_EQ(origin, pass->transformToRootTarget()); 161 EXPECT_EQ(origin, pass->transformToRootTarget());
162 } 162 }
163 163
164 } // namespace 164 } // namespace
OLDNEW
« cc/active_animation.h ('K') | « cc/render_surface_impl.cc ('k') | cc/renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698