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 "Region.h" | 9 #include "Region.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 tile->dirtyRect.unite(bound); | 321 tile->dirtyRect.unite(bound); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 // Returns true if tile is dirty and only part of it needs to be updated. | 325 // Returns true if tile is dirty and only part of it needs to be updated. |
326 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) | 326 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) |
327 { | 327 { |
328 return !tile->dirtyRect.contains(m_tiler->tileRect(tile)) && tile->managedTe
xture()->haveBackingTexture(); | 328 return !tile->dirtyRect.contains(m_tiler->tileRect(tile)) && tile->managedTe
xture()->haveBackingTexture(); |
329 } | 329 } |
330 | 330 |
331 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, TextureUp
dateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, bool
& didPaint) | 331 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceU
pdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, boo
l& didPaint) |
332 { | 332 { |
333 didPaint = false; | 333 didPaint = false; |
334 createUpdaterIfNeeded(); | 334 createUpdaterIfNeeded(); |
335 | 335 |
336 bool ignoreOcclusions = !occlusion; | 336 bool ignoreOcclusions = !occlusion; |
337 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { | 337 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { |
338 m_failedUpdate = true; | 338 m_failedUpdate = true; |
339 return false; | 339 return false; |
340 } | 340 } |
341 | 341 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
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; |
447 } | 447 } |
448 | 448 |
449 void TiledLayer::updateTileTextures(const IntRect& paintRect, int left, int top,
int right, int bottom, TextureUpdateQueue& queue, const OcclusionTracker* occlu
sion, RenderingStats& stats) | 449 void TiledLayer::updateTileTextures(const IntRect& paintRect, int left, int top,
int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occl
usion, RenderingStats& stats) |
450 { | 450 { |
451 // The updateRect should be in layer space. So we have to convert the paintR
ect from content space to layer space. | 451 // The updateRect should be in layer space. So we have to convert the paintR
ect from content space to layer space. |
452 m_updateRect = FloatRect(paintRect); | 452 m_updateRect = FloatRect(paintRect); |
453 float widthScale = bounds().width() / static_cast<float>(contentBounds().wid
th()); | 453 float widthScale = bounds().width() / static_cast<float>(contentBounds().wid
th()); |
454 float heightScale = bounds().height() / static_cast<float>(contentBounds().h
eight()); | 454 float heightScale = bounds().height() / static_cast<float>(contentBounds().h
eight()); |
455 m_updateRect.scale(widthScale, heightScale); | 455 m_updateRect.scale(widthScale, heightScale); |
456 | 456 |
457 // Calling prepareToUpdate() calls into WebKit to paint, which may have the
side | 457 // Calling prepareToUpdate() calls into WebKit to paint, which may have the
side |
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, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 IntRect bound = visibleContentRect(); | 658 IntRect bound = visibleContentRect(); |
659 bound.inflateX(m_tiler->tileSize().width() * maxPredictiveTilesCount); | 659 bound.inflateX(m_tiler->tileSize().width() * maxPredictiveTilesCount); |
660 bound.inflateY(m_tiler->tileSize().height() * maxPredictiveTilesCount); | 660 bound.inflateY(m_tiler->tileSize().height() * maxPredictiveTilesCount); |
661 bound.intersect(IntRect(IntPoint::zero(), contentBounds())); | 661 bound.intersect(IntRect(IntPoint::zero(), contentBounds())); |
662 m_predictedVisibleRect.intersect(bound); | 662 m_predictedVisibleRect.intersect(bound); |
663 } | 663 } |
664 m_previousContentBounds = contentBounds(); | 664 m_previousContentBounds = contentBounds(); |
665 m_previousVisibleRect = visibleContentRect(); | 665 m_previousVisibleRect = visibleContentRect(); |
666 } | 666 } |
667 | 667 |
668 void TiledLayer::update(TextureUpdateQueue& queue, const OcclusionTracker* occlu
sion, RenderingStats& stats) | 668 void TiledLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occl
usion, RenderingStats& stats) |
669 { | 669 { |
670 DCHECK(!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 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 IntRect prepaintRect = visibleContentRect(); | 792 IntRect prepaintRect = visibleContentRect(); |
793 prepaintRect.inflateX(m_tiler->tileSize().width() * prepaintColumns); | 793 prepaintRect.inflateX(m_tiler->tileSize().width() * prepaintColumns); |
794 prepaintRect.inflateY(m_tiler->tileSize().height() * prepaintRows); | 794 prepaintRect.inflateY(m_tiler->tileSize().height() * prepaintRows); |
795 IntRect contentRect(IntPoint::zero(), contentBounds()); | 795 IntRect contentRect(IntPoint::zero(), contentBounds()); |
796 prepaintRect.intersect(contentRect); | 796 prepaintRect.intersect(contentRect); |
797 | 797 |
798 return prepaintRect; | 798 return prepaintRect; |
799 } | 799 } |
800 | 800 |
801 } | 801 } |
OLD | NEW |