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

Side by Side Diff: cc/tiled_layer_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 months 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/tiled_layer_impl_unittest.cc ('k') | cc/top_controls_manager_unittest.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/tiled_layer.h" 5 #include "cc/tiled_layer.h"
6 6
7 #include "cc/bitmap_content_layer_updater.h" 7 #include "cc/bitmap_content_layer_updater.h"
8 #include "cc/layer_painter.h" 8 #include "cc/layer_painter.h"
9 #include "cc/overdraw_metrics.h" 9 #include "cc/overdraw_metrics.h"
10 #include "cc/prioritized_resource_manager.h" 10 #include "cc/prioritized_resource_manager.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : m_proxy(NULL) 49 : m_proxy(NULL)
50 , m_outputSurface(createFakeOutputSurface()) 50 , m_outputSurface(createFakeOutputSurface())
51 , m_queue(make_scoped_ptr(new ResourceUpdateQueue)) 51 , m_queue(make_scoped_ptr(new ResourceUpdateQueue))
52 , m_occlusion(0) 52 , m_occlusion(0)
53 { 53 {
54 m_settings.maxPartialTextureUpdates = std::numeric_limits<size_t>::max() ; 54 m_settings.maxPartialTextureUpdates = std::numeric_limits<size_t>::max() ;
55 } 55 }
56 56
57 virtual void SetUp() 57 virtual void SetUp()
58 { 58 {
59 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL)); 59 layer_tree_host_ = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL));
60 m_proxy = m_layerTreeHost->proxy(); 60 m_proxy = layer_tree_host_->proxy();
61 m_resourceManager = PrioritizedResourceManager::create(m_proxy); 61 m_resourceManager = PrioritizedResourceManager::create(m_proxy);
62 m_layerTreeHost->initializeRendererIfNeeded(); 62 layer_tree_host_->initializeRendererIfNeeded();
63 m_layerTreeHost->setRootLayer(Layer::create()); 63 layer_tree_host_->setRootLayer(Layer::Create());
64 64
65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); 65 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
66 m_resourceProvider = ResourceProvider::Create(m_outputSurface.get()); 66 m_resourceProvider = ResourceProvider::Create(m_outputSurface.get());
67 m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy)); 67 m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy));
68 } 68 }
69 69
70 virtual ~TiledLayerTest() 70 virtual ~TiledLayerTest()
71 { 71 {
72 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get()); 72 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get());
73 73
(...skipping 20 matching lines...) Expand all
94 NULL, 94 NULL,
95 m_proxy->ImplThread(), 95 m_proxy->ImplThread(),
96 m_queue.Pass(), 96 m_queue.Pass(),
97 m_resourceProvider.get()); 97 m_resourceProvider.get());
98 updateController->Finalize(); 98 updateController->Finalize();
99 m_queue = make_scoped_ptr(new ResourceUpdateQueue); 99 m_queue = make_scoped_ptr(new ResourceUpdateQueue);
100 } 100 }
101 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl) 101 void layerPushPropertiesTo(FakeTiledLayer* layer, FakeTiledLayerImpl* layerI mpl)
102 { 102 {
103 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); 103 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy);
104 layer->pushPropertiesTo(layerImpl); 104 layer->PushPropertiesTo(layerImpl);
105 } 105 }
106 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) 106 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded)
107 { 107 {
108 DebugScopedSetMainThread mainThread(m_proxy); 108 DebugScopedSetMainThread mainThread(m_proxy);
109 layer->update(*m_queue.get(), occluded, NULL); 109 layer->Update(m_queue.get(), occluded, NULL);
110 } 110 }
111 111
112 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) 112 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1)
113 { 113 {
114 scoped_refptr<FakeTiledLayer> layer2; 114 scoped_refptr<FakeTiledLayer> layer2;
115 calcDrawProps(layer1, layer2); 115 calcDrawProps(layer1, layer2);
116 } 116 }
117 117
118 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, 118 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1,
119 const scoped_refptr<FakeTiledLayer>& layer2) 119 const scoped_refptr<FakeTiledLayer>& layer2)
120 { 120 {
121 if (layer1 && !layer1->parent()) 121 if (layer1 && !layer1->parent())
122 m_layerTreeHost->rootLayer()->addChild(layer1); 122 layer_tree_host_->rootLayer()->AddChild(layer1);
123 if (layer2 && !layer2->parent()) 123 if (layer2 && !layer2->parent())
124 m_layerTreeHost->rootLayer()->addChild(layer2); 124 layer_tree_host_->rootLayer()->AddChild(layer2);
125 if (m_occlusion) 125 if (m_occlusion)
126 m_occlusion->setRenderTarget(m_layerTreeHost->rootLayer()); 126 m_occlusion->setRenderTarget(layer_tree_host_->rootLayer());
127 127
128 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; 128 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
129 LayerTreeHostCommon::calculateDrawProperties( 129 LayerTreeHostCommon::calculateDrawProperties(
130 m_layerTreeHost->rootLayer(), 130 layer_tree_host_->rootLayer(),
131 m_layerTreeHost->deviceViewportSize(), 131 layer_tree_host_->deviceViewportSize(),
132 m_layerTreeHost->deviceScaleFactor(), 132 layer_tree_host_->deviceScaleFactor(),
133 1, // page_scale_factor 133 1, // page_scale_factor
134 m_layerTreeHost->rendererCapabilities().maxTextureSize, 134 layer_tree_host_->rendererCapabilities().maxTextureSize,
135 false, // can_use_lcd_text 135 false, // can_use_lcd_text
136 renderSurfaceLayerList); 136 renderSurfaceLayerList);
137 } 137 }
138 138
139 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, 139 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1,
140 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1) 140 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1)
141 { 141 {
142 scoped_refptr<FakeTiledLayer> layer2; 142 scoped_refptr<FakeTiledLayer> layer2;
143 scoped_ptr<FakeTiledLayerImpl> layerImpl2; 143 scoped_ptr<FakeTiledLayerImpl> layerImpl2;
144 return updateAndPush(layer1, layerImpl1, layer2, layerImpl2); 144 return updateAndPush(layer1, layerImpl1, layer2, layerImpl2);
145 } 145 }
146 146
147 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, 147 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1,
148 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1, 148 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1,
149 const scoped_refptr<FakeTiledLayer>& layer2, 149 const scoped_refptr<FakeTiledLayer>& layer2,
150 const scoped_ptr<FakeTiledLayerImpl>& layerImpl2) 150 const scoped_ptr<FakeTiledLayerImpl>& layerImpl2)
151 { 151 {
152 // Get textures 152 // Get textures
153 m_resourceManager->clearPriorities(); 153 m_resourceManager->clearPriorities();
154 if (layer1) 154 if (layer1)
155 layer1->setTexturePriorities(m_priorityCalculator); 155 layer1->SetTexturePriorities(m_priorityCalculator);
156 if (layer2) 156 if (layer2)
157 layer2->setTexturePriorities(m_priorityCalculator); 157 layer2->SetTexturePriorities(m_priorityCalculator);
158 m_resourceManager->prioritizeTextures(); 158 m_resourceManager->prioritizeTextures();
159 159
160 // Update content 160 // Update content
161 if (layer1) 161 if (layer1)
162 layer1->update(*m_queue.get(), m_occlusion, NULL); 162 layer1->Update(m_queue.get(), m_occlusion, NULL);
163 if (layer2) 163 if (layer2)
164 layer2->update(*m_queue.get(), m_occlusion, NULL); 164 layer2->Update(m_queue.get(), m_occlusion, NULL);
165 165
166 bool needsUpdate = false; 166 bool needsUpdate = false;
167 if (layer1) 167 if (layer1)
168 needsUpdate |= layer1->needsIdlePaint(); 168 needsUpdate |= layer1->needsIdlePaint();
169 if (layer2) 169 if (layer2)
170 needsUpdate |= layer2->needsIdlePaint(); 170 needsUpdate |= layer2->needsIdlePaint();
171 171
172 // Update textures and push. 172 // Update textures and push.
173 updateTextures(); 173 updateTextures();
174 if (layer1) 174 if (layer1)
175 layerPushPropertiesTo(layer1.get(), layerImpl1.get()); 175 layerPushPropertiesTo(layer1.get(), layerImpl1.get());
176 if (layer2) 176 if (layer2)
177 layerPushPropertiesTo(layer2.get(), layerImpl2.get()); 177 layerPushPropertiesTo(layer2.get(), layerImpl2.get());
178 178
179 return needsUpdate; 179 return needsUpdate;
180 } 180 }
181 181
182 public: 182 public:
183 Proxy* m_proxy; 183 Proxy* m_proxy;
184 LayerTreeSettings m_settings; 184 LayerTreeSettings m_settings;
185 scoped_ptr<OutputSurface> m_outputSurface; 185 scoped_ptr<OutputSurface> m_outputSurface;
186 scoped_ptr<ResourceProvider> m_resourceProvider; 186 scoped_ptr<ResourceProvider> m_resourceProvider;
187 scoped_ptr<ResourceUpdateQueue> m_queue; 187 scoped_ptr<ResourceUpdateQueue> m_queue;
188 PriorityCalculator m_priorityCalculator; 188 PriorityCalculator m_priorityCalculator;
189 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; 189 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
190 scoped_ptr<LayerTreeHost> m_layerTreeHost; 190 scoped_ptr<LayerTreeHost> layer_tree_host_;
191 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; 191 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl;
192 scoped_ptr<PrioritizedResourceManager> m_resourceManager; 192 scoped_ptr<PrioritizedResourceManager> m_resourceManager;
193 TestOcclusionTracker* m_occlusion; 193 TestOcclusionTracker* m_occlusion;
194 }; 194 };
195 195
196 TEST_F(TiledLayerTest, pushDirtyTiles) 196 TEST_F(TiledLayerTest, pushDirtyTiles)
197 { 197 {
198 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 198 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
199 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 199 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
200 200
201 // The tile size is 100x100, so this invalidates and then paints two tiles. 201 // The tile size is 100x100, so this invalidates and then paints two tiles.
202 layer->setBounds(gfx::Size(100, 200)); 202 layer->SetBounds(gfx::Size(100, 200));
203 calcDrawProps(layer); 203 calcDrawProps(layer);
204 updateAndPush(layer, layerImpl); 204 updateAndPush(layer, layerImpl);
205 205
206 // We should have both tiles on the impl side. 206 // We should have both tiles on the impl side.
207 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 207 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
208 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 208 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
209 209
210 // Invalidates both tiles, but then only update one of them. 210 // Invalidates both tiles, but then only update one of them.
211 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); 211 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
212 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 212 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
213 updateAndPush(layer, layerImpl); 213 updateAndPush(layer, layerImpl);
214 214
215 // We should only have the first tile since the other tile was invalidated b ut not painted. 215 // We should only have the first tile since the other tile was invalidated b ut not painted.
216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
217 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 217 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
218 } 218 }
219 219
220 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) 220 TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
221 { 221 {
222 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 222 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
223 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 223 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
224 TestOcclusionTracker occluded; 224 TestOcclusionTracker occluded;
225 m_occlusion = &occluded; 225 m_occlusion = &occluded;
226 m_layerTreeHost->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 1000 )); 226 layer_tree_host_->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 100 0));
227 227
228 // The tile size is 100x100, so this invalidates and then paints two tiles. 228 // The tile size is 100x100, so this invalidates and then paints two tiles.
229 layer->setBounds(gfx::Size(100, 200)); 229 layer->SetBounds(gfx::Size(100, 200));
230 calcDrawProps(layer); 230 calcDrawProps(layer);
231 updateAndPush(layer, layerImpl); 231 updateAndPush(layer, layerImpl);
232 232
233 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 233 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
234 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000, 1); 234 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000, 1);
235 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 235 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
236 236
237 // We should have both tiles on the impl side. 237 // We should have both tiles on the impl side.
238 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 238 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
239 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 239 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
(...skipping 13 matching lines...) Expand all
253 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 253 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
254 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 254 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
255 } 255 }
256 256
257 TEST_F(TiledLayerTest, pushDeletedTiles) 257 TEST_F(TiledLayerTest, pushDeletedTiles)
258 { 258 {
259 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 259 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
260 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 260 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
261 261
262 // The tile size is 100x100, so this invalidates and then paints two tiles. 262 // The tile size is 100x100, so this invalidates and then paints two tiles.
263 layer->setBounds(gfx::Size(100, 200)); 263 layer->SetBounds(gfx::Size(100, 200));
264 calcDrawProps(layer); 264 calcDrawProps(layer);
265 updateAndPush(layer, layerImpl); 265 updateAndPush(layer, layerImpl);
266 266
267 // We should have both tiles on the impl side. 267 // We should have both tiles on the impl side.
268 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 268 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
269 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 269 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
270 270
271 m_resourceManager->clearPriorities(); 271 m_resourceManager->clearPriorities();
272 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge t()); 272 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge t());
273 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024); 273 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024);
274 274
275 // This should drop the tiles on the impl thread. 275 // This should drop the tiles on the impl thread.
276 layerPushPropertiesTo(layer.get(), layerImpl.get()); 276 layerPushPropertiesTo(layer.get(), layerImpl.get());
277 277
278 // We should now have no textures on the impl thread. 278 // We should now have no textures on the impl thread.
279 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 279 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
280 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 280 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
281 281
282 // This should recreate and update one of the deleted textures. 282 // This should recreate and update one of the deleted textures.
283 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 283 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
284 updateAndPush(layer, layerImpl); 284 updateAndPush(layer, layerImpl);
285 285
286 // We should have one tiles on the impl side. 286 // We should have one tiles on the impl side.
287 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 287 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
288 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 288 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
289 } 289 }
290 290
291 TEST_F(TiledLayerTest, pushIdlePaintTiles) 291 TEST_F(TiledLayerTest, pushIdlePaintTiles)
292 { 292 {
293 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 293 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
294 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 294 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
295 295
296 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. 296 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter.
297 // This paints 1 visible of the 25 invalid tiles. 297 // This paints 1 visible of the 25 invalid tiles.
298 layer->setBounds(gfx::Size(500, 500)); 298 layer->SetBounds(gfx::Size(500, 500));
299 calcDrawProps(layer); 299 calcDrawProps(layer);
300 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100) ; 300 layer->draw_properties().visible_content_rect = gfx::Rect(200, 200, 100, 100 );
301 bool needsUpdate = updateAndPush(layer, layerImpl); 301 bool needsUpdate = updateAndPush(layer, layerImpl);
302 // We should need idle-painting for surrounding tiles. 302 // We should need idle-painting for surrounding tiles.
303 EXPECT_TRUE(needsUpdate); 303 EXPECT_TRUE(needsUpdate);
304 304
305 // We should have one tile on the impl side. 305 // We should have one tile on the impl side.
306 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); 306 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2));
307 307
308 // For the next four updates, we should detect we still need idle painting. 308 // For the next four updates, we should detect we still need idle painting.
309 for (int i = 0; i < 4; i++) { 309 for (int i = 0; i < 4; i++) {
310 needsUpdate = updateAndPush(layer, layerImpl); 310 needsUpdate = updateAndPush(layer, layerImpl);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 gfx::Rect(2, 2, 3, 1) }; 354 gfx::Rect(2, 2, 3, 1) };
355 for(int k = 0; k < 6; k++) { 355 for(int k = 0; k < 6; k++) {
356 // The tile size is 100x100. Setup 5x5 tiles with one visible tile 356 // The tile size is 100x100. Setup 5x5 tiles with one visible tile
357 // in the center. 357 // in the center.
358 gfx::Size bounds = gfx::Size(500, 500); 358 gfx::Size bounds = gfx::Size(500, 500);
359 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); 359 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100);
360 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi ons[k], visibleRect.size()); 360 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi ons[k], visibleRect.size());
361 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[ k], visibleRect.size()); 361 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[ k], visibleRect.size());
362 362
363 // Setup. Use the previousVisibleRect to setup the prediction for next f rame. 363 // Setup. Use the previousVisibleRect to setup the prediction for next f rame.
364 layer->setBounds(bounds); 364 layer->SetBounds(bounds);
365 calcDrawProps(layer); 365 calcDrawProps(layer);
366 layer->drawProperties().visible_content_rect = previousVisibleRect; 366 layer->draw_properties().visible_content_rect = previousVisibleRect;
367 bool needsUpdate = updateAndPush(layer, layerImpl); 367 bool needsUpdate = updateAndPush(layer, layerImpl);
368 368
369 // Invalidate and move the visibleRect in the scroll direction. 369 // Invalidate and move the visibleRect in the scroll direction.
370 // Check that the correct tiles have been painted in the visible pass. 370 // Check that the correct tiles have been painted in the visible pass.
371 layer->setNeedsDisplay(); 371 layer->SetNeedsDisplay();
372 layer->drawProperties().visible_content_rect = visibleRect; 372 layer->draw_properties().visible_content_rect = visibleRect;
373 needsUpdate = updateAndPush(layer, layerImpl); 373 needsUpdate = updateAndPush(layer, layerImpl);
374 for (int i = 0; i < 5; i++) { 374 for (int i = 0; i < 5; i++) {
375 for (int j = 0; j < 5; j++) 375 for (int j = 0; j < 5; j++)
376 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible Tiles[k].Contains(i, j)); 376 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible Tiles[k].Contains(i, j));
377 } 377 }
378 378
379 // Move the transform in the same direction without invalidating. 379 // Move the transform in the same direction without invalidating.
380 // Check that non-visible pre-painting occured in the correct direction. 380 // Check that non-visible pre-painting occured in the correct direction.
381 // Ignore diagonal scrolls here (k > 3) as these have new visible conten t now. 381 // Ignore diagonal scrolls here (k > 3) as these have new visible conten t now.
382 if (k <= 3) { 382 if (k <= 3) {
383 layer->drawProperties().visible_content_rect = nextVisibleRect; 383 layer->draw_properties().visible_content_rect = nextVisibleRect;
384 needsUpdate = updateAndPush(layer, layerImpl); 384 needsUpdate = updateAndPush(layer, layerImpl);
385 for (int i = 0; i < 5; i++) { 385 for (int i = 0; i < 5; i++) {
386 for (int j = 0; j < 5; j++) 386 for (int j = 0; j < 5; j++)
387 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre paintTiles[k].Contains(i, j)); 387 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre paintTiles[k].Contains(i, j));
388 } 388 }
389 } 389 }
390 390
391 // We should always finish painting eventually. 391 // We should always finish painting eventually.
392 for (int i = 0; i < 20; i++) 392 for (int i = 0; i < 20; i++)
393 needsUpdate = updateAndPush(layer, layerImpl); 393 needsUpdate = updateAndPush(layer, layerImpl);
(...skipping 14 matching lines...) Expand all
408 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint 408 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
409 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state. 409 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state.
410 410
411 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer. 411 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer.
412 gfx::Rect layer1Rect(0, 0, 100, 2400); 412 gfx::Rect layer1Rect(0, 0, 100, 2400);
413 413
414 // This requires 4*30000 bytes of memory. 414 // This requires 4*30000 bytes of memory.
415 gfx::Rect layer2Rect(0, 0, 100, 300); 415 gfx::Rect layer2Rect(0, 0, 100, 300);
416 416
417 // Paint a single tile in layer2 so that it will idle paint. 417 // Paint a single tile in layer2 so that it will idle paint.
418 layer1->setBounds(layer1Rect.size()); 418 layer1->SetBounds(layer1Rect.size());
419 layer2->setBounds(layer2Rect.size()); 419 layer2->SetBounds(layer2Rect.size());
420 calcDrawProps(layer1, layer2); 420 calcDrawProps(layer1, layer2);
421 layer1->drawProperties().visible_content_rect = layer1Rect; 421 layer1->draw_properties().visible_content_rect = layer1Rect;
422 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 422 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
423 bool needsUpdate = updateAndPush(layer1, layerImpl1, 423 bool needsUpdate = updateAndPush(layer1, layerImpl1,
424 layer2, layerImpl2); 424 layer2, layerImpl2);
425 // We should need idle-painting for both remaining tiles in layer2. 425 // We should need idle-painting for both remaining tiles in layer2.
426 EXPECT_TRUE(needsUpdate); 426 EXPECT_TRUE(needsUpdate);
427 427
428 // Reduce our memory limits to 1mb. 428 // Reduce our memory limits to 1mb.
429 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024); 429 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024);
430 430
431 // Now idle paint layer2. We are going to run out of memory though! 431 // Now idle paint layer2. We are going to run out of memory though!
432 // Oh well, commit the frame and push. 432 // Oh well, commit the frame and push.
(...skipping 20 matching lines...) Expand all
453 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) 453 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
454 { 454 {
455 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 455 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
456 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 456 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
457 TestOcclusionTracker occluded; 457 TestOcclusionTracker occluded;
458 m_occlusion = &occluded; 458 m_occlusion = &occluded;
459 459
460 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. 460 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
461 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); 461 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100));
462 462
463 layer->setBounds(gfx::Size(100, 100)); 463 layer->SetBounds(gfx::Size(100, 100));
464 calcDrawProps(layer); 464 calcDrawProps(layer);
465 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 465 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
466 updateAndPush(layer, layerImpl); 466 updateAndPush(layer, layerImpl);
467 467
468 // We should have the prepainted tile on the impl side, but culled it during paint. 468 // We should have the prepainted tile on the impl side, but culled it during paint.
469 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 469 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
470 EXPECT_EQ(1, occluded.OverdrawMetrics().tiles_culled_for_upload()); 470 EXPECT_EQ(1, occluded.OverdrawMetrics().tiles_culled_for_upload());
471 } 471 }
472 472
473 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) 473 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
474 { 474 {
475 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 475 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
476 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 476 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
477 477
478 // The tile size is 100x100, so this invalidates and then paints two tiles. 478 // The tile size is 100x100, so this invalidates and then paints two tiles.
479 // However, during the paint, we invalidate one of the tiles. This should 479 // However, during the paint, we invalidate one of the tiles. This should
480 // not prevent the tile from being pushed. 480 // not prevent the tile from being pushed.
481 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get()); 481 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get());
482 layer->setBounds(gfx::Size(100, 200)); 482 layer->SetBounds(gfx::Size(100, 200));
483 calcDrawProps(layer); 483 calcDrawProps(layer);
484 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 484 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
485 updateAndPush(layer, layerImpl); 485 updateAndPush(layer, layerImpl);
486 486
487 // We should have both tiles on the impl side. 487 // We should have both tiles on the impl side.
488 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 488 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
489 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 489 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
490 } 490 }
491 491
492 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) 492 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
493 { 493 {
494 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 494 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
495 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 495 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
496 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1)); 496 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1));
497 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2)); 497 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2));
498 498
499 // Invalidate a tile on layer1, during update of layer 2. 499 // Invalidate a tile on layer1, during update of layer 2.
500 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get()); 500 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get());
501 layer1->setBounds(gfx::Size(100, 200)); 501 layer1->SetBounds(gfx::Size(100, 200));
502 layer2->setBounds(gfx::Size(100, 200)); 502 layer2->SetBounds(gfx::Size(100, 200));
503 calcDrawProps(layer1, layer2); 503 calcDrawProps(layer1, layer2);
504 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 504 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
505 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 505 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
506 updateAndPush(layer1, layer1Impl, 506 updateAndPush(layer1, layer1Impl,
507 layer2, layer2Impl); 507 layer2, layer2Impl);
508 508
509 // We should have both tiles on the impl side for all layers. 509 // We should have both tiles on the impl side for all layers.
510 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); 510 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
511 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 511 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
512 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 512 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
513 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 513 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
514 } 514 }
515 515
516 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) 516 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
517 { 517 {
518 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 518 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
519 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); 519 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get()));
520 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1)); 520 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1));
521 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2)); 521 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2));
522 522
523 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get()); 523 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get());
524 layer1->setBounds(gfx::Size(100, 200)); 524 layer1->SetBounds(gfx::Size(100, 200));
525 layer2->setBounds(gfx::Size(100, 200)); 525 layer2->SetBounds(gfx::Size(100, 200));
526 calcDrawProps(layer1, layer2); 526 calcDrawProps(layer1, layer2);
527 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 527 layer1->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
528 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 528 layer2->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
529 updateAndPush(layer1, layer1Impl, 529 updateAndPush(layer1, layer1Impl,
530 layer2, layer2Impl); 530 layer2, layer2Impl);
531 531
532 // We should have both tiles on the impl side for all layers. 532 // We should have both tiles on the impl side for all layers.
533 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); 533 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0));
534 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); 534 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1));
535 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); 535 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0));
536 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); 536 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1));
537 } 537 }
538 538
539 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) 539 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
540 { 540 {
541 // Create a LayerTreeHost that has the right viewportsize, 541 // Create a LayerTreeHost that has the right viewportsize,
542 // so the layer is considered small enough. 542 // so the layer is considered small enough.
543 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; 543 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient;
544 544
545 bool runOutOfMemory[2] = {false, true}; 545 bool runOutOfMemory[2] = {false, true};
546 for (int i = 0; i < 2; i++) { 546 for (int i = 0; i < 2; i++) {
547 // Create a layer with 5x5 tiles, with 4x4 size viewport. 547 // Create a layer with 5x5 tiles, with 4x4 size viewport.
548 int viewportWidth = 4 * FakeTiledLayer::tileSize().width(); 548 int viewportWidth = 4 * FakeTiledLayer::tileSize().width();
549 int viewportHeight = 4 * FakeTiledLayer::tileSize().width(); 549 int viewportHeight = 4 * FakeTiledLayer::tileSize().width();
550 int layerWidth = 5 * FakeTiledLayer::tileSize().width(); 550 int layerWidth = 5 * FakeTiledLayer::tileSize().width();
551 int layerHeight = 5 * FakeTiledLayer::tileSize().height(); 551 int layerHeight = 5 * FakeTiledLayer::tileSize().height();
552 int memoryForLayer = layerWidth * layerHeight * 4; 552 int memoryForLayer = layerWidth * layerHeight * 4;
553 m_layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx ::Size(layerWidth, layerHeight)); 553 layer_tree_host_->setViewportSize(gfx::Size(layerWidth, layerHeight), gf x::Size(layerWidth, layerHeight));
554 554
555 // Use 10x5 tiles to run out of memory. 555 // Use 10x5 tiles to run out of memory.
556 if (runOutOfMemory[i]) 556 if (runOutOfMemory[i])
557 layerWidth *= 2; 557 layerWidth *= 2;
558 558
559 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); 559 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer);
560 560
561 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get())); 561 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get()));
562 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 562 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
563 563
564 // Full size layer with half being visible. 564 // Full size layer with half being visible.
565 layer->setBounds(gfx::Size(layerWidth, layerHeight)); 565 layer->SetBounds(gfx::Size(layerWidth, layerHeight));
566 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t)); 566 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t));
567 calcDrawProps(layer); 567 calcDrawProps(layer);
568 568
569 // Pretend the layer is animating. 569 // Pretend the layer is animating.
570 layer->drawProperties().target_space_transform_is_animating = true; 570 layer->draw_properties().target_space_transform_is_animating = true;
571 layer->drawProperties().visible_content_rect = visibleRect; 571 layer->draw_properties().visible_content_rect = visibleRect;
572 layer->setLayerTreeHost(m_layerTreeHost.get()); 572 layer->SetLayerTreeHost(layer_tree_host_.get());
573 573
574 // The layer should paint its entire contents on the first paint 574 // The layer should paint its entire contents on the first paint
575 // if it is close to the viewport size and has the available memory. 575 // if it is close to the viewport size and has the available memory.
576 layer->setTexturePriorities(m_priorityCalculator); 576 layer->SetTexturePriorities(m_priorityCalculator);
577 m_resourceManager->prioritizeTextures(); 577 m_resourceManager->prioritizeTextures();
578 layer->update(*m_queue.get(), 0, NULL); 578 layer->Update(m_queue.get(), 0, NULL);
579 updateTextures(); 579 updateTextures();
580 layerPushPropertiesTo(layer.get(), layerImpl.get()); 580 layerPushPropertiesTo(layer.get(), layerImpl.get());
581 581
582 // We should have all the tiles for the small animated layer. 582 // We should have all the tiles for the small animated layer.
583 // We should still have the visible tiles when we didn't 583 // We should still have the visible tiles when we didn't
584 // have enough memory for all the tiles. 584 // have enough memory for all the tiles.
585 if (!runOutOfMemory[i]) { 585 if (!runOutOfMemory[i]) {
586 for (int i = 0; i < 5; ++i) { 586 for (int i = 0; i < 5; ++i) {
587 for (int j = 0; j < 5; ++j) 587 for (int j = 0; j < 5; ++j)
588 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); 588 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j));
(...skipping 11 matching lines...) Expand all
600 { 600 {
601 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 601 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
602 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 602 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
603 603
604 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. 604 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint.
605 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. 605 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
606 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); 606 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit);
607 607
608 // The tile size is 100x100, so this invalidates and then paints two tiles. 608 // The tile size is 100x100, so this invalidates and then paints two tiles.
609 bool needsUpdate = false; 609 bool needsUpdate = false;
610 layer->setBounds(gfx::Size(300, 300)); 610 layer->SetBounds(gfx::Size(300, 300));
611 calcDrawProps(layer); 611 calcDrawProps(layer);
612 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100) ; 612 layer->draw_properties().visible_content_rect = gfx::Rect(100, 100, 100, 100 );
613 for (int i = 0; i < 2; i++) 613 for (int i = 0; i < 2; i++)
614 needsUpdate = updateAndPush(layer, layerImpl); 614 needsUpdate = updateAndPush(layer, layerImpl);
615 615
616 // Idle-painting should see no more priority tiles for painting. 616 // Idle-painting should see no more priority tiles for painting.
617 EXPECT_FALSE(needsUpdate); 617 EXPECT_FALSE(needsUpdate);
618 618
619 // We should have one tile on the impl side. 619 // We should have one tile on the impl side.
620 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); 620 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
621 } 621 }
622 622
623 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) 623 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
624 { 624 {
625 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 625 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
626 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 626 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
627 627
628 bool animating[2] = {false, true}; 628 bool animating[2] = {false, true};
629 for (int i = 0; i < 2; i++) { 629 for (int i = 0; i < 2; i++) {
630 // Pretend the layer is animating. 630 // Pretend the layer is animating.
631 layer->drawProperties().target_space_transform_is_animating = animating[ i]; 631 layer->draw_properties().target_space_transform_is_animating = animating [i];
632 632
633 // The layer's bounds are empty. 633 // The layer's bounds are empty.
634 // Empty layers don't paint or idle-paint. 634 // Empty layers don't paint or idle-paint.
635 layer->setBounds(gfx::Size()); 635 layer->SetBounds(gfx::Size());
636 calcDrawProps(layer); 636 calcDrawProps(layer);
637 layer->drawProperties().visible_content_rect = gfx::Rect(); 637 layer->draw_properties().visible_content_rect = gfx::Rect();
638 bool needsUpdate = updateAndPush(layer, layerImpl); 638 bool needsUpdate = updateAndPush(layer, layerImpl);
639 639
640 // Empty layers don't have tiles. 640 // Empty layers don't have tiles.
641 EXPECT_EQ(0u, layer->numPaintedTiles()); 641 EXPECT_EQ(0u, layer->numPaintedTiles());
642 642
643 // Empty layers don't need prepaint. 643 // Empty layers don't need prepaint.
644 EXPECT_FALSE(needsUpdate); 644 EXPECT_FALSE(needsUpdate);
645 645
646 // Empty layers don't have tiles. 646 // Empty layers don't have tiles.
647 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 647 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
648 } 648 }
649 } 649 }
650 650
651 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) 651 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
652 { 652 {
653 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 653 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
654 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 654 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
655 655
656 // Alternate between not visible and visible. 656 // Alternate between not visible and visible.
657 gfx::Rect v(0, 0, 100, 100); 657 gfx::Rect v(0, 0, 100, 100);
658 gfx::Rect nv(0, 0, 0, 0); 658 gfx::Rect nv(0, 0, 0, 0);
659 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; 659 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv};
660 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; 660 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false };
661 661
662 // We should not have any tiles except for when the layer was visible 662 // We should not have any tiles except for when the layer was visible
663 // or after the layer was visible and we didn't invalidate. 663 // or after the layer was visible and we didn't invalidate.
664 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; 664 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true };
665 665
666 for (int i = 0; i < 10; i++) { 666 for (int i = 0; i < 10; i++) {
667 layer->setBounds(gfx::Size(100, 100)); 667 layer->SetBounds(gfx::Size(100, 100));
668 calcDrawProps(layer); 668 calcDrawProps(layer);
669 layer->drawProperties().visible_content_rect = visibleRect[i]; 669 layer->draw_properties().visible_content_rect = visibleRect[i];
670 670
671 if (invalidate[i]) 671 if (invalidate[i])
672 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); 672 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100));
673 bool needsUpdate = updateAndPush(layer, layerImpl); 673 bool needsUpdate = updateAndPush(layer, layerImpl);
674 674
675 // We should never signal idle paint, as we painted the entire layer 675 // We should never signal idle paint, as we painted the entire layer
676 // or the layer was not visible. 676 // or the layer was not visible.
677 EXPECT_FALSE(needsUpdate); 677 EXPECT_FALSE(needsUpdate);
678 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); 678 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]);
679 } 679 }
680 } 680 }
681 681
682 TEST_F(TiledLayerTest, invalidateFromPrepare) 682 TEST_F(TiledLayerTest, invalidateFromPrepare)
683 { 683 {
684 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 684 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
685 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 685 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
686 686
687 // The tile size is 100x100, so this invalidates and then paints two tiles. 687 // The tile size is 100x100, so this invalidates and then paints two tiles.
688 layer->setBounds(gfx::Size(100, 200)); 688 layer->SetBounds(gfx::Size(100, 200));
689 calcDrawProps(layer); 689 calcDrawProps(layer);
690 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 690 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
691 updateAndPush(layer, layerImpl); 691 updateAndPush(layer, layerImpl);
692 692
693 // We should have both tiles on the impl side. 693 // We should have both tiles on the impl side.
694 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 694 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
695 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 695 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
696 696
697 layer->fakeLayerUpdater()->clearPrepareCount(); 697 layer->fakeLayerUpdater()->clearPrepareCount();
698 // Invoke update again. As the layer is valid update shouldn't be invoked on 698 // Invoke update again. As the layer is valid update shouldn't be invoked on
699 // the LayerUpdater. 699 // the LayerUpdater.
700 updateAndPush(layer, layerImpl); 700 updateAndPush(layer, layerImpl);
(...skipping 14 matching lines...) Expand all
715 715
716 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) 716 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
717 { 717 {
718 // The updateRect (that indicates what was actually painted) should be in 718 // The updateRect (that indicates what was actually painted) should be in
719 // layer space, not the content space. 719 // layer space, not the content space.
720 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_resourceManager.get())); 720 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_resourceManager.get()));
721 721
722 gfx::Rect layerBounds(0, 0, 300, 200); 722 gfx::Rect layerBounds(0, 0, 300, 200);
723 gfx::Rect contentBounds(0, 0, 200, 250); 723 gfx::Rect contentBounds(0, 0, 200, 250);
724 724
725 layer->setBounds(layerBounds.size()); 725 layer->SetBounds(layerBounds.size());
726 layer->setContentBounds(contentBounds.size()); 726 layer->setContentBounds(contentBounds.size());
727 layer->drawProperties().visible_content_rect = contentBounds; 727 layer->draw_properties().visible_content_rect = contentBounds;
728 728
729 // On first update, the updateRect includes all tiles, even beyond the bound aries of the layer. 729 // On first update, the updateRect includes all tiles, even beyond the bound aries of the layer.
730 // However, it should still be in layer space, not content space. 730 // However, it should still be in layer space, not content space.
731 layer->invalidateContentRect(contentBounds); 731 layer->invalidateContentRect(contentBounds);
732 732
733 layer->setTexturePriorities(m_priorityCalculator); 733 layer->SetTexturePriorities(m_priorityCalculator);
734 m_resourceManager->prioritizeTextures(); 734 m_resourceManager->prioritizeTextures();
735 layer->update(*m_queue.get(), 0, NULL); 735 layer->Update(m_queue.get(), 0, NULL);
736 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect()); 736 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect());
737 updateTextures(); 737 updateTextures();
738 738
739 // After the tiles are updated once, another invalidate only needs to update the bounds of the layer. 739 // After the tiles are updated once, another invalidate only needs to update the bounds of the layer.
740 layer->setTexturePriorities(m_priorityCalculator); 740 layer->SetTexturePriorities(m_priorityCalculator);
741 m_resourceManager->prioritizeTextures(); 741 m_resourceManager->prioritizeTextures();
742 layer->invalidateContentRect(contentBounds); 742 layer->invalidateContentRect(contentBounds);
743 layer->update(*m_queue.get(), 0, NULL); 743 layer->Update(m_queue.get(), 0, NULL);
744 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->updateRect()); 744 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->updateRect());
745 updateTextures(); 745 updateTextures();
746 746
747 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space. 747 // Partial re-paint should also be represented by the updateRect in layer sp ace, not content space.
748 gfx::Rect partialDamage(30, 100, 10, 10); 748 gfx::Rect partialDamage(30, 100, 10, 10);
749 layer->invalidateContentRect(partialDamage); 749 layer->invalidateContentRect(partialDamage);
750 layer->setTexturePriorities(m_priorityCalculator); 750 layer->SetTexturePriorities(m_priorityCalculator);
751 m_resourceManager->prioritizeTextures(); 751 m_resourceManager->prioritizeTextures();
752 layer->update(*m_queue.get(), 0, NULL); 752 layer->Update(m_queue.get(), 0, NULL);
753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); 753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect());
754 } 754 }
755 755
756 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) 756 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
757 { 757 {
758 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 758 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
759 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); 759 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1));
760 760
761 // Create a layer with one tile. 761 // Create a layer with one tile.
762 layer->setBounds(gfx::Size(100, 100)); 762 layer->SetBounds(gfx::Size(100, 100));
763 calcDrawProps(layer); 763 calcDrawProps(layer);
764 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); 764 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100);
765 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ()); 765 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ());
766 766
767 // Push the tiles to the impl side and check that there is exactly one. 767 // Push the tiles to the impl side and check that there is exactly one.
768 layer->setTexturePriorities(m_priorityCalculator); 768 layer->SetTexturePriorities(m_priorityCalculator);
769 m_resourceManager->prioritizeTextures(); 769 m_resourceManager->prioritizeTextures();
770 layer->update(*m_queue.get(), 0, NULL); 770 layer->Update(m_queue.get(), 0, NULL);
771 updateTextures(); 771 updateTextures();
772 layerPushPropertiesTo(layer.get(), layerImpl.get()); 772 layerPushPropertiesTo(layer.get(), layerImpl.get());
773 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 773 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
774 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 774 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
775 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); 775 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
776 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); 776 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
777 777
778 layer->setNeedsDisplayRect(gfx::Rect()); 778 layer->SetNeedsDisplayRect(gfx::Rect());
779 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->lastNeedsDisplayRect()); 779 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->lastNeedsDisplayRect());
780 780
781 // Change the contents scale. 781 // Change the contents scale.
782 layer->updateContentsScale(2); 782 layer->updateContentsScale(2);
783 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 200, 200); 783 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200);
784 784
785 // The impl side should get 2x2 tiles now. 785 // The impl side should get 2x2 tiles now.
786 layer->setTexturePriorities(m_priorityCalculator); 786 layer->SetTexturePriorities(m_priorityCalculator);
787 m_resourceManager->prioritizeTextures(); 787 m_resourceManager->prioritizeTextures();
788 layer->update(*m_queue.get(), 0, NULL); 788 layer->Update(m_queue.get(), 0, NULL);
789 updateTextures(); 789 updateTextures();
790 layerPushPropertiesTo(layer.get(), layerImpl.get()); 790 layerPushPropertiesTo(layer.get(), layerImpl.get());
791 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); 791 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
792 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); 792 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
793 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0)); 793 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0));
794 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); 794 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1));
795 795
796 // Verify that changing the contents scale caused invalidation, and 796 // Verify that changing the contents scale caused invalidation, and
797 // that the layer-space rectangle requiring painting is not scaled. 797 // that the layer-space rectangle requiring painting is not scaled.
798 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ()); 798 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ());
799 799
800 // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the 800 // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the
801 // impl side. 801 // impl side.
802 layer->setNeedsDisplay(); 802 layer->SetNeedsDisplay();
803 layer->setTexturePriorities(m_priorityCalculator); 803 layer->SetTexturePriorities(m_priorityCalculator);
804 m_resourceManager->prioritizeTextures(); 804 m_resourceManager->prioritizeTextures();
805 805
806 layerPushPropertiesTo(layer.get(), layerImpl.get()); 806 layerPushPropertiesTo(layer.get(), layerImpl.get());
807 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); 807 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
808 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); 808 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1));
809 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); 809 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0));
810 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); 810 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1));
811 } 811 }
812 812
813 TEST_F(TiledLayerTest, skipsDrawGetsReset) 813 TEST_F(TiledLayerTest, skipsDrawGetsReset)
814 { 814 {
815 // Create two 300 x 300 tiled layers. 815 // Create two 300 x 300 tiled layers.
816 gfx::Size contentBounds(300, 300); 816 gfx::Size contentBounds(300, 300);
817 gfx::Rect contentRect(gfx::Point(), contentBounds); 817 gfx::Rect contentRect(gfx::Point(), contentBounds);
818 818
819 // We have enough memory for only one of the two layers. 819 // We have enough memory for only one of the two layers.
820 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. 820 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
821 821
822 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(m_layerTreeHost->contentsTextureManager())); 822 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa yer(layer_tree_host_->contentsTextureManager()));
823 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(m_layerTreeHost->contentsTextureManager())); 823 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL ayer(layer_tree_host_->contentsTextureManager()));
824 rootLayer->addChild(childLayer); 824 rootLayer->AddChild(childLayer);
825 825
826 rootLayer->setBounds(contentBounds); 826 rootLayer->SetBounds(contentBounds);
827 rootLayer->drawProperties().visible_content_rect = contentRect; 827 rootLayer->draw_properties().visible_content_rect = contentRect;
828 rootLayer->setPosition(gfx::PointF(0, 0)); 828 rootLayer->SetPosition(gfx::PointF(0, 0));
829 childLayer->setBounds(contentBounds); 829 childLayer->SetBounds(contentBounds);
830 childLayer->drawProperties().visible_content_rect = contentRect; 830 childLayer->draw_properties().visible_content_rect = contentRect;
831 childLayer->setPosition(gfx::PointF(0, 0)); 831 childLayer->SetPosition(gfx::PointF(0, 0));
832 rootLayer->invalidateContentRect(contentRect); 832 rootLayer->invalidateContentRect(contentRect);
833 childLayer->invalidateContentRect(contentRect); 833 childLayer->invalidateContentRect(contentRect);
834 834
835 m_layerTreeHost->setRootLayer(rootLayer); 835 layer_tree_host_->setRootLayer(rootLayer);
836 m_layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); 836 layer_tree_host_->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300));
837 837
838 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 838 layer_tree_host_->updateLayers(*m_queue.get(), memoryLimit);
839 839
840 // We'll skip the root layer. 840 // We'll skip the root layer.
841 EXPECT_TRUE(rootLayer->skipsDraw()); 841 EXPECT_TRUE(rootLayer->skipsDraw());
842 EXPECT_FALSE(childLayer->skipsDraw()); 842 EXPECT_FALSE(childLayer->skipsDraw());
843 843
844 m_layerTreeHost->commitComplete(); 844 layer_tree_host_->commitComplete();
845 845
846 // Remove the child layer. 846 // Remove the child layer.
847 rootLayer->removeAllChildren(); 847 rootLayer->RemoveAllChildren();
848 848
849 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); 849 layer_tree_host_->updateLayers(*m_queue.get(), memoryLimit);
850 EXPECT_FALSE(rootLayer->skipsDraw()); 850 EXPECT_FALSE(rootLayer->skipsDraw());
851 851
852 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get()); 852 resourceManagerClearAllMemory(layer_tree_host_->contentsTextureManager(), m_ resourceProvider.get());
853 m_layerTreeHost->setRootLayer(0); 853 layer_tree_host_->setRootLayer(0);
854 } 854 }
855 855
856 TEST_F(TiledLayerTest, resizeToSmaller) 856 TEST_F(TiledLayerTest, resizeToSmaller)
857 { 857 {
858 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 858 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
859 859
860 layer->setBounds(gfx::Size(700, 700)); 860 layer->SetBounds(gfx::Size(700, 700));
861 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 861 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
862 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700)); 862 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700));
863 863
864 layer->setTexturePriorities(m_priorityCalculator); 864 layer->SetTexturePriorities(m_priorityCalculator);
865 m_resourceManager->prioritizeTextures(); 865 m_resourceManager->prioritizeTextures();
866 layer->update(*m_queue.get(), 0, NULL); 866 layer->Update(m_queue.get(), 0, NULL);
867 867
868 layer->setBounds(gfx::Size(200, 200)); 868 layer->SetBounds(gfx::Size(200, 200));
869 layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200)); 869 layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200));
870 } 870 }
871 871
872 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) 872 TEST_F(TiledLayerTest, hugeLayerUpdateCrash)
873 { 873 {
874 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 874 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
875 875
876 int size = 1 << 30; 876 int size = 1 << 30;
877 layer->setBounds(gfx::Size(size, size)); 877 layer->SetBounds(gfx::Size(size, size));
878 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 700, 700); 878 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700);
879 layer->invalidateContentRect(gfx::Rect(0, 0, size, size)); 879 layer->invalidateContentRect(gfx::Rect(0, 0, size, size));
880 880
881 // Ensure no crash for bounds where size * size would overflow an int. 881 // Ensure no crash for bounds where size * size would overflow an int.
882 layer->setTexturePriorities(m_priorityCalculator); 882 layer->SetTexturePriorities(m_priorityCalculator);
883 m_resourceManager->prioritizeTextures(); 883 m_resourceManager->prioritizeTextures();
884 layer->update(*m_queue.get(), 0, NULL); 884 layer->Update(m_queue.get(), 0, NULL);
885 } 885 }
886 886
887 class TiledLayerPartialUpdateTest : public TiledLayerTest { 887 class TiledLayerPartialUpdateTest : public TiledLayerTest {
888 public: 888 public:
889 TiledLayerPartialUpdateTest() 889 TiledLayerPartialUpdateTest()
890 { 890 {
891 m_settings.maxPartialTextureUpdates = 4; 891 m_settings.maxPartialTextureUpdates = 4;
892 } 892 }
893 }; 893 };
894 894
895 TEST_F(TiledLayerPartialUpdateTest, partialUpdates) 895 TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
896 { 896 {
897 // Create one 300 x 200 tiled layer with 3 x 2 tiles. 897 // Create one 300 x 200 tiled layer with 3 x 2 tiles.
898 gfx::Size contentBounds(300, 200); 898 gfx::Size contentBounds(300, 200);
899 gfx::Rect contentRect(gfx::Point(), contentBounds); 899 gfx::Rect contentRect(gfx::Point(), contentBounds);
900 900
901 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager())); 901 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( layer_tree_host_->contentsTextureManager()));
902 layer->setBounds(contentBounds); 902 layer->SetBounds(contentBounds);
903 layer->setPosition(gfx::PointF(0, 0)); 903 layer->SetPosition(gfx::PointF(0, 0));
904 layer->drawProperties().visible_content_rect = contentRect; 904 layer->draw_properties().visible_content_rect = contentRect;
905 layer->invalidateContentRect(contentRect); 905 layer->invalidateContentRect(contentRect);
906 906
907 m_layerTreeHost->setRootLayer(layer); 907 layer_tree_host_->setRootLayer(layer);
908 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); 908 layer_tree_host_->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200));
909 909
910 // Full update of all 6 tiles. 910 // Full update of all 6 tiles.
911 m_layerTreeHost->updateLayers( 911 layer_tree_host_->updateLayers(
912 *m_queue.get(), std::numeric_limits<size_t>::max()); 912 *m_queue.get(), std::numeric_limits<size_t>::max());
913 { 913 {
914 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 914 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
915 EXPECT_EQ(6, m_queue->fullUploadSize()); 915 EXPECT_EQ(6, m_queue->fullUploadSize());
916 EXPECT_EQ(0, m_queue->partialUploadSize()); 916 EXPECT_EQ(0, m_queue->partialUploadSize());
917 updateTextures(); 917 updateTextures();
918 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 918 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
919 EXPECT_FALSE(m_queue->hasMoreUpdates()); 919 EXPECT_FALSE(m_queue->hasMoreUpdates());
920 layer->fakeLayerUpdater()->clearUpdateCount(); 920 layer->fakeLayerUpdater()->clearUpdateCount();
921 layerPushPropertiesTo(layer.get(), layerImpl.get()); 921 layerPushPropertiesTo(layer.get(), layerImpl.get());
922 } 922 }
923 m_layerTreeHost->commitComplete(); 923 layer_tree_host_->commitComplete();
924 924
925 // Full update of 3 tiles and partial update of 3 tiles. 925 // Full update of 3 tiles and partial update of 3 tiles.
926 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); 926 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
927 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax()); 927 layer_tree_host_->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:: max());
928 { 928 {
929 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 929 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
930 EXPECT_EQ(3, m_queue->fullUploadSize()); 930 EXPECT_EQ(3, m_queue->fullUploadSize());
931 EXPECT_EQ(3, m_queue->partialUploadSize()); 931 EXPECT_EQ(3, m_queue->partialUploadSize());
932 updateTextures(); 932 updateTextures();
933 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 933 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
934 EXPECT_FALSE(m_queue->hasMoreUpdates()); 934 EXPECT_FALSE(m_queue->hasMoreUpdates());
935 layer->fakeLayerUpdater()->clearUpdateCount(); 935 layer->fakeLayerUpdater()->clearUpdateCount();
936 layerPushPropertiesTo(layer.get(), layerImpl.get()); 936 layerPushPropertiesTo(layer.get(), layerImpl.get());
937 } 937 }
938 m_layerTreeHost->commitComplete(); 938 layer_tree_host_->commitComplete();
939 939
940 // Partial update of 6 tiles. 940 // Partial update of 6 tiles.
941 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 941 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
942 { 942 {
943 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 943 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
944 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 944 layer_tree_host_->updateLayers(*m_queue.get(), std::numeric_limits<size_ t>::max());
945 EXPECT_EQ(2, m_queue->fullUploadSize()); 945 EXPECT_EQ(2, m_queue->fullUploadSize());
946 EXPECT_EQ(4, m_queue->partialUploadSize()); 946 EXPECT_EQ(4, m_queue->partialUploadSize());
947 updateTextures(); 947 updateTextures();
948 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 948 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
949 EXPECT_FALSE(m_queue->hasMoreUpdates()); 949 EXPECT_FALSE(m_queue->hasMoreUpdates());
950 layer->fakeLayerUpdater()->clearUpdateCount(); 950 layer->fakeLayerUpdater()->clearUpdateCount();
951 layerPushPropertiesTo(layer.get(), layerImpl.get()); 951 layerPushPropertiesTo(layer.get(), layerImpl.get());
952 } 952 }
953 m_layerTreeHost->commitComplete(); 953 layer_tree_host_->commitComplete();
954 954
955 // Checkerboard all tiles. 955 // Checkerboard all tiles.
956 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); 956 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
957 { 957 {
958 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 958 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
959 layerPushPropertiesTo(layer.get(), layerImpl.get()); 959 layerPushPropertiesTo(layer.get(), layerImpl.get());
960 } 960 }
961 m_layerTreeHost->commitComplete(); 961 layer_tree_host_->commitComplete();
962 962
963 // Partial update of 6 checkerboard tiles. 963 // Partial update of 6 checkerboard tiles.
964 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); 964 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
965 { 965 {
966 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 966 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
967 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 967 layer_tree_host_->updateLayers(*m_queue.get(), std::numeric_limits<size_ t>::max());
968 EXPECT_EQ(6, m_queue->fullUploadSize()); 968 EXPECT_EQ(6, m_queue->fullUploadSize());
969 EXPECT_EQ(0, m_queue->partialUploadSize()); 969 EXPECT_EQ(0, m_queue->partialUploadSize());
970 updateTextures(); 970 updateTextures();
971 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); 971 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount());
972 EXPECT_FALSE(m_queue->hasMoreUpdates()); 972 EXPECT_FALSE(m_queue->hasMoreUpdates());
973 layer->fakeLayerUpdater()->clearUpdateCount(); 973 layer->fakeLayerUpdater()->clearUpdateCount();
974 layerPushPropertiesTo(layer.get(), layerImpl.get()); 974 layerPushPropertiesTo(layer.get(), layerImpl.get());
975 } 975 }
976 m_layerTreeHost->commitComplete(); 976 layer_tree_host_->commitComplete();
977 977
978 // Partial update of 4 tiles. 978 // Partial update of 4 tiles.
979 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); 979 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
980 { 980 {
981 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); 981 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1));
982 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); 982 layer_tree_host_->updateLayers(*m_queue.get(), std::numeric_limits<size_ t>::max());
983 EXPECT_EQ(0, m_queue->fullUploadSize()); 983 EXPECT_EQ(0, m_queue->fullUploadSize());
984 EXPECT_EQ(4, m_queue->partialUploadSize()); 984 EXPECT_EQ(4, m_queue->partialUploadSize());
985 updateTextures(); 985 updateTextures();
986 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); 986 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount());
987 EXPECT_FALSE(m_queue->hasMoreUpdates()); 987 EXPECT_FALSE(m_queue->hasMoreUpdates());
988 layer->fakeLayerUpdater()->clearUpdateCount(); 988 layer->fakeLayerUpdater()->clearUpdateCount();
989 layerPushPropertiesTo(layer.get(), layerImpl.get()); 989 layerPushPropertiesTo(layer.get(), layerImpl.get());
990 } 990 }
991 m_layerTreeHost->commitComplete(); 991 layer_tree_host_->commitComplete();
992 992
993 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get()); 993 resourceManagerClearAllMemory(layer_tree_host_->contentsTextureManager(), m_ resourceProvider.get());
994 m_layerTreeHost->setRootLayer(0); 994 layer_tree_host_->setRootLayer(0);
995 } 995 }
996 996
997 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) 997 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
998 { 998 {
999 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 999 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1000 1000
1001 // The tile size is 100x100, so this invalidates and then paints two tiles. 1001 // The tile size is 100x100, so this invalidates and then paints two tiles.
1002 layer->setBounds(gfx::Size(100, 200)); 1002 layer->SetBounds(gfx::Size(100, 200));
1003 calcDrawProps(layer); 1003 calcDrawProps(layer);
1004 1004
1005 layer->setTexturePriorities(m_priorityCalculator); 1005 layer->SetTexturePriorities(m_priorityCalculator);
1006 m_resourceManager->prioritizeTextures(); 1006 m_resourceManager->prioritizeTextures();
1007 layer->update(*m_queue.get(), 0, NULL); 1007 layer->Update(m_queue.get(), 0, NULL);
1008 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); 1008 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount());
1009 } 1009 }
1010 1010
1011 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) 1011 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
1012 { 1012 {
1013 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1013 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1014 TestOcclusionTracker occluded; 1014 TestOcclusionTracker occluded;
1015 m_occlusion = &occluded; 1015 m_occlusion = &occluded;
1016 1016
1017 // The tile size is 100x100. 1017 // The tile size is 100x100.
1018 1018
1019 m_layerTreeHost->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); 1019 layer_tree_host_->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600));
1020 layer->setBounds(gfx::Size(600, 600)); 1020 layer->SetBounds(gfx::Size(600, 600));
1021 calcDrawProps(layer); 1021 calcDrawProps(layer);
1022 1022
1023 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); 1023 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100));
1024 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); 1024 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds());
1025 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); 1025 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds());
1026 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1026 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1027 1027
1028 layer->setTexturePriorities(m_priorityCalculator); 1028 layer->SetTexturePriorities(m_priorityCalculator);
1029 m_resourceManager->prioritizeTextures(); 1029 m_resourceManager->prioritizeTextures();
1030 layer->update(*m_queue.get(), &occluded, NULL); 1030 layer->Update(m_queue.get(), &occluded, NULL);
1031 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); 1031 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
1032 1032
1033 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1033 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1034 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1); 1034 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1);
1035 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1035 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload());
1036 1036
1037 layer->fakeLayerUpdater()->clearUpdateCount(); 1037 layer->fakeLayerUpdater()->clearUpdateCount();
1038 layer->setTexturePriorities(m_priorityCalculator); 1038 layer->SetTexturePriorities(m_priorityCalculator);
1039 m_resourceManager->prioritizeTextures(); 1039 m_resourceManager->prioritizeTextures();
1040 1040
1041 occluded.setOcclusion(gfx::Rect(250, 200, 300, 100)); 1041 occluded.setOcclusion(gfx::Rect(250, 200, 300, 100));
1042 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1042 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1043 layer->update(*m_queue.get(), &occluded, NULL); 1043 layer->Update(m_queue.get(), &occluded, NULL);
1044 EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount()); 1044 EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount());
1045 1045
1046 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1046 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1047 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 + 340000, 1); 1047 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 + 340000, 1);
1048 EXPECT_EQ(3 + 2, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1048 EXPECT_EQ(3 + 2, occluded.OverdrawMetrics().tiles_culled_for_upload());
1049 1049
1050 layer->fakeLayerUpdater()->clearUpdateCount(); 1050 layer->fakeLayerUpdater()->clearUpdateCount();
1051 layer->setTexturePriorities(m_priorityCalculator); 1051 layer->SetTexturePriorities(m_priorityCalculator);
1052 m_resourceManager->prioritizeTextures(); 1052 m_resourceManager->prioritizeTextures();
1053 1053
1054 occluded.setOcclusion(gfx::Rect(250, 250, 300, 100)); 1054 occluded.setOcclusion(gfx::Rect(250, 250, 300, 100));
1055 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1055 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1056 layer->update(*m_queue.get(), &occluded, NULL); 1056 layer->Update(m_queue.get(), &occluded, NULL);
1057 EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount()); 1057 EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount());
1058 1058
1059 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1059 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1060 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 + 340000 + 360000, 1); 1060 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 + 340000 + 360000, 1);
1061 EXPECT_EQ(3 + 2, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1061 EXPECT_EQ(3 + 2, occluded.OverdrawMetrics().tiles_culled_for_upload());
1062 } 1062 }
1063 1063
1064 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) 1064 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
1065 { 1065 {
1066 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1066 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1067 TestOcclusionTracker occluded; 1067 TestOcclusionTracker occluded;
1068 m_occlusion = &occluded; 1068 m_occlusion = &occluded;
1069 1069
1070 // The tile size is 100x100. 1070 // The tile size is 100x100.
1071 1071
1072 m_layerTreeHost->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); 1072 layer_tree_host_->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600));
1073 layer->setBounds(gfx::Size(600, 600)); 1073 layer->SetBounds(gfx::Size(600, 600));
1074 calcDrawProps(layer); 1074 calcDrawProps(layer);
1075 1075
1076 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. 1076 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled.
1077 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); 1077 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150));
1078 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); 1078 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360);
1079 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 360); 1079 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360);
1080 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1080 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1081 1081
1082 layer->setTexturePriorities(m_priorityCalculator); 1082 layer->SetTexturePriorities(m_priorityCalculator);
1083 m_resourceManager->prioritizeTextures(); 1083 m_resourceManager->prioritizeTextures();
1084 layer->update(*m_queue.get(), &occluded, NULL); 1084 layer->Update(m_queue.get(), &occluded, NULL);
1085 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); 1085 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount());
1086 1086
1087 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1087 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1088 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 , 1); 1088 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 , 1);
1089 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1089 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload());
1090 1090
1091 layer->fakeLayerUpdater()->clearUpdateCount(); 1091 layer->fakeLayerUpdater()->clearUpdateCount();
1092 1092
1093 // Now the visible region stops at the edge of the occlusion so the partly v isible tiles become fully occluded. 1093 // Now the visible region stops at the edge of the occlusion so the partly v isible tiles become fully occluded.
1094 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); 1094 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150));
1095 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); 1095 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 350);
1096 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 350); 1096 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 350);
1097 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1097 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1098 layer->setTexturePriorities(m_priorityCalculator); 1098 layer->SetTexturePriorities(m_priorityCalculator);
1099 m_resourceManager->prioritizeTextures(); 1099 m_resourceManager->prioritizeTextures();
1100 layer->update(*m_queue.get(), &occluded, NULL); 1100 layer->Update(m_queue.get(), &occluded, NULL);
1101 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); 1101 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount());
1102 1102
1103 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1103 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1104 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 + 180000, 1); 1104 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 + 180000, 1);
1105 EXPECT_EQ(3 + 6, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1105 EXPECT_EQ(3 + 6, occluded.OverdrawMetrics().tiles_culled_for_upload());
1106 1106
1107 layer->fakeLayerUpdater()->clearUpdateCount(); 1107 layer->fakeLayerUpdater()->clearUpdateCount();
1108 1108
1109 // Now the visible region is even smaller than the occlusion, it should have the same result. 1109 // Now the visible region is even smaller than the occlusion, it should have the same result.
1110 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); 1110 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150));
1111 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); 1111 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 340);
1112 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 340); 1112 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 340);
1113 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1113 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1114 layer->setTexturePriorities(m_priorityCalculator); 1114 layer->SetTexturePriorities(m_priorityCalculator);
1115 m_resourceManager->prioritizeTextures(); 1115 m_resourceManager->prioritizeTextures();
1116 layer->update(*m_queue.get(), &occluded, NULL); 1116 layer->Update(m_queue.get(), &occluded, NULL);
1117 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); 1117 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount());
1118 1118
1119 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1119 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1120 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 + 180000 + 180000, 1); 1120 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 210000 + 180000 + 180000, 1);
1121 EXPECT_EQ(3 + 6 + 6, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1121 EXPECT_EQ(3 + 6 + 6, occluded.OverdrawMetrics().tiles_culled_for_upload());
1122 1122
1123 } 1123 }
1124 1124
1125 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) 1125 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
1126 { 1126 {
1127 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1127 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1128 TestOcclusionTracker occluded; 1128 TestOcclusionTracker occluded;
1129 m_occlusion = &occluded; 1129 m_occlusion = &occluded;
1130 1130
1131 // The tile size is 100x100. 1131 // The tile size is 100x100.
1132 1132
1133 m_layerTreeHost->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); 1133 layer_tree_host_->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600));
1134 layer->setBounds(gfx::Size(600, 600)); 1134 layer->SetBounds(gfx::Size(600, 600));
1135 calcDrawProps(layer); 1135 calcDrawProps(layer);
1136 1136
1137 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); 1137 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100));
1138 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); 1138 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600);
1139 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 600); 1139 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600);
1140 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1140 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1141 layer->setTexturePriorities(m_priorityCalculator); 1141 layer->SetTexturePriorities(m_priorityCalculator);
1142 m_resourceManager->prioritizeTextures(); 1142 m_resourceManager->prioritizeTextures();
1143 layer->update(*m_queue.get(), &occluded, NULL); 1143 layer->Update(m_queue.get(), &occluded, NULL);
1144 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); 1144 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
1145 { 1145 {
1146 updateTextures(); 1146 updateTextures();
1147 } 1147 }
1148 1148
1149 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1149 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1150 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1); 1150 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1);
1151 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1151 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload());
1152 1152
1153 layer->fakeLayerUpdater()->clearUpdateCount(); 1153 layer->fakeLayerUpdater()->clearUpdateCount();
1154 layer->setTexturePriorities(m_priorityCalculator); 1154 layer->SetTexturePriorities(m_priorityCalculator);
1155 m_resourceManager->prioritizeTextures(); 1155 m_resourceManager->prioritizeTextures();
1156 1156
1157 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now. 1157 // Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
1158 layer->update(*m_queue.get(), &occluded, NULL); 1158 layer->Update(m_queue.get(), &occluded, NULL);
1159 EXPECT_EQ(3, layer->fakeLayerUpdater()->updateCount()); 1159 EXPECT_EQ(3, layer->fakeLayerUpdater()->updateCount());
1160 1160
1161 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1161 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1162 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1); 1162 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1);
1163 EXPECT_EQ(6, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1163 EXPECT_EQ(6, occluded.OverdrawMetrics().tiles_culled_for_upload());
1164 } 1164 }
1165 1165
1166 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) 1166 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
1167 { 1167 {
1168 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1168 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1169 TestOcclusionTracker occluded; 1169 TestOcclusionTracker occluded;
1170 m_occlusion = &occluded; 1170 m_occlusion = &occluded;
1171 1171
1172 // The tile size is 100x100. 1172 // The tile size is 100x100.
1173 1173
1174 // This makes sure the painting works when the occluded region (in screen sp ace) 1174 // This makes sure the painting works when the occluded region (in screen sp ace)
1175 // is transformed differently than the layer. 1175 // is transformed differently than the layer.
1176 m_layerTreeHost->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); 1176 layer_tree_host_->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600));
1177 layer->setBounds(gfx::Size(600, 600)); 1177 layer->SetBounds(gfx::Size(600, 600));
1178 calcDrawProps(layer); 1178 calcDrawProps(layer);
1179 gfx::Transform screenTransform; 1179 gfx::Transform screenTransform;
1180 screenTransform.Scale(0.5, 0.5); 1180 screenTransform.Scale(0.5, 0.5);
1181 layer->drawProperties().screen_space_transform = screenTransform; 1181 layer->draw_properties().screen_space_transform = screenTransform;
1182 layer->drawProperties().target_space_transform = screenTransform; 1182 layer->draw_properties().target_space_transform = screenTransform;
1183 1183
1184 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); 1184 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50));
1185 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); 1185 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->content_bounds());
1186 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); 1186 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds());
1187 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1187 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1188 layer->setTexturePriorities(m_priorityCalculator); 1188 layer->SetTexturePriorities(m_priorityCalculator);
1189 m_resourceManager->prioritizeTextures(); 1189 m_resourceManager->prioritizeTextures();
1190 layer->update(*m_queue.get(), &occluded, NULL); 1190 layer->Update(m_queue.get(), &occluded, NULL);
1191 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); 1191 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
1192 1192
1193 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1193 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1194 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1); 1194 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 330000 , 1);
1195 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1195 EXPECT_EQ(3, occluded.OverdrawMetrics().tiles_culled_for_upload());
1196 } 1196 }
1197 1197
1198 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) 1198 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
1199 { 1199 {
1200 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1200 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1201 TestOcclusionTracker occluded; 1201 TestOcclusionTracker occluded;
1202 m_occlusion = &occluded; 1202 m_occlusion = &occluded;
1203 1203
1204 // The tile size is 100x100. 1204 // The tile size is 100x100.
1205 1205
1206 // This makes sure the painting works when the content space is scaled to 1206 // This makes sure the painting works when the content space is scaled to
1207 // a different layer space. In this case tiles are scaled to be 200x200 1207 // a different layer space. In this case tiles are scaled to be 200x200
1208 // pixels, which means none should be occluded. 1208 // pixels, which means none should be occluded.
1209 m_layerTreeHost->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); 1209 layer_tree_host_->setViewportSize(gfx::Size(600, 600), gfx::Size(600, 600));
1210 layer->setBounds(gfx::Size(600, 600)); 1210 layer->SetBounds(gfx::Size(600, 600));
1211 layer->setRasterScale(0.5); 1211 layer->SetRasterScale(0.5);
1212 calcDrawProps(layer); 1212 calcDrawProps(layer);
1213 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); 1213 EXPECT_FLOAT_EQ(layer->contents_scale_x(), layer->contents_scale_y());
1214 gfx::Transform drawTransform; 1214 gfx::Transform drawTransform;
1215 double invScaleFactor = 1 / layer->contentsScaleX(); 1215 double invScaleFactor = 1 / layer->contents_scale_x();
1216 drawTransform.Scale(invScaleFactor, invScaleFactor); 1216 drawTransform.Scale(invScaleFactor, invScaleFactor);
1217 layer->drawProperties().target_space_transform = drawTransform; 1217 layer->draw_properties().target_space_transform = drawTransform;
1218 layer->drawProperties().screen_space_transform = drawTransform; 1218 layer->draw_properties().screen_space_transform = drawTransform;
1219 1219
1220 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); 1220 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100));
1221 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->bounds()); 1221 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds());
1222 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); 1222 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds());
1223 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1223 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1224 layer->setTexturePriorities(m_priorityCalculator); 1224 layer->SetTexturePriorities(m_priorityCalculator);
1225 m_resourceManager->prioritizeTextures(); 1225 m_resourceManager->prioritizeTextures();
1226 layer->update(*m_queue.get(), &occluded, NULL); 1226 layer->Update(m_queue.get(), &occluded, NULL);
1227 // The content is half the size of the layer (so the number of tiles is fewe r). 1227 // The content is half the size of the layer (so the number of tiles is fewe r).
1228 // In this case, the content is 300x300, and since the tile size is 100, the 1228 // In this case, the content is 300x300, and since the tile size is 100, the
1229 // number of tiles 3x3. 1229 // number of tiles 3x3.
1230 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); 1230 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount());
1231 1231
1232 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1232 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1233 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000, 1); 1233 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000, 1);
1234 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1234 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1235 1235
1236 layer->fakeLayerUpdater()->clearUpdateCount(); 1236 layer->fakeLayerUpdater()->clearUpdateCount();
1237 1237
1238 // This makes sure the painting works when the content space is scaled to 1238 // This makes sure the painting works when the content space is scaled to
1239 // a different layer space. In this case the occluded region catches the 1239 // a different layer space. In this case the occluded region catches the
1240 // blown up tiles. 1240 // blown up tiles.
1241 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200)); 1241 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200));
1242 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->bounds()); 1242 layer->draw_properties().drawable_content_rect = gfx::Rect(gfx::Point(), lay er->bounds());
1243 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); 1243 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds());
1244 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1244 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1245 layer->setTexturePriorities(m_priorityCalculator); 1245 layer->SetTexturePriorities(m_priorityCalculator);
1246 m_resourceManager->prioritizeTextures(); 1246 m_resourceManager->prioritizeTextures();
1247 layer->update(*m_queue.get(), &occluded, NULL); 1247 layer->Update(m_queue.get(), &occluded, NULL);
1248 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); 1248 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount());
1249 1249
1250 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1250 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1251 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000 + 80000, 1); 1251 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000 + 80000, 1);
1252 EXPECT_EQ(1, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1252 EXPECT_EQ(1, occluded.OverdrawMetrics().tiles_culled_for_upload());
1253 1253
1254 layer->fakeLayerUpdater()->clearUpdateCount(); 1254 layer->fakeLayerUpdater()->clearUpdateCount();
1255 1255
1256 // This makes sure content scaling and transforms work together. 1256 // This makes sure content scaling and transforms work together.
1257 gfx::Transform screenTransform; 1257 gfx::Transform screenTransform;
1258 screenTransform.Scale(0.5, 0.5); 1258 screenTransform.Scale(0.5, 0.5);
1259 layer->drawProperties().screen_space_transform = screenTransform; 1259 layer->draw_properties().screen_space_transform = screenTransform;
1260 layer->drawProperties().target_space_transform = screenTransform; 1260 layer->draw_properties().target_space_transform = screenTransform;
1261 1261
1262 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100)); 1262 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100));
1263 1263
1264 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); 1264 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds());
1265 layer->drawProperties().drawable_content_rect = gfx::ToEnclosingRect(gfx::Sc aleRect(layerBoundsRect, 0.5)); 1265 layer->draw_properties().drawable_content_rect = gfx::ToEnclosingRect(gfx::S caleRect(layerBoundsRect, 0.5));
1266 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); 1266 layer->draw_properties().visible_content_rect = gfx::Rect(gfx::Point(), laye r->content_bounds());
1267 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); 1267 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
1268 layer->setTexturePriorities(m_priorityCalculator); 1268 layer->SetTexturePriorities(m_priorityCalculator);
1269 m_resourceManager->prioritizeTextures(); 1269 m_resourceManager->prioritizeTextures();
1270 layer->update(*m_queue.get(), &occluded, NULL); 1270 layer->Update(m_queue.get(), &occluded, NULL);
1271 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); 1271 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount());
1272 1272
1273 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1273 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1274 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000 + 80000 + 80000, 1); 1274 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 90000 + 80000 + 80000, 1);
1275 EXPECT_EQ(1 + 1, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1275 EXPECT_EQ(1 + 1, occluded.OverdrawMetrics().tiles_culled_for_upload());
1276 } 1276 }
1277 1277
1278 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) 1278 TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
1279 { 1279 {
1280 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1280 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1281 TestOcclusionTracker occluded; 1281 TestOcclusionTracker occluded;
1282 m_occlusion = &occluded; 1282 m_occlusion = &occluded;
1283 m_layerTreeHost->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 1000 )); 1283 layer_tree_host_->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 100 0));
1284 1284
1285 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways. 1285 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways.
1286 1286
1287 gfx::Rect opaquePaintRect; 1287 gfx::Rect opaquePaintRect;
1288 Region opaqueContents; 1288 Region opaqueContents;
1289 1289
1290 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 200); 1290 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 200);
1291 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 150); 1291 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 150);
1292 1292
1293 layer->setBounds(contentBounds.size()); 1293 layer->SetBounds(contentBounds.size());
1294 calcDrawProps(layer); 1294 calcDrawProps(layer);
1295 layer->drawProperties().drawable_content_rect = visibleBounds; 1295 layer->draw_properties().drawable_content_rect = visibleBounds;
1296 layer->drawProperties().visible_content_rect = visibleBounds; 1296 layer->draw_properties().visible_content_rect = visibleBounds;
1297 1297
1298 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR egion should be empty. 1298 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR egion should be empty.
1299 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1299 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1300 layer->invalidateContentRect(contentBounds); 1300 layer->invalidateContentRect(contentBounds);
1301 layer->setTexturePriorities(m_priorityCalculator); 1301 layer->SetTexturePriorities(m_priorityCalculator);
1302 m_resourceManager->prioritizeTextures(); 1302 m_resourceManager->prioritizeTextures();
1303 layer->update(*m_queue.get(), &occluded, NULL); 1303 layer->Update(m_queue.get(), &occluded, NULL);
1304 opaqueContents = layer->visibleContentOpaqueRegion(); 1304 opaqueContents = layer->VisibleContentOpaqueRegion();
1305 EXPECT_TRUE(opaqueContents.IsEmpty()); 1305 EXPECT_TRUE(opaqueContents.IsEmpty());
1306 1306
1307 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000, 1); 1307 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000, 1);
1308 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1308 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1309 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000, 1); 1309 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000, 1);
1310 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1310 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1311 1311
1312 // visibleContentOpaqueRegion should match the visible part of what is paint ed opaque. 1312 // visibleContentOpaqueRegion should match the visible part of what is paint ed opaque.
1313 opaquePaintRect = gfx::Rect(10, 10, 90, 190); 1313 opaquePaintRect = gfx::Rect(10, 10, 90, 190);
1314 layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect); 1314 layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect);
1315 layer->invalidateContentRect(contentBounds); 1315 layer->invalidateContentRect(contentBounds);
1316 layer->setTexturePriorities(m_priorityCalculator); 1316 layer->SetTexturePriorities(m_priorityCalculator);
1317 m_resourceManager->prioritizeTextures(); 1317 m_resourceManager->prioritizeTextures();
1318 layer->update(*m_queue.get(), &occluded, NULL); 1318 layer->Update(m_queue.get(), &occluded, NULL);
1319 updateTextures(); 1319 updateTextures();
1320 opaqueContents = layer->visibleContentOpaqueRegion(); 1320 opaqueContents = layer->VisibleContentOpaqueRegion();
1321 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); 1321 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString());
1322 1322
1323 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2, 1); 1323 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2, 1);
1324 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1); 1324 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1);
1325 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100, 1); 1325 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100, 1);
1326 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1326 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1327 1327
1328 // If we paint again without invalidating, the same stuff should be opaque. 1328 // If we paint again without invalidating, the same stuff should be opaque.
1329 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1329 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1330 layer->setTexturePriorities(m_priorityCalculator); 1330 layer->SetTexturePriorities(m_priorityCalculator);
1331 m_resourceManager->prioritizeTextures(); 1331 m_resourceManager->prioritizeTextures();
1332 layer->update(*m_queue.get(), &occluded, NULL); 1332 layer->Update(m_queue.get(), &occluded, NULL);
1333 updateTextures(); 1333 updateTextures();
1334 opaqueContents = layer->visibleContentOpaqueRegion(); 1334 opaqueContents = layer->VisibleContentOpaqueRegion();
1335 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); 1335 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString());
1336 1336
1337 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2, 1); 1337 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2, 1);
1338 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1); 1338 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1);
1339 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100, 1); 1339 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100, 1);
1340 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1340 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1341 1341
1342 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o paque-ness. And other tiles should 1342 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o paque-ness. And other tiles should
1343 // not be affected. 1343 // not be affected.
1344 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1344 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1345 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); 1345 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1));
1346 layer->setTexturePriorities(m_priorityCalculator); 1346 layer->SetTexturePriorities(m_priorityCalculator);
1347 m_resourceManager->prioritizeTextures(); 1347 m_resourceManager->prioritizeTextures();
1348 layer->update(*m_queue.get(), &occluded, NULL); 1348 layer->Update(m_queue.get(), &occluded, NULL);
1349 updateTextures(); 1349 updateTextures();
1350 opaqueContents = layer->visibleContentOpaqueRegion(); 1350 opaqueContents = layer->VisibleContentOpaqueRegion();
1351 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString()); 1351 EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), op aqueContents.ToString());
1352 1352
1353 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2 + 1, 1); 1353 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2 + 1, 1);
1354 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1); 1354 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1);
1355 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100 + 1, 1); 1355 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100 + 1, 1);
1356 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1356 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1357 1357
1358 // If we repaint an opaque part of the tile, then it should lose its opaque- ness. But other tiles should still 1358 // If we repaint an opaque part of the tile, then it should lose its opaque- ness. But other tiles should still
1359 // not be affected. 1359 // not be affected.
1360 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1360 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1361 layer->invalidateContentRect(gfx::Rect(10, 10, 1, 1)); 1361 layer->invalidateContentRect(gfx::Rect(10, 10, 1, 1));
1362 layer->setTexturePriorities(m_priorityCalculator); 1362 layer->SetTexturePriorities(m_priorityCalculator);
1363 m_resourceManager->prioritizeTextures(); 1363 m_resourceManager->prioritizeTextures();
1364 layer->update(*m_queue.get(), &occluded, NULL); 1364 layer->Update(m_queue.get(), &occluded, NULL);
1365 updateTextures(); 1365 updateTextures();
1366 opaqueContents = layer->visibleContentOpaqueRegion(); 1366 opaqueContents = layer->VisibleContentOpaqueRegion();
1367 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).To String(), opaqueContents.ToString()); 1367 EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).To String(), opaqueContents.ToString());
1368 1368
1369 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2 + 1 + 1, 1); 1369 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 20000 * 2 + 1 + 1, 1);
1370 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1); 1370 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 17100, 1);
1371 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100 + 1 + 1, 1); 1371 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 20000 + 20000 - 17100 + 1 + 1, 1);
1372 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1372 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1373 } 1373 }
1374 1374
1375 TEST_F(TiledLayerTest, pixels_paintedMetrics) 1375 TEST_F(TiledLayerTest, pixels_paintedMetrics)
1376 { 1376 {
1377 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); 1377 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get()));
1378 TestOcclusionTracker occluded; 1378 TestOcclusionTracker occluded;
1379 m_occlusion = &occluded; 1379 m_occlusion = &occluded;
1380 m_layerTreeHost->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 1000 )); 1380 layer_tree_host_->setViewportSize(gfx::Size(1000, 1000), gfx::Size(1000, 100 0));
1381 1381
1382 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways. 1382 // The tile size is 100x100, so this invalidates and then paints two tiles i n various ways.
1383 1383
1384 gfx::Rect opaquePaintRect; 1384 gfx::Rect opaquePaintRect;
1385 Region opaqueContents; 1385 Region opaqueContents;
1386 1386
1387 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); 1387 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300);
1388 layer->setBounds(contentBounds.size()); 1388 layer->SetBounds(contentBounds.size());
1389 calcDrawProps(layer); 1389 calcDrawProps(layer);
1390 1390
1391 // Invalidates and paints the whole layer. 1391 // Invalidates and paints the whole layer.
1392 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1392 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1393 layer->invalidateContentRect(contentBounds); 1393 layer->invalidateContentRect(contentBounds);
1394 layer->setTexturePriorities(m_priorityCalculator); 1394 layer->SetTexturePriorities(m_priorityCalculator);
1395 m_resourceManager->prioritizeTextures(); 1395 m_resourceManager->prioritizeTextures();
1396 layer->update(*m_queue.get(), &occluded, NULL); 1396 layer->Update(m_queue.get(), &occluded, NULL);
1397 updateTextures(); 1397 updateTextures();
1398 opaqueContents = layer->visibleContentOpaqueRegion(); 1398 opaqueContents = layer->VisibleContentOpaqueRegion();
1399 EXPECT_TRUE(opaqueContents.IsEmpty()); 1399 EXPECT_TRUE(opaqueContents.IsEmpty());
1400 1400
1401 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 30000, 1); 1401 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 30000, 1);
1402 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1402 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1403 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 30000, 1); 1403 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 30000, 1);
1404 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1404 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1405 1405
1406 // Invalidates an area on the top and bottom tile, which will cause us to pa int the tile in the middle, 1406 // Invalidates an area on the top and bottom tile, which will cause us to pa int the tile in the middle,
1407 // even though it is not dirty and will not be uploaded. 1407 // even though it is not dirty and will not be uploaded.
1408 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); 1408 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
1409 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); 1409 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1));
1410 layer->invalidateContentRect(gfx::Rect(50, 200, 10, 10)); 1410 layer->invalidateContentRect(gfx::Rect(50, 200, 10, 10));
1411 layer->setTexturePriorities(m_priorityCalculator); 1411 layer->SetTexturePriorities(m_priorityCalculator);
1412 m_resourceManager->prioritizeTextures(); 1412 m_resourceManager->prioritizeTextures();
1413 layer->update(*m_queue.get(), &occluded, NULL); 1413 layer->Update(m_queue.get(), &occluded, NULL);
1414 updateTextures(); 1414 updateTextures();
1415 opaqueContents = layer->visibleContentOpaqueRegion(); 1415 opaqueContents = layer->VisibleContentOpaqueRegion();
1416 EXPECT_TRUE(opaqueContents.IsEmpty()); 1416 EXPECT_TRUE(opaqueContents.IsEmpty());
1417 1417
1418 // The middle tile was painted even though not invalidated. 1418 // The middle tile was painted even though not invalidated.
1419 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 30000 + 60 * 210, 1 ); 1419 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_painted(), 30000 + 60 * 210, 1 );
1420 // The pixels uploaded will not include the non-invalidated tile in the midd le. 1420 // The pixels uploaded will not include the non-invalidated tile in the midd le.
1421 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1); 1421 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_opaque(), 0, 1);
1422 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 30000 + 1 + 100, 1); 1422 EXPECT_NEAR(occluded.OverdrawMetrics().pixels_uploaded_translucent(), 30000 + 1 + 100, 1);
1423 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload()); 1423 EXPECT_EQ(0, occluded.OverdrawMetrics().tiles_culled_for_upload());
1424 } 1424 }
1425 1425
1426 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) 1426 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
1427 { 1427 {
1428 // Tile size is 100x100. 1428 // Tile size is 100x100.
1429 gfx::Rect rootRect(0, 0, 300, 200); 1429 gfx::Rect rootRect(0, 0, 300, 200);
1430 gfx::Rect childRect(0, 0, 300, 100); 1430 gfx::Rect childRect(0, 0, 300, 100);
1431 gfx::Rect child2Rect(0, 100, 300, 100); 1431 gfx::Rect child2Rect(0, 100, 300, 100);
1432 1432
1433 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(m _layerTreeHost->contentsTextureManager())); 1433 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(l ayer_tree_host_->contentsTextureManager()));
1434 scoped_refptr<Layer> surface = Layer::create(); 1434 scoped_refptr<Layer> surface = Layer::Create();
1435 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( m_layerTreeHost->contentsTextureManager())); 1435 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer( layer_tree_host_->contentsTextureManager()));
1436 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (m_layerTreeHost->contentsTextureManager())); 1436 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer (layer_tree_host_->contentsTextureManager()));
1437 1437
1438 root->setBounds(rootRect.size()); 1438 root->SetBounds(rootRect.size());
1439 root->setAnchorPoint(gfx::PointF()); 1439 root->SetAnchorPoint(gfx::PointF());
1440 root->drawProperties().drawable_content_rect = rootRect; 1440 root->draw_properties().drawable_content_rect = rootRect;
1441 root->drawProperties().visible_content_rect = rootRect; 1441 root->draw_properties().visible_content_rect = rootRect;
1442 root->addChild(surface); 1442 root->AddChild(surface);
1443 1443
1444 surface->setForceRenderSurface(true); 1444 surface->SetForceRenderSurface(true);
1445 surface->setAnchorPoint(gfx::PointF()); 1445 surface->SetAnchorPoint(gfx::PointF());
1446 surface->setOpacity(0.5); 1446 surface->SetOpacity(0.5);
1447 surface->addChild(child); 1447 surface->AddChild(child);
1448 surface->addChild(child2); 1448 surface->AddChild(child2);
1449 1449
1450 child->setBounds(childRect.size()); 1450 child->SetBounds(childRect.size());
1451 child->setAnchorPoint(gfx::PointF()); 1451 child->SetAnchorPoint(gfx::PointF());
1452 child->setPosition(childRect.origin()); 1452 child->SetPosition(childRect.origin());
1453 child->drawProperties().visible_content_rect = childRect; 1453 child->draw_properties().visible_content_rect = childRect;
1454 child->drawProperties().drawable_content_rect = rootRect; 1454 child->draw_properties().drawable_content_rect = rootRect;
1455 1455
1456 child2->setBounds(child2Rect.size()); 1456 child2->SetBounds(child2Rect.size());
1457 child2->setAnchorPoint(gfx::PointF()); 1457 child2->SetAnchorPoint(gfx::PointF());
1458 child2->setPosition(child2Rect.origin()); 1458 child2->SetPosition(child2Rect.origin());
1459 child2->drawProperties().visible_content_rect = child2Rect; 1459 child2->draw_properties().visible_content_rect = child2Rect;
1460 child2->drawProperties().drawable_content_rect = rootRect; 1460 child2->draw_properties().drawable_content_rect = rootRect;
1461 1461
1462 m_layerTreeHost->setRootLayer(root); 1462 layer_tree_host_->setRootLayer(root);
1463 m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); 1463 layer_tree_host_->setViewportSize(rootRect.size(), rootRect.size());
1464 1464
1465 // With a huge memory limit, all layers should update and push their texture s. 1465 // With a huge memory limit, all layers should update and push their texture s.
1466 root->invalidateContentRect(rootRect); 1466 root->invalidateContentRect(rootRect);
1467 child->invalidateContentRect(childRect); 1467 child->invalidateContentRect(childRect);
1468 child2->invalidateContentRect(child2Rect); 1468 child2->invalidateContentRect(child2Rect);
1469 m_layerTreeHost->updateLayers( 1469 layer_tree_host_->updateLayers(
1470 *m_queue.get(), std::numeric_limits<size_t>::max()); 1470 *m_queue.get(), std::numeric_limits<size_t>::max());
1471 { 1471 {
1472 updateTextures(); 1472 updateTextures();
1473 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1473 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1474 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); 1474 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount());
1475 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); 1475 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount());
1476 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1476 EXPECT_FALSE(m_queue->hasMoreUpdates());
1477 1477
1478 root->fakeLayerUpdater()->clearUpdateCount(); 1478 root->fakeLayerUpdater()->clearUpdateCount();
1479 child->fakeLayerUpdater()->clearUpdateCount(); 1479 child->fakeLayerUpdater()->clearUpdateCount();
1480 child2->fakeLayerUpdater()->clearUpdateCount(); 1480 child2->fakeLayerUpdater()->clearUpdateCount();
1481 1481
1482 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); 1482 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id()));
1483 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); 1483 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id()));
1484 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); 1484 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id()));
1485 layerPushPropertiesTo(root.get(), rootImpl.get()); 1485 layerPushPropertiesTo(root.get(), rootImpl.get());
1486 layerPushPropertiesTo(child.get(), childImpl.get()); 1486 layerPushPropertiesTo(child.get(), childImpl.get());
1487 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1487 layerPushPropertiesTo(child2.get(), child2Impl.get());
1488 1488
1489 for (unsigned i = 0; i < 3; ++i) { 1489 for (unsigned i = 0; i < 3; ++i) {
1490 for (unsigned j = 0; j < 2; ++j) 1490 for (unsigned j = 0; j < 2; ++j)
1491 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1491 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1492 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); 1492 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0));
1493 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); 1493 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0));
1494 } 1494 }
1495 } 1495 }
1496 m_layerTreeHost->commitComplete(); 1496 layer_tree_host_->commitComplete();
1497 1497
1498 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that 1498 // With a memory limit that includes only the root layer (3x2 tiles) and hal f the surface that
1499 // the child layers draw into, the child layers will not be allocated. If th e surface isn't 1499 // the child layers draw into, the child layers will not be allocated. If th e surface isn't
1500 // accounted for, then one of the children would fit within the memory limit . 1500 // accounted for, then one of the children would fit within the memory limit .
1501 root->invalidateContentRect(rootRect); 1501 root->invalidateContentRect(rootRect);
1502 child->invalidateContentRect(childRect); 1502 child->invalidateContentRect(childRect);
1503 child2->invalidateContentRect(child2Rect); 1503 child2->invalidateContentRect(child2Rect);
1504 m_layerTreeHost->updateLayers( 1504 layer_tree_host_->updateLayers(
1505 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4); 1505 *m_queue.get(), (3 * 2 + 3 * 1) * (100 * 100) * 4);
1506 { 1506 {
1507 updateTextures(); 1507 updateTextures();
1508 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); 1508 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount());
1509 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1509 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1510 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1510 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1511 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1511 EXPECT_FALSE(m_queue->hasMoreUpdates());
1512 1512
1513 root->fakeLayerUpdater()->clearUpdateCount(); 1513 root->fakeLayerUpdater()->clearUpdateCount();
1514 child->fakeLayerUpdater()->clearUpdateCount(); 1514 child->fakeLayerUpdater()->clearUpdateCount();
1515 child2->fakeLayerUpdater()->clearUpdateCount(); 1515 child2->fakeLayerUpdater()->clearUpdateCount();
1516 1516
1517 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); 1517 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id()));
1518 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); 1518 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id()));
1519 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); 1519 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id()));
1520 layerPushPropertiesTo(root.get(), rootImpl.get()); 1520 layerPushPropertiesTo(root.get(), rootImpl.get());
1521 layerPushPropertiesTo(child.get(), childImpl.get()); 1521 layerPushPropertiesTo(child.get(), childImpl.get());
1522 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1522 layerPushPropertiesTo(child2.get(), child2Impl.get());
1523 1523
1524 for (unsigned i = 0; i < 3; ++i) { 1524 for (unsigned i = 0; i < 3; ++i) {
1525 for (unsigned j = 0; j < 2; ++j) 1525 for (unsigned j = 0; j < 2; ++j)
1526 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); 1526 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j));
1527 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1527 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1528 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1528 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1529 } 1529 }
1530 } 1530 }
1531 m_layerTreeHost->commitComplete(); 1531 layer_tree_host_->commitComplete();
1532 1532
1533 // With a memory limit that includes only half the root layer, no contents w ill be 1533 // With a memory limit that includes only half the root layer, no contents w ill be
1534 // allocated. If render surface memory wasn't accounted for, there is enough space 1534 // allocated. If render surface memory wasn't accounted for, there is enough space
1535 // for one of the children layers, but they draw into a surface that can't b e 1535 // for one of the children layers, but they draw into a surface that can't b e
1536 // allocated. 1536 // allocated.
1537 root->invalidateContentRect(rootRect); 1537 root->invalidateContentRect(rootRect);
1538 child->invalidateContentRect(childRect); 1538 child->invalidateContentRect(childRect);
1539 child2->invalidateContentRect(child2Rect); 1539 child2->invalidateContentRect(child2Rect);
1540 m_layerTreeHost->updateLayers( 1540 layer_tree_host_->updateLayers(
1541 *m_queue.get(), (3 * 1) * (100 * 100) * 4); 1541 *m_queue.get(), (3 * 1) * (100 * 100) * 4);
1542 { 1542 {
1543 updateTextures(); 1543 updateTextures();
1544 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); 1544 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount());
1545 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); 1545 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount());
1546 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); 1546 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount());
1547 EXPECT_FALSE(m_queue->hasMoreUpdates()); 1547 EXPECT_FALSE(m_queue->hasMoreUpdates());
1548 1548
1549 root->fakeLayerUpdater()->clearUpdateCount(); 1549 root->fakeLayerUpdater()->clearUpdateCount();
1550 child->fakeLayerUpdater()->clearUpdateCount(); 1550 child->fakeLayerUpdater()->clearUpdateCount();
1551 child2->fakeLayerUpdater()->clearUpdateCount(); 1551 child2->fakeLayerUpdater()->clearUpdateCount();
1552 1552
1553 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); 1553 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id()));
1554 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); 1554 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id()));
1555 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); 1555 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id()));
1556 layerPushPropertiesTo(root.get(), rootImpl.get()); 1556 layerPushPropertiesTo(root.get(), rootImpl.get());
1557 layerPushPropertiesTo(child.get(), childImpl.get()); 1557 layerPushPropertiesTo(child.get(), childImpl.get());
1558 layerPushPropertiesTo(child2.get(), child2Impl.get()); 1558 layerPushPropertiesTo(child2.get(), child2Impl.get());
1559 1559
1560 for (unsigned i = 0; i < 3; ++i) { 1560 for (unsigned i = 0; i < 3; ++i) {
1561 for (unsigned j = 0; j < 2; ++j) 1561 for (unsigned j = 0; j < 2; ++j)
1562 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); 1562 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j));
1563 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); 1563 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0));
1564 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); 1564 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0));
1565 } 1565 }
1566 } 1566 }
1567 m_layerTreeHost->commitComplete(); 1567 layer_tree_host_->commitComplete();
1568 1568
1569 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r esourceProvider.get()); 1569 resourceManagerClearAllMemory(layer_tree_host_->contentsTextureManager(), m_ resourceProvider.get());
1570 m_layerTreeHost->setRootLayer(0); 1570 layer_tree_host_->setRootLayer(0);
1571 } 1571 }
1572 1572
1573 class TrackingLayerPainter : public LayerPainter { 1573 class TrackingLayerPainter : public LayerPainter {
1574 public: 1574 public:
1575 static scoped_ptr<TrackingLayerPainter> create() { return make_scoped_ptr(ne w TrackingLayerPainter()); } 1575 static scoped_ptr<TrackingLayerPainter> Create() { return make_scoped_ptr(ne w TrackingLayerPainter()); }
1576 1576
1577 virtual void Paint(SkCanvas* canvas, gfx::Rect content_rect, gfx::RectF* opa que) OVERRIDE 1577 virtual void Paint(SkCanvas* canvas, gfx::Rect content_rect, gfx::RectF* opa que) OVERRIDE
1578 { 1578 {
1579 m_paintedRect = content_rect; 1579 m_paintedRect = content_rect;
1580 } 1580 }
1581 1581
1582 const gfx::Rect& paintedRect() const { return m_paintedRect; } 1582 const gfx::Rect& paintedRect() const { return m_paintedRect; }
1583 void resetPaintedRect() { m_paintedRect = gfx::Rect(); } 1583 void resetPaintedRect() { m_paintedRect = gfx::Rect(); }
1584 1584
1585 private: 1585 private:
1586 TrackingLayerPainter() { } 1586 TrackingLayerPainter() { }
1587 1587
1588 gfx::Rect m_paintedRect; 1588 gfx::Rect m_paintedRect;
1589 }; 1589 };
1590 1590
1591 class UpdateTrackingTiledLayer : public FakeTiledLayer { 1591 class UpdateTrackingTiledLayer : public FakeTiledLayer {
1592 public: 1592 public:
1593 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager) 1593 explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager)
1594 : FakeTiledLayer(manager) 1594 : FakeTiledLayer(manager)
1595 { 1595 {
1596 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::create()); 1596 scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPaint er::Create());
1597 m_trackingLayerPainter = trackingLayerPainter.get(); 1597 m_trackingLayerPainter = trackingLayerPainter.get();
1598 m_layerUpdater = BitmapContentLayerUpdater::create(trackingLayerPainter. PassAs<LayerPainter>()); 1598 m_layerUpdater = BitmapContentLayerUpdater::create(trackingLayerPainter. PassAs<LayerPainter>());
1599 } 1599 }
1600 1600
1601 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; } 1601 TrackingLayerPainter* trackingLayerPainter() const { return m_trackingLayerP ainter; }
1602 1602
1603 protected: 1603 protected:
1604 virtual ~UpdateTrackingTiledLayer() { } 1604 virtual ~UpdateTrackingTiledLayer() { }
1605 1605
1606 virtual LayerUpdater* updater() const OVERRIDE { return m_layerUpdater.get() ; } 1606 virtual LayerUpdater* updater() const OVERRIDE { return m_layerUpdater.get() ; }
1607 1607
1608 private: 1608 private:
1609 TrackingLayerPainter* m_trackingLayerPainter; 1609 TrackingLayerPainter* m_trackingLayerPainter;
1610 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater; 1610 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater;
1611 }; 1611 };
1612 1612
1613 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) 1613 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
1614 { 1614 {
1615 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_resourceManager.get())); 1615 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_resourceManager.get()));
1616 1616
1617 gfx::Rect layerRect(0, 0, 30, 31); 1617 gfx::Rect layerRect(0, 0, 30, 31);
1618 layer->setPosition(layerRect.origin()); 1618 layer->SetPosition(layerRect.origin());
1619 layer->setBounds(layerRect.size()); 1619 layer->SetBounds(layerRect.size());
1620 layer->updateContentsScale(1.5); 1620 layer->updateContentsScale(1.5);
1621 1621
1622 gfx::Rect contentRect(0, 0, 45, 47); 1622 gfx::Rect contentRect(0, 0, 45, 47);
1623 EXPECT_EQ(contentRect.size(), layer->contentBounds()); 1623 EXPECT_EQ(contentRect.size(), layer->content_bounds());
1624 layer->drawProperties().visible_content_rect = contentRect; 1624 layer->draw_properties().visible_content_rect = contentRect;
1625 layer->drawProperties().drawable_content_rect = contentRect; 1625 layer->draw_properties().drawable_content_rect = contentRect;
1626 1626
1627 layer->setTexturePriorities(m_priorityCalculator); 1627 layer->SetTexturePriorities(m_priorityCalculator);
1628 m_resourceManager->prioritizeTextures(); 1628 m_resourceManager->prioritizeTextures();
1629 1629
1630 // Update the whole tile. 1630 // Update the whole tile.
1631 layer->update(*m_queue.get(), 0, NULL); 1631 layer->Update(m_queue.get(), 0, NULL);
1632 layer->trackingLayerPainter()->resetPaintedRect(); 1632 layer->trackingLayerPainter()->resetPaintedRect();
1633 1633
1634 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); 1634 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect());
1635 updateTextures(); 1635 updateTextures();
1636 1636
1637 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds. 1637 // Invalidate the entire layer in content space. When painting, the rect giv en to webkit should match the layer's bounds.
1638 layer->invalidateContentRect(contentRect); 1638 layer->invalidateContentRect(contentRect);
1639 layer->update(*m_queue.get(), 0, NULL); 1639 layer->Update(m_queue.get(), 0, NULL);
1640 1640
1641 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1641 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1642 } 1642 }
1643 1643
1644 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) 1644 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
1645 { 1645 {
1646 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_resourceManager.get())); 1646 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat eTrackingTiledLayer(m_resourceManager.get()));
1647 1647
1648 gfx::Rect layerRect(0, 0, 30, 31); 1648 gfx::Rect layerRect(0, 0, 30, 31);
1649 layer->setPosition(layerRect.origin()); 1649 layer->SetPosition(layerRect.origin());
1650 layer->setBounds(layerRect.size()); 1650 layer->SetBounds(layerRect.size());
1651 layer->updateContentsScale(1.3f); 1651 layer->updateContentsScale(1.3f);
1652 1652
1653 gfx::Rect contentRect(gfx::Point(), layer->contentBounds()); 1653 gfx::Rect contentRect(gfx::Point(), layer->content_bounds());
1654 layer->drawProperties().visible_content_rect = contentRect; 1654 layer->draw_properties().visible_content_rect = contentRect;
1655 layer->drawProperties().drawable_content_rect = contentRect; 1655 layer->draw_properties().drawable_content_rect = contentRect;
1656 1656
1657 layer->setTexturePriorities(m_priorityCalculator); 1657 layer->SetTexturePriorities(m_priorityCalculator);
1658 m_resourceManager->prioritizeTextures(); 1658 m_resourceManager->prioritizeTextures();
1659 1659
1660 // Update the whole tile. 1660 // Update the whole tile.
1661 layer->update(*m_queue.get(), 0, NULL); 1661 layer->Update(m_queue.get(), 0, NULL);
1662 layer->trackingLayerPainter()->resetPaintedRect(); 1662 layer->trackingLayerPainter()->resetPaintedRect();
1663 1663
1664 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); 1664 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect());
1665 updateTextures(); 1665 updateTextures();
1666 1666
1667 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. 1667 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds.
1668 layer->setNeedsDisplayRect(layerRect); 1668 layer->SetNeedsDisplayRect(layerRect);
1669 layer->update(*m_queue.get(), 0, NULL); 1669 layer->Update(m_queue.get(), 0, NULL);
1670 1670
1671 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); 1671 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect());
1672 } 1672 }
1673 1673
1674 } // namespace 1674 } // namespace
1675 } // namespace cc 1675 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiled_layer_impl_unittest.cc ('k') | cc/top_controls_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698