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

Side by Side Diff: src/gpu/effects/GrMatrixConvolutionEffect.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/GrMatrixConvolutionEffect.h ('k') | src/gpu/effects/GrSimpleTextureEffect.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 2014 Google Inc. 2 * Copyright 2014 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 #include "GrMatrixConvolutionEffect.h" 7 #include "GrMatrixConvolutionEffect.h"
8 #include "gl/GrGLProcessor.h" 8 #include "gl/GrGLProcessor.h"
9 #include "gl/GrGLTexture.h" 9 #include "gl/GrGLTexture.h"
10 #include "gl/builders/GrGLProgramBuilder.h" 10 #include "gl/builders/GrGLProgramBuilder.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 imageIncrement[0] = 1.0f / texture.width(); 131 imageIncrement[0] = 1.0f / texture.width();
132 imageIncrement[1] = ySign / texture.height(); 132 imageIncrement[1] = ySign / texture.height();
133 pdman.set2fv(fImageIncrementUni, 1, imageIncrement); 133 pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
134 pdman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset()); 134 pdman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset());
135 pdman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.ke rnel()); 135 pdman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.ke rnel());
136 pdman.set1f(fGainUni, conv.gain()); 136 pdman.set1f(fGainUni, conv.gain());
137 pdman.set1f(fBiasUni, conv.bias()); 137 pdman.set1f(fBiasUni, conv.bias());
138 fDomain.setData(pdman, conv.domain(), texture.origin()); 138 fDomain.setData(pdman, conv.domain(), texture.origin());
139 } 139 }
140 140
141 GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, 141 GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrProcessorDataManager* pro cDataManager,
142 GrTexture* texture,
142 const SkIRect& bounds, 143 const SkIRect& bounds,
143 const SkISize& kernelSize, 144 const SkISize& kernelSize,
144 const SkScalar* kernel, 145 const SkScalar* kernel,
145 SkScalar gain, 146 SkScalar gain,
146 SkScalar bias, 147 SkScalar bias,
147 const SkIPoint& kernelOffse t, 148 const SkIPoint& kernelOffse t,
148 GrTextureDomain::Mode tileM ode, 149 GrTextureDomain::Mode tileM ode,
149 bool convolveAlpha) 150 bool convolveAlpha)
150 : INHERITED(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture)), 151 : INHERITED(procDataManager, texture, GrCoordTransform::MakeDivByTextureWHMatr ix(texture)),
151 fKernelSize(kernelSize), 152 fKernelSize(kernelSize),
152 fGain(SkScalarToFloat(gain)), 153 fGain(SkScalarToFloat(gain)),
153 fBias(SkScalarToFloat(bias) / 255.0f), 154 fBias(SkScalarToFloat(bias) / 255.0f),
154 fConvolveAlpha(convolveAlpha), 155 fConvolveAlpha(convolveAlpha),
155 fDomain(GrTextureDomain::MakeTexelDomainForMode(texture, bounds, tileMode), tileMode) { 156 fDomain(GrTextureDomain::MakeTexelDomainForMode(texture, bounds, tileMode), tileMode) {
156 this->initClassID<GrMatrixConvolutionEffect>(); 157 this->initClassID<GrMatrixConvolutionEffect>();
157 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { 158 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
158 fKernel[i] = SkScalarToFloat(kernel[i]); 159 fKernel[i] = SkScalarToFloat(kernel[i]);
159 } 160 }
160 fKernelOffset[0] = static_cast<float>(kernelOffset.x()); 161 fKernelOffset[0] = static_cast<float>(kernelOffset.x());
(...skipping 19 matching lines...) Expand all
180 fKernelSize.width() * fKernelSize.height() * sizeof(float)) & & 181 fKernelSize.width() * fKernelSize.height() * sizeof(float)) & &
181 fGain == s.gain() && 182 fGain == s.gain() &&
182 fBias == s.bias() && 183 fBias == s.bias() &&
183 fKernelOffset == s.kernelOffset() && 184 fKernelOffset == s.kernelOffset() &&
184 fConvolveAlpha == s.convolveAlpha() && 185 fConvolveAlpha == s.convolveAlpha() &&
185 fDomain == s.domain(); 186 fDomain == s.domain();
186 } 187 }
187 188
188 // Static function to create a 2D convolution 189 // Static function to create a 2D convolution
189 GrFragmentProcessor* 190 GrFragmentProcessor*
190 GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture, 191 GrMatrixConvolutionEffect::CreateGaussian(GrProcessorDataManager* procDataManage r,
192 GrTexture* texture,
191 const SkIRect& bounds, 193 const SkIRect& bounds,
192 const SkISize& kernelSize, 194 const SkISize& kernelSize,
193 SkScalar gain, 195 SkScalar gain,
194 SkScalar bias, 196 SkScalar bias,
195 const SkIPoint& kernelOffset, 197 const SkIPoint& kernelOffset,
196 GrTextureDomain::Mode tileMode, 198 GrTextureDomain::Mode tileMode,
197 bool convolveAlpha, 199 bool convolveAlpha,
198 SkScalar sigmaX, 200 SkScalar sigmaX,
199 SkScalar sigmaY) { 201 SkScalar sigmaY) {
200 float kernel[MAX_KERNEL_SIZE]; 202 float kernel[MAX_KERNEL_SIZE];
(...skipping 15 matching lines...) Expand all
216 // is dropped here, since we renormalize the kernel below. 218 // is dropped here, since we renormalize the kernel below.
217 kernel[y * width + x] = xyTerm; 219 kernel[y * width + x] = xyTerm;
218 sum += xyTerm; 220 sum += xyTerm;
219 } 221 }
220 } 222 }
221 // Normalize the kernel 223 // Normalize the kernel
222 float scale = 1.0f / sum; 224 float scale = 1.0f / sum;
223 for (int i = 0; i < width * height; ++i) { 225 for (int i = 0; i < width * height; ++i) {
224 kernel[i] *= scale; 226 kernel[i] *= scale;
225 } 227 }
226 return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture, 228 return SkNEW_ARGS(GrMatrixConvolutionEffect, (procDataManager,
229 texture,
227 bounds, 230 bounds,
228 kernelSize, 231 kernelSize,
229 kernel, 232 kernel,
230 gain, 233 gain,
231 bias, 234 bias,
232 kernelOffset, 235 kernelOffset,
233 tileMode, 236 tileMode,
234 convolveAlpha)); 237 convolveAlpha));
235 } 238 }
236 239
(...skipping 13 matching lines...) Expand all
250 SkScalar bias = d->fRandom->nextSScalar1(); 253 SkScalar bias = d->fRandom->nextSScalar1();
251 SkIPoint kernelOffset = SkIPoint::Make(d->fRandom->nextRangeU(0, kernelSize. width()), 254 SkIPoint kernelOffset = SkIPoint::Make(d->fRandom->nextRangeU(0, kernelSize. width()),
252 d->fRandom->nextRangeU(0, kernelSize. height())); 255 d->fRandom->nextRangeU(0, kernelSize. height()));
253 SkIRect bounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->width()), 256 SkIRect bounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->width()),
254 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->height()), 257 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->height()),
255 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->width()), 258 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->width()),
256 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->height())); 259 d->fRandom->nextRangeU(0, d->fTextures[te xIdx]->height()));
257 GrTextureDomain::Mode tileMode = 260 GrTextureDomain::Mode tileMode =
258 static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2)); 261 static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2));
259 bool convolveAlpha = d->fRandom->nextBool(); 262 bool convolveAlpha = d->fRandom->nextBool();
260 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], 263 return GrMatrixConvolutionEffect::Create(d->fProcDataManager,
264 d->fTextures[texIdx],
261 bounds, 265 bounds,
262 kernelSize, 266 kernelSize,
263 kernel.get(), 267 kernel.get(),
264 gain, 268 gain,
265 bias, 269 bias,
266 kernelOffset, 270 kernelOffset,
267 tileMode, 271 tileMode,
268 convolveAlpha); 272 convolveAlpha);
269 } 273 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrMatrixConvolutionEffect.h ('k') | src/gpu/effects/GrSimpleTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698