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

Side by Side Diff: cc/render_surface_unittest.cc

Issue 11519018: [cc] Make LayerImpls point at LayerTreeImpl instead of LTHI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 "cc/render_surface_impl.h" 5 #include "cc/render_surface_impl.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/layer_impl.h" 8 #include "cc/layer_impl.h"
9 #include "cc/render_pass_sink.h" 9 #include "cc/render_pass_sink.h"
10 #include "cc/scoped_ptr_vector.h" 10 #include "cc/scoped_ptr_vector.h"
(...skipping 21 matching lines...) Expand all
32 EXPECT_FALSE(renderSurface->surfacePropertyChanged()) 32 EXPECT_FALSE(renderSurface->surfacePropertyChanged())
33 33
34 TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly) 34 TEST(RenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
35 { 35 {
36 // 36 //
37 // This test checks that surfacePropertyChanged() has the correct behavior. 37 // This test checks that surfacePropertyChanged() has the correct behavior.
38 // 38 //
39 39
40 FakeImplProxy proxy; 40 FakeImplProxy proxy;
41 FakeLayerTreeHostImpl hostImpl(&proxy); 41 FakeLayerTreeHostImpl hostImpl(&proxy);
42 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(&hostImpl, 1); 42 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(hostImpl.activeTree(), 1);
43 owningLayer->createRenderSurface(); 43 owningLayer->createRenderSurface();
44 ASSERT_TRUE(owningLayer->renderSurface()); 44 ASSERT_TRUE(owningLayer->renderSurface());
45 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 45 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
46 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));
47 owningLayer->resetAllChangeTrackingForSubtree(); 47 owningLayer->resetAllChangeTrackingForSubtree();
48 48
49 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are 49 // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChang ed() are
50 // the only sources of change. 50 // the only sources of change.
51 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect)); 51 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect));
52 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect)); 52 EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect));
53 53
54 owningLayer->setOpacity(0.5f); 54 owningLayer->setOpacity(0.5f);
55 EXPECT_TRUE(renderSurface->surfacePropertyChanged()); 55 EXPECT_TRUE(renderSurface->surfacePropertyChanged());
56 owningLayer->resetAllChangeTrackingForSubtree(); 56 owningLayer->resetAllChangeTrackingForSubtree();
57 57
58 // Setting the surface properties to the same values again should not be con sidered "change". 58 // Setting the surface properties to the same values again should not be con sidered "change".
59 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec t)); 59 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRec t));
60 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test Rect)); 60 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(test Rect));
61 61
62 scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(&hostImpl, 1); 62 scoped_ptr<LayerImpl> dummyMask = LayerImpl::create(hostImpl.activeTree(), 1 );
63 gfx::Transform dummyMatrix; 63 gfx::Transform dummyMatrix;
64 dummyMatrix.Translate(1.0, 2.0); 64 dummyMatrix.Translate(1.0, 2.0);
65 65
66 // 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,
67 // or they are already accounted for by the owninglayer->layerPropertyChange d(). 67 // or they are already accounted for by the owninglayer->layerPropertyChange d().
68 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) ); 68 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5) );
69 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix)); 69 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(du mmyMatrix));
70 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix)); 70 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTrans form(dummyMatrix));
71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists()); 71 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerLists());
72 } 72 }
73 73
74 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState) 74 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
75 { 75 {
76 FakeImplProxy proxy; 76 FakeImplProxy proxy;
77 FakeLayerTreeHostImpl hostImpl(&proxy); 77 FakeLayerTreeHostImpl hostImpl(&proxy);
78 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(&hostImpl, 1); 78 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(hostImpl.activeTree(), 1 );
79 79
80 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(&hostImpl, 2); 80 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(hostImpl.activeTree(), 2);
81 owningLayer->createRenderSurface(); 81 owningLayer->createRenderSurface();
82 ASSERT_TRUE(owningLayer->renderSurface()); 82 ASSERT_TRUE(owningLayer->renderSurface());
83 owningLayer->drawProperties().render_target = owningLayer.get(); 83 owningLayer->drawProperties().render_target = owningLayer.get();
84 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 84 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
85 85
86 rootLayer->addChild(owningLayer.Pass()); 86 rootLayer->addChild(owningLayer.Pass());
87 87
88 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50)); 88 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
89 gfx::Rect clipRect = gfx::Rect(gfx::Point(5, 5), gfx::Size(40, 40)); 89 gfx::Rect clipRect = gfx::Rect(gfx::Point(5, 5), gfx::Size(40, 40));
90 gfx::Transform origin; 90 gfx::Transform origin;
(...skipping 29 matching lines...) Expand all
120 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; } 120 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; }
121 121
122 private: 122 private:
123 ScopedPtrVector<RenderPass> m_renderPasses; 123 ScopedPtrVector<RenderPass> m_renderPasses;
124 }; 124 };
125 125
126 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) 126 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
127 { 127 {
128 FakeImplProxy proxy; 128 FakeImplProxy proxy;
129 FakeLayerTreeHostImpl hostImpl(&proxy); 129 FakeLayerTreeHostImpl hostImpl(&proxy);
130 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(&hostImpl, 1); 130 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(hostImpl.activeTree(), 1 );
131 131
132 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(&hostImpl, 2); 132 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(hostImpl.activeTree(), 2);
133 owningLayer->createRenderSurface(); 133 owningLayer->createRenderSurface();
134 ASSERT_TRUE(owningLayer->renderSurface()); 134 ASSERT_TRUE(owningLayer->renderSurface());
135 owningLayer->drawProperties().render_target = owningLayer.get(); 135 owningLayer->drawProperties().render_target = owningLayer.get();
136 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 136 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
137 137
138 rootLayer->addChild(owningLayer.Pass()); 138 rootLayer->addChild(owningLayer.Pass());
139 139
140 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50)); 140 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
141 gfx::Transform origin; 141 gfx::Transform origin;
142 origin.Translate(30, 40); 142 origin.Translate(30, 40);
143 143
144 renderSurface->setScreenSpaceTransform(origin); 144 renderSurface->setScreenSpaceTransform(origin);
145 renderSurface->setContentRect(contentRect); 145 renderSurface->setContentRect(contentRect);
146 146
147 TestRenderPassSink passSink; 147 TestRenderPassSink passSink;
148 148
149 renderSurface->appendRenderPasses(passSink); 149 renderSurface->appendRenderPasses(passSink);
150 150
151 ASSERT_EQ(1u, passSink.renderPasses().size()); 151 ASSERT_EQ(1u, passSink.renderPasses().size());
152 RenderPass* pass = passSink.renderPasses()[0]; 152 RenderPass* pass = passSink.renderPasses()[0];
153 153
154 EXPECT_EQ(RenderPass::Id(2, 0), pass->id); 154 EXPECT_EQ(RenderPass::Id(2, 0), pass->id);
155 EXPECT_RECT_EQ(contentRect, pass->output_rect); 155 EXPECT_RECT_EQ(contentRect, pass->output_rect);
156 EXPECT_EQ(origin, pass->transform_to_root_target); 156 EXPECT_EQ(origin, pass->transform_to_root_target);
157 } 157 }
158 158
159 } // namespace 159 } // namespace
160 } // namespace cc 160 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698