SaveFlags be-gone

Remove the deprecated save(SaveFlags), willSave(SaveFlags) and all
traces of kMatrix_SaveFlags/kClip_SaveFlag.

BUG=skia:2297
R=mtklein@google.com, reed@google.com, robertphillips@google.com

Review URL: https://codereview.chromium.org/340403003
This commit is contained in:
Florin Malita 2014-06-30 10:13:28 -04:00
parent fdecca8440
commit 5f6102d079
36 changed files with 92 additions and 376 deletions

View File

@ -1,180 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRect.h"
namespace skiagm {
/*
* This GM exercises the flags to SkCanvas::save(). The canvas' save() and
* restore actions can be limited to only a portion of the canvas' state through
* the use of flags when calling save.
*/
class CanvasStateGM : public GM {
SkSize fSize;
enum {
WIDTH = 150,
HEIGHT = 150,
};
SkPaint fFillPaint;
SkPaint fStrokePaint;
SkPath fPath;
SkRect fOutlineRect;
SkRect fFillRect;
public:
CanvasStateGM() {
fSize.set(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT));
fFillPaint.setColor(SK_ColorRED);
fFillPaint.setStyle(SkPaint::kFill_Style);
fStrokePaint.setColor(SK_ColorBLUE);
fStrokePaint.setStyle(SkPaint::kStroke_Style);
fStrokePaint.setStrokeWidth(1);
fPath.moveTo(25, 25);
fPath.lineTo(125, 25);
fPath.lineTo(75, 125);
fPath.close();
fOutlineRect = SkRect::MakeXYWH(1, 1, WIDTH-2, HEIGHT-2);
fFillRect = SkRect::MakeXYWH(10, 10, WIDTH-20, HEIGHT-20);
}
protected:
virtual SkString onShortName() SK_OVERRIDE {
return SkString("canvas-state");
}
virtual SkISize onISize() SK_OVERRIDE {
return SkISize::Make(WIDTH*3, HEIGHT*4);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkCanvas::SaveFlags flags[] = { SkCanvas::kMatrix_SaveFlag,
SkCanvas::kClip_SaveFlag,
SkCanvas::kMatrixClip_SaveFlag };
// columns -- flags
// rows -- permutations of setting the clip and matrix
for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(flags)); ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
this->drawTestPattern(i, (2*j)+k, canvas, flags[i],
SkToBool(j), SkToBool(k));
}
}
}
}
virtual uint32_t onGetFlags() const SK_OVERRIDE { return kSkipPicture_Flag; }
private:
void drawTestPattern(int x, int y, SkCanvas* canvas,
SkCanvas::SaveFlags flags, bool doClip, bool doScale) {
canvas->save();
canvas->translate(SkIntToScalar(x*WIDTH), SkIntToScalar(y*HEIGHT));
canvas->drawRect(fOutlineRect, fStrokePaint);
canvas->save(flags);
if(doClip) {
canvas->clipPath(fPath);
}
if (doScale) {
canvas->scale(SkDoubleToScalar(0.5), SkDoubleToScalar(0.5));
}
canvas->restore();
canvas->drawRect(fFillRect, fFillPaint);
canvas->restore();
}
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
class CanvasLayerStateGM : public GM {
public:
CanvasLayerStateGM() {
fBluePaint.setColor(SK_ColorBLUE);
fBluePaint.setStyle(SkPaint::kFill_Style);
fRect = SkRect::MakeXYWH(SPACER, SPACER, WIDTH-(2*SPACER), (HEIGHT-(2*SPACER)) / 7);
}
protected:
virtual SkString onShortName() SK_OVERRIDE {
return SkString("canvas-layer-state");
}
virtual SkISize onISize() SK_OVERRIDE {
return SkISize::Make(WIDTH, HEIGHT);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
// clear the canvas to red
canvas->drawColor(SK_ColorRED);
#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
// both rects should appear
drawTestPattern(canvas, 255, SkCanvas::kARGB_NoClipLayer_SaveFlag);
canvas->translate(0, 2*(fRect.height() + 10));
// only the top rect should appear
drawTestPattern(canvas, 255, SkCanvas::kARGB_ClipLayer_SaveFlag);
canvas->translate(0, 2*(fRect.height() + 10));
// only the bottom rect should appear
drawTestPattern(canvas, 0, SkCanvas::kARGB_NoClipLayer_SaveFlag);
#endif
}
virtual uint32_t onGetFlags() const SK_OVERRIDE { return kSkipGPU_Flag; }
private:
// draw a rect within the layer's bounds and again outside the layer's bounds
void drawTestPattern(SkCanvas* canvas, U8CPU layerAlpha, SkCanvas::SaveFlags flags) {
canvas->saveLayerAlpha(&fRect, layerAlpha, flags);
canvas->drawRect(fRect, fBluePaint);
canvas->translate(0, fRect.height() + 10);
canvas->drawRect(fRect, fBluePaint);
canvas->restore();
}
enum {
WIDTH = 400,
HEIGHT = 400,
SPACER = 10,
};
SkPaint fBluePaint;
SkRect fRect;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM( return SkNEW(CanvasStateGM); )
DEF_GM( return SkNEW(CanvasLayerStateGM); )
} // end namespace

View File

@ -36,7 +36,6 @@
'../gm/blurquickreject.cpp',
'../gm/blurrect.cpp',
'../gm/blurroundrect.cpp',
'../gm/canvasstate.cpp',
'../gm/circles.cpp',
'../gm/circularclips.cpp',
'../gm/clippedbitmapshaders.cpp',

View File

@ -293,9 +293,9 @@ public:
enum SaveFlags {
/** save the matrix state, restoring it on restore() */
kMatrix_SaveFlag = 0x01,
// [deprecated] kMatrix_SaveFlag = 0x01,
/** save the clip state, restoring it on restore() */
kClip_SaveFlag = 0x02,
// [deprecated] kClip_SaveFlag = 0x02,
/** the layer needs to support per-pixel alpha */
kHasAlphaLayer_SaveFlag = 0x04,
/** the layer needs to support 8-bits per color component */
@ -308,7 +308,7 @@ public:
kClipToLayer_SaveFlag = 0x10,
// helper masks for common choices
kMatrixClip_SaveFlag = 0x03,
// [deprecated] kMatrixClip_SaveFlag = 0x03,
#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
kARGB_NoClipLayer_SaveFlag = 0x0F,
#endif
@ -326,22 +326,6 @@ public:
*/
int save();
/** DEPRECATED - use save() instead.
This behaves the same as save(), but it allows fine-grained control of
which state bits to be saved (and subsequently restored).
@param flags The flags govern what portion of the Matrix/Clip/drawFilter
state the save (and matching restore) effect. For example,
if only kMatrix is specified, then only the matrix state
will be pushed and popped. Likewise for the clip if kClip
is specified. However, the drawFilter is always affected
by calls to save/restore.
@return The value to pass to restoreToCount() to balance this save()
*/
SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated")
int save(SaveFlags flags);
/** This behaves the same as save(), but in addition it allocates an
offscreen bitmap. All drawing calls are directed there, and only when
the balancing call to restore() is made is that offscreen transfered to
@ -1191,9 +1175,6 @@ protected:
kNoLayer_SaveLayerStrategy
};
// Transitional, pending external clients cleanup.
virtual void willSave(SaveFlags) { this->willSave(); }
virtual void willSave() {}
virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) {
return kFullLayer_SaveLayerStrategy;
@ -1324,7 +1305,7 @@ private:
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
// shared by save() and saveLayer()
int internalSave(SaveFlags flags);
int internalSave();
void internalRestore();
static void DrawRect(const SkDraw& draw, const SkPaint& paint,
const SkRect& r, SkScalar textSize);

View File

@ -238,13 +238,14 @@ protected:
// V26: Removed boolean from SkColorShader for inheriting color from SkPaint.
// V27: Remove SkUnitMapper from gradients (and skia).
// V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap.
// V29: Removed SaveFlags parameter from save().
// Note: If the picture version needs to be increased then please follow the
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
// Only SKPs within the min/current picture version range (inclusive) can be read.
static const uint32_t MIN_PICTURE_VERSION = 19;
static const uint32_t CURRENT_PICTURE_VERSION = 28;
static const uint32_t CURRENT_PICTURE_VERSION = 29;
mutable uint32_t fUniqueID;

View File

@ -170,7 +170,7 @@ public:
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) 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;

View File

@ -101,7 +101,7 @@ public:
virtual void endCommentGroup() 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;

View File

@ -44,7 +44,7 @@ public:
virtual void drawData(const void* data, size_t length) 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;

View File

@ -59,7 +59,7 @@ public:
protected:
SkTDArray<SkCanvas*> fList;
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;

View File

@ -55,11 +55,8 @@ public:
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
// Transitional, to facilitate migrating subclasses to the new willSave API.
using SkCanvas::willSave;
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;

View File

@ -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,

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -317,7 +317,7 @@ static void translate_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
static void save_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
canvas->save((SkCanvas::SaveFlags)DrawOp_unpackData(op32));
canvas->save();
}
static void saveLayer_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,

View File

@ -266,7 +266,7 @@ public:
bool shuttleBitmap(const SkBitmap&, int32_t slot);
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;
@ -515,13 +515,13 @@ uint32_t SkGPipeCanvas::getTypefaceID(SkTypeface* face) {
#define NOTIFY_SETUP(canvas) \
AutoPipeNotify apn(canvas)
void SkGPipeCanvas::willSave(SaveFlags flags) {
void SkGPipeCanvas::willSave() {
NOTIFY_SETUP(this);
if (this->needOpBytes()) {
this->writeOp(kSave_DrawOp, 0, flags);
this->writeOp(kSave_DrawOp);
}
this->INHERITED::willSave(flags);
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -678,10 +678,10 @@ bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
SkIntToScalar(canvasSize.fWidth), SkIntToScalar(canvasSize.fHeight)));
}
void SkDeferredCanvas::willSave(SaveFlags flags) {
this->drawingCanvas()->save(flags);
void SkDeferredCanvas::willSave() {
this->drawingCanvas()->save();
this->recordedDrawCommand();
this->INHERITED::willSave(flags);
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkDeferredCanvas::willSaveLayer(const SkRect* bounds,

View File

@ -192,9 +192,9 @@ void SkDumpCanvas::dump(Verb verb, const SkPaint* paint,
///////////////////////////////////////////////////////////////////////////////
void SkDumpCanvas::willSave(SaveFlags flags) {
this->dump(kSave_Verb, NULL, "save(0x%X)", flags);
this->INHERITED::willSave(flags);
void SkDumpCanvas::willSave() {
this->dump(kSave_Verb, NULL, "save()");
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkDumpCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -81,9 +81,9 @@ SkLuaCanvas::SkLuaCanvas(int width, int height, lua_State* L, const char func[])
SkLuaCanvas::~SkLuaCanvas() {}
void SkLuaCanvas::willSave(SaveFlags flags) {
void SkLuaCanvas::willSave() {
AUTO_LUA("save");
this->INHERITED::willSave(flags);
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkLuaCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -57,13 +57,13 @@ private:
SkCanvas* fCanvas;
};
void SkNWayCanvas::willSave(SaveFlags flags) {
void SkNWayCanvas::willSave() {
Iter iter(fList);
while (iter.next()) {
iter->save(flags);
iter->save();
}
this->INHERITED::willSave(flags);
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkNWayCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -21,9 +21,9 @@ void SkProxyCanvas::setProxy(SkCanvas* proxy) {
///////////////////////////////// Overrides ///////////
void SkProxyCanvas::willSave(SaveFlags flags) {
fProxy->save(flags);
this->INHERITED::willSave(flags);
void SkProxyCanvas::willSave() {
fProxy->save();
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkProxyCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -590,9 +590,9 @@ void SkDebugCanvas::willRestore() {
this->INHERITED::willRestore();
}
void SkDebugCanvas::willSave(SaveFlags flags) {
this->addDrawCommand(new SkSaveCommand(flags));
this->INHERITED::willSave(flags);
void SkDebugCanvas::willSave() {
this->addDrawCommand(new SkSaveCommand());
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkDebugCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,

View File

@ -231,7 +231,7 @@ public:
}
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;

View File

@ -840,14 +840,12 @@ void SkRotateCommand::execute(SkCanvas* canvas) {
canvas->rotate(fDegrees);
}
SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags)
SkSaveCommand::SkSaveCommand()
: INHERITED(SAVE) {
fFlags = flags;
fInfo.push(SkObjectParser::SaveFlagsToString(flags));
}
void SkSaveCommand::execute(SkCanvas* canvas) {
canvas->save(fFlags);
canvas->save();
}
void SkSaveCommand::trackSaveState(int* state) {

View File

@ -522,13 +522,11 @@ private:
class SkSaveCommand : public SkDrawCommand {
public:
SkSaveCommand(SkCanvas::SaveFlags flags);
SkSaveCommand();
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
virtual void trackSaveState(int* state) SK_OVERRIDE;
virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; }
private:
SkCanvas::SaveFlags fFlags;
typedef SkDrawCommand INHERITED;
};

View File

@ -300,12 +300,6 @@ SkString* SkObjectParser::RegionToString(const SkRegion& region) {
SkString* SkObjectParser::SaveFlagsToString(SkCanvas::SaveFlags flags) {
SkString* mFlags = new SkString("SkCanvas::SaveFlags: ");
if (flags & SkCanvas::kMatrix_SaveFlag) {
mFlags->append("kMatrix_SaveFlag ");
}
if (flags & SkCanvas::kClip_SaveFlag) {
mFlags->append("kClip_SaveFlag ");
}
if (flags & SkCanvas::kHasAlphaLayer_SaveFlag) {
mFlags->append("kHasAlphaLayer_SaveFlag ");
}

View File

@ -367,45 +367,11 @@ SIMPLE_TEST_STEP(EndGroup, endCommentGroup());
///////////////////////////////////////////////////////////////////////////////
// Complex test steps
// Save/restore calls cannot be in isolated simple test steps because the test
// cases that use SkPicture require that save and restore calls be balanced.
static void SaveMatrixStep(SkCanvas* canvas,
skiatest::Reporter* reporter,
CanvasTestStep* testStep) {
int saveCount = canvas->getSaveCount();
canvas->save(SkCanvas::kMatrix_SaveFlag);
canvas->clipRegion(kTestRegion);
canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
canvas->restore();
REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount,
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(),
testStep->assertMessage());
// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() == kTestRegion, testStep->assertMessage());
}
TEST_STEP(SaveMatrix, SaveMatrixStep);
static void SaveClipStep(SkCanvas* canvas,
skiatest::Reporter* reporter,
CanvasTestStep* testStep) {
int saveCount = canvas->getSaveCount();
canvas->save(SkCanvas::kClip_SaveFlag);
canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
canvas->clipRegion(kTestRegion);
canvas->restore();
REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount,
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, !canvas->getTotalMatrix().isIdentity(),
testStep->assertMessage());
// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, testStep->assertMessage());
}
TEST_STEP(SaveClip, SaveClipStep);
static void SaveMatrixClipStep(SkCanvas* canvas,
skiatest::Reporter* reporter,
CanvasTestStep* testStep) {
int saveCount = canvas->getSaveCount();
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
canvas->save();
canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
canvas->clipRegion(kTestRegion);
canvas->restore();

View File

@ -933,9 +933,9 @@ public:
return this->INHERITED::willSaveLayer(bounds, paint, flags);
}
virtual void willSave(SaveFlags flags) SK_OVERRIDE {
virtual void willSave() SK_OVERRIDE {
++fSaveCount;
this->INHERITED::willSave(flags);
this->INHERITED::willSave();
}
virtual void willRestore() SK_OVERRIDE {