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

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

Issue 808703006: remove view matrix from context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: one more fix Created 6 years 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
« no previous file with comments | « src/effects/gradients/SkLinearGradient.h ('k') | src/effects/gradients/SkRadialGradient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 SkScalar stopsArray[kMaxRandomGradientColors]; 532 SkScalar stopsArray[kMaxRandomGradientColors];
533 SkScalar* stops = stopsArray; 533 SkScalar* stops = stopsArray;
534 SkShader::TileMode tm; 534 SkShader::TileMode tm;
535 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 535 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
536 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, 536 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points,
537 colors, stops, colorCount, 537 colors, stops, colorCount,
538 tm)); 538 tm));
539 SkPaint paint; 539 SkPaint paint;
540 GrColor paintColor; 540 GrColor paintColor;
541 GrFragmentProcessor* fp; 541 GrFragmentProcessor* fp;
542 SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor , &fp)); 542 SkAssertResult(shader->asFragmentProcessor(context, paint,
543 GrProcessorUnitTest::TestMatrix(r andom), NULL,
544 &paintColor, &fp));
543 return fp; 545 return fp;
544 } 546 }
545 547
546 ///////////////////////////////////////////////////////////////////// 548 /////////////////////////////////////////////////////////////////////
547 549
548 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder, 550 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder,
549 const GrFragmentProcessor& fp, 551 const GrFragmentProcessor& fp,
550 const char* outputColor, 552 const char* outputColor,
551 const char* inputColor, 553 const char* inputColor,
552 const TransformedCoordsArray& coords, 554 const TransformedCoordsArray& coords,
553 const TextureSamplerArray& samplers) { 555 const TextureSamplerArray& samplers) {
554 const GrLinearGradient& ge = fp.cast<GrLinearGradient>(); 556 const GrLinearGradient& ge = fp.cast<GrLinearGradient>();
555 this->emitUniforms(builder, ge); 557 this->emitUniforms(builder, ge);
556 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 ); 558 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 );
557 t.append(".x"); 559 t.append(".x");
558 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 560 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
559 } 561 }
560 562
561 ///////////////////////////////////////////////////////////////////// 563 /////////////////////////////////////////////////////////////////////
562 564
563 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 565 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
564 const SkMatrix* localMatrix, GrColor* paintColor, 566 const SkMatrix& viewm, const SkMatrix * localMatrix,
565 GrFragmentProcessor** fp) const { 567 GrColor* paintColor, GrFragmentProces sor** fp) const {
566 SkASSERT(context); 568 SkASSERT(context);
567 569
568 SkMatrix matrix; 570 SkMatrix matrix;
569 if (!this->getLocalMatrix().invert(&matrix)) { 571 if (!this->getLocalMatrix().invert(&matrix)) {
570 return false; 572 return false;
571 } 573 }
572 if (localMatrix) { 574 if (localMatrix) {
573 SkMatrix inv; 575 SkMatrix inv;
574 if (!localMatrix->invert(&inv)) { 576 if (!localMatrix->invert(&inv)) {
575 return false; 577 return false;
576 } 578 }
577 matrix.postConcat(inv); 579 matrix.postConcat(inv);
578 } 580 }
579 matrix.postConcat(fPtsToUnit); 581 matrix.postConcat(fPtsToUnit);
580 582
581 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 583 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
582 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); 584 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode);
583 585
584 return true; 586 return true;
585 } 587 }
586 588
587 #else 589 #else
588 590
589 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix*, GrColor*, 591 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix&,
592 const SkMatrix*, GrColor*,
590 GrFragmentProcessor**) const { 593 GrFragmentProcessor**) const {
591 SkDEBUGFAIL("Should not call in GPU-less build"); 594 SkDEBUGFAIL("Should not call in GPU-less build");
592 return false; 595 return false;
593 } 596 }
594 597
595 #endif 598 #endif
596 599
597 #ifndef SK_IGNORE_TO_STRING 600 #ifndef SK_IGNORE_TO_STRING
598 void SkLinearGradient::toString(SkString* str) const { 601 void SkLinearGradient::toString(SkString* str) const {
599 str->append("SkLinearGradient ("); 602 str->append("SkLinearGradient (");
600 603
601 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 604 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
602 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 605 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
603 606
604 this->INHERITED::toString(str); 607 this->INHERITED::toString(str);
605 608
606 str->append(")"); 609 str->append(")");
607 } 610 }
608 #endif 611 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkLinearGradient.h ('k') | src/effects/gradients/SkRadialGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698