aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBBoxHierarchyRecord.cpp4
-rw-r--r--src/core/SkBBoxHierarchyRecord.h2
-rw-r--r--src/core/SkCanvas.cpp46
-rw-r--r--src/core/SkMatrixClipStateMgr.cpp16
-rw-r--r--src/core/SkMatrixClipStateMgr.h22
-rw-r--r--src/core/SkPicturePlayback.cpp7
-rw-r--r--src/core/SkPictureRecord.cpp24
-rw-r--r--src/core/SkPictureRecord.h4
-rw-r--r--src/core/SkRecordDraw.cpp2
-rw-r--r--src/core/SkRecordOpts.cpp5
-rw-r--r--src/core/SkRecorder.cpp6
-rw-r--r--src/core/SkRecorder.h2
-rw-r--r--src/core/SkRecords.h2
13 files changed, 52 insertions, 90 deletions
diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp
index 96e6cdf102..1868e65325 100644
--- a/src/core/SkBBoxHierarchyRecord.cpp
+++ b/src/core/SkBBoxHierarchyRecord.cpp
@@ -26,9 +26,9 @@ void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) {
fBoundingHierarchy->insert(draw, r, true);
}
-void SkBBoxHierarchyRecord::willSave(SaveFlags flags) {
+void SkBBoxHierarchyRecord::willSave() {
fStateTree->appendSave();
- this->INHERITED::willSave(flags);
+ this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* bounds,
diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h
index ba7d514bc5..7db82d8369 100644
--- a/src/core/SkBBoxHierarchyRecord.h
+++ b/src/core/SkBBoxHierarchyRecord.h
@@ -28,7 +28,7 @@ public:
virtual bool shouldRewind(void* data) SK_OVERRIDE;
protected:
- virtual void willSave(SaveFlags) SK_OVERRIDE;
+ virtual void willSave() SK_OVERRIDE;
virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
virtual void willRestore() SK_OVERRIDE;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 2fb5c95124..c35f284432 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -189,7 +189,6 @@ private:
*/
class SkCanvas::MCRec {
public:
- int fFlags;
SkMatrix* fMatrix; // points to either fMatrixStorage or prev MCRec
SkRasterClip* fRasterClip; // points to either fRegionStorage or prev MCRec
SkDrawFilter* fFilter; // the current filter (or null)
@@ -203,21 +202,13 @@ public:
*/
DeviceCM* fTopLayer;
- MCRec(const MCRec* prev, int flags) : fFlags(flags) {
+ MCRec(const MCRec* prev) {
if (NULL != prev) {
- if (flags & SkCanvas::kMatrix_SaveFlag) {
- fMatrixStorage = *prev->fMatrix;
- fMatrix = &fMatrixStorage;
- } else {
- fMatrix = prev->fMatrix;
- }
+ fMatrixStorage = *prev->fMatrix;
+ fMatrix = &fMatrixStorage;
- if (flags & SkCanvas::kClip_SaveFlag) {
- fRasterClipStorage = *prev->fRasterClip;
- fRasterClip = &fRasterClipStorage;
- } else {
- fRasterClip = prev->fRasterClip;
- }
+ fRasterClipStorage = *prev->fRasterClip;
+ fRasterClip = &fRasterClipStorage;
fFilter = prev->fFilter;
SkSafeRef(fFilter);
@@ -449,7 +440,7 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device) {
fMetaData = NULL;
fMCRec = (MCRec*)fMCStack.push_back();
- new (fMCRec) MCRec(NULL, 0);
+ new (fMCRec) MCRec(NULL);
fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL));
fMCRec->fTopLayer = fMCRec->fLayer;
@@ -786,30 +777,21 @@ void SkCanvas::updateDeviceCMCache() {
///////////////////////////////////////////////////////////////////////////////
-int SkCanvas::internalSave(SaveFlags flags) {
+int SkCanvas::internalSave() {
int saveCount = this->getSaveCount(); // record this before the actual save
MCRec* newTop = (MCRec*)fMCStack.push_back();
- new (newTop) MCRec(fMCRec, flags); // balanced in restore()
-
+ new (newTop) MCRec(fMCRec); // balanced in restore()
fMCRec = newTop;
- if (SkCanvas::kClip_SaveFlag & flags) {
- fClipStack.save();
- }
+ fClipStack.save();
return saveCount;
}
int SkCanvas::save() {
- this->willSave(kMatrixClip_SaveFlag);
- return this->internalSave(kMatrixClip_SaveFlag);
-}
-
-int SkCanvas::save(SaveFlags flags) {
- this->willSave(flags);
- // call shared impl
- return this->internalSave(flags);
+ this->willSave();
+ return this->internalSave();
}
static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
@@ -889,7 +871,7 @@ int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Save
// do this before we create the layer. We don't call the public save() since
// that would invoke a possibly overridden virtual
- int count = this->internalSave(flags);
+ int count = this->internalSave();
fDeviceCMDirty = true;
@@ -974,9 +956,7 @@ void SkCanvas::internalRestore() {
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- if (SkCanvas::kClip_SaveFlag & fMCRec->fFlags) {
- fClipStack.restore();
- }
+ fClipStack.restore();
// reserve our layer (if any)
DeviceCM* layer = fMCRec->fLayer; // may be null
diff --git a/src/core/SkMatrixClipStateMgr.cpp b/src/core/SkMatrixClipStateMgr.cpp
index 1fc7fe8321..680cc364d2 100644
--- a/src/core/SkMatrixClipStateMgr.cpp
+++ b/src/core/SkMatrixClipStateMgr.cpp
@@ -110,7 +110,7 @@ SkMatrixClipStateMgr::SkMatrixClipStateMgr()
fMatrixDict.append()->reset();
fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back();
- new (fCurMCState) MatrixClipState(NULL, 0); // balanced in restore()
+ new (fCurMCState) MatrixClipState(NULL); // balanced in restore()
#ifdef SK_DEBUG
fActualDepth = 0;
@@ -126,9 +126,9 @@ SkMatrixClipStateMgr::~SkMatrixClipStateMgr() {
}
-int SkMatrixClipStateMgr::MCStackPush(SkCanvas::SaveFlags flags) {
+int SkMatrixClipStateMgr::MCStackPush() {
MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back();
- new (newTop) MatrixClipState(fCurMCState, flags); // balanced in restore()
+ new (newTop) MatrixClipState(fCurMCState); // balanced in restore()
fCurMCState = newTop;
SkDEBUGCODE(this->validate();)
@@ -136,10 +136,10 @@ int SkMatrixClipStateMgr::MCStackPush(SkCanvas::SaveFlags flags) {
return fMatrixClipStack.count();
}
-int SkMatrixClipStateMgr::save(SkCanvas::SaveFlags flags) {
+int SkMatrixClipStateMgr::save() {
SkDEBUGCODE(this->validate();)
- return this->MCStackPush(flags);
+ return this->MCStackPush();
}
int SkMatrixClipStateMgr::saveLayer(const SkRect* bounds, const SkPaint* paint,
@@ -154,7 +154,7 @@ int SkMatrixClipStateMgr::saveLayer(const SkRect* bounds, const SkPaint* paint,
// out the MC state
SkDEBUGCODE(bool saved =) this->call(kOther_CallType);
- int result = this->MCStackPush(flags);
+ int result = this->MCStackPush();
++fCurMCState->fLayerID;
fCurMCState->fIsSaveLayer = true;
@@ -172,7 +172,7 @@ int SkMatrixClipStateMgr::saveLayer(const SkRect* bounds, const SkPaint* paint,
// restore
fSkipOffsets = SkNEW(SkTDArray<int>);
- fPicRecord->recordSaveLayer(bounds, paint, flags | SkCanvas::kMatrixClip_SaveFlag);
+ fPicRecord->recordSaveLayer(bounds, paint, flags);
#ifdef SK_DEBUG
fActualDepth++;
#endif
@@ -289,7 +289,7 @@ bool SkMatrixClipStateMgr::call(CallType callType) {
SkASSERT(!fCurMCState->fHasOpen);
SkASSERT(0 == fSkipOffsets->count());
fCurMCState->fHasOpen = true;
- fPicRecord->recordSave(SkCanvas::kMatrixClip_SaveFlag);
+ fPicRecord->recordSave();
#ifdef SK_DEBUG
fActualDepth++;
SkASSERT(fActualDepth == fCurMCState->fExpectedDepth);
diff --git a/src/core/SkMatrixClipStateMgr.h b/src/core/SkMatrixClipStateMgr.h
index 016baa008a..9a80b0154e 100644
--- a/src/core/SkMatrixClipStateMgr.h
+++ b/src/core/SkMatrixClipStateMgr.h
@@ -181,7 +181,7 @@ public:
typedef SkNoncopyable INHERITED;
};
- MatrixClipState(MatrixClipState* prev, int flags)
+ MatrixClipState(MatrixClipState* prev)
: fPrev(prev)
{
fHasOpen = false;
@@ -202,19 +202,11 @@ public:
else {
fLayerID = prev->fLayerID;
- if (flags & SkCanvas::kMatrix_SaveFlag) {
- fMatrixInfoStorage = *prev->fMatrixInfo;
- fMatrixInfo = &fMatrixInfoStorage;
- } else {
- fMatrixInfo = prev->fMatrixInfo;
- }
+ fMatrixInfoStorage = *prev->fMatrixInfo;
+ fMatrixInfo = &fMatrixInfoStorage;
- if (flags & SkCanvas::kClip_SaveFlag) {
- // We don't copy the ClipOps of the previous clip states
- fClipInfo = &fClipInfoStorage;
- } else {
- fClipInfo = prev->fClipInfo;
- }
+ // We don't copy the ClipOps of the previous clip states
+ fClipInfo = &fClipInfoStorage;
// Initially a new save/saveLayer represents the same MC state
// as its predecessor.
@@ -275,7 +267,7 @@ public:
// this duplicates effort.
int getSaveCount() const { return fMatrixClipStack.count(); }
- int save(SkCanvas::SaveFlags flags);
+ int save();
int saveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlags flags);
@@ -372,7 +364,7 @@ protected:
SkDEBUGCODE(void validate();)
- int MCStackPush(SkCanvas::SaveFlags flags);
+ int MCStackPush();
void addClipOffset(size_t offset) {
SkASSERT(NULL != fSkipOffsets);
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 148237a5a8..35e66bb7eb 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -1307,7 +1307,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
canvas.rotate(reader.readScalar());
break;
case SAVE:
- canvas.save((SkCanvas::SaveFlags) reader.readInt());
+ // SKPs with version < 29 also store a SaveFlags param.
+ if (size > 4) {
+ SkASSERT(8 == size);
+ reader.readInt();
+ }
+ canvas.save();
break;
case SAVE_LAYER: {
const SkRect* boundsPtr = this->getRectPtr(reader);
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 16856d639d..566cb196ba 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -32,7 +32,7 @@ enum {
// A lot of basic types get stored as a uint32_t: bools, ints, paint indices, etc.
static int const kUInt32Size = 4;
-static const uint32_t kSaveSize = 2 * kUInt32Size;
+static const uint32_t kSaveSize = kUInt32Size;
static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect);
@@ -151,25 +151,24 @@ static inline size_t getPaintOffset(DrawType op, size_t opSize) {
return gPaintOffsets[op] * sizeof(uint32_t) + overflow;
}
-void SkPictureRecord::willSave(SaveFlags flags) {
+void SkPictureRecord::willSave() {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
- fMCMgr.save(flags);
+ fMCMgr.save();
#else
// record the offset to us, making it non-positive to distinguish a save
// from a clip entry.
fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten());
- this->recordSave(flags);
+ this->recordSave();
#endif
- this->INHERITED::willSave(flags);
+ this->INHERITED::willSave();
}
-void SkPictureRecord::recordSave(SaveFlags flags) {
- // op + flags
+void SkPictureRecord::recordSave() {
+ // op only
size_t size = kSaveSize;
size_t initialOffset = this->addDraw(SAVE, &size);
- this->addInt(flags);
this->validate(initialOffset, size);
}
@@ -517,15 +516,6 @@ static bool collapse_save_clip_restore(SkWriter32* writer, int32_t offset,
SkASSERT(SAVE == op);
SkASSERT(kSaveSize == opSize);
- // get the save flag (last 4-bytes of the space allocated for the opSize)
- SkCanvas::SaveFlags saveFlags = (SkCanvas::SaveFlags) writer->readTAt<uint32_t>(offset + 4);
- if (SkCanvas::kMatrixClip_SaveFlag != saveFlags) {
- // This function's optimization is only correct for kMatrixClip style saves.
- // TODO: set checkMatrix & checkClip booleans here and then check for the
- // offending operations in the following loop.
- return false;
- }
-
// Walk forward until we get back to either a draw-verb (abort) or we hit
// our restore (success).
int32_t saveOffset = offset;
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 7e5c5c6410..417dde6e82 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -233,7 +233,7 @@ protected:
return NULL;
}
- virtual void willSave(SaveFlags) SK_OVERRIDE;
+ virtual void willSave() SK_OVERRIDE;
virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
virtual void willRestore() SK_OVERRIDE;
@@ -293,7 +293,7 @@ protected:
size_t recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
size_t recordClipPath(int pathID, SkRegion::Op op, bool doAA);
size_t recordClipRegion(const SkRegion& region, SkRegion::Op op);
- void recordSave(SaveFlags flags);
+ void recordSave();
void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags);
void recordRestore(bool fillInSkips = true);
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index e4c49e4f49..db149100c5 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -36,7 +36,7 @@ template <> void Draw::draw(const NoOp&) {}
#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
DRAW(Restore, restore());
-DRAW(Save, save(r.flags));
+DRAW(Save, save());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 75f7c62605..cb429cf76c 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -84,11 +84,6 @@ struct SaveNoDrawsRestoreNooper {
Pattern;
bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) {
- // If restore doesn't revert both matrix and clip, this isn't safe to noop away.
- if (pattern->first<Save>()->flags != SkCanvas::kMatrixClip_SaveFlag) {
- return false;
- }
-
// The entire span between Save and Restore (inclusively) does nothing.
for (unsigned i = begin; i < end; i++) {
record->replace<NoOp>(i);
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 8581257c4a..4c02a35c9f 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -206,9 +206,9 @@ void SkRecorder::drawVertices(VertexMode vmode,
indexCount);
}
-void SkRecorder::willSave(SkCanvas::SaveFlags flags) {
- APPEND(Save, flags);
- INHERITED(willSave, flags);
+void SkRecorder::willSave() {
+ APPEND(Save);
+ INHERITED(willSave);
}
SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds,
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 3e2932d42e..0eb11d7af8 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -62,7 +62,7 @@ public:
int indexCount,
const SkPaint& paint) SK_OVERRIDE;
- void willSave(SkCanvas::SaveFlags) SK_OVERRIDE;
+ void willSave() SK_OVERRIDE;
SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) SK_OVERRIDE;
void willRestore() SK_OVERRIDE;
diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h
index 581ae21e05..02cfc64032 100644
--- a/src/core/SkRecords.h
+++ b/src/core/SkRecords.h
@@ -183,7 +183,7 @@ private:
RECORD0(NoOp);
RECORD0(Restore);
-RECORD1(Save, SkCanvas::SaveFlags, flags);
+RECORD0(Save);
RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas::SaveFlags, flags);
RECORD1(PushCull, SkRect, rect);