SkEmbossMaskFilter.h revision 54924243c1b65b3ee6d8fa064b50a9b1bb2a19a5
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    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
38
39protected:
40    SkEmbossMaskFilter(SkFlattenableReadBuffer&);
41    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
42
43private:
44    Light       fLight;
45    SkScalar    fBlurRadius;
46
47    typedef SkMaskFilter INHERITED;
48};
49
50#endif
51
52