| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 void TiledLayer::updateBounds() | 142 void TiledLayer::updateBounds() |
| 143 { | 143 { |
| 144 gfx::Size oldBounds = m_tiler->bounds(); | 144 gfx::Size oldBounds = m_tiler->bounds(); |
| 145 gfx::Size newBounds = contentBounds(); | 145 gfx::Size newBounds = contentBounds(); |
| 146 if (oldBounds == newBounds) | 146 if (oldBounds == newBounds) |
| 147 return; | 147 return; |
| 148 m_tiler->setBounds(newBounds); | 148 m_tiler->setBounds(newBounds); |
| 149 | 149 |
| 150 // Invalidate any areas that the new bounds exposes. | 150 // Invalidate any areas that the new bounds exposes. |
| 151 Region oldRegion = IntRect(IntPoint(), cc::IntSize(oldBounds)); | 151 Region oldRegion = gfx::Rect(gfx::Point(), oldBounds); |
| 152 Region newRegion = IntRect(IntPoint(), cc::IntSize(newBounds)); | 152 Region newRegion = gfx::Rect(gfx::Point(), newBounds); |
| 153 newRegion.subtract(oldRegion); | 153 newRegion.Subtract(oldRegion); |
| 154 Vector<WebCore::IntRect> rects = newRegion.rects(); | 154 Vector<WebCore::IntRect> rects = newRegion.rects(); |
| 155 for (size_t i = 0; i < rects.size(); ++i) | 155 for (size_t i = 0; i < rects.size(); ++i) |
| 156 invalidateContentRect(cc::IntRect(rects[i])); | 156 invalidateContentRect(cc::IntRect(rects[i])); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void TiledLayer::setTileSize(const gfx::Size& size) | 159 void TiledLayer::setTileSize(const gfx::Size& size) |
| 160 { | 160 { |
| 161 m_tiler->setTileSize(size); | 161 m_tiler->setTileSize(size); |
| 162 } | 162 } |
| 163 | 163 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 bool ignoreOcclusions = !occlusion; | 323 bool ignoreOcclusions = !occlusion; |
| 324 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { | 324 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { |
| 325 m_failedUpdate = true; | 325 m_failedUpdate = true; |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 | 328 |
| 329 gfx::Rect paintRect = markTilesForUpdate(left, top, right, bottom, ignoreOcc
lusions); | 329 gfx::Rect paintRect = markTilesForUpdate(left, top, right, bottom, ignoreOcc
lusions); |
| 330 | 330 |
| 331 if (occlusion) | 331 if (occlusion) |
| 332 occlusion->overdrawMetrics().didPaint(cc::IntRect(paintRect)); | 332 occlusion->overdrawMetrics().didPaint(paintRect); |
| 333 | 333 |
| 334 if (paintRect.IsEmpty()) | 334 if (paintRect.IsEmpty()) |
| 335 return true; | 335 return true; |
| 336 | 336 |
| 337 didPaint = true; | 337 didPaint = true; |
| 338 updateTileTextures(paintRect, left, top, right, bottom, queue, occlusion, st
ats); | 338 updateTileTextures(paintRect, left, top, right, bottom, queue, occlusion, st
ats); |
| 339 return true; | 339 return true; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void TiledLayer::markOcclusionsAndRequestTextures(int left, int top, int right,
int bottom, const OcclusionTracker* occlusion) | 342 void TiledLayer::markOcclusionsAndRequestTextures(int left, int top, int right,
int bottom, const OcclusionTracker* occlusion) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 CRASH(); | 503 CRASH(); |
| 504 if (paintOffset.y() < 0) | 504 if (paintOffset.y() < 0) |
| 505 CRASH(); | 505 CRASH(); |
| 506 if (paintOffset.x() + sourceRect.width() > paintRect.width()) | 506 if (paintOffset.x() + sourceRect.width() > paintRect.width()) |
| 507 CRASH(); | 507 CRASH(); |
| 508 if (paintOffset.y() + sourceRect.height() > paintRect.height()) | 508 if (paintOffset.y() + sourceRect.height() > paintRect.height()) |
| 509 CRASH(); | 509 CRASH(); |
| 510 | 510 |
| 511 tile->updaterResource()->update(queue, sourceRect, destOffset, tile-
>partialUpdate, stats); | 511 tile->updaterResource()->update(queue, sourceRect, destOffset, tile-
>partialUpdate, stats); |
| 512 if (occlusion) | 512 if (occlusion) |
| 513 occlusion->overdrawMetrics().didUpload(WebTransformationMatrix()
, cc::IntRect(sourceRect), cc::IntRect(tile->opaqueRect())); | 513 occlusion->overdrawMetrics().didUpload(WebTransformationMatrix()
, sourceRect, tile->opaqueRect()); |
| 514 | 514 |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 | 518 |
| 519 namespace { | 519 namespace { |
| 520 // This picks a small animated layer to be anything less than one viewport. This | 520 // This picks a small animated layer to be anything less than one viewport. This |
| 521 // is specifically for page transitions which are viewport-sized layers. The ext
ra | 521 // is specifically for page transitions which are viewport-sized layers. The ext
ra |
| 522 // 64 pixels is due to these layers being slightly larger than the viewport in s
ome cases. | 522 // 64 pixels is due to these layers being slightly larger than the viewport in s
ome cases. |
| 523 bool isSmallAnimatedLayer(TiledLayer* layer) | 523 bool isSmallAnimatedLayer(TiledLayer* layer) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 gfx::Rect tileRect = m_tiler->tileRect(tile); | 585 gfx::Rect tileRect = m_tiler->tileRect(tile); |
| 586 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma
llAnimatedLayer, tile->managedTexture()); | 586 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma
llAnimatedLayer, tile->managedTexture()); |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 Region TiledLayer::visibleContentOpaqueRegion() const | 590 Region TiledLayer::visibleContentOpaqueRegion() const |
| 591 { | 591 { |
| 592 if (m_skipsDraw) | 592 if (m_skipsDraw) |
| 593 return Region(); | 593 return Region(); |
| 594 if (contentsOpaque()) | 594 if (contentsOpaque()) |
| 595 return cc::IntRect(visibleContentRect()); | 595 return visibleContentRect(); |
| 596 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); | 596 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); |
| 597 } | 597 } |
| 598 | 598 |
| 599 void TiledLayer::resetUpdateState() | 599 void TiledLayer::resetUpdateState() |
| 600 { | 600 { |
| 601 m_skipsDraw = false; | 601 m_skipsDraw = false; |
| 602 m_failedUpdate = false; | 602 m_failedUpdate = false; |
| 603 | 603 |
| 604 LayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); | 604 LayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); |
| 605 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != end; ++iter) { | 605 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != end; ++iter) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 gfx::Rect prepaintRect = visibleContentRect(); | 778 gfx::Rect prepaintRect = visibleContentRect(); |
| 779 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns, | 779 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns, |
| 780 -m_tiler->tileSize().height() * prepaintRows); | 780 -m_tiler->tileSize().height() * prepaintRows); |
| 781 gfx::Rect contentRect(gfx::Point(), contentBounds()); | 781 gfx::Rect contentRect(gfx::Point(), 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 |