Chromium Code Reviews| Index: src/image/SkSurface.cpp |
| =================================================================== |
| --- src/image/SkSurface.cpp (revision 8683) |
| +++ src/image/SkSurface.cpp (working copy) |
| @@ -59,28 +59,30 @@ |
| return fCachedImage; |
| } |
| -void SkSurface_Base::aboutToDraw(SkCanvas* canvas) { |
| +void SkSurface_Base::aboutToDraw() { |
| this->dirtyGenerationID(); |
|
reed1
2013/04/15 18:56:33
How do we know that fCachedCanvas is always presen
Justin Novosad
2013/04/15 19:08:57
Done.
|
| - if (canvas) { |
| - SkASSERT(canvas == fCachedCanvas); |
| - SkASSERT(canvas->getSurfaceBase() == this); |
| - canvas->setSurfaceBase(NULL); |
| + if (NULL == fCachedCanvas->getSurfaceBase()) { |
| + // getSurfaceBase will be non-NULL if there are SkImages |
|
reed1
2013/04/15 18:56:33
Why is this test more robust than just checking fC
Justin Novosad
2013/04/15 19:08:57
Done.
|
| + // referencing the canvas backingstore |
| + return; |
| } |
| - if (fCachedImage) { |
| - // the surface may need to fork its backend, if its sharing it with |
| - // the cached image. Note: we only call if there is an outstanding owner |
| - // on the image (besides us). |
| - if (fCachedImage->getRefCnt() > 1) { |
| - this->onCopyOnWrite(fCachedImage, canvas); |
| - } |
| + SkASSERT(NULL != fCachedImage); |
| + SkASSERT(fCachedCanvas->getSurfaceBase() == this); |
| + fCachedCanvas->setSurfaceBase(NULL); |
| - // regardless of copy-on-write, we must drop our cached image now, so |
| - // that the next request will get our new contents. |
| - fCachedImage->unref(); |
| - fCachedImage = NULL; |
| + // the surface may need to fork its backend, if its sharing it with |
| + // the cached image. Note: we only call if there is an outstanding owner |
| + // on the image (besides us). |
| + if (fCachedImage->getRefCnt() > 1) { |
| + this->onCopyOnWrite(); |
| } |
| + |
| + // regardless of copy-on-write, we must drop our cached image now, so |
| + // that the next request will get our new contents. |
| + fCachedImage->unref(); |
| + fCachedImage = NULL; |
| } |
| uint32_t SkSurface_Base::newGenerationID() { |
| @@ -110,7 +112,7 @@ |
| } |
| void SkSurface::notifyContentChanged() { |
| - asSB(this)->aboutToDraw(NULL); |
| + asSB(this)->aboutToDraw(); |
| } |
| SkCanvas* SkSurface::getCanvas() { |