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

Side by Side Diff: cc/render_surface_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
« no previous file with comments | « cc/rate_limiter.cc ('k') | cc/renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/render_surface_impl.h" 7 #include "cc/render_surface_impl.h"
8 8
9 #include "cc/append_quads_data.h" 9 #include "cc/append_quads_data.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 21 matching lines...) Expand all
32 renderSurface->resetPropertyChangedFlag(); \ 32 renderSurface->resetPropertyChangedFlag(); \
33 codeToTest; \ 33 codeToTest; \
34 EXPECT_FALSE(renderSurface->surfacePropertyChanged()) 34 EXPECT_FALSE(renderSurface->surfacePropertyChanged())
35 35
36 TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) 36 TEST(RenderSurfaceTest, 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.
43 DebugScopedSetImplThread setImplThread;
44
45 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(1); 42 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(1);
46 owningLayer->createRenderSurface(); 43 owningLayer->createRenderSurface();
47 ASSERT_TRUE(owningLayer->renderSurface()); 44 ASSERT_TRUE(owningLayer->renderSurface());
48 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 45 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
49 gfx::Rect testRect = gfx::Rect(gfx::Point(3, 4), gfx::Size(5, 6)); 46 gfx::Rect testRect = gfx::Rect(gfx::Point(3, 4), gfx::Size(5, 6));
50 owningLayer->resetAllChangeTrackingForSubtree(); 47 owningLayer->resetAllChangeTrackingForSubtree();
51 48
52 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are 49 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are
53 // the only sources of change. 50 // the only sources of change.
54 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect)); 51 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect));
(...skipping 14 matching lines...) Expand all
69 // The rest of the surface properties are either internal and should not cau se change, 66 // 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(). 67 // or they are already accounted for by the owninglayer->layerPropertyChange d().
71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) ); 68 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) );
72 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix)); 69 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix));
73 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix)); 70 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix));
74 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists()); 71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists());
75 } 72 }
76 73
77 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) 74 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
78 { 75 {
79 // This will fake that we are on the correct thread for testing purposes.
80 DebugScopedSetImplThread setImplThread;
81
82 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1); 76 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
83 77
84 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2); 78 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
85 owningLayer->createRenderSurface(); 79 owningLayer->createRenderSurface();
86 ASSERT_TRUE(owningLayer->renderSurface()); 80 ASSERT_TRUE(owningLayer->renderSurface());
87 owningLayer->setRenderTarget(owningLayer.get()); 81 owningLayer->setRenderTarget(owningLayer.get());
88 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 82 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
89 83
90 rootLayer->addChild(owningLayer.Pass()); 84 rootLayer->addChild(owningLayer.Pass());
91 85
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 virtual void appendRenderPass(scoped_ptr<RenderPass> renderPass) OVERRIDE { m_renderPasses.append(renderPass.Pass()); } 117 virtual void appendRenderPass(scoped_ptr<RenderPass> renderPass) OVERRIDE { m_renderPasses.append(renderPass.Pass()); }
124 118
125 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; } 119 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; }
126 120
127 private: 121 private:
128 ScopedPtrVector<RenderPass> m_renderPasses; 122 ScopedPtrVector<RenderPass> m_renderPasses;
129 }; 123 };
130 124
131 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) 125 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
132 { 126 {
133 // This will fake that we are on the correct thread for testing purposes.
134 DebugScopedSetImplThread setImplThread;
135
136 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1); 127 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
137 128
138 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2); 129 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
139 owningLayer->createRenderSurface(); 130 owningLayer->createRenderSurface();
140 ASSERT_TRUE(owningLayer->renderSurface()); 131 ASSERT_TRUE(owningLayer->renderSurface());
141 owningLayer->setRenderTarget(owningLayer.get()); 132 owningLayer->setRenderTarget(owningLayer.get());
142 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 133 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
143 134
144 rootLayer->addChild(owningLayer.Pass()); 135 rootLayer->addChild(owningLayer.Pass());
145 136
(...skipping 10 matching lines...) Expand all
156 147
157 ASSERT_EQ(1u, passSink.renderPasses().size()); 148 ASSERT_EQ(1u, passSink.renderPasses().size());
158 RenderPass* pass = passSink.renderPasses()[0]; 149 RenderPass* pass = passSink.renderPasses()[0];
159 150
160 EXPECT_EQ(RenderPass::Id(2, 0), pass->id()); 151 EXPECT_EQ(RenderPass::Id(2, 0), pass->id());
161 EXPECT_RECT_EQ(contentRect, pass->outputRect()); 152 EXPECT_RECT_EQ(contentRect, pass->outputRect());
162 EXPECT_EQ(origin, pass->transformToRootTarget()); 153 EXPECT_EQ(origin, pass->transformToRootTarget());
163 } 154 }
164 155
165 } // anonymous namespace 156 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/rate_limiter.cc ('k') | cc/renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698