1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkEmbossMaskFilter_DEFINED
11#define SkEmbossMaskFilter_DEFINED
12
13#include "SkMaskFilter.h"
14
15/** \class SkEmbossMaskFilter
16
17    This mask filter creates a 3D emboss look, by specifying a light and blur amount.
18*/
19class SkEmbossMaskFilter : public SkMaskFilter {
20public:
21    struct Light {
22        SkScalar    fDirection[3];  // x,y,z
23        uint16_t    fPad;
24        uint8_t     fAmbient;
25        uint8_t     fSpecular;      // exponent, 4.4 right now
26    };
27
28    SkEmbossMaskFilter(const Light& light, SkScalar blurRadius);
29
30    // overrides from SkMaskFilter
31    //  This method is not exported to java.
32    virtual SkMask::Format getFormat();
33    //  This method is not exported to java.
34    virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
35                            SkIPoint* margin);
36
37    // overrides from SkFlattenable
38
39    //  This method is not exported to java.
40    virtual Factory getFactory();
41    //  This method is not exported to java.
42    virtual void flatten(SkFlattenableWriteBuffer&);
43
44    SK_DECLARE_FLATTENABLE_REGISTRAR()
45
46protected:
47    SkEmbossMaskFilter(SkFlattenableReadBuffer&);
48
49private:
50    Light       fLight;
51    SkScalar    fBlurRadius;
52
53    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
54
55    typedef SkMaskFilter INHERITED;
56};
57
58#endif
59
60