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

Side by Side Diff: cc/render_surface_unittest.cc

Issue 11275113: Remove most remaining references to IntRect and FloatRect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compositor bindings 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 | Annotate | Revision Log
« no previous file with comments | « cc/render_pass.cc ('k') | cc/scrollbar_layer_impl.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 25 matching lines...) Expand all
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 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(1); 42 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(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 IntRect testRect = IntRect(IntPoint(3, 4), IntSize(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();
(...skipping 19 matching lines...) Expand all
76 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1); 76 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
77 77
78 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2); 78 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
79 owningLayer->createRenderSurface(); 79 owningLayer->createRenderSurface();
80 ASSERT_TRUE(owningLayer->renderSurface()); 80 ASSERT_TRUE(owningLayer->renderSurface());
81 owningLayer->setRenderTarget(owningLayer.get()); 81 owningLayer->setRenderTarget(owningLayer.get());
82 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 82 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
83 83
84 rootLayer->addChild(owningLayer.Pass()); 84 rootLayer->addChild(owningLayer.Pass());
85 85
86 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); 86 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
87 IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40)); 87 gfx::Rect clipRect = gfx::Rect(gfx::Point(5, 5), gfx::Size(40, 40));
88 WebTransformationMatrix origin; 88 WebTransformationMatrix origin;
89 89
90 origin.translate(30, 40); 90 origin.translate(30, 40);
91 91
92 renderSurface->setDrawTransform(origin); 92 renderSurface->setDrawTransform(origin);
93 renderSurface->setContentRect(contentRect); 93 renderSurface->setContentRect(contentRect);
94 renderSurface->setClipRect(clipRect); 94 renderSurface->setClipRect(clipRect);
95 renderSurface->setDrawOpacity(1); 95 renderSurface->setDrawOpacity(1);
96 96
97 QuadList quadList; 97 QuadList quadList;
98 SharedQuadStateList sharedStateList; 98 SharedQuadStateList sharedStateList;
99 MockQuadCuller mockQuadCuller(quadList, sharedStateList); 99 MockQuadCuller mockQuadCuller(quadList, sharedStateList);
100 AppendQuadsData appendQuadsData; 100 AppendQuadsData appendQuadsData;
101 101
102 bool forReplica = false; 102 bool forReplica = false;
103 renderSurface->appendQuads(mockQuadCuller, appendQuadsData, forReplica, Rend erPass::Id(2, 0)); 103 renderSurface->appendQuads(mockQuadCuller, appendQuadsData, forReplica, Rend erPass::Id(2, 0));
104 104
105 ASSERT_EQ(1u, sharedStateList.size()); 105 ASSERT_EQ(1u, sharedStateList.size());
106 SharedQuadState* sharedQuadState = sharedStateList[0]; 106 SharedQuadState* sharedQuadState = sharedStateList[0];
107 107
108 EXPECT_EQ(30, sharedQuadState->quadTransform.m41()); 108 EXPECT_EQ(30, sharedQuadState->quadTransform.m41());
109 EXPECT_EQ(40, sharedQuadState->quadTransform.m42()); 109 EXPECT_EQ(40, sharedQuadState->quadTransform.m42());
110 EXPECT_RECT_EQ(contentRect, IntRect(sharedQuadState->visibleContentRect)); 110 EXPECT_RECT_EQ(contentRect, gfx::Rect(sharedQuadState->visibleContentRect));
111 EXPECT_EQ(1, sharedQuadState->opacity); 111 EXPECT_EQ(1, sharedQuadState->opacity);
112 EXPECT_FALSE(sharedQuadState->opaque); 112 EXPECT_FALSE(sharedQuadState->opaque);
113 } 113 }
114 114
115 class TestRenderPassSink : public RenderPassSink { 115 class TestRenderPassSink : public RenderPassSink {
116 public: 116 public:
117 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()); }
118 118
119 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; } 119 const ScopedPtrVector<RenderPass>& renderPasses() const { return m_renderPas ses; }
120 120
121 private: 121 private:
122 ScopedPtrVector<RenderPass> m_renderPasses; 122 ScopedPtrVector<RenderPass> m_renderPasses;
123 }; 123 };
124 124
125 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass) 125 TEST(RenderSurfaceTest, sanityCheckSurfaceCreatesCorrectRenderPass)
126 { 126 {
127 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1); 127 scoped_ptr<LayerImpl> rootLayer = LayerImpl::create(1);
128 128
129 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2); 129 scoped_ptr<LayerImpl> owningLayer = LayerImpl::create(2);
130 owningLayer->createRenderSurface(); 130 owningLayer->createRenderSurface();
131 ASSERT_TRUE(owningLayer->renderSurface()); 131 ASSERT_TRUE(owningLayer->renderSurface());
132 owningLayer->setRenderTarget(owningLayer.get()); 132 owningLayer->setRenderTarget(owningLayer.get());
133 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface(); 133 RenderSurfaceImpl* renderSurface = owningLayer->renderSurface();
134 134
135 rootLayer->addChild(owningLayer.Pass()); 135 rootLayer->addChild(owningLayer.Pass());
136 136
137 IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50)); 137 gfx::Rect contentRect = gfx::Rect(gfx::Point(), gfx::Size(50, 50));
138 WebTransformationMatrix origin; 138 WebTransformationMatrix origin;
139 origin.translate(30, 40); 139 origin.translate(30, 40);
140 140
141 renderSurface->setScreenSpaceTransform(origin); 141 renderSurface->setScreenSpaceTransform(origin);
142 renderSurface->setContentRect(contentRect); 142 renderSurface->setContentRect(contentRect);
143 143
144 TestRenderPassSink passSink; 144 TestRenderPassSink passSink;
145 145
146 renderSurface->appendRenderPasses(passSink); 146 renderSurface->appendRenderPasses(passSink);
147 147
148 ASSERT_EQ(1u, passSink.renderPasses().size()); 148 ASSERT_EQ(1u, passSink.renderPasses().size());
149 RenderPass* pass = passSink.renderPasses()[0]; 149 RenderPass* pass = passSink.renderPasses()[0];
150 150
151 EXPECT_EQ(RenderPass::Id(2, 0), pass->id()); 151 EXPECT_EQ(RenderPass::Id(2, 0), pass->id());
152 EXPECT_RECT_EQ(contentRect, pass->outputRect()); 152 EXPECT_RECT_EQ(contentRect, pass->outputRect());
153 EXPECT_EQ(origin, pass->transformToRootTarget()); 153 EXPECT_EQ(origin, pass->transformToRootTarget());
154 } 154 }
155 155
156 } // namespace 156 } // namespace
OLDNEW
« no previous file with comments | « cc/render_pass.cc ('k') | cc/scrollbar_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698