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

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

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkRadialGradient.h" 9 #include "SkRadialGradient.h"
10 #include "SkRadialGradient_Table.h" 10 #include "SkRadialGradient_Table.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 dstX += SK_Scalar1; 463 dstX += SK_Scalar1;
464 } while (--count != 0); 464 } while (--count != 0);
465 } 465 }
466 } 466 }
467 467
468 ///////////////////////////////////////////////////////////////////// 468 /////////////////////////////////////////////////////////////////////
469 469
470 #if SK_SUPPORT_GPU 470 #if SK_SUPPORT_GPU
471 471
472 #include "GrTBackendEffectFactory.h" 472 #include "GrTBackendEffectFactory.h"
473 #include "gl/GrGLShaderBuilder.h" 473 #include "gl/builders/GrGLProgramBuilder.h"
474 #include "SkGr.h" 474 #include "SkGr.h"
475 475
476 class GrGLRadialGradient : public GrGLGradientEffect { 476 class GrGLRadialGradient : public GrGLGradientEffect {
477 public: 477 public:
478 478
479 GrGLRadialGradient(const GrBackendEffectFactory& factory, 479 GrGLRadialGradient(const GrBackendEffectFactory& factory,
480 const GrDrawEffect&) : INHERITED (factory) { } 480 const GrDrawEffect&) : INHERITED (factory) { }
481 virtual ~GrGLRadialGradient() { } 481 virtual ~GrGLRadialGradient() { }
482 482
483 virtual void emitCode(GrGLShaderBuilder*, 483 virtual void emitCode(GrGLProgramBuilder*,
484 const GrDrawEffect&, 484 const GrDrawEffect&,
485 const GrEffectKey&, 485 const GrEffectKey&,
486 const char* outputColor, 486 const char* outputColor,
487 const char* inputColor, 487 const char* inputColor,
488 const TransformedCoordsArray&, 488 const TransformedCoordsArray&,
489 const TextureSamplerArray&) SK_OVERRIDE; 489 const TextureSamplerArray&) SK_OVERRIDE;
490 490
491 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) { 491 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) {
492 b->add32(GenBaseGradientKey(drawEffect)); 492 b->add32(GenBaseGradientKey(drawEffect));
493 } 493 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 tm)); 552 tm));
553 SkPaint paint; 553 SkPaint paint;
554 GrColor paintColor; 554 GrColor paintColor;
555 GrEffect* effect; 555 GrEffect* effect;
556 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t)); 556 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t));
557 return effect; 557 return effect;
558 } 558 }
559 559
560 ///////////////////////////////////////////////////////////////////// 560 /////////////////////////////////////////////////////////////////////
561 561
562 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, 562 void GrGLRadialGradient::emitCode(GrGLProgramBuilder* builder,
563 const GrDrawEffect&, 563 const GrDrawEffect&,
564 const GrEffectKey& key, 564 const GrEffectKey& key,
565 const char* outputColor, 565 const char* outputColor,
566 const char* inputColor, 566 const char* inputColor,
567 const TransformedCoordsArray& coords, 567 const TransformedCoordsArray& coords,
568 const TextureSamplerArray& samplers) { 568 const TextureSamplerArray& samplers) {
569 uint32_t baseKey = key.get32(0); 569 uint32_t baseKey = key.get32(0);
570 this->emitUniforms(builder, baseKey); 570 this->emitUniforms(builder, baseKey);
571 SkString t("length("); 571 SkString t("length(");
572 t.append(builder->ensureFSCoords2D(coords, 0)); 572 t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0));
573 t.append(")"); 573 t.append(")");
574 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs); 574 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs);
575 } 575 }
576 576
577 ///////////////////////////////////////////////////////////////////// 577 /////////////////////////////////////////////////////////////////////
578 578
579 bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint, 579 bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
580 const SkMatrix* localMatrix, GrColor* paintCo lor, 580 const SkMatrix* localMatrix, GrColor* paintCo lor,
581 GrEffect** effect) const { 581 GrEffect** effect) const {
582 SkASSERT(NULL != context); 582 SkASSERT(NULL != context);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 str->appendScalar(fCenter.fY); 621 str->appendScalar(fCenter.fY);
622 str->append(") radius: "); 622 str->append(") radius: ");
623 str->appendScalar(fRadius); 623 str->appendScalar(fRadius);
624 str->append(" "); 624 str->append(" ");
625 625
626 this->INHERITED::toString(str); 626 this->INHERITED::toString(str);
627 627
628 str->append(")"); 628 str->append(")");
629 } 629 }
630 #endif 630 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698