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

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

Issue 1110033004: Make XPFragmentBuilder only Builder with access to DstCopy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 561
562 fScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 562 fScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
563 kVec2f_GrSLType, kDefault_GrSLPrecision, "Sc ale"); 563 kVec2f_GrSLType, kDefault_GrSLPrecision, "Sc ale");
564 const char* scaleUni = builder->getUniformCStr(fScaleUni); 564 const char* scaleUni = builder->getUniformCStr(fScaleUni);
565 const char* dColor = "dColor"; 565 const char* dColor = "dColor";
566 const char* cCoords = "cCoords"; 566 const char* cCoords = "cCoords";
567 const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half floa t, use 567 const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half floa t, use
568 // a number smaller than that to approximate 0, but 568 // a number smaller than that to approximate 0, but
569 // leave room for 32-bit float GPU rounding e rrors. 569 // leave room for 32-bit float GPU rounding e rrors.
570 570
571 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 571 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
572 fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor); 572 fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
573 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].get Type()); 573 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].get Type());
574 fsBuilder->codeAppend(";\n"); 574 fsBuilder->codeAppend(";\n");
575 575
576 // Unpremultiply the displacement 576 // Unpremultiply the displacement
577 fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);", 577 fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
578 dColor, dColor, nearZero, dColor, dColor); 578 dColor, dColor, nearZero, dColor, dColor);
579 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 1); 579 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 1);
580 fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.", 580 fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
581 cCoords, coords2D.c_str(), scaleUni, dColor); 581 cCoords, coords2D.c_str(), scaleUni, dColor);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 637 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
639 639
640 uint32_t xKey = displacementMap.xChannelSelector(); 640 uint32_t xKey = displacementMap.xChannelSelector();
641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
642 642
643 b->add32(xKey | yKey); 643 b->add32(xKey | yKey);
644 } 644 }
645 #endif 645 #endif
646 646
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