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

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

Issue 374923002: Goodbye GrEffectRef. (Closed) Base URL: https://skia.googlesource.com/skia.git@noref3
Patch Set: Address comments Created 6 years, 5 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 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 "SkArithmeticMode.h" 8 #include "SkArithmeticMode.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 16 matching lines...) Expand all
27 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4, enforcePMCol or)); 27 return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4, enforcePMCol or));
28 } 28 }
29 29
30 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 30 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
31 const SkAlpha aa[]) const SK_OVERRIDE; 31 const SkAlpha aa[]) const SK_OVERRIDE;
32 32
33 SK_TO_STRING_OVERRIDE() 33 SK_TO_STRING_OVERRIDE()
34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar) 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
35 35
36 #if SK_SUPPORT_GPU 36 #if SK_SUPPORT_GPU
37 virtual bool asNewEffect(GrEffectRef** effect, GrTexture* background) const SK_OVERRIDE; 37 virtual bool asNewEffect(GrEffect** effect, GrTexture* background) const SK_ OVERRIDE;
38 #endif 38 #endif
39 39
40 private: 40 private:
41 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor) { 41 SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor) {
42 fK[0] = k1; 42 fK[0] = k1;
43 fK[1] = k2; 43 fK[1] = k2;
44 fK[2] = k3; 44 fK[2] = k3;
45 fK[3] = k4; 45 fK[3] = k4;
46 fEnforcePMColor = enforcePMColor; 46 fEnforcePMColor = enforcePMColor;
47 } 47 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 GrGLUniformManager::UniformHandle fKUni; 255 GrGLUniformManager::UniformHandle fKUni;
256 bool fEnforcePMColor; 256 bool fEnforcePMColor;
257 257
258 typedef GrGLEffect INHERITED; 258 typedef GrGLEffect INHERITED;
259 }; 259 };
260 260
261 /////////////////////////////////////////////////////////////////////////////// 261 ///////////////////////////////////////////////////////////////////////////////
262 262
263 class GrArithmeticEffect : public GrEffect { 263 class GrArithmeticEffect : public GrEffect {
264 public: 264 public:
265 static GrEffectRef* Create(float k1, float k2, float k3, float k4, bool enfo rcePMColor, 265 static GrEffect* Create(float k1, float k2, float k3, float k4, bool enforce PMColor,
266 GrTexture* background) { 266 GrTexture* background) {
267 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, b ackground)); 267 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, b ackground));
268 } 268 }
269 269
270 virtual ~GrArithmeticEffect(); 270 virtual ~GrArithmeticEffect();
271 271
272 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 272 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
273 273
274 typedef GrGLArithmeticEffect GLEffect; 274 typedef GrGLArithmeticEffect GLEffect;
275 static const char* Name() { return "Arithmetic"; } 275 static const char* Name() { return "Arithmetic"; }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 GrGLEffect::EffectKey GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffec t, 403 GrGLEffect::EffectKey GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffec t,
404 const GrGLCaps&) { 404 const GrGLCaps&) {
405 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( ); 405 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( );
406 EffectKey key = arith.enforcePMColor() ? 1 : 0; 406 EffectKey key = arith.enforcePMColor() ? 1 : 0;
407 if (arith.backgroundTexture()) { 407 if (arith.backgroundTexture()) {
408 key |= 2; 408 key |= 2;
409 } 409 }
410 return key; 410 return key;
411 } 411 }
412 412
413 GrEffectRef* GrArithmeticEffect::TestCreate(SkRandom* rand, 413 GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
414 GrContext*, 414 GrContext*,
415 const GrDrawTargetCaps&, 415 const GrDrawTargetCaps&,
416 GrTexture*[]) { 416 GrTexture*[]) {
417 float k1 = rand->nextF(); 417 float k1 = rand->nextF();
418 float k2 = rand->nextF(); 418 float k2 = rand->nextF();
419 float k3 = rand->nextF(); 419 float k3 = rand->nextF();
420 float k4 = rand->nextF(); 420 float k4 = rand->nextF();
421 bool enforcePMColor = rand->nextBool(); 421 bool enforcePMColor = rand->nextBool();
422 422
423 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, NULL) ); 423 return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, NULL) );
424 } 424 }
425 425
426 GR_DEFINE_EFFECT_TEST(GrArithmeticEffect); 426 GR_DEFINE_EFFECT_TEST(GrArithmeticEffect);
427 427
428 bool SkArithmeticMode_scalar::asNewEffect(GrEffectRef** effect, GrTexture* backg round) const { 428 bool SkArithmeticMode_scalar::asNewEffect(GrEffect** effect, GrTexture* backgrou nd) const {
429 if (effect) { 429 if (effect) {
430 *effect = GrArithmeticEffect::Create(SkScalarToFloat(fK[0]), 430 *effect = GrArithmeticEffect::Create(SkScalarToFloat(fK[0]),
431 SkScalarToFloat(fK[1]), 431 SkScalarToFloat(fK[1]),
432 SkScalarToFloat(fK[2]), 432 SkScalarToFloat(fK[2]),
433 SkScalarToFloat(fK[3]), 433 SkScalarToFloat(fK[3]),
434 fEnforcePMColor, 434 fEnforcePMColor,
435 background); 435 background);
436 } 436 }
437 return true; 437 return true;
438 } 438 }
439 439
440 #endif 440 #endif
441 441
442 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 442 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
443 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 443 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
444 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 444 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
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