robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 1 | /* |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 2 | * Copyright 2017 Google Inc. |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 8 | /* |
| 9 | * This file was autogenerated from GrAlphaThresholdFragmentProcessor.fp; do not modify. |
| 10 | */ |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 11 | #ifndef GrAlphaThresholdFragmentProcessor_DEFINED |
| 12 | #define GrAlphaThresholdFragmentProcessor_DEFINED |
Ethan Nicholas | ceb4d48 | 2017-07-10 15:40:20 -0400 | [diff] [blame] | 13 | #include "SkTypes.h" |
| 14 | #if SK_SUPPORT_GPU |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 15 | |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 16 | #include "GrColorSpaceXform.h" |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 17 | #include "GrFragmentProcessor.h" |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 18 | #include "GrCoordTransform.h" |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 19 | #include "GrColorSpaceXform.h" |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 20 | class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor { |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 21 | public: |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 22 | inline OptimizationFlags optFlags(float outerThreshold); |
| 23 | sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; } |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 24 | float innerThreshold() const { return fInnerThreshold; } |
| 25 | float outerThreshold() const { return fOuterThreshold; } |
| 26 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 27 | static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> image, |
| 28 | sk_sp<GrColorSpaceXform> |
| 29 | colorXform, |
| 30 | sk_sp<GrTextureProxy> |
| 31 | mask, |
| 32 | float innerThreshold, |
| 33 | float outerThreshold, |
| 34 | const SkIRect& bounds) { |
| 35 | return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor( |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 36 | image, colorXform, mask, innerThreshold, outerThreshold, bounds)); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 37 | } |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 38 | GrAlphaThresholdFragmentProcessor(const GrAlphaThresholdFragmentProcessor& src); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 39 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 40 | const char* name() const override { return "AlphaThresholdFragmentProcessor"; } |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 41 | |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 42 | private: |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 43 | GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> image, |
| 44 | sk_sp<GrColorSpaceXform> colorXform, |
| 45 | sk_sp<GrTextureProxy> mask, float innerThreshold, |
| 46 | float outerThreshold, const SkIRect& bounds) |
| 47 | : INHERITED(kNone_OptimizationFlags) |
| 48 | , fImage(std::move(image)) |
| 49 | , fColorXform(colorXform) |
| 50 | , fMask(std::move(mask)) |
| 51 | , fInnerThreshold(innerThreshold) |
| 52 | , fOuterThreshold(outerThreshold) |
| 53 | , fImageCoordTransform(SkMatrix::I(), fImage.proxy()) |
| 54 | , fMaskCoordTransform( |
| 55 | SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())), |
| 56 | fMask.proxy()) { |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 57 | this->addTextureSampler(&fImage); |
| 58 | this->addTextureSampler(&fMask); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 59 | this->addCoordTransform(&fImageCoordTransform); |
| 60 | this->addCoordTransform(&fMaskCoordTransform); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 61 | this->initClassID<GrAlphaThresholdFragmentProcessor>(); |
| 62 | } |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 63 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 64 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 65 | bool onIsEqual(const GrFragmentProcessor&) const override; |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 66 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 67 | TextureSampler fImage; |
| 68 | sk_sp<GrColorSpaceXform> fColorXform; |
| 69 | TextureSampler fMask; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 70 | float fInnerThreshold; |
| 71 | float fOuterThreshold; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 72 | GrCoordTransform fImageCoordTransform; |
| 73 | GrCoordTransform fMaskCoordTransform; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 74 | typedef GrFragmentProcessor INHERITED; |
| 75 | }; |
Ethan Nicholas | ceb4d48 | 2017-07-10 15:40:20 -0400 | [diff] [blame] | 76 | #endif |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 77 | #endif |