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