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

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

Issue 1170553002: Apply coverage in XP base class when using dst reads (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: names Created 5 years, 6 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 | « include/gpu/GrXferProcessor.h ('k') | src/gpu/GrXferProcessor.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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstText ure, 165 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstText ure,
166 willReadDstColor)); 166 willReadDstColor));
167 } 167 }
168 168
169 ~ArithmeticXP() override {}; 169 ~ArithmeticXP() override {};
170 170
171 const char* name() const override { return "Arithmetic"; } 171 const char* name() const override { return "Arithmetic"; }
172 172
173 GrGLXferProcessor* createGLInstance() const override; 173 GrGLXferProcessor* createGLInstance() const override;
174 174
175 bool hasSecondaryOutput() const override { return false; }
176
177 float k1() const { return fK1; } 175 float k1() const { return fK1; }
178 float k2() const { return fK2; } 176 float k2() const { return fK2; }
179 float k3() const { return fK3; } 177 float k3() const { return fK3; }
180 float k4() const { return fK4; } 178 float k4() const { return fK4; }
181 bool enforcePMColor() const { return fEnforcePMColor; } 179 bool enforcePMColor() const { return fEnforcePMColor; }
182 180
183 private: 181 private:
184 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, 182 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor,
185 const DstTexture*, bool willReadDstColor); 183 const DstTexture*, bool willReadDstColor);
186 184
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ~GLArithmeticXP() override {} 219 ~GLArithmeticXP() override {}
222 220
223 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, 221 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
224 GrProcessorKeyBuilder* b) { 222 GrProcessorKeyBuilder* b) {
225 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 223 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
226 uint32_t key = arith.enforcePMColor() ? 1 : 0; 224 uint32_t key = arith.enforcePMColor() ? 1 : 0;
227 b->add32(key); 225 b->add32(key);
228 } 226 }
229 227
230 private: 228 private:
231 void onEmitCode(const EmitArgs& args) override { 229 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor,
232 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 230 const char* outColor, const GrXferProcessor& pr oc) override {
231 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
233 232
234 const char* dstColor = fsBuilder->dstColor(); 233 fKUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
234 kVec4f_GrSLType, kDefault_GrSLPrecision,
235 "k");
236 const char* kUni = pb->getUniformCStr(fKUni);
235 237
236 fKUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility, 238 add_arithmetic_code(fsBuilder, srcColor, dstColor, outColor, kUni, fEnfo rcePMColor);
237 kVec4f_GrSLType, kDefault_GrSLPrecision,
238 "k");
239 const char* kUni = args.fPB->getUniformCStr(fKUni);
240
241 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputP rimary, kUni,
242 fEnforcePMColor);
243
244 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
245 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
246 args.fInputCoverage, dstColor);
247 } 239 }
248 240
249 void onSetData(const GrGLProgramDataManager& pdman, 241 void onSetData(const GrGLProgramDataManager& pdman,
250 const GrXferProcessor& processor) override { 242 const GrXferProcessor& processor) override {
251 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 243 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
252 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 244 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
253 fEnforcePMColor = arith.enforcePMColor(); 245 fEnforcePMColor = arith.enforcePMColor();
254 }; 246 };
255 247
256 GrGLProgramDataManager::UniformHandle fKUni; 248 GrGLProgramDataManager::UniformHandle fKUni;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 float k1 = random->nextF(); 317 float k1 = random->nextF();
326 float k2 = random->nextF(); 318 float k2 = random->nextF();
327 float k3 = random->nextF(); 319 float k3 = random->nextF();
328 float k4 = random->nextF(); 320 float k4 = random->nextF();
329 bool enforcePMColor = random->nextBool(); 321 bool enforcePMColor = random->nextBool();
330 322
331 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 323 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
332 } 324 }
333 325
334 #endif 326 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrXferProcessor.h ('k') | src/gpu/GrXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698