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" |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 20 | #include "effects/GrProxyMove.h" |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 21 | class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor { |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 22 | public: |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 23 | inline OptimizationFlags optFlags(float outerThreshold); |
| 24 | sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; } |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 25 | float innerThreshold() const { return fInnerThreshold; } |
| 26 | float outerThreshold() const { return fOuterThreshold; } |
| 27 | |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 28 | static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> image, |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 29 | sk_sp<GrColorSpaceXform> |
| 30 | colorXform, |
| 31 | sk_sp<GrTextureProxy> |
| 32 | mask, |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 33 | float innerThreshold, |
| 34 | float outerThreshold, |
| 35 | const SkIRect& bounds) { |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 36 | return sk_sp<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor( |
| 37 | image, colorXform, mask, innerThreshold, outerThreshold, bounds)); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 38 | } |
| 39 | const char* name() const override { return "AlphaThresholdFragmentProcessor"; } |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 40 | |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 41 | private: |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 42 | GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> image, |
| 43 | sk_sp<GrColorSpaceXform> colorXform, |
| 44 | sk_sp<GrTextureProxy> mask, float innerThreshold, |
| 45 | float outerThreshold, const SkIRect& bounds) |
| 46 | : INHERITED(kNone_OptimizationFlags) |
| 47 | , fImage(std::move(image)) |
| 48 | , fColorXform(colorXform) |
| 49 | , fMask(std::move(mask)) |
| 50 | , fInnerThreshold(innerThreshold) |
| 51 | , fOuterThreshold(outerThreshold) |
| 52 | , fImageCoordTransform(SkMatrix::I(), fImage.proxy()) |
| 53 | , fMaskCoordTransform( |
| 54 | SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())), |
| 55 | fMask.proxy()) { |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 56 | this->addTextureSampler(&fImage); |
| 57 | this->addTextureSampler(&fMask); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 58 | this->addCoordTransform(&fImageCoordTransform); |
| 59 | this->addCoordTransform(&fMaskCoordTransform); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 60 | this->initClassID<GrAlphaThresholdFragmentProcessor>(); |
| 61 | } |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 62 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 63 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 64 | bool onIsEqual(const GrFragmentProcessor&) const override; |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 65 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 66 | TextureSampler fImage; |
| 67 | sk_sp<GrColorSpaceXform> fColorXform; |
| 68 | TextureSampler fMask; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 69 | float fInnerThreshold; |
| 70 | float fOuterThreshold; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 71 | GrCoordTransform fImageCoordTransform; |
| 72 | GrCoordTransform fMaskCoordTransform; |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 73 | typedef GrFragmentProcessor INHERITED; |
| 74 | }; |
Ethan Nicholas | ceb4d48 | 2017-07-10 15:40:20 -0400 | [diff] [blame] | 75 | #endif |
robertphillips | f7142e7 | 2016-04-18 07:20:05 -0700 | [diff] [blame] | 76 | #endif |