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

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

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month 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/GrGLFragmentProcessor.h" 17 #include "gl/GrGLFragmentProcessor.h"
18 #include "gl/GrGLProgramDataManager.h"
19 #include "gl/builders/GrGLProgramBuilder.h" 18 #include "gl/builders/GrGLProgramBuilder.h"
19 #include "glsl/GrGLSLProgramDataManager.h"
20 20
21 static const bool gUseUnpremul = false; 21 static const bool gUseUnpremul = false;
22 22
23 static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder, 23 static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder,
24 const char* srcColor, 24 const char* srcColor,
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
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 fEnforcePMColor); 73 fEnforcePMColor);
74 } 74 }
75 75
76 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces sorKeyBuilder* b) { 76 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces sorKeyBuilder* b) {
77 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); 77 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
78 uint32_t key = arith.enforcePMColor() ? 1 : 0; 78 uint32_t key = arith.enforcePMColor() ? 1 : 0;
79 b->add32(key); 79 b->add32(key);
80 } 80 }
81 81
82 protected: 82 protected:
83 void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) override { 83 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& pro c) override {
84 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); 84 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
85 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 85 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
86 fEnforcePMColor = arith.enforcePMColor(); 86 fEnforcePMColor = arith.enforcePMColor();
87 } 87 }
88 88
89 private: 89 private:
90 GrGLProgramDataManager::UniformHandle fKUni; 90 GrGLSLProgramDataManager::UniformHandle fKUni;
91 bool fEnforcePMColor; 91 bool fEnforcePMColor;
92 92
93 typedef GrGLFragmentProcessor INHERITED; 93 typedef GrGLFragmentProcessor INHERITED;
94 }; 94 };
95 95
96 /////////////////////////////////////////////////////////////////////////////// 96 ///////////////////////////////////////////////////////////////////////////////
97 97
98 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enfo rcePMColor, 98 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enfo rcePMColor,
99 const GrFragmentProcessor* dst) 99 const GrFragmentProcessor* dst)
100 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { 100 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 211 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
212 212
213 fKUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility, 213 fKUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
214 kVec4f_GrSLType, kDefault_GrSLPrecision, 214 kVec4f_GrSLType, kDefault_GrSLPrecision,
215 "k"); 215 "k");
216 const char* kUni = pb->getUniformCStr(fKUni); 216 const char* kUni = pb->getUniformCStr(fKUni);
217 217
218 add_arithmetic_code(fsBuilder, srcColor, dstColor, outColor, kUni, fEnfo rcePMColor); 218 add_arithmetic_code(fsBuilder, srcColor, dstColor, outColor, kUni, fEnfo rcePMColor);
219 } 219 }
220 220
221 void onSetData(const GrGLProgramDataManager& pdman, 221 void onSetData(const GrGLSLProgramDataManager& pdman,
222 const GrXferProcessor& processor) override { 222 const GrXferProcessor& processor) override {
223 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 223 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
224 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 224 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
225 fEnforcePMColor = arith.enforcePMColor(); 225 fEnforcePMColor = arith.enforcePMColor();
226 }; 226 };
227 227
228 GrGLProgramDataManager::UniformHandle fKUni; 228 GrGLSLProgramDataManager::UniformHandle fKUni;
229 bool fEnforcePMColor; 229 bool fEnforcePMColor;
230 230
231 typedef GrGLXferProcessor INHERITED; 231 typedef GrGLXferProcessor INHERITED;
232 }; 232 };
233 233
234 /////////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////////
235 235
236 ArithmeticXP::ArithmeticXP(const DstTexture* dstTexture, bool hasMixedSamples, 236 ArithmeticXP::ArithmeticXP(const DstTexture* dstTexture, bool hasMixedSamples,
237 float k1, float k2, float k3, float k4, bool enforceP MColor) 237 float k1, float k2, float k3, float k4, bool enforceP MColor)
238 : INHERITED(dstTexture, true, hasMixedSamples) 238 : INHERITED(dstTexture, true, hasMixedSamples)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 float k1 = d->fRandom->nextF(); 292 float k1 = d->fRandom->nextF();
293 float k2 = d->fRandom->nextF(); 293 float k2 = d->fRandom->nextF();
294 float k3 = d->fRandom->nextF(); 294 float k3 = d->fRandom->nextF();
295 float k4 = d->fRandom->nextF(); 295 float k4 = d->fRandom->nextF();
296 bool enforcePMColor = d->fRandom->nextBool(); 296 bool enforcePMColor = d->fRandom->nextBool();
297 297
298 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 298 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
299 } 299 }
300 300
301 #endif 301 #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