| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 460 // so we grab a local reference here to hold the updater alive until the pai
nt completes. | 460 // so we grab a local reference here to hold the updater alive until the pai
nt completes. |
| 461 scoped_refptr<LayerUpdater> protector(updater()); | 461 scoped_refptr<LayerUpdater> protector(updater()); |
| 462 IntRect paintedOpaqueRect; | 462 gfx::Rect paintedOpaqueRect; |
| 463 updater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1
/ heightScale, paintedOpaqueRect, stats); | 463 updater()->prepareToUpdate(paintRect, m_tiler->tileSize(), 1 / widthScale, 1
/ heightScale, paintedOpaqueRect, stats); |
| 464 | 464 |
| 465 for (int j = top; j <= bottom; ++j) { | 465 for (int j = top; j <= bottom; ++j) { |
| 466 for (int i = left; i <= right; ++i) { | 466 for (int i = left; i <= right; ++i) { |
| 467 UpdatableTile* tile = tileAt(i, j); | 467 UpdatableTile* tile = tileAt(i, j); |
| 468 DCHECK(tile); // Did setTexturePriorites get skipped? | 468 DCHECK(tile); // Did setTexturePriorites get skipped? |
| 469 // FIXME: This should not ever be null. | 469 // FIXME: This should not ever be null. |
| 470 if (!tile) | 470 if (!tile) |
| 471 continue; | 471 continue; |
| 472 | 472 |
| 473 IntRect tileRect = m_tiler->tileBounds(i, j); | 473 IntRect tileRect = m_tiler->tileBounds(i, j); |
| 474 | 474 |
| 475 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. | 475 // Use updateRect as the above loop copied the dirty rect for this f
rame to updateRect. |
| 476 const IntRect& dirtyRect = tile->updateRect; | 476 const IntRect& dirtyRect = tile->updateRect; |
| 477 if (dirtyRect.isEmpty()) | 477 if (dirtyRect.isEmpty()) |
| 478 continue; | 478 continue; |
| 479 | 479 |
| 480 // Save what was painted opaque in the tile. Keep the old area if th
e paint didn't touch it, and didn't paint some | 480 // Save what was painted opaque in the tile. Keep the old area if th
e paint didn't touch it, and didn't paint some |
| 481 // other part of the tile opaque. | 481 // other part of the tile opaque. |
| 482 IntRect tilePaintedRect = intersection(tileRect, paintRect); | 482 IntRect tilePaintedRect = intersection(tileRect, paintRect); |
| 483 IntRect tilePaintedOpaqueRect = intersection(tileRect, paintedOpaque
Rect); | 483 IntRect tilePaintedOpaqueRect = intersection(tileRect, cc::IntRect(p
aintedOpaqueRect)); |
| 484 if (!tilePaintedRect.isEmpty()) { | 484 if (!tilePaintedRect.isEmpty()) { |
| 485 IntRect paintInsideTileOpaqueRect = intersection(tile->opaqueRec
t(), tilePaintedRect); | 485 IntRect paintInsideTileOpaqueRect = intersection(tile->opaqueRec
t(), tilePaintedRect); |
| 486 bool paintInsideTileOpaqueRectIsNonOpaque = !tilePaintedOpaqueRe
ct.contains(paintInsideTileOpaqueRect); | 486 bool paintInsideTileOpaqueRectIsNonOpaque = !tilePaintedOpaqueRe
ct.contains(paintInsideTileOpaqueRect); |
| 487 bool opaquePaintNotInsideTileOpaqueRect = !tilePaintedOpaqueRect
.isEmpty() && !tile->opaqueRect().contains(tilePaintedOpaqueRect); | 487 bool opaquePaintNotInsideTileOpaqueRect = !tilePaintedOpaqueRect
.isEmpty() && !tile->opaqueRect().contains(tilePaintedOpaqueRect); |
| 488 | 488 |
| 489 if (paintInsideTileOpaqueRectIsNonOpaque || opaquePaintNotInside
TileOpaqueRect) | 489 if (paintInsideTileOpaqueRectIsNonOpaque || opaquePaintNotInside
TileOpaqueRect) |
| 490 tile->setOpaqueRect(tilePaintedOpaqueRect); | 490 tile->setOpaqueRect(tilePaintedOpaqueRect); |
| 491 } | 491 } |
| 492 | 492 |
| 493 // sourceRect starts as a full-sized tile with border texels include
d. | 493 // sourceRect starts as a full-sized tile with border texels include
d. |
| 494 IntRect sourceRect = m_tiler->tileRect(tile); | 494 IntRect sourceRect = m_tiler->tileRect(tile); |
| 495 sourceRect.intersect(dirtyRect); | 495 sourceRect.intersect(dirtyRect); |
| 496 // Paint rect not guaranteed to line up on tile boundaries, so | 496 // Paint rect not guaranteed to line up on tile boundaries, so |
| 497 // make sure that sourceRect doesn't extend outside of it. | 497 // make sure that sourceRect doesn't extend outside of it. |
| 498 sourceRect.intersect(paintRect); | 498 sourceRect.intersect(paintRect); |
| 499 | 499 |
| 500 tile->updateRect = sourceRect; | 500 tile->updateRect = sourceRect; |
| 501 | 501 |
| 502 if (sourceRect.isEmpty()) | 502 if (sourceRect.isEmpty()) |
| 503 continue; | 503 continue; |
| 504 | 504 |
| 505 const IntPoint anchor = m_tiler->tileRect(tile).location(); | 505 const IntPoint anchor = m_tiler->tileRect(tile).location(); |
| 506 | 506 |
| 507 // Calculate tile-space rectangle to upload into. | 507 // Calculate tile-space rectangle to upload into. |
| 508 IntSize destOffset(sourceRect.x() - anchor.x(), sourceRect.y() - anc
hor.y()); | 508 gfx::Vector2d destOffset(sourceRect.x() - anchor.x(), sourceRect.y()
- anchor.y()); |
| 509 if (destOffset.width() < 0) | 509 if (destOffset.x() < 0) |
| 510 CRASH(); | 510 CRASH(); |
| 511 if (destOffset.height() < 0) | 511 if (destOffset.y() < 0) |
| 512 CRASH(); | 512 CRASH(); |
| 513 | 513 |
| 514 // Offset from paint rectangle to this tile's dirty rectangle. | 514 // Offset from paint rectangle to this tile's dirty rectangle. |
| 515 IntPoint paintOffset(sourceRect.x() - paintRect.x(), sourceRect.y()
- paintRect.y()); | 515 gfx::Vector2d paintOffset(sourceRect.x() - paintRect.x(), sourceRect
.y() - paintRect.y()); |
| 516 if (paintOffset.x() < 0) | 516 if (paintOffset.x() < 0) |
| 517 CRASH(); | 517 CRASH(); |
| 518 if (paintOffset.y() < 0) | 518 if (paintOffset.y() < 0) |
| 519 CRASH(); | 519 CRASH(); |
| 520 if (paintOffset.x() + sourceRect.width() > paintRect.width()) | 520 if (paintOffset.x() + sourceRect.width() > paintRect.width()) |
| 521 CRASH(); | 521 CRASH(); |
| 522 if (paintOffset.y() + sourceRect.height() > paintRect.height()) | 522 if (paintOffset.y() + sourceRect.height() > paintRect.height()) |
| 523 CRASH(); | 523 CRASH(); |
| 524 | 524 |
| 525 tile->updaterResource()->update(queue, sourceRect, destOffset, tile-
>partialUpdate, stats); | 525 tile->updaterResource()->update(queue, sourceRect, destOffset, tile-
>partialUpdate, stats); |
| (...skipping 266 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 |