| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 SkAutoTArray<float> halfKernel(kernelWH*kernelWH/2); | 202 SkAutoTArray<float> halfKernel(kernelWH*kernelWH/2); |
| 203 | 203 |
| 204 make_half_kernel(halfKernel.get(), kernelWH, sigma); | 204 make_half_kernel(halfKernel.get(), kernelWH, sigma); |
| 205 | 205 |
| 206 float offset; | 206 float offset; |
| 207 int numSteps; | 207 int numSteps; |
| 208 | 208 |
| 209 compute_profile_offset_and_size(halfWH, sigma, &offset, &numSteps); | 209 compute_profile_offset_and_size(halfWH, sigma, &offset, &numSteps); |
| 210 | 210 |
| 211 uint8_t* weights = new uint8_t[numSteps]; | 211 uint8_t* weights = new uint8_t[numSteps]; |
| 212 for (int i = 0; i < numSteps; ++i) { | 212 for (int i = 0; i < numSteps - 1; ++i) { |
| 213 weights[i] = eval_at(offset+i, halfWH, halfKernel.get(), kernelWH); | 213 weights[i] = eval_at(offset+i, halfWH, halfKernel.get(), kernelWH); |
| 214 } | 214 } |
| 215 // Ensure the tail of the Gaussian goes to zero. |
| 216 weights[numSteps-1] = 0; |
| 215 | 217 |
| 216 return weights; | 218 return weights; |
| 217 } | 219 } |
| 218 | 220 |
| 219 GrTexture* GrCircleBlurFragmentProcessor::CreateCircleBlurProfileTexture( | 221 GrTexture* GrCircleBlurFragmentProcessor::CreateCircleBlurProfileTexture( |
| 220 GrTextureProvide
r* textureProvider, | 222 GrTextureProvide
r* textureProvider, |
| 221 const SkRect& ci
rcle, | 223 const SkRect& ci
rcle, |
| 222 float sigma, | 224 float sigma, |
| 223 float* offset) { | 225 float* offset) { |
| 224 float halfWH = circle.width() / 2.0f; | 226 float halfWH = circle.width() / 2.0f; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); | 259 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); |
| 258 | 260 |
| 259 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { | 261 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { |
| 260 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); | 262 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); |
| 261 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); | 263 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); |
| 262 SkRect circle = SkRect::MakeWH(wh, wh); | 264 SkRect circle = SkRect::MakeWH(wh, wh); |
| 263 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); | 265 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); |
| 264 } | 266 } |
| 265 | 267 |
| 266 #endif | 268 #endif |
| OLD | NEW |