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

Unified Diff: src/core/SkCanvas.cpp

Issue 1067893002: SkCanvas::resetForNextPicture() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Return null when we're not recording. Should fix printing failures. Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/core/SkBitmapDevice.cpp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698