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

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

Issue 1215643006: more threading of GrShaderDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@GrShaderDataManager3
Patch Set: tweaks 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 482
483 typedef GrGLGradientEffect INHERITED; 483 typedef GrGLGradientEffect INHERITED;
484 }; 484 };
485 485
486 ///////////////////////////////////////////////////////////////////// 486 /////////////////////////////////////////////////////////////////////
487 487
488 class GrLinearGradient : public GrGradientEffect { 488 class GrLinearGradient : public GrGradientEffect {
489 public: 489 public:
490 490
491 static GrFragmentProcessor* Create(GrContext* ctx, 491 static GrFragmentProcessor* Create(GrContext* ctx,
492 GrShaderDataManager* shaderDataManager,
492 const SkLinearGradient& shader, 493 const SkLinearGradient& shader,
493 const SkMatrix& matrix, 494 const SkMatrix& matrix,
494 SkShader::TileMode tm) { 495 SkShader::TileMode tm) {
495 return SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm)); 496 return SkNEW_ARGS(GrLinearGradient, (ctx, shaderDataManager, shader, mat rix, tm));
496 } 497 }
497 498
498 virtual ~GrLinearGradient() { } 499 virtual ~GrLinearGradient() { }
499 500
500 const char* name() const override { return "Linear Gradient"; } 501 const char* name() const override { return "Linear Gradient"; }
501 502
502 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 503 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
503 GrProcessorKeyBuilder* b) const override { 504 GrProcessorKeyBuilder* b) const override {
504 GrGLLinearGradient::GenKey(*this, caps, b); 505 GrGLLinearGradient::GenKey(*this, caps, b);
505 } 506 }
506 507
507 GrGLFragmentProcessor* createGLInstance() const override { 508 GrGLFragmentProcessor* createGLInstance() const override {
508 return SkNEW_ARGS(GrGLLinearGradient, (*this)); 509 return SkNEW_ARGS(GrGLLinearGradient, (*this));
509 } 510 }
510 511
511 private: 512 private:
512 GrLinearGradient(GrContext* ctx, 513 GrLinearGradient(GrContext* ctx,
514 GrShaderDataManager* shaderDataManager,
513 const SkLinearGradient& shader, 515 const SkLinearGradient& shader,
514 const SkMatrix& matrix, 516 const SkMatrix& matrix,
515 SkShader::TileMode tm) 517 SkShader::TileMode tm)
516 : INHERITED(ctx, shader, matrix, tm) { 518 : INHERITED(ctx, shaderDataManager, shader, matrix, tm) {
517 this->initClassID<GrLinearGradient>(); 519 this->initClassID<GrLinearGradient>();
518 } 520 }
519 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 521 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
520 522
521 typedef GrGradientEffect INHERITED; 523 typedef GrGradientEffect INHERITED;
522 }; 524 };
523 525
524 ///////////////////////////////////////////////////////////////////// 526 /////////////////////////////////////////////////////////////////////
525 527
526 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient); 528 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 this->emitUniforms(builder, ge); 564 this->emitUniforms(builder, ge);
563 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 ); 565 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0 );
564 t.append(".x"); 566 t.append(".x");
565 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); 567 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers);
566 } 568 }
567 569
568 ///////////////////////////////////////////////////////////////////// 570 /////////////////////////////////////////////////////////////////////
569 571
570 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int, 572 bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa int,
571 const SkMatrix& viewm, const SkMatrix * localMatrix, 573 const SkMatrix& viewm, const SkMatrix * localMatrix,
572 GrColor* paintColor, GrShaderDataMana ger*, 574 GrColor* paintColor,
575 GrShaderDataManager* shaderDataManage r,
573 GrFragmentProcessor** fp) const { 576 GrFragmentProcessor** fp) const {
574 SkASSERT(context); 577 SkASSERT(context);
575 578
576 SkMatrix matrix; 579 SkMatrix matrix;
577 if (!this->getLocalMatrix().invert(&matrix)) { 580 if (!this->getLocalMatrix().invert(&matrix)) {
578 return false; 581 return false;
579 } 582 }
580 if (localMatrix) { 583 if (localMatrix) {
581 SkMatrix inv; 584 SkMatrix inv;
582 if (!localMatrix->invert(&inv)) { 585 if (!localMatrix->invert(&inv)) {
583 return false; 586 return false;
584 } 587 }
585 matrix.postConcat(inv); 588 matrix.postConcat(inv);
586 } 589 }
587 matrix.postConcat(fPtsToUnit); 590 matrix.postConcat(fPtsToUnit);
588 591
589 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 592 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
590 *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode); 593 *fp = GrLinearGradient::Create(context, shaderDataManager, *this, matrix, fT ileMode);
591 594
592 return true; 595 return true;
593 } 596 }
594 597
595 #else 598 #else
596 599
597 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix&, 600 bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM atrix&,
598 const SkMatrix*, GrColor*, GrShaderDa taManager*, 601 const SkMatrix*, GrColor*, GrShaderDa taManager*,
599 GrFragmentProcessor**) const { 602 GrFragmentProcessor**) const {
600 SkDEBUGFAIL("Should not call in GPU-less build"); 603 SkDEBUGFAIL("Should not call in GPU-less build");
601 return false; 604 return false;
602 } 605 }
603 606
604 #endif 607 #endif
605 608
606 #ifndef SK_IGNORE_TO_STRING 609 #ifndef SK_IGNORE_TO_STRING
607 void SkLinearGradient::toString(SkString* str) const { 610 void SkLinearGradient::toString(SkString* str) const {
608 str->append("SkLinearGradient ("); 611 str->append("SkLinearGradient (");
609 612
610 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 613 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
611 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 614 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
612 615
613 this->INHERITED::toString(str); 616 this->INHERITED::toString(str);
614 617
615 str->append(")"); 618 str->append(")");
616 } 619 }
617 #endif 620 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698