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

Side by Side Diff: cc/quad_culler_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698