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

Side by Side Diff: cc/quad_culler_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for landing 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
« no previous file with comments | « cc/quad_culler.cc ('k') | cc/render_pass.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/quad_culler.h" 5 #include "cc/quad_culler.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/layer_tiling_data.h" 8 #include "cc/layer_tiling_data.h"
9 #include "cc/math_util.h" 9 #include "cc/math_util.h"
10 #include "cc/occlusion_tracker.h" 10 #include "cc/occlusion_tracker.h"
11 #include "cc/overdraw_metrics.h" 11 #include "cc/overdraw_metrics.h"
12 #include "cc/single_thread_proxy.h" 12 #include "cc/single_thread_proxy.h"
13 #include "cc/tile_draw_quad.h" 13 #include "cc/tile_draw_quad.h"
14 #include "cc/tiled_layer_impl.h" 14 #include "cc/tiled_layer_impl.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include <public/WebTransformationMatrix.h> 17 #include "ui/gfx/transform.h"
18
19 using WebKit::WebTransformationMatrix;
20 18
21 namespace cc { 19 namespace cc {
22 namespace { 20 namespace {
23 21
24 class TestOcclusionTrackerImpl : public OcclusionTrackerImpl { 22 class TestOcclusionTrackerImpl : public OcclusionTrackerImpl {
25 public: 23 public:
26 TestOcclusionTrackerImpl(const gfx::Rect& scissorRectInScreen, bool recordMe tricsForFrame = true) 24 TestOcclusionTrackerImpl(const gfx::Rect& scissorRectInScreen, bool recordMe tricsForFrame = true)
27 : OcclusionTrackerImpl(scissorRectInScreen, recordMetricsForFrame) 25 : OcclusionTrackerImpl(scissorRectInScreen, recordMetricsForFrame)
28 , m_scissorRectInScreen(scissorRectInScreen) 26 , m_scissorRectInScreen(scissorRectInScreen)
29 { 27 {
30 } 28 }
31 29
32 protected: 30 protected:
33 virtual gfx::Rect layerScissorRectInTargetSurface(const LayerImpl* layer) co nst { return m_scissorRectInScreen; } 31 virtual gfx::Rect layerScissorRectInTargetSurface(const LayerImpl* layer) co nst { return m_scissorRectInScreen; }
34 32
35 private: 33 private:
36 gfx::Rect m_scissorRectInScreen; 34 gfx::Rect m_scissorRectInScreen;
37 }; 35 };
38 36
39 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, Lay erIteratorActions::FrontToBack> LayerIteratorType; 37 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, Lay erIteratorActions::FrontToBack> LayerIteratorType;
40 38
41 static scoped_ptr<TiledLayerImpl> makeLayer(TiledLayerImpl* parent, const WebTra nsformationMatrix& drawTransform, const gfx::Rect& layerRect, float opacity, boo l opaque, const gfx::Rect& layerOpaqueRect, std::vector<LayerImpl*>& surfaceLaye rList) 39 static scoped_ptr<TiledLayerImpl> makeLayer(TiledLayerImpl* parent, const gfx::T ransform& drawTransform, const gfx::Rect& layerRect, float opacity, bool opaque, const gfx::Rect& layerOpaqueRect, std::vector<LayerImpl*>& surfaceLayerList)
42 { 40 {
43 scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1); 41 scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1);
44 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(100, 1 00), LayerTilingData::NoBorderTexels); 42 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(100, 1 00), LayerTilingData::NoBorderTexels);
45 tiler->setBounds(layerRect.size()); 43 tiler->setBounds(layerRect.size());
46 layer->setTilingData(*tiler); 44 layer->setTilingData(*tiler);
47 layer->setSkipsDraw(false); 45 layer->setSkipsDraw(false);
48 layer->setDrawTransform(drawTransform); 46 layer->setDrawTransform(drawTransform);
49 layer->setScreenSpaceTransform(drawTransform); 47 layer->setScreenSpaceTransform(drawTransform);
50 layer->setVisibleContentRect(layerRect); 48 layer->setVisibleContentRect(layerRect);
51 layer->setDrawOpacity(opacity); 49 layer->setDrawOpacity(opacity);
(...skipping 30 matching lines...) Expand all
82 AppendQuadsData data; 80 AppendQuadsData data;
83 layer->appendQuads(quadCuller, data); 81 layer->appendQuads(quadCuller, data);
84 occlusionTracker.leaveLayer(it); 82 occlusionTracker.leaveLayer(it);
85 ++it; 83 ++it;
86 } 84 }
87 85
88 #define DECLARE_AND_INITIALIZE_TEST_QUADS \ 86 #define DECLARE_AND_INITIALIZE_TEST_QUADS \
89 QuadList quadList; \ 87 QuadList quadList; \
90 SharedQuadStateList sharedStateList; \ 88 SharedQuadStateList sharedStateList; \
91 std::vector<LayerImpl*> renderSurfaceLayerList; \ 89 std::vector<LayerImpl*> renderSurfaceLayerList; \
92 WebTransformationMatrix childTransform; \ 90 gfx::Transform childTransform; \
93 gfx::Size rootSize = gfx::Size(300, 300); \ 91 gfx::Size rootSize = gfx::Size(300, 300); \
94 gfx::Rect rootRect = gfx::Rect(rootSize); \ 92 gfx::Rect rootRect = gfx::Rect(rootSize); \
95 gfx::Size childSize = gfx::Size(200, 200); \ 93 gfx::Size childSize = gfx::Size(200, 200); \
96 gfx::Rect childRect = gfx::Rect(childSize); 94 gfx::Rect childRect = gfx::Rect(childSize);
97 95
98 TEST(QuadCullerTest, verifyNoCulling) 96 TEST(QuadCullerTest, verifyNoCulling)
99 { 97 {
100 DECLARE_AND_INITIALIZE_TEST_QUADS 98 DECLARE_AND_INITIALIZE_TEST_QUADS
101 99
102 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 100 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
103 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, false, gfx::Rect(), renderSurfaceLayerList); 101 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
104 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 102 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
105 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 103 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
106 104
107 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 105 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
108 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 106 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
109 EXPECT_EQ(quadList.size(), 13u); 107 EXPECT_EQ(quadList.size(), 13u);
110 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 108 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
111 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1); 109 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1);
112 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 110 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
113 } 111 }
114 112
115 TEST(QuadCullerTest, verifyCullChildLinesUpTopLeft) 113 TEST(QuadCullerTest, verifyCullChildLinesUpTopLeft)
116 { 114 {
117 DECLARE_AND_INITIALIZE_TEST_QUADS 115 DECLARE_AND_INITIALIZE_TEST_QUADS
118 116
119 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 117 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
120 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 118 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
121 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 119 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
122 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 120 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
123 121
124 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 122 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
125 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 123 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
126 EXPECT_EQ(quadList.size(), 9u); 124 EXPECT_EQ(quadList.size(), 9u);
127 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 125 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
128 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 126 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
129 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 400 00, 1); 127 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 400 00, 1);
130 } 128 }
131 129
132 TEST(QuadCullerTest, verifyCullWhenChildOpacityNotOne) 130 TEST(QuadCullerTest, verifyCullWhenChildOpacityNotOne)
133 { 131 {
134 DECLARE_AND_INITIALIZE_TEST_QUADS 132 DECLARE_AND_INITIALIZE_TEST_QUADS
135 133
136 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 134 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
137 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 0.9f, true, gfx::Rect(), renderSurfaceLayerList); 135 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 0.9f, true, gfx::Rect(), renderSurfaceLayerList);
138 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 136 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
139 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 137 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
140 138
141 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 139 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
142 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 140 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
143 EXPECT_EQ(quadList.size(), 13u); 141 EXPECT_EQ(quadList.size(), 13u);
144 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 142 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
145 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1); 143 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1);
146 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 144 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
147 } 145 }
148 146
149 TEST(QuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) 147 TEST(QuadCullerTest, verifyCullWhenChildOpaqueFlagFalse)
150 { 148 {
151 DECLARE_AND_INITIALIZE_TEST_QUADS 149 DECLARE_AND_INITIALIZE_TEST_QUADS
152 150
153 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 151 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
154 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, gfx::Rect(), renderSurfaceLayerList); 152 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, gfx::Rect(), renderSurfaceLayerList);
155 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 153 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
156 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 154 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
157 155
158 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 156 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
159 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 157 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
160 EXPECT_EQ(quadList.size(), 13u); 158 EXPECT_EQ(quadList.size(), 13u);
161 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 159 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
162 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1); 160 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 400 00, 1);
163 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 161 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
164 } 162 }
165 163
166 TEST(QuadCullerTest, verifyCullCenterTileOnly) 164 TEST(QuadCullerTest, verifyCullCenterTileOnly)
167 { 165 {
168 DECLARE_AND_INITIALIZE_TEST_QUADS 166 DECLARE_AND_INITIALIZE_TEST_QUADS
169 167
170 childTransform.translate(50, 50); 168 childTransform.Translate(50, 50);
171 169
172 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 170 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
173 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 171 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
174 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 172 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
175 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 173 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
176 174
177 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 175 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
178 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 176 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
179 ASSERT_EQ(quadList.size(), 12u); 177 ASSERT_EQ(quadList.size(), 12u);
180 178
181 gfx::Rect quadVisibleRect1 = quadList[5]->visible_rect; 179 gfx::Rect quadVisibleRect1 = quadList[5]->visible_rect;
182 EXPECT_EQ(quadVisibleRect1.height(), 50); 180 EXPECT_EQ(quadVisibleRect1.height(), 50);
(...skipping 12 matching lines...) Expand all
195 193
196 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 100000, 1); 194 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 100000, 1);
197 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 195 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
198 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 300 00, 1); 196 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 300 00, 1);
199 } 197 }
200 198
201 TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1) 199 TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1)
202 { 200 {
203 DECLARE_AND_INITIALIZE_TEST_QUADS 201 DECLARE_AND_INITIALIZE_TEST_QUADS
204 202
205 childTransform.translate(100, 100); 203 childTransform.Translate(100, 100);
206 204
207 // Make the root layer's quad have extent (99.1, 99.1) -> (200.9, 200.9) to make 205 // Make the root layer's quad have extent (99.1, 99.1) -> (200.9, 200.9) to make
208 // sure it doesn't get culled due to transform rounding. 206 // sure it doesn't get culled due to transform rounding.
209 WebTransformationMatrix rootTransform; 207 gfx::Transform rootTransform;
210 rootTransform.translate(99.1, 99.1); 208 rootTransform.Translate(99.1, 99.1);
211 rootTransform.scale(1.018); 209 rootTransform.Scale(1.018, 1.018);
212 210
213 rootRect = childRect = gfx::Rect(0, 0, 100, 100); 211 rootRect = childRect = gfx::Rect(0, 0, 100, 100);
214 212
215 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 213 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
216 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 214 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
217 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 215 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
218 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 216 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
219 217
220 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 218 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
221 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 219 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
222 EXPECT_EQ(quadList.size(), 2u); 220 EXPECT_EQ(quadList.size(), 2u);
223 221
224 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20363, 1 ); 222 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20363, 1 );
225 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 223 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
226 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 224 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
227 } 225 }
228 226
229 TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize2) 227 TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize2)
230 { 228 {
231 DECLARE_AND_INITIALIZE_TEST_QUADS 229 DECLARE_AND_INITIALIZE_TEST_QUADS
232 230
233 // Make the child's quad slightly smaller than, and centred over, the root l ayer tile. 231 // Make the child's quad slightly smaller than, and centred over, the root l ayer tile.
234 // Verify the child does not cause the quad below to be culled due to roundi ng. 232 // Verify the child does not cause the quad below to be culled due to roundi ng.
235 childTransform.translate(100.1, 100.1); 233 childTransform.Translate(100.1, 100.1);
236 childTransform.scale(0.982); 234 childTransform.Scale(0.982, 0.982);
237 235
238 WebTransformationMatrix rootTransform; 236 gfx::Transform rootTransform;
239 rootTransform.translate(100, 100); 237 rootTransform.Translate(100, 100);
240 238
241 rootRect = childRect = gfx::Rect(0, 0, 100, 100); 239 rootRect = childRect = gfx::Rect(0, 0, 100, 100);
242 240
243 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 241 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
244 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 242 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
245 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 243 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
246 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 244 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
247 245
248 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 246 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
249 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 247 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
250 EXPECT_EQ(quadList.size(), 2u); 248 EXPECT_EQ(quadList.size(), 2u);
251 249
252 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 19643, 1 ); 250 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 19643, 1 );
253 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 251 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
254 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 252 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
255 } 253 }
256 254
257 TEST(QuadCullerTest, verifyCullChildLinesUpBottomRight) 255 TEST(QuadCullerTest, verifyCullChildLinesUpBottomRight)
258 { 256 {
259 DECLARE_AND_INITIALIZE_TEST_QUADS 257 DECLARE_AND_INITIALIZE_TEST_QUADS
260 258
261 childTransform.translate(100, 100); 259 childTransform.Translate(100, 100);
262 260
263 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 261 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
264 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 262 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
265 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 263 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
266 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 264 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
267 265
268 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 266 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
269 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 267 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
270 EXPECT_EQ(quadList.size(), 9u); 268 EXPECT_EQ(quadList.size(), 9u);
271 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 269 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
272 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 270 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
273 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 400 00, 1); 271 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 400 00, 1);
274 } 272 }
275 273
276 TEST(QuadCullerTest, verifyCullSubRegion) 274 TEST(QuadCullerTest, verifyCullSubRegion)
277 { 275 {
278 DECLARE_AND_INITIALIZE_TEST_QUADS 276 DECLARE_AND_INITIALIZE_TEST_QUADS
279 277
280 childTransform.translate(50, 50); 278 childTransform.Translate(50, 50);
281 279
282 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 280 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
283 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); 281 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
284 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); 282 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
285 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 283 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
286 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 284 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
287 285
288 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 286 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
289 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 287 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
290 EXPECT_EQ(quadList.size(), 12u); 288 EXPECT_EQ(quadList.size(), 12u);
291 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 289 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
292 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 300 00, 1); 290 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 300 00, 1);
293 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 100 00, 1); 291 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 100 00, 1);
294 } 292 }
295 293
296 TEST(QuadCullerTest, verifyCullSubRegion2) 294 TEST(QuadCullerTest, verifyCullSubRegion2)
297 { 295 {
298 DECLARE_AND_INITIALIZE_TEST_QUADS 296 DECLARE_AND_INITIALIZE_TEST_QUADS
299 297
300 childTransform.translate(50, 10); 298 childTransform.Translate(50, 10);
301 299
302 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 300 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
303 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4); 301 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4);
304 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); 302 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
305 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 303 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
306 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 304 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
307 305
308 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 306 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
309 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 307 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
310 EXPECT_EQ(quadList.size(), 12u); 308 EXPECT_EQ(quadList.size(), 12u);
311 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 309 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
312 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 250 00, 1); 310 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 250 00, 1);
313 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 150 00, 1); 311 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 150 00, 1);
314 } 312 }
315 313
316 TEST(QuadCullerTest, verifyCullSubRegionCheckOvercull) 314 TEST(QuadCullerTest, verifyCullSubRegionCheckOvercull)
317 { 315 {
318 DECLARE_AND_INITIALIZE_TEST_QUADS 316 DECLARE_AND_INITIALIZE_TEST_QUADS
319 317
320 childTransform.translate(50, 49); 318 childTransform.Translate(50, 49);
321 319
322 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 320 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
323 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); 321 gfx::Rect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y () + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
324 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList); 322 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, false, childOpaqueRect, renderSurfaceLayerList);
325 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 323 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
326 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 324 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
327 325
328 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 326 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
329 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 327 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
330 EXPECT_EQ(quadList.size(), 13u); 328 EXPECT_EQ(quadList.size(), 13u);
331 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 ); 329 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 90000, 1 );
332 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 300 00, 1); 330 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 300 00, 1);
333 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 100 00, 1); 331 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 100 00, 1);
334 } 332 }
335 333
336 TEST(QuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude) 334 TEST(QuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude)
337 { 335 {
338 DECLARE_AND_INITIALIZE_TEST_QUADS 336 DECLARE_AND_INITIALIZE_TEST_QUADS
339 337
340 // Use a small rotation so as to not disturb the geometry significantly. 338 // Use a small rotation so as to not disturb the geometry significantly.
341 childTransform.rotate(1); 339 childTransform.Rotate(1);
342 340
343 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 341 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
344 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 342 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTran sform, childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
345 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 343 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
346 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 344 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
347 345
348 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 346 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
349 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 347 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
350 EXPECT_EQ(quadList.size(), 13u); 348 EXPECT_EQ(quadList.size(), 13u);
351 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 130000, 1); 349 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 130000, 1);
352 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 350 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
353 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 351 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
354 } 352 }
355 353
356 // This test requires some explanation: here we are rotating the quads to be cul led. 354 // This test requires some explanation: here we are rotating the quads to be cul led.
357 // The 2x2 tile child layer remains in the top-left corner, unrotated, but the 3 x3 355 // The 2x2 tile child layer remains in the top-left corner, unrotated, but the 3 x3
358 // tile parent layer is rotated by 1 degree. Of the four tiles the child would 356 // tile parent layer is rotated by 1 degree. Of the four tiles the child would
359 // normally occlude, three will move (slightly) out from under the child layer, and 357 // normally occlude, three will move (slightly) out from under the child layer, and
360 // one moves further under the child. Only this last tile should be culled. 358 // one moves further under the child. Only this last tile should be culled.
361 TEST(QuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled) 359 TEST(QuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled)
362 { 360 {
363 DECLARE_AND_INITIALIZE_TEST_QUADS 361 DECLARE_AND_INITIALIZE_TEST_QUADS
364 362
365 // Use a small rotation so as to not disturb the geometry significantly. 363 // Use a small rotation so as to not disturb the geometry significantly.
366 WebTransformationMatrix parentTransform; 364 gfx::Transform parentTransform;
367 parentTransform.rotate(1); 365 parentTransform.Rotate(1);
368 366
369 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRec t, 1, true, gfx::Rect(), renderSurfaceLayerList); 367 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRec t, 1, true, gfx::Rect(), renderSurfaceLayerList);
370 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 368 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
371 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ; 369 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(-100, -100, 1000, 1000)) ;
372 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 370 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
373 371
374 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 372 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
375 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 373 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
376 EXPECT_EQ(quadList.size(), 12u); 374 EXPECT_EQ(quadList.size(), 12u);
377 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 100600, 1); 375 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 100600, 1);
378 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 376 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
379 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 294 00, 1); 377 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 294 00, 1);
380 } 378 }
381 379
382 TEST(QuadCullerTest, verifyCullOutsideScissorOverTile) 380 TEST(QuadCullerTest, verifyCullOutsideScissorOverTile)
383 { 381 {
384 DECLARE_AND_INITIALIZE_TEST_QUADS 382 DECLARE_AND_INITIALIZE_TEST_QUADS
385 383
386 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 384 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
387 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 385 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
388 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(200, 100, 100, 100)); 386 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(200, 100, 100, 100));
389 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 387 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
390 388
391 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 389 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
392 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 390 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
393 EXPECT_EQ(quadList.size(), 1u); 391 EXPECT_EQ(quadList.size(), 1u);
394 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 10000, 1 ); 392 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 10000, 1 );
395 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 393 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
396 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 120 000, 1); 394 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 120 000, 1);
397 } 395 }
398 396
399 TEST(QuadCullerTest, verifyCullOutsideScissorOverCulledTile) 397 TEST(QuadCullerTest, verifyCullOutsideScissorOverCulledTile)
400 { 398 {
401 DECLARE_AND_INITIALIZE_TEST_QUADS 399 DECLARE_AND_INITIALIZE_TEST_QUADS
402 400
403 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 401 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
404 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 402 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
405 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(100, 100, 100, 100)); 403 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(100, 100, 100, 100));
406 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 404 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
407 405
408 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 406 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
409 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 407 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
410 EXPECT_EQ(quadList.size(), 1u); 408 EXPECT_EQ(quadList.size(), 1u);
411 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 10000, 1 ); 409 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 10000, 1 );
412 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 410 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
413 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 120 000, 1); 411 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 120 000, 1);
414 } 412 }
415 413
416 TEST(QuadCullerTest, verifyCullOutsideScissorOverPartialTiles) 414 TEST(QuadCullerTest, verifyCullOutsideScissorOverPartialTiles)
417 { 415 {
418 DECLARE_AND_INITIALIZE_TEST_QUADS 416 DECLARE_AND_INITIALIZE_TEST_QUADS
419 417
420 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 418 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
421 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 419 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
422 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200)); 420 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200));
423 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 421 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
424 422
425 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 423 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
426 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 424 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
427 EXPECT_EQ(quadList.size(), 9u); 425 EXPECT_EQ(quadList.size(), 9u);
428 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 40000, 1 ); 426 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 40000, 1 );
429 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 427 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
430 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 900 00, 1); 428 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 900 00, 1);
431 } 429 }
432 430
433 TEST(QuadCullerTest, verifyCullOutsideScissorOverNoTiles) 431 TEST(QuadCullerTest, verifyCullOutsideScissorOverNoTiles)
434 { 432 {
435 DECLARE_AND_INITIALIZE_TEST_QUADS 433 DECLARE_AND_INITIALIZE_TEST_QUADS
436 434
437 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 435 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
438 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 436 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
439 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(500, 500, 100, 100)); 437 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(500, 500, 100, 100));
440 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 438 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
441 439
442 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 440 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
443 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 441 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
444 EXPECT_EQ(quadList.size(), 0u); 442 EXPECT_EQ(quadList.size(), 0u);
445 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 0, 1); 443 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 0, 1);
446 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 444 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
447 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 130 000, 1); 445 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 130 000, 1);
448 } 446 }
449 447
450 TEST(QuadCullerTest, verifyWithoutMetrics) 448 TEST(QuadCullerTest, verifyWithoutMetrics)
451 { 449 {
452 DECLARE_AND_INITIALIZE_TEST_QUADS 450 DECLARE_AND_INITIALIZE_TEST_QUADS
453 451
454 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix( ), rootRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 452 scoped_ptr<TiledLayerImpl> rootLayer = makeLayer(0, gfx::Transform(), rootRe ct, 1, true, gfx::Rect(), renderSurfaceLayerList);
455 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransf ormationMatrix(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList); 453 scoped_ptr<TiledLayerImpl> childLayer = makeLayer(rootLayer.get(), gfx::Tran sform(), childRect, 1, true, gfx::Rect(), renderSurfaceLayerList);
456 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200), false ); 454 TestOcclusionTrackerImpl occlusionTracker(gfx::Rect(50, 50, 200, 200), false );
457 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList); 455 LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList);
458 456
459 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r); 457 appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracke r);
460 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker ); 458 appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker );
461 EXPECT_EQ(quadList.size(), 9u); 459 EXPECT_EQ(quadList.size(), 9u);
462 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 0, 1); 460 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 0, 1);
463 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); 461 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
464 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); 462 EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
465 } 463 }
466 464
467 } // namespace 465 } // namespace
468 } // namespace cc 466 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quad_culler.cc ('k') | cc/render_pass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698