aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/GrAlphaThresholdFragmentProcessor.h
blob: 702b6aeb887f370c90b0649cdf03680e6065602a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/*
 * This file was autogenerated from GrAlphaThresholdFragmentProcessor.fp; do not modify.
 */
#ifndef GrAlphaThresholdFragmentProcessor_DEFINED
#define GrAlphaThresholdFragmentProcessor_DEFINED
#include "SkTypes.h"
#if SK_SUPPORT_GPU

    #include "GrColorSpaceXform.h"
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
#include "effects/GrProxyMove.h"
class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
public:

    inline OptimizationFlags optFlags(float outerThreshold);
    sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; }
    float innerThreshold() const { return fInnerThreshold; }
    float outerThreshold() const { return fOuterThreshold; }

    static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> image,
                                           sk_sp<GrColorSpaceXform> colorXform,
                                           sk_sp<GrTextureProxy> mask,
                                           float innerThreshold,
                                           float outerThreshold,
                                           const SkIRect& bounds) {
        return sk_sp<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(image,
                                                                                colorXform,
                                                                                mask,
                                                                                innerThreshold,
                                                                                outerThreshold,
                                                                                bounds));
    }
    const char* name() const override { return "AlphaThresholdFragmentProcessor"; }
private:
    GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform, sk_sp<GrTextureProxy> mask, float innerThreshold, float outerThreshold, 
    const SkIRect& bounds
)
    : INHERITED(kNone_OptimizationFlags)
    , 
    fImageCoordTransform(SkMatrix::I(), image.get()),
    fMaskCoordTransform(SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
                        mask.get())

    , fImage(std::move(image))
    , fColorXform(colorXform)
    , fMask(std::move(mask))
    , fInnerThreshold(innerThreshold)
    , fOuterThreshold(outerThreshold) {

    this->addCoordTransform(&fImageCoordTransform);
    this->addCoordTransform(&fMaskCoordTransform);
        this->addTextureSampler(&fImage);
        this->addTextureSampler(&fMask);
        this->initClassID<GrAlphaThresholdFragmentProcessor>();
    }
    GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
    void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) const override;
    bool onIsEqual(const GrFragmentProcessor&) const override;
    GR_DECLARE_FRAGMENT_PROCESSOR_TEST

    GrCoordTransform fImageCoordTransform;
    GrCoordTransform fMaskCoordTransform;
    TextureSampler fImage;
    sk_sp<GrColorSpaceXform> fColorXform;
    TextureSampler fMask;
    float fInnerThreshold;
    float fOuterThreshold;
    typedef GrFragmentProcessor INHERITED;
};
#endif
#endif