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

Side by Side Diff: src/effects/gradients/SkSweepGradient.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 "SkSweepGradient.h" 9 #include "SkSweepGradient.h"
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 private: 185 private:
186 186
187 typedef GrGLGradientEffect INHERITED; 187 typedef GrGLGradientEffect INHERITED;
188 188
189 }; 189 };
190 190
191 ///////////////////////////////////////////////////////////////////// 191 /////////////////////////////////////////////////////////////////////
192 192
193 class GrSweepGradient : public GrGradientEffect { 193 class GrSweepGradient : public GrGradientEffect {
194 public: 194 public:
195 static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& sh ader, 195 static GrFragmentProcessor* Create(GrContext* ctx,
196 const SkMatrix& m) { 196 const SkSweepGradient& shader, const SkMa trix& m, GrRenderTarget* dst) {
197 return new GrSweepGradient(ctx, shader, m); 197 return new GrSweepGradient(ctx, shader, m, dst);
198 } 198 }
199 virtual ~GrSweepGradient() { } 199 virtual ~GrSweepGradient() { }
200 200
201 const char* name() const override { return "Sweep Gradient"; } 201 const char* name() const override { return "Sweep Gradient"; }
202 202
203 private: 203 private:
204 GrSweepGradient(GrContext* ctx, 204 GrSweepGradient(GrContext* ctx,
205 const SkSweepGradient& shader, 205 const SkSweepGradient& shader,
206 const SkMatrix& matrix) 206 const SkMatrix& matrix, GrRenderTarget* dst)
207 : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { 207 : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode, dst) {
208 this->initClassID<GrSweepGradient>(); 208 this->initClassID<GrSweepGradient>();
209 } 209 }
210 210
211 GrGLFragmentProcessor* onCreateGLInstance() const override { 211 GrGLFragmentProcessor* onCreateGLInstance() const override {
212 return new GrGLSweepGradient(*this); 212 return new GrGLSweepGradient(*this);
213 } 213 }
214 214
215 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 215 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
216 GrProcessorKeyBuilder* b) const override { 216 GrProcessorKeyBuilder* b) const override {
217 GrGLSweepGradient::GenKey(*this, caps, b); 217 GrGLSweepGradient::GenKey(*this, caps, b);
(...skipping 13 matching lines...) Expand all
231 231
232 SkColor colors[kMaxRandomGradientColors]; 232 SkColor colors[kMaxRandomGradientColors];
233 SkScalar stopsArray[kMaxRandomGradientColors]; 233 SkScalar stopsArray[kMaxRandomGradientColors];
234 SkScalar* stops = stopsArray; 234 SkScalar* stops = stopsArray;
235 SkShader::TileMode tmIgnored; 235 SkShader::TileMode tmIgnored;
236 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored ); 236 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored );
237 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY, 237 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY,
238 colors, stops, c olorCount)); 238 colors, stops, c olorCount));
239 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 239 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
240 GrTest::TestMatr ix(d->fRandom), 240 GrTest::TestMatr ix(d->fRandom),
241 NULL, kNone_SkFi lterQuality); 241 NULL, kNone_SkFi lterQuality,
242 NULL);
242 GrAlwaysAssert(fp); 243 GrAlwaysAssert(fp);
243 return fp; 244 return fp;
244 } 245 }
245 246
246 ///////////////////////////////////////////////////////////////////// 247 /////////////////////////////////////////////////////////////////////
247 248
248 void GrGLSweepGradient::emitCode(EmitArgs& args) { 249 void GrGLSweepGradient::emitCode(EmitArgs& args) {
249 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>(); 250 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
250 this->emitUniforms(args.fBuilder, ge); 251 this->emitUniforms(args.fBuilder, ge);
251 SkString coords2D = args.fBuilder->getFragmentShaderBuilder() 252 SkString coords2D = args.fBuilder->getFragmentShaderBuilder()
(...skipping 12 matching lines...) Expand all
264 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput Color, 265 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput Color,
265 args.fSamplers); 266 args.fSamplers);
266 } 267 }
267 268
268 ///////////////////////////////////////////////////////////////////// 269 /////////////////////////////////////////////////////////////////////
269 270
270 const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor( 271 const GrFragmentProcessor* SkSweepGradient::asFragmentProcessor(
271 GrContext* context, 272 GrContext* context,
272 const SkMatrix& viewM, 273 const SkMatrix& viewM,
273 const SkMatrix* localMatrix, 274 const SkMatrix* localMatrix,
274 SkFilterQuality) const { 275 SkFilterQuality,
276 GrRenderTarget* dst) const {
275 277
276 SkMatrix matrix; 278 SkMatrix matrix;
277 if (!this->getLocalMatrix().invert(&matrix)) { 279 if (!this->getLocalMatrix().invert(&matrix)) {
278 return nullptr; 280 return nullptr;
279 } 281 }
280 if (localMatrix) { 282 if (localMatrix) {
281 SkMatrix inv; 283 SkMatrix inv;
282 if (!localMatrix->invert(&inv)) { 284 if (!localMatrix->invert(&inv)) {
283 return nullptr; 285 return nullptr;
284 } 286 }
285 matrix.postConcat(inv); 287 matrix.postConcat(inv);
286 } 288 }
287 matrix.postConcat(fPtsToUnit); 289 matrix.postConcat(fPtsToUnit);
288 290
289 SkAutoTUnref<const GrFragmentProcessor> inner( 291 SkAutoTUnref<const GrFragmentProcessor> inner(
290 GrSweepGradient::Create(context, *this, matrix)); 292 GrSweepGradient::Create(context, *this, matrix, dst));
291 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 293 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
292 } 294 }
293 295
294 #endif 296 #endif
295 297
296 #ifndef SK_IGNORE_TO_STRING 298 #ifndef SK_IGNORE_TO_STRING
297 void SkSweepGradient::toString(SkString* str) const { 299 void SkSweepGradient::toString(SkString* str) const {
298 str->append("SkSweepGradient: ("); 300 str->append("SkSweepGradient: (");
299 301
300 str->append("center: ("); 302 str->append("center: (");
301 str->appendScalar(fCenter.fX); 303 str->appendScalar(fCenter.fX);
302 str->append(", "); 304 str->append(", ");
303 str->appendScalar(fCenter.fY); 305 str->appendScalar(fCenter.fY);
304 str->append(") "); 306 str->append(") ");
305 307
306 this->INHERITED::toString(str); 308 this->INHERITED::toString(str);
307 309
308 str->append(")"); 310 str->append(")");
309 } 311 }
310 #endif 312 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkSweepGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698