From 9fb036fb133d0b2eafb95a86a06b7910c0b0039c Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Wed, 5 Jul 2017 16:19:09 -0400 Subject: rewrote GrAlphaThresholdFragmentProcessor in sksl Bug: skia: Change-Id: I641b206fc3bc19ac190ad94ee755ab9e1caab9b3 Reviewed-on: https://skia-review.googlesource.com/21341 Reviewed-by: Jim Van Verth Commit-Queue: Ethan Nicholas --- src/effects/GrAlphaThresholdFragmentProcessor.h | 100 ++++++++++++------------ 1 file changed, 52 insertions(+), 48 deletions(-) (limited to 'src/effects/GrAlphaThresholdFragmentProcessor.h') diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.h b/src/effects/GrAlphaThresholdFragmentProcessor.h index de58bbfc62..454085730b 100644 --- a/src/effects/GrAlphaThresholdFragmentProcessor.h +++ b/src/effects/GrAlphaThresholdFragmentProcessor.h @@ -1,75 +1,79 @@ /* - * Copyright 2016 Google Inc. + * 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 "GrCoordTransform.h" + #include "SkTypes.h" + #if SK_SUPPORT_GPU #include "GrFragmentProcessor.h" -#include "GrProcessorUnitTest.h" - +#include "GrCoordTransform.h" +#include "effects/GrProxyMove.h" class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor { - public: - static sk_sp Make(sk_sp proxy, - sk_sp colorSpaceXform, - sk_sp maskProxy, - float innerThreshold, - float outerThreshold, - const SkIRect& bounds) { - return sk_sp(new GrAlphaThresholdFragmentProcessor( - std::move(proxy), - std::move(colorSpaceXform), - std::move(maskProxy), - innerThreshold, outerThreshold, - bounds)); - } - - const char* name() const override { return "Alpha Threshold"; } + inline OptimizationFlags optFlags(float outerThreshold); + sk_sp colorXform() const { return fColorXform; } float innerThreshold() const { return fInnerThreshold; } float outerThreshold() const { return fOuterThreshold; } - GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } - + static sk_sp Make(sk_sp image, + sk_sp colorXform, + sk_sp mask, + float innerThreshold, + float outerThreshold, + const SkIRect& bounds) { + return sk_sp(new GrAlphaThresholdFragmentProcessor(image, + colorXform, + mask, + innerThreshold, + outerThreshold, + bounds)); + } + const char* name() const override { return "AlphaThresholdFragmentProcessor"; } private: - static OptimizationFlags OptFlags(float outerThreshold); - - GrAlphaThresholdFragmentProcessor(sk_sp proxy, - sk_sp colorSpaceXform, - sk_sp maskProxy, - float innerThreshold, - float outerThreshold, - const SkIRect& bounds); - + GrAlphaThresholdFragmentProcessor(sk_sp image, sk_sp colorXform, sk_sp 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(); + } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; - - void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; - + void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; - float fInnerThreshold; - float fOuterThreshold; GrCoordTransform fImageCoordTransform; - TextureSampler fImageTextureSampler; - // Color space transform is for the image (not the mask) - sk_sp fColorSpaceXform; GrCoordTransform fMaskCoordTransform; - TextureSampler fMaskTextureSampler; - + TextureSampler fImage; + sk_sp fColorXform; + TextureSampler fMask; + float fInnerThreshold; + float fOuterThreshold; typedef GrFragmentProcessor INHERITED; }; -#endif + #endif #endif -- cgit v1.2.3