aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkNormalBevelSource.h
blob: 1d1983c66aa0710230a2a1b87504b8b468180394 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkNormalBevelSource_DEFINED
#define SkNormalBevelSource_DEFINED

#include "SkNormalSource.h"

class SK_API SkNormalBevelSourceImpl : public SkNormalSource {
public:
    SkNormalBevelSourceImpl(BevelType type, SkScalar width, SkScalar height)
        : fType(type)
        , fWidth(width)
        , fHeight(height) {}

#if SK_SUPPORT_GPU
    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
#endif

    SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
                                         SkArenaAlloc*) const override;

    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalBevelSourceImpl)

protected:
    void flatten(SkWriteBuffer& buf) const override;

private:
    class Provider : public SkNormalSource::Provider {
    public:
        Provider();

        virtual ~Provider();

        void fillScanLine(int x, int y, SkPoint3 output[], int count) const override;

    private:
        typedef SkNormalSource::Provider INHERITED;

    };

    SkNormalSource::BevelType fType;
    SkScalar fWidth;
    SkScalar fHeight;

    friend class SkNormalSource;

    typedef SkNormalSource INHERITED;
};


#endif