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

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

Issue 1666773002: Clean up GrGLSLFragmentProcessor-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/SkColorCubeFilter.cpp ('k') | src/effects/SkLumaColorFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 str->appendf("))"); 306 str->appendf("))");
307 } 307 }
308 #endif 308 #endif
309 309
310 /////////////////////////////////////////////////////////////////////////////// 310 ///////////////////////////////////////////////////////////////////////////////
311 311
312 #if SK_SUPPORT_GPU 312 #if SK_SUPPORT_GPU
313 class GrGLDisplacementMapEffect : public GrGLSLFragmentProcessor { 313 class GrGLDisplacementMapEffect : public GrGLSLFragmentProcessor {
314 public: 314 public:
315 GrGLDisplacementMapEffect(const GrProcessor&); 315 GrGLDisplacementMapEffect(const GrProcessor&);
316 virtual ~GrGLDisplacementMapEffect();
317 316
318 virtual void emitCode(EmitArgs&) override; 317 void emitCode(EmitArgs&) override;
319 318
320 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*); 319 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*);
321 320
322 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; } 321 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; }
323 322
324 protected: 323 protected:
325 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 324 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
326 325
327 private: 326 private:
328 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; 327 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 d->fTextures[texIdxColor], colorDimen sions); 540 d->fTextures[texIdxColor], colorDimen sions);
542 } 541 }
543 542
544 /////////////////////////////////////////////////////////////////////////////// 543 ///////////////////////////////////////////////////////////////////////////////
545 544
546 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc) 545 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc)
547 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector()) 546 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
548 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) { 547 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
549 } 548 }
550 549
551 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
552 }
553
554 void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) { 550 void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
555 const GrTextureDomain& domain = args.fFp.cast<GrDisplacementMapEffect>().dom ain(); 551 const GrTextureDomain& domain = args.fFp.cast<GrDisplacementMapEffect>().dom ain();
556 552
557 fScaleUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment _Visibility, 553 fScaleUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment _Visibility,
558 kVec2f_GrSLType, kDefault_GrSLP recision, "Scale"); 554 kVec2f_GrSLType, kDefault_GrSLP recision, "Scale");
559 const char* scaleUni = args.fUniformHandler->getUniformCStr(fScaleUni); 555 const char* scaleUni = args.fUniformHandler->getUniformCStr(fScaleUni);
560 const char* dColor = "dColor"; 556 const char* dColor = "dColor";
561 const char* cCoords = "cCoords"; 557 const char* cCoords = "cCoords";
562 const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half floa t, use 558 const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half floa t, use
563 // a number smaller than that to approximate 0, but 559 // a number smaller than that to approximate 0, but
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 636 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
641 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 637 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
642 638
643 uint32_t xKey = displacementMap.xChannelSelector(); 639 uint32_t xKey = displacementMap.xChannelSelector();
644 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 640 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
645 641
646 b->add32(xKey | yKey); 642 b->add32(xKey | yKey);
647 } 643 }
648 #endif 644 #endif
649 645
OLDNEW
« no previous file with comments | « src/effects/SkColorCubeFilter.cpp ('k') | src/effects/SkLumaColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698