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

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

Issue 1334293003: Create fragment processor for performing input color blend with child processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 3 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/SkLumaColorFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.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 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkTableColorFilter.h" 9 #include "SkTableColorFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 } 43 }
44 44
45 virtual ~SkTable_ColorFilter() { delete fBitmap; } 45 virtual ~SkTable_ColorFilter() { delete fBitmap; }
46 46
47 bool asComponentTable(SkBitmap* table) const override; 47 bool asComponentTable(SkBitmap* table) const override;
48 SkColorFilter* newComposed(const SkColorFilter* inner) const override; 48 SkColorFilter* newComposed(const SkColorFilter* inner) const override;
49 49
50 #if SK_SUPPORT_GPU 50 #if SK_SUPPORT_GPU
51 bool asFragmentProcessors(GrContext*, GrProcessorDataManager*, 51 bool asFragmentProcessors(GrContext*, GrProcessorDataManager*,
52 SkTDArray<GrFragmentProcessor*>*) const override; 52 SkTDArray<const GrFragmentProcessor*>*) const over ride;
53 #endif 53 #endif
54 54
55 void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const ove rride; 55 void filterSpan(const SkPMColor src[], int count, SkPMColor dst[]) const ove rride;
56 56
57 SK_TO_STRING_OVERRIDE() 57 SK_TO_STRING_OVERRIDE()
58 58
59 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) 59 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter)
60 60
61 enum { 61 enum {
62 kA_Flag = 1 << 0, 62 kA_Flag = 1 << 0,
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // same row. 514 // same row.
515 const ColorTableEffect& that = other.cast<ColorTableEffect>(); 515 const ColorTableEffect& that = other.cast<ColorTableEffect>();
516 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); 516 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas));
517 // Ok to always do this comparison since both would be -1 if non-atlased. 517 // Ok to always do this comparison since both would be -1 if non-atlased.
518 return fRow == that.fRow; 518 return fRow == that.fRow;
519 } 519 }
520 520
521 void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 521 void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
522 // If we kept the table in the effect then we could actually run known input s through the 522 // If we kept the table in the effect then we could actually run known input s through the
523 // table. 523 // table.
524 uint8_t invalidateFlags = 0; 524 GrColorComponentFlags invalidateFlags = kNone_GrColorComponentFlags;
525 if (fFlags & SkTable_ColorFilter::kR_Flag) { 525 if (fFlags & SkTable_ColorFilter::kR_Flag) {
526 invalidateFlags |= kR_GrColorComponentFlag; 526 invalidateFlags |= kR_GrColorComponentFlag;
527 } 527 }
528 if (fFlags & SkTable_ColorFilter::kG_Flag) { 528 if (fFlags & SkTable_ColorFilter::kG_Flag) {
529 invalidateFlags |= kG_GrColorComponentFlag; 529 invalidateFlags |= kG_GrColorComponentFlag;
530 } 530 }
531 if (fFlags & SkTable_ColorFilter::kB_Flag) { 531 if (fFlags & SkTable_ColorFilter::kB_Flag) {
532 invalidateFlags |= kB_GrColorComponentFlag; 532 invalidateFlags |= kB_GrColorComponentFlag;
533 } 533 }
534 if (fFlags & SkTable_ColorFilter::kA_Flag) { 534 if (fFlags & SkTable_ColorFilter::kA_Flag) {
(...skipping 21 matching lines...) Expand all
556 } 556 }
557 } 557 }
558 } 558 }
559 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB( 559 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB(
560 (flags & (1 << 0)) ? luts[0] : nullptr, 560 (flags & (1 << 0)) ? luts[0] : nullptr,
561 (flags & (1 << 1)) ? luts[1] : nullptr, 561 (flags & (1 << 1)) ? luts[1] : nullptr,
562 (flags & (1 << 2)) ? luts[2] : nullptr, 562 (flags & (1 << 2)) ? luts[2] : nullptr,
563 (flags & (1 << 3)) ? luts[3] : nullptr 563 (flags & (1 << 3)) ? luts[3] : nullptr
564 )); 564 ));
565 565
566 SkTDArray<GrFragmentProcessor*> array; 566 SkTDArray<const GrFragmentProcessor*> array;
567 if (filter->asFragmentProcessors(d->fContext, d->fProcDataManager, &array)) { 567 if (filter->asFragmentProcessors(d->fContext, d->fProcDataManager, &array)) {
568 SkASSERT(1 == array.count()); // TableColorFilter only returns 1 568 SkASSERT(1 == array.count()); // TableColorFilter only returns 1
569 return array[0]; 569 return array[0];
570 } 570 }
571 return nullptr; 571 return nullptr;
572 } 572 }
573 573
574 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context, 574 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context,
575 GrProcessorDataManager*, 575 GrProcessorDataManager*,
576 SkTDArray<GrFragmentProcessor*>* array) const { 576 SkTDArray<const GrFragmentProcess or*>* array) const {
577 SkBitmap bitmap; 577 SkBitmap bitmap;
578 this->asComponentTable(&bitmap); 578 this->asComponentTable(&bitmap);
579 579
580 GrFragmentProcessor* frag = ColorTableEffect::Create(context, bitmap, fFlags ); 580 GrFragmentProcessor* frag = ColorTableEffect::Create(context, bitmap, fFlags );
581 if (frag) { 581 if (frag) {
582 if (array) { 582 if (array) {
583 *array->append() = frag; 583 *array->append() = frag;
584 } else { 584 } else {
585 frag->unref(); 585 frag->unref();
586 SkDEBUGCODE(frag = nullptr;) 586 SkDEBUGCODE(frag = nullptr;)
(...skipping 24 matching lines...) Expand all
611 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], 611 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
612 const uint8_t tableR[256], 612 const uint8_t tableR[256],
613 const uint8_t tableG[256], 613 const uint8_t tableG[256],
614 const uint8_t tableB[256]) { 614 const uint8_t tableB[256]) {
615 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); 615 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB);
616 } 616 }
617 617
618 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) 618 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)
619 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) 619 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter)
620 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 620 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkLumaColorFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698