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

Side by Side Diff: src/effects/SkDisplacementMapEffect.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/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // and no displacement offset push any texture coordinates out of bounds OR if the constant 520 // and no displacement offset push any texture coordinates out of bounds OR if the constant
521 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is 521 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is
522 // not of constant color when a displacement effect is applied. 522 // not of constant color when a displacement effect is applied.
523 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); 523 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
524 } 524 }
525 525
526 /////////////////////////////////////////////////////////////////////////////// 526 ///////////////////////////////////////////////////////////////////////////////
527 527
528 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); 528 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
529 529
530 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, 530 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
531 GrContext*, 531 int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextu reIdx :
532 const GrCaps&, 532 GrProcessorUnitTest::kAlphaTextur eIdx;
533 GrTexture* textures[]) { 533 int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextu reIdx :
534 int texIdxDispl = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureId x : 534 GrProcessorUnitTest::kAlphaTextur eIdx;
535 GrProcessorUnitTest::kAlphaTextureIdx ;
536 int texIdxColor = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureId x :
537 GrProcessorUnitTest::kAlphaTextureIdx ;
538 static const int kMaxComponent = 4; 535 static const int kMaxComponent = 4;
539 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector = 536 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector =
540 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 537 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
541 random->nextRangeU(1, kMaxComponent)); 538 d->fRandom->nextRangeU(1, kMaxComponent));
542 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = 539 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector =
543 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( 540 static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
544 random->nextRangeU(1, kMaxComponent)); 541 d->fRandom->nextRangeU(1, kMaxComponent));
545 SkVector scale = SkVector::Make(random->nextRangeScalar(0, 100.0f), 542 SkVector scale = SkVector::Make(d->fRandom->nextRangeScalar(0, 100.0f),
546 random->nextRangeScalar(0, 100.0f)); 543 d->fRandom->nextRangeScalar(0, 100.0f));
547 SkISize colorDimensions; 544 SkISize colorDimensions;
548 colorDimensions.fWidth = random->nextRangeU(0, textures[texIdxColor]->width( )); 545 colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor] ->width());
549 colorDimensions.fHeight = random->nextRangeU(0, textures[texIdxColor]->heigh t()); 546 colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor ]->height());
550 GrShaderDataManager shaderDataManager; 547 return GrDisplacementMapEffect::Create(d->fShaderDataManager,
551 return GrDisplacementMapEffect::Create(&shaderDataManager,
552 xChannelSelector, yChannelSelector, s cale, 548 xChannelSelector, yChannelSelector, s cale,
553 textures[texIdxDispl], SkMatrix::I(), 549 d->fTextures[texIdxDispl], SkMatrix:: I(),
554 textures[texIdxColor], colorDimension s); 550 d->fTextures[texIdxColor], colorDimen sions);
555 } 551 }
556 552
557 /////////////////////////////////////////////////////////////////////////////// 553 ///////////////////////////////////////////////////////////////////////////////
558 554
559 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc) 555 GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrProcessor& proc)
560 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector()) 556 : fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
561 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) { 557 , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
562 } 558 }
563 559
564 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() { 560 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 647 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
652 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 648 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
653 649
654 uint32_t xKey = displacementMap.xChannelSelector(); 650 uint32_t xKey = displacementMap.xChannelSelector();
655 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 651 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
656 652
657 b->add32(xKey | yKey); 653 b->add32(xKey | yKey);
658 } 654 }
659 #endif 655 #endif
660 656
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698