Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: cc/tiled_layer.cc

Issue 11369109: cc: Rename PrioritizedTexture to PrioritizedResource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/tiled_layer.h ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 32
33 33
34 class UpdatableTile : public LayerTilingData::Tile { 34 class UpdatableTile : public LayerTilingData::Tile {
35 public: 35 public:
36 static scoped_ptr<UpdatableTile> create(scoped_ptr<LayerUpdater::Resource> u pdaterResource) 36 static scoped_ptr<UpdatableTile> create(scoped_ptr<LayerUpdater::Resource> u pdaterResource)
37 { 37 {
38 return make_scoped_ptr(new UpdatableTile(updaterResource.Pass())); 38 return make_scoped_ptr(new UpdatableTile(updaterResource.Pass()));
39 } 39 }
40 40
41 LayerUpdater::Resource* updaterResource() { return m_updaterResource.get(); } 41 LayerUpdater::Resource* updaterResource() { return m_updaterResource.get(); }
42 PrioritizedTexture* managedTexture() { return m_updaterResource->texture(); } 42 PrioritizedResource* managedResource() { return m_updaterResource->texture() ; }
43 43
44 bool isDirty() const { return !dirtyRect.IsEmpty(); } 44 bool isDirty() const { return !dirtyRect.IsEmpty(); }
45 45
46 // Reset update state for the current frame. This should occur before painti ng 46 // Reset update state for the current frame. This should occur before painti ng
47 // for all layers. Since painting one layer can invalidate another layer 47 // for all layers. Since painting one layer can invalidate another layer
48 // after it has already painted, mark all non-dirty tiles as valid before pa inting 48 // after it has already painted, mark all non-dirty tiles as valid before pa inting
49 // such that invalidations during painting won't prevent them from being pus hed. 49 // such that invalidations during painting won't prevent them from being pus hed.
50 void resetUpdateState() 50 void resetUpdateState()
51 { 51 {
52 updateRect = gfx::Rect(); 52 updateRect = gfx::Rect();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 std::vector<UpdatableTile*> invalidTiles; 198 std::vector<UpdatableTile*> invalidTiles;
199 199
200 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) { 200 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) {
201 int i = iter->first.first; 201 int i = iter->first.first;
202 int j = iter->first.second; 202 int j = iter->first.second;
203 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 203 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
204 // FIXME: This should not ever be null. 204 // FIXME: This should not ever be null.
205 if (!tile) 205 if (!tile)
206 continue; 206 continue;
207 207
208 if (!tile->managedTexture()->haveBackingTexture()) { 208 if (!tile->managedResource()->haveBackingTexture()) {
209 // Evicted tiles get deleted from both layers 209 // Evicted tiles get deleted from both layers
210 invalidTiles.push_back(tile); 210 invalidTiles.push_back(tile);
211 continue; 211 continue;
212 } 212 }
213 213
214 if (!tile->validForFrame) { 214 if (!tile->validForFrame) {
215 // Invalidated tiles are set so they can get different debug colors. 215 // Invalidated tiles are set so they can get different debug colors.
216 tiledLayer->pushInvalidTile(i, j); 216 tiledLayer->pushInvalidTile(i, j);
217 continue; 217 continue;
218 } 218 }
219 219
220 tiledLayer->pushTileProperties(i, j, tile->managedTexture()->resourceId( ), tile->opaqueRect(), tile->managedTexture()->contentsSwizzled()); 220 tiledLayer->pushTileProperties(i, j, tile->managedResource()->resourceId (), tile->opaqueRect(), tile->managedResource()->contentsSwizzled());
221 } 221 }
222 for (std::vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin() ; iter != invalidTiles.end(); ++iter) 222 for (std::vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin() ; iter != invalidTiles.end(); ++iter)
223 m_tiler->takeTile((*iter)->i(), (*iter)->j()); 223 m_tiler->takeTile((*iter)->i(), (*iter)->j());
224 } 224 }
225 225
226 PrioritizedTextureManager* TiledLayer::textureManager() const 226 PrioritizedResourceManager* TiledLayer::resourceManager() const
227 { 227 {
228 if (!layerTreeHost()) 228 if (!layerTreeHost())
229 return 0; 229 return 0;
230 return layerTreeHost()->contentsTextureManager(); 230 return layerTreeHost()->contentsTextureManager();
231 } 231 }
232 232
233 void TiledLayer::setLayerTreeHost(LayerTreeHost* host) 233 void TiledLayer::setLayerTreeHost(LayerTreeHost* host)
234 { 234 {
235 if (host && host != layerTreeHost()) { 235 if (host && host != layerTreeHost()) {
236 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be gin(); iter != m_tiler->tiles().end(); ++iter) { 236 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().be gin(); iter != m_tiler->tiles().end(); ++iter) {
237 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 237 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
238 // FIXME: This should not ever be null. 238 // FIXME: This should not ever be null.
239 if (!tile) 239 if (!tile)
240 continue; 240 continue;
241 tile->managedTexture()->setTextureManager(host->contentsTextureManag er()); 241 tile->managedResource()->setTextureManager(host->contentsTextureMana ger());
242 } 242 }
243 } 243 }
244 ContentsScalingLayer::setLayerTreeHost(host); 244 ContentsScalingLayer::setLayerTreeHost(host);
245 } 245 }
246 246
247 UpdatableTile* TiledLayer::tileAt(int i, int j) const 247 UpdatableTile* TiledLayer::tileAt(int i, int j) const
248 { 248 {
249 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j)); 249 return static_cast<UpdatableTile*>(m_tiler->tileAt(i, j));
250 } 250 }
251 251
252 UpdatableTile* TiledLayer::createTile(int i, int j) 252 UpdatableTile* TiledLayer::createTile(int i, int j)
253 { 253 {
254 createUpdaterIfNeeded(); 254 createUpdaterIfNeeded();
255 255
256 scoped_ptr<UpdatableTile> tile(UpdatableTile::create(updater()->createResour ce(textureManager()))); 256 scoped_ptr<UpdatableTile> tile(UpdatableTile::create(updater()->createResour ce(resourceManager())));
257 tile->managedTexture()->setDimensions(m_tiler->tileSize(), m_textureFormat); 257 tile->managedResource()->setDimensions(m_tiler->tileSize(), m_textureFormat) ;
258 258
259 UpdatableTile* addedTile = tile.get(); 259 UpdatableTile* addedTile = tile.get();
260 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j); 260 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j);
261 261
262 addedTile->dirtyRect = m_tiler->tileRect(addedTile); 262 addedTile->dirtyRect = m_tiler->tileRect(addedTile);
263 263
264 // Temporary diagnostic crash. 264 // Temporary diagnostic crash.
265 if (!addedTile) 265 if (!addedTile)
266 CRASH(); 266 CRASH();
267 if (!tileAt(i, j)) 267 if (!tileAt(i, j))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 continue; 304 continue;
305 gfx::Rect bound = m_tiler->tileRect(tile); 305 gfx::Rect bound = m_tiler->tileRect(tile);
306 bound.Intersect(contentRect); 306 bound.Intersect(contentRect);
307 tile->dirtyRect.Union(bound); 307 tile->dirtyRect.Union(bound);
308 } 308 }
309 } 309 }
310 310
311 // Returns true if tile is dirty and only part of it needs to be updated. 311 // Returns true if tile is dirty and only part of it needs to be updated.
312 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) 312 bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile)
313 { 313 {
314 return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedTe xture()->haveBackingTexture(); 314 return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedRe source()->haveBackingTexture();
315 } 315 }
316 316
317 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceU pdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, boo l& didPaint) 317 bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceU pdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, boo l& didPaint)
318 { 318 {
319 didPaint = false; 319 didPaint = false;
320 createUpdaterIfNeeded(); 320 createUpdaterIfNeeded();
321 321
322 bool ignoreOcclusions = !occlusion; 322 bool ignoreOcclusions = !occlusion;
323 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) { 323 if (!haveTexturesForTiles(left, top, right, bottom, ignoreOcclusions)) {
324 m_failedUpdate = true; 324 m_failedUpdate = true;
(...skipping 29 matching lines...) Expand all
354 DCHECK(tile); // Did setTexturePriorities get skipped? 354 DCHECK(tile); // Did setTexturePriorities get skipped?
355 // FIXME: This should not ever be null. 355 // FIXME: This should not ever be null.
356 if (!tile) 356 if (!tile)
357 continue; 357 continue;
358 DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are we doing more than one occlusion pass? 358 DCHECK(!tile->occluded); // Did resetUpdateState get skipped? Are we doing more than one occlusion pass?
359 gfx::Rect visibleTileRect = gfx::IntersectRects(m_tiler->tileBounds( i, j), visibleContentRect()); 359 gfx::Rect visibleTileRect = gfx::IntersectRects(m_tiler->tileBounds( i, j), visibleContentRect());
360 if (occlusion && occlusion->occluded(renderTarget(), visibleTileRect , drawTransform(), drawTransformIsAnimating(), drawableContentRect())) { 360 if (occlusion && occlusion->occluded(renderTarget(), visibleTileRect , drawTransform(), drawTransformIsAnimating(), drawableContentRect())) {
361 tile->occluded = true; 361 tile->occluded = true;
362 occludedTileCount++; 362 occludedTileCount++;
363 } else { 363 } else {
364 succeeded &= tile->managedTexture()->requestLate(); 364 succeeded &= tile->managedResource()->requestLate();
365 } 365 }
366 } 366 }
367 } 367 }
368 368
369 if (!succeeded) 369 if (!succeeded)
370 return; 370 return;
371 if (occlusion) 371 if (occlusion)
372 occlusion->overdrawMetrics().didCullTilesForUpload(occludedTileCount); 372 occlusion->overdrawMetrics().didCullTilesForUpload(occludedTileCount);
373 } 373 }
374 374
375 bool TiledLayer::haveTexturesForTiles(int left, int top, int right, int bottom, bool ignoreOcclusions) 375 bool TiledLayer::haveTexturesForTiles(int left, int top, int right, int bottom, bool ignoreOcclusions)
376 { 376 {
377 for (int j = top; j <= bottom; ++j) { 377 for (int j = top; j <= bottom; ++j) {
378 for (int i = left; i <= right; ++i) { 378 for (int i = left; i <= right; ++i) {
379 UpdatableTile* tile = tileAt(i, j); 379 UpdatableTile* tile = tileAt(i, j);
380 DCHECK(tile); // Did setTexturePriorites get skipped? 380 DCHECK(tile); // Did setTexturePriorites get skipped?
381 // FIXME: This should not ever be null. 381 // FIXME: This should not ever be null.
382 if (!tile) 382 if (!tile)
383 continue; 383 continue;
384 384
385 // Ensure the entire tile is dirty if we don't have the texture. 385 // Ensure the entire tile is dirty if we don't have the texture.
386 if (!tile->managedTexture()->haveBackingTexture()) 386 if (!tile->managedResource()->haveBackingTexture())
387 tile->dirtyRect = m_tiler->tileRect(tile); 387 tile->dirtyRect = m_tiler->tileRect(tile);
388 388
389 // If using occlusion and the visible region of the tile is occluded , 389 // If using occlusion and the visible region of the tile is occluded ,
390 // don't reserve a texture or update the tile. 390 // don't reserve a texture or update the tile.
391 if (tile->occluded && !ignoreOcclusions) 391 if (tile->occluded && !ignoreOcclusions)
392 continue; 392 continue;
393 393
394 if (!tile->managedTexture()->canAcquireBackingTexture()) 394 if (!tile->managedResource()->canAcquireBackingTexture())
395 return false; 395 return false;
396 } 396 }
397 } 397 }
398 return true; 398 return true;
399 } 399 }
400 400
401 gfx::Rect TiledLayer::markTilesForUpdate(int left, int top, int right, int botto m, bool ignoreOcclusions) 401 gfx::Rect TiledLayer::markTilesForUpdate(int left, int top, int right, int botto m, bool ignoreOcclusions)
402 { 402 {
403 gfx::Rect paintRect; 403 gfx::Rect paintRect;
404 for (int j = top; j <= bottom; ++j) { 404 for (int j = top; j <= bottom; ++j) {
405 for (int i = left; i <= right; ++i) { 405 for (int i = left; i <= right; ++i) {
406 UpdatableTile* tile = tileAt(i, j); 406 UpdatableTile* tile = tileAt(i, j);
407 DCHECK(tile); // Did setTexturePriorites get skipped? 407 DCHECK(tile); // Did setTexturePriorites get skipped?
408 // FIXME: This should not ever be null. 408 // FIXME: This should not ever be null.
409 if (!tile) 409 if (!tile)
410 continue; 410 continue;
411 if (tile->occluded && !ignoreOcclusions) 411 if (tile->occluded && !ignoreOcclusions)
412 continue; 412 continue;
413 // FIXME: Decide if partial update should be allowed based on cost 413 // FIXME: Decide if partial update should be allowed based on cost
414 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 414 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376
415 if (tile->isDirty() && layerTreeHost() && layerTreeHost()->bufferedU pdates()) { 415 if (tile->isDirty() && layerTreeHost() && layerTreeHost()->bufferedU pdates()) {
416 // If we get a partial update, we use the same texture, otherwis e return the 416 // If we get a partial update, we use the same texture, otherwis e return the
417 // current texture backing, so we don't update visible textures non-atomically. 417 // current texture backing, so we don't update visible textures non-atomically.
418 // If the current backing is in-use, it won't be deleted until a fter the commit 418 // If the current backing is in-use, it won't be deleted until a fter the commit
419 // as the texture manager will not allow deletion or recycling o f in-use textures. 419 // as the texture manager will not allow deletion or recycling o f in-use textures.
420 if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost()->request PartialTextureUpdate()) 420 if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost()->request PartialTextureUpdate())
421 tile->partialUpdate = true; 421 tile->partialUpdate = true;
422 else { 422 else {
423 tile->dirtyRect = m_tiler->tileRect(tile); 423 tile->dirtyRect = m_tiler->tileRect(tile);
424 tile->managedTexture()->returnBackingTexture(); 424 tile->managedResource()->returnBackingTexture();
425 } 425 }
426 } 426 }
427 427
428 paintRect.Union(tile->dirtyRect); 428 paintRect.Union(tile->dirtyRect);
429 tile->markForUpdate(); 429 tile->markForUpdate();
430 } 430 }
431 } 431 }
432 return paintRect; 432 return paintRect;
433 } 433 }
434 434
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 && contentRect.height() <= viewportSize.height() + 64; 529 && contentRect.height() <= viewportSize.height() + 64;
530 } 530 }
531 531
532 // FIXME: Remove this and make this based on distance once distance can be calcu lated 532 // FIXME: Remove this and make this based on distance once distance can be calcu lated
533 // for offscreen layers. For now, prioritize all small animated layers after 512 533 // for offscreen layers. For now, prioritize all small animated layers after 512
534 // pixels of pre-painting. 534 // pixels of pre-painting.
535 void setPriorityForTexture(const gfx::Rect& visibleRect, 535 void setPriorityForTexture(const gfx::Rect& visibleRect,
536 const gfx::Rect& tileRect, 536 const gfx::Rect& tileRect,
537 bool drawsToRoot, 537 bool drawsToRoot,
538 bool isSmallAnimatedLayer, 538 bool isSmallAnimatedLayer,
539 PrioritizedTexture* texture) 539 PrioritizedResource* texture)
540 { 540 {
541 int priority = PriorityCalculator::lowestPriority(); 541 int priority = PriorityCalculator::lowestPriority();
542 if (!visibleRect.IsEmpty()) 542 if (!visibleRect.IsEmpty())
543 priority = PriorityCalculator::priorityFromDistance(visibleRect, tileRec t, drawsToRoot); 543 priority = PriorityCalculator::priorityFromDistance(visibleRect, tileRec t, drawsToRoot);
544 if (isSmallAnimatedLayer) 544 if (isSmallAnimatedLayer)
545 priority = PriorityCalculator::maxPriority(priority, PriorityCalculator: :smallAnimatedLayerMinPriority()); 545 priority = PriorityCalculator::maxPriority(priority, PriorityCalculator: :smallAnimatedLayerMinPriority());
546 if (priority != PriorityCalculator::lowestPriority()) 546 if (priority != PriorityCalculator::lowestPriority())
547 texture->setRequestPriority(priority); 547 texture->setRequestPriority(priority);
548 } 548 }
549 } 549 }
(...skipping 25 matching lines...) Expand all
575 } 575 }
576 } 576 }
577 577
578 // Now update priorities on all tiles we have in the layer, no matter where they are. 578 // Now update priorities on all tiles we have in the layer, no matter where they are.
579 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) { 579 for (LayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin( ); iter != m_tiler->tiles().end(); ++iter) {
580 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 580 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
581 // FIXME: This should not ever be null. 581 // FIXME: This should not ever be null.
582 if (!tile) 582 if (!tile)
583 continue; 583 continue;
584 gfx::Rect tileRect = m_tiler->tileRect(tile); 584 gfx::Rect tileRect = m_tiler->tileRect(tile);
585 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma llAnimatedLayer, tile->managedTexture()); 585 setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, sma llAnimatedLayer, tile->managedResource());
586 } 586 }
587 } 587 }
588 588
589 Region TiledLayer::visibleContentOpaqueRegion() const 589 Region TiledLayer::visibleContentOpaqueRegion() const
590 { 590 {
591 if (m_skipsDraw) 591 if (m_skipsDraw)
592 return Region(); 592 return Region();
593 if (contentsOpaque()) 593 if (contentsOpaque())
594 return visibleContentRect(); 594 return visibleContentRect();
595 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); 595 return m_tiler->opaqueRegionInContentRect(visibleContentRect());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo ttom); 752 m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bo ttom);
753 753
754 for (int j = top; j <= bottom; ++j) { 754 for (int j = top; j <= bottom; ++j) {
755 for (int i = left; i <= right; ++i) { 755 for (int i = left; i <= right; ++i) {
756 UpdatableTile* tile = tileAt(i, j); 756 UpdatableTile* tile = tileAt(i, j);
757 DCHECK(tile); // Did setTexturePriorities get skipped? 757 DCHECK(tile); // Did setTexturePriorities get skipped?
758 if (!tile) 758 if (!tile)
759 continue; 759 continue;
760 760
761 bool updated = !tile->updateRect.IsEmpty(); 761 bool updated = !tile->updateRect.IsEmpty();
762 bool canAcquire = tile->managedTexture()->canAcquireBackingTexture() ; 762 bool canAcquire = tile->managedResource()->canAcquireBackingTexture( );
763 bool dirty = tile->isDirty() || !tile->managedTexture()->haveBacking Texture(); 763 bool dirty = tile->isDirty() || !tile->managedResource()->haveBackin gTexture();
764 if (!updated && canAcquire && dirty) 764 if (!updated && canAcquire && dirty)
765 return true; 765 return true;
766 } 766 }
767 } 767 }
768 return false; 768 return false;
769 } 769 }
770 770
771 gfx::Rect TiledLayer::idlePaintRect() 771 gfx::Rect TiledLayer::idlePaintRect()
772 { 772 {
773 // Don't inflate an empty rect. 773 // Don't inflate an empty rect.
774 if (visibleContentRect().IsEmpty()) 774 if (visibleContentRect().IsEmpty())
775 return gfx::Rect(); 775 return gfx::Rect();
776 776
777 gfx::Rect prepaintRect = visibleContentRect(); 777 gfx::Rect prepaintRect = visibleContentRect();
778 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns, 778 prepaintRect.Inset(-m_tiler->tileSize().width() * prepaintColumns,
779 -m_tiler->tileSize().height() * prepaintRows); 779 -m_tiler->tileSize().height() * prepaintRows);
780 gfx::Rect contentRect(gfx::Point(), contentBounds()); 780 gfx::Rect contentRect(gfx::Point(), contentBounds());
781 prepaintRect.Intersect(contentRect); 781 prepaintRect.Intersect(contentRect);
782 782
783 return prepaintRect; 783 return prepaintRect;
784 } 784 }
785 785
786 } // namespace cc 786 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiled_layer.h ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698