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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 fBitmap = bmp; | 269 fBitmap = bmp; |
270 } | 270 } |
271 *table = *fBitmap; | 271 *table = *fBitmap; |
272 } | 272 } |
273 return true; | 273 return true; |
274 } | 274 } |
275 | 275 |
276 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
277 | 277 |
278 #include "GrFragmentProcessor.h" | 278 #include "GrFragmentProcessor.h" |
| 279 #include "GrInvariantOutput.h" |
279 #include "GrTBackendProcessorFactory.h" | 280 #include "GrTBackendProcessorFactory.h" |
280 #include "SkGr.h" | 281 #include "SkGr.h" |
281 #include "effects/GrTextureStripAtlas.h" | 282 #include "effects/GrTextureStripAtlas.h" |
282 #include "gl/GrGLProcessor.h" | 283 #include "gl/GrGLProcessor.h" |
283 #include "gl/builders/GrGLProgramBuilder.h" | 284 #include "gl/builders/GrGLProgramBuilder.h" |
284 | 285 |
285 | 286 |
286 class GLColorTableEffect; | 287 class GLColorTableEffect; |
287 | 288 |
288 class ColorTableEffect : public GrFragmentProcessor { | 289 class ColorTableEffect : public GrFragmentProcessor { |
289 public: | 290 public: |
290 static GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsi
gned flags); | 291 static GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsi
gned flags); |
291 | 292 |
292 virtual ~ColorTableEffect(); | 293 virtual ~ColorTableEffect(); |
293 | 294 |
294 static const char* Name() { return "ColorTable"; } | 295 static const char* Name() { return "ColorTable"; } |
295 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 296 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
296 | 297 |
297 typedef GLColorTableEffect GLProcessor; | 298 typedef GLColorTableEffect GLProcessor; |
298 | 299 |
299 const GrTextureStripAtlas* atlas() const { return fAtlas; } | 300 const GrTextureStripAtlas* atlas() const { return fAtlas; } |
300 int atlasRow() const { return fRow; } | 301 int atlasRow() const { return fRow; } |
301 | 302 |
302 private: | 303 private: |
303 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 304 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
304 | 305 |
305 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 306 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; |
306 | 307 |
307 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un
signed flags); | 308 ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, un
signed flags); |
308 | 309 |
309 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 310 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
310 | 311 |
311 GrTextureAccess fTextureAccess; | 312 GrTextureAccess fTextureAccess; |
312 | 313 |
313 // currently not used in shader code, just to assist onComputeInvariantOutpu
t(). | 314 // currently not used in shader code, just to assist onComputeInvariantOutpu
t(). |
314 unsigned fFlags; | 315 unsigned fFlags; |
315 | 316 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { | 463 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { |
463 // For non-atlased instances, the texture (compared by base class) is suffic
ient to | 464 // For non-atlased instances, the texture (compared by base class) is suffic
ient to |
464 // differentiate different tables. For atlased instances we ensure they are
using the | 465 // differentiate different tables. For atlased instances we ensure they are
using the |
465 // same row. | 466 // same row. |
466 const ColorTableEffect& that = other.cast<ColorTableEffect>(); | 467 const ColorTableEffect& that = other.cast<ColorTableEffect>(); |
467 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); | 468 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); |
468 // Ok to always do this comparison since both would be -1 if non-atlased. | 469 // Ok to always do this comparison since both would be -1 if non-atlased. |
469 return fRow == that.fRow; | 470 return fRow == that.fRow; |
470 } | 471 } |
471 | 472 |
472 void ColorTableEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 473 void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
473 // If we kept the table in the effect then we could actually run known input
s through the | 474 // If we kept the table in the effect then we could actually run known input
s through the |
474 // table. | 475 // table. |
475 uint8_t invalidateFlags = 0; | 476 uint8_t invalidateFlags = 0; |
476 if (fFlags & SkTable_ColorFilter::kR_Flag) { | 477 if (fFlags & SkTable_ColorFilter::kR_Flag) { |
477 invalidateFlags |= kR_GrColorComponentFlag; | 478 invalidateFlags |= kR_GrColorComponentFlag; |
478 } | 479 } |
479 if (fFlags & SkTable_ColorFilter::kG_Flag) { | 480 if (fFlags & SkTable_ColorFilter::kG_Flag) { |
480 invalidateFlags |= kG_GrColorComponentFlag; | 481 invalidateFlags |= kG_GrColorComponentFlag; |
481 } | 482 } |
482 if (fFlags & SkTable_ColorFilter::kB_Flag) { | 483 if (fFlags & SkTable_ColorFilter::kB_Flag) { |
483 invalidateFlags |= kB_GrColorComponentFlag; | 484 invalidateFlags |= kB_GrColorComponentFlag; |
484 } | 485 } |
485 if (fFlags & SkTable_ColorFilter::kA_Flag) { | 486 if (fFlags & SkTable_ColorFilter::kA_Flag) { |
486 invalidateFlags |= kA_GrColorComponentFlag; | 487 invalidateFlags |= kA_GrColorComponentFlag; |
487 } | 488 } |
488 inout->invalidateComponents(invalidateFlags, InvariantOutput::kWill_ReadInpu
t); | 489 inout->invalidateComponents(invalidateFlags, GrInvariantOutput::kWill_ReadIn
put); |
489 } | 490 } |
490 | 491 |
491 /////////////////////////////////////////////////////////////////////////////// | 492 /////////////////////////////////////////////////////////////////////////////// |
492 | 493 |
493 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); | 494 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); |
494 | 495 |
495 GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, | 496 GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, |
496 GrContext* context, | 497 GrContext* context, |
497 const GrDrawTargetCaps&, | 498 const GrDrawTargetCaps&, |
498 GrTexture* textures[]) { | 499 GrTexture* textures[]) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 548 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
548 const uint8_t tableR[256], | 549 const uint8_t tableR[256], |
549 const uint8_t tableG[256], | 550 const uint8_t tableG[256], |
550 const uint8_t tableB[256]) { | 551 const uint8_t tableB[256]) { |
551 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); | 552 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); |
552 } | 553 } |
553 | 554 |
554 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 555 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
555 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 556 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
556 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 557 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |