| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 395 |
| 396 GrGLSweepGradient(const GrBackendEffectFactory& factory, | 396 GrGLSweepGradient(const GrBackendEffectFactory& factory, |
| 397 const GrDrawEffect&) : INHERITED (factory) { } | 397 const GrDrawEffect&) : INHERITED (factory) { } |
| 398 virtual ~GrGLSweepGradient() { } | 398 virtual ~GrGLSweepGradient() { } |
| 399 | 399 |
| 400 virtual void emitCode(GrGLShaderBuilder*, | 400 virtual void emitCode(GrGLShaderBuilder*, |
| 401 const GrDrawEffect&, | 401 const GrDrawEffect&, |
| 402 EffectKey, | 402 EffectKey, |
| 403 const char* outputColor, | 403 const char* outputColor, |
| 404 const char* inputColor, | 404 const char* inputColor, |
| 405 const TransformedCoordsArray&, |
| 405 const TextureSamplerArray&) SK_OVERRIDE; | 406 const TextureSamplerArray&) SK_OVERRIDE; |
| 406 | 407 |
| 407 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { | 408 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { |
| 408 return GenBaseGradientKey(drawEffect); | 409 return GenBaseGradientKey(drawEffect); |
| 409 } | 410 } |
| 410 | 411 |
| 411 private: | 412 private: |
| 412 | 413 |
| 413 typedef GrGLGradientEffect INHERITED; | 414 typedef GrGLGradientEffect INHERITED; |
| 414 | 415 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return shader->asNewEffect(context, paint); | 465 return shader->asNewEffect(context, paint); |
| 465 } | 466 } |
| 466 | 467 |
| 467 ///////////////////////////////////////////////////////////////////// | 468 ///////////////////////////////////////////////////////////////////// |
| 468 | 469 |
| 469 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, | 470 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, |
| 470 const GrDrawEffect&, | 471 const GrDrawEffect&, |
| 471 EffectKey key, | 472 EffectKey key, |
| 472 const char* outputColor, | 473 const char* outputColor, |
| 473 const char* inputColor, | 474 const char* inputColor, |
| 475 const TransformedCoordsArray& coords, |
| 474 const TextureSamplerArray& samplers) { | 476 const TextureSamplerArray& samplers) { |
| 475 this->emitUniforms(builder, key); | 477 this->emitUniforms(builder, key); |
| 476 SkString coords; | 478 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
| 477 this->setupMatrix(builder, key, &coords); | |
| 478 SkString t; | 479 SkString t; |
| 479 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords.c_str(), coo
rds.c_str()); | 480 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", coords2D.c_str(), c
oords2D.c_str()); |
| 480 this->emitColor(builder, t.c_str(), key, | 481 this->emitColor(builder, t.c_str(), key, |
| 481 outputColor, inputColor, samplers); | 482 outputColor, inputColor, samplers); |
| 482 } | 483 } |
| 483 | 484 |
| 484 ///////////////////////////////////////////////////////////////////// | 485 ///////////////////////////////////////////////////////////////////// |
| 485 | 486 |
| 486 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) co
nst { | 487 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) co
nst { |
| 487 SkMatrix matrix; | 488 SkMatrix matrix; |
| 488 if (!this->getLocalMatrix().invert(&matrix)) { | 489 if (!this->getLocalMatrix().invert(&matrix)) { |
| 489 return NULL; | 490 return NULL; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 509 str->appendScalar(fCenter.fX); | 510 str->appendScalar(fCenter.fX); |
| 510 str->append(", "); | 511 str->append(", "); |
| 511 str->appendScalar(fCenter.fY); | 512 str->appendScalar(fCenter.fY); |
| 512 str->append(") "); | 513 str->append(") "); |
| 513 | 514 |
| 514 this->INHERITED::toString(str); | 515 this->INHERITED::toString(str); |
| 515 | 516 |
| 516 str->append(")"); | 517 str->append(")"); |
| 517 } | 518 } |
| 518 #endif | 519 #endif |
| OLD | NEW |