OLD | NEW |
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 ////////////////////////////////////////////////////////////////////////////// | 247 ////////////////////////////////////////////////////////////////////////////// |
248 | 248 |
249 #if SK_SUPPORT_GPU | 249 #if SK_SUPPORT_GPU |
250 | 250 |
251 class GrGLArithmeticEffect : public GrGLFragmentProcessor { | 251 class GrGLArithmeticEffect : public GrGLFragmentProcessor { |
252 public: | 252 public: |
253 GrGLArithmeticEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 253 GrGLArithmeticEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
254 virtual ~GrGLArithmeticEffect(); | 254 virtual ~GrGLArithmeticEffect(); |
255 | 255 |
256 virtual void emitCode(GrGLProgramBuilder*, | 256 virtual void emitCode(GrGLFPBuilder*, |
257 const GrFragmentProcessor&, | 257 const GrFragmentProcessor&, |
258 const GrProcessorKey&, | 258 const GrProcessorKey&, |
259 const char* outputColor, | 259 const char* outputColor, |
260 const char* inputColor, | 260 const char* inputColor, |
261 const TransformedCoordsArray&, | 261 const TransformedCoordsArray&, |
262 const TextureSamplerArray&) SK_OVERRIDE; | 262 const TextureSamplerArray&) SK_OVERRIDE; |
263 | 263 |
264 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 264 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
265 | 265 |
266 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); | 266 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendProcessorFactory& fact
ory, | 355 GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendProcessorFactory& fact
ory, |
356 const GrProcessor&) | 356 const GrProcessor&) |
357 : INHERITED(factory), | 357 : INHERITED(factory), |
358 fEnforcePMColor(true) { | 358 fEnforcePMColor(true) { |
359 } | 359 } |
360 | 360 |
361 GrGLArithmeticEffect::~GrGLArithmeticEffect() { | 361 GrGLArithmeticEffect::~GrGLArithmeticEffect() { |
362 } | 362 } |
363 | 363 |
364 void GrGLArithmeticEffect::emitCode(GrGLProgramBuilder* builder, | 364 void GrGLArithmeticEffect::emitCode(GrGLFPBuilder* builder, |
365 const GrFragmentProcessor& fp, | 365 const GrFragmentProcessor& fp, |
366 const GrProcessorKey& key, | 366 const GrProcessorKey& key, |
367 const char* outputColor, | 367 const char* outputColor, |
368 const char* inputColor, | 368 const char* inputColor, |
369 const TransformedCoordsArray& coords, | 369 const TransformedCoordsArray& coords, |
370 const TextureSamplerArray& samplers) { | 370 const TextureSamplerArray& samplers) { |
371 | 371 |
372 GrTexture* backgroundTex = fp.cast<GrArithmeticEffect>().backgroundTexture()
; | 372 GrTexture* backgroundTex = fp.cast<GrArithmeticEffect>().backgroundTexture()
; |
373 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 373 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
374 const char* dstColor; | 374 const char* dstColor; |
375 if (backgroundTex) { | 375 if (backgroundTex) { |
376 fsBuilder->codeAppend("\t\tvec4 bgColor = "); | 376 fsBuilder->codeAppend("\t\tvec4 bgColor = "); |
377 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.getType()); | 377 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.getType()); |
378 fsBuilder->codeAppendf(";\n"); | 378 fsBuilder->codeAppendf(";\n"); |
379 dstColor = "bgColor"; | 379 dstColor = "bgColor"; |
380 } else { | 380 } else { |
381 dstColor = fsBuilder->dstColor(); | 381 dstColor = fsBuilder->dstColor(); |
382 } | 382 } |
383 | 383 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 background); | 453 background); |
454 } | 454 } |
455 return true; | 455 return true; |
456 } | 456 } |
457 | 457 |
458 #endif | 458 #endif |
459 | 459 |
460 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 460 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
461 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 461 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
462 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 462 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |