Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkLinearGradient.h" | 8 #include "SkLinearGradient.h" |
| 9 | 9 |
| 10 static inline int repeat_bits(int x, const int bits) { | 10 static inline int repeat_bits(int x, const int bits) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 | 520 |
| 521 SkColor colors[kMaxRandomGradientColors]; | 521 SkColor colors[kMaxRandomGradientColors]; |
| 522 SkScalar stopsArray[kMaxRandomGradientColors]; | 522 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 523 SkScalar* stops = stopsArray; | 523 SkScalar* stops = stopsArray; |
| 524 SkShader::TileMode tm; | 524 SkShader::TileMode tm; |
| 525 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 525 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 526 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, | 526 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, |
| 527 colors, stops, colorCount, | 527 colors, stops, colorCount, |
| 528 tm)); | 528 tm)); |
| 529 SkPaint paint; | 529 SkPaint paint; |
| 530 return shader->asNewEffect(context, paint, NULL); | 530 GrColor grColor; |
| 531 GrEffectRef* effect; | |
| 532 shader->asNewEffect(context, paint, &grColor, &effect, NULL); | |
| 533 return effect; | |
| 531 } | 534 } |
| 532 | 535 |
| 533 ///////////////////////////////////////////////////////////////////// | 536 ///////////////////////////////////////////////////////////////////// |
| 534 | 537 |
| 535 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, | 538 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, |
| 536 const GrDrawEffect&, | 539 const GrDrawEffect&, |
| 537 EffectKey key, | 540 EffectKey key, |
| 538 const char* outputColor, | 541 const char* outputColor, |
| 539 const char* inputColor, | 542 const char* inputColor, |
| 540 const TransformedCoordsArray& coords, | 543 const TransformedCoordsArray& coords, |
| 541 const TextureSamplerArray& samplers) { | 544 const TextureSamplerArray& samplers) { |
| 542 this->emitUniforms(builder, key); | 545 this->emitUniforms(builder, key); |
| 543 SkString t = builder->ensureFSCoords2D(coords, 0); | 546 SkString t = builder->ensureFSCoords2D(coords, 0); |
| 544 t.append(".x"); | 547 t.append(".x"); |
| 545 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); | 548 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); |
| 546 } | 549 } |
| 547 | 550 |
| 548 ///////////////////////////////////////////////////////////////////// | 551 ///////////////////////////////////////////////////////////////////// |
| 549 | 552 |
| 550 GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&, | 553 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, GrC olor* grColor, |
| 551 const SkMatrix* localMatrix) const { | 554 GrEffectRef** grEffect, const SkMatrix* local Matrix) const { |
|
jvanverth1
2014/06/05 17:36:31
grColor never gets set by this method
dandov
2014/06/06 21:50:43
Done.
| |
| 552 SkASSERT(NULL != context); | 555 SkASSERT(NULL != context); |
| 553 SkMatrix matrix; | 556 SkMatrix matrix; |
| 554 if (!this->getLocalMatrix().invert(&matrix)) { | 557 if (!this->getLocalMatrix().invert(&matrix)) { |
| 555 return NULL; | 558 return false; |
| 556 } | 559 } |
| 557 if (localMatrix) { | 560 if (localMatrix) { |
| 558 SkMatrix inv; | 561 SkMatrix inv; |
| 559 if (!localMatrix->invert(&inv)) { | 562 if (!localMatrix->invert(&inv)) { |
| 560 return NULL; | 563 return false; |
| 561 } | 564 } |
| 562 matrix.postConcat(inv); | 565 matrix.postConcat(inv); |
| 563 } | 566 } |
| 564 matrix.postConcat(fPtsToUnit); | 567 matrix.postConcat(fPtsToUnit); |
| 565 return GrLinearGradient::Create(context, *this, matrix, fTileMode); | 568 *grEffect = GrLinearGradient::Create(context, *this, matrix, fTileMode); |
| 569 return true; | |
| 566 } | 570 } |
| 567 | 571 |
| 568 #else | 572 #else |
| 569 | 573 |
| 570 GrEffectRef* SkLinearGradient::asNewEffect(GrContext*, const SkPaint&, const SkM atrix*) const { | 574 bool SkLinearGradient:::asNewEffect(GrContext*, const SkPaint&, const GrColor&, |
| 575 GrEffectRef**, const SkMatrix*) const { | |
| 571 SkDEBUGFAIL("Should not call in GPU-less build"); | 576 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 572 return NULL; | 577 *grEffect = NULL; |
| 578 return false; | |
| 573 } | 579 } |
| 574 | 580 |
| 575 #endif | 581 #endif |
| 576 | 582 |
| 577 #ifndef SK_IGNORE_TO_STRING | 583 #ifndef SK_IGNORE_TO_STRING |
| 578 void SkLinearGradient::toString(SkString* str) const { | 584 void SkLinearGradient::toString(SkString* str) const { |
| 579 str->append("SkLinearGradient ("); | 585 str->append("SkLinearGradient ("); |
| 580 | 586 |
| 581 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 587 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
| 582 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 588 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
| 583 | 589 |
| 584 this->INHERITED::toString(str); | 590 this->INHERITED::toString(str); |
| 585 | 591 |
| 586 str->append(")"); | 592 str->append(")"); |
| 587 } | 593 } |
| 588 #endif | 594 #endif |
| OLD | NEW |