OLD | NEW |
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 ///////////////////////////////////////////////////////////////////// | 384 ///////////////////////////////////////////////////////////////////// |
385 | 385 |
386 #if SK_SUPPORT_GPU | 386 #if SK_SUPPORT_GPU |
387 | 387 |
388 #include "GrTBackendEffectFactory.h" | 388 #include "GrTBackendEffectFactory.h" |
389 | 389 |
390 class GrGLSweepGradient : public GrGLGradientEffect { | 390 class GrGLSweepGradient : public GrGLGradientEffect { |
391 public: | 391 public: |
392 | 392 |
393 GrGLSweepGradient(const GrBackendEffectFactory& factory, | 393 GrGLSweepGradient(const GrBackendEffectFactory& factory, |
394 const GrEffectRef&) : INHERITED (factory) { } | 394 const GrDrawEffect&) : INHERITED (factory) { } |
395 virtual ~GrGLSweepGradient() { } | 395 virtual ~GrGLSweepGradient() { } |
396 | 396 |
397 virtual void emitCode(GrGLShaderBuilder*, | 397 virtual void emitCode(GrGLShaderBuilder*, |
398 const GrEffectStage&, | 398 const GrDrawEffect&, |
399 EffectKey, | 399 EffectKey, |
400 const char* vertexCoords, | |
401 const char* outputColor, | 400 const char* outputColor, |
402 const char* inputColor, | 401 const char* inputColor, |
403 const TextureSamplerArray&) SK_OVERRIDE; | 402 const TextureSamplerArray&) SK_OVERRIDE; |
404 | 403 |
405 static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) { | 404 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { |
406 return GenMatrixKey(stage); | 405 return GenMatrixKey(drawEffect); |
407 } | 406 } |
408 | 407 |
409 private: | 408 private: |
410 | 409 |
411 typedef GrGLGradientEffect INHERITED; | 410 typedef GrGLGradientEffect INHERITED; |
412 | 411 |
413 }; | 412 }; |
414 | 413 |
415 ///////////////////////////////////////////////////////////////////// | 414 ///////////////////////////////////////////////////////////////////// |
416 | 415 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); | 456 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); |
458 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, | 457 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, |
459 colors, stops, c
olorCount)); | 458 colors, stops, c
olorCount)); |
460 SkPaint paint; | 459 SkPaint paint; |
461 return shader->asNewEffect(context, paint); | 460 return shader->asNewEffect(context, paint); |
462 } | 461 } |
463 | 462 |
464 ///////////////////////////////////////////////////////////////////// | 463 ///////////////////////////////////////////////////////////////////// |
465 | 464 |
466 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, | 465 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, |
467 const GrEffectStage&, | 466 const GrDrawEffect&, |
468 EffectKey key, | 467 EffectKey key, |
469 const char* vertexCoords, | |
470 const char* outputColor, | 468 const char* outputColor, |
471 const char* inputColor, | 469 const char* inputColor, |
472 const TextureSamplerArray& samplers) { | 470 const TextureSamplerArray& samplers) { |
473 this->emitYCoordUniform(builder); | 471 this->emitYCoordUniform(builder); |
474 const char* coords; | 472 const char* coords; |
475 this->setupMatrix(builder, key, vertexCoords, &coords); | 473 this->setupMatrix(builder, key, &coords); |
476 SkString t; | 474 SkString t; |
477 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords, coords); | 475 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords, coords); |
478 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[
0]); | 476 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[
0]); |
479 } | 477 } |
480 | 478 |
481 ///////////////////////////////////////////////////////////////////// | 479 ///////////////////////////////////////////////////////////////////// |
482 | 480 |
483 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) co
nst { | 481 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) co
nst { |
484 SkMatrix matrix; | 482 SkMatrix matrix; |
485 if (!this->getLocalMatrix().invert(&matrix)) { | 483 if (!this->getLocalMatrix().invert(&matrix)) { |
(...skipping 20 matching lines...) Expand all Loading... |
506 str->appendScalar(fCenter.fX); | 504 str->appendScalar(fCenter.fX); |
507 str->append(", "); | 505 str->append(", "); |
508 str->appendScalar(fCenter.fY); | 506 str->appendScalar(fCenter.fY); |
509 str->append(") "); | 507 str->append(") "); |
510 | 508 |
511 this->INHERITED::toString(str); | 509 this->INHERITED::toString(str); |
512 | 510 |
513 str->append(")"); | 511 str->append(")"); |
514 } | 512 } |
515 #endif | 513 #endif |
OLD | NEW |