OLD | NEW |
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/rendering_stats.h" | 10 #include "cc/rendering_stats.h" |
11 #include "cc/resource_update_controller.h" | 11 #include "cc/resource_update_controller.h" |
12 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 12 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
13 #include "cc/test/animation_test_common.h" | 13 #include "cc/test/animation_test_common.h" |
14 #include "cc/test/fake_layer_tree_host_client.h" | 14 #include "cc/test/fake_layer_tree_host_client.h" |
| 15 #include "cc/test/fake_layer_tree_host_impl.h" |
15 #include "cc/test/fake_output_surface.h" | 16 #include "cc/test/fake_output_surface.h" |
16 #include "cc/test/fake_proxy.h" | 17 #include "cc/test/fake_proxy.h" |
17 #include "cc/test/geometry_test_utils.h" | 18 #include "cc/test/geometry_test_utils.h" |
18 #include "cc/test/tiled_layer_test_common.h" | 19 #include "cc/test/tiled_layer_test_common.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
22 | 23 |
23 using namespace WebKitTests; | 24 using namespace WebKitTests; |
24 | 25 |
(...skipping 30 matching lines...) Expand all Loading... |
55 } | 56 } |
56 | 57 |
57 virtual void SetUp() | 58 virtual void SetUp() |
58 { | 59 { |
59 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient,
m_settings, scoped_ptr<Thread>(NULL)); | 60 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient,
m_settings, scoped_ptr<Thread>(NULL)); |
60 m_proxy = m_layerTreeHost->proxy(); | 61 m_proxy = m_layerTreeHost->proxy(); |
61 m_resourceManager = PrioritizedResourceManager::create(Renderer::Content
Pool, m_proxy); | 62 m_resourceManager = PrioritizedResourceManager::create(Renderer::Content
Pool, m_proxy); |
62 m_layerTreeHost->initializeRendererIfNeeded(); | 63 m_layerTreeHost->initializeRendererIfNeeded(); |
63 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked(m_proxy); | 64 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked(m_proxy); |
64 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); | 65 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); |
| 66 m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy)); |
65 } | 67 } |
66 | 68 |
67 virtual ~TiledLayerTest() | 69 virtual ~TiledLayerTest() |
68 { | 70 { |
69 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide
r.get()); | 71 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide
r.get()); |
70 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked(m_proxy); | 72 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked(m_proxy); |
71 m_resourceProvider.reset(); | 73 m_resourceProvider.reset(); |
| 74 m_hostImpl.reset(); |
72 } | 75 } |
73 | 76 |
74 class ScopedFakeTiledLayerImpl { | 77 class ScopedFakeTiledLayerImpl { |
75 public: | 78 public: |
76 ScopedFakeTiledLayerImpl(int id) | 79 ScopedFakeTiledLayerImpl(LayerTreeHostImpl* hostImpl, int id) |
77 { | 80 { |
78 m_layerImpl = new FakeTiledLayerImpl(id); | 81 m_layerImpl = new FakeTiledLayerImpl(hostImpl, id); |
79 } | 82 } |
80 ~ScopedFakeTiledLayerImpl() | 83 ~ScopedFakeTiledLayerImpl() |
81 { | 84 { |
82 delete m_layerImpl; | 85 delete m_layerImpl; |
83 } | 86 } |
84 FakeTiledLayerImpl* get() | 87 FakeTiledLayerImpl* get() |
85 { | 88 { |
86 return m_layerImpl; | 89 return m_layerImpl; |
87 } | 90 } |
88 FakeTiledLayerImpl* operator->() | 91 FakeTiledLayerImpl* operator->() |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 public: | 167 public: |
165 Proxy* m_proxy; | 168 Proxy* m_proxy; |
166 LayerTreeSettings m_settings; | 169 LayerTreeSettings m_settings; |
167 scoped_ptr<OutputSurface> m_outputSurface; | 170 scoped_ptr<OutputSurface> m_outputSurface; |
168 scoped_ptr<ResourceProvider> m_resourceProvider; | 171 scoped_ptr<ResourceProvider> m_resourceProvider; |
169 scoped_ptr<ResourceUpdateQueue> m_queue; | 172 scoped_ptr<ResourceUpdateQueue> m_queue; |
170 RenderingStats m_stats; | 173 RenderingStats m_stats; |
171 PriorityCalculator m_priorityCalculator; | 174 PriorityCalculator m_priorityCalculator; |
172 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; | 175 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; |
173 scoped_ptr<LayerTreeHost> m_layerTreeHost; | 176 scoped_ptr<LayerTreeHost> m_layerTreeHost; |
| 177 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; |
174 scoped_ptr<PrioritizedResourceManager> m_resourceManager; | 178 scoped_ptr<PrioritizedResourceManager> m_resourceManager; |
175 TestOcclusionTracker* m_occlusion; | 179 TestOcclusionTracker* m_occlusion; |
176 }; | 180 }; |
177 | 181 |
178 TEST_F(TiledLayerTest, pushDirtyTiles) | 182 TEST_F(TiledLayerTest, pushDirtyTiles) |
179 { | 183 { |
180 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 184 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
181 ScopedFakeTiledLayerImpl layerImpl(1); | 185 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
182 | 186 |
183 // The tile size is 100x100, so this invalidates and then paints two tiles. | 187 // The tile size is 100x100, so this invalidates and then paints two tiles. |
184 layer->setBounds(gfx::Size(100, 200)); | 188 layer->setBounds(gfx::Size(100, 200)); |
185 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 189 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
186 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 190 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
187 updateAndPush(layer.get(), layerImpl.get()); | 191 updateAndPush(layer.get(), layerImpl.get()); |
188 | 192 |
189 // We should have both tiles on the impl side. | 193 // We should have both tiles on the impl side. |
190 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
191 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 195 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
192 | 196 |
193 // Invalidates both tiles, but then only update one of them. | 197 // Invalidates both tiles, but then only update one of them. |
194 layer->setBounds(gfx::Size(100, 200)); | 198 layer->setBounds(gfx::Size(100, 200)); |
195 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 199 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
196 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 200 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
197 updateAndPush(layer.get(), layerImpl.get()); | 201 updateAndPush(layer.get(), layerImpl.get()); |
198 | 202 |
199 // We should only have the first tile since the other tile was invalidated b
ut not painted. | 203 // We should only have the first tile since the other tile was invalidated b
ut not painted. |
200 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 204 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
201 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 205 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
202 } | 206 } |
203 | 207 |
204 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) | 208 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) |
205 { | 209 { |
206 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 210 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
207 ScopedFakeTiledLayerImpl layerImpl(1); | 211 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
208 TestOcclusionTracker occluded; | 212 TestOcclusionTracker occluded; |
209 m_occlusion = &occluded; | 213 m_occlusion = &occluded; |
210 | 214 |
211 // The tile size is 100x100, so this invalidates and then paints two tiles. | 215 // The tile size is 100x100, so this invalidates and then paints two tiles. |
212 layer->setBounds(gfx::Size(100, 200)); | 216 layer->setBounds(gfx::Size(100, 200)); |
213 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 217 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
214 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); | 218 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); |
215 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 219 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
216 updateAndPush(layer.get(), layerImpl.get()); | 220 updateAndPush(layer.get(), layerImpl.get()); |
217 | 221 |
(...skipping 16 matching lines...) Expand all Loading... |
234 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 238 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
235 | 239 |
236 // We should still have both tiles, as part of the top tile is still unocclu
ded. | 240 // We should still have both tiles, as part of the top tile is still unocclu
ded. |
237 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 241 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
238 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 242 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
239 } | 243 } |
240 | 244 |
241 TEST_F(TiledLayerTest, pushDeletedTiles) | 245 TEST_F(TiledLayerTest, pushDeletedTiles) |
242 { | 246 { |
243 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 247 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
244 ScopedFakeTiledLayerImpl layerImpl(1); | 248 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
245 | 249 |
246 // The tile size is 100x100, so this invalidates and then paints two tiles. | 250 // The tile size is 100x100, so this invalidates and then paints two tiles. |
247 layer->setBounds(gfx::Size(100, 200)); | 251 layer->setBounds(gfx::Size(100, 200)); |
248 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 252 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
249 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 253 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
250 updateAndPush(layer.get(), layerImpl.get()); | 254 updateAndPush(layer.get(), layerImpl.get()); |
251 | 255 |
252 // We should have both tiles on the impl side. | 256 // We should have both tiles on the impl side. |
253 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 257 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
254 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 258 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
(...skipping 14 matching lines...) Expand all Loading... |
269 updateAndPush(layer.get(), layerImpl.get()); | 273 updateAndPush(layer.get(), layerImpl.get()); |
270 | 274 |
271 // We should have one tiles on the impl side. | 275 // We should have one tiles on the impl side. |
272 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 276 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
273 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 277 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
274 } | 278 } |
275 | 279 |
276 TEST_F(TiledLayerTest, pushIdlePaintTiles) | 280 TEST_F(TiledLayerTest, pushIdlePaintTiles) |
277 { | 281 { |
278 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 282 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
279 ScopedFakeTiledLayerImpl layerImpl(1); | 283 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
280 | 284 |
281 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. | 285 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. |
282 // This paints 1 visible of the 25 invalid tiles. | 286 // This paints 1 visible of the 25 invalid tiles. |
283 layer->setBounds(gfx::Size(500, 500)); | 287 layer->setBounds(gfx::Size(500, 500)); |
284 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100)
; | 288 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100)
; |
285 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); | 289 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); |
286 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 290 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
287 // We should need idle-painting for surrounding tiles. | 291 // We should need idle-painting for surrounding tiles. |
288 EXPECT_TRUE(needsUpdate); | 292 EXPECT_TRUE(needsUpdate); |
289 | 293 |
(...skipping 15 matching lines...) Expand all Loading... |
305 for (int j = 0; j < 5; j++) | 309 for (int j = 0; j < 5; j++) |
306 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); | 310 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); |
307 } | 311 } |
308 | 312 |
309 EXPECT_FALSE(needsUpdate); | 313 EXPECT_FALSE(needsUpdate); |
310 } | 314 } |
311 | 315 |
312 TEST_F(TiledLayerTest, predictivePainting) | 316 TEST_F(TiledLayerTest, predictivePainting) |
313 { | 317 { |
314 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 318 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
315 ScopedFakeTiledLayerImpl layerImpl(1); | 319 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
316 | 320 |
317 // Prepainting should occur in the scroll direction first, and the | 321 // Prepainting should occur in the scroll direction first, and the |
318 // visible rect should be extruded only along the dominant axis. | 322 // visible rect should be extruded only along the dominant axis. |
319 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), | 323 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), |
320 gfx::Vector2d(10, 0), | 324 gfx::Vector2d(10, 0), |
321 gfx::Vector2d(0, -10), | 325 gfx::Vector2d(0, -10), |
322 gfx::Vector2d(0, 10), | 326 gfx::Vector2d(0, 10), |
323 gfx::Vector2d(10, 20), | 327 gfx::Vector2d(10, 20), |
324 gfx::Vector2d(-20, 10) }; | 328 gfx::Vector2d(-20, 10) }; |
325 // We should push all tiles that touch the extruded visible rect. | 329 // We should push all tiles that touch the extruded visible rect. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 383 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
380 EXPECT_FALSE(needsUpdate); | 384 EXPECT_FALSE(needsUpdate); |
381 } | 385 } |
382 } | 386 } |
383 | 387 |
384 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) | 388 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) |
385 { | 389 { |
386 // Start with 2mb of memory, but the test is going to try to use just more t
han 1mb, so we reduce to 1mb later. | 390 // Start with 2mb of memory, but the test is going to try to use just more t
han 1mb, so we reduce to 1mb later. |
387 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); | 391 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); |
388 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 392 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
389 ScopedFakeTiledLayerImpl layerImpl1(1); | 393 ScopedFakeTiledLayerImpl layerImpl1(m_hostImpl.get(), 1); |
390 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 394 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
391 ScopedFakeTiledLayerImpl layerImpl2(2); | 395 ScopedFakeTiledLayerImpl layerImpl2(m_hostImpl.get(), 2); |
392 | 396 |
393 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from | 397 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from |
394 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint | 398 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint |
395 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. | 399 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. |
396 | 400 |
397 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. | 401 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. |
398 gfx::Rect layer1Rect(0, 0, 100, 2400); | 402 gfx::Rect layer1Rect(0, 0, 100, 2400); |
399 | 403 |
400 // This requires 4*30000 bytes of memory. | 404 // This requires 4*30000 bytes of memory. |
401 gfx::Rect layer2Rect(0, 0, 100, 300); | 405 gfx::Rect layer2Rect(0, 0, 100, 300); |
(...skipping 29 matching lines...) Expand all Loading... |
431 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 435 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
432 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 436 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
433 | 437 |
434 EXPECT_FALSE(needsUpdate); | 438 EXPECT_FALSE(needsUpdate); |
435 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); | 439 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); |
436 } | 440 } |
437 | 441 |
438 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) | 442 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) |
439 { | 443 { |
440 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 444 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
441 ScopedFakeTiledLayerImpl layerImpl(1); | 445 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
442 TestOcclusionTracker occluded; | 446 TestOcclusionTracker occluded; |
443 m_occlusion = &occluded; | 447 m_occlusion = &occluded; |
444 | 448 |
445 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. | 449 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. |
446 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); | 450 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); |
447 | 451 |
448 layer->setBounds(gfx::Size(100, 100)); | 452 layer->setBounds(gfx::Size(100, 100)); |
449 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 453 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
450 updateAndPush(layer.get(), layerImpl.get()); | 454 updateAndPush(layer.get(), layerImpl.get()); |
451 | 455 |
452 // We should have the prepainted tile on the impl side, but culled it during
paint. | 456 // We should have the prepainted tile on the impl side, but culled it during
paint. |
453 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 457 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
454 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 458 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
455 } | 459 } |
456 | 460 |
457 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) | 461 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) |
458 { | 462 { |
459 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 463 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
460 ScopedFakeTiledLayerImpl layerImpl(1); | 464 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
461 | 465 |
462 // The tile size is 100x100, so this invalidates and then paints two tiles. | 466 // The tile size is 100x100, so this invalidates and then paints two tiles. |
463 // However, during the paint, we invalidate one of the tiles. This should | 467 // However, during the paint, we invalidate one of the tiles. This should |
464 // not prevent the tile from being pushed. | 468 // not prevent the tile from being pushed. |
465 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); | 469 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); |
466 layer->setBounds(gfx::Size(100, 200)); | 470 layer->setBounds(gfx::Size(100, 200)); |
467 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 471 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
468 updateAndPush(layer.get(), layerImpl.get()); | 472 updateAndPush(layer.get(), layerImpl.get()); |
469 | 473 |
470 // We should have both tiles on the impl side. | 474 // We should have both tiles on the impl side. |
471 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 475 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
472 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 476 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
473 } | 477 } |
474 | 478 |
475 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 479 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
476 { | 480 { |
477 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 481 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
478 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 482 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
479 ScopedFakeTiledLayerImpl layer1Impl(1); | 483 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1); |
480 ScopedFakeTiledLayerImpl layer2Impl(2); | 484 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2); |
481 | 485 |
482 // Invalidate a tile on layer1, during update of layer 2. | 486 // Invalidate a tile on layer1, during update of layer 2. |
483 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); | 487 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); |
484 layer1->setBounds(gfx::Size(100, 200)); | 488 layer1->setBounds(gfx::Size(100, 200)); |
485 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 489 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
486 layer2->setBounds(gfx::Size(100, 200)); | 490 layer2->setBounds(gfx::Size(100, 200)); |
487 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 491 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
488 updateAndPush(layer1.get(), layer1Impl.get(), | 492 updateAndPush(layer1.get(), layer1Impl.get(), |
489 layer2.get(), layer2Impl.get()); | 493 layer2.get(), layer2Impl.get()); |
490 | 494 |
491 // We should have both tiles on the impl side for all layers. | 495 // We should have both tiles on the impl side for all layers. |
492 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 496 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
493 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 497 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
494 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 498 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
495 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 499 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
496 } | 500 } |
497 | 501 |
498 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) | 502 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) |
499 { | 503 { |
500 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 504 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
501 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 505 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
502 ScopedFakeTiledLayerImpl layer1Impl(1); | 506 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1); |
503 ScopedFakeTiledLayerImpl layer2Impl(2); | 507 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2); |
504 | 508 |
505 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); | 509 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); |
506 layer1->setBounds(gfx::Size(100, 200)); | 510 layer1->setBounds(gfx::Size(100, 200)); |
507 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 511 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
508 layer2->setBounds(gfx::Size(100, 200)); | 512 layer2->setBounds(gfx::Size(100, 200)); |
509 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 513 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
510 updateAndPush(layer1.get(), layer1Impl.get(), | 514 updateAndPush(layer1.get(), layer1Impl.get(), |
511 layer2.get(), layer2Impl.get()); | 515 layer2.get(), layer2Impl.get()); |
512 | 516 |
513 // We should have both tiles on the impl side for all layers. | 517 // We should have both tiles on the impl side for all layers. |
(...skipping 20 matching lines...) Expand all Loading... |
534 int memoryForLayer = layerWidth * layerHeight * 4; | 538 int memoryForLayer = layerWidth * layerHeight * 4; |
535 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx::
Size(layerWidth, layerHeight)); | 539 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx::
Size(layerWidth, layerHeight)); |
536 | 540 |
537 // Use 10x5 tiles to run out of memory. | 541 // Use 10x5 tiles to run out of memory. |
538 if (runOutOfMemory[i]) | 542 if (runOutOfMemory[i]) |
539 layerWidth *= 2; | 543 layerWidth *= 2; |
540 | 544 |
541 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); | 545 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); |
542 | 546 |
543 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); | 547 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); |
544 ScopedFakeTiledLayerImpl layerImpl(1); | 548 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
545 | 549 |
546 // Full size layer with half being visible. | 550 // Full size layer with half being visible. |
547 gfx::Size contentBounds(layerWidth, layerHeight); | 551 gfx::Size contentBounds(layerWidth, layerHeight); |
548 gfx::Rect contentRect(gfx::Point(), contentBounds); | 552 gfx::Rect contentRect(gfx::Point(), contentBounds); |
549 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); | 553 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); |
550 | 554 |
551 // Pretend the layer is animating. | 555 // Pretend the layer is animating. |
552 layer->drawProperties().target_space_transform_is_animating = true; | 556 layer->drawProperties().target_space_transform_is_animating = true; |
553 layer->setBounds(contentBounds); | 557 layer->setBounds(contentBounds); |
554 layer->drawProperties().visible_content_rect = visibleRect; | 558 layer->drawProperties().visible_content_rect = visibleRect; |
(...skipping 21 matching lines...) Expand all Loading... |
576 for (int j = 0; j < 5; ++j) | 580 for (int j = 0; j < 5; ++j) |
577 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); | 581 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); |
578 } | 582 } |
579 } | 583 } |
580 } | 584 } |
581 } | 585 } |
582 | 586 |
583 TEST_F(TiledLayerTest, idlePaintOutOfMemory) | 587 TEST_F(TiledLayerTest, idlePaintOutOfMemory) |
584 { | 588 { |
585 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 589 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
586 ScopedFakeTiledLayerImpl layerImpl(1); | 590 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
587 | 591 |
588 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 592 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. |
589 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. | 593 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
590 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); | 594 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); |
591 | 595 |
592 // The tile size is 100x100, so this invalidates and then paints two tiles. | 596 // The tile size is 100x100, so this invalidates and then paints two tiles. |
593 bool needsUpdate = false; | 597 bool needsUpdate = false; |
594 layer->setBounds(gfx::Size(300, 300)); | 598 layer->setBounds(gfx::Size(300, 300)); |
595 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100)
; | 599 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100)
; |
596 for (int i = 0; i < 2; i++) | 600 for (int i = 0; i < 2; i++) |
597 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 601 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
598 | 602 |
599 // Idle-painting should see no more priority tiles for painting. | 603 // Idle-painting should see no more priority tiles for painting. |
600 EXPECT_FALSE(needsUpdate); | 604 EXPECT_FALSE(needsUpdate); |
601 | 605 |
602 // We should have one tile on the impl side. | 606 // We should have one tile on the impl side. |
603 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); | 607 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); |
604 } | 608 } |
605 | 609 |
606 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) | 610 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) |
607 { | 611 { |
608 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 612 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
609 ScopedFakeTiledLayerImpl layerImpl(1); | 613 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
610 | 614 |
611 bool animating[2] = {false, true}; | 615 bool animating[2] = {false, true}; |
612 for (int i = 0; i < 2; i++) { | 616 for (int i = 0; i < 2; i++) { |
613 // Pretend the layer is animating. | 617 // Pretend the layer is animating. |
614 layer->drawProperties().target_space_transform_is_animating = animating[
i]; | 618 layer->drawProperties().target_space_transform_is_animating = animating[
i]; |
615 | 619 |
616 // The layer's bounds are empty. | 620 // The layer's bounds are empty. |
617 // Empty layers don't paint or idle-paint. | 621 // Empty layers don't paint or idle-paint. |
618 layer->setBounds(gfx::Size()); | 622 layer->setBounds(gfx::Size()); |
619 layer->drawProperties().visible_content_rect = gfx::Rect(); | 623 layer->drawProperties().visible_content_rect = gfx::Rect(); |
620 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 624 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
621 | 625 |
622 // Empty layers don't have tiles. | 626 // Empty layers don't have tiles. |
623 EXPECT_EQ(0u, layer->numPaintedTiles()); | 627 EXPECT_EQ(0u, layer->numPaintedTiles()); |
624 | 628 |
625 // Empty layers don't need prepaint. | 629 // Empty layers don't need prepaint. |
626 EXPECT_FALSE(needsUpdate); | 630 EXPECT_FALSE(needsUpdate); |
627 | 631 |
628 // Empty layers don't have tiles. | 632 // Empty layers don't have tiles. |
629 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 633 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
630 } | 634 } |
631 } | 635 } |
632 | 636 |
633 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) | 637 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) |
634 { | 638 { |
635 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 639 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
636 ScopedFakeTiledLayerImpl layerImpl(1); | 640 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
637 | 641 |
638 // Alternate between not visible and visible. | 642 // Alternate between not visible and visible. |
639 gfx::Rect v(0, 0, 100, 100); | 643 gfx::Rect v(0, 0, 100, 100); |
640 gfx::Rect nv(0, 0, 0, 0); | 644 gfx::Rect nv(0, 0, 0, 0); |
641 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 645 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; |
642 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; | 646 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; |
643 | 647 |
644 // We should not have any tiles except for when the layer was visible | 648 // We should not have any tiles except for when the layer was visible |
645 // or after the layer was visible and we didn't invalidate. | 649 // or after the layer was visible and we didn't invalidate. |
646 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; | 650 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; |
647 | 651 |
648 for (int i = 0; i < 10; i++) { | 652 for (int i = 0; i < 10; i++) { |
649 layer->setBounds(gfx::Size(100, 100)); | 653 layer->setBounds(gfx::Size(100, 100)); |
650 layer->drawProperties().visible_content_rect = visibleRect[i]; | 654 layer->drawProperties().visible_content_rect = visibleRect[i]; |
651 | 655 |
652 if (invalidate[i]) | 656 if (invalidate[i]) |
653 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); | 657 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); |
654 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 658 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
655 | 659 |
656 // We should never signal idle paint, as we painted the entire layer | 660 // We should never signal idle paint, as we painted the entire layer |
657 // or the layer was not visible. | 661 // or the layer was not visible. |
658 EXPECT_FALSE(needsUpdate); | 662 EXPECT_FALSE(needsUpdate); |
659 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); | 663 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); |
660 } | 664 } |
661 } | 665 } |
662 | 666 |
663 TEST_F(TiledLayerTest, invalidateFromPrepare) | 667 TEST_F(TiledLayerTest, invalidateFromPrepare) |
664 { | 668 { |
665 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 669 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
666 ScopedFakeTiledLayerImpl layerImpl(1); | 670 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
667 | 671 |
668 // The tile size is 100x100, so this invalidates and then paints two tiles. | 672 // The tile size is 100x100, so this invalidates and then paints two tiles. |
669 layer->setBounds(gfx::Size(100, 200)); | 673 layer->setBounds(gfx::Size(100, 200)); |
670 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 674 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
671 updateAndPush(layer.get(), layerImpl.get()); | 675 updateAndPush(layer.get(), layerImpl.get()); |
672 | 676 |
673 // We should have both tiles on the impl side. | 677 // We should have both tiles on the impl side. |
674 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 678 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
675 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 679 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
676 | 680 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 layer->invalidateContentRect(partialDamage); | 733 layer->invalidateContentRect(partialDamage); |
730 layer->setTexturePriorities(m_priorityCalculator); | 734 layer->setTexturePriorities(m_priorityCalculator); |
731 m_resourceManager->prioritizeTextures(); | 735 m_resourceManager->prioritizeTextures(); |
732 layer->update(*m_queue.get(), 0, m_stats); | 736 layer->update(*m_queue.get(), 0, m_stats); |
733 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); | 737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); |
734 } | 738 } |
735 | 739 |
736 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 740 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
737 { | 741 { |
738 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 742 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
739 ScopedFakeTiledLayerImpl layerImpl(1); | 743 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
740 | 744 |
741 // Create a layer with one tile. | 745 // Create a layer with one tile. |
742 layer->setBounds(gfx::Size(100, 100)); | 746 layer->setBounds(gfx::Size(100, 100)); |
743 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 747 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
744 | 748 |
745 // Invalidate the entire layer. | 749 // Invalidate the entire layer. |
746 layer->setNeedsDisplay(); | 750 layer->setNeedsDisplay(); |
747 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); | 751 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
748 | 752 |
749 // Push the tiles to the impl side and check that there is exactly one. | 753 // Push the tiles to the impl side and check that there is exactly one. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 layer->drawProperties().visible_content_rect = contentRect; | 885 layer->drawProperties().visible_content_rect = contentRect; |
882 layer->invalidateContentRect(contentRect); | 886 layer->invalidateContentRect(contentRect); |
883 | 887 |
884 m_layerTreeHost->setRootLayer(layer); | 888 m_layerTreeHost->setRootLayer(layer); |
885 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 889 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
886 | 890 |
887 // Full update of all 6 tiles. | 891 // Full update of all 6 tiles. |
888 m_layerTreeHost->updateLayers( | 892 m_layerTreeHost->updateLayers( |
889 *m_queue.get(), std::numeric_limits<size_t>::max()); | 893 *m_queue.get(), std::numeric_limits<size_t>::max()); |
890 { | 894 { |
891 ScopedFakeTiledLayerImpl layerImpl(1); | 895 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
892 EXPECT_EQ(6, m_queue->fullUploadSize()); | 896 EXPECT_EQ(6, m_queue->fullUploadSize()); |
893 EXPECT_EQ(0, m_queue->partialUploadSize()); | 897 EXPECT_EQ(0, m_queue->partialUploadSize()); |
894 updateTextures(); | 898 updateTextures(); |
895 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 899 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
896 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 900 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
897 layer->fakeLayerUpdater()->clearUpdateCount(); | 901 layer->fakeLayerUpdater()->clearUpdateCount(); |
898 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 902 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
899 } | 903 } |
900 m_layerTreeHost->commitComplete(); | 904 m_layerTreeHost->commitComplete(); |
901 | 905 |
902 // Full update of 3 tiles and partial update of 3 tiles. | 906 // Full update of 3 tiles and partial update of 3 tiles. |
903 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); | 907 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); |
904 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m
ax()); | 908 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m
ax()); |
905 { | 909 { |
906 ScopedFakeTiledLayerImpl layerImpl(1); | 910 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
907 EXPECT_EQ(3, m_queue->fullUploadSize()); | 911 EXPECT_EQ(3, m_queue->fullUploadSize()); |
908 EXPECT_EQ(3, m_queue->partialUploadSize()); | 912 EXPECT_EQ(3, m_queue->partialUploadSize()); |
909 updateTextures(); | 913 updateTextures(); |
910 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 914 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
911 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 915 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
912 layer->fakeLayerUpdater()->clearUpdateCount(); | 916 layer->fakeLayerUpdater()->clearUpdateCount(); |
913 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 917 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
914 } | 918 } |
915 m_layerTreeHost->commitComplete(); | 919 m_layerTreeHost->commitComplete(); |
916 | 920 |
917 // Partial update of 6 tiles. | 921 // Partial update of 6 tiles. |
918 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 922 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
919 { | 923 { |
920 ScopedFakeTiledLayerImpl layerImpl(1); | 924 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
921 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); | 925 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
922 EXPECT_EQ(2, m_queue->fullUploadSize()); | 926 EXPECT_EQ(2, m_queue->fullUploadSize()); |
923 EXPECT_EQ(4, m_queue->partialUploadSize()); | 927 EXPECT_EQ(4, m_queue->partialUploadSize()); |
924 updateTextures(); | 928 updateTextures(); |
925 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 929 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
926 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 930 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
927 layer->fakeLayerUpdater()->clearUpdateCount(); | 931 layer->fakeLayerUpdater()->clearUpdateCount(); |
928 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 932 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
929 } | 933 } |
930 m_layerTreeHost->commitComplete(); | 934 m_layerTreeHost->commitComplete(); |
931 | 935 |
932 // Checkerboard all tiles. | 936 // Checkerboard all tiles. |
933 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); | 937 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); |
934 { | 938 { |
935 ScopedFakeTiledLayerImpl layerImpl(1); | 939 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
936 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 940 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
937 } | 941 } |
938 m_layerTreeHost->commitComplete(); | 942 m_layerTreeHost->commitComplete(); |
939 | 943 |
940 // Partial update of 6 checkerboard tiles. | 944 // Partial update of 6 checkerboard tiles. |
941 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 945 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
942 { | 946 { |
943 ScopedFakeTiledLayerImpl layerImpl(1); | 947 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
944 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); | 948 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
945 EXPECT_EQ(6, m_queue->fullUploadSize()); | 949 EXPECT_EQ(6, m_queue->fullUploadSize()); |
946 EXPECT_EQ(0, m_queue->partialUploadSize()); | 950 EXPECT_EQ(0, m_queue->partialUploadSize()); |
947 updateTextures(); | 951 updateTextures(); |
948 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 952 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
949 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 953 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
950 layer->fakeLayerUpdater()->clearUpdateCount(); | 954 layer->fakeLayerUpdater()->clearUpdateCount(); |
951 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 955 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
952 } | 956 } |
953 m_layerTreeHost->commitComplete(); | 957 m_layerTreeHost->commitComplete(); |
954 | 958 |
955 // Partial update of 4 tiles. | 959 // Partial update of 4 tiles. |
956 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); | 960 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); |
957 { | 961 { |
958 ScopedFakeTiledLayerImpl layerImpl(1); | 962 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1); |
959 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); | 963 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t
>::max()); |
960 EXPECT_EQ(0, m_queue->fullUploadSize()); | 964 EXPECT_EQ(0, m_queue->fullUploadSize()); |
961 EXPECT_EQ(4, m_queue->partialUploadSize()); | 965 EXPECT_EQ(4, m_queue->partialUploadSize()); |
962 updateTextures(); | 966 updateTextures(); |
963 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); | 967 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); |
964 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 968 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
965 layer->fakeLayerUpdater()->clearUpdateCount(); | 969 layer->fakeLayerUpdater()->clearUpdateCount(); |
966 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 970 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
967 } | 971 } |
968 m_layerTreeHost->commitComplete(); | 972 m_layerTreeHost->commitComplete(); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 updateTextures(); | 1432 updateTextures(); |
1429 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1433 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
1430 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); | 1434 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); |
1431 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); | 1435 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); |
1432 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1436 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
1433 | 1437 |
1434 root->fakeLayerUpdater()->clearUpdateCount(); | 1438 root->fakeLayerUpdater()->clearUpdateCount(); |
1435 child->fakeLayerUpdater()->clearUpdateCount(); | 1439 child->fakeLayerUpdater()->clearUpdateCount(); |
1436 child2->fakeLayerUpdater()->clearUpdateCount(); | 1440 child2->fakeLayerUpdater()->clearUpdateCount(); |
1437 | 1441 |
1438 ScopedFakeTiledLayerImpl rootImpl(root->id()); | 1442 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); |
1439 ScopedFakeTiledLayerImpl childImpl(child->id()); | 1443 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); |
1440 ScopedFakeTiledLayerImpl child2Impl(child2->id()); | 1444 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); |
1441 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1445 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1442 layerPushPropertiesTo(child.get(), childImpl.get()); | 1446 layerPushPropertiesTo(child.get(), childImpl.get()); |
1443 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1447 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
1444 | 1448 |
1445 for (unsigned i = 0; i < 3; ++i) { | 1449 for (unsigned i = 0; i < 3; ++i) { |
1446 for (unsigned j = 0; j < 2; ++j) | 1450 for (unsigned j = 0; j < 2; ++j) |
1447 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1451 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
1448 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); | 1452 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); |
1449 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1453 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); |
1450 } | 1454 } |
(...skipping 12 matching lines...) Expand all Loading... |
1463 updateTextures(); | 1467 updateTextures(); |
1464 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1468 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
1465 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1469 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
1466 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1470 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
1467 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1471 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
1468 | 1472 |
1469 root->fakeLayerUpdater()->clearUpdateCount(); | 1473 root->fakeLayerUpdater()->clearUpdateCount(); |
1470 child->fakeLayerUpdater()->clearUpdateCount(); | 1474 child->fakeLayerUpdater()->clearUpdateCount(); |
1471 child2->fakeLayerUpdater()->clearUpdateCount(); | 1475 child2->fakeLayerUpdater()->clearUpdateCount(); |
1472 | 1476 |
1473 ScopedFakeTiledLayerImpl rootImpl(root->id()); | 1477 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); |
1474 ScopedFakeTiledLayerImpl childImpl(child->id()); | 1478 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); |
1475 ScopedFakeTiledLayerImpl child2Impl(child2->id()); | 1479 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); |
1476 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1480 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1477 layerPushPropertiesTo(child.get(), childImpl.get()); | 1481 layerPushPropertiesTo(child.get(), childImpl.get()); |
1478 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1482 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
1479 | 1483 |
1480 for (unsigned i = 0; i < 3; ++i) { | 1484 for (unsigned i = 0; i < 3; ++i) { |
1481 for (unsigned j = 0; j < 2; ++j) | 1485 for (unsigned j = 0; j < 2; ++j) |
1482 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1486 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
1483 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1487 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
1484 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1488 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
1485 } | 1489 } |
(...skipping 13 matching lines...) Expand all Loading... |
1499 updateTextures(); | 1503 updateTextures(); |
1500 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); | 1504 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); |
1501 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1505 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
1502 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1506 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
1503 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1507 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
1504 | 1508 |
1505 root->fakeLayerUpdater()->clearUpdateCount(); | 1509 root->fakeLayerUpdater()->clearUpdateCount(); |
1506 child->fakeLayerUpdater()->clearUpdateCount(); | 1510 child->fakeLayerUpdater()->clearUpdateCount(); |
1507 child2->fakeLayerUpdater()->clearUpdateCount(); | 1511 child2->fakeLayerUpdater()->clearUpdateCount(); |
1508 | 1512 |
1509 ScopedFakeTiledLayerImpl rootImpl(root->id()); | 1513 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id()); |
1510 ScopedFakeTiledLayerImpl childImpl(child->id()); | 1514 ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id()); |
1511 ScopedFakeTiledLayerImpl child2Impl(child2->id()); | 1515 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id()); |
1512 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1516 layerPushPropertiesTo(root.get(), rootImpl.get()); |
1513 layerPushPropertiesTo(child.get(), childImpl.get()); | 1517 layerPushPropertiesTo(child.get(), childImpl.get()); |
1514 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1518 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
1515 | 1519 |
1516 for (unsigned i = 0; i < 3; ++i) { | 1520 for (unsigned i = 0; i < 3; ++i) { |
1517 for (unsigned j = 0; j < 2; ++j) | 1521 for (unsigned j = 0; j < 2; ++j) |
1518 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); | 1522 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); |
1519 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1523 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
1520 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1524 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
1521 } | 1525 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 | 1626 |
1623 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1627 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
1624 layer->setNeedsDisplayRect(layerRect); | 1628 layer->setNeedsDisplayRect(layerRect); |
1625 layer->update(*m_queue.get(), 0, m_stats); | 1629 layer->update(*m_queue.get(), 0, m_stats); |
1626 | 1630 |
1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1631 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1628 } | 1632 } |
1629 | 1633 |
1630 } // namespace | 1634 } // namespace |
1631 } // namespace cc | 1635 } // namespace cc |
OLD | NEW |