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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/SkArithmeticMode_gpu.h ('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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 outputColor, outputColor, outputColor); 51 outputColor, outputColor, outputColor);
52 } 52 }
53 } 53 }
54 54
55 class GLArithmeticFP : public GrGLFragmentProcessor { 55 class GLArithmeticFP : public GrGLFragmentProcessor {
56 public: 56 public:
57 GLArithmeticFP(const GrProcessor&) 57 GLArithmeticFP(const GrProcessor&)
58 : fEnforcePMColor(true) { 58 : fEnforcePMColor(true) {
59 } 59 }
60 60
61 ~GLArithmeticFP() SK_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) SK_OVERRIDE { 68 const TextureSamplerArray& samplers) override {
69 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 69 GrGLFPFragmentBuilder* 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
80 add_arithmetic_code(fsBuilder, inputColor, dstColor, outputColor, kUni, fEnforcePMColor); 80 add_arithmetic_code(fsBuilder, inputColor, dstColor, outputColor, kUni, fEnforcePMColor);
81 } 81 }
82 82
83 void setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) S K_OVERRIDE { 83 void setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) o verride {
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 static void GenKey(const GrProcessor& proc, const GrGLCaps& caps, GrProcesso rKeyBuilder* b) { 89 static void GenKey(const GrProcessor& proc, const GrGLCaps& caps, GrProcesso rKeyBuilder* b) {
90 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); 90 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
91 uint32_t key = arith.enforcePMColor() ? 1 : 0; 91 uint32_t key = arith.enforcePMColor() ? 1 : 0;
92 b->add32(key); 92 b->add32(key);
93 } 93 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 class ArithmeticXP : public GrXferProcessor { 161 class ArithmeticXP : public GrXferProcessor {
162 public: 162 public:
163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor, 163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
164 const GrDeviceCoordTexture* dstCopy, 164 const GrDeviceCoordTexture* dstCopy,
165 bool willReadDstColor) { 165 bool willReadDstColor) {
166 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCopy , 166 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCopy ,
167 willReadDstColor)); 167 willReadDstColor));
168 } 168 }
169 169
170 ~ArithmeticXP() SK_OVERRIDE {}; 170 ~ArithmeticXP() override {};
171 171
172 const char* name() const SK_OVERRIDE { return "Arithmetic"; } 172 const char* name() const override { return "Arithmetic"; }
173 173
174 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; 174 GrGLXferProcessor* createGLInstance() const override;
175 175
176 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } 176 bool hasSecondaryOutput() const override { return false; }
177 177
178 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 178 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
179 const GrProcOptInfo& coveragePOI, 179 const GrProcOptInfo& coveragePOI,
180 bool doesStencilWrite, 180 bool doesStencilWrite,
181 GrColor* overrideColor, 181 GrColor* overrideColor,
182 const GrDrawTargetCaps& caps) SK_ OVERRIDE; 182 const GrDrawTargetCaps& caps) ove rride;
183 183
184 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { 184 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override {
185 blendInfo->fSrcBlend = kOne_GrBlendCoeff; 185 blendInfo->fSrcBlend = kOne_GrBlendCoeff;
186 blendInfo->fDstBlend = kZero_GrBlendCoeff; 186 blendInfo->fDstBlend = kZero_GrBlendCoeff;
187 blendInfo->fBlendConstant = 0; 187 blendInfo->fBlendConstant = 0;
188 } 188 }
189 189
190 float k1() const { return fK1; } 190 float k1() const { return fK1; }
191 float k2() const { return fK2; } 191 float k2() const { return fK2; }
192 float k3() const { return fK3; } 192 float k3() const { return fK3; }
193 float k4() const { return fK4; } 193 float k4() const { return fK4; }
194 bool enforcePMColor() const { return fEnforcePMColor; } 194 bool enforcePMColor() const { return fEnforcePMColor; }
195 195
196 private: 196 private:
197 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, 197 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor,
198 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); 198 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
199 199
200 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con st SK_OVERRIDE; 200 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con st override;
201 201
202 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { 202 bool onIsEqual(const GrXferProcessor& xpBase) const override {
203 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>(); 203 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>();
204 if (fK1 != xp.fK1 || 204 if (fK1 != xp.fK1 ||
205 fK2 != xp.fK2 || 205 fK2 != xp.fK2 ||
206 fK3 != xp.fK3 || 206 fK3 != xp.fK3 ||
207 fK4 != xp.fK4 || 207 fK4 != xp.fK4 ||
208 fEnforcePMColor != xp.fEnforcePMColor) { 208 fEnforcePMColor != xp.fEnforcePMColor) {
209 return false; 209 return false;
210 } 210 }
211 return true; 211 return true;
212 } 212 }
213 213
214 float fK1, fK2, fK3, fK4; 214 float fK1, fK2, fK3, fK4;
215 bool fEnforcePMColor; 215 bool fEnforcePMColor;
216 216
217 typedef GrXferProcessor INHERITED; 217 typedef GrXferProcessor INHERITED;
218 }; 218 };
219 219
220 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
221 221
222 class GLArithmeticXP : public GrGLXferProcessor { 222 class GLArithmeticXP : public GrGLXferProcessor {
223 public: 223 public:
224 GLArithmeticXP(const GrProcessor&) 224 GLArithmeticXP(const GrProcessor&)
225 : fEnforcePMColor(true) { 225 : fEnforcePMColor(true) {
226 } 226 }
227 227
228 ~GLArithmeticXP() SK_OVERRIDE {} 228 ~GLArithmeticXP() override {}
229 229
230 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, 230 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps,
231 GrProcessorKeyBuilder* b) { 231 GrProcessorKeyBuilder* b) {
232 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 232 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
233 uint32_t key = arith.enforcePMColor() ? 1 : 0; 233 uint32_t key = arith.enforcePMColor() ? 1 : 0;
234 b->add32(key); 234 b->add32(key);
235 } 235 }
236 236
237 private: 237 private:
238 void onEmitCode(const EmitArgs& args) SK_OVERRIDE { 238 void onEmitCode(const EmitArgs& args) override {
239 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 239 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
240 240
241 const char* dstColor = fsBuilder->dstColor(); 241 const char* dstColor = fsBuilder->dstColor();
242 242
243 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility, 243 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
244 kVec4f_GrSLType, kDefault_GrSLPrecision, 244 kVec4f_GrSLType, kDefault_GrSLPrecision,
245 "k"); 245 "k");
246 const char* kUni = args.fPB->getUniformCStr(fKUni); 246 const char* kUni = args.fPB->getUniformCStr(fKUni);
247 247
248 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni, 248 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni,
249 fEnforcePMColor); 249 fEnforcePMColor);
250 250
251 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", 251 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
252 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage, 252 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
253 args.fInputCoverage, dstColor); 253 args.fInputCoverage, dstColor);
254 } 254 }
255 255
256 void onSetData(const GrGLProgramDataManager& pdman, 256 void onSetData(const GrGLProgramDataManager& pdman,
257 const GrXferProcessor& processor) SK_OVERRIDE { 257 const GrXferProcessor& processor) override {
258 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 258 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
259 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 259 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
260 fEnforcePMColor = arith.enforcePMColor(); 260 fEnforcePMColor = arith.enforcePMColor();
261 }; 261 };
262 262
263 GrGLProgramDataManager::UniformHandle fKUni; 263 GrGLProgramDataManager::UniformHandle fKUni;
264 bool fEnforcePMColor; 264 bool fEnforcePMColor;
265 265
266 typedef GrGLXferProcessor INHERITED; 266 typedef GrGLXferProcessor INHERITED;
267 }; 267 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 float k1 = random->nextF(); 333 float k1 = random->nextF();
334 float k2 = random->nextF(); 334 float k2 = random->nextF();
335 float k3 = random->nextF(); 335 float k3 = random->nextF();
336 float k4 = random->nextF(); 336 float k4 = random->nextF();
337 bool enforcePMColor = random->nextBool(); 337 bool enforcePMColor = random->nextBool();
338 338
339 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 339 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
340 } 340 }
341 341
342 #endif 342 #endif
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.h ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698