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

Side by Side Diff: src/effects/SkLightingImageFilter.cpp

Issue 1416423003: Make GrGLSLProgramBuilder base class for ProgramBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 1 month 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/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkTableColorFilter.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 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 /////////////////////////////////////////////////////////////////////////////// 590 ///////////////////////////////////////////////////////////////////////////////
591 591
592 class GrGLLight { 592 class GrGLLight {
593 public: 593 public:
594 virtual ~GrGLLight() {} 594 virtual ~GrGLLight() {}
595 595
596 /** 596 /**
597 * This is called by GrGLLightingEffect::emitCode() before either of the two virtual functions 597 * This is called by GrGLLightingEffect::emitCode() before either of the two virtual functions
598 * below. It adds a vec3f uniform visible in the FS that represents the cons tant light color. 598 * below. It adds a vec3f uniform visible in the FS that represents the cons tant light color.
599 */ 599 */
600 void emitLightColorUniform(GrGLFPBuilder*); 600 void emitLightColorUniform(GrGLSLFPBuilder*);
601 601
602 /** 602 /**
603 * These two functions are called from GrGLLightingEffect's emitCode() funct ion. 603 * These two functions are called from GrGLLightingEffect's emitCode() funct ion.
604 * emitSurfaceToLight places an expression in param out that is the vector f rom the surface to 604 * emitSurfaceToLight places an expression in param out that is the vector f rom the surface to
605 * the light. The expression will be used in the FS. emitLightColor writes a n expression into 605 * the light. The expression will be used in the FS. emitLightColor writes a n expression into
606 * the FS that is the color of the light. Either function may add functions and/or uniforms to 606 * the FS that is the color of the light. Either function may add functions and/or uniforms to
607 * the FS. The default of emitLightColor appends the name of the constant li ght color uniform 607 * the FS. The default of emitLightColor appends the name of the constant li ght color uniform
608 * and so this function only needs to be overridden if the light color varie s spatially. 608 * and so this function only needs to be overridden if the light color varie s spatially.
609 */ 609 */
610 virtual void emitSurfaceToLight(GrGLFPBuilder*, const char* z) = 0; 610 virtual void emitSurfaceToLight(GrGLSLFPBuilder*, const char* z) = 0;
611 virtual void emitLightColor(GrGLFPBuilder*, const char *surfaceToLight); 611 virtual void emitLightColor(GrGLSLFPBuilder*, const char *surfaceToLight);
612 612
613 // This is called from GrGLLightingEffect's setData(). Subclasses of GrGLLig ht must call 613 // This is called from GrGLLightingEffect's setData(). Subclasses of GrGLLig ht must call
614 // INHERITED::setData(). 614 // INHERITED::setData().
615 virtual void setData(const GrGLSLProgramDataManager&, const SkImageFilterLig ht* light) const; 615 virtual void setData(const GrGLSLProgramDataManager&, const SkImageFilterLig ht* light) const;
616 616
617 protected: 617 protected:
618 /** 618 /**
619 * Gets the constant light color uniform. Subclasses can use this in their e mitLightColor 619 * Gets the constant light color uniform. Subclasses can use this in their e mitLightColor
620 * function. 620 * function.
621 */ 621 */
622 UniformHandle lightColorUni() const { return fColorUni; } 622 UniformHandle lightColorUni() const { return fColorUni; }
623 623
624 private: 624 private:
625 UniformHandle fColorUni; 625 UniformHandle fColorUni;
626 626
627 typedef SkRefCnt INHERITED; 627 typedef SkRefCnt INHERITED;
628 }; 628 };
629 629
630 /////////////////////////////////////////////////////////////////////////////// 630 ///////////////////////////////////////////////////////////////////////////////
631 631
632 class GrGLDistantLight : public GrGLLight { 632 class GrGLDistantLight : public GrGLLight {
633 public: 633 public:
634 virtual ~GrGLDistantLight() {} 634 virtual ~GrGLDistantLight() {}
635 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override; 635 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override;
636 void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; 636 void emitSurfaceToLight(GrGLSLFPBuilder*, const char* z) override;
637 637
638 private: 638 private:
639 typedef GrGLLight INHERITED; 639 typedef GrGLLight INHERITED;
640 UniformHandle fDirectionUni; 640 UniformHandle fDirectionUni;
641 }; 641 };
642 642
643 /////////////////////////////////////////////////////////////////////////////// 643 ///////////////////////////////////////////////////////////////////////////////
644 644
645 class GrGLPointLight : public GrGLLight { 645 class GrGLPointLight : public GrGLLight {
646 public: 646 public:
647 virtual ~GrGLPointLight() {} 647 virtual ~GrGLPointLight() {}
648 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override; 648 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override;
649 void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; 649 void emitSurfaceToLight(GrGLSLFPBuilder*, const char* z) override;
650 650
651 private: 651 private:
652 typedef GrGLLight INHERITED; 652 typedef GrGLLight INHERITED;
653 UniformHandle fLocationUni; 653 UniformHandle fLocationUni;
654 }; 654 };
655 655
656 /////////////////////////////////////////////////////////////////////////////// 656 ///////////////////////////////////////////////////////////////////////////////
657 657
658 class GrGLSpotLight : public GrGLLight { 658 class GrGLSpotLight : public GrGLLight {
659 public: 659 public:
660 virtual ~GrGLSpotLight() {} 660 virtual ~GrGLSpotLight() {}
661 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override; 661 void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* ligh t) const override;
662 void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; 662 void emitSurfaceToLight(GrGLSLFPBuilder*, const char* z) override;
663 void emitLightColor(GrGLFPBuilder*, const char *surfaceToLight) override; 663 void emitLightColor(GrGLSLFPBuilder*, const char *surfaceToLight) override;
664 664
665 private: 665 private:
666 typedef GrGLLight INHERITED; 666 typedef GrGLLight INHERITED;
667 667
668 SkString fLightColorFunc; 668 SkString fLightColorFunc;
669 UniformHandle fLocationUni; 669 UniformHandle fLocationUni;
670 UniformHandle fExponentUni; 670 UniformHandle fExponentUni;
671 UniformHandle fCosOuterConeAngleUni; 671 UniformHandle fCosOuterConeAngleUni;
672 UniformHandle fCosInnerConeAngleUni; 672 UniformHandle fCosInnerConeAngleUni;
673 UniformHandle fConeScaleUni; 673 UniformHandle fConeScaleUni;
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 void emitCode(EmitArgs&) override; 1515 void emitCode(EmitArgs&) override;
1516 1516
1517 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b); 1517 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder* b);
1518 1518
1519 protected: 1519 protected:
1520 /** 1520 /**
1521 * Subclasses of GrGLLightingEffect must call INHERITED::onSetData(); 1521 * Subclasses of GrGLLightingEffect must call INHERITED::onSetData();
1522 */ 1522 */
1523 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 1523 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
1524 1524
1525 virtual void emitLightFunc(GrGLFPBuilder*, SkString* funcName) = 0; 1525 virtual void emitLightFunc(GrGLSLFPBuilder*, SkString* funcName) = 0;
1526 1526
1527 private: 1527 private:
1528 typedef GrGLFragmentProcessor INHERITED; 1528 typedef GrGLFragmentProcessor INHERITED;
1529 1529
1530 UniformHandle fImageIncrementUni; 1530 UniformHandle fImageIncrementUni;
1531 UniformHandle fSurfaceScaleUni; 1531 UniformHandle fSurfaceScaleUni;
1532 GrGLLight* fLight; 1532 GrGLLight* fLight;
1533 BoundaryMode fBoundaryMode; 1533 BoundaryMode fBoundaryMode;
1534 }; 1534 };
1535 1535
1536 /////////////////////////////////////////////////////////////////////////////// 1536 ///////////////////////////////////////////////////////////////////////////////
1537 1537
1538 class GrGLDiffuseLightingEffect : public GrGLLightingEffect { 1538 class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
1539 public: 1539 public:
1540 GrGLDiffuseLightingEffect(const GrProcessor&); 1540 GrGLDiffuseLightingEffect(const GrProcessor&);
1541 void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override; 1541 void emitLightFunc(GrGLSLFPBuilder*, SkString* funcName) override;
1542 1542
1543 protected: 1543 protected:
1544 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 1544 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
1545 1545
1546 private: 1546 private:
1547 typedef GrGLLightingEffect INHERITED; 1547 typedef GrGLLightingEffect INHERITED;
1548 1548
1549 UniformHandle fKDUni; 1549 UniformHandle fKDUni;
1550 }; 1550 };
1551 1551
1552 /////////////////////////////////////////////////////////////////////////////// 1552 ///////////////////////////////////////////////////////////////////////////////
1553 1553
1554 class GrGLSpecularLightingEffect : public GrGLLightingEffect { 1554 class GrGLSpecularLightingEffect : public GrGLLightingEffect {
1555 public: 1555 public:
1556 GrGLSpecularLightingEffect(const GrProcessor&); 1556 GrGLSpecularLightingEffect(const GrProcessor&);
1557 void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override; 1557 void emitLightFunc(GrGLSLFPBuilder*, SkString* funcName) override;
1558 1558
1559 protected: 1559 protected:
1560 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 1560 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
1561 1561
1562 private: 1562 private:
1563 typedef GrGLLightingEffect INHERITED; 1563 typedef GrGLLightingEffect INHERITED;
1564 1564
1565 UniformHandle fKSUni; 1565 UniformHandle fKSUni;
1566 UniformHandle fShininessUni; 1566 UniformHandle fShininessUni;
1567 }; 1567 };
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 } 1756 }
1757 1757
1758 /////////////////////////////////////////////////////////////////////////////// 1758 ///////////////////////////////////////////////////////////////////////////////
1759 1759
1760 /////////////////////////////////////////////////////////////////////////////// 1760 ///////////////////////////////////////////////////////////////////////////////
1761 1761
1762 GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc) 1762 GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc)
1763 : INHERITED(proc) { 1763 : INHERITED(proc) {
1764 } 1764 }
1765 1765
1766 void GrGLDiffuseLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString* funcName) { 1766 void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder, SkString * funcName) {
1767 const char* kd; 1767 const char* kd;
1768 fKDUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1768 fKDUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
1769 kFloat_GrSLType, kDefault_GrSLPrecision, 1769 kFloat_GrSLType, kDefault_GrSLPrecision,
1770 "KD", &kd); 1770 "KD", &kd);
1771 1771
1772 static const GrGLSLShaderVar gLightArgs[] = { 1772 static const GrGLSLShaderVar gLightArgs[] = {
1773 GrGLSLShaderVar("normal", kVec3f_GrSLType), 1773 GrGLSLShaderVar("normal", kVec3f_GrSLType),
1774 GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType), 1774 GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType),
1775 GrGLSLShaderVar("lightColor", kVec3f_GrSLType) 1775 GrGLSLShaderVar("lightColor", kVec3f_GrSLType)
1776 }; 1776 };
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kA lphaTextureIdx], 1838 return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kA lphaTextureIdx],
1839 light, surfaceScale, matrix, ks, shi niness, mode); 1839 light, surfaceScale, matrix, ks, shi niness, mode);
1840 } 1840 }
1841 1841
1842 /////////////////////////////////////////////////////////////////////////////// 1842 ///////////////////////////////////////////////////////////////////////////////
1843 1843
1844 GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProcessor& proc) 1844 GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProcessor& proc)
1845 : INHERITED(proc) { 1845 : INHERITED(proc) {
1846 } 1846 }
1847 1847
1848 void GrGLSpecularLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString* funcName) { 1848 void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder, SkStrin g* funcName) {
1849 const char* ks; 1849 const char* ks;
1850 const char* shininess; 1850 const char* shininess;
1851 1851
1852 fKSUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1852 fKSUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
1853 kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks); 1853 kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks);
1854 fShininessUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility , 1854 fShininessUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility ,
1855 kFloat_GrSLType, 1855 kFloat_GrSLType,
1856 kDefault_GrSLPrecision, 1856 kDefault_GrSLPrecision,
1857 "Shininess", 1857 "Shininess",
1858 &shininess); 1858 &shininess);
(...skipping 18 matching lines...) Expand all
1877 1877
1878 void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman , 1878 void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman ,
1879 const GrProcessor& effect) { 1879 const GrProcessor& effect) {
1880 INHERITED::onSetData(pdman, effect); 1880 INHERITED::onSetData(pdman, effect);
1881 const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect> (); 1881 const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect> ();
1882 pdman.set1f(fKSUni, spec.ks()); 1882 pdman.set1f(fKSUni, spec.ks());
1883 pdman.set1f(fShininessUni, spec.shininess()); 1883 pdman.set1f(fShininessUni, spec.shininess());
1884 } 1884 }
1885 1885
1886 /////////////////////////////////////////////////////////////////////////////// 1886 ///////////////////////////////////////////////////////////////////////////////
1887 void GrGLLight::emitLightColorUniform(GrGLFPBuilder* builder) { 1887 void GrGLLight::emitLightColorUniform(GrGLSLFPBuilder* builder) {
1888 fColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1888 fColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
1889 kVec3f_GrSLType, kDefault_GrSLPrecision, 1889 kVec3f_GrSLType, kDefault_GrSLPrecision,
1890 "LightColor"); 1890 "LightColor");
1891 } 1891 }
1892 1892
1893 void GrGLLight::emitLightColor(GrGLFPBuilder* builder, const char *surfaceToLigh t) { 1893 void GrGLLight::emitLightColor(GrGLSLFPBuilder* builder, const char *surfaceToLi ght) {
1894 builder->getFragmentShaderBuilder()->codeAppend(builder->getUniformCStr(this ->lightColorUni())); 1894 builder->getFragmentShaderBuilder()->codeAppend(builder->getUniformCStr(this ->lightColorUni()));
1895 } 1895 }
1896 1896
1897 void GrGLLight::setData(const GrGLSLProgramDataManager& pdman, 1897 void GrGLLight::setData(const GrGLSLProgramDataManager& pdman,
1898 const SkImageFilterLight* light) const { 1898 const SkImageFilterLight* light) const {
1899 setUniformPoint3(pdman, fColorUni, 1899 setUniformPoint3(pdman, fColorUni,
1900 light->color().makeScale(SkScalarInvert(SkIntToScalar(255)) )); 1900 light->color().makeScale(SkScalarInvert(SkIntToScalar(255)) ));
1901 } 1901 }
1902 1902
1903 /////////////////////////////////////////////////////////////////////////////// 1903 ///////////////////////////////////////////////////////////////////////////////
1904 1904
1905 void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman, 1905 void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
1906 const SkImageFilterLight* light) const { 1906 const SkImageFilterLight* light) const {
1907 INHERITED::setData(pdman, light); 1907 INHERITED::setData(pdman, light);
1908 SkASSERT(light->type() == SkImageFilterLight::kDistant_LightType); 1908 SkASSERT(light->type() == SkImageFilterLight::kDistant_LightType);
1909 const SkDistantLight* distantLight = static_cast<const SkDistantLight*>(ligh t); 1909 const SkDistantLight* distantLight = static_cast<const SkDistantLight*>(ligh t);
1910 setUniformNormal3(pdman, fDirectionUni, distantLight->direction()); 1910 setUniformNormal3(pdman, fDirectionUni, distantLight->direction());
1911 } 1911 }
1912 1912
1913 void GrGLDistantLight::emitSurfaceToLight(GrGLFPBuilder* builder, const char* z) { 1913 void GrGLDistantLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
1914 const char* dir; 1914 const char* dir;
1915 fDirectionUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility , 1915 fDirectionUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility ,
1916 kVec3f_GrSLType, kDefault_GrSLPrecision, 1916 kVec3f_GrSLType, kDefault_GrSLPrecision,
1917 "LightDirection", &dir); 1917 "LightDirection", &dir);
1918 builder->getFragmentShaderBuilder()->codeAppend(dir); 1918 builder->getFragmentShaderBuilder()->codeAppend(dir);
1919 } 1919 }
1920 1920
1921 /////////////////////////////////////////////////////////////////////////////// 1921 ///////////////////////////////////////////////////////////////////////////////
1922 1922
1923 void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman, 1923 void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
1924 const SkImageFilterLight* light) const { 1924 const SkImageFilterLight* light) const {
1925 INHERITED::setData(pdman, light); 1925 INHERITED::setData(pdman, light);
1926 SkASSERT(light->type() == SkImageFilterLight::kPoint_LightType); 1926 SkASSERT(light->type() == SkImageFilterLight::kPoint_LightType);
1927 const SkPointLight* pointLight = static_cast<const SkPointLight*>(light); 1927 const SkPointLight* pointLight = static_cast<const SkPointLight*>(light);
1928 setUniformPoint3(pdman, fLocationUni, pointLight->location()); 1928 setUniformPoint3(pdman, fLocationUni, pointLight->location());
1929 } 1929 }
1930 1930
1931 void GrGLPointLight::emitSurfaceToLight(GrGLFPBuilder* builder, const char* z) { 1931 void GrGLPointLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
1932 const char* loc; 1932 const char* loc;
1933 fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1933 fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
1934 kVec3f_GrSLType, kDefault_GrSLPrecision, 1934 kVec3f_GrSLType, kDefault_GrSLPrecision,
1935 "LightLocation", &loc); 1935 "LightLocation", &loc);
1936 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 1936 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
1937 fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))", 1937 fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
1938 loc, fsBuilder->fragmentPosition(), z); 1938 loc, fsBuilder->fragmentPosition(), z);
1939 } 1939 }
1940 1940
1941 /////////////////////////////////////////////////////////////////////////////// 1941 ///////////////////////////////////////////////////////////////////////////////
1942 1942
1943 void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman, 1943 void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
1944 const SkImageFilterLight* light) const { 1944 const SkImageFilterLight* light) const {
1945 INHERITED::setData(pdman, light); 1945 INHERITED::setData(pdman, light);
1946 SkASSERT(light->type() == SkImageFilterLight::kSpot_LightType); 1946 SkASSERT(light->type() == SkImageFilterLight::kSpot_LightType);
1947 const SkSpotLight* spotLight = static_cast<const SkSpotLight *>(light); 1947 const SkSpotLight* spotLight = static_cast<const SkSpotLight *>(light);
1948 setUniformPoint3(pdman, fLocationUni, spotLight->location()); 1948 setUniformPoint3(pdman, fLocationUni, spotLight->location());
1949 pdman.set1f(fExponentUni, spotLight->specularExponent()); 1949 pdman.set1f(fExponentUni, spotLight->specularExponent());
1950 pdman.set1f(fCosInnerConeAngleUni, spotLight->cosInnerConeAngle()); 1950 pdman.set1f(fCosInnerConeAngleUni, spotLight->cosInnerConeAngle());
1951 pdman.set1f(fCosOuterConeAngleUni, spotLight->cosOuterConeAngle()); 1951 pdman.set1f(fCosOuterConeAngleUni, spotLight->cosOuterConeAngle());
1952 pdman.set1f(fConeScaleUni, spotLight->coneScale()); 1952 pdman.set1f(fConeScaleUni, spotLight->coneScale());
1953 setUniformNormal3(pdman, fSUni, spotLight->s()); 1953 setUniformNormal3(pdman, fSUni, spotLight->s());
1954 } 1954 }
1955 1955
1956 void GrGLSpotLight::emitSurfaceToLight(GrGLFPBuilder* builder, const char* z) { 1956 void GrGLSpotLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
1957 const char* location; 1957 const char* location;
1958 fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1958 fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
1959 kVec3f_GrSLType, kDefault_GrSLPrecision, 1959 kVec3f_GrSLType, kDefault_GrSLPrecision,
1960 "LightLocation", &location); 1960 "LightLocation", &location);
1961 1961
1962 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 1962 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
1963 fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))", 1963 fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
1964 location, fsBuilder->fragmentPosition(), z); 1964 location, fsBuilder->fragmentPosition(), z);
1965 } 1965 }
1966 1966
1967 void GrGLSpotLight::emitLightColor(GrGLFPBuilder* builder, 1967 void GrGLSpotLight::emitLightColor(GrGLSLFPBuilder* builder,
1968 const char *surfaceToLight) { 1968 const char *surfaceToLight) {
1969 1969
1970 const char* color = builder->getUniformCStr(this->lightColorUni()); // creat ed by parent class. 1970 const char* color = builder->getUniformCStr(this->lightColorUni()); // creat ed by parent class.
1971 1971
1972 const char* exponent; 1972 const char* exponent;
1973 const char* cosInner; 1973 const char* cosInner;
1974 const char* cosOuter; 1974 const char* cosOuter;
1975 const char* coneScale; 1975 const char* coneScale;
1976 const char* s; 1976 const char* s;
1977 fExponentUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 1977 fExponentUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 2013
2014 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2014 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2015 } 2015 }
2016 2016
2017 #endif 2017 #endif
2018 2018
2019 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2019 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2020 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2020 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2021 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2021 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2022 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2022 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698