OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrCircleBlurFragmentProcessor.h" | 9 #include "GrCircleBlurFragmentProcessor.h" |
10 | 10 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 continue; | 168 continue; |
169 } | 169 } |
170 | 170 |
171 for (int x = 0; x < kernelWH; ++x) { | 171 for (int x = 0; x < kernelWH; ++x) { |
172 float image = disk(t - kernelOff + x, -kernelOff + y, halfWidth); | 172 float image = disk(t - kernelOff + x, -kernelOff + y, halfWidth); |
173 float kernel = halfKernel[y*kernelWH+x]; | 173 float kernel = halfKernel[y*kernelWH+x]; |
174 acc += kernel * image; | 174 acc += kernel * image; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 return SkUnitScalarClampToByte(acc); | 178 return static_cast<uint8_t>(SkTPin(acc, 0.0f, 1.0f) * 255); |
179 } | 179 } |
180 | 180 |
181 static inline void compute_profile_offset_and_size(float halfWH, float sigma, | 181 static inline void compute_profile_offset_and_size(float halfWH, float sigma, |
182 float* offset, int* size) { | 182 float* offset, int* size) { |
183 | 183 |
184 if (3*sigma <= halfWH) { | 184 if (3*sigma <= halfWH) { |
185 // The circle is bigger than the Gaussian. In this case we know the inte
rior of the | 185 // The circle is bigger than the Gaussian. In this case we know the inte
rior of the |
186 // blurred circle is solid. | 186 // blurred circle is solid. |
187 *offset = halfWH - 3 * sigma; // This location maps to 0.5f in the weigh
ts texture. | 187 *offset = halfWH - 3 * sigma; // This location maps to 0.5f in the weigh
ts texture. |
188 // It should always be 255. | 188 // It should always be 255. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); | 257 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); |
258 | 258 |
259 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { | 259 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { |
260 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); | 260 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); |
261 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); | 261 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); |
262 SkRect circle = SkRect::MakeWH(wh, wh); | 262 SkRect circle = SkRect::MakeWH(wh, wh); |
263 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); | 263 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); |
264 } | 264 } |
265 | 265 |
266 #endif | 266 #endif |
OLD | NEW |