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

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

Issue 1213623022: fix up test create functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 5 years, 5 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/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkLinearGradient.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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (fFlags & SkTable_ColorFilter::kA_Flag) { 544 if (fFlags & SkTable_ColorFilter::kA_Flag) {
545 invalidateFlags |= kA_GrColorComponentFlag; 545 invalidateFlags |= kA_GrColorComponentFlag;
546 } 546 }
547 inout->invalidateComponents(invalidateFlags, GrInvariantOutput::kWill_ReadIn put); 547 inout->invalidateComponents(invalidateFlags, GrInvariantOutput::kWill_ReadIn put);
548 } 548 }
549 549
550 /////////////////////////////////////////////////////////////////////////////// 550 ///////////////////////////////////////////////////////////////////////////////
551 551
552 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); 552 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
553 553
554 GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, 554 GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) {
555 GrContext* context,
556 const GrCaps&,
557 GrTexture* textures[]) {
558 int flags = 0; 555 int flags = 0;
559 uint8_t luts[256][4]; 556 uint8_t luts[256][4];
560 do { 557 do {
561 for (int i = 0; i < 4; ++i) { 558 for (int i = 0; i < 4; ++i) {
562 flags |= random->nextBool() ? (1 << i): 0; 559 flags |= d->fRandom->nextBool() ? (1 << i): 0;
563 } 560 }
564 } while (!flags); 561 } while (!flags);
565 for (int i = 0; i < 4; ++i) { 562 for (int i = 0; i < 4; ++i) {
566 if (flags & (1 << i)) { 563 if (flags & (1 << i)) {
567 for (int j = 0; j < 256; ++j) { 564 for (int j = 0; j < 256; ++j) {
568 luts[j][i] = SkToU8(random->nextBits(8)); 565 luts[j][i] = SkToU8(d->fRandom->nextBits(8));
569 } 566 }
570 } 567 }
571 } 568 }
572 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB( 569 SkAutoTUnref<SkColorFilter> filter(SkTableColorFilter::CreateARGB(
573 (flags & (1 << 0)) ? luts[0] : NULL, 570 (flags & (1 << 0)) ? luts[0] : NULL,
574 (flags & (1 << 1)) ? luts[1] : NULL, 571 (flags & (1 << 1)) ? luts[1] : NULL,
575 (flags & (1 << 2)) ? luts[2] : NULL, 572 (flags & (1 << 2)) ? luts[2] : NULL,
576 (flags & (1 << 3)) ? luts[3] : NULL 573 (flags & (1 << 3)) ? luts[3] : NULL
577 )); 574 ));
578 575
579 SkTDArray<GrFragmentProcessor*> array; 576 SkTDArray<GrFragmentProcessor*> array;
580 GrPaint grPaint; 577 if (filter->asFragmentProcessors(d->fContext, d->fShaderDataManager, &array) ) {
581 if (filter->asFragmentProcessors(context, grPaint.getShaderDataManager(), &a rray)) {
582 SkASSERT(1 == array.count()); // TableColorFilter only returns 1 578 SkASSERT(1 == array.count()); // TableColorFilter only returns 1
583 return array[0]; 579 return array[0];
584 } 580 }
585 return NULL; 581 return NULL;
586 } 582 }
587 583
588 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context, 584 bool SkTable_ColorFilter::asFragmentProcessors(GrContext* context,
589 GrShaderDataManager*, 585 GrShaderDataManager*,
590 SkTDArray<GrFragmentProcessor*>* array) const { 586 SkTDArray<GrFragmentProcessor*>* array) const {
591 SkBitmap bitmap; 587 SkBitmap bitmap;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], 621 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256],
626 const uint8_t tableR[256], 622 const uint8_t tableR[256],
627 const uint8_t tableG[256], 623 const uint8_t tableG[256],
628 const uint8_t tableB[256]) { 624 const uint8_t tableB[256]) {
629 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); 625 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB));
630 } 626 }
631 627
632 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) 628 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter)
633 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) 629 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter)
634 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 630 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698