tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h" |
Robert Phillips | 296b1cc | 2017-03-15 10:42:12 -0400 | [diff] [blame] | 9 | |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 10 | #include "src/core/SkGpuBlurUtils.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 11 | #include "src/gpu/GrTexture.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrTextureProxy.h" |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 13 | #include "src/gpu/effects/GrTextureEffect.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/glsl/GrGLSLFragmentProcessor.h" |
| 15 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 16 | #include "src/gpu/glsl/GrGLSLProgramDataManager.h" |
| 17 | #include "src/gpu/glsl/GrGLSLUniformHandler.h" |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 18 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 19 | // For brevity |
Brian Salomon | b133ffe | 2017-07-27 11:53:21 -0400 | [diff] [blame] | 20 | using UniformHandle = GrGLSLProgramDataManager::UniformHandle; |
| 21 | using Direction = GrGaussianConvolutionFragmentProcessor::Direction; |
bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 22 | |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 23 | class GrGaussianConvolutionFragmentProcessor::Impl : public GrGLSLFragmentProcessor { |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 24 | public: |
robertphillips | 9cdb992 | 2016-02-03 12:25:40 -0800 | [diff] [blame] | 25 | void emitCode(EmitArgs&) override; |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 26 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 27 | static inline void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 28 | |
wangyix | b1daa86 | 2015-08-18 11:29:31 -0700 | [diff] [blame] | 29 | protected: |
Brian Salomon | ab015ef | 2017-04-04 10:15:51 -0400 | [diff] [blame] | 30 | void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override; |
wangyix | b1daa86 | 2015-08-18 11:29:31 -0700 | [diff] [blame] | 31 | |
ericrk | 0f38612 | 2015-07-21 13:15:47 -0700 | [diff] [blame] | 32 | private: |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 33 | UniformHandle fKernelUni; |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 34 | UniformHandle fIncrementUni; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 35 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 36 | using INHERITED = GrGLSLFragmentProcessor; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 37 | }; |
| 38 | |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 39 | void GrGaussianConvolutionFragmentProcessor::Impl::emitCode(EmitArgs& args) { |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 40 | const GrGaussianConvolutionFragmentProcessor& ce = |
| 41 | args.fFp.cast<GrGaussianConvolutionFragmentProcessor>(); |
robertphillips | bf536af | 2016-02-04 06:11:53 -0800 | [diff] [blame] | 42 | |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 43 | GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 44 | |
| 45 | const char* inc; |
| 46 | fIncrementUni = uniformHandler->addUniform(&ce, kFragment_GrShaderFlag, kHalf2_GrSLType, |
| 47 | "Increment", &inc); |
robertphillips | bf536af | 2016-02-04 06:11:53 -0800 | [diff] [blame] | 48 | |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 49 | int width = SkGpuBlurUtils::KernelWidth(ce.fRadius); |
robertphillips | bf536af | 2016-02-04 06:11:53 -0800 | [diff] [blame] | 50 | |
jvanverth | 78d6eb0 | 2016-03-02 13:21:16 -0800 | [diff] [blame] | 51 | int arrayCount = (width + 3) / 4; |
| 52 | SkASSERT(4 * arrayCount >= width); |
| 53 | |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 54 | const char* kernel; |
Ethan Nicholas | 16464c3 | 2020-04-06 13:53:05 -0400 | [diff] [blame] | 55 | fKernelUni = uniformHandler->addUniformArray(&ce, kFragment_GrShaderFlag, kHalf4_GrSLType, |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 56 | "Kernel", arrayCount, &kernel); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 57 | |
cdalton | 8528541 | 2016-02-18 12:37:07 -0800 | [diff] [blame] | 58 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 59 | |
John Stiles | 1c50643 | 2020-12-14 16:14:45 -0500 | [diff] [blame] | 60 | fragBuilder->codeAppendf("half4 color = half4(0);"); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 61 | |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 62 | fragBuilder->codeAppendf("float2 coord = %s - %d.0 * %s;", args.fSampleCoord, ce.fRadius, inc); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 63 | |
| 64 | // Manually unroll loop because some drivers don't; yields 20-30% speedup. |
| 65 | for (int i = 0; i < width; i++) { |
John Stiles | 1c50643 | 2020-12-14 16:14:45 -0500 | [diff] [blame] | 66 | auto sample = this->invokeChild(/*childIndex=*/0, args, "coord"); |
| 67 | if (i != 0) { |
| 68 | fragBuilder->codeAppendf("coord += %s;", inc); |
| 69 | } |
| 70 | fragBuilder->codeAppendf("color += %s * %s[%d][%d];", |
| 71 | sample.c_str(), kernel, i / 4, i & 0x3); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 72 | } |
John Stiles | 1c50643 | 2020-12-14 16:14:45 -0500 | [diff] [blame] | 73 | fragBuilder->codeAppendf("return color;"); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 76 | void GrGaussianConvolutionFragmentProcessor::Impl::onSetData(const GrGLSLProgramDataManager& pdman, |
| 77 | const GrFragmentProcessor& processor) { |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 78 | const auto& conv = processor.cast<GrGaussianConvolutionFragmentProcessor>(); |
robertphillips | bf536af | 2016-02-04 06:11:53 -0800 | [diff] [blame] | 79 | |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 80 | float increment[2] = {}; |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 81 | increment[static_cast<int>(conv.fDirection)] = 1; |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 82 | pdman.set2fv(fIncrementUni, 1, increment); |
Robert Phillips | eaded9d | 2018-05-01 15:17:50 -0400 | [diff] [blame] | 83 | |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 84 | int width = SkGpuBlurUtils::KernelWidth(conv.fRadius); |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 85 | int arrayCount = (width + 3)/4; |
| 86 | SkDEBUGCODE(size_t arraySize = 4*arrayCount;) |
| 87 | SkASSERT(arraySize >= static_cast<size_t>(width)); |
| 88 | SkASSERT(arraySize <= SK_ARRAY_COUNT(GrGaussianConvolutionFragmentProcessor::fKernel)); |
| 89 | pdman.set4fv(fKernelUni, arrayCount, conv.fKernel); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 92 | void GrGaussianConvolutionFragmentProcessor::Impl::GenKey(const GrProcessor& processor, |
| 93 | const GrShaderCaps&, |
| 94 | GrProcessorKeyBuilder* b) { |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 95 | const auto& conv = processor.cast<GrGaussianConvolutionFragmentProcessor>(); |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 96 | b->add32(conv.fRadius); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 97 | } |
| 98 | |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 99 | /////////////////////////////////////////////////////////////////////////////// |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 100 | |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 101 | std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::Make( |
Greg Daniel | 5c08249 | 2020-01-29 15:06:49 -0500 | [diff] [blame] | 102 | GrSurfaceProxyView view, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 103 | SkAlphaType alphaType, |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 104 | Direction dir, |
| 105 | int halfWidth, |
| 106 | float gaussianSigma, |
| 107 | GrSamplerState::WrapMode wm, |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 108 | const SkIRect& subset, |
| 109 | const SkIRect* pixelDomain, |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 110 | const GrCaps& caps) { |
| 111 | std::unique_ptr<GrFragmentProcessor> child; |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 112 | GrSamplerState sampler(wm, GrSamplerState::Filter::kNearest); |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 113 | if (SkGpuBlurUtils::IsEffectivelyZeroSigma(gaussianSigma)) { |
| 114 | halfWidth = 0; |
| 115 | } |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 116 | if (pixelDomain) { |
| 117 | // Inset because we expect to be invoked at pixel centers. |
| 118 | SkRect domain = SkRect::Make(*pixelDomain).makeInset(0.5, 0.5f); |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 119 | switch (dir) { |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 120 | case Direction::kX: domain.outset(halfWidth, 0); break; |
| 121 | case Direction::kY: domain.outset(0, halfWidth); break; |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 122 | } |
| 123 | child = GrTextureEffect::MakeSubset(std::move(view), alphaType, SkMatrix::I(), sampler, |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 124 | SkRect::Make(subset), domain, caps); |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 125 | } else { |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 126 | child = GrTextureEffect::MakeSubset(std::move(view), alphaType, SkMatrix::I(), sampler, |
| 127 | SkRect::Make(subset), caps); |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 128 | } |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 129 | |
| 130 | if (SkGpuBlurUtils::IsEffectivelyZeroSigma(gaussianSigma)) { |
| 131 | return child; |
| 132 | } |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 133 | return std::unique_ptr<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor( |
| 134 | std::move(child), dir, halfWidth, gaussianSigma)); |
| 135 | } |
| 136 | |
| 137 | GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( |
| 138 | std::unique_ptr<GrFragmentProcessor> child, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 139 | Direction direction, |
| 140 | int radius, |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 141 | float gaussianSigma) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 142 | : INHERITED(kGrGaussianConvolutionFragmentProcessor_ClassID, |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 143 | ProcessorOptimizationFlags(child.get())) |
Brian Salomon | b133ffe | 2017-07-27 11:53:21 -0400 | [diff] [blame] | 144 | , fRadius(radius) |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 145 | , fDirection(direction) { |
Brian Osman | 1298bc4 | 2020-06-30 13:39:35 -0400 | [diff] [blame] | 146 | this->registerChild(std::move(child), SkSL::SampleUsage::Explicit()); |
Brian Salomon | 6862643 | 2020-04-15 12:56:13 +0000 | [diff] [blame] | 147 | SkASSERT(radius <= kMaxKernelRadius); |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 148 | SkGpuBlurUtils::Compute1DGaussianKernel(fKernel, gaussianSigma, fRadius); |
Michael Ludwig | fbe2859 | 2020-06-26 16:02:15 -0400 | [diff] [blame] | 149 | this->setUsesSampleCoordsDirectly(); |
tomhudson@google.com | fde2c0a | 2012-07-16 12:23:32 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Brian Salomon | 3f6f965 | 2017-07-28 07:34:05 -0400 | [diff] [blame] | 152 | GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( |
| 153 | const GrGaussianConvolutionFragmentProcessor& that) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 154 | : INHERITED(kGrGaussianConvolutionFragmentProcessor_ClassID, that.optimizationFlags()) |
Brian Salomon | 3f6f965 | 2017-07-28 07:34:05 -0400 | [diff] [blame] | 155 | , fRadius(that.fRadius) |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 156 | , fDirection(that.fDirection) { |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 157 | this->cloneAndRegisterAllChildProcessors(that); |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 158 | memcpy(fKernel, that.fKernel, SkGpuBlurUtils::KernelWidth(fRadius) * sizeof(float)); |
Michael Ludwig | fbe2859 | 2020-06-26 16:02:15 -0400 | [diff] [blame] | 159 | this->setUsesSampleCoordsDirectly(); |
Brian Salomon | 3f6f965 | 2017-07-28 07:34:05 -0400 | [diff] [blame] | 160 | } |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 161 | |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 162 | void GrGaussianConvolutionFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
| 163 | GrProcessorKeyBuilder* b) const { |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 164 | Impl::GenKey(*this, caps, b); |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 165 | } |
| 166 | |
Brian Salomon | 18ab203 | 2021-02-23 10:07:05 -0500 | [diff] [blame^] | 167 | std::unique_ptr<GrGLSLFragmentProcessor> |
| 168 | GrGaussianConvolutionFragmentProcessor::onMakeProgramImpl() const { |
| 169 | return std::make_unique<Impl>(); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 172 | bool GrGaussianConvolutionFragmentProcessor::onIsEqual(const GrFragmentProcessor& sBase) const { |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 173 | const auto& that = sBase.cast<GrGaussianConvolutionFragmentProcessor>(); |
Brian Salomon | 08cb4bf | 2020-05-07 15:34:15 -0400 | [diff] [blame] | 174 | return fRadius == that.fRadius && fDirection == that.fDirection && |
Michael Ludwig | e267464 | 2020-10-21 13:01:34 -0400 | [diff] [blame] | 175 | std::equal(fKernel, fKernel + SkGpuBlurUtils::KernelWidth(fRadius), that.fKernel); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 176 | } |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 177 | |
| 178 | /////////////////////////////////////////////////////////////////////////////// |
| 179 | |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 180 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGaussianConvolutionFragmentProcessor); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 181 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 182 | #if GR_TEST_UTILS |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 183 | std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate( |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 184 | GrProcessorTestData* d) { |
Greg Daniel | 026a60c | 2020-02-12 10:53:51 -0500 | [diff] [blame] | 185 | auto [view, ct, at] = d->randomView(); |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 186 | |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 187 | Direction dir = d->fRandom->nextBool() ? Direction::kY : Direction::kX; |
| 188 | SkIRect subset{ |
| 189 | static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)), |
| 190 | static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)), |
| 191 | static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)), |
| 192 | static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)), |
| 193 | }; |
| 194 | subset.sort(); |
Brian Salomon | 6862643 | 2020-04-15 12:56:13 +0000 | [diff] [blame] | 195 | |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 196 | auto wm = static_cast<GrSamplerState::WrapMode>( |
| 197 | d->fRandom->nextULessThan(GrSamplerState::kWrapModeCount)); |
Robert Phillips | 08c5ec7 | 2017-01-30 12:26:47 -0500 | [diff] [blame] | 198 | int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius); |
Brian Salomon | aee504b | 2017-01-24 12:29:36 -0500 | [diff] [blame] | 199 | float sigma = radius / 3.f; |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 200 | SkIRect temp; |
| 201 | SkIRect* domain = nullptr; |
| 202 | if (d->fRandom->nextBool()) { |
| 203 | temp = { |
| 204 | static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)), |
| 205 | static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)), |
| 206 | static_cast<int>(d->fRandom->nextRangeU(0, view.width() - 1)), |
| 207 | static_cast<int>(d->fRandom->nextRangeU(0, view.height() - 1)), |
| 208 | }; |
| 209 | temp.sort(); |
| 210 | domain = &temp; |
| 211 | } |
Robert Phillips | 08c5ec7 | 2017-01-30 12:26:47 -0500 | [diff] [blame] | 212 | |
Brian Salomon | 5ed3c2f | 2020-04-13 16:51:39 -0400 | [diff] [blame] | 213 | return GrGaussianConvolutionFragmentProcessor::Make(std::move(view), at, dir, radius, sigma, wm, |
Brian Salomon | 11ad4cc | 2020-05-15 12:07:59 -0400 | [diff] [blame] | 214 | subset, domain, *d->caps()); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 215 | } |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 216 | #endif |