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

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

Issue 648463003: FPs now use the correct builder types(just a rename) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.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 "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 /////////////////////////////////////////////////////////////////////////////// 297 ///////////////////////////////////////////////////////////////////////////////
298 298
299 #if SK_SUPPORT_GPU 299 #if SK_SUPPORT_GPU
300 class GrGLDisplacementMapEffect : public GrGLFragmentProcessor { 300 class GrGLDisplacementMapEffect : public GrGLFragmentProcessor {
301 public: 301 public:
302 GrGLDisplacementMapEffect(const GrBackendProcessorFactory&, 302 GrGLDisplacementMapEffect(const GrBackendProcessorFactory&,
303 const GrProcessor&); 303 const GrProcessor&);
304 virtual ~GrGLDisplacementMapEffect(); 304 virtual ~GrGLDisplacementMapEffect();
305 305
306 virtual void emitCode(GrGLProgramBuilder*, 306 virtual void emitCode(GrGLFPBuilder*,
307 const GrFragmentProcessor&, 307 const GrFragmentProcessor&,
308 const GrProcessorKey&, 308 const GrProcessorKey&,
309 const char* outputColor, 309 const char* outputColor,
310 const char* inputColor, 310 const char* inputColor,
311 const TransformedCoordsArray&, 311 const TransformedCoordsArray&,
312 const TextureSamplerArray&) SK_OVERRIDE; 312 const TextureSamplerArray&) SK_OVERRIDE;
313 313
314 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*); 314 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*);
315 315
316 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE; 316 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendProcessorFac tory& factory, 533 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendProcessorFac tory& factory,
534 const GrProcessor& proc) 534 const GrProcessor& proc)
535 : INHERITED(factory) 535 : INHERITED(factory)
536 , fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector()) 536 , fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
537 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) { 537 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
538 } 538 }
539 539
540 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() { 540 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
541 } 541 }
542 542
543 void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder, 543 void GrGLDisplacementMapEffect::emitCode(GrGLFPBuilder* builder,
544 const GrFragmentProcessor&, 544 const GrFragmentProcessor&,
545 const GrProcessorKey& key, 545 const GrProcessorKey& key,
546 const char* outputColor, 546 const char* outputColor,
547 const char* inputColor, 547 const char* inputColor,
548 const TransformedCoordsArray& coords, 548 const TransformedCoordsArray& coords,
549 const TextureSamplerArray& samplers) { 549 const TextureSamplerArray& samplers) {
550 sk_ignore_unused_variable(inputColor); 550 sk_ignore_unused_variable(inputColor);
551 551
552 fScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 552 fScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
553 kVec2f_GrSLType, "Scale"); 553 kVec2f_GrSLType, "Scale");
554 const char* scaleUni = builder->getUniformCStr(fScaleUni); 554 const char* scaleUni = builder->getUniformCStr(fScaleUni);
555 const char* dColor = "dColor"; 555 const char* dColor = "dColor";
556 const char* cCoords = "cCoords"; 556 const char* cCoords = "cCoords";
557 const char* outOfBounds = "outOfBounds"; 557 const char* outOfBounds = "outOfBounds";
558 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
559 // a number smaller than that to approximate 0, but 559 // a number smaller than that to approximate 0, but
560 // leave room for 32-bit float GPU rounding e rrors. 560 // leave room for 32-bit float GPU rounding e rrors.
561 561
562 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 562 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
563 fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor); 563 fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
564 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].get Type()); 564 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].get Type());
565 fsBuilder->codeAppend(";\n"); 565 fsBuilder->codeAppend(";\n");
566 566
567 // Unpremultiply the displacement 567 // Unpremultiply the displacement
568 fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);", 568 fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
569 dColor, dColor, nearZero, dColor, dColor); 569 dColor, dColor, nearZero, dColor, dColor);
570 570
571 fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.", 571 fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
572 cCoords, coords[1].c_str(), scaleUni, dColor); 572 cCoords, coords[1].c_str(), scaleUni, dColor);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, 632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
633 const GrGLCaps&, GrProcessorKeyBuilder* b ) { 633 const GrGLCaps&, GrProcessorKeyBuilder* b ) {
634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
635 635
636 uint32_t xKey = displacementMap.xChannelSelector(); 636 uint32_t xKey = displacementMap.xChannelSelector();
637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
638 638
639 b->add32(xKey | yKey); 639 b->add32(xKey | yKey);
640 } 640 }
641 #endif 641 #endif
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698