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

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

Issue 1251173002: Added GrGLFragmentProcessor::EmitArgs struct for use with emitCode() (Closed) Base URL: https://skia.googlesource.com/skia@composeshader_gpu
Patch Set: 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
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 ///////////////////////////////////////////////////////////////////// 461 /////////////////////////////////////////////////////////////////////
462 462
463 class GrGLLinearGradient : public GrGLGradientEffect { 463 class GrGLLinearGradient : public GrGLGradientEffect {
464 public: 464 public:
465 465
466 GrGLLinearGradient(const GrProcessor&) {} 466 GrGLLinearGradient(const GrProcessor&) {}
467 467
468 virtual ~GrGLLinearGradient() { } 468 virtual ~GrGLLinearGradient() { }
469 469
470 virtual void emitCode(GrGLFPBuilder*, 470 virtual void emitCode(EmitArgs&) override;
471 const GrFragmentProcessor&,
472 const char* outputColor,
473 const char* inputColor,
474 const TransformedCoordsArray&,
475 const TextureSamplerArray&) override;
476 471
477 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces sorKeyBuilder* b) { 472 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces sorKeyBuilder* b) {
478 b->add32(GenBaseGradientKey(processor)); 473 b->add32(GenBaseGradientKey(processor));
479 } 474 }
480 475
481 private: 476 private:
482 477
483 typedef GrGLGradientEffect INHERITED; 478 typedef GrGLGradientEffect INHERITED;
484 }; 479 };
485 480
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 GrColor paintColor; 538 GrColor paintColor;
544 GrFragmentProcessor* fp; 539 GrFragmentProcessor* fp;
545 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 540 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
546 GrTest::TestMatrix(d->fRandom), N ULL, 541 GrTest::TestMatrix(d->fRandom), N ULL,
547 &paintColor, d->fProcDataManager, &fp)); 542 &paintColor, d->fProcDataManager, &fp));
548 return fp; 543 return fp;
549 } 544 }
550 545
551 ///////////////////////////////////////////////////////////////////// 546 /////////////////////////////////////////////////////////////////////
552 547
553 void GrGLLinearGradient::emitCode(GrGLFPBuilder* builder, 548 void GrGLLinearGradient::emitCode(EmitArgs& args) {
554 const GrFragmentProcessor& fp, 549 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
555 const char* outputColor, 550 this->emitUniforms(args.fBuilder, ge);
556 const char* inputColor, 551 SkString t = args.fBuilder->getFragmentShaderBuilder()->ensureFSCoords2D(arg s.fCoords, 0);
557 const TransformedCoordsArray& coords,
558 const TextureSamplerArray& samplers) {
559 const GrLinearGradient& ge = fp.cast<GrLinearGradient>();
560 this->emitUniforms(builder, ge);
561 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 );
562 t.append(".x"); 552 t.append(".x");
563 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 553 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput Color,
554 args.fSamplers);
564 } 555 }
565 556
566 ///////////////////////////////////////////////////////////////////// 557 /////////////////////////////////////////////////////////////////////
567 558
568 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 559 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
569 const SkMatrix& viewm, const SkMatrix * localMatrix, 560 const SkMatrix& viewm, const SkMatrix * localMatrix,
570 GrColor* paintColor, 561 GrColor* paintColor,
571 GrProcessorDataManager* procDataManag er, 562 GrProcessorDataManager* procDataManag er,
572 GrFragmentProcessor** fp) const { 563 GrFragmentProcessor** fp) const {
573 SkASSERT(context); 564 SkASSERT(context);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 str->append("SkLinearGradient ("); 598 str->append("SkLinearGradient (");
608 599
609 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 600 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
610 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 601 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
611 602
612 this->INHERITED::toString(str); 603 this->INHERITED::toString(str);
613 604
614 str->append(")"); 605 str->append(")");
615 } 606 }
616 #endif 607 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698