Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index ec2195523535e021af715e04b9532ef5f3ddfcf6..63a9241f60ec950f3d8bbed87e9aaa3b045b31de 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -135,6 +135,13 @@ struct DeviceCM { |
SkDELETE(fPaint); |
} |
+ void reset(const SkIRect& bounds) { |
+ SkASSERT(!fPaint); |
+ SkASSERT(!fNext); |
+ SkASSERT(fDevice); |
+ fClip.setRect(bounds); |
+ } |
+ |
void updateMC(const SkMatrix& totalMatrix, const SkRasterClip& totalClip, |
const SkClipStack& clipStack, SkRasterClip* updateClip) { |
int x = fDevice->getOrigin().x(); |
@@ -224,6 +231,15 @@ public: |
SkDELETE(fLayer); |
dec_rec(); |
} |
+ |
+ void reset(const SkIRect& bounds) { |
+ SkASSERT(fLayer); |
+ SkASSERT(fDeferredSaveCount == 0); |
+ |
+ fMatrix.reset(); |
+ fRasterClip.setRect(bounds); |
+ fLayer->reset(bounds); |
+ } |
}; |
class SkDrawIter : public SkDraw { |
@@ -425,6 +441,18 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { |
//////////////////////////////////////////////////////////////////////////// |
+void SkCanvas::resetForNextPicture(const SkIRect& bounds) { |
+ this->restoreToCount(1); |
+ fCachedLocalClipBounds.setEmpty(); |
+ fCachedLocalClipBoundsDirty = true; |
+ fClipStack->reset(); |
+ fMCRec->reset(bounds); |
+ |
+ // We're peering through a lot of structs here. Only at this scope do we |
+ // know that the device is an SkBitmapDevice (really an SkNoPixelsBitmapDevice). |
+ static_cast<SkBitmapDevice*>(fMCRec->fLayer->fDevice)->setNewSize(bounds.size()); |
+} |
+ |
SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag); |
fCachedLocalClipBounds.setEmpty(); |