Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: src/gpu/effects/GrConvolutionEffect.cpp

Issue 1230813003: More threading of GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrConvolutionEffect.h" 8 #include "GrConvolutionEffect.h"
9 #include "gl/GrGLProcessor.h" 9 #include "gl/GrGLProcessor.h"
10 #include "gl/GrGLTexture.h" 10 #include "gl/GrGLTexture.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 key <<= 2; 147 key <<= 2;
148 if (conv.useBounds()) { 148 if (conv.useBounds()) {
149 key |= 0x2; 149 key |= 0x2;
150 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0 ; 150 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0 ;
151 } 151 }
152 b->add32(key); 152 b->add32(key);
153 } 153 }
154 154
155 /////////////////////////////////////////////////////////////////////////////// 155 ///////////////////////////////////////////////////////////////////////////////
156 156
157 GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, 157 GrConvolutionEffect::GrConvolutionEffect(GrProcessorDataManager* procDataManager ,
158 GrTexture* texture,
158 Direction direction, 159 Direction direction,
159 int radius, 160 int radius,
160 const float* kernel, 161 const float* kernel,
161 bool useBounds, 162 bool useBounds,
162 float bounds[2]) 163 float bounds[2])
163 : Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) { 164 : INHERITED(procDataManager, texture, direction, radius), fUseBounds(useBoun ds) {
164 this->initClassID<GrConvolutionEffect>(); 165 this->initClassID<GrConvolutionEffect>();
165 SkASSERT(radius <= kMaxKernelRadius); 166 SkASSERT(radius <= kMaxKernelRadius);
166 SkASSERT(kernel); 167 SkASSERT(kernel);
167 int width = this->width(); 168 int width = this->width();
168 for (int i = 0; i < width; i++) { 169 for (int i = 0; i < width; i++) {
169 fKernel[i] = kernel[i]; 170 fKernel[i] = kernel[i];
170 } 171 }
171 memcpy(fBounds, bounds, sizeof(fBounds)); 172 memcpy(fBounds, bounds, sizeof(fBounds));
172 } 173 }
173 174
174 GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, 175 GrConvolutionEffect::GrConvolutionEffect(GrProcessorDataManager* procDataManager ,
176 GrTexture* texture,
175 Direction direction, 177 Direction direction,
176 int radius, 178 int radius,
177 float gaussianSigma, 179 float gaussianSigma,
178 bool useBounds, 180 bool useBounds,
179 float bounds[2]) 181 float bounds[2])
180 : Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) { 182 : INHERITED(procDataManager, texture, direction, radius), fUseBounds(useBoun ds) {
181 this->initClassID<GrConvolutionEffect>(); 183 this->initClassID<GrConvolutionEffect>();
182 SkASSERT(radius <= kMaxKernelRadius); 184 SkASSERT(radius <= kMaxKernelRadius);
183 int width = this->width(); 185 int width = this->width();
184 186
185 float sum = 0.0f; 187 float sum = 0.0f;
186 float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma); 188 float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma);
187 for (int i = 0; i < width; ++i) { 189 for (int i = 0; i < width; ++i) {
188 float x = static_cast<float>(i - this->radius()); 190 float x = static_cast<float>(i - this->radius());
189 // Note that the constant term (1/(sqrt(2*pi*sigma^2)) of the Gaussian 191 // Note that the constant term (1/(sqrt(2*pi*sigma^2)) of the Gaussian
190 // is dropped here, since we renormalize the kernel below. 192 // is dropped here, since we renormalize the kernel below.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 float kernel[kMaxKernelWidth]; 234 float kernel[kMaxKernelWidth];
233 for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) { 235 for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) {
234 kernel[i] = d->fRandom->nextSScalar1(); 236 kernel[i] = d->fRandom->nextSScalar1();
235 } 237 }
236 float bounds[2]; 238 float bounds[2];
237 for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { 239 for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) {
238 bounds[i] = d->fRandom->nextF(); 240 bounds[i] = d->fRandom->nextF();
239 } 241 }
240 242
241 bool useBounds = d->fRandom->nextBool(); 243 bool useBounds = d->fRandom->nextBool();
242 return GrConvolutionEffect::Create(d->fTextures[texIdx], 244 return GrConvolutionEffect::Create(d->fProcDataManager,
245 d->fTextures[texIdx],
243 dir, 246 dir,
244 radius, 247 radius,
245 kernel, 248 kernel,
246 useBounds, 249 useBounds,
247 bounds); 250 bounds);
248 } 251 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698