OLD | NEW |
1 | 1 |
2 #include "SkBitmap.h" | 2 #include "SkBitmap.h" |
3 #include "SkTableColorFilter.h" | 3 #include "SkTableColorFilter.h" |
4 #include "SkColorPriv.h" | 4 #include "SkColorPriv.h" |
5 #include "SkReadBuffer.h" | 5 #include "SkReadBuffer.h" |
6 #include "SkWriteBuffer.h" | 6 #include "SkWriteBuffer.h" |
7 #include "SkUnPreMultiply.h" | 7 #include "SkUnPreMultiply.h" |
8 #include "SkString.h" | 8 #include "SkString.h" |
9 | 9 |
10 class SkTable_ColorFilter : public SkColorFilter { | 10 class SkTable_ColorFilter : public SkColorFilter { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 public: | 287 public: |
288 static GrFragmentProcessor* Create(GrTexture* texture, unsigned flags) { | 288 static GrFragmentProcessor* Create(GrTexture* texture, unsigned flags) { |
289 return SkNEW_ARGS(ColorTableEffect, (texture, flags)); | 289 return SkNEW_ARGS(ColorTableEffect, (texture, flags)); |
290 } | 290 } |
291 | 291 |
292 virtual ~ColorTableEffect(); | 292 virtual ~ColorTableEffect(); |
293 | 293 |
294 static const char* Name() { return "ColorTable"; } | 294 static const char* Name() { return "ColorTable"; } |
295 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 295 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
296 | 296 |
| 297 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 298 |
297 typedef GLColorTableEffect GLProcessor; | 299 typedef GLColorTableEffect GLProcessor; |
298 | 300 |
299 private: | 301 private: |
300 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 302 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
301 | 303 |
302 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | |
303 | |
304 explicit ColorTableEffect(GrTexture* texture, unsigned flags); | 304 explicit ColorTableEffect(GrTexture* texture, unsigned flags); |
305 | 305 |
306 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 306 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
307 | 307 |
308 GrTextureAccess fTextureAccess; | 308 GrTextureAccess fTextureAccess; |
309 unsigned fFlags; // currently not used in shader code, just to assist | 309 unsigned fFlags; // currently not used in shader code, just to assist |
310 // onComputeInvariantOutput(). | 310 // getConstantColorComponents(). |
311 | 311 |
312 typedef GrFragmentProcessor INHERITED; | 312 typedef GrFragmentProcessor INHERITED; |
313 }; | 313 }; |
314 | 314 |
315 class GLColorTableEffect : public GrGLFragmentProcessor { | 315 class GLColorTableEffect : public GrGLFragmentProcessor { |
316 public: | 316 public: |
317 GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 317 GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
318 | 318 |
319 virtual void emitCode(GrGLProgramBuilder*, | 319 virtual void emitCode(GrGLProgramBuilder*, |
320 const GrFragmentProcessor&, | 320 const GrFragmentProcessor&, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 394 } |
395 | 395 |
396 const GrBackendFragmentProcessorFactory& ColorTableEffect::getFactory() const { | 396 const GrBackendFragmentProcessorFactory& ColorTableEffect::getFactory() const { |
397 return GrTBackendFragmentProcessorFactory<ColorTableEffect>::getInstance(); | 397 return GrTBackendFragmentProcessorFactory<ColorTableEffect>::getInstance(); |
398 } | 398 } |
399 | 399 |
400 bool ColorTableEffect::onIsEqual(const GrProcessor& sBase) const { | 400 bool ColorTableEffect::onIsEqual(const GrProcessor& sBase) const { |
401 return this->texture(0) == sBase.texture(0); | 401 return this->texture(0) == sBase.texture(0); |
402 } | 402 } |
403 | 403 |
404 void ColorTableEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 404 void ColorTableEffect::getConstantColorComponents(GrColor* color, uint32_t* vali
dFlags) const { |
405 // If we kept the table in the effect then we could actually run known input
s through the | 405 // If we kept the table in the effect then we could actually run known input
s through the |
406 // table. | 406 // table. |
407 if (fFlags & SkTable_ColorFilter::kR_Flag) { | 407 if (fFlags & SkTable_ColorFilter::kR_Flag) { |
408 inout->fValidFlags &= ~kR_GrColorComponentFlag; | 408 *validFlags &= ~kR_GrColorComponentFlag; |
409 } | 409 } |
410 if (fFlags & SkTable_ColorFilter::kG_Flag) { | 410 if (fFlags & SkTable_ColorFilter::kG_Flag) { |
411 inout->fValidFlags &= ~kG_GrColorComponentFlag; | 411 *validFlags &= ~kG_GrColorComponentFlag; |
412 } | 412 } |
413 if (fFlags & SkTable_ColorFilter::kB_Flag) { | 413 if (fFlags & SkTable_ColorFilter::kB_Flag) { |
414 inout->fValidFlags &= ~kB_GrColorComponentFlag; | 414 *validFlags &= ~kB_GrColorComponentFlag; |
415 } | 415 } |
416 if (fFlags & SkTable_ColorFilter::kA_Flag) { | 416 if (fFlags & SkTable_ColorFilter::kA_Flag) { |
417 inout->fValidFlags &= ~kA_GrColorComponentFlag; | 417 *validFlags &= ~kA_GrColorComponentFlag; |
418 } | 418 } |
419 inout->fIsSingleComponent = false; | |
420 } | 419 } |
421 | 420 |
422 | 421 |
423 /////////////////////////////////////////////////////////////////////////////// | 422 /////////////////////////////////////////////////////////////////////////////// |
424 | 423 |
425 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); | 424 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); |
426 | 425 |
427 GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, | 426 GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, |
428 GrContext* context, | 427 GrContext* context, |
429 const GrDrawTargetCaps&, | 428 const GrDrawTargetCaps&, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 470 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
472 const uint8_t tableR[256], | 471 const uint8_t tableR[256], |
473 const uint8_t tableG[256], | 472 const uint8_t tableG[256], |
474 const uint8_t tableB[256]) { | 473 const uint8_t tableB[256]) { |
475 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); | 474 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); |
476 } | 475 } |
477 | 476 |
478 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 477 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
479 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 478 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
480 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 479 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |