gfx/skia/trunk/include/effects/SkBlurDrawLooper.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/effects/SkBlurDrawLooper.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +/*
     1.5 + * Copyright 2008 The Android Open Source Project
     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 +
    1.12 +#ifndef SkBlurDrawLooper_DEFINED
    1.13 +#define SkBlurDrawLooper_DEFINED
    1.14 +
    1.15 +#include "SkDrawLooper.h"
    1.16 +#include "SkColor.h"
    1.17 +
    1.18 +class SkMaskFilter;
    1.19 +class SkColorFilter;
    1.20 +
    1.21 +/** \class SkBlurDrawLooper
    1.22 +    This class draws a shadow of the object (possibly offset), and then draws
    1.23 +    the original object in its original position.
    1.24 +    should there be an option to just draw the shadow/blur layer? webkit?
    1.25 +*/
    1.26 +class SK_API SkBlurDrawLooper : public SkDrawLooper {
    1.27 +public:
    1.28 +    enum BlurFlags {
    1.29 +        kNone_BlurFlag = 0x00,
    1.30 +        /**
    1.31 +            The blur layer's dx/dy/radius aren't affected by the canvas
    1.32 +            transform.
    1.33 +        */
    1.34 +        kIgnoreTransform_BlurFlag   = 0x01,
    1.35 +        kOverrideColor_BlurFlag     = 0x02,
    1.36 +        kHighQuality_BlurFlag       = 0x04,
    1.37 +        /** mask for all blur flags */
    1.38 +        kAll_BlurFlag               = 0x07
    1.39 +    };
    1.40 +
    1.41 +    SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy,
    1.42 +                     uint32_t flags = kNone_BlurFlag);
    1.43 +
    1.44 +//    SK_ATTR_DEPRECATED("use sigma version")
    1.45 +    SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color,
    1.46 +                     uint32_t flags = kNone_BlurFlag);
    1.47 +    virtual ~SkBlurDrawLooper();
    1.48 +
    1.49 +    virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE;
    1.50 +
    1.51 +    virtual size_t contextSize() const SK_OVERRIDE { return sizeof(BlurDrawLooperContext); }
    1.52 +
    1.53 +    SK_TO_STRING_OVERRIDE()
    1.54 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper)
    1.55 +
    1.56 +protected:
    1.57 +    SkBlurDrawLooper(SkReadBuffer&);
    1.58 +    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    1.59 +
    1.60 +private:
    1.61 +    SkMaskFilter*   fBlur;
    1.62 +    SkColorFilter*  fColorFilter;
    1.63 +    SkScalar        fDx, fDy;
    1.64 +    SkColor         fBlurColor;
    1.65 +    uint32_t        fBlurFlags;
    1.66 +
    1.67 +    enum State {
    1.68 +        kBeforeEdge,
    1.69 +        kAfterEdge,
    1.70 +        kDone
    1.71 +    };
    1.72 +
    1.73 +    class BlurDrawLooperContext : public SkDrawLooper::Context {
    1.74 +    public:
    1.75 +        explicit BlurDrawLooperContext(const SkBlurDrawLooper* looper);
    1.76 +
    1.77 +        virtual bool next(SkCanvas* canvas, SkPaint* paint) SK_OVERRIDE;
    1.78 +
    1.79 +    private:
    1.80 +        const SkBlurDrawLooper* fLooper;
    1.81 +        State fState;
    1.82 +    };
    1.83 +
    1.84 +    void init(SkScalar sigma, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags);
    1.85 +
    1.86 +    typedef SkDrawLooper INHERITED;
    1.87 +};
    1.88 +
    1.89 +#endif

mercurial