gfx/skia/trunk/include/utils/SkNoSaveLayerCanvas.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/SkNoSaveLayerCanvas.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +/*
     1.5 + * Copyright 2014 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkNoSaveLayerCanvas_DEFINED
    1.12 +#define SkNoSaveLayerCanvas_DEFINED
    1.13 +
    1.14 +#include "SkCanvas.h"
    1.15 +#include "SkRRect.h"
    1.16 +
    1.17 +// The NoSaveLayerCanvas is used to play back SkPictures when the saveLayer
    1.18 +// functionality isn't required (e.g., during analysis of the draw calls).
    1.19 +// It also simplifies the clipping calls to only use rectangles.
    1.20 +class SK_API SkNoSaveLayerCanvas : public SkCanvas {
    1.21 +public:
    1.22 +    SkNoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {}
    1.23 +
    1.24 +protected:
    1.25 +    virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
    1.26 +                                            SaveFlags flags) SK_OVERRIDE {
    1.27 +        this->INHERITED::willSaveLayer(bounds, paint, flags);
    1.28 +        return kNoLayer_SaveLayerStrategy;
    1.29 +    }
    1.30 +
    1.31 +    // disable aa for speed
    1.32 +    virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    1.33 +        this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
    1.34 +    }
    1.35 +
    1.36 +    // for speed, just respect the bounds, and disable AA. May give us a few
    1.37 +    // false positives and negatives.
    1.38 +    virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    1.39 +        this->updateClipConservativelyUsingBounds(path.getBounds(), op,
    1.40 +                                                  path.isInverseFillType());
    1.41 +    }
    1.42 +    virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
    1.43 +        this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
    1.44 +    }
    1.45 +
    1.46 +private:
    1.47 +    typedef SkCanvas INHERITED;
    1.48 +};
    1.49 +
    1.50 +#endif // SkNoSaveLayerCanvas_DEFINED

mercurial