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 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 virtual ~SkTable_ColorFilter() { | 39 virtual ~SkTable_ColorFilter() { |
40 SkDELETE(fBitmap); | 40 SkDELETE(fBitmap); |
41 } | 41 } |
42 | 42 |
43 bool asComponentTable(SkBitmap* table) const SK_OVERRIDE; | 43 bool asComponentTable(SkBitmap* table) const SK_OVERRIDE; |
44 SkColorFilter* newComposed(const SkColorFilter* inner) const SK_OVERRIDE; | 44 SkColorFilter* newComposed(const SkColorFilter* inner) const SK_OVERRIDE; |
45 | 45 |
46 #if SK_SUPPORT_GPU | 46 #if SK_SUPPORT_GPU |
47 GrFragmentProcessor* asFragmentProcessor(GrContext* context) const SK_OVERRI
DE; | 47 bool asFragmentProcessors(GrContext*, SkTDArray<GrFragmentProcessor*>*) cons
t SK_OVERRIDE; |
48 #endif | 48 #endif |
49 | 49 |
50 void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const SK_
OVERRIDE; | 50 void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const SK_
OVERRIDE; |
51 | 51 |
52 SK_TO_STRING_OVERRIDE() | 52 SK_TO_STRING_OVERRIDE() |
53 | 53 |
54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) | 54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) |
55 | 55 |
56 enum { | 56 enum { |
57 kA_Flag = 1 << 0, | 57 kA_Flag = 1 << 0, |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 luts[j][i] = SkToU8(random->nextBits(8)); | 560 luts[j][i] = SkToU8(random->nextBits(8)); |
561 } | 561 } |
562 } | 562 } |
563 } | 563 } |
564 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB( | 564 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB( |
565 (flags & (1 << 0)) ? luts[0] : NULL, | 565 (flags & (1 << 0)) ? luts[0] : NULL, |
566 (flags & (1 << 1)) ? luts[1] : NULL, | 566 (flags & (1 << 1)) ? luts[1] : NULL, |
567 (flags & (1 << 2)) ? luts[2] : NULL, | 567 (flags & (1 << 2)) ? luts[2] : NULL, |
568 (flags & (1 << 3)) ? luts[3] : NULL | 568 (flags & (1 << 3)) ? luts[3] : NULL |
569 )); | 569 )); |
570 return filter->asFragmentProcessor(context); | 570 |
| 571 SkTDArray<GrFragmentProcessor*> array; |
| 572 if (filter->asFragmentProcessors(context, &array)) { |
| 573 SkASSERT(1 == array.count()); // TableColorFilter only returns 1 |
| 574 return array[0]; |
| 575 } |
| 576 return NULL; |
571 } | 577 } |
572 | 578 |
573 GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* context
) const { | 579 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context, |
| 580 SkTDArray<GrFragmentProcessor*>*
array) const { |
574 SkBitmap bitmap; | 581 SkBitmap bitmap; |
575 this->asComponentTable(&bitmap); | 582 this->asComponentTable(&bitmap); |
576 | 583 |
577 return ColorTableEffect::Create(context, bitmap, fFlags); | 584 GrFragmentProcessor* frag = ColorTableEffect::Create(context, bitmap, fFlags
); |
| 585 if (frag) { |
| 586 if (array) { |
| 587 *array->append() = frag; |
| 588 } |
| 589 return true; |
| 590 } |
| 591 return false; |
578 } | 592 } |
579 | 593 |
580 #endif // SK_SUPPORT_GPU | 594 #endif // SK_SUPPORT_GPU |
581 | 595 |
582 /////////////////////////////////////////////////////////////////////////////// | 596 /////////////////////////////////////////////////////////////////////////////// |
583 | 597 |
584 #ifdef SK_CPU_BENDIAN | 598 #ifdef SK_CPU_BENDIAN |
585 #else | 599 #else |
586 #define SK_A32_INDEX (3 - (SK_A32_SHIFT >> 3)) | 600 #define SK_A32_INDEX (3 - (SK_A32_SHIFT >> 3)) |
587 #define SK_R32_INDEX (3 - (SK_R32_SHIFT >> 3)) | 601 #define SK_R32_INDEX (3 - (SK_R32_SHIFT >> 3)) |
(...skipping 10 matching lines...) Expand all Loading... |
598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 612 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
599 const uint8_t tableR[256], | 613 const uint8_t tableR[256], |
600 const uint8_t tableG[256], | 614 const uint8_t tableG[256], |
601 const uint8_t tableB[256]) { | 615 const uint8_t tableB[256]) { |
602 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); | 616 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); |
603 } | 617 } |
604 | 618 |
605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 619 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 620 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 621 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |