explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
virtual ~SkNulCanvas() {}
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE {return 0;}
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE {return 0;}
- int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
- virtual void restore() SK_OVERRIDE {}
- int getSaveCount() const {return 0;}
virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE {return true;}
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;}
virtual SkCanvas* canvasForDrawIter() {return NULL;}
virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
+ virtual bool onSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags)
+ SK_OVERRIDE {
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ return false;
+ }
+
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE {}
by calls to save/restore.
@return The value to pass to restoreToCount() to balance this save()
*/
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
+ int save(SaveFlags flags = kMatrixClip_SaveFlag);
/** This behaves the same as save(), but in addition it allocates an
offscreen bitmap. All drawing calls are directed there, and only when
@param flags LayerFlags
@return The value to pass to restoreToCount() to balance this save()
*/
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag);
+ int saveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag);
/** This behaves the same as save(), but in addition it allocates an
offscreen bitmap. All drawing calls are directed there, and only when
call.
It is an error to call restore() more times than save() was called.
*/
- virtual void restore();
+ void restore();
/** Returns the number of matrix/clip states on the SkCanvas' private stack.
This will equal # save() calls - # restore() calls + 1. The save count on
// default impl defers to its device
virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
+ // Subclass save/restore notifiers. These are called *before* updating the canvas state.
+ // Overriders should call the corresponding INHERITED method up the inheritance chain.
+ // For onSaveLayer(), returning false suppresses full layer allocation (and forces
+ // the base impl to only perform a state save + bounds clip).
+ virtual void onSave(SaveFlags);
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags);
+ virtual void onRestore();
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
enum ClipEdgeStyle {
const SkRect& dst, const SkPaint* paint);
void internalDrawPaint(const SkPaint& paint);
int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags, bool justForImageFilter);
+ SaveFlags, bool justForImageFilter, bool skipLayer);
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
// shared by save() and saveLayer()
void silentFlush();
// Overrides of the SkCanvas interface
- virtual int save(SaveFlags flags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
virtual bool isDrawingToLayer() const SK_OVERRIDE;
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&,
const SkPaint&) SK_OVERRIDE;
int getNestLevel() const { return fNestLevel; }
- virtual int save(SaveFlags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
-
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
SkLuaCanvas(int width, int height, lua_State*, const char function[]);
virtual ~SkLuaCanvas();
- virtual int save(SaveFlags flags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
-
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
///////////////////////////////////////////////////////////////////////////
// These are forwarded to the N canvases we're referencing
- virtual int save(SaveFlags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint*,
- SaveFlags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
protected:
SkTDArray<SkCanvas*> fList;
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
SkCanvas* getProxy() const { return fProxy; }
void setProxy(SkCanvas* proxy);
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
-
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
fBoundingHierarchy->insert(draw, r, true);
}
-int SkBBoxHierarchyRecord::save(SaveFlags flags) {
+void SkBBoxHierarchyRecord::onSave(SaveFlags flags) {
fStateTree->appendSave();
- return INHERITED::save(flags);
+ this->INHERITED::onSave(flags);
}
-int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkBBoxHierarchyRecord::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
fStateTree->appendSaveLayer(this->writeStream().bytesWritten());
- return INHERITED::saveLayer(bounds, paint, flags);
+ return this->INHERITED::onSaveLayer(bounds, paint, flags);
}
-void SkBBoxHierarchyRecord::restore() {
+void SkBBoxHierarchyRecord::onRestore() {
fStateTree->appendRestore();
- INHERITED::restore();
+ this->INHERITED::onRestore();
}
bool SkBBoxHierarchyRecord::translate(SkScalar dx, SkScalar dy) {
virtual void handleBBox(const SkRect& bounds) SK_OVERRIDE;
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
-
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
virtual bool shouldRewind(void* data) SK_OVERRIDE;
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
SkPaint tmp;
tmp.setImageFilter(fOrigPaint.getImageFilter());
(void)canvas->internalSaveLayer(bounds, &tmp,
- SkCanvas::kARGB_ClipLayer_SaveFlag, true);
+ SkCanvas::kARGB_ClipLayer_SaveFlag, true, false);
// we'll clear the imageFilter for the actual draws in next(), so
// it will only be applied during the restore().
fDoClearImageFilter = true;
return saveCount;
}
+void SkCanvas::onSave(SaveFlags) {
+ // Do nothing. Subclasses may do something.
+}
+
int SkCanvas::save(SaveFlags flags) {
+ this->onSave(flags);
// call shared impl
return this->internalSave(flags);
}
return true;
}
+bool SkCanvas::onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) {
+ // Do nothing. Subclasses may do something.
+ return true;
+}
+
int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) {
- return this->internalSaveLayer(bounds, paint, flags, false);
+ // Overriding classes may return false to signal that we don't need to create a layer.
+ bool skipLayer = !this->onSaveLayer(bounds, paint, flags);
+ return this->internalSaveLayer(bounds, paint, flags, false, skipLayer);
}
static SkBaseDevice* createCompatibleDevice(SkCanvas* canvas,
}
int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags, bool justForImageFilter) {
+ SaveFlags flags, bool justForImageFilter, bool skipLayer) {
#ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
flags = (SaveFlags)(flags | kClipToLayer_SaveFlag);
#endif
return count;
}
+ // FIXME: do onSaveLayer() overriders returning false really care about the clipRectBounds()
+ // call above?
+ if (skipLayer)
+ return count;
+
// Kill the imagefilter if our device doesn't allow it
SkLazyPaint lazyP;
if (paint && paint->getImageFilter()) {
}
}
+void SkCanvas::onRestore() {
+ // Do nothing. Subclasses may do something.
+}
+
void SkCanvas::restore() {
// check for underflow
if (fMCStack.count() > 1) {
+ this->onRestore();
this->internalRestore();
}
}
return gPaintOffsets[op] * sizeof(uint32_t) + overflow;
}
-int SkPictureRecord::save(SaveFlags flags) {
+void SkPictureRecord::onSave(SaveFlags flags) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.save(flags);
fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten());
this->recordSave(flags);
#endif
- return this->INHERITED::save(flags);
+
+ this->INHERITED::onSave(flags);
}
void SkPictureRecord::recordSave(SaveFlags flags) {
this->validate(initialOffset, size);
}
-int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkPictureRecord::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
- int count;
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
- count = fMCMgr.saveLayer(bounds, paint, flags);
+ fMCMgr.saveLayer(bounds, paint, flags);
#else
// record the offset to us, making it non-positive to distinguish a save
// from a clip entry.
}
#endif
- /* Don't actually call INHERITED::saveLayer, because that will try to allocate
- an offscreen device (potentially very big) which we don't actually need
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ /* No need for a (potentially very big) layer which we don't actually need
at this time (and may not be able to afford since during record our
clip starts out the size of the picture, which is often much larger
than the size of the actual device we'll use during playback).
*/
- count = this->INHERITED::save(flags);
- this->clipRectBounds(bounds, flags, NULL);
- return count;
+ return false;
}
void SkPictureRecord::recordSaveLayer(const SkRect* bounds, const SkPaint* paint,
}
}
-void SkPictureRecord::restore() {
+void SkPictureRecord::onRestore() {
// FIXME: SkDeferredCanvas needs to be refactored to respect
// save/restore balancing so that the following test can be
// turned on permanently.
fRestoreOffsetStack.pop();
#endif
- return this->INHERITED::restore();
+ this->INHERITED::onRestore();
}
void SkPictureRecord::recordRestore(bool fillInSkips) {
SkPictureRecord(const SkISize& dimensions, uint32_t recordFlags);
virtual ~SkPictureRecord();
- virtual int save(SaveFlags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
const void* onPeekPixels(SkImageInfo*, size_t*) SK_OVERRIDE {
return NULL;
}
+
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect&) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
}
// overrides from SkCanvas
- virtual int save(SaveFlags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint*,
- SaveFlags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
virtual bool isDrawingToLayer() const SK_OVERRIDE;
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
bool shuttleBitmap(const SkBitmap&, int32_t slot);
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
#define NOTIFY_SETUP(canvas) \
AutoPipeNotify apn(canvas)
-int SkGPipeCanvas::save(SaveFlags flags) {
+void SkGPipeCanvas::onSave(SaveFlags flags) {
NOTIFY_SETUP(this);
if (this->needOpBytes()) {
this->writeOp(kSave_DrawOp, 0, flags);
}
- return this->INHERITED::save(flags);
+
+ this->INHERITED::onSave(flags);
}
-int SkGPipeCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags saveFlags) {
+bool SkGPipeCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags saveFlags) {
NOTIFY_SETUP(this);
size_t size = 0;
unsigned opFlags = 0;
if (kNoSaveLayer == fFirstSaveLayerStackLevel){
fFirstSaveLayerStackLevel = this->getSaveCount();
}
- // we just pass on the save, so we don't create a layer
- return this->INHERITED::save(saveFlags);
+
+ this->INHERITED::onSaveLayer(bounds, paint, saveFlags);
+ // we don't create a layer
+ return false;
}
-void SkGPipeCanvas::restore() {
+void SkGPipeCanvas::onRestore() {
NOTIFY_SETUP(this);
if (this->needOpBytes()) {
this->writeOp(kRestore_DrawOp);
}
- this->INHERITED::restore();
-
- if (this->getSaveCount() == fFirstSaveLayerStackLevel){
+ if (this->getSaveCount() - 1 == fFirstSaveLayerStackLevel){
fFirstSaveLayerStackLevel = kNoSaveLayer;
}
+
+ this->INHERITED::onRestore();
}
bool SkGPipeCanvas::isDrawingToLayer() const {
SkIntToScalar(canvasSize.fWidth), SkIntToScalar(canvasSize.fHeight)));
}
-int SkDeferredCanvas::save(SaveFlags flags) {
+void SkDeferredCanvas::onSave(SaveFlags flags) {
this->drawingCanvas()->save(flags);
- int val = this->INHERITED::save(flags);
this->recordedDrawCommand();
-
- return val;
+ this->INHERITED::onSave(flags);
}
-int SkDeferredCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkDeferredCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
this->drawingCanvas()->saveLayer(bounds, paint, flags);
- int count = this->INHERITED::save(flags);
- this->clipRectBounds(bounds, flags, NULL);
this->recordedDrawCommand();
-
- return count;
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ // No need for a full layer.
+ return false;
}
-void SkDeferredCanvas::restore() {
+void SkDeferredCanvas::onRestore() {
this->drawingCanvas()->restore();
- this->INHERITED::restore();
this->recordedDrawCommand();
+ this->INHERITED::onRestore();
}
bool SkDeferredCanvas::isDrawingToLayer() const {
///////////////////////////////////////////////////////////////////////////////
-int SkDumpCanvas::save(SaveFlags flags) {
+void SkDumpCanvas::onSave(SaveFlags flags) {
this->dump(kSave_Verb, NULL, "save(0x%X)", flags);
- return this->INHERITED::save(flags);
+ this->INHERITED::onSave(flags);
}
-int SkDumpCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkDumpCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
SkString str;
str.printf("saveLayer(0x%X)", flags);
if (bounds) {
}
}
this->dump(kSave_Verb, paint, str.c_str());
- return this->INHERITED::saveLayer(bounds, paint, flags);
+ return this->INHERITED::onSaveLayer(bounds, paint, flags);
}
-void SkDumpCanvas::restore() {
- this->INHERITED::restore();
+void SkDumpCanvas::onRestore() {
this->dump(kRestore_Verb, NULL, "restore");
+ this->INHERITED::onRestore();
}
bool SkDumpCanvas::translate(SkScalar dx, SkScalar dy) {
SkLuaCanvas::~SkLuaCanvas() {}
-int SkLuaCanvas::save(SaveFlags flags) {
+void SkLuaCanvas::onSave(SaveFlags flags) {
AUTO_LUA("save");
- return this->INHERITED::save(flags);
+ this->INHERITED::onSave(flags);
}
-int SkLuaCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkLuaCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
AUTO_LUA("saveLayer");
if (bounds) {
lua.pushRect(*bounds, "bounds");
if (paint) {
lua.pushPaint(*paint, "paint");
}
- return this->INHERITED::save(flags);
+
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ // No need for a layer.
+ return false;
}
-void SkLuaCanvas::restore() {
+void SkLuaCanvas::onRestore() {
AUTO_LUA("restore");
- this->INHERITED::restore();
+ this->INHERITED::onRestore();
}
bool SkLuaCanvas::translate(SkScalar dx, SkScalar dy) {
SkCanvas* fCanvas;
};
-int SkNWayCanvas::save(SaveFlags flags) {
+void SkNWayCanvas::onSave(SaveFlags flags) {
Iter iter(fList);
while (iter.next()) {
iter->save(flags);
}
- return this->INHERITED::save(flags);
+
+ this->INHERITED::onSave(flags);
}
-int SkNWayCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
+bool SkNWayCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
Iter iter(fList);
while (iter.next()) {
iter->saveLayer(bounds, paint, flags);
}
- return this->INHERITED::saveLayer(bounds, paint, flags);
+
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ // No need for a layer.
+ return false;
}
-void SkNWayCanvas::restore() {
+void SkNWayCanvas::onRestore() {
Iter iter(fList);
while (iter.next()) {
iter->restore();
}
- this->INHERITED::restore();
+ this->INHERITED::onRestore();
}
bool SkNWayCanvas::translate(SkScalar dx, SkScalar dy) {
public:
SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {}
- // turn saveLayer() into save() for speed, should not affect correctness.
- virtual int saveLayer(const SkRect* bounds,
- const SkPaint* paint,
- SaveFlags flags) SK_OVERRIDE {
-
- // Like SkPictureRecord, we don't want to create layers, but we do need
- // to respect the save and (possibly) its rect-clip.
- int count = this->INHERITED::save(flags);
- if (NULL != bounds) {
- this->INHERITED::clipRectBounds(bounds, flags, NULL);
- }
- return count;
+protected:
+ virtual bool onSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags)
+ SK_OVERRIDE {
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ return false;
}
-protected:
// disable aa for speed
virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
///////////////////////////////// Overrides ///////////
-int SkProxyCanvas::save(SaveFlags flags) {
- return fProxy->save(flags);
+void SkProxyCanvas::onSave(SaveFlags flags) {
+ fProxy->save(flags);
+ this->INHERITED::onSave(flags);
}
-int SkProxyCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
- return fProxy->saveLayer(bounds, paint, flags);
+bool SkProxyCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
+ fProxy->saveLayer(bounds, paint, flags);
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ // No need for a layer.
+ return false;
}
-void SkProxyCanvas::restore() {
+void SkProxyCanvas::onRestore() {
fProxy->restore();
+ this->INHERITED::onRestore();
}
bool SkProxyCanvas::translate(SkScalar dx, SkScalar dy) {
this->addDrawCommand(new SkPopCullCommand());
}
-void SkDebugCanvas::restore() {
- addDrawCommand(new SkRestoreCommand());
+void SkDebugCanvas::onRestore() {
+ this->addDrawCommand(new SkRestoreCommand());
+ this->INHERITED::onRestore();
}
bool SkDebugCanvas::rotate(SkScalar degrees) {
return true;
}
-int SkDebugCanvas::save(SaveFlags flags) {
- addDrawCommand(new SkSaveCommand(flags));
- return true;
+void SkDebugCanvas::onSave(SaveFlags flags) {
+ this->addDrawCommand(new SkSaveCommand(flags));
+ this->INHERITED::onSave(flags);
}
-int SkDebugCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
- addDrawCommand(new SkSaveLayerCommand(bounds, paint, flags));
- return true;
+bool SkDebugCanvas::onSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
+ this->addDrawCommand(new SkSaveLayerCommand(bounds, paint, flags));
+ this->INHERITED::onSaveLayer(bounds, paint, flags);
+ // No need for a full layer.
+ return false;
}
bool SkDebugCanvas::scale(SkScalar sx, SkScalar sy) {
const uint16_t indices[], int indexCount,
const SkPaint&) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
-
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
- virtual int save(SaveFlags) SK_OVERRIDE;
-
- virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE;
-
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
}
protected:
+ virtual void onSave(SaveFlags) SK_OVERRIDE;
+ virtual bool onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void onRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;