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

Side by Side Diff: src/effects/SkArithmeticMode_gpu.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/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurMaskFilter.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 2015 Google Inc. 2 * Copyright 2015 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 "SkArithmeticMode_gpu.h" 8 #include "SkArithmeticMode_gpu.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrFragmentProcessor.h" 12 #include "GrFragmentProcessor.h"
13 #include "GrInvariantOutput.h" 13 #include "GrInvariantOutput.h"
14 #include "GrProcessor.h" 14 #include "GrProcessor.h"
15 #include "GrTexture.h" 15 #include "GrTexture.h"
16 #include "gl/GrGLCaps.h" 16 #include "gl/GrGLCaps.h"
17 #include "gl/GrGLProcessor.h" 17 #include "gl/GrGLProcessor.h"
18 #include "gl/GrGLProgramDataManager.h" 18 #include "gl/GrGLProgramDataManager.h"
19 #include "gl/builders/GrGLProgramBuilder.h" 19 #include "gl/builders/GrGLProgramBuilder.h"
20 20
21 static const bool gUseUnpremul = false; 21 static const bool gUseUnpremul = false;
22 22
23 static void add_arithmetic_code(GrGLFPFragmentBuilder* fsBuilder, 23 static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder,
24 const char* inputColor, 24 const char* inputColor,
25 const char* dstColor, 25 const char* dstColor,
26 const char* outputColor, 26 const char* outputColor,
27 const char* kUni, 27 const char* kUni,
28 bool enforcePMColor) { 28 bool enforcePMColor) {
29 // We don't try to optimize for this case at all 29 // We don't try to optimize for this case at all
30 if (NULL == inputColor) { 30 if (NULL == inputColor) {
31 fsBuilder->codeAppend("const vec4 src = vec4(1);"); 31 fsBuilder->codeAppend("const vec4 src = vec4(1);");
32 } else { 32 } else {
33 fsBuilder->codeAppendf("vec4 src = %s;", inputColor); 33 fsBuilder->codeAppendf("vec4 src = %s;", inputColor);
(...skipping 25 matching lines...) Expand all
59 } 59 }
60 60
61 ~GLArithmeticFP() override {} 61 ~GLArithmeticFP() override {}
62 62
63 void emitCode(GrGLFPBuilder* builder, 63 void emitCode(GrGLFPBuilder* builder,
64 const GrFragmentProcessor& fp, 64 const GrFragmentProcessor& fp,
65 const char* outputColor, 65 const char* outputColor,
66 const char* inputColor, 66 const char* inputColor,
67 const TransformedCoordsArray& coords, 67 const TransformedCoordsArray& coords,
68 const TextureSamplerArray& samplers) override { 68 const TextureSamplerArray& samplers) override {
69 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 69 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
70 fsBuilder->codeAppend("vec4 bgColor = "); 70 fsBuilder->codeAppend("vec4 bgColor = ");
71 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .getType()); 71 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .getType());
72 fsBuilder->codeAppendf(";"); 72 fsBuilder->codeAppendf(";");
73 const char* dstColor = "bgColor"; 73 const char* dstColor = "bgColor";
74 74
75 fKUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 75 fKUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
76 kVec4f_GrSLType, kDefault_GrSLPrecision, 76 kVec4f_GrSLType, kDefault_GrSLPrecision,
77 "k"); 77 "k");
78 const char* kUni = builder->getUniformCStr(fKUni); 78 const char* kUni = builder->getUniformCStr(fKUni);
79 79
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, 224 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
225 GrProcessorKeyBuilder* b) { 225 GrProcessorKeyBuilder* b) {
226 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 226 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
227 uint32_t key = arith.enforcePMColor() ? 1 : 0; 227 uint32_t key = arith.enforcePMColor() ? 1 : 0;
228 b->add32(key); 228 b->add32(key);
229 } 229 }
230 230
231 private: 231 private:
232 void onEmitCode(const EmitArgs& args) override { 232 void onEmitCode(const EmitArgs& args) override {
233 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 233 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
234 234
235 const char* dstColor = fsBuilder->dstColor(); 235 const char* dstColor = fsBuilder->dstColor();
236 236
237 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility, 237 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
238 kVec4f_GrSLType, kDefault_GrSLPrecision, 238 kVec4f_GrSLType, kDefault_GrSLPrecision,
239 "k"); 239 "k");
240 const char* kUni = args.fPB->getUniformCStr(fKUni); 240 const char* kUni = args.fPB->getUniformCStr(fKUni);
241 241
242 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni, 242 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni,
243 fEnforcePMColor); 243 fEnforcePMColor);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 float k1 = random->nextF(); 327 float k1 = random->nextF();
328 float k2 = random->nextF(); 328 float k2 = random->nextF();
329 float k3 = random->nextF(); 329 float k3 = random->nextF();
330 float k4 = random->nextF(); 330 float k4 = random->nextF();
331 bool enforcePMColor = random->nextBool(); 331 bool enforcePMColor = random->nextBool();
332 332
333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
334 } 334 }
335 335
336 #endif 336 #endif
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698