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

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

Issue 385713005: Allow GrGLEffects to produce variable length keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: rebase 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 #if SK_SUPPORT_GPU 236 #if SK_SUPPORT_GPU
237 237
238 class GrGLArithmeticEffect : public GrGLEffect { 238 class GrGLArithmeticEffect : public GrGLEffect {
239 public: 239 public:
240 GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 240 GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
241 virtual ~GrGLArithmeticEffect(); 241 virtual ~GrGLArithmeticEffect();
242 242
243 virtual void emitCode(GrGLShaderBuilder*, 243 virtual void emitCode(GrGLShaderBuilder*,
244 const GrDrawEffect&, 244 const GrDrawEffect&,
245 EffectKey, 245 const GrEffectKey&,
246 const char* outputColor, 246 const char* outputColor,
247 const char* inputColor, 247 const char* inputColor,
248 const TransformedCoordsArray&, 248 const TransformedCoordsArray&,
249 const TextureSamplerArray&) SK_OVERRIDE; 249 const TextureSamplerArray&) SK_OVERRIDE;
250 250
251 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 251 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
252 252
253 static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps); 253 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui lder* b);
254 254
255 private: 255 private:
256 GrGLUniformManager::UniformHandle fKUni; 256 GrGLUniformManager::UniformHandle fKUni;
257 bool fEnforcePMColor; 257 bool fEnforcePMColor;
258 258
259 typedef GrGLEffect INHERITED; 259 typedef GrGLEffect INHERITED;
260 }; 260 };
261 261
262 /////////////////////////////////////////////////////////////////////////////// 262 ///////////////////////////////////////////////////////////////////////////////
263 263
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 const GrDrawEffect& drawEffect) 342 const GrDrawEffect& drawEffect)
343 : INHERITED(factory), 343 : INHERITED(factory),
344 fEnforcePMColor(true) { 344 fEnforcePMColor(true) {
345 } 345 }
346 346
347 GrGLArithmeticEffect::~GrGLArithmeticEffect() { 347 GrGLArithmeticEffect::~GrGLArithmeticEffect() {
348 } 348 }
349 349
350 void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder, 350 void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder,
351 const GrDrawEffect& drawEffect, 351 const GrDrawEffect& drawEffect,
352 EffectKey key, 352 const GrEffectKey& key,
353 const char* outputColor, 353 const char* outputColor,
354 const char* inputColor, 354 const char* inputColor,
355 const TransformedCoordsArray& coords, 355 const TransformedCoordsArray& coords,
356 const TextureSamplerArray& samplers) { 356 const TextureSamplerArray& samplers) {
357 357
358 GrTexture* backgroundTex = drawEffect.castEffect<GrArithmeticEffect>().backg roundTexture(); 358 GrTexture* backgroundTex = drawEffect.castEffect<GrArithmeticEffect>().backg roundTexture();
359 const char* dstColor; 359 const char* dstColor;
360 if (backgroundTex) { 360 if (backgroundTex) {
361 builder->fsCodeAppend("\t\tvec4 bgColor = "); 361 builder->fsCodeAppend("\t\tvec4 bgColor = ");
362 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .type()); 362 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .type());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 builder->fsCodeAppendf("\t\t%s.rgb = min(%s.rgb, %s.a);\n", outputColor, outputColor, outputColor); 394 builder->fsCodeAppendf("\t\t%s.rgb = min(%s.rgb, %s.a);\n", outputColor, outputColor, outputColor);
395 } 395 }
396 } 396 }
397 397
398 void GrGLArithmeticEffect::setData(const GrGLUniformManager& uman, const GrDrawE ffect& drawEffect) { 398 void GrGLArithmeticEffect::setData(const GrGLUniformManager& uman, const GrDrawE ffect& drawEffect) {
399 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( ); 399 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( );
400 uman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 400 uman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
401 fEnforcePMColor = arith.enforcePMColor(); 401 fEnforcePMColor = arith.enforcePMColor();
402 } 402 }
403 403
404 GrGLEffect::EffectKey GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffec t, 404 void GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect,
405 const GrGLCaps&) { 405 const GrGLCaps&, GrEffectKeyBuilder* b) {
406 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( ); 406 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>( );
407 EffectKey key = arith.enforcePMColor() ? 1 : 0; 407 uint32_t key = arith.enforcePMColor() ? 1 : 0;
408 if (arith.backgroundTexture()) { 408 if (arith.backgroundTexture()) {
409 key |= 2; 409 key |= 2;
410 } 410 }
411 return key; 411 b->add32(key);
412 } 412 }
413 413
414 GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand, 414 GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
415 GrContext*, 415 GrContext*,
416 const GrDrawTargetCaps&, 416 const GrDrawTargetCaps&,
417 GrTexture*[]) { 417 GrTexture*[]) {
418 float k1 = rand->nextF(); 418 float k1 = rand->nextF();
419 float k2 = rand->nextF(); 419 float k2 = rand->nextF();
420 float k3 = rand->nextF(); 420 float k3 = rand->nextF();
421 float k4 = rand->nextF(); 421 float k4 = rand->nextF();
(...skipping 14 matching lines...) Expand all
436 background); 436 background);
437 } 437 }
438 return true; 438 return true;
439 } 439 }
440 440
441 #endif 441 #endif
442 442
443 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 443 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
444 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 444 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
445 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 445 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