michael@0: /* michael@0: * Copyright 2014 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkNoSaveLayerCanvas_DEFINED michael@0: #define SkNoSaveLayerCanvas_DEFINED michael@0: michael@0: #include "SkCanvas.h" michael@0: #include "SkRRect.h" michael@0: michael@0: // The NoSaveLayerCanvas is used to play back SkPictures when the saveLayer michael@0: // functionality isn't required (e.g., during analysis of the draw calls). michael@0: // It also simplifies the clipping calls to only use rectangles. michael@0: class SK_API SkNoSaveLayerCanvas : public SkCanvas { michael@0: public: michael@0: SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {} michael@0: michael@0: protected: michael@0: virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, michael@0: SaveFlags flags) SK_OVERRIDE { michael@0: this->INHERITED::willSaveLayer(bounds, paint, flags); michael@0: return kNoLayer_SaveLayerStrategy; michael@0: } michael@0: michael@0: // disable aa for speed michael@0: virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { michael@0: this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); michael@0: } michael@0: michael@0: // for speed, just respect the bounds, and disable AA. May give us a few michael@0: // false positives and negatives. michael@0: virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { michael@0: this->updateClipConservativelyUsingBounds(path.getBounds(), op, michael@0: path.isInverseFillType()); michael@0: } michael@0: virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { michael@0: this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); michael@0: } michael@0: michael@0: private: michael@0: typedef SkCanvas INHERITED; michael@0: }; michael@0: michael@0: #endif // SkNoSaveLayerCanvas_DEFINED