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" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 TestOcclusionTracker* m_occlusion; | 175 TestOcclusionTracker* m_occlusion; |
176 }; | 176 }; |
177 | 177 |
178 TEST_F(TiledLayerTest, pushDirtyTiles) | 178 TEST_F(TiledLayerTest, pushDirtyTiles) |
179 { | 179 { |
180 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 180 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
181 ScopedFakeTiledLayerImpl layerImpl(1); | 181 ScopedFakeTiledLayerImpl layerImpl(1); |
182 | 182 |
183 // The tile size is 100x100, so this invalidates and then paints two tiles. | 183 // The tile size is 100x100, so this invalidates and then paints two tiles. |
184 layer->setBounds(gfx::Size(100, 200)); | 184 layer->setBounds(gfx::Size(100, 200)); |
185 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 185 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
186 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 186 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
187 updateAndPush(layer.get(), layerImpl.get()); | 187 updateAndPush(layer.get(), layerImpl.get()); |
188 | 188 |
189 // We should have both tiles on the impl side. | 189 // We should have both tiles on the impl side. |
190 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 190 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
191 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 191 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
192 | 192 |
193 // Invalidates both tiles, but then only update one of them. | 193 // Invalidates both tiles, but then only update one of them. |
194 layer->setBounds(gfx::Size(100, 200)); | 194 layer->setBounds(gfx::Size(100, 200)); |
195 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); | 195 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
196 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 196 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
197 updateAndPush(layer.get(), layerImpl.get()); | 197 updateAndPush(layer.get(), layerImpl.get()); |
198 | 198 |
199 // We should only have the first tile since the other tile was invalidated b
ut not painted. | 199 // We should only have the first tile since the other tile was invalidated b
ut not painted. |
200 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 200 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
201 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 201 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
202 } | 202 } |
203 | 203 |
204 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) | 204 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) |
205 { | 205 { |
206 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 206 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
207 ScopedFakeTiledLayerImpl layerImpl(1); | 207 ScopedFakeTiledLayerImpl layerImpl(1); |
208 TestOcclusionTracker occluded; | 208 TestOcclusionTracker occluded; |
209 m_occlusion = &occluded; | 209 m_occlusion = &occluded; |
210 | 210 |
211 // The tile size is 100x100, so this invalidates and then paints two tiles. | 211 // The tile size is 100x100, so this invalidates and then paints two tiles. |
212 layer->setBounds(gfx::Size(100, 200)); | 212 layer->setBounds(gfx::Size(100, 200)); |
213 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 213 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
214 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200)); | 214 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); |
215 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 215 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
216 updateAndPush(layer.get(), layerImpl.get()); | 216 updateAndPush(layer.get(), layerImpl.get()); |
217 | 217 |
218 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 218 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
219 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); | 219 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); |
220 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 220 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
221 | 221 |
222 // We should have both tiles on the impl side. | 222 // We should have both tiles on the impl side. |
223 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 223 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
224 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 224 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
(...skipping 13 matching lines...) Expand all Loading... |
238 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 238 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
239 } | 239 } |
240 | 240 |
241 TEST_F(TiledLayerTest, pushDeletedTiles) | 241 TEST_F(TiledLayerTest, pushDeletedTiles) |
242 { | 242 { |
243 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 243 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
244 ScopedFakeTiledLayerImpl layerImpl(1); | 244 ScopedFakeTiledLayerImpl layerImpl(1); |
245 | 245 |
246 // The tile size is 100x100, so this invalidates and then paints two tiles. | 246 // The tile size is 100x100, so this invalidates and then paints two tiles. |
247 layer->setBounds(gfx::Size(100, 200)); | 247 layer->setBounds(gfx::Size(100, 200)); |
248 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 248 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
249 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 249 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
250 updateAndPush(layer.get(), layerImpl.get()); | 250 updateAndPush(layer.get(), layerImpl.get()); |
251 | 251 |
252 // We should have both tiles on the impl side. | 252 // We should have both tiles on the impl side. |
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 m_resourceManager->clearPriorities(); | 256 m_resourceManager->clearPriorities(); |
257 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge
t()); | 257 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge
t()); |
258 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024); | 258 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024); |
259 | 259 |
260 // This should drop the tiles on the impl thread. | 260 // This should drop the tiles on the impl thread. |
261 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 261 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
262 | 262 |
263 // We should now have no textures on the impl thread. | 263 // We should now have no textures on the impl thread. |
264 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 264 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
265 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 265 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
266 | 266 |
267 // This should recreate and update one of the deleted textures. | 267 // This should recreate and update one of the deleted textures. |
268 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); | 268 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
269 updateAndPush(layer.get(), layerImpl.get()); | 269 updateAndPush(layer.get(), layerImpl.get()); |
270 | 270 |
271 // We should have one tiles on the impl side. | 271 // We should have one tiles on the impl side. |
272 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 272 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
273 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 273 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
274 } | 274 } |
275 | 275 |
276 TEST_F(TiledLayerTest, pushIdlePaintTiles) | 276 TEST_F(TiledLayerTest, pushIdlePaintTiles) |
277 { | 277 { |
278 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 278 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
279 ScopedFakeTiledLayerImpl layerImpl(1); | 279 ScopedFakeTiledLayerImpl layerImpl(1); |
280 | 280 |
281 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. | 281 // 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. | 282 // This paints 1 visible of the 25 invalid tiles. |
283 layer->setBounds(gfx::Size(500, 500)); | 283 layer->setBounds(gfx::Size(500, 500)); |
284 layer->setVisibleContentRect(gfx::Rect(200, 200, 100, 100)); | 284 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100)
; |
285 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); | 285 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); |
286 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 286 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
287 // We should need idle-painting for surrounding tiles. | 287 // We should need idle-painting for surrounding tiles. |
288 EXPECT_TRUE(needsUpdate); | 288 EXPECT_TRUE(needsUpdate); |
289 | 289 |
290 // We should have one tile on the impl side. | 290 // We should have one tile on the impl side. |
291 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); | 291 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); |
292 | 292 |
293 // For the next four updates, we should detect we still need idle painting. | 293 // For the next four updates, we should detect we still need idle painting. |
294 for (int i = 0; i < 4; i++) { | 294 for (int i = 0; i < 4; i++) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // The tile size is 100x100. Setup 5x5 tiles with one visible tile | 341 // The tile size is 100x100. Setup 5x5 tiles with one visible tile |
342 // in the center. | 342 // in the center. |
343 gfx::Size contentBounds = gfx::Size(500, 500); | 343 gfx::Size contentBounds = gfx::Size(500, 500); |
344 gfx::Rect contentRect = gfx::Rect(0, 0, 500, 500); | 344 gfx::Rect contentRect = gfx::Rect(0, 0, 500, 500); |
345 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); | 345 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); |
346 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi
ons[k], visibleRect.size()); | 346 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi
ons[k], visibleRect.size()); |
347 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[
k], visibleRect.size()); | 347 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[
k], visibleRect.size()); |
348 | 348 |
349 // Setup. Use the previousVisibleRect to setup the prediction for next f
rame. | 349 // Setup. Use the previousVisibleRect to setup the prediction for next f
rame. |
350 layer->setBounds(contentBounds); | 350 layer->setBounds(contentBounds); |
351 layer->setVisibleContentRect(previousVisibleRect); | 351 layer->drawProperties().visible_content_rect = previousVisibleRect; |
352 layer->invalidateContentRect(contentRect); | 352 layer->invalidateContentRect(contentRect); |
353 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 353 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
354 | 354 |
355 // Invalidate and move the visibleRect in the scroll direction. | 355 // Invalidate and move the visibleRect in the scroll direction. |
356 // Check that the correct tiles have been painted in the visible pass. | 356 // Check that the correct tiles have been painted in the visible pass. |
357 layer->invalidateContentRect(contentRect); | 357 layer->invalidateContentRect(contentRect); |
358 layer->setVisibleContentRect(visibleRect); | 358 layer->drawProperties().visible_content_rect = visibleRect; |
359 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 359 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
360 for (int i = 0; i < 5; i++) { | 360 for (int i = 0; i < 5; i++) { |
361 for (int j = 0; j < 5; j++) | 361 for (int j = 0; j < 5; j++) |
362 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible
Tiles[k].Contains(i, j)); | 362 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible
Tiles[k].Contains(i, j)); |
363 } | 363 } |
364 | 364 |
365 // Move the transform in the same direction without invalidating. | 365 // Move the transform in the same direction without invalidating. |
366 // Check that non-visible pre-painting occured in the correct direction. | 366 // Check that non-visible pre-painting occured in the correct direction. |
367 // Ignore diagonal scrolls here (k > 3) as these have new visible conten
t now. | 367 // Ignore diagonal scrolls here (k > 3) as these have new visible conten
t now. |
368 if (k <= 3) { | 368 if (k <= 3) { |
369 layer->setVisibleContentRect(nextVisibleRect); | 369 layer->drawProperties().visible_content_rect = nextVisibleRect; |
370 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 370 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
371 for (int i = 0; i < 5; i++) { | 371 for (int i = 0; i < 5; i++) { |
372 for (int j = 0; j < 5; j++) | 372 for (int j = 0; j < 5; j++) |
373 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre
paintTiles[k].Contains(i, j)); | 373 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre
paintTiles[k].Contains(i, j)); |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 // We should always finish painting eventually. | 377 // We should always finish painting eventually. |
378 for (int i = 0; i < 20; i++) | 378 for (int i = 0; i < 20; i++) |
379 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 379 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
(...skipping 15 matching lines...) Expand all Loading... |
395 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. | 395 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. |
396 | 396 |
397 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. | 397 // 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); | 398 gfx::Rect layer1Rect(0, 0, 100, 2400); |
399 | 399 |
400 // This requires 4*30000 bytes of memory. | 400 // This requires 4*30000 bytes of memory. |
401 gfx::Rect layer2Rect(0, 0, 100, 300); | 401 gfx::Rect layer2Rect(0, 0, 100, 300); |
402 | 402 |
403 // Paint a single tile in layer2 so that it will idle paint. | 403 // Paint a single tile in layer2 so that it will idle paint. |
404 layer1->setBounds(layer1Rect.size()); | 404 layer1->setBounds(layer1Rect.size()); |
405 layer1->setVisibleContentRect(layer1Rect); | 405 layer1->drawProperties().visible_content_rect = layer1Rect; |
406 layer2->setBounds(layer2Rect.size()); | 406 layer2->setBounds(layer2Rect.size()); |
407 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); | 407 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
408 bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), | 408 bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), |
409 layer2.get(), layerImpl2.get()); | 409 layer2.get(), layerImpl2.get()); |
410 // We should need idle-painting for both remaining tiles in layer2. | 410 // We should need idle-painting for both remaining tiles in layer2. |
411 EXPECT_TRUE(needsUpdate); | 411 EXPECT_TRUE(needsUpdate); |
412 | 412 |
413 // Reduce our memory limits to 1mb. | 413 // Reduce our memory limits to 1mb. |
414 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024); | 414 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024); |
415 | 415 |
416 // Now idle paint layer2. We are going to run out of memory though! | 416 // Now idle paint layer2. We are going to run out of memory though! |
417 // Oh well, commit the frame and push. | 417 // Oh well, commit the frame and push. |
(...skipping 21 matching lines...) Expand all Loading... |
439 { | 439 { |
440 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 440 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
441 ScopedFakeTiledLayerImpl layerImpl(1); | 441 ScopedFakeTiledLayerImpl layerImpl(1); |
442 TestOcclusionTracker occluded; | 442 TestOcclusionTracker occluded; |
443 m_occlusion = &occluded; | 443 m_occlusion = &occluded; |
444 | 444 |
445 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. | 445 // 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)); | 446 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); |
447 | 447 |
448 layer->setBounds(gfx::Size(100, 100)); | 448 layer->setBounds(gfx::Size(100, 100)); |
449 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); | 449 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
450 updateAndPush(layer.get(), layerImpl.get()); | 450 updateAndPush(layer.get(), layerImpl.get()); |
451 | 451 |
452 // We should have the prepainted tile on the impl side, but culled it during
paint. | 452 // We should have the prepainted tile on the impl side, but culled it during
paint. |
453 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 453 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
454 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 454 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
455 } | 455 } |
456 | 456 |
457 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) | 457 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) |
458 { | 458 { |
459 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 459 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
460 ScopedFakeTiledLayerImpl layerImpl(1); | 460 ScopedFakeTiledLayerImpl layerImpl(1); |
461 | 461 |
462 // The tile size is 100x100, so this invalidates and then paints two tiles. | 462 // 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 | 463 // However, during the paint, we invalidate one of the tiles. This should |
464 // not prevent the tile from being pushed. | 464 // not prevent the tile from being pushed. |
465 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); | 465 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); |
466 layer->setBounds(gfx::Size(100, 200)); | 466 layer->setBounds(gfx::Size(100, 200)); |
467 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 467 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
468 updateAndPush(layer.get(), layerImpl.get()); | 468 updateAndPush(layer.get(), layerImpl.get()); |
469 | 469 |
470 // We should have both tiles on the impl side. | 470 // We should have both tiles on the impl side. |
471 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 471 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
472 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 472 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
473 } | 473 } |
474 | 474 |
475 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 475 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
476 { | 476 { |
477 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 477 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())); | 478 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
479 ScopedFakeTiledLayerImpl layer1Impl(1); | 479 ScopedFakeTiledLayerImpl layer1Impl(1); |
480 ScopedFakeTiledLayerImpl layer2Impl(2); | 480 ScopedFakeTiledLayerImpl layer2Impl(2); |
481 | 481 |
482 // Invalidate a tile on layer1, during update of layer 2. | 482 // Invalidate a tile on layer1, during update of layer 2. |
483 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); | 483 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); |
484 layer1->setBounds(gfx::Size(100, 200)); | 484 layer1->setBounds(gfx::Size(100, 200)); |
485 layer1->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 485 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
486 layer2->setBounds(gfx::Size(100, 200)); | 486 layer2->setBounds(gfx::Size(100, 200)); |
487 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 487 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
488 updateAndPush(layer1.get(), layer1Impl.get(), | 488 updateAndPush(layer1.get(), layer1Impl.get(), |
489 layer2.get(), layer2Impl.get()); | 489 layer2.get(), layer2Impl.get()); |
490 | 490 |
491 // We should have both tiles on the impl side for all layers. | 491 // We should have both tiles on the impl side for all layers. |
492 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 492 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
493 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 493 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
494 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 494 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
495 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 495 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
496 } | 496 } |
497 | 497 |
498 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) | 498 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) |
499 { | 499 { |
500 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); | 500 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())); | 501 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_resourceManager.get())); |
502 ScopedFakeTiledLayerImpl layer1Impl(1); | 502 ScopedFakeTiledLayerImpl layer1Impl(1); |
503 ScopedFakeTiledLayerImpl layer2Impl(2); | 503 ScopedFakeTiledLayerImpl layer2Impl(2); |
504 | 504 |
505 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); | 505 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); |
506 layer1->setBounds(gfx::Size(100, 200)); | 506 layer1->setBounds(gfx::Size(100, 200)); |
507 layer1->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 507 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
508 layer2->setBounds(gfx::Size(100, 200)); | 508 layer2->setBounds(gfx::Size(100, 200)); |
509 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 509 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
510 updateAndPush(layer1.get(), layer1Impl.get(), | 510 updateAndPush(layer1.get(), layer1Impl.get(), |
511 layer2.get(), layer2Impl.get()); | 511 layer2.get(), layer2Impl.get()); |
512 | 512 |
513 // We should have both tiles on the impl side for all layers. | 513 // We should have both tiles on the impl side for all layers. |
514 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 514 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
515 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 515 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
516 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 516 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
517 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 517 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
518 } | 518 } |
519 | 519 |
(...skipping 22 matching lines...) Expand all Loading... |
542 | 542 |
543 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); | 543 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_resourceManager.get())); |
544 ScopedFakeTiledLayerImpl layerImpl(1); | 544 ScopedFakeTiledLayerImpl layerImpl(1); |
545 | 545 |
546 // Full size layer with half being visible. | 546 // Full size layer with half being visible. |
547 gfx::Size contentBounds(layerWidth, layerHeight); | 547 gfx::Size contentBounds(layerWidth, layerHeight); |
548 gfx::Rect contentRect(gfx::Point(), contentBounds); | 548 gfx::Rect contentRect(gfx::Point(), contentBounds); |
549 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); | 549 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); |
550 | 550 |
551 // Pretend the layer is animating. | 551 // Pretend the layer is animating. |
552 layer->setDrawTransformIsAnimating(true); | 552 layer->drawProperties().target_space_transform_is_animating = true; |
553 layer->setBounds(contentBounds); | 553 layer->setBounds(contentBounds); |
554 layer->setVisibleContentRect(visibleRect); | 554 layer->drawProperties().visible_content_rect = visibleRect; |
555 layer->invalidateContentRect(contentRect); | 555 layer->invalidateContentRect(contentRect); |
556 layer->setLayerTreeHost(layerTreeHost.get()); | 556 layer->setLayerTreeHost(layerTreeHost.get()); |
557 | 557 |
558 // The layer should paint it's entire contents on the first paint | 558 // The layer should paint it's entire contents on the first paint |
559 // if it is close to the viewport size and has the available memory. | 559 // if it is close to the viewport size and has the available memory. |
560 layer->setTexturePriorities(m_priorityCalculator); | 560 layer->setTexturePriorities(m_priorityCalculator); |
561 m_resourceManager->prioritizeTextures(); | 561 m_resourceManager->prioritizeTextures(); |
562 layer->update(*m_queue.get(), 0, m_stats); | 562 layer->update(*m_queue.get(), 0, m_stats); |
563 updateTextures(); | 563 updateTextures(); |
564 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 564 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
(...skipping 20 matching lines...) Expand all Loading... |
585 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 585 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
586 ScopedFakeTiledLayerImpl layerImpl(1); | 586 ScopedFakeTiledLayerImpl layerImpl(1); |
587 | 587 |
588 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 588 // 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. | 589 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
590 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); | 590 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); |
591 | 591 |
592 // The tile size is 100x100, so this invalidates and then paints two tiles. | 592 // The tile size is 100x100, so this invalidates and then paints two tiles. |
593 bool needsUpdate = false; | 593 bool needsUpdate = false; |
594 layer->setBounds(gfx::Size(300, 300)); | 594 layer->setBounds(gfx::Size(300, 300)); |
595 layer->setVisibleContentRect(gfx::Rect(100, 100, 100, 100)); | 595 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100)
; |
596 for (int i = 0; i < 2; i++) | 596 for (int i = 0; i < 2; i++) |
597 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 597 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
598 | 598 |
599 // Idle-painting should see no more priority tiles for painting. | 599 // Idle-painting should see no more priority tiles for painting. |
600 EXPECT_FALSE(needsUpdate); | 600 EXPECT_FALSE(needsUpdate); |
601 | 601 |
602 // We should have one tile on the impl side. | 602 // We should have one tile on the impl side. |
603 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); | 603 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); |
604 } | 604 } |
605 | 605 |
606 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) | 606 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) |
607 { | 607 { |
608 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 608 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
609 ScopedFakeTiledLayerImpl layerImpl(1); | 609 ScopedFakeTiledLayerImpl layerImpl(1); |
610 | 610 |
611 bool animating[2] = {false, true}; | 611 bool animating[2] = {false, true}; |
612 for (int i = 0; i < 2; i++) { | 612 for (int i = 0; i < 2; i++) { |
613 // Pretend the layer is animating. | 613 // Pretend the layer is animating. |
614 layer->setDrawTransformIsAnimating(animating[i]); | 614 layer->drawProperties().target_space_transform_is_animating = animating[
i]; |
615 | 615 |
616 // The layer's bounds are empty. | 616 // The layer's bounds are empty. |
617 // Empty layers don't paint or idle-paint. | 617 // Empty layers don't paint or idle-paint. |
618 layer->setBounds(gfx::Size()); | 618 layer->setBounds(gfx::Size()); |
619 layer->setVisibleContentRect(gfx::Rect()); | 619 layer->drawProperties().visible_content_rect = gfx::Rect(); |
620 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 620 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
621 | 621 |
622 // Empty layers don't have tiles. | 622 // Empty layers don't have tiles. |
623 EXPECT_EQ(0u, layer->numPaintedTiles()); | 623 EXPECT_EQ(0u, layer->numPaintedTiles()); |
624 | 624 |
625 // Empty layers don't need prepaint. | 625 // Empty layers don't need prepaint. |
626 EXPECT_FALSE(needsUpdate); | 626 EXPECT_FALSE(needsUpdate); |
627 | 627 |
628 // Empty layers don't have tiles. | 628 // Empty layers don't have tiles. |
629 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 629 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
(...skipping 10 matching lines...) Expand all Loading... |
640 gfx::Rect nv(0, 0, 0, 0); | 640 gfx::Rect nv(0, 0, 0, 0); |
641 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 641 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 }; | 642 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; |
643 | 643 |
644 // We should not have any tiles except for when the layer was visible | 644 // 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. | 645 // 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 }; | 646 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; |
647 | 647 |
648 for (int i = 0; i < 10; i++) { | 648 for (int i = 0; i < 10; i++) { |
649 layer->setBounds(gfx::Size(100, 100)); | 649 layer->setBounds(gfx::Size(100, 100)); |
650 layer->setVisibleContentRect(visibleRect[i]); | 650 layer->drawProperties().visible_content_rect = visibleRect[i]; |
651 | 651 |
652 if (invalidate[i]) | 652 if (invalidate[i]) |
653 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); | 653 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); |
654 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 654 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
655 | 655 |
656 // We should never signal idle paint, as we painted the entire layer | 656 // We should never signal idle paint, as we painted the entire layer |
657 // or the layer was not visible. | 657 // or the layer was not visible. |
658 EXPECT_FALSE(needsUpdate); | 658 EXPECT_FALSE(needsUpdate); |
659 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); | 659 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); |
660 } | 660 } |
661 } | 661 } |
662 | 662 |
663 TEST_F(TiledLayerTest, invalidateFromPrepare) | 663 TEST_F(TiledLayerTest, invalidateFromPrepare) |
664 { | 664 { |
665 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 665 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
666 ScopedFakeTiledLayerImpl layerImpl(1); | 666 ScopedFakeTiledLayerImpl layerImpl(1); |
667 | 667 |
668 // The tile size is 100x100, so this invalidates and then paints two tiles. | 668 // The tile size is 100x100, so this invalidates and then paints two tiles. |
669 layer->setBounds(gfx::Size(100, 200)); | 669 layer->setBounds(gfx::Size(100, 200)); |
670 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 670 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
671 updateAndPush(layer.get(), layerImpl.get()); | 671 updateAndPush(layer.get(), layerImpl.get()); |
672 | 672 |
673 // We should have both tiles on the impl side. | 673 // We should have both tiles on the impl side. |
674 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 674 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
675 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 675 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
676 | 676 |
677 layer->fakeLayerUpdater()->clearPrepareCount(); | 677 layer->fakeLayerUpdater()->clearPrepareCount(); |
678 // Invoke update again. As the layer is valid update shouldn't be invoked on | 678 // Invoke update again. As the layer is valid update shouldn't be invoked on |
679 // the LayerUpdater. | 679 // the LayerUpdater. |
680 updateAndPush(layer.get(), layerImpl.get()); | 680 updateAndPush(layer.get(), layerImpl.get()); |
(...skipping 16 matching lines...) Expand all Loading... |
697 { | 697 { |
698 // The updateRect (that indicates what was actually painted) should be in | 698 // The updateRect (that indicates what was actually painted) should be in |
699 // layer space, not the content space. | 699 // layer space, not the content space. |
700 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new
FakeTiledLayerWithScaledBounds(m_resourceManager.get())); | 700 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new
FakeTiledLayerWithScaledBounds(m_resourceManager.get())); |
701 | 701 |
702 gfx::Rect layerBounds(0, 0, 300, 200); | 702 gfx::Rect layerBounds(0, 0, 300, 200); |
703 gfx::Rect contentBounds(0, 0, 200, 250); | 703 gfx::Rect contentBounds(0, 0, 200, 250); |
704 | 704 |
705 layer->setBounds(layerBounds.size()); | 705 layer->setBounds(layerBounds.size()); |
706 layer->setContentBounds(contentBounds.size()); | 706 layer->setContentBounds(contentBounds.size()); |
707 layer->setVisibleContentRect(contentBounds); | 707 layer->drawProperties().visible_content_rect = contentBounds; |
708 | 708 |
709 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. | 709 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. |
710 // However, it should still be in layer space, not content space. | 710 // However, it should still be in layer space, not content space. |
711 layer->invalidateContentRect(contentBounds); | 711 layer->invalidateContentRect(contentBounds); |
712 | 712 |
713 layer->setTexturePriorities(m_priorityCalculator); | 713 layer->setTexturePriorities(m_priorityCalculator); |
714 m_resourceManager->prioritizeTextures(); | 714 m_resourceManager->prioritizeTextures(); |
715 layer->update(*m_queue.get(), 0, m_stats); | 715 layer->update(*m_queue.get(), 0, m_stats); |
716 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect()); | 716 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect()); |
717 updateTextures(); | 717 updateTextures(); |
(...skipping 15 matching lines...) Expand all Loading... |
733 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); | 733 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); |
734 } | 734 } |
735 | 735 |
736 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 736 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
737 { | 737 { |
738 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 738 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
739 ScopedFakeTiledLayerImpl layerImpl(1); | 739 ScopedFakeTiledLayerImpl layerImpl(1); |
740 | 740 |
741 // Create a layer with one tile. | 741 // Create a layer with one tile. |
742 layer->setBounds(gfx::Size(100, 100)); | 742 layer->setBounds(gfx::Size(100, 100)); |
743 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); | 743 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
744 | 744 |
745 // Invalidate the entire layer. | 745 // Invalidate the entire layer. |
746 layer->setNeedsDisplay(); | 746 layer->setNeedsDisplay(); |
747 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); | 747 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
748 | 748 |
749 // Push the tiles to the impl side and check that there is exactly one. | 749 // Push the tiles to the impl side and check that there is exactly one. |
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, m_stats); | 752 layer->update(*m_queue.get(), 0, m_stats); |
753 updateTextures(); | 753 updateTextures(); |
754 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 754 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
755 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 755 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
756 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 756 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
757 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); | 757 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); |
758 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); | 758 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); |
759 | 759 |
760 // Change the contents scale and verify that the content rectangle requiring
painting | 760 // Change the contents scale and verify that the content rectangle requiring
painting |
761 // is not scaled. | 761 // is not scaled. |
762 layer->setContentsScale(2); | 762 layer->setContentsScale(2); |
763 layer->setVisibleContentRect(gfx::Rect(0, 0, 200, 200)); | 763 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 200, 200); |
764 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); | 764 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
765 | 765 |
766 // The impl side should get 2x2 tiles now. | 766 // The impl side should get 2x2 tiles now. |
767 layer->setTexturePriorities(m_priorityCalculator); | 767 layer->setTexturePriorities(m_priorityCalculator); |
768 m_resourceManager->prioritizeTextures(); | 768 m_resourceManager->prioritizeTextures(); |
769 layer->update(*m_queue.get(), 0, m_stats); | 769 layer->update(*m_queue.get(), 0, m_stats); |
770 updateTextures(); | 770 updateTextures(); |
771 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 771 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
772 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 772 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
773 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 773 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
(...skipping 20 matching lines...) Expand all Loading... |
794 gfx::Rect contentRect(gfx::Point(), contentBounds); | 794 gfx::Rect contentRect(gfx::Point(), contentBounds); |
795 | 795 |
796 // We have enough memory for only one of the two layers. | 796 // We have enough memory for only one of the two layers. |
797 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. | 797 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. |
798 | 798 |
799 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa
yer(m_layerTreeHost->contentsTextureManager())); | 799 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa
yer(m_layerTreeHost->contentsTextureManager())); |
800 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL
ayer(m_layerTreeHost->contentsTextureManager())); | 800 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL
ayer(m_layerTreeHost->contentsTextureManager())); |
801 rootLayer->addChild(childLayer); | 801 rootLayer->addChild(childLayer); |
802 | 802 |
803 rootLayer->setBounds(contentBounds); | 803 rootLayer->setBounds(contentBounds); |
804 rootLayer->setVisibleContentRect(contentRect); | 804 rootLayer->drawProperties().visible_content_rect = contentRect; |
805 rootLayer->setPosition(gfx::PointF(0, 0)); | 805 rootLayer->setPosition(gfx::PointF(0, 0)); |
806 childLayer->setBounds(contentBounds); | 806 childLayer->setBounds(contentBounds); |
807 childLayer->setVisibleContentRect(contentRect); | 807 childLayer->drawProperties().visible_content_rect = contentRect; |
808 childLayer->setPosition(gfx::PointF(0, 0)); | 808 childLayer->setPosition(gfx::PointF(0, 0)); |
809 rootLayer->invalidateContentRect(contentRect); | 809 rootLayer->invalidateContentRect(contentRect); |
810 childLayer->invalidateContentRect(contentRect); | 810 childLayer->invalidateContentRect(contentRect); |
811 | 811 |
812 m_layerTreeHost->setRootLayer(rootLayer); | 812 m_layerTreeHost->setRootLayer(rootLayer); |
813 m_layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); | 813 m_layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); |
814 | 814 |
815 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); | 815 m_layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); |
816 | 816 |
817 // We'll skip the root layer. | 817 // We'll skip the root layer. |
(...skipping 10 matching lines...) Expand all Loading... |
828 | 828 |
829 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r
esourceProvider.get()); | 829 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r
esourceProvider.get()); |
830 m_layerTreeHost->setRootLayer(0); | 830 m_layerTreeHost->setRootLayer(0); |
831 } | 831 } |
832 | 832 |
833 TEST_F(TiledLayerTest, resizeToSmaller) | 833 TEST_F(TiledLayerTest, resizeToSmaller) |
834 { | 834 { |
835 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 835 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
836 | 836 |
837 layer->setBounds(gfx::Size(700, 700)); | 837 layer->setBounds(gfx::Size(700, 700)); |
838 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); | 838 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
839 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700)); | 839 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700)); |
840 | 840 |
841 layer->setTexturePriorities(m_priorityCalculator); | 841 layer->setTexturePriorities(m_priorityCalculator); |
842 m_resourceManager->prioritizeTextures(); | 842 m_resourceManager->prioritizeTextures(); |
843 layer->update(*m_queue.get(), 0, m_stats); | 843 layer->update(*m_queue.get(), 0, m_stats); |
844 | 844 |
845 layer->setBounds(gfx::Size(200, 200)); | 845 layer->setBounds(gfx::Size(200, 200)); |
846 layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200)); | 846 layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200)); |
847 } | 847 } |
848 | 848 |
849 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) | 849 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) |
850 { | 850 { |
851 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 851 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
852 | 852 |
853 int size = 1 << 30; | 853 int size = 1 << 30; |
854 layer->setBounds(gfx::Size(size, size)); | 854 layer->setBounds(gfx::Size(size, size)); |
855 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); | 855 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
856 layer->invalidateContentRect(gfx::Rect(0, 0, size, size)); | 856 layer->invalidateContentRect(gfx::Rect(0, 0, size, size)); |
857 | 857 |
858 // Ensure no crash for bounds where size * size would overflow an int. | 858 // Ensure no crash for bounds where size * size would overflow an int. |
859 layer->setTexturePriorities(m_priorityCalculator); | 859 layer->setTexturePriorities(m_priorityCalculator); |
860 m_resourceManager->prioritizeTextures(); | 860 m_resourceManager->prioritizeTextures(); |
861 layer->update(*m_queue.get(), 0, m_stats); | 861 layer->update(*m_queue.get(), 0, m_stats); |
862 } | 862 } |
863 | 863 |
864 class TiledLayerPartialUpdateTest : public TiledLayerTest { | 864 class TiledLayerPartialUpdateTest : public TiledLayerTest { |
865 public: | 865 public: |
866 TiledLayerPartialUpdateTest() | 866 TiledLayerPartialUpdateTest() |
867 { | 867 { |
868 m_settings.maxPartialTextureUpdates = 4; | 868 m_settings.maxPartialTextureUpdates = 4; |
869 } | 869 } |
870 }; | 870 }; |
871 | 871 |
872 TEST_F(TiledLayerPartialUpdateTest, partialUpdates) | 872 TEST_F(TiledLayerPartialUpdateTest, partialUpdates) |
873 { | 873 { |
874 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 874 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
875 gfx::Size contentBounds(300, 200); | 875 gfx::Size contentBounds(300, 200); |
876 gfx::Rect contentRect(gfx::Point(), contentBounds); | 876 gfx::Rect contentRect(gfx::Point(), contentBounds); |
877 | 877 |
878 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_layerTreeHost->contentsTextureManager())); | 878 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_layerTreeHost->contentsTextureManager())); |
879 layer->setBounds(contentBounds); | 879 layer->setBounds(contentBounds); |
880 layer->setPosition(gfx::PointF(0, 0)); | 880 layer->setPosition(gfx::PointF(0, 0)); |
881 layer->setVisibleContentRect(contentRect); | 881 layer->drawProperties().visible_content_rect = contentRect; |
882 layer->invalidateContentRect(contentRect); | 882 layer->invalidateContentRect(contentRect); |
883 | 883 |
884 m_layerTreeHost->setRootLayer(layer); | 884 m_layerTreeHost->setRootLayer(layer); |
885 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 885 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
886 | 886 |
887 // Full update of all 6 tiles. | 887 // Full update of all 6 tiles. |
888 m_layerTreeHost->updateLayers( | 888 m_layerTreeHost->updateLayers( |
889 *m_queue.get(), std::numeric_limits<size_t>::max()); | 889 *m_queue.get(), std::numeric_limits<size_t>::max()); |
890 { | 890 { |
891 ScopedFakeTiledLayerImpl layerImpl(1); | 891 ScopedFakeTiledLayerImpl layerImpl(1); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r
esourceProvider.get()); | 970 resourceManagerClearAllMemory(m_layerTreeHost->contentsTextureManager(), m_r
esourceProvider.get()); |
971 m_layerTreeHost->setRootLayer(0); | 971 m_layerTreeHost->setRootLayer(0); |
972 } | 972 } |
973 | 973 |
974 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) | 974 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) |
975 { | 975 { |
976 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 976 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
977 | 977 |
978 // The tile size is 100x100, so this invalidates and then paints two tiles. | 978 // The tile size is 100x100, so this invalidates and then paints two tiles. |
979 layer->setBounds(gfx::Size(100, 200)); | 979 layer->setBounds(gfx::Size(100, 200)); |
980 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200)); | 980 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); |
981 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); | 981 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
982 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 982 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
983 | 983 |
984 layer->setTexturePriorities(m_priorityCalculator); | 984 layer->setTexturePriorities(m_priorityCalculator); |
985 m_resourceManager->prioritizeTextures(); | 985 m_resourceManager->prioritizeTextures(); |
986 layer->update(*m_queue.get(), 0, m_stats); | 986 layer->update(*m_queue.get(), 0, m_stats); |
987 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); | 987 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); |
988 } | 988 } |
989 | 989 |
990 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) | 990 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) |
991 { | 991 { |
992 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 992 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
993 TestOcclusionTracker occluded; | 993 TestOcclusionTracker occluded; |
994 | 994 |
995 // The tile size is 100x100. | 995 // The tile size is 100x100. |
996 | 996 |
997 layer->setBounds(gfx::Size(600, 600)); | 997 layer->setBounds(gfx::Size(600, 600)); |
998 | 998 |
999 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 999 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1000 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()
)); | 1000 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye
r->contentBounds()); |
1001 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); | 1001 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer
->contentBounds()); |
1002 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1002 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1003 | 1003 |
1004 layer->setTexturePriorities(m_priorityCalculator); | 1004 layer->setTexturePriorities(m_priorityCalculator); |
1005 m_resourceManager->prioritizeTextures(); | 1005 m_resourceManager->prioritizeTextures(); |
1006 layer->update(*m_queue.get(), &occluded, m_stats); | 1006 layer->update(*m_queue.get(), &occluded, m_stats); |
1007 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1007 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
1008 | 1008 |
1009 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1009 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1010 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1010 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
1011 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1011 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
(...skipping 29 matching lines...) Expand all Loading... |
1041 { | 1041 { |
1042 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 1042 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
1043 TestOcclusionTracker occluded; | 1043 TestOcclusionTracker occluded; |
1044 | 1044 |
1045 // The tile size is 100x100. | 1045 // The tile size is 100x100. |
1046 | 1046 |
1047 layer->setBounds(gfx::Size(600, 600)); | 1047 layer->setBounds(gfx::Size(600, 600)); |
1048 | 1048 |
1049 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. | 1049 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. |
1050 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1050 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1051 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 360)); | 1051 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
1052 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 360)); | 1052 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
1053 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1053 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1054 | 1054 |
1055 layer->setTexturePriorities(m_priorityCalculator); | 1055 layer->setTexturePriorities(m_priorityCalculator); |
1056 m_resourceManager->prioritizeTextures(); | 1056 m_resourceManager->prioritizeTextures(); |
1057 layer->update(*m_queue.get(), &occluded, m_stats); | 1057 layer->update(*m_queue.get(), &occluded, m_stats); |
1058 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); | 1058 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); |
1059 | 1059 |
1060 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1060 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1061 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); | 1061 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); |
1062 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1062 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
1063 | 1063 |
1064 layer->fakeLayerUpdater()->clearUpdateCount(); | 1064 layer->fakeLayerUpdater()->clearUpdateCount(); |
1065 | 1065 |
1066 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. | 1066 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. |
1067 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1067 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1068 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 350)); | 1068 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 350); |
1069 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 350)); | 1069 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 350); |
1070 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1070 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1071 layer->setTexturePriorities(m_priorityCalculator); | 1071 layer->setTexturePriorities(m_priorityCalculator); |
1072 m_resourceManager->prioritizeTextures(); | 1072 m_resourceManager->prioritizeTextures(); |
1073 layer->update(*m_queue.get(), &occluded, m_stats); | 1073 layer->update(*m_queue.get(), &occluded, m_stats); |
1074 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); | 1074 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); |
1075 | 1075 |
1076 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1076 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1077 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); | 1077 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); |
1078 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1078 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
1079 | 1079 |
1080 layer->fakeLayerUpdater()->clearUpdateCount(); | 1080 layer->fakeLayerUpdater()->clearUpdateCount(); |
1081 | 1081 |
1082 // Now the visible region is even smaller than the occlusion, it should have
the same result. | 1082 // Now the visible region is even smaller than the occlusion, it should have
the same result. |
1083 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1083 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
1084 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 340)); | 1084 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 340); |
1085 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 340)); | 1085 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 340); |
1086 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1086 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1087 layer->setTexturePriorities(m_priorityCalculator); | 1087 layer->setTexturePriorities(m_priorityCalculator); |
1088 m_resourceManager->prioritizeTextures(); | 1088 m_resourceManager->prioritizeTextures(); |
1089 layer->update(*m_queue.get(), &occluded, m_stats); | 1089 layer->update(*m_queue.get(), &occluded, m_stats); |
1090 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); | 1090 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); |
1091 | 1091 |
1092 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1092 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1093 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); | 1093 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); |
1094 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1094 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
1095 | 1095 |
1096 } | 1096 } |
1097 | 1097 |
1098 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) | 1098 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) |
1099 { | 1099 { |
1100 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 1100 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
1101 TestOcclusionTracker occluded; | 1101 TestOcclusionTracker occluded; |
1102 | 1102 |
1103 // The tile size is 100x100. | 1103 // The tile size is 100x100. |
1104 | 1104 |
1105 layer->setBounds(gfx::Size(600, 600)); | 1105 layer->setBounds(gfx::Size(600, 600)); |
1106 | 1106 |
1107 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1107 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1108 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 600)); | 1108 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
1109 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 600)); | 1109 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
1110 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1110 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1111 layer->setTexturePriorities(m_priorityCalculator); | 1111 layer->setTexturePriorities(m_priorityCalculator); |
1112 m_resourceManager->prioritizeTextures(); | 1112 m_resourceManager->prioritizeTextures(); |
1113 layer->update(*m_queue.get(), &occluded, m_stats); | 1113 layer->update(*m_queue.get(), &occluded, m_stats); |
1114 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1114 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
1115 { | 1115 { |
1116 updateTextures(); | 1116 updateTextures(); |
1117 } | 1117 } |
1118 | 1118 |
1119 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1119 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
(...skipping 18 matching lines...) Expand all Loading... |
1138 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 1138 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
1139 TestOcclusionTracker occluded; | 1139 TestOcclusionTracker occluded; |
1140 | 1140 |
1141 // The tile size is 100x100. | 1141 // The tile size is 100x100. |
1142 | 1142 |
1143 // This makes sure the painting works when the occluded region (in screen sp
ace) | 1143 // This makes sure the painting works when the occluded region (in screen sp
ace) |
1144 // is transformed differently than the layer. | 1144 // is transformed differently than the layer. |
1145 layer->setBounds(gfx::Size(600, 600)); | 1145 layer->setBounds(gfx::Size(600, 600)); |
1146 gfx::Transform screenTransform; | 1146 gfx::Transform screenTransform; |
1147 screenTransform.Scale(0.5, 0.5); | 1147 screenTransform.Scale(0.5, 0.5); |
1148 layer->setScreenSpaceTransform(screenTransform); | 1148 layer->drawProperties().screen_space_transform = screenTransform; |
1149 layer->setDrawTransform(screenTransform); | 1149 layer->drawProperties().target_space_transform = screenTransform; |
1150 | 1150 |
1151 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); | 1151 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); |
1152 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()
)); | 1152 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye
r->contentBounds()); |
1153 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); | 1153 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer
->contentBounds()); |
1154 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1154 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1155 layer->setTexturePriorities(m_priorityCalculator); | 1155 layer->setTexturePriorities(m_priorityCalculator); |
1156 m_resourceManager->prioritizeTextures(); | 1156 m_resourceManager->prioritizeTextures(); |
1157 layer->update(*m_queue.get(), &occluded, m_stats); | 1157 layer->update(*m_queue.get(), &occluded, m_stats); |
1158 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1158 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
1159 | 1159 |
1160 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1160 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1161 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1161 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
1162 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1162 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
1163 } | 1163 } |
1164 | 1164 |
1165 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) | 1165 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) |
1166 { | 1166 { |
1167 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 1167 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
1168 TestOcclusionTracker occluded; | 1168 TestOcclusionTracker occluded; |
1169 | 1169 |
1170 // The tile size is 100x100. | 1170 // The tile size is 100x100. |
1171 | 1171 |
1172 // This makes sure the painting works when the content space is scaled to | 1172 // This makes sure the painting works when the content space is scaled to |
1173 // a different layer space. In this case tiles are scaled to be 200x200 | 1173 // a different layer space. In this case tiles are scaled to be 200x200 |
1174 // pixels, which means none should be occluded. | 1174 // pixels, which means none should be occluded. |
1175 layer->setContentsScale(0.5); | 1175 layer->setContentsScale(0.5); |
1176 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); | 1176 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); |
1177 layer->setBounds(gfx::Size(600, 600)); | 1177 layer->setBounds(gfx::Size(600, 600)); |
1178 gfx::Transform drawTransform; | 1178 gfx::Transform drawTransform; |
1179 double invScaleFactor = 1 / layer->contentsScaleX(); | 1179 double invScaleFactor = 1 / layer->contentsScaleX(); |
1180 drawTransform.Scale(invScaleFactor, invScaleFactor); | 1180 drawTransform.Scale(invScaleFactor, invScaleFactor); |
1181 layer->setDrawTransform(drawTransform); | 1181 layer->drawProperties().target_space_transform = drawTransform; |
1182 layer->setScreenSpaceTransform(drawTransform); | 1182 layer->drawProperties().screen_space_transform = drawTransform; |
1183 | 1183 |
1184 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1184 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
1185 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->bounds())); | 1185 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye
r->bounds()); |
1186 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); | 1186 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer
->contentBounds()); |
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, m_stats); | 1190 layer->update(*m_queue.get(), &occluded, m_stats); |
1191 // The content is half the size of the layer (so the number of tiles is fewe
r). | 1191 // The content is half the size of the layer (so the number of tiles is fewe
r). |
1192 // In this case, the content is 300x300, and since the tile size is 100, the | 1192 // In this case, the content is 300x300, and since the tile size is 100, the |
1193 // number of tiles 3x3. | 1193 // number of tiles 3x3. |
1194 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); | 1194 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); |
1195 | 1195 |
1196 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1196 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1197 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); | 1197 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); |
1198 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1198 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1199 | 1199 |
1200 layer->fakeLayerUpdater()->clearUpdateCount(); | 1200 layer->fakeLayerUpdater()->clearUpdateCount(); |
1201 | 1201 |
1202 // This makes sure the painting works when the content space is scaled to | 1202 // This makes sure the painting works when the content space is scaled to |
1203 // a different layer space. In this case the occluded region catches the | 1203 // a different layer space. In this case the occluded region catches the |
1204 // blown up tiles. | 1204 // blown up tiles. |
1205 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200)); | 1205 occluded.setOcclusion(gfx::Rect(200, 200, 300, 200)); |
1206 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->bounds())); | 1206 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye
r->bounds()); |
1207 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); | 1207 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer
->contentBounds()); |
1208 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1208 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1209 layer->setTexturePriorities(m_priorityCalculator); | 1209 layer->setTexturePriorities(m_priorityCalculator); |
1210 m_resourceManager->prioritizeTextures(); | 1210 m_resourceManager->prioritizeTextures(); |
1211 layer->update(*m_queue.get(), &occluded, m_stats); | 1211 layer->update(*m_queue.get(), &occluded, m_stats); |
1212 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); | 1212 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); |
1213 | 1213 |
1214 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1214 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1215 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); | 1215 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); |
1216 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1216 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
1217 | 1217 |
1218 layer->fakeLayerUpdater()->clearUpdateCount(); | 1218 layer->fakeLayerUpdater()->clearUpdateCount(); |
1219 | 1219 |
1220 // This makes sure content scaling and transforms work together. | 1220 // This makes sure content scaling and transforms work together. |
1221 gfx::Transform screenTransform; | 1221 gfx::Transform screenTransform; |
1222 screenTransform.Scale(0.5, 0.5); | 1222 screenTransform.Scale(0.5, 0.5); |
1223 layer->setScreenSpaceTransform(screenTransform); | 1223 layer->drawProperties().screen_space_transform = screenTransform; |
1224 layer->setDrawTransform(screenTransform); | 1224 layer->drawProperties().target_space_transform = screenTransform; |
1225 | 1225 |
1226 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100)); | 1226 occluded.setOcclusion(gfx::Rect(100, 100, 150, 100)); |
1227 | 1227 |
1228 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); | 1228 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); |
1229 layer->setDrawableContentRect(gfx::ToEnclosingRect(gfx::ScaleRect(layerBound
sRect, 0.5))); | 1229 layer->drawProperties().drawable_content_rect = gfx::ToEnclosingRect(gfx::Sc
aleRect(layerBoundsRect, 0.5)); |
1230 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); | 1230 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer
->contentBounds()); |
1231 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1231 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1232 layer->setTexturePriorities(m_priorityCalculator); | 1232 layer->setTexturePriorities(m_priorityCalculator); |
1233 m_resourceManager->prioritizeTextures(); | 1233 m_resourceManager->prioritizeTextures(); |
1234 layer->update(*m_queue.get(), &occluded, m_stats); | 1234 layer->update(*m_queue.get(), &occluded, m_stats); |
1235 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); | 1235 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); |
1236 | 1236 |
1237 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1237 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1238 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); | 1238 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); |
1239 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1239 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); |
1240 } | 1240 } |
1241 | 1241 |
1242 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) | 1242 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) |
1243 { | 1243 { |
1244 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); | 1244 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_resourceManager.get())); |
1245 TestOcclusionTracker occluded; | 1245 TestOcclusionTracker occluded; |
1246 | 1246 |
1247 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1247 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
1248 | 1248 |
1249 gfx::Rect opaquePaintRect; | 1249 gfx::Rect opaquePaintRect; |
1250 Region opaqueContents; | 1250 Region opaqueContents; |
1251 | 1251 |
1252 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 200); | 1252 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 200); |
1253 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 150); | 1253 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 150); |
1254 | 1254 |
1255 layer->setBounds(contentBounds.size()); | 1255 layer->setBounds(contentBounds.size()); |
1256 layer->setDrawableContentRect(visibleBounds); | 1256 layer->drawProperties().drawable_content_rect = visibleBounds; |
1257 layer->setVisibleContentRect(visibleBounds); | 1257 layer->drawProperties().visible_content_rect = visibleBounds; |
1258 layer->setDrawOpacity(1); | 1258 layer->drawProperties().opacity = 1; |
1259 | 1259 |
1260 layer->setTexturePriorities(m_priorityCalculator); | 1260 layer->setTexturePriorities(m_priorityCalculator); |
1261 m_resourceManager->prioritizeTextures(); | 1261 m_resourceManager->prioritizeTextures(); |
1262 | 1262 |
1263 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. | 1263 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. |
1264 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); | 1264 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1265 layer->invalidateContentRect(contentBounds); | 1265 layer->invalidateContentRect(contentBounds); |
1266 layer->update(*m_queue.get(), &occluded, m_stats); | 1266 layer->update(*m_queue.get(), &occluded, m_stats); |
1267 opaqueContents = layer->visibleContentOpaqueRegion(); | 1267 opaqueContents = layer->visibleContentOpaqueRegion(); |
1268 EXPECT_TRUE(opaqueContents.IsEmpty()); | 1268 EXPECT_TRUE(opaqueContents.IsEmpty()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 | 1334 |
1335 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1335 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
1336 | 1336 |
1337 gfx::Rect opaquePaintRect; | 1337 gfx::Rect opaquePaintRect; |
1338 Region opaqueContents; | 1338 Region opaqueContents; |
1339 | 1339 |
1340 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); | 1340 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); |
1341 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 300); | 1341 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 300); |
1342 | 1342 |
1343 layer->setBounds(contentBounds.size()); | 1343 layer->setBounds(contentBounds.size()); |
1344 layer->setDrawableContentRect(visibleBounds); | 1344 layer->drawProperties().drawable_content_rect = visibleBounds; |
1345 layer->setVisibleContentRect(visibleBounds); | 1345 layer->drawProperties().visible_content_rect = visibleBounds; |
1346 layer->setDrawOpacity(1); | 1346 layer->drawProperties().opacity = 1; |
1347 | 1347 |
1348 layer->setTexturePriorities(m_priorityCalculator); | 1348 layer->setTexturePriorities(m_priorityCalculator); |
1349 m_resourceManager->prioritizeTextures(); | 1349 m_resourceManager->prioritizeTextures(); |
1350 | 1350 |
1351 // Invalidates and paints the whole layer. | 1351 // Invalidates and paints the whole layer. |
1352 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); | 1352 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1353 layer->invalidateContentRect(contentBounds); | 1353 layer->invalidateContentRect(contentBounds); |
1354 layer->update(*m_queue.get(), &occluded, m_stats); | 1354 layer->update(*m_queue.get(), &occluded, m_stats); |
1355 updateTextures(); | 1355 updateTextures(); |
1356 opaqueContents = layer->visibleContentOpaqueRegion(); | 1356 opaqueContents = layer->visibleContentOpaqueRegion(); |
(...skipping 29 matching lines...) Expand all Loading... |
1386 gfx::Rect childRect(0, 0, 300, 100); | 1386 gfx::Rect childRect(0, 0, 300, 100); |
1387 gfx::Rect child2Rect(0, 100, 300, 100); | 1387 gfx::Rect child2Rect(0, 100, 300, 100); |
1388 | 1388 |
1389 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(m
_layerTreeHost->contentsTextureManager())); | 1389 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(m
_layerTreeHost->contentsTextureManager())); |
1390 scoped_refptr<Layer> surface = Layer::create(); | 1390 scoped_refptr<Layer> surface = Layer::create(); |
1391 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(
m_layerTreeHost->contentsTextureManager())); | 1391 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(
m_layerTreeHost->contentsTextureManager())); |
1392 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer
(m_layerTreeHost->contentsTextureManager())); | 1392 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer
(m_layerTreeHost->contentsTextureManager())); |
1393 | 1393 |
1394 root->setBounds(rootRect.size()); | 1394 root->setBounds(rootRect.size()); |
1395 root->setAnchorPoint(gfx::PointF()); | 1395 root->setAnchorPoint(gfx::PointF()); |
1396 root->setDrawableContentRect(rootRect); | 1396 root->drawProperties().drawable_content_rect = rootRect; |
1397 root->setVisibleContentRect(rootRect); | 1397 root->drawProperties().visible_content_rect = rootRect; |
1398 root->addChild(surface); | 1398 root->addChild(surface); |
1399 | 1399 |
1400 surface->setForceRenderSurface(true); | 1400 surface->setForceRenderSurface(true); |
1401 surface->setAnchorPoint(gfx::PointF()); | 1401 surface->setAnchorPoint(gfx::PointF()); |
1402 surface->setOpacity(0.5); | 1402 surface->setOpacity(0.5); |
1403 surface->addChild(child); | 1403 surface->addChild(child); |
1404 surface->addChild(child2); | 1404 surface->addChild(child2); |
1405 | 1405 |
1406 child->setBounds(childRect.size()); | 1406 child->setBounds(childRect.size()); |
1407 child->setAnchorPoint(gfx::PointF()); | 1407 child->setAnchorPoint(gfx::PointF()); |
1408 child->setPosition(childRect.origin()); | 1408 child->setPosition(childRect.origin()); |
1409 child->setVisibleContentRect(childRect); | 1409 child->drawProperties().visible_content_rect = childRect; |
1410 child->setDrawableContentRect(rootRect); | 1410 child->drawProperties().drawable_content_rect = rootRect; |
1411 | 1411 |
1412 child2->setBounds(child2Rect.size()); | 1412 child2->setBounds(child2Rect.size()); |
1413 child2->setAnchorPoint(gfx::PointF()); | 1413 child2->setAnchorPoint(gfx::PointF()); |
1414 child2->setPosition(child2Rect.origin()); | 1414 child2->setPosition(child2Rect.origin()); |
1415 child2->setVisibleContentRect(child2Rect); | 1415 child2->drawProperties().visible_content_rect = child2Rect; |
1416 child2->setDrawableContentRect(rootRect); | 1416 child2->drawProperties().drawable_content_rect = rootRect; |
1417 | 1417 |
1418 m_layerTreeHost->setRootLayer(root); | 1418 m_layerTreeHost->setRootLayer(root); |
1419 m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); | 1419 m_layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); |
1420 | 1420 |
1421 // With a huge memory limit, all layers should update and push their texture
s. | 1421 // With a huge memory limit, all layers should update and push their texture
s. |
1422 root->invalidateContentRect(rootRect); | 1422 root->invalidateContentRect(rootRect); |
1423 child->invalidateContentRect(childRect); | 1423 child->invalidateContentRect(childRect); |
1424 child2->invalidateContentRect(child2Rect); | 1424 child2->invalidateContentRect(child2Rect); |
1425 m_layerTreeHost->updateLayers( | 1425 m_layerTreeHost->updateLayers( |
1426 *m_queue.get(), std::numeric_limits<size_t>::max()); | 1426 *m_queue.get(), std::numeric_limits<size_t>::max()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 { | 1570 { |
1571 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_resourceManager.get())); | 1571 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_resourceManager.get())); |
1572 | 1572 |
1573 gfx::Rect layerRect(0, 0, 30, 31); | 1573 gfx::Rect layerRect(0, 0, 30, 31); |
1574 layer->setPosition(layerRect.origin()); | 1574 layer->setPosition(layerRect.origin()); |
1575 layer->setBounds(layerRect.size()); | 1575 layer->setBounds(layerRect.size()); |
1576 layer->setContentsScale(1.5); | 1576 layer->setContentsScale(1.5); |
1577 | 1577 |
1578 gfx::Rect contentRect(0, 0, 45, 47); | 1578 gfx::Rect contentRect(0, 0, 45, 47); |
1579 EXPECT_EQ(contentRect.size(), layer->contentBounds()); | 1579 EXPECT_EQ(contentRect.size(), layer->contentBounds()); |
1580 layer->setVisibleContentRect(contentRect); | 1580 layer->drawProperties().visible_content_rect = contentRect; |
1581 layer->setDrawableContentRect(contentRect); | 1581 layer->drawProperties().drawable_content_rect = contentRect; |
1582 | 1582 |
1583 layer->setTexturePriorities(m_priorityCalculator); | 1583 layer->setTexturePriorities(m_priorityCalculator); |
1584 m_resourceManager->prioritizeTextures(); | 1584 m_resourceManager->prioritizeTextures(); |
1585 | 1585 |
1586 // Update the whole tile. | 1586 // Update the whole tile. |
1587 layer->update(*m_queue.get(), 0, m_stats); | 1587 layer->update(*m_queue.get(), 0, m_stats); |
1588 layer->trackingLayerPainter()->resetPaintedRect(); | 1588 layer->trackingLayerPainter()->resetPaintedRect(); |
1589 | 1589 |
1590 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); | 1590 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1591 updateTextures(); | 1591 updateTextures(); |
1592 | 1592 |
1593 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. | 1593 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. |
1594 layer->invalidateContentRect(contentRect); | 1594 layer->invalidateContentRect(contentRect); |
1595 layer->update(*m_queue.get(), 0, m_stats); | 1595 layer->update(*m_queue.get(), 0, m_stats); |
1596 | 1596 |
1597 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1597 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1598 } | 1598 } |
1599 | 1599 |
1600 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) | 1600 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) |
1601 { | 1601 { |
1602 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_resourceManager.get())); | 1602 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_resourceManager.get())); |
1603 | 1603 |
1604 gfx::Rect layerRect(0, 0, 30, 31); | 1604 gfx::Rect layerRect(0, 0, 30, 31); |
1605 layer->setPosition(layerRect.origin()); | 1605 layer->setPosition(layerRect.origin()); |
1606 layer->setBounds(layerRect.size()); | 1606 layer->setBounds(layerRect.size()); |
1607 layer->setContentsScale(1.3f); | 1607 layer->setContentsScale(1.3f); |
1608 | 1608 |
1609 gfx::Rect contentRect(gfx::Point(), layer->contentBounds()); | 1609 gfx::Rect contentRect(gfx::Point(), layer->contentBounds()); |
1610 layer->setVisibleContentRect(contentRect); | 1610 layer->drawProperties().visible_content_rect = contentRect; |
1611 layer->setDrawableContentRect(contentRect); | 1611 layer->drawProperties().drawable_content_rect = contentRect; |
1612 | 1612 |
1613 layer->setTexturePriorities(m_priorityCalculator); | 1613 layer->setTexturePriorities(m_priorityCalculator); |
1614 m_resourceManager->prioritizeTextures(); | 1614 m_resourceManager->prioritizeTextures(); |
1615 | 1615 |
1616 // Update the whole tile. | 1616 // Update the whole tile. |
1617 layer->update(*m_queue.get(), 0, m_stats); | 1617 layer->update(*m_queue.get(), 0, m_stats); |
1618 layer->trackingLayerPainter()->resetPaintedRect(); | 1618 layer->trackingLayerPainter()->resetPaintedRect(); |
1619 | 1619 |
1620 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); | 1620 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1621 updateTextures(); | 1621 updateTextures(); |
1622 | 1622 |
1623 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1623 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
1624 layer->setNeedsDisplayRect(layerRect); | 1624 layer->setNeedsDisplayRect(layerRect); |
1625 layer->update(*m_queue.get(), 0, m_stats); | 1625 layer->update(*m_queue.get(), 0, m_stats); |
1626 | 1626 |
1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1628 } | 1628 } |
1629 | 1629 |
1630 } // namespace | 1630 } // namespace |
1631 } // namespace cc | 1631 } // namespace cc |
OLD | NEW |