| 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 "cc/tiled_layer.h" | 5 #include "cc/tiled_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Number of rows/columns of tiles to pre-paint. | 25 // Number of rows/columns of tiles to pre-paint. |
| 26 // We should increase these further as all textures are | 26 // We should increase these further as all textures are |
| 27 // prioritized and we insure performance doesn't suffer. | 27 // prioritized and we insure performance doesn't suffer. |
| 28 static const int prepaintRows = 4; | 28 static const int prepaintRows = 4; |
| 29 static const int prepaintColumns = 2; | 29 static const int prepaintColumns = 2; |
| 30 | 30 |
| 31 | 31 |
| 32 class UpdatableTile : public LayerTilingData::Tile { | 32 class UpdatableTile : public LayerTilingData::Tile { |
| 33 public: | 33 public: |
| 34 static scoped_ptr<UpdatableTile> create(scoped_ptr<LayerUpdater::Resource> u
pdaterResource) | 34 static scoped_ptr<UpdatableTile> Create(scoped_ptr<LayerUpdater::Resource> u
pdaterResource) |
| 35 { | 35 { |
| 36 return make_scoped_ptr(new UpdatableTile(updaterResource.Pass())); | 36 return make_scoped_ptr(new UpdatableTile(updaterResource.Pass())); |
| 37 } | 37 } |
| 38 | 38 |
| 39 LayerUpdater::Resource* updaterResource() { return m_updaterResource.get();
} | 39 LayerUpdater::Resource* updaterResource() { return m_updaterResource.get();
} |
| 40 PrioritizedResource* managedResource() { return m_updaterResource->texture()
; } | 40 PrioritizedResource* managedResource() { return m_updaterResource->texture()
; } |
| 41 | 41 |
| 42 bool isDirty() const { return !dirtyRect.IsEmpty(); } | 42 bool isDirty() const { return !dirtyRect.IsEmpty(); } |
| 43 | 43 |
| 44 // Reset update state for the current frame. This should occur before painti
ng | 44 // Reset update state for the current frame. This should occur before painti
ng |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 , m_failedUpdate(false) | 90 , m_failedUpdate(false) |
| 91 , m_tilingOption(AutoTile) | 91 , m_tilingOption(AutoTile) |
| 92 { | 92 { |
| 93 m_tiler = LayerTilingData::create(gfx::Size(), LayerTilingData::HasBorderTex
els); | 93 m_tiler = LayerTilingData::create(gfx::Size(), LayerTilingData::HasBorderTex
els); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TiledLayer::~TiledLayer() | 96 TiledLayer::~TiledLayer() |
| 97 { | 97 { |
| 98 } | 98 } |
| 99 | 99 |
| 100 scoped_ptr<LayerImpl> TiledLayer::createLayerImpl(LayerTreeImpl* treeImpl) | 100 scoped_ptr<LayerImpl> TiledLayer::CreateLayerImpl(LayerTreeImpl* treeImpl) |
| 101 { | 101 { |
| 102 return TiledLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); | 102 return TiledLayerImpl::Create(treeImpl, id()).PassAs<LayerImpl>(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void TiledLayer::updateTileSizeAndTilingOption() | 105 void TiledLayer::updateTileSizeAndTilingOption() |
| 106 { | 106 { |
| 107 DCHECK(layerTreeHost()); | 107 DCHECK(layer_tree_host()); |
| 108 | 108 |
| 109 gfx::Size defaultTileSize = layerTreeHost()->settings().defaultTileSize; | 109 gfx::Size defaultTileSize = layer_tree_host()->settings().defaultTileSize; |
| 110 gfx::Size maxUntiledLayerSize = layerTreeHost()->settings().maxUntiledLayerS
ize; | 110 gfx::Size maxUntiledLayerSize = layer_tree_host()->settings().maxUntiledLaye
rSize; |
| 111 int layerWidth = contentBounds().width(); | 111 int layerWidth = content_bounds().width(); |
| 112 int layerHeight = contentBounds().height(); | 112 int layerHeight = content_bounds().height(); |
| 113 | 113 |
| 114 gfx::Size tileSize(std::min(defaultTileSize.width(), layerWidth), std::min(d
efaultTileSize.height(), layerHeight)); | 114 gfx::Size tileSize(std::min(defaultTileSize.width(), layerWidth), std::min(d
efaultTileSize.height(), layerHeight)); |
| 115 | 115 |
| 116 // Tile if both dimensions large, or any one dimension large and the other | 116 // Tile if both dimensions large, or any one dimension large and the other |
| 117 // extends into a second tile but the total layer area isn't larger than tha
t | 117 // extends into a second tile but the total layer area isn't larger than tha
t |
| 118 // of the largest possible untiled layer. This heuristic allows for long ski
nny layers | 118 // of the largest possible untiled layer. This heuristic allows for long ski
nny layers |
| 119 // (e.g. scrollbars) that are Nx1 tiles to minimize wasted texture space but
still avoids | 119 // (e.g. scrollbars) that are Nx1 tiles to minimize wasted texture space but
still avoids |
| 120 // creating very large tiles. | 120 // creating very large tiles. |
| 121 bool anyDimensionLarge = layerWidth > maxUntiledLayerSize.width() || layerHe
ight > maxUntiledLayerSize.height(); | 121 bool anyDimensionLarge = layerWidth > maxUntiledLayerSize.width() || layerHe
ight > maxUntiledLayerSize.height(); |
| 122 bool anyDimensionOneTile = (layerWidth <= defaultTileSize.width() || layerHe
ight <= defaultTileSize.height()) | 122 bool anyDimensionOneTile = (layerWidth <= defaultTileSize.width() || layerHe
ight <= defaultTileSize.height()) |
| 123 && (layerWidth * layerHeight) <= (maxUntil
edLayerSize.width() * maxUntiledLayerSize.height()); | 123 && (layerWidth * layerHeight) <= (maxUntil
edLayerSize.width() * maxUntiledLayerSize.height()); |
| 124 bool autoTiled = anyDimensionLarge && !anyDimensionOneTile; | 124 bool autoTiled = anyDimensionLarge && !anyDimensionOneTile; |
| 125 | 125 |
| 126 bool isTiled; | 126 bool isTiled; |
| 127 if (m_tilingOption == AlwaysTile) | 127 if (m_tilingOption == AlwaysTile) |
| 128 isTiled = true; | 128 isTiled = true; |
| 129 else if (m_tilingOption == NeverTile) | 129 else if (m_tilingOption == NeverTile) |
| 130 isTiled = false; | 130 isTiled = false; |
| 131 else | 131 else |
| 132 isTiled = autoTiled; | 132 isTiled = autoTiled; |
| 133 | 133 |
| 134 gfx::Size requestedSize = isTiled ? tileSize : contentBounds(); | 134 gfx::Size requestedSize = isTiled ? tileSize : content_bounds(); |
| 135 const int maxSize = layerTreeHost()->rendererCapabilities().maxTextureSize; | 135 const int maxSize = layer_tree_host()->rendererCapabilities().maxTextureSize
; |
| 136 requestedSize.ClampToMax(gfx::Size(maxSize, maxSize)); | 136 requestedSize.ClampToMax(gfx::Size(maxSize, maxSize)); |
| 137 setTileSize(requestedSize); | 137 setTileSize(requestedSize); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void TiledLayer::updateBounds() | 140 void TiledLayer::updateBounds() |
| 141 { | 141 { |
| 142 gfx::Size oldBounds = m_tiler->bounds(); | 142 gfx::Size oldBounds = m_tiler->bounds(); |
| 143 gfx::Size newBounds = contentBounds(); | 143 gfx::Size newBounds = content_bounds(); |
| 144 if (oldBounds == newBounds) | 144 if (oldBounds == newBounds) |
| 145 return; | 145 return; |
| 146 m_tiler->setBounds(newBounds); | 146 m_tiler->setBounds(newBounds); |
| 147 | 147 |
| 148 // Invalidate any areas that the new bounds exposes. | 148 // Invalidate any areas that the new bounds exposes. |
| 149 Region oldRegion = gfx::Rect(gfx::Point(), oldBounds); | 149 Region oldRegion = gfx::Rect(gfx::Point(), oldBounds); |
| 150 Region newRegion = gfx::Rect(gfx::Point(), newBounds); | 150 Region newRegion = gfx::Rect(gfx::Point(), newBounds); |
| 151 newRegion.Subtract(oldRegion); | 151 newRegion.Subtract(oldRegion); |
| 152 for (Region::Iterator newRects(newRegion); newRects.has_rect(); newRects.nex
t()) | 152 for (Region::Iterator newRects(newRegion); newRects.has_rect(); newRects.nex
t()) |
| 153 invalidateContentRect(newRects.rect()); | 153 invalidateContentRect(newRects.rect()); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void TiledLayer::setTileSize(const gfx::Size& size) | 156 void TiledLayer::setTileSize(const gfx::Size& size) |
| 157 { | 157 { |
| 158 m_tiler->setTileSize(size); | 158 m_tiler->setTileSize(size); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void TiledLayer::setBorderTexelOption(LayerTilingData::BorderTexelOption borderT
exelOption) | 161 void TiledLayer::setBorderTexelOption(LayerTilingData::BorderTexelOption borderT
exelOption) |
| 162 { | 162 { |
| 163 m_tiler->setBorderTexelOption(borderTexelOption); | 163 m_tiler->setBorderTexelOption(borderTexelOption); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool TiledLayer::drawsContent() const | 166 bool TiledLayer::DrawsContent() const |
| 167 { | 167 { |
| 168 if (!ContentsScalingLayer::drawsContent()) | 168 if (!ContentsScalingLayer::DrawsContent()) |
| 169 return false; | 169 return false; |
| 170 | 170 |
| 171 bool hasMoreThanOneTile = m_tiler->numTilesX() > 1 || m_tiler->numTilesY() >
1; | 171 bool hasMoreThanOneTile = m_tiler->numTilesX() > 1 || m_tiler->numTilesY() >
1; |
| 172 if (m_tilingOption == NeverTile && hasMoreThanOneTile) | 172 if (m_tilingOption == NeverTile && hasMoreThanOneTile) |
| 173 return false; | 173 return false; |
| 174 | 174 |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 | 177 |
| 178 void TiledLayer::setTilingOption(TilingOption tilingOption) | 178 void TiledLayer::setTilingOption(TilingOption tilingOption) |
| 179 { | 179 { |
| 180 m_tilingOption = tilingOption; | 180 m_tilingOption = tilingOption; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void TiledLayer::setIsMask(bool isMask) | 183 void TiledLayer::SetIsMask(bool isMask) |
| 184 { | 184 { |
| 185 setTilingOption(isMask ? NeverTile : AutoTile); | 185 setTilingOption(isMask ? NeverTile : AutoTile); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void TiledLayer::pushPropertiesTo(LayerImpl* layer) | 188 void TiledLayer::PushPropertiesTo(LayerImpl* layer) |
| 189 { | 189 { |
| 190 ContentsScalingLayer::pushPropertiesTo(layer); | 190 ContentsScalingLayer::PushPropertiesTo(layer); |
| 191 | 191 |
| 192 TiledLayerImpl* tiledLayer = static_cast<TiledLayerImpl*>(layer); | 192 TiledLayerImpl* tiledLayer = static_cast<TiledLayerImpl*>(layer); |
| 193 | 193 |
| 194 tiledLayer->setSkipsDraw(m_skipsDraw); | 194 tiledLayer->setSkipsDraw(m_skipsDraw); |
| 195 tiledLayer->setTilingData(*m_tiler); | 195 tiledLayer->setTilingData(*m_tiler); |
| 196 std::vector<UpdatableTile*> invalidTiles; | 196 std::vector<UpdatableTile*> invalidTiles; |
| 197 | 197 |
| 198 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { | 198 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { |
| 199 int i = iter->first.first; | 199 int i = iter->first.first; |
| 200 int j = iter->first.second; | 200 int j = iter->first.second; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 214 tiledLayer->pushInvalidTile(i, j); | 214 tiledLayer->pushInvalidTile(i, j); |
| 215 continue; | 215 continue; |
| 216 } | 216 } |
| 217 | 217 |
| 218 tiledLayer->pushTileProperties(i, j, tile->managedResource()->resourceId
(), tile->opaqueRect(), tile->managedResource()->contentsSwizzled()); | 218 tiledLayer->pushTileProperties(i, j, tile->managedResource()->resourceId
(), tile->opaqueRect(), tile->managedResource()->contentsSwizzled()); |
| 219 } | 219 } |
| 220 for (std::vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin()
; iter != invalidTiles.end(); ++iter) | 220 for (std::vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin()
; iter != invalidTiles.end(); ++iter) |
| 221 m_tiler->takeTile((*iter)->i(), (*iter)->j()); | 221 m_tiler->takeTile((*iter)->i(), (*iter)->j()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool TiledLayer::blocksPendingCommit() const | 224 bool TiledLayer::BlocksPendingCommit() const |
| 225 { | 225 { |
| 226 return true; | 226 return true; |
| 227 } | 227 } |
| 228 | 228 |
| 229 PrioritizedResourceManager* TiledLayer::resourceManager() const | 229 PrioritizedResourceManager* TiledLayer::resourceManager() const |
| 230 { | 230 { |
| 231 if (!layerTreeHost()) | 231 if (!layer_tree_host()) |
| 232 return 0; | 232 return 0; |
| 233 return layerTreeHost()->contentsTextureManager(); | 233 return layer_tree_host()->contentsTextureManager(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 const PrioritizedResource* TiledLayer::resourceAtForTesting(int i, int j) const | 236 const PrioritizedResource* TiledLayer::resourceAtForTesting(int i, int j) const |
| 237 { | 237 { |
| 238 UpdatableTile* tile = tileAt(i, j); | 238 UpdatableTile* tile = tileAt(i, j); |
| 239 if (!tile) | 239 if (!tile) |
| 240 return 0; | 240 return 0; |
| 241 return tile->managedResource(); | 241 return tile->managedResource(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void TiledLayer::setLayerTreeHost(LayerTreeHost* host) | 244 void TiledLayer::SetLayerTreeHost(LayerTreeHost* host) |
| 245 { | 245 { |
| 246 if (host && host != layerTreeHost()) { | 246 if (host && host != layer_tree_host()) { |
| 247 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be
gin(); iter != m_tiler->tiles().end(); ++iter) { | 247 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be
gin(); iter != m_tiler->tiles().end(); ++iter) { |
| 248 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 248 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
| 249 // FIXME: This should not ever be null. | 249 // FIXME: This should not ever be null. |
| 250 if (!tile) | 250 if (!tile) |
| 251 continue; | 251 continue; |
| 252 tile->managedResource()->setTextureManager(host->contentsTextureMana
ger()); | 252 tile->managedResource()->setTextureManager(host->contentsTextureMana
ger()); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 ContentsScalingLayer::setLayerTreeHost(host); | 255 ContentsScalingLayer::SetLayerTreeHost(host); |
| 256 } | 256 } |
| 257 | 257 |
| 258 UpdatableTile* TiledLayer::tileAt(int i, int j) const | 258 UpdatableTile* TiledLayer::tileAt(int i, int j) const |
| 259 { | 259 { |
| 260 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j)); | 260 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 UpdatableTile* TiledLayer::createTile(int i, int j) | 263 UpdatableTile* TiledLayer::createTile(int i, int j) |
| 264 { | 264 { |
| 265 createUpdaterIfNeeded(); | 265 createUpdaterIfNeeded(); |
| 266 | 266 |
| 267 scoped_ptr<UpdatableTile> tile(UpdatableTile::create(updater()->createResour
ce(resourceManager()))); | 267 scoped_ptr<UpdatableTile> tile(UpdatableTile::Create(updater()->createResour
ce(resourceManager()))); |
| 268 tile->managedResource()->setDimensions(m_tiler->tileSize(), m_textureFormat)
; | 268 tile->managedResource()->setDimensions(m_tiler->tileSize(), m_textureFormat)
; |
| 269 | 269 |
| 270 UpdatableTile* addedTile = tile.get(); | 270 UpdatableTile* addedTile = tile.get(); |
| 271 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j); | 271 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j); |
| 272 | 272 |
| 273 addedTile->dirtyRect = m_tiler->tileRect(addedTile); | 273 addedTile->dirtyRect = m_tiler->tileRect(addedTile); |
| 274 | 274 |
| 275 // Temporary diagnostic crash. | 275 // Temporary diagnostic crash. |
| 276 CHECK(addedTile); | 276 CHECK(addedTile); |
| 277 CHECK(tileAt(i, j)); | 277 CHECK(tileAt(i, j)); |
| 278 | 278 |
| 279 return addedTile; | 279 return addedTile; |
| 280 } | 280 } |
| 281 | 281 |
| 282 void TiledLayer::setNeedsDisplayRect(const gfx::RectF& dirtyRect) | 282 void TiledLayer::SetNeedsDisplayRect(const gfx::RectF& dirtyRect) |
| 283 { | 283 { |
| 284 invalidateContentRect(layerRectToContentRect(dirtyRect)); | 284 invalidateContentRect(LayerRectToContentRect(dirtyRect)); |
| 285 ContentsScalingLayer::setNeedsDisplayRect(dirtyRect); | 285 ContentsScalingLayer::SetNeedsDisplayRect(dirtyRect); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void TiledLayer::invalidateContentRect(const gfx::Rect& contentRect) | 288 void TiledLayer::invalidateContentRect(const gfx::Rect& contentRect) |
| 289 { | 289 { |
| 290 updateBounds(); | 290 updateBounds(); |
| 291 if (m_tiler->isEmpty() || contentRect.IsEmpty() || m_skipsDraw) | 291 if (m_tiler->isEmpty() || contentRect.IsEmpty() || m_skipsDraw) |
| 292 return; | 292 return; |
| 293 | 293 |
| 294 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { | 294 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { |
| 295 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 295 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
| 296 DCHECK(tile); | 296 DCHECK(tile); |
| 297 // FIXME: This should not ever be null. | 297 // FIXME: This should not ever be null. |
| 298 if (!tile) | 298 if (!tile) |
| 299 continue; | 299 continue; |
| 300 gfx::Rect bound = m_tiler->tileRect(tile); | 300 gfx::Rect bound = m_tiler->tileRect(tile); |
| 301 bound.Intersect(contentRect); | 301 bound.Intersect(contentRect); |
| 302 tile->dirtyRect.Union(bound); | 302 tile->dirtyRect.Union(bound); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 // Returns true if tile is dirty and only part of it needs to be updated. | 306 // Returns true if tile is dirty and only part of it needs to be updated. |
| 307 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) | 307 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) |
| 308 { | 308 { |
| 309 return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedRe
source()->haveBackingTexture(); | 309 return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedRe
source()->haveBackingTexture(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceU
pdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats, boo
l& didPaint) | 312 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceU
pdateQueue* queue, const OcclusionTracker* occlusion, RenderingStats* stats, boo
l& didPaint) |
| 313 { | 313 { |
| 314 didPaint = false; | 314 didPaint = false; |
| 315 createUpdaterIfNeeded(); | 315 createUpdaterIfNeeded(); |
| 316 | 316 |
| 317 bool ignoreOcclusions = !occlusion; | 317 bool ignoreOcclusions = !occlusion; |
| 318 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { | 318 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { |
| 319 m_failedUpdate = true; | 319 m_failedUpdate = true; |
| 320 return false; | 320 return false; |
| 321 } | 321 } |
| 322 | 322 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 344 int occludedTileCount = 0; | 344 int occludedTileCount = 0; |
| 345 bool succeeded = true; | 345 bool succeeded = true; |
| 346 for (int j = top; j <= bottom; ++j) { | 346 for (int j = top; j <= bottom; ++j) { |
| 347 for (int i = left; i <= right; ++i) { | 347 for (int i = left; i <= right; ++i) { |
| 348 UpdatableTile* tile = tileAt(i, j); | 348 UpdatableTile* tile = tileAt(i, j); |
| 349 DCHECK(tile); // Did setTexturePriorities get skipped? | 349 DCHECK(tile); // Did setTexturePriorities get skipped? |
| 350 // FIXME: This should not ever be null. | 350 // FIXME: This should not ever be null. |
| 351 if (!tile) | 351 if (!tile) |
| 352 continue; | 352 continue; |
| 353 DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are we
doing more than one occlusion pass? | 353 DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are we
doing more than one occlusion pass? |
| 354 gfx::Rect visibleTileRect = gfx::IntersectRects(m_tiler->tileBounds(
i, j), visibleContentRect()); | 354 gfx::Rect visibleTileRect = gfx::IntersectRects(m_tiler->tileBounds(
i, j), visible_content_rect()); |
| 355 if (occlusion && occlusion->Occluded(renderTarget(), visibleTileRect
, drawTransform(), drawTransformIsAnimating(), isClipped(), clipRect(), NULL)) { | 355 if (occlusion && occlusion->Occluded(render_target(), visibleTileRec
t, draw_transform(), draw_transform_is_animating(), is_clipped(), clip_rect(), N
ULL)) { |
| 356 tile->occluded = true; | 356 tile->occluded = true; |
| 357 occludedTileCount++; | 357 occludedTileCount++; |
| 358 } else { | 358 } else { |
| 359 succeeded &= tile->managedResource()->requestLate(); | 359 succeeded &= tile->managedResource()->requestLate(); |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (!succeeded) | 364 if (!succeeded) |
| 365 return; | 365 return; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 for (int i = left; i <= right; ++i) { | 400 for (int i = left; i <= right; ++i) { |
| 401 UpdatableTile* tile = tileAt(i, j); | 401 UpdatableTile* tile = tileAt(i, j); |
| 402 DCHECK(tile); // Did setTexturePriorites get skipped? | 402 DCHECK(tile); // Did setTexturePriorites get skipped? |
| 403 // FIXME: This should not ever be null. | 403 // FIXME: This should not ever be null. |
| 404 if (!tile) | 404 if (!tile) |
| 405 continue; | 405 continue; |
| 406 if (tile->occluded && !ignoreOcclusions) | 406 if (tile->occluded && !ignoreOcclusions) |
| 407 continue; | 407 continue; |
| 408 // FIXME: Decide if partial update should be allowed based on cost | 408 // FIXME: Decide if partial update should be allowed based on cost |
| 409 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 | 409 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 |
| 410 if (tile->isDirty() && layerTreeHost() && layerTreeHost()->bufferedU
pdates()) { | 410 if (tile->isDirty() && layer_tree_host() && layer_tree_host()->buffe
redUpdates()) { |
| 411 // If we get a partial update, we use the same texture, otherwis
e return the | 411 // If we get a partial update, we use the same texture, otherwis
e return the |
| 412 // current texture backing, so we don't update visible textures
non-atomically. | 412 // current texture backing, so we don't update visible textures
non-atomically. |
| 413 // If the current backing is in-use, it won't be deleted until a
fter the commit | 413 // If the current backing is in-use, it won't be deleted until a
fter the commit |
| 414 // as the texture manager will not allow deletion or recycling o
f in-use textures. | 414 // as the texture manager will not allow deletion or recycling o
f in-use textures. |
| 415 if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost()->request
PartialTextureUpdate()) | 415 if (tileOnlyNeedsPartialUpdate(tile) && layer_tree_host()->reque
stPartialTextureUpdate()) |
| 416 tile->partialUpdate = true; | 416 tile->partialUpdate = true; |
| 417 else { | 417 else { |
| 418 tile->dirtyRect = m_tiler->tileRect(tile); | 418 tile->dirtyRect = m_tiler->tileRect(tile); |
| 419 tile->managedResource()->returnBackingTexture(); | 419 tile->managedResource()->returnBackingTexture(); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 paintRect.Union(tile->dirtyRect); | 423 paintRect.Union(tile->dirtyRect); |
| 424 tile->markForUpdate(); | 424 tile->markForUpdate(); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 return paintRect; | 427 return paintRect; |
| 428 } | 428 } |
| 429 | 429 |
| 430 void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int to
p, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* oc
clusion, RenderingStats* stats) | 430 void TiledLayer::updateTileTextures(const gfx::Rect& paintRect, int left, int to
p, int right, int bottom, ResourceUpdateQueue* queue, const OcclusionTracker* oc
clusion, RenderingStats* stats) |
| 431 { | 431 { |
| 432 // The updateRect should be in layer space. So we have to convert the paintR
ect from content space to layer space. | 432 // The updateRect should be in layer space. So we have to convert the paintR
ect from content space to layer space. |
| 433 float widthScale = bounds().width() / static_cast<float>(contentBounds().wid
th()); | 433 float widthScale = bounds().width() / static_cast<float>(content_bounds().wi
dth()); |
| 434 float heightScale = bounds().height() / static_cast<float>(contentBounds().h
eight()); | 434 float heightScale = bounds().height() / static_cast<float>(content_bounds().
height()); |
| 435 m_updateRect = gfx::ScaleRect(paintRect, widthScale, heightScale); | 435 update_rect_ = gfx::ScaleRect(paintRect, widthScale, heightScale); |
| 436 | 436 |
| 437 // Calling prepareToUpdate() calls into WebKit to paint, which may have the
side | 437 // Calling prepareToUpdate() calls into WebKit to paint, which may have the
side |
| 438 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. | 438 // effect of disabling compositing, which causes our reference to the textur
e updater to be deleted. |
| 439 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, | 439 // However, we can't free the memory backing the SkCanvas until the paint fi
nishes, |
| 440 // so we grab a local reference here to hold the updater alive until the pai
nt completes. | 440 // so we grab a local reference here to hold the updater alive until the pai
nt completes. |
| 441 scoped_refptr<LayerUpdater> protector(updater()); | 441 scoped_refptr<LayerUpdater> protector(updater()); |
| 442 gfx::Rect paintedOpaqueRect; | 442 gfx::Rect paintedOpaqueRect; |
| 443 updater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1
/ heightScale, paintedOpaqueRect, stats); | 443 updater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1
/ heightScale, paintedOpaqueRect, stats); |
| 444 | 444 |
| 445 for (int j = top; j <= bottom; ++j) { | 445 for (int j = top; j <= bottom; ++j) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 CHECK(destOffset.x() >= 0); | 489 CHECK(destOffset.x() >= 0); |
| 490 CHECK(destOffset.y() >= 0); | 490 CHECK(destOffset.y() >= 0); |
| 491 | 491 |
| 492 // Offset from paint rectangle to this tile's dirty rectangle. | 492 // Offset from paint rectangle to this tile's dirty rectangle. |
| 493 gfx::Vector2d paintOffset = sourceRect.origin() - paintRect.origin()
; | 493 gfx::Vector2d paintOffset = sourceRect.origin() - paintRect.origin()
; |
| 494 CHECK(paintOffset.x() >= 0); | 494 CHECK(paintOffset.x() >= 0); |
| 495 CHECK(paintOffset.y() >= 0); | 495 CHECK(paintOffset.y() >= 0); |
| 496 CHECK(paintOffset.x() + sourceRect.width() <= paintRect.width()); | 496 CHECK(paintOffset.x() + sourceRect.width() <= paintRect.width()); |
| 497 CHECK(paintOffset.y() + sourceRect.height() <= paintRect.height()); | 497 CHECK(paintOffset.y() + sourceRect.height() <= paintRect.height()); |
| 498 | 498 |
| 499 tile->updaterResource()->update(queue, sourceRect, destOffset, tile-
>partialUpdate, stats); | 499 tile->updaterResource()->update(*queue, sourceRect, destOffset, tile
->partialUpdate, stats); |
| 500 if (occlusion) | 500 if (occlusion) |
| 501 occlusion->OverdrawMetrics().DidUpload(gfx::Transform(), sourceR
ect, tile->opaqueRect()); | 501 occlusion->OverdrawMetrics().DidUpload(gfx::Transform(), sourceR
ect, tile->opaqueRect()); |
| 502 | 502 |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 // This picks a small animated layer to be anything less than one viewport. This | 507 // This picks a small animated layer to be anything less than one viewport. This |
| 508 // is specifically for page transitions which are viewport-sized layers. The ext
ra | 508 // is specifically for page transitions which are viewport-sized layers. The ext
ra |
| 509 // tile of padding is due to these layers being slightly larger than the viewpor
t | 509 // tile of padding is due to these layers being slightly larger than the viewpor
t |
| 510 // in some cases. | 510 // in some cases. |
| 511 bool TiledLayer::isSmallAnimatedLayer() const | 511 bool TiledLayer::isSmallAnimatedLayer() const |
| 512 { | 512 { |
| 513 if (!drawTransformIsAnimating() && !screenSpaceTransformIsAnimating()) | 513 if (!draw_transform_is_animating() && !screen_space_transform_is_animating()
) |
| 514 return false; | 514 return false; |
| 515 gfx::Size viewportSize = layerTreeHost() ? layerTreeHost()->deviceViewportSi
ze() : gfx::Size(); | 515 gfx::Size viewportSize = layer_tree_host() ? layer_tree_host()->deviceViewpo
rtSize() : gfx::Size(); |
| 516 gfx::Rect contentRect(gfx::Point(), contentBounds()); | 516 gfx::Rect contentRect(gfx::Point(), content_bounds()); |
| 517 return contentRect.width() <= viewportSize.width() + m_tiler->tileSize().wid
th() | 517 return contentRect.width() <= viewportSize.width() + m_tiler->tileSize().wid
th() |
| 518 && contentRect.height() <= viewportSize.height() + m_tiler->tileSize().h
eight(); | 518 && contentRect.height() <= viewportSize.height() + m_tiler->tileSize().h
eight(); |
| 519 } | 519 } |
| 520 | 520 |
| 521 namespace { | 521 namespace { |
| 522 // FIXME: Remove this and make this based on distance once distance can be calcu
lated | 522 // FIXME: Remove this and make this based on distance once distance can be calcu
lated |
| 523 // for offscreen layers. For now, prioritize all small animated layers after 512 | 523 // for offscreen layers. For now, prioritize all small animated layers after 512 |
| 524 // pixels of pre-painting. | 524 // pixels of pre-painting. |
| 525 void setPriorityForTexture(const gfx::Rect& visibleRect, | 525 void setPriorityForTexture(const gfx::Rect& visibleRect, |
| 526 const gfx::Rect& tileRect, | 526 const gfx::Rect& tileRect, |
| 527 bool drawsToRoot, | 527 bool drawsToRoot, |
| 528 bool isSmallAnimatedLayer, | 528 bool isSmallAnimatedLayer, |
| 529 PrioritizedResource* texture) | 529 PrioritizedResource* texture) |
| 530 { | 530 { |
| 531 int priority = PriorityCalculator::lowestPriority(); | 531 int priority = PriorityCalculator::lowestPriority(); |
| 532 if (!visibleRect.IsEmpty()) | 532 if (!visibleRect.IsEmpty()) |
| 533 priority = PriorityCalculator::priorityFromDistance(visibleRect, tileRec
t, drawsToRoot); | 533 priority = PriorityCalculator::priorityFromDistance(visibleRect, tileRec
t, drawsToRoot); |
| 534 if (isSmallAnimatedLayer) | 534 if (isSmallAnimatedLayer) |
| 535 priority = PriorityCalculator::maxPriority(priority, PriorityCalculator:
:smallAnimatedLayerMinPriority()); | 535 priority = PriorityCalculator::maxPriority(priority, PriorityCalculator:
:smallAnimatedLayerMinPriority()); |
| 536 if (priority != PriorityCalculator::lowestPriority()) | 536 if (priority != PriorityCalculator::lowestPriority()) |
| 537 texture->setRequestPriority(priority); | 537 texture->setRequestPriority(priority); |
| 538 } | 538 } |
| 539 } // namespace | 539 } // namespace |
| 540 | 540 |
| 541 void TiledLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) | 541 void TiledLayer::SetTexturePriorities(const PriorityCalculator& priorityCalc) |
| 542 { | 542 { |
| 543 updateBounds(); | 543 updateBounds(); |
| 544 resetUpdateState(); | 544 resetUpdateState(); |
| 545 updateScrollPrediction(); | 545 updateScrollPrediction(); |
| 546 | 546 |
| 547 if (m_tiler->hasEmptyBounds()) | 547 if (m_tiler->hasEmptyBounds()) |
| 548 return; | 548 return; |
| 549 | 549 |
| 550 bool drawsToRoot = !renderTarget()->parent(); | 550 bool drawsToRoot = !render_target()->parent(); |
| 551 bool smallAnimatedLayer = isSmallAnimatedLayer(); | 551 bool smallAnimatedLayer = isSmallAnimatedLayer(); |
| 552 | 552 |
| 553 // Minimally create the tiles in the desired pre-paint rect. | 553 // Minimally create the tiles in the desired pre-paint rect. |
| 554 gfx::Rect createTilesRect = idlePaintRect(); | 554 gfx::Rect createTilesRect = idlePaintRect(); |
| 555 if (smallAnimatedLayer) | 555 if (smallAnimatedLayer) |
| 556 createTilesRect = gfx::Rect(gfx::Point(), contentBounds()); | 556 createTilesRect = gfx::Rect(gfx::Point(), content_bounds()); |
| 557 if (!createTilesRect.IsEmpty()) { | 557 if (!createTilesRect.IsEmpty()) { |
| 558 int left, top, right, bottom; | 558 int left, top, right, bottom; |
| 559 m_tiler->contentRectToTileIndices(createTilesRect, left, top, right, bot
tom); | 559 m_tiler->contentRectToTileIndices(createTilesRect, left, top, right, bot
tom); |
| 560 for (int j = top; j <= bottom; ++j) { | 560 for (int j = top; j <= bottom; ++j) { |
| 561 for (int i = left; i <= right; ++i) { | 561 for (int i = left; i <= right; ++i) { |
| 562 if (!tileAt(i, j)) | 562 if (!tileAt(i, j)) |
| 563 createTile(i, j); | 563 createTile(i, j); |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Now update priorities on all tiles we have in the layer, no matter where
they are. | 568 // Now update priorities on all tiles we have in the layer, no matter where
they are. |
| 569 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { | 569 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != m_tiler->tiles().end(); ++iter) { |
| 570 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 570 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
| 571 // FIXME: This should not ever be null. | 571 // FIXME: This should not ever be null. |
| 572 if (!tile) | 572 if (!tile) |
| 573 continue; | 573 continue; |
| 574 gfx::Rect tileRect = m_tiler->tileRect(tile); | 574 gfx::Rect tileRect = m_tiler->tileRect(tile); |
| 575 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma
llAnimatedLayer, tile->managedResource()); | 575 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma
llAnimatedLayer, tile->managedResource()); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 Region TiledLayer::visibleContentOpaqueRegion() const | 579 Region TiledLayer::VisibleContentOpaqueRegion() const |
| 580 { | 580 { |
| 581 if (m_skipsDraw) | 581 if (m_skipsDraw) |
| 582 return Region(); | 582 return Region(); |
| 583 if (contentsOpaque()) | 583 if (contents_opaque()) |
| 584 return visibleContentRect(); | 584 return visible_content_rect(); |
| 585 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); | 585 return m_tiler->opaqueRegionInContentRect(visible_content_rect()); |
| 586 } | 586 } |
| 587 | 587 |
| 588 void TiledLayer::resetUpdateState() | 588 void TiledLayer::resetUpdateState() |
| 589 { | 589 { |
| 590 m_skipsDraw = false; | 590 m_skipsDraw = false; |
| 591 m_failedUpdate = false; | 591 m_failedUpdate = false; |
| 592 | 592 |
| 593 LayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); | 593 LayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); |
| 594 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != end; ++iter) { | 594 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(
); iter != end; ++iter) { |
| 595 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); | 595 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 609 return gfx::Rect(x, y, width, height); | 609 return gfx::Rect(x, y, width, height); |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 void TiledLayer::updateScrollPrediction() | 613 void TiledLayer::updateScrollPrediction() |
| 614 { | 614 { |
| 615 // This scroll prediction is very primitive and should be replaced by a | 615 // This scroll prediction is very primitive and should be replaced by a |
| 616 // a recursive calculation on all layers which uses actual scroll/animation | 616 // a recursive calculation on all layers which uses actual scroll/animation |
| 617 // velocities. To insure this doesn't miss-predict, we only use it to predic
t | 617 // velocities. To insure this doesn't miss-predict, we only use it to predic
t |
| 618 // the visibleRect if: | 618 // the visibleRect if: |
| 619 // - contentBounds() hasn't changed. | 619 // - content_bounds() hasn't changed. |
| 620 // - visibleRect.size() hasn't changed. | 620 // - visibleRect.size() hasn't changed. |
| 621 // These two conditions prevent rotations, scales, pinch-zooms etc. where | 621 // These two conditions prevent rotations, scales, pinch-zooms etc. where |
| 622 // the prediction would be incorrect. | 622 // the prediction would be incorrect. |
| 623 gfx::Vector2d delta = visibleContentRect().CenterPoint() - m_previousVisible
Rect.CenterPoint(); | 623 gfx::Vector2d delta = visible_content_rect().CenterPoint() - m_previousVisib
leRect.CenterPoint(); |
| 624 m_predictedScroll = -delta; | 624 m_predictedScroll = -delta; |
| 625 m_predictedVisibleRect = visibleContentRect(); | 625 m_predictedVisibleRect = visible_content_rect(); |
| 626 if (m_previousContentBounds == contentBounds() && m_previousVisibleRect.size
() == visibleContentRect().size()) { | 626 if (m_previousContentBounds == content_bounds() && m_previousVisibleRect.siz
e() == visible_content_rect().size()) { |
| 627 // Only expand the visible rect in the major scroll direction, to preven
t | 627 // Only expand the visible rect in the major scroll direction, to preven
t |
| 628 // massive paints due to diagonal scrolls. | 628 // massive paints due to diagonal scrolls. |
| 629 gfx::Vector2d majorScrollDelta = (abs(delta.x()) > abs(delta.y())) ? gfx
::Vector2d(delta.x(), 0) : gfx::Vector2d(0, delta.y()); | 629 gfx::Vector2d majorScrollDelta = (abs(delta.x()) > abs(delta.y())) ? gfx
::Vector2d(delta.x(), 0) : gfx::Vector2d(0, delta.y()); |
| 630 m_predictedVisibleRect = expandRectByDelta(visibleContentRect(), majorSc
rollDelta); | 630 m_predictedVisibleRect = expandRectByDelta(visible_content_rect(), major
ScrollDelta); |
| 631 | 631 |
| 632 // Bound the prediction to prevent unbounded paints, and clamp to conten
t bounds. | 632 // Bound the prediction to prevent unbounded paints, and clamp to conten
t bounds. |
| 633 gfx::Rect bound = visibleContentRect(); | 633 gfx::Rect bound = visible_content_rect(); |
| 634 bound.Inset(-m_tiler->tileSize().width() * maxPredictiveTilesCount, | 634 bound.Inset(-m_tiler->tileSize().width() * maxPredictiveTilesCount, |
| 635 -m_tiler->tileSize().height() * maxPredictiveTilesCount); | 635 -m_tiler->tileSize().height() * maxPredictiveTilesCount); |
| 636 bound.Intersect(gfx::Rect(gfx::Point(), contentBounds())); | 636 bound.Intersect(gfx::Rect(gfx::Point(), content_bounds())); |
| 637 m_predictedVisibleRect.Intersect(bound); | 637 m_predictedVisibleRect.Intersect(bound); |
| 638 } | 638 } |
| 639 m_previousContentBounds = contentBounds(); | 639 m_previousContentBounds = content_bounds(); |
| 640 m_previousVisibleRect = visibleContentRect(); | 640 m_previousVisibleRect = visible_content_rect(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void TiledLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occl
usion, RenderingStats* stats) | 643 void TiledLayer::Update(ResourceUpdateQueue* queue, const OcclusionTracker* occl
usion, RenderingStats* stats) |
| 644 { | 644 { |
| 645 DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped
? | 645 DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped
? |
| 646 | 646 |
| 647 { | 647 { |
| 648 base::AutoReset<bool> ignoreSetNeedsCommit(&m_ignoreSetNeedsCommit, true
); | 648 base::AutoReset<bool> ignoreSetNeedsCommit(&ignore_set_needs_commit_, tr
ue); |
| 649 | 649 |
| 650 ContentsScalingLayer::update(queue, occlusion, stats); | 650 ContentsScalingLayer::Update(queue, occlusion, stats); |
| 651 updateBounds(); | 651 updateBounds(); |
| 652 } | 652 } |
| 653 | 653 |
| 654 if (m_tiler->hasEmptyBounds() || !drawsContent()) | 654 if (m_tiler->hasEmptyBounds() || !DrawsContent()) |
| 655 return; | 655 return; |
| 656 | 656 |
| 657 bool didPaint = false; | 657 bool didPaint = false; |
| 658 | 658 |
| 659 // Animation pre-paint. If the layer is small, try to paint it all | 659 // Animation pre-paint. If the layer is small, try to paint it all |
| 660 // immediately whether or not it is occluded, to avoid paint/upload | 660 // immediately whether or not it is occluded, to avoid paint/upload |
| 661 // hiccups while it is animating. | 661 // hiccups while it is animating. |
| 662 if (isSmallAnimatedLayer()) { | 662 if (isSmallAnimatedLayer()) { |
| 663 int left, top, right, bottom; | 663 int left, top, right, bottom; |
| 664 m_tiler->contentRectToTileIndices(gfx::Rect(gfx::Point(), contentBounds(
)), left, top, right, bottom); | 664 m_tiler->contentRectToTileIndices(gfx::Rect(gfx::Point(), content_bounds
()), left, top, right, bottom); |
| 665 updateTiles(left, top, right, bottom, queue, 0, stats, didPaint); | 665 updateTiles(left, top, right, bottom, queue, 0, stats, didPaint); |
| 666 if (didPaint) | 666 if (didPaint) |
| 667 return; | 667 return; |
| 668 // This was an attempt to paint the entire layer so if we fail it's okay
, | 668 // This was an attempt to paint the entire layer so if we fail it's okay
, |
| 669 // just fallback on painting visible etc. below. | 669 // just fallback on painting visible etc. below. |
| 670 m_failedUpdate = false; | 670 m_failedUpdate = false; |
| 671 } | 671 } |
| 672 | 672 |
| 673 if (m_predictedVisibleRect.IsEmpty()) | 673 if (m_predictedVisibleRect.IsEmpty()) |
| 674 return; | 674 return; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 if (!updateTiles(right, top, right, bottom, queue, 0, stats, did
Paint) || didPaint) | 731 if (!updateTiles(right, top, right, bottom, queue, 0, stats, did
Paint) || didPaint) |
| 732 return; | 732 return; |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 | 737 |
| 738 bool TiledLayer::needsIdlePaint() | 738 bool TiledLayer::needsIdlePaint() |
| 739 { | 739 { |
| 740 // Don't trigger more paints if we failed (as we'll just fail again). | 740 // Don't trigger more paints if we failed (as we'll just fail again). |
| 741 if (m_failedUpdate || visibleContentRect().IsEmpty() || m_tiler->hasEmptyBou
nds() || !drawsContent()) | 741 if (m_failedUpdate || visible_content_rect().IsEmpty() || m_tiler->hasEmptyB
ounds() || !DrawsContent()) |
| 742 return false; | 742 return false; |
| 743 | 743 |
| 744 gfx::Rect idlePaintContentRect = idlePaintRect(); | 744 gfx::Rect idlePaintContentRect = idlePaintRect(); |
| 745 if (idlePaintContentRect.IsEmpty()) | 745 if (idlePaintContentRect.IsEmpty()) |
| 746 return false; | 746 return false; |
| 747 | 747 |
| 748 int left, top, right, bottom; | 748 int left, top, right, bottom; |
| 749 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); | 749 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo
ttom); |
| 750 | 750 |
| 751 for (int j = top; j <= bottom; ++j) { | 751 for (int j = top; j <= bottom; ++j) { |
| 752 for (int i = left; i <= right; ++i) { | 752 for (int i = left; i <= right; ++i) { |
| 753 UpdatableTile* tile = tileAt(i, j); | 753 UpdatableTile* tile = tileAt(i, j); |
| 754 DCHECK(tile); // Did setTexturePriorities get skipped? | 754 DCHECK(tile); // Did setTexturePriorities get skipped? |
| 755 if (!tile) | 755 if (!tile) |
| 756 continue; | 756 continue; |
| 757 | 757 |
| 758 bool updated = !tile->updateRect.IsEmpty(); | 758 bool updated = !tile->updateRect.IsEmpty(); |
| 759 bool canAcquire = tile->managedResource()->canAcquireBackingTexture(
); | 759 bool canAcquire = tile->managedResource()->canAcquireBackingTexture(
); |
| 760 bool dirty = tile->isDirty() || !tile->managedResource()->haveBackin
gTexture(); | 760 bool dirty = tile->isDirty() || !tile->managedResource()->haveBackin
gTexture(); |
| 761 if (!updated && canAcquire && dirty) | 761 if (!updated && canAcquire && dirty) |
| 762 return true; | 762 return true; |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 return false; | 765 return false; |
| 766 } | 766 } |
| 767 | 767 |
| 768 gfx::Rect TiledLayer::idlePaintRect() | 768 gfx::Rect TiledLayer::idlePaintRect() |
| 769 { | 769 { |
| 770 // Don't inflate an empty rect. | 770 // Don't inflate an empty rect. |
| 771 if (visibleContentRect().IsEmpty()) | 771 if (visible_content_rect().IsEmpty()) |
| 772 return gfx::Rect(); | 772 return gfx::Rect(); |
| 773 | 773 |
| 774 gfx::Rect prepaintRect = visibleContentRect(); | 774 gfx::Rect prepaintRect = visible_content_rect(); |
| 775 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns, | 775 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns, |
| 776 -m_tiler->tileSize().height() * prepaintRows); | 776 -m_tiler->tileSize().height() * prepaintRows); |
| 777 gfx::Rect contentRect(gfx::Point(), contentBounds()); | 777 gfx::Rect contentRect(content_bounds()); |
| 778 prepaintRect.Intersect(contentRect); | 778 prepaintRect.Intersect(contentRect); |
| 779 | 779 |
| 780 return prepaintRect; | 780 return prepaintRect; |
| 781 } | 781 } |
| 782 | 782 |
| 783 } // namespace cc | 783 } // namespace cc |
| OLD | NEW |