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 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 521 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
522 | 522 |
523 typedef GrGradientEffect INHERITED; | 523 typedef GrGradientEffect INHERITED; |
524 }; | 524 }; |
525 | 525 |
526 ///////////////////////////////////////////////////////////////////// | 526 ///////////////////////////////////////////////////////////////////// |
527 | 527 |
528 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient); | 528 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient); |
529 | 529 |
530 GrFragmentProcessor* GrLinearGradient::TestCreate(SkRandom* random, | 530 GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) { |
531 GrContext* context, | 531 SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}
, |
532 const GrCaps&, | 532 {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}
}; |
533 GrTexture**) { | |
534 SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()}, | |
535 {random->nextUScalar1(), random->nextUScalar1()}}; | |
536 | 533 |
537 SkColor colors[kMaxRandomGradientColors]; | 534 SkColor colors[kMaxRandomGradientColors]; |
538 SkScalar stopsArray[kMaxRandomGradientColors]; | 535 SkScalar stopsArray[kMaxRandomGradientColors]; |
539 SkScalar* stops = stopsArray; | 536 SkScalar* stops = stopsArray; |
540 SkShader::TileMode tm; | 537 SkShader::TileMode tm; |
541 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 538 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
542 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, | 539 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, |
543 colors, stops,
colorCount, | 540 colors, stops,
colorCount, |
544 tm)); | 541 tm)); |
545 SkPaint paint; | 542 SkPaint paint; |
546 GrColor paintColor; | 543 GrColor paintColor; |
547 GrFragmentProcessor* fp; | 544 GrFragmentProcessor* fp; |
548 GrPaint grPaint; | 545 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
549 SkAssertResult(shader->asFragmentProcessor(context, paint, | 546 GrTest::TestMatrix(d->fRandom), N
ULL, |
550 GrTest::TestMatrix(random), NULL, | 547 &paintColor, d->fShaderDataManage
r, &fp)); |
551 &paintColor, grPaint.getShaderDat
aManager(), &fp)); | |
552 return fp; | 548 return fp; |
553 } | 549 } |
554 | 550 |
555 ///////////////////////////////////////////////////////////////////// | 551 ///////////////////////////////////////////////////////////////////// |
556 | 552 |
557 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder, | 553 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder, |
558 const GrFragmentProcessor& fp, | 554 const GrFragmentProcessor& fp, |
559 const char* outputColor, | 555 const char* outputColor, |
560 const char* inputColor, | 556 const char* inputColor, |
561 const TransformedCoordsArray& coords, | 557 const TransformedCoordsArray& coords, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 str->append("SkLinearGradient ("); | 607 str->append("SkLinearGradient ("); |
612 | 608 |
613 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 609 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
614 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 610 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
615 | 611 |
616 this->INHERITED::toString(str); | 612 this->INHERITED::toString(str); |
617 | 613 |
618 str->append(")"); | 614 str->append(")"); |
619 } | 615 } |
620 #endif | 616 #endif |
OLD | NEW |