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