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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "TiledLayerChromium.h" | 7 #include "TiledLayerChromium.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 { | 89 { |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl() | 92 scoped_ptr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl() |
93 { | 93 { |
94 return CCTiledLayerImpl::create(id()).PassAs<CCLayerImpl>(); | 94 return CCTiledLayerImpl::create(id()).PassAs<CCLayerImpl>(); |
95 } | 95 } |
96 | 96 |
97 void TiledLayerChromium::updateTileSizeAndTilingOption() | 97 void TiledLayerChromium::updateTileSizeAndTilingOption() |
98 { | 98 { |
99 ASSERT(layerTreeHost()); | 99 CC_DCHECK(layerTreeHost()); |
100 | 100 |
101 const IntSize& defaultTileSize = layerTreeHost()->settings().defaultTileSize
; | 101 const IntSize& defaultTileSize = layerTreeHost()->settings().defaultTileSize
; |
102 const IntSize& maxUntiledLayerSize = layerTreeHost()->settings().maxUntiledL
ayerSize; | 102 const IntSize& maxUntiledLayerSize = layerTreeHost()->settings().maxUntiledL
ayerSize; |
103 int layerWidth = contentBounds().width(); | 103 int layerWidth = contentBounds().width(); |
104 int layerHeight = contentBounds().height(); | 104 int layerHeight = contentBounds().height(); |
105 | 105 |
106 const IntSize tileSize(min(defaultTileSize.width(), layerWidth), min(default
TileSize.height(), layerHeight)); | 106 const IntSize tileSize(min(defaultTileSize.width(), layerWidth), min(default
TileSize.height(), layerHeight)); |
107 | 107 |
108 // Tile if both dimensions large, or any one dimension large and the other | 108 // Tile if both dimensions large, or any one dimension large and the other |
109 // extends into a second tile but the total layer area isn't larger than tha
t | 109 // extends into a second tile but the total layer area isn't larger than tha
t |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 void TiledLayerChromium::invalidateContentRect(const IntRect& contentRect) | 303 void TiledLayerChromium::invalidateContentRect(const IntRect& contentRect) |
304 { | 304 { |
305 updateBounds(); | 305 updateBounds(); |
306 if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw) | 306 if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw) |
307 return; | 307 return; |
308 | 308 |
309 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { | 309 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { |
310 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 310 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
311 ASSERT(tile); | 311 CC_DCHECK(tile); |
312 // FIXME: This should not ever be null. | 312 // FIXME: This should not ever be null. |
313 if (!tile) | 313 if (!tile) |
314 continue; | 314 continue; |
315 IntRect bound = m_tiler->tileRect(tile); | 315 IntRect bound = m_tiler->tileRect(tile); |
316 bound.intersect(contentRect); | 316 bound.intersect(contentRect); |
317 tile->dirtyRect.unite(bound); | 317 tile->dirtyRect.unite(bound); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 // Returns true if tile is dirty and only part of it needs to be updated. | 321 // Returns true if tile is dirty and only part of it needs to be updated. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // and requesting memory so those are encapsulated in this function: | 371 // and requesting memory so those are encapsulated in this function: |
372 // - We only want to call requestLate on unoccluded textures (to preserve | 372 // - We only want to call requestLate on unoccluded textures (to preserve |
373 // memory for other layers when near OOM). | 373 // memory for other layers when near OOM). |
374 // - We only want to record occlusion metrics if all memory requests succeed
. | 374 // - We only want to record occlusion metrics if all memory requests succeed
. |
375 | 375 |
376 int occludedTileCount = 0; | 376 int occludedTileCount = 0; |
377 bool succeeded = true; | 377 bool succeeded = true; |
378 for (int j = top; j <= bottom; ++j) { | 378 for (int j = top; j <= bottom; ++j) { |
379 for (int i = left; i <= right; ++i) { | 379 for (int i = left; i <= right; ++i) { |
380 UpdatableTile* tile = tileAt(i, j); | 380 UpdatableTile* tile = tileAt(i, j); |
381 ASSERT(tile); // Did setTexturePriorities get skipped? | 381 CC_DCHECK(tile); // Did setTexturePriorities get skipped? |
382 // FIXME: This should not ever be null. | 382 // FIXME: This should not ever be null. |
383 if (!tile) | 383 if (!tile) |
384 continue; | 384 continue; |
385 ASSERT(!tile->occluded); // Did resetUpdateState get skipped? Are we
doing more than one occlusion pass? | 385 CC_DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are
we doing more than one occlusion pass? |
386 IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), vi
sibleContentRect()); | 386 IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), vi
sibleContentRect()); |
387 if (occlusion && occlusion->occluded(this, visibleTileRect)) { | 387 if (occlusion && occlusion->occluded(this, visibleTileRect)) { |
388 tile->occluded = true; | 388 tile->occluded = true; |
389 occludedTileCount++; | 389 occludedTileCount++; |
390 } else { | 390 } else { |
391 succeeded &= tile->managedTexture()->requestLate(); | 391 succeeded &= tile->managedTexture()->requestLate(); |
392 } | 392 } |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 if (!succeeded) | 396 if (!succeeded) |
397 return; | 397 return; |
398 | 398 |
399 // FIXME: Remove the loop and just pass the count! | 399 // FIXME: Remove the loop and just pass the count! |
400 for (int i = 0; i < occludedTileCount; i++) | 400 for (int i = 0; i < occludedTileCount; i++) |
401 occlusion->overdrawMetrics().didCullTileForUpload(); | 401 occlusion->overdrawMetrics().didCullTileForUpload(); |
402 } | 402 } |
403 | 403 |
404 bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int
bottom, bool ignoreOcclusions) | 404 bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int
bottom, bool ignoreOcclusions) |
405 { | 405 { |
406 for (int j = top; j <= bottom; ++j) { | 406 for (int j = top; j <= bottom; ++j) { |
407 for (int i = left; i <= right; ++i) { | 407 for (int i = left; i <= right; ++i) { |
408 UpdatableTile* tile = tileAt(i, j); | 408 UpdatableTile* tile = tileAt(i, j); |
409 ASSERT(tile); // Did setTexturePriorites get skipped? | 409 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
410 // FIXME: This should not ever be null. | 410 // FIXME: This should not ever be null. |
411 if (!tile) | 411 if (!tile) |
412 continue; | 412 continue; |
413 | 413 |
414 // Ensure the entire tile is dirty if we don't have the texture. | 414 // Ensure the entire tile is dirty if we don't have the texture. |
415 if (!tile->managedTexture()->haveBackingTexture()) | 415 if (!tile->managedTexture()->haveBackingTexture()) |
416 tile->dirtyRect = m_tiler->tileRect(tile); | 416 tile->dirtyRect = m_tiler->tileRect(tile); |
417 | 417 |
418 // If using occlusion and the visible region of the tile is occluded
, | 418 // If using occlusion and the visible region of the tile is occluded
, |
419 // don't reserve a texture or update the tile. | 419 // don't reserve a texture or update the tile. |
420 if (tile->occluded && !ignoreOcclusions) | 420 if (tile->occluded && !ignoreOcclusions) |
421 continue; | 421 continue; |
422 | 422 |
423 if (!tile->managedTexture()->canAcquireBackingTexture()) | 423 if (!tile->managedTexture()->canAcquireBackingTexture()) |
424 return false; | 424 return false; |
425 } | 425 } |
426 } | 426 } |
427 return true; | 427 return true; |
428 } | 428 } |
429 | 429 |
430 IntRect TiledLayerChromium::markTilesForUpdate(int left, int top, int right, int
bottom, bool ignoreOcclusions) | 430 IntRect TiledLayerChromium::markTilesForUpdate(int left, int top, int right, int
bottom, bool ignoreOcclusions) |
431 { | 431 { |
432 IntRect paintRect; | 432 IntRect paintRect; |
433 for (int j = top; j <= bottom; ++j) { | 433 for (int j = top; j <= bottom; ++j) { |
434 for (int i = left; i <= right; ++i) { | 434 for (int i = left; i <= right; ++i) { |
435 UpdatableTile* tile = tileAt(i, j); | 435 UpdatableTile* tile = tileAt(i, j); |
436 ASSERT(tile); // Did setTexturePriorites get skipped? | 436 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
437 // FIXME: This should not ever be null. | 437 // FIXME: This should not ever be null. |
438 if (!tile) | 438 if (!tile) |
439 continue; | 439 continue; |
440 if (tile->occluded && !ignoreOcclusions) | 440 if (tile->occluded && !ignoreOcclusions) |
441 continue; | 441 continue; |
442 paintRect.unite(tile->dirtyRect); | 442 paintRect.unite(tile->dirtyRect); |
443 tile->markForUpdate(); | 443 tile->markForUpdate(); |
444 } | 444 } |
445 } | 445 } |
446 return paintRect; | 446 return paintRect; |
(...skipping 11 matching lines...) Expand all Loading... |
458 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. | 458 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. |
459 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, | 459 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, |
460 // so we grab a local reference here to hold the updater alive until the pai
nt completes. | 460 // so we grab a local reference here to hold the updater alive until the pai
nt completes. |
461 RefPtr<LayerTextureUpdater> protector(textureUpdater()); | 461 RefPtr<LayerTextureUpdater> protector(textureUpdater()); |
462 IntRect paintedOpaqueRect; | 462 IntRect paintedOpaqueRect; |
463 textureUpdater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthS
cale, 1 / heightScale, paintedOpaqueRect, stats); | 463 textureUpdater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthS
cale, 1 / heightScale, paintedOpaqueRect, stats); |
464 | 464 |
465 for (int j = top; j <= bottom; ++j) { | 465 for (int j = top; j <= bottom; ++j) { |
466 for (int i = left; i <= right; ++i) { | 466 for (int i = left; i <= right; ++i) { |
467 UpdatableTile* tile = tileAt(i, j); | 467 UpdatableTile* tile = tileAt(i, j); |
468 ASSERT(tile); // Did setTexturePriorites get skipped? | 468 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
469 // FIXME: This should not ever be null. | 469 // FIXME: This should not ever be null. |
470 if (!tile) | 470 if (!tile) |
471 continue; | 471 continue; |
472 | 472 |
473 IntRect tileRect = m_tiler->tileBounds(i, j); | 473 IntRect tileRect = m_tiler->tileBounds(i, j); |
474 | 474 |
475 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. | 475 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. |
476 const IntRect& dirtyRect = tile->updateRect; | 476 const IntRect& dirtyRect = tile->updateRect; |
477 if (dirtyRect.isEmpty()) | 477 if (dirtyRect.isEmpty()) |
478 continue; | 478 continue; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 659 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
660 // FIXME: This should not ever be null. | 660 // FIXME: This should not ever be null. |
661 if (!tile) | 661 if (!tile) |
662 continue; | 662 continue; |
663 tile->resetUpdateState(); | 663 tile->resetUpdateState(); |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 void TiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTr
acker* occlusion, CCRenderingStats& stats) | 667 void TiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTr
acker* occlusion, CCRenderingStats& stats) |
668 { | 668 { |
669 ASSERT(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped
? | 669 CC_DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skip
ped? |
670 updateBounds(); | 670 updateBounds(); |
671 if (m_tiler->hasEmptyBounds() || !drawsContent()) | 671 if (m_tiler->hasEmptyBounds() || !drawsContent()) |
672 return; | 672 return; |
673 | 673 |
674 bool didPaint = false; | 674 bool didPaint = false; |
675 | 675 |
676 // Animation pre-paint. If the layer is small, try to paint it all | 676 // Animation pre-paint. If the layer is small, try to paint it all |
677 // immediately whether or not it is occluded, to avoid paint/upload | 677 // immediately whether or not it is occluded, to avoid paint/upload |
678 // hiccups while it is animating. | 678 // hiccups while it is animating. |
679 if (isSmallAnimatedLayer(this)) { | 679 if (isSmallAnimatedLayer(this)) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 IntRect idlePaintContentRect = idlePaintRect(); | 746 IntRect idlePaintContentRect = idlePaintRect(); |
747 if (idlePaintContentRect.isEmpty()) | 747 if (idlePaintContentRect.isEmpty()) |
748 return false; | 748 return false; |
749 | 749 |
750 int left, top, right, bottom; | 750 int left, top, right, bottom; |
751 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); | 751 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); |
752 | 752 |
753 for (int j = top; j <= bottom; ++j) { | 753 for (int j = top; j <= bottom; ++j) { |
754 for (int i = left; i <= right; ++i) { | 754 for (int i = left; i <= right; ++i) { |
755 UpdatableTile* tile = tileAt(i, j); | 755 UpdatableTile* tile = tileAt(i, j); |
756 ASSERT(tile); // Did setTexturePriorities get skipped? | 756 CC_DCHECK(tile); // Did setTexturePriorities get skipped? |
757 if (!tile) | 757 if (!tile) |
758 continue; | 758 continue; |
759 | 759 |
760 bool updated = !tile->updateRect.isEmpty(); | 760 bool updated = !tile->updateRect.isEmpty(); |
761 bool canAcquire = tile->managedTexture()->canAcquireBackingTexture()
; | 761 bool canAcquire = tile->managedTexture()->canAcquireBackingTexture()
; |
762 bool dirty = tile->isDirty() || !tile->managedTexture()->haveBacking
Texture(); | 762 bool dirty = tile->isDirty() || !tile->managedTexture()->haveBacking
Texture(); |
763 if (!updated && canAcquire && dirty) | 763 if (!updated && canAcquire && dirty) |
764 return true; | 764 return true; |
765 } | 765 } |
766 } | 766 } |
(...skipping 11 matching lines...) Expand all Loading... |
778 IntRect prepaintRect = visibleContentRect(); | 778 IntRect prepaintRect = visibleContentRect(); |
779 prepaintRect.inflateX(m_tiler->tileSize().width()); | 779 prepaintRect.inflateX(m_tiler->tileSize().width()); |
780 prepaintRect.inflateY(m_tiler->tileSize().height() * 2); | 780 prepaintRect.inflateY(m_tiler->tileSize().height() * 2); |
781 IntRect contentRect(IntPoint::zero(), contentBounds()); | 781 IntRect contentRect(IntPoint::zero(), contentBounds()); |
782 prepaintRect.intersect(contentRect); | 782 prepaintRect.intersect(contentRect); |
783 | 783 |
784 return prepaintRect; | 784 return prepaintRect; |
785 } | 785 } |
786 | 786 |
787 } | 787 } |
OLD | NEW |