| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 { | 92 { |
| 93 } | 93 } |
| 94 | 94 |
| 95 scoped_ptr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl() | 95 scoped_ptr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl() |
| 96 { | 96 { |
| 97 return CCTiledLayerImpl::create(id()).PassAs<CCLayerImpl>(); | 97 return CCTiledLayerImpl::create(id()).PassAs<CCLayerImpl>(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void TiledLayerChromium::updateTileSizeAndTilingOption() | 100 void TiledLayerChromium::updateTileSizeAndTilingOption() |
| 101 { | 101 { |
| 102 ASSERT(layerTreeHost()); | 102 CC_DCHECK(layerTreeHost()); |
| 103 | 103 |
| 104 const IntSize& defaultTileSize = layerTreeHost()->settings().defaultTileSize
; | 104 const IntSize& defaultTileSize = layerTreeHost()->settings().defaultTileSize
; |
| 105 const IntSize& maxUntiledLayerSize = layerTreeHost()->settings().maxUntiledL
ayerSize; | 105 const IntSize& maxUntiledLayerSize = layerTreeHost()->settings().maxUntiledL
ayerSize; |
| 106 int layerWidth = contentBounds().width(); | 106 int layerWidth = contentBounds().width(); |
| 107 int layerHeight = contentBounds().height(); | 107 int layerHeight = contentBounds().height(); |
| 108 | 108 |
| 109 const IntSize tileSize(min(defaultTileSize.width(), layerWidth), min(default
TileSize.height(), layerHeight)); | 109 const IntSize tileSize(min(defaultTileSize.width(), layerWidth), min(default
TileSize.height(), layerHeight)); |
| 110 | 110 |
| 111 // Tile if both dimensions large, or any one dimension large and the other | 111 // Tile if both dimensions large, or any one dimension large and the other |
| 112 // extends into a second tile but the total layer area isn't larger than tha
t | 112 // extends into a second tile but the total layer area isn't larger than tha
t |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 updateBounds(); | 318 updateBounds(); |
| 319 if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw) | 319 if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw) |
| 320 return; | 320 return; |
| 321 | 321 |
| 322 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { | 322 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { |
| 323 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 323 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 324 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); | 324 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); |
| 325 #else | 325 #else |
| 326 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); | 326 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); |
| 327 #endif | 327 #endif |
| 328 ASSERT(tile); | 328 CC_DCHECK(tile); |
| 329 // FIXME: This should not ever be null. | 329 // FIXME: This should not ever be null. |
| 330 if (!tile) | 330 if (!tile) |
| 331 continue; | 331 continue; |
| 332 IntRect bound = m_tiler->tileRect(tile); | 332 IntRect bound = m_tiler->tileRect(tile); |
| 333 bound.intersect(contentRect); | 333 bound.intersect(contentRect); |
| 334 tile->dirtyRect.unite(bound); | 334 tile->dirtyRect.unite(bound); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 // Returns true if tile is dirty and only part of it needs to be updated. | 338 // 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... |
| 388 // and requesting memory so those are encapsulated in this function: | 388 // and requesting memory so those are encapsulated in this function: |
| 389 // - We only want to call requestLate on unoccluded textures (to preserve | 389 // - We only want to call requestLate on unoccluded textures (to preserve |
| 390 // memory for other layers when near OOM). | 390 // memory for other layers when near OOM). |
| 391 // - We only want to record occlusion metrics if all memory requests succeed
. | 391 // - We only want to record occlusion metrics if all memory requests succeed
. |
| 392 | 392 |
| 393 int occludedTileCount = 0; | 393 int occludedTileCount = 0; |
| 394 bool succeeded = true; | 394 bool succeeded = true; |
| 395 for (int j = top; j <= bottom; ++j) { | 395 for (int j = top; j <= bottom; ++j) { |
| 396 for (int i = left; i <= right; ++i) { | 396 for (int i = left; i <= right; ++i) { |
| 397 UpdatableTile* tile = tileAt(i, j); | 397 UpdatableTile* tile = tileAt(i, j); |
| 398 ASSERT(tile); // Did setTexturePriorities get skipped? | 398 CC_DCHECK(tile); // Did setTexturePriorities get skipped? |
| 399 // FIXME: This should not ever be null. | 399 // FIXME: This should not ever be null. |
| 400 if (!tile) | 400 if (!tile) |
| 401 continue; | 401 continue; |
| 402 ASSERT(!tile->occluded); // Did resetUpdateState get skipped? Are we
doing more than one occlusion pass? | 402 CC_DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are
we doing more than one occlusion pass? |
| 403 IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), vi
sibleContentRect()); | 403 IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), vi
sibleContentRect()); |
| 404 if (occlusion && occlusion->occluded(this, visibleTileRect)) { | 404 if (occlusion && occlusion->occluded(this, visibleTileRect)) { |
| 405 tile->occluded = true; | 405 tile->occluded = true; |
| 406 occludedTileCount++; | 406 occludedTileCount++; |
| 407 } else { | 407 } else { |
| 408 succeeded &= tile->managedTexture()->requestLate(); | 408 succeeded &= tile->managedTexture()->requestLate(); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 if (!succeeded) | 413 if (!succeeded) |
| 414 return; | 414 return; |
| 415 | 415 |
| 416 // FIXME: Remove the loop and just pass the count! | 416 // FIXME: Remove the loop and just pass the count! |
| 417 for (int i = 0; i < occludedTileCount; i++) | 417 for (int i = 0; i < occludedTileCount; i++) |
| 418 occlusion->overdrawMetrics().didCullTileForUpload(); | 418 occlusion->overdrawMetrics().didCullTileForUpload(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int
bottom, bool ignoreOcclusions) | 421 bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int
bottom, bool ignoreOcclusions) |
| 422 { | 422 { |
| 423 for (int j = top; j <= bottom; ++j) { | 423 for (int j = top; j <= bottom; ++j) { |
| 424 for (int i = left; i <= right; ++i) { | 424 for (int i = left; i <= right; ++i) { |
| 425 UpdatableTile* tile = tileAt(i, j); | 425 UpdatableTile* tile = tileAt(i, j); |
| 426 ASSERT(tile); // Did setTexturePriorites get skipped? | 426 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
| 427 // FIXME: This should not ever be null. | 427 // FIXME: This should not ever be null. |
| 428 if (!tile) | 428 if (!tile) |
| 429 continue; | 429 continue; |
| 430 | 430 |
| 431 // Ensure the entire tile is dirty if we don't have the texture. | 431 // Ensure the entire tile is dirty if we don't have the texture. |
| 432 if (!tile->managedTexture()->haveBackingTexture()) | 432 if (!tile->managedTexture()->haveBackingTexture()) |
| 433 tile->dirtyRect = m_tiler->tileRect(tile); | 433 tile->dirtyRect = m_tiler->tileRect(tile); |
| 434 | 434 |
| 435 // If using occlusion and the visible region of the tile is occluded
, | 435 // If using occlusion and the visible region of the tile is occluded
, |
| 436 // don't reserve a texture or update the tile. | 436 // don't reserve a texture or update the tile. |
| 437 if (tile->occluded && !ignoreOcclusions) | 437 if (tile->occluded && !ignoreOcclusions) |
| 438 continue; | 438 continue; |
| 439 | 439 |
| 440 if (!tile->managedTexture()->canAcquireBackingTexture()) | 440 if (!tile->managedTexture()->canAcquireBackingTexture()) |
| 441 return false; | 441 return false; |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 return true; | 444 return true; |
| 445 } | 445 } |
| 446 | 446 |
| 447 IntRect TiledLayerChromium::markTilesForUpdate(int left, int top, int right, int
bottom, bool ignoreOcclusions) | 447 IntRect TiledLayerChromium::markTilesForUpdate(int left, int top, int right, int
bottom, bool ignoreOcclusions) |
| 448 { | 448 { |
| 449 IntRect paintRect; | 449 IntRect paintRect; |
| 450 for (int j = top; j <= bottom; ++j) { | 450 for (int j = top; j <= bottom; ++j) { |
| 451 for (int i = left; i <= right; ++i) { | 451 for (int i = left; i <= right; ++i) { |
| 452 UpdatableTile* tile = tileAt(i, j); | 452 UpdatableTile* tile = tileAt(i, j); |
| 453 ASSERT(tile); // Did setTexturePriorites get skipped? | 453 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
| 454 // FIXME: This should not ever be null. | 454 // FIXME: This should not ever be null. |
| 455 if (!tile) | 455 if (!tile) |
| 456 continue; | 456 continue; |
| 457 if (tile->occluded && !ignoreOcclusions) | 457 if (tile->occluded && !ignoreOcclusions) |
| 458 continue; | 458 continue; |
| 459 paintRect.unite(tile->dirtyRect); | 459 paintRect.unite(tile->dirtyRect); |
| 460 tile->markForUpdate(); | 460 tile->markForUpdate(); |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 return paintRect; | 463 return paintRect; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 475 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. | 475 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. |
| 476 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, | 476 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, |
| 477 // so we grab a local reference here to hold the updater alive until the pai
nt completes. | 477 // so we grab a local reference here to hold the updater alive until the pai
nt completes. |
| 478 RefPtr<LayerTextureUpdater> protector(textureUpdater()); | 478 RefPtr<LayerTextureUpdater> protector(textureUpdater()); |
| 479 IntRect paintedOpaqueRect; | 479 IntRect paintedOpaqueRect; |
| 480 textureUpdater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthS
cale, 1 / heightScale, paintedOpaqueRect, stats); | 480 textureUpdater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthS
cale, 1 / heightScale, paintedOpaqueRect, stats); |
| 481 | 481 |
| 482 for (int j = top; j <= bottom; ++j) { | 482 for (int j = top; j <= bottom; ++j) { |
| 483 for (int i = left; i <= right; ++i) { | 483 for (int i = left; i <= right; ++i) { |
| 484 UpdatableTile* tile = tileAt(i, j); | 484 UpdatableTile* tile = tileAt(i, j); |
| 485 ASSERT(tile); // Did setTexturePriorites get skipped? | 485 CC_DCHECK(tile); // Did setTexturePriorites get skipped? |
| 486 // FIXME: This should not ever be null. | 486 // FIXME: This should not ever be null. |
| 487 if (!tile) | 487 if (!tile) |
| 488 continue; | 488 continue; |
| 489 | 489 |
| 490 IntRect tileRect = m_tiler->tileBounds(i, j); | 490 IntRect tileRect = m_tiler->tileBounds(i, j); |
| 491 | 491 |
| 492 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. | 492 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. |
| 493 const IntRect& dirtyRect = tile->updateRect; | 493 const IntRect& dirtyRect = tile->updateRect; |
| 494 if (dirtyRect.isEmpty()) | 494 if (dirtyRect.isEmpty()) |
| 495 continue; | 495 continue; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 #endif | 684 #endif |
| 685 // FIXME: This should not ever be null. | 685 // FIXME: This should not ever be null. |
| 686 if (!tile) | 686 if (!tile) |
| 687 continue; | 687 continue; |
| 688 tile->resetUpdateState(); | 688 tile->resetUpdateState(); |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 | 691 |
| 692 void TiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTr
acker* occlusion, CCRenderingStats& stats) | 692 void TiledLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTr
acker* occlusion, CCRenderingStats& stats) |
| 693 { | 693 { |
| 694 ASSERT(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped
? | 694 CC_DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skip
ped? |
| 695 updateBounds(); | 695 updateBounds(); |
| 696 if (m_tiler->hasEmptyBounds() || !drawsContent()) | 696 if (m_tiler->hasEmptyBounds() || !drawsContent()) |
| 697 return; | 697 return; |
| 698 | 698 |
| 699 bool didPaint = false; | 699 bool didPaint = false; |
| 700 | 700 |
| 701 // Animation pre-paint. If the layer is small, try to paint it all | 701 // Animation pre-paint. If the layer is small, try to paint it all |
| 702 // immediately whether or not it is occluded, to avoid paint/upload | 702 // immediately whether or not it is occluded, to avoid paint/upload |
| 703 // hiccups while it is animating. | 703 // hiccups while it is animating. |
| 704 if (isSmallAnimatedLayer(this)) { | 704 if (isSmallAnimatedLayer(this)) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 IntRect idlePaintContentRect = idlePaintRect(); | 771 IntRect idlePaintContentRect = idlePaintRect(); |
| 772 if (idlePaintContentRect.isEmpty()) | 772 if (idlePaintContentRect.isEmpty()) |
| 773 return false; | 773 return false; |
| 774 | 774 |
| 775 int left, top, right, bottom; | 775 int left, top, right, bottom; |
| 776 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); | 776 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); |
| 777 | 777 |
| 778 for (int j = top; j <= bottom; ++j) { | 778 for (int j = top; j <= bottom; ++j) { |
| 779 for (int i = left; i <= right; ++i) { | 779 for (int i = left; i <= right; ++i) { |
| 780 UpdatableTile* tile = tileAt(i, j); | 780 UpdatableTile* tile = tileAt(i, j); |
| 781 ASSERT(tile); // Did setTexturePriorities get skipped? | 781 CC_DCHECK(tile); // Did setTexturePriorities get skipped? |
| 782 if (!tile) | 782 if (!tile) |
| 783 continue; | 783 continue; |
| 784 | 784 |
| 785 bool updated = !tile->updateRect.isEmpty(); | 785 bool updated = !tile->updateRect.isEmpty(); |
| 786 bool canAcquire = tile->managedTexture()->canAcquireBackingTexture()
; | 786 bool canAcquire = tile->managedTexture()->canAcquireBackingTexture()
; |
| 787 bool dirty = tile->isDirty() || !tile->managedTexture()->haveBacking
Texture(); | 787 bool dirty = tile->isDirty() || !tile->managedTexture()->haveBacking
Texture(); |
| 788 if (!updated && canAcquire && dirty) | 788 if (!updated && canAcquire && dirty) |
| 789 return true; | 789 return true; |
| 790 } | 790 } |
| 791 } | 791 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 803 IntRect prepaintRect = visibleContentRect(); | 803 IntRect prepaintRect = visibleContentRect(); |
| 804 prepaintRect.inflateX(m_tiler->tileSize().width()); | 804 prepaintRect.inflateX(m_tiler->tileSize().width()); |
| 805 prepaintRect.inflateY(m_tiler->tileSize().height() * 2); | 805 prepaintRect.inflateY(m_tiler->tileSize().height() * 2); |
| 806 IntRect contentRect(IntPoint::zero(), contentBounds()); | 806 IntRect contentRect(IntPoint::zero(), contentBounds()); |
| 807 prepaintRect.intersect(contentRect); | 807 prepaintRect.intersect(contentRect); |
| 808 | 808 |
| 809 return prepaintRect; | 809 return prepaintRect; |
| 810 } | 810 } |
| 811 | 811 |
| 812 } | 812 } |
| OLD | NEW |