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

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

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: refactored to onGetGLProcessorKey; removed emitSamplers specialized template; fixed nits Created 5 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/SkDisplacementMapEffect.cpp ('k') | src/effects/SkLightingShader.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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 texture, 527 texture,
528 light, 528 light,
529 surfaceScale, 529 surfaceScale,
530 matrix, 530 matrix,
531 kd, 531 kd,
532 boundaryMode)); 532 boundaryMode));
533 } 533 }
534 534
535 const char* name() const override { return "DiffuseLighting"; } 535 const char* name() const override { return "DiffuseLighting"; }
536 536
537 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
538
539 GrGLFragmentProcessor* createGLInstance() const override; 537 GrGLFragmentProcessor* createGLInstance() const override;
540 538
541 SkScalar kd() const { return fKD; } 539 SkScalar kd() const { return fKD; }
542 540
543 private: 541 private:
542 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
543
544 bool onIsEqual(const GrFragmentProcessor&) const override; 544 bool onIsEqual(const GrFragmentProcessor&) const override;
545 545
546 GrDiffuseLightingEffect(GrProcessorDataManager*, 546 GrDiffuseLightingEffect(GrProcessorDataManager*,
547 GrTexture* texture, 547 GrTexture* texture,
548 const SkLight* light, 548 const SkLight* light,
549 SkScalar surfaceScale, 549 SkScalar surfaceScale,
550 const SkMatrix& matrix, 550 const SkMatrix& matrix,
551 SkScalar kd, 551 SkScalar kd,
552 BoundaryMode boundaryMode); 552 BoundaryMode boundaryMode);
553 553
(...skipping 17 matching lines...) Expand all
571 light, 571 light,
572 surfaceScale, 572 surfaceScale,
573 matrix, 573 matrix,
574 ks, 574 ks,
575 shininess, 575 shininess,
576 boundaryMode)); 576 boundaryMode));
577 } 577 }
578 578
579 const char* name() const override { return "SpecularLighting"; } 579 const char* name() const override { return "SpecularLighting"; }
580 580
581 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
582
583 GrGLFragmentProcessor* createGLInstance() const override; 581 GrGLFragmentProcessor* createGLInstance() const override;
584 582
585 SkScalar ks() const { return fKS; } 583 SkScalar ks() const { return fKS; }
586 SkScalar shininess() const { return fShininess; } 584 SkScalar shininess() const { return fShininess; }
587 585
588 private: 586 private:
587 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
588
589 bool onIsEqual(const GrFragmentProcessor&) const override; 589 bool onIsEqual(const GrFragmentProcessor&) const override;
590 590
591 GrSpecularLightingEffect(GrProcessorDataManager*, 591 GrSpecularLightingEffect(GrProcessorDataManager*,
592 GrTexture* texture, 592 GrTexture* texture,
593 const SkLight* light, 593 const SkLight* light,
594 SkScalar surfaceScale, 594 SkScalar surfaceScale,
595 const SkMatrix& matrix, 595 const SkMatrix& matrix,
596 SkScalar ks, 596 SkScalar ks,
597 SkScalar shininess, 597 SkScalar shininess,
598 BoundaryMode boundaryMode); 598 BoundaryMode boundaryMode);
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 : INHERITED(procDataManager, texture, light, surfaceScale, matrix, boundaryM ode), fKD(kd) { 1606 : INHERITED(procDataManager, texture, light, surfaceScale, matrix, boundaryM ode), fKD(kd) {
1607 this->initClassID<GrDiffuseLightingEffect>(); 1607 this->initClassID<GrDiffuseLightingEffect>();
1608 } 1608 }
1609 1609
1610 bool GrDiffuseLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 1610 bool GrDiffuseLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
1611 const GrDiffuseLightingEffect& s = sBase.cast<GrDiffuseLightingEffect>(); 1611 const GrDiffuseLightingEffect& s = sBase.cast<GrDiffuseLightingEffect>();
1612 return INHERITED::onIsEqual(sBase) && 1612 return INHERITED::onIsEqual(sBase) &&
1613 this->kd() == s.kd(); 1613 this->kd() == s.kd();
1614 } 1614 }
1615 1615
1616 void GrDiffuseLightingEffect::getGLProcessorKey(const GrGLSLCaps& caps, 1616 void GrDiffuseLightingEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
1617 GrProcessorKeyBuilder* b) const { 1617 GrProcessorKeyBuilder* b) const {
1618 GrGLDiffuseLightingEffect::GenKey(*this, caps, b); 1618 GrGLDiffuseLightingEffect::GenKey(*this, caps, b);
1619 } 1619 }
1620 1620
1621 GrGLFragmentProcessor* GrDiffuseLightingEffect::createGLInstance() const { 1621 GrGLFragmentProcessor* GrDiffuseLightingEffect::createGLInstance() const {
1622 return SkNEW_ARGS(GrGLDiffuseLightingEffect, (*this)); 1622 return SkNEW_ARGS(GrGLDiffuseLightingEffect, (*this));
1623 } 1623 }
1624 1624
1625 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect); 1625 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
1626 1626
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 this->initClassID<GrSpecularLightingEffect>(); 1808 this->initClassID<GrSpecularLightingEffect>();
1809 } 1809 }
1810 1810
1811 bool GrSpecularLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 1811 bool GrSpecularLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
1812 const GrSpecularLightingEffect& s = sBase.cast<GrSpecularLightingEffect>(); 1812 const GrSpecularLightingEffect& s = sBase.cast<GrSpecularLightingEffect>();
1813 return INHERITED::onIsEqual(sBase) && 1813 return INHERITED::onIsEqual(sBase) &&
1814 this->ks() == s.ks() && 1814 this->ks() == s.ks() &&
1815 this->shininess() == s.shininess(); 1815 this->shininess() == s.shininess();
1816 } 1816 }
1817 1817
1818 void GrSpecularLightingEffect::getGLProcessorKey(const GrGLSLCaps& caps, 1818 void GrSpecularLightingEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
1819 GrProcessorKeyBuilder* b) const { 1819 GrProcessorKeyBuilder* b) const {
1820 GrGLSpecularLightingEffect::GenKey(*this, caps, b); 1820 GrGLSpecularLightingEffect::GenKey(*this, caps, b);
1821 } 1821 }
1822 1822
1823 GrGLFragmentProcessor* GrSpecularLightingEffect::createGLInstance() const { 1823 GrGLFragmentProcessor* GrSpecularLightingEffect::createGLInstance() const {
1824 return SkNEW_ARGS(GrGLSpecularLightingEffect, (*this)); 1824 return SkNEW_ARGS(GrGLSpecularLightingEffect, (*this));
1825 } 1825 }
1826 1826
1827 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect); 1827 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
1828 1828
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 2014
2015 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2015 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2016 } 2016 }
2017 2017
2018 #endif 2018 #endif
2019 2019
2020 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2020 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2021 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2021 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2022 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2022 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2023 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2023 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkLightingShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698