OLD | NEW |
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 "SkTwoPointRadialGradient.h" | 9 #include "SkTwoPointRadialGradient.h" |
10 | 10 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // For brevity | 404 // For brevity |
405 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 405 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
406 | 406 |
407 class GrGLRadial2Gradient : public GrGLGradientEffect { | 407 class GrGLRadial2Gradient : public GrGLGradientEffect { |
408 | 408 |
409 public: | 409 public: |
410 | 410 |
411 GrGLRadial2Gradient(const GrBackendProcessorFactory& factory, const GrProces
sor&); | 411 GrGLRadial2Gradient(const GrBackendProcessorFactory& factory, const GrProces
sor&); |
412 virtual ~GrGLRadial2Gradient() { } | 412 virtual ~GrGLRadial2Gradient() { } |
413 | 413 |
414 virtual void emitCode(GrGLProgramBuilder*, | 414 virtual void emitCode(GrGLFPBuilder*, |
415 const GrFragmentProcessor&, | 415 const GrFragmentProcessor&, |
416 const GrProcessorKey&, | 416 const GrProcessorKey&, |
417 const char* outputColor, | 417 const char* outputColor, |
418 const char* inputColor, | 418 const char* inputColor, |
419 const TransformedCoordsArray&, | 419 const TransformedCoordsArray&, |
420 const TextureSamplerArray&) SK_OVERRIDE; | 420 const TextureSamplerArray&) SK_OVERRIDE; |
421 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 421 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
422 | 422 |
423 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); | 423 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); |
424 | 424 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 , fVSVaryingName(NULL) | 560 , fVSVaryingName(NULL) |
561 , fFSVaryingName(NULL) | 561 , fFSVaryingName(NULL) |
562 , fCachedCenter(SK_ScalarMax) | 562 , fCachedCenter(SK_ScalarMax) |
563 , fCachedRadius(-SK_ScalarMax) | 563 , fCachedRadius(-SK_ScalarMax) |
564 , fCachedPosRoot(0) { | 564 , fCachedPosRoot(0) { |
565 | 565 |
566 const GrRadial2Gradient& data = processor.cast<GrRadial2Gradient>(); | 566 const GrRadial2Gradient& data = processor.cast<GrRadial2Gradient>(); |
567 fIsDegenerate = data.isDegenerate(); | 567 fIsDegenerate = data.isDegenerate(); |
568 } | 568 } |
569 | 569 |
570 void GrGLRadial2Gradient::emitCode(GrGLProgramBuilder* builder, | 570 void GrGLRadial2Gradient::emitCode(GrGLFPBuilder* builder, |
571 const GrFragmentProcessor&, | 571 const GrFragmentProcessor&, |
572 const GrProcessorKey& key, | 572 const GrProcessorKey& key, |
573 const char* outputColor, | 573 const char* outputColor, |
574 const char* inputColor, | 574 const char* inputColor, |
575 const TransformedCoordsArray& coords, | 575 const TransformedCoordsArray& coords, |
576 const TextureSamplerArray& samplers) { | 576 const TextureSamplerArray& samplers) { |
577 uint32_t baseKey = key.get32(0); | 577 uint32_t baseKey = key.get32(0); |
578 this->emitUniforms(builder, baseKey); | 578 this->emitUniforms(builder, baseKey); |
579 fParamUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibilit
y, | 579 fParamUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibilit
y, |
580 kFloat_GrSLType, "Radial2FSParams", 6); | 580 kFloat_GrSLType, "Radial2FSParams", 6); |
581 | 581 |
582 SkString cName("c"); | 582 SkString cName("c"); |
583 SkString ac4Name("ac4"); | 583 SkString ac4Name("ac4"); |
584 SkString rootName("root"); | 584 SkString rootName("root"); |
585 SkString t; | 585 SkString t; |
586 SkString p0; | 586 SkString p0; |
587 SkString p1; | 587 SkString p1; |
588 SkString p2; | 588 SkString p2; |
589 SkString p3; | 589 SkString p3; |
590 SkString p4; | 590 SkString p4; |
591 SkString p5; | 591 SkString p5; |
592 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); | 592 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); |
593 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); | 593 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); |
594 builder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2); | 594 builder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2); |
595 builder->getUniformVariable(fParamUni).appendArrayAccess(3, &p3); | 595 builder->getUniformVariable(fParamUni).appendArrayAccess(3, &p3); |
596 builder->getUniformVariable(fParamUni).appendArrayAccess(4, &p4); | 596 builder->getUniformVariable(fParamUni).appendArrayAccess(4, &p4); |
597 builder->getUniformVariable(fParamUni).appendArrayAccess(5, &p5); | 597 builder->getUniformVariable(fParamUni).appendArrayAccess(5, &p5); |
598 | 598 |
599 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 599 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
600 // We interpolate the linear component in coords[1]. | 600 // We interpolate the linear component in coords[1]. |
601 SkASSERT(coords[0].getType() == coords[1].getType()); | 601 SkASSERT(coords[0].getType() == coords[1].getType()); |
602 const char* coords2D; | 602 const char* coords2D; |
603 SkString bVar; | 603 SkString bVar; |
604 if (kVec3f_GrSLType == coords[0].getType()) { | 604 if (kVec3f_GrSLType == coords[0].getType()) { |
605 fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy, %s.x) / %s.z;\
n", | 605 fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy, %s.x) / %s.z;\
n", |
606 coords[0].c_str(), coords[1].c_str(), coords[0].c
_str()); | 606 coords[0].c_str(), coords[1].c_str(), coords[0].c
_str()); |
607 coords2D = "interpolants.xy"; | 607 coords2D = "interpolants.xy"; |
608 bVar = "interpolants.z"; | 608 bVar = "interpolants.z"; |
609 } else { | 609 } else { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 720 |
721 #else | 721 #else |
722 | 722 |
723 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix*, | 723 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix*, |
724 GrColor*, GrFragmentProcessor
**) const { | 724 GrColor*, GrFragmentProcessor
**) const { |
725 SkDEBUGFAIL("Should not call in GPU-less build"); | 725 SkDEBUGFAIL("Should not call in GPU-less build"); |
726 return false; | 726 return false; |
727 } | 727 } |
728 | 728 |
729 #endif | 729 #endif |
OLD | NEW |