| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 LayerTextureUpdater::Texture* texture() { return m_texture.get(); } | 58 LayerTextureUpdater::Texture* texture() { return m_texture.get(); } |
| 59 ManagedTexture* managedTexture() { return m_texture->texture(); } | 59 ManagedTexture* managedTexture() { return m_texture->texture(); } |
| 60 | 60 |
| 61 bool isDirty() const { return !m_dirtyRect.isEmpty(); } | 61 bool isDirty() const { return !m_dirtyRect.isEmpty(); } |
| 62 void copyAndClearDirty() | 62 void copyAndClearDirty() |
| 63 { | 63 { |
| 64 m_updateRect = m_dirtyRect; | 64 m_updateRect = m_dirtyRect; |
| 65 m_dirtyRect = IntRect(); | 65 m_dirtyRect = IntRect(); |
| 66 } | 66 } |
| 67 bool isDirtyForCurrentFrame() { return !m_dirtyRect.isEmpty() && m_updateRec
t.isEmpty(); } |
| 67 | 68 |
| 68 IntRect m_dirtyRect; | 69 IntRect m_dirtyRect; |
| 69 IntRect m_updateRect; | 70 IntRect m_updateRect; |
| 70 IntRect m_opaqueRect; | 71 IntRect m_opaqueRect; |
| 71 private: | 72 private: |
| 72 OwnPtr<LayerTextureUpdater::Texture> m_texture; | 73 OwnPtr<LayerTextureUpdater::Texture> m_texture; |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 TiledLayerChromium::TiledLayerChromium() | 76 TiledLayerChromium::TiledLayerChromium() |
| 76 : LayerChromium() | 77 : LayerChromium() |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 Vector<UpdatableTile*> invalidTiles; | 268 Vector<UpdatableTile*> invalidTiles; |
| 268 | 269 |
| 269 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { | 270 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { |
| 270 int i = iter->first.first; | 271 int i = iter->first.first; |
| 271 int j = iter->first.second; | 272 int j = iter->first.second; |
| 272 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); | 273 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); |
| 273 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureForma
t)) { | 274 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureForma
t)) { |
| 274 invalidTiles.append(tile); | 275 invalidTiles.append(tile); |
| 275 continue; | 276 continue; |
| 276 } | 277 } |
| 277 if (tile->isDirty()) | 278 if (tile->isDirtyForCurrentFrame()) |
| 278 continue; | 279 continue; |
| 279 | 280 |
| 280 tiledLayer->pushTileProperties(i, j, tile->managedTexture()->textureId()
, tile->m_opaqueRect); | 281 tiledLayer->pushTileProperties(i, j, tile->managedTexture()->textureId()
, tile->m_opaqueRect); |
| 281 } | 282 } |
| 282 for (Vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin(); ite
r != invalidTiles.end(); ++iter) | 283 for (Vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin(); ite
r != invalidTiles.end(); ++iter) |
| 283 m_tiler->takeTile((*iter)->i(), (*iter)->j()); | 284 m_tiler->takeTile((*iter)->i(), (*iter)->j()); |
| 284 } | 285 } |
| 285 | 286 |
| 286 TextureManager* TiledLayerChromium::textureManager() const | 287 TextureManager* TiledLayerChromium::textureManager() const |
| 287 { | 288 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m
_textureFormat)) | 359 if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m
_textureFormat)) |
| 359 continue; | 360 continue; |
| 360 | 361 |
| 361 tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat
); | 362 tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat
); |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 } | 365 } |
| 365 | 366 |
| 366 void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
right, int bottom) | 367 void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
right, int bottom) |
| 367 { | 368 { |
| 368 // Reset m_updateRect for all tiles. | |
| 369 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != m_tiler->tiles().end(); ++iter) { | |
| 370 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); | |
| 371 tile->m_updateRect = IntRect(); | |
| 372 } | |
| 373 | |
| 374 // Create tiles as needed, expanding a dirty rect to contain all | 369 // Create tiles as needed, expanding a dirty rect to contain all |
| 375 // the dirty regions currently being drawn. All dirty tiles that are to be p
ainted | 370 // the dirty regions currently being drawn. All dirty tiles that are to be p
ainted |
| 376 // get their m_updateRect set to m_dirtyRect and m_dirtyRect cleared. This w
ay if | 371 // get their m_updateRect set to m_dirtyRect and m_dirtyRect cleared. This w
ay if |
| 377 // invalidateRect is invoked during prepareToUpdate we don't lose the reques
t. | 372 // invalidateRect is invoked during prepareToUpdate we don't lose the reques
t. |
| 378 IntRect dirtyLayerRect; | 373 IntRect dirtyLayerRect; |
| 379 for (int j = top; j <= bottom; ++j) { | 374 for (int j = top; j <= bottom; ++j) { |
| 380 for (int i = left; i <= right; ++i) { | 375 for (int i = left; i <= right; ++i) { |
| 381 UpdatableTile* tile = tileAt(i, j); | 376 UpdatableTile* tile = tileAt(i, j); |
| 382 if (!tile) | 377 if (!tile) |
| 383 tile = createTile(i, j); | 378 tile = createTile(i, j); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 476 |
| 482 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureF
ormat)) | 477 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureF
ormat)) |
| 483 tile->m_dirtyRect = m_tiler->tileRect(tile); | 478 tile->m_dirtyRect = m_tiler->tileRect(tile); |
| 484 | 479 |
| 485 if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureF
ormat)) | 480 if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureF
ormat)) |
| 486 return; | 481 return; |
| 487 } | 482 } |
| 488 } | 483 } |
| 489 } | 484 } |
| 490 | 485 |
| 486 void TiledLayerChromium::resetUpdateState() |
| 487 { |
| 488 // Reset m_updateRect for all tiles. |
| 489 CCLayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); |
| 490 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begi
n(); iter != end; ++iter) { |
| 491 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); |
| 492 tile->m_updateRect = IntRect(); |
| 493 } |
| 494 } |
| 495 |
| 491 void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) | 496 void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) |
| 492 { | 497 { |
| 493 m_skipsDraw = false; | 498 m_skipsDraw = false; |
| 494 m_skipsIdlePaint = false; | 499 m_skipsIdlePaint = false; |
| 495 m_requestedUpdateTilesRect = IntRect(); | 500 m_requestedUpdateTilesRect = IntRect(); |
| 496 m_paintRect = IntRect(); | 501 m_paintRect = IntRect(); |
| 497 | 502 |
| 498 updateBounds(); | 503 updateBounds(); |
| 499 | 504 |
| 505 resetUpdateState(); |
| 506 |
| 500 if (layerRect.isEmpty() || !m_tiler->numTiles()) | 507 if (layerRect.isEmpty() || !m_tiler->numTiles()) |
| 501 return; | 508 return; |
| 502 | 509 |
| 503 int left, top, right, bottom; | 510 int left, top, right, bottom; |
| 504 m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); | 511 m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); |
| 505 | 512 |
| 506 prepareToUpdateTiles(false, left, top, right, bottom); | 513 prepareToUpdateTiles(false, left, top, right, bottom); |
| 507 } | 514 } |
| 508 | 515 |
| 509 void TiledLayerChromium::prepareToUpdateIdle(const IntRect& layerRect) | 516 void TiledLayerChromium::prepareToUpdateIdle(const IntRect& layerRect) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // - only reserve idle paint tiles up to a memory reclaim threshold and | 593 // - only reserve idle paint tiles up to a memory reclaim threshold and |
| 587 // - insure we play nicely with other layers | 594 // - insure we play nicely with other layers |
| 588 prepaintRect.inflateX(m_tiler->tileSize().width()); | 595 prepaintRect.inflateX(m_tiler->tileSize().width()); |
| 589 prepaintRect.inflateY(m_tiler->tileSize().height()); | 596 prepaintRect.inflateY(m_tiler->tileSize().height()); |
| 590 prepaintRect.intersect(IntRect(IntPoint::zero(), contentBounds())); | 597 prepaintRect.intersect(IntRect(IntPoint::zero(), contentBounds())); |
| 591 return prepaintRect; | 598 return prepaintRect; |
| 592 } | 599 } |
| 593 | 600 |
| 594 } | 601 } |
| 595 #endif // USE(ACCELERATED_COMPOSITING) | 602 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |