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

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

Issue 1225673007: Initial CL to create dummy GrShaderDataManager and thread it through (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 5 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 * 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 SkScalar stopsArray[kMaxRandomGradientColors]; 536 SkScalar stopsArray[kMaxRandomGradientColors];
537 SkScalar* stops = stopsArray; 537 SkScalar* stops = stopsArray;
538 SkShader::TileMode tm; 538 SkShader::TileMode tm;
539 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 539 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
540 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, 540 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
541 colors, stops, colorCount, 541 colors, stops, colorCount,
542 tm)); 542 tm));
543 SkPaint paint; 543 SkPaint paint;
544 GrColor paintColor; 544 GrColor paintColor;
545 GrFragmentProcessor* fp; 545 GrFragmentProcessor* fp;
546 GrPaint grPaint;
546 SkAssertResult(shader->asFragmentProcessor(context, paint, 547 SkAssertResult(shader->asFragmentProcessor(context, paint,
547 GrTest::TestMatrix(random), NULL, 548 GrTest::TestMatrix(random), NULL,
548 &paintColor, &fp)); 549 &paintColor, grPaint.getShaderDat aManager(), &fp));
549 return fp; 550 return fp;
550 } 551 }
551 552
552 ///////////////////////////////////////////////////////////////////// 553 /////////////////////////////////////////////////////////////////////
553 554
554 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder, 555 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder,
555 const GrFragmentProcessor& fp, 556 const GrFragmentProcessor& fp,
556 const char* outputColor, 557 const char* outputColor,
557 const char* inputColor, 558 const char* inputColor,
558 const TransformedCoordsArray& coords, 559 const TransformedCoordsArray& coords,
559 const TextureSamplerArray& samplers) { 560 const TextureSamplerArray& samplers) {
560 const GrLinearGradient& ge = fp.cast<GrLinearGradient>(); 561 const GrLinearGradient& ge = fp.cast<GrLinearGradient>();
561 this->emitUniforms(builder, ge); 562 this->emitUniforms(builder, ge);
562 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 ); 563 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 );
563 t.append(".x"); 564 t.append(".x");
564 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 565 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
565 } 566 }
566 567
567 ///////////////////////////////////////////////////////////////////// 568 /////////////////////////////////////////////////////////////////////
568 569
569 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 570 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
570 const SkMatrix& viewm, const SkMatrix * localMatrix, 571 const SkMatrix& viewm, const SkMatrix * localMatrix,
571 GrColor* paintColor, GrFragmentProces sor** fp) const { 572 GrColor* paintColor, GrShaderDataMana ger*,
573 GrFragmentProcessor** fp) const {
572 SkASSERT(context); 574 SkASSERT(context);
573 575
574 SkMatrix matrix; 576 SkMatrix matrix;
575 if (!this->getLocalMatrix().invert(&matrix)) { 577 if (!this->getLocalMatrix().invert(&matrix)) {
576 return false; 578 return false;
577 } 579 }
578 if (localMatrix) { 580 if (localMatrix) {
579 SkMatrix inv; 581 SkMatrix inv;
580 if (!localMatrix->invert(&inv)) { 582 if (!localMatrix->invert(&inv)) {
581 return false; 583 return false;
582 } 584 }
583 matrix.postConcat(inv); 585 matrix.postConcat(inv);
584 } 586 }
585 matrix.postConcat(fPtsToUnit); 587 matrix.postConcat(fPtsToUnit);
586 588
587 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 589 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
588 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); 590 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode);
589 591
590 return true; 592 return true;
591 } 593 }
592 594
593 #else 595 #else
594 596
595 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix&, 597 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix&,
596 const SkMatrix*, GrColor*, 598 const SkMatrix*, GrColor*, GrShaderDa taManager*,
597 GrFragmentProcessor**) const { 599 GrFragmentProcessor**) const {
598 SkDEBUGFAIL("Should not call in GPU-less build"); 600 SkDEBUGFAIL("Should not call in GPU-less build");
599 return false; 601 return false;
600 } 602 }
601 603
602 #endif 604 #endif
603 605
604 #ifndef SK_IGNORE_TO_STRING 606 #ifndef SK_IGNORE_TO_STRING
605 void SkLinearGradient::toString(SkString* str) const { 607 void SkLinearGradient::toString(SkString* str) const {
606 str->append("SkLinearGradient ("); 608 str->append("SkLinearGradient (");
607 609
608 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 610 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
609 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 611 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
610 612
611 this->INHERITED::toString(str); 613 this->INHERITED::toString(str);
612 614
613 str->append(")"); 615 str->append(")");
614 } 616 }
615 #endif 617 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698