diff options
Diffstat (limited to 'src')
37 files changed, 389 insertions, 559 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 006b9e6052..36c046b88d 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -207,17 +207,13 @@ void GrGLAlphaThresholdEffect::setData(const GrGLProgramDataManager& pdman, GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AlphaThresholdEffect); -GrFragmentProcessor* AlphaThresholdEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture** textures) { - GrTexture* bmpTex = textures[GrProcessorUnitTest::kSkiaPMTextureIdx]; - GrTexture* maskTex = textures[GrProcessorUnitTest::kAlphaTextureIdx]; - float inner_thresh = random->nextUScalar1(); - float outer_thresh = random->nextUScalar1(); - GrShaderDataManager shaderDataManager; - return AlphaThresholdEffect::Create(&shaderDataManager, bmpTex, maskTex, inner_thresh, - outer_thresh); +GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData* d) { + GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; + GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; + float innerThresh = d->fRandom->nextUScalar1(); + float outerThresh = d->fRandom->nextUScalar1(); + return AlphaThresholdEffect::Create(d->fShaderDataManager, bmpTex, maskTex, innerThresh, + outerThresh); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp index 302e8b6405..007ff26b42 100644 --- a/src/effects/SkArithmeticMode_gpu.cpp +++ b/src/effects/SkArithmeticMode_gpu.cpp @@ -139,19 +139,15 @@ void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { /////////////////////////////////////////////////////////////////////////////// -GrFragmentProcessor* GrArithmeticFP::TestCreate(SkRandom* rand, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - float k1 = rand->nextF(); - float k2 = rand->nextF(); - float k3 = rand->nextF(); - float k4 = rand->nextF(); - bool enforcePMColor = rand->nextBool(); - - GrShaderDataManager shaderDataManager; - return SkNEW_ARGS(GrArithmeticFP, (&shaderDataManager, k1, k2, k3, k4, enforcePMColor, - textures[0])); +GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { + float k1 = d->fRandom->nextF(); + float k2 = d->fRandom->nextF(); + float k3 = d->fRandom->nextF(); + float k4 = d->fRandom->nextF(); + bool enforcePMColor = d->fRandom->nextBool(); + + return SkNEW_ARGS(GrArithmeticFP, (d->fShaderDataManager, k1, k2, k3, k4, enforcePMColor, + d->fTextures[0])); } GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); @@ -305,15 +301,12 @@ void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); -GrXPFactory* GrArithmeticXPFactory::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture*[]) { - float k1 = random->nextF(); - float k2 = random->nextF(); - float k3 = random->nextF(); - float k4 = random->nextF(); - bool enforcePMColor = random->nextBool(); +GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { + float k1 = d->fRandom->nextF(); + float k2 = d->fRandom->nextF(); + float k3 = d->fRandom->nextF(); + float k4 = d->fRandom->nextF(); + bool enforcePMColor = d->fRandom->nextBool(); return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); } diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 22a9ac62a2..0436f087e0 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -821,14 +821,11 @@ void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); -GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - float sigma = random->nextRangeF(3,8); - float width = random->nextRangeF(200,300); - float height = random->nextRangeF(200,300); - return GrRectBlurEffect::Create(context->textureProvider(), SkRect::MakeWH(width, height), +GrFragmentProcessor* GrRectBlurEffect::TestCreate(GrProcessorTestData* d) { + float sigma = d->fRandom->nextRangeF(3,8); + float width = d->fRandom->nextRangeF(200,300); + float height = d->fRandom->nextRangeF(200,300); + return GrRectBlurEffect::Create(d->fContext->textureProvider(), SkRect::MakeWH(width, height), sigma); } @@ -1009,17 +1006,14 @@ bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); -GrFragmentProcessor* GrRRectBlurEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps& caps, - GrTexture*[]) { - SkScalar w = random->nextRangeScalar(100.f, 1000.f); - SkScalar h = random->nextRangeScalar(100.f, 1000.f); - SkScalar r = random->nextRangeF(1.f, 9.f); - SkScalar sigma = random->nextRangeF(1.f,10.f); +GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) { + SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f); + SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f); + SkScalar r = d->fRandom->nextRangeF(1.f, 9.f); + SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); SkRRect rrect; rrect.setRectXY(SkRect::MakeWH(w, h), r, r); - return GrRRectBlurEffect::Create(context, sigma, rrect); + return GrRRectBlurEffect::Create(d->fContext, sigma, rrect); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index ac3bee0ea6..f4a2260715 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -344,20 +344,17 @@ void ModeColorFilterEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c } GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect); -GrFragmentProcessor* ModeColorFilterEffect::TestCreate(SkRandom* rand, - GrContext*, - const GrCaps&, - GrTexture*[]) { +GrFragmentProcessor* ModeColorFilterEffect::TestCreate(GrProcessorTestData* d) { SkXfermode::Mode mode = SkXfermode::kDst_Mode; while (SkXfermode::kDst_Mode == mode) { - mode = static_cast<SkXfermode::Mode>(rand->nextRangeU(0, SkXfermode::kLastCoeffMode)); + mode = static_cast<SkXfermode::Mode>(d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode)); } // pick a random premul color - uint8_t alpha = rand->nextULessThan(256); - GrColor color = GrColorPackRGBA(rand->nextRangeU(0, alpha), - rand->nextRangeU(0, alpha), - rand->nextRangeU(0, alpha), + uint8_t alpha = d->fRandom->nextULessThan(256); + GrColor color = GrColorPackRGBA(d->fRandom->nextRangeU(0, alpha), + d->fRandom->nextRangeU(0, alpha), + d->fRandom->nextRangeU(0, alpha), alpha); return ModeColorFilterEffect::Create(color, mode); } diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 6401aaa55f..16275d59ff 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -531,13 +531,10 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect); -GrFragmentProcessor* ColorMatrixEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* dummyTextures[2]) { +GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) { SkColorMatrix colorMatrix; for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) { - colorMatrix.fMat[i] = random->nextSScalar1(); + colorMatrix.fMat[i] = d->fRandom->nextSScalar1(); } return ColorMatrixEffect::Create(colorMatrix); } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 932a4b1e3a..817206ffa9 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -527,31 +527,27 @@ void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout) GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); -GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdxDispl = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; - int texIdxColor = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) { + int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; + int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; static const int kMaxComponent = 4; SkDisplacementMapEffect::ChannelSelectorType xChannelSelector = static_cast<SkDisplacementMapEffect::ChannelSelectorType>( - random->nextRangeU(1, kMaxComponent)); + d->fRandom->nextRangeU(1, kMaxComponent)); SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = static_cast<SkDisplacementMapEffect::ChannelSelectorType>( - random->nextRangeU(1, kMaxComponent)); - SkVector scale = SkVector::Make(random->nextRangeScalar(0, 100.0f), - random->nextRangeScalar(0, 100.0f)); + d->fRandom->nextRangeU(1, kMaxComponent)); + SkVector scale = SkVector::Make(d->fRandom->nextRangeScalar(0, 100.0f), + d->fRandom->nextRangeScalar(0, 100.0f)); SkISize colorDimensions; - colorDimensions.fWidth = random->nextRangeU(0, textures[texIdxColor]->width()); - colorDimensions.fHeight = random->nextRangeU(0, textures[texIdxColor]->height()); - GrShaderDataManager shaderDataManager; - return GrDisplacementMapEffect::Create(&shaderDataManager, + colorDimensions.fWidth = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->width()); + colorDimensions.fHeight = d->fRandom->nextRangeU(0, d->fTextures[texIdxColor]->height()); + return GrDisplacementMapEffect::Create(d->fShaderDataManager, xChannelSelector, yChannelSelector, scale, - textures[texIdxDispl], SkMatrix::I(), - textures[texIdxColor], colorDimensions); + d->fTextures[texIdxDispl], SkMatrix::I(), + d->fTextures[texIdxColor], colorDimensions); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 1b309abd0a..3a96bc3b9a 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -1597,19 +1597,16 @@ GrGLFragmentProcessor* GrDiffuseLightingEffect::createGLInstance() const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect); -GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - SkScalar surfaceScale = random->nextSScalar1(); - SkScalar kd = random->nextUScalar1(); - SkAutoTUnref<SkLight> light(create_random_light(random)); +GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) { + SkScalar surfaceScale = d->fRandom->nextSScalar1(); + SkScalar kd = d->fRandom->nextUScalar1(); + SkAutoTUnref<SkLight> light(create_random_light(d->fRandom)); SkMatrix matrix; for (int i = 0; i < 9; i++) { - matrix[i] = random->nextUScalar1(); + matrix[i] = d->fRandom->nextUScalar1(); } - BoundaryMode mode = static_cast<BoundaryMode>(random->nextU() % kBoundaryModeCount); - return GrDiffuseLightingEffect::Create(textures[GrProcessorUnitTest::kAlphaTextureIdx], + BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount); + return GrDiffuseLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx], light, surfaceScale, matrix, kd, mode); } @@ -1805,20 +1802,17 @@ GrGLFragmentProcessor* GrSpecularLightingEffect::createGLInstance() const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect); -GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - SkScalar surfaceScale = random->nextSScalar1(); - SkScalar ks = random->nextUScalar1(); - SkScalar shininess = random->nextUScalar1(); - SkAutoTUnref<SkLight> light(create_random_light(random)); +GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) { + SkScalar surfaceScale = d->fRandom->nextSScalar1(); + SkScalar ks = d->fRandom->nextUScalar1(); + SkScalar shininess = d->fRandom->nextUScalar1(); + SkAutoTUnref<SkLight> light(create_random_light(d->fRandom)); SkMatrix matrix; for (int i = 0; i < 9; i++) { - matrix[i] = random->nextUScalar1(); + matrix[i] = d->fRandom->nextUScalar1(); } - BoundaryMode mode = static_cast<BoundaryMode>(random->nextU() % kBoundaryModeCount); - return GrSpecularLightingEffect::Create(textures[GrProcessorUnitTest::kAlphaTextureIdx], + BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount); + return GrSpecularLightingEffect::Create(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx], light, surfaceScale, matrix, ks, shininess, mode); } diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 96d04e2786..ba704b37a0 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -207,19 +207,16 @@ GrGLFragmentProcessor* GrMagnifierEffect::createGLInstance() const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect); -GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture** textures) { - GrTexture* texture = textures[0]; +GrFragmentProcessor* GrMagnifierEffect::TestCreate(GrProcessorTestData* d) { + GrTexture* texture = d->fTextures[0]; const int kMaxWidth = 200; const int kMaxHeight = 200; const int kMaxInset = 20; - uint32_t width = random->nextULessThan(kMaxWidth); - uint32_t height = random->nextULessThan(kMaxHeight); - uint32_t x = random->nextULessThan(kMaxWidth - width); - uint32_t y = random->nextULessThan(kMaxHeight - height); - uint32_t inset = random->nextULessThan(kMaxInset); + uint32_t width = d->fRandom->nextULessThan(kMaxWidth); + uint32_t height = d->fRandom->nextULessThan(kMaxHeight); + uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width); + uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height); + uint32_t inset = d->fRandom->nextULessThan(kMaxInset); GrFragmentProcessor* effect = GrMagnifierEffect::Create( texture, diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 5eccb0db23..f284360b03 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -543,19 +543,16 @@ void GrMorphologyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect); -GrFragmentProcessor* GrMorphologyEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : +GrFragmentProcessor* GrMorphologyEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : GrProcessorUnitTest::kAlphaTextureIdx; - Direction dir = random->nextBool() ? kX_Direction : kY_Direction; + Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction; static const int kMaxRadius = 10; - int radius = random->nextRangeU(1, kMaxRadius); - MorphologyType type = random->nextBool() ? GrMorphologyEffect::kErode_MorphologyType : + int radius = d->fRandom->nextRangeU(1, kMaxRadius); + MorphologyType type = d->fRandom->nextBool() ? GrMorphologyEffect::kErode_MorphologyType : GrMorphologyEffect::kDilate_MorphologyType; - return GrMorphologyEffect::Create(textures[texIdx], dir, radius, type); + return GrMorphologyEffect::Create(d->fTextures[texIdx], dir, radius, type); } namespace { diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 38a778406f..b6611209a4 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -602,20 +602,18 @@ private: ///////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect); -GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - int numOctaves = random->nextRangeU(2, 10); - bool stitchTiles = random->nextBool(); - SkScalar seed = SkIntToScalar(random->nextU()); - SkISize tileSize = SkISize::Make(random->nextRangeU(4, 4096), random->nextRangeU(4, 4096)); - SkScalar baseFrequencyX = random->nextRangeScalar(0.01f, - 0.99f); - SkScalar baseFrequencyY = random->nextRangeScalar(0.01f, - 0.99f); - - SkShader* shader = random->nextBool() ? +GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) { + int numOctaves = d->fRandom->nextRangeU(2, 10); + bool stitchTiles = d->fRandom->nextBool(); + SkScalar seed = SkIntToScalar(d->fRandom->nextU()); + SkISize tileSize = SkISize::Make(d->fRandom->nextRangeU(4, 4096), + d->fRandom->nextRangeU(4, 4096)); + SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f, + 0.99f); + SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f, + 0.99f); + + SkShader* shader = d->fRandom->nextBool() ? SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles ? &tileSize : NULL) : SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, @@ -625,8 +623,8 @@ GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random, GrColor paintColor; GrFragmentProcessor* effect; GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, &paintColor, grPaint.getShaderDataManager(), &effect)); diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index e4bc778a8e..faffa4a43d 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -551,21 +551,18 @@ void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); -GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { +GrFragmentProcessor* ColorTableEffect::TestCreate(GrProcessorTestData* d) { int flags = 0; uint8_t luts[256][4]; do { for (int i = 0; i < 4; ++i) { - flags |= random->nextBool() ? (1 << i): 0; + flags |= d->fRandom->nextBool() ? (1 << i): 0; } } while (!flags); for (int i = 0; i < 4; ++i) { if (flags & (1 << i)) { for (int j = 0; j < 256; ++j) { - luts[j][i] = SkToU8(random->nextBits(8)); + luts[j][i] = SkToU8(d->fRandom->nextBits(8)); } } } @@ -577,8 +574,7 @@ GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random, )); SkTDArray<GrFragmentProcessor*> array; - GrPaint grPaint; - if (filter->asFragmentProcessors(context, grPaint.getShaderDataManager(), &array)) { + if (filter->asFragmentProcessors(d->fContext, d->fShaderDataManager, &array)) { SkASSERT(1 == array.count()); // TableColorFilter only returns 1 return array[0]; } diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 2fbe435d14..8e2edcf0ab 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -527,28 +527,24 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient); -GrFragmentProcessor* GrLinearGradient::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()}, - {random->nextUScalar1(), random->nextUScalar1()}}; +GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d) { + SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}, + {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}}; SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, colors, stops, colorCount, tm)); SkPaint paint; GrColor paintColor; GrFragmentProcessor* fp; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index b46a044214..2a039df5da 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -501,28 +501,24 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient); -GrFragmentProcessor* GrRadialGradient::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center = {random->nextUScalar1(), random->nextUScalar1()}; - SkScalar radius = random->nextUScalar1(); +GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d) { + SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; + SkScalar radius = d->fRandom->nextUScalar1(); SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, colors, stops, colorCount, tm)); SkPaint paint; GrColor paintColor; GrFragmentProcessor* fp; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 4bf80984fd..95d8a2eda3 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -245,26 +245,22 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient); -GrFragmentProcessor* GrSweepGradient::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center = {random->nextUScalar1(), random->nextUScalar1()}; +GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) { + SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tmIgnored; - int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tmIgnored); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY, colors, stops, colorCount)); SkPaint paint; GrFragmentProcessor* fp; GrColor paintColor; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp index 07722e9724..38b266d67a 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -187,16 +187,13 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); /* * All Two point conical gradient test create functions may occasionally create edge case shaders */ -GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; - SkScalar radius1 = random->nextUScalar1(); +GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) { + SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; + SkScalar radius1 = d->fRandom->nextUScalar1(); SkPoint center2; SkScalar radius2; do { - center2.set(random->nextUScalar1(), random->nextUScalar1()); + center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); // If the circles are identical the factory will give us an empty shader. // This will happen if we pick identical centers } while (center1 == center2); @@ -211,7 +208,7 @@ GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random, SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center1, radius1, center2, radius2, colors, stops, colorCount, @@ -219,10 +216,9 @@ GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random, SkPaint paint; GrFragmentProcessor* fp; GrColor paintColor; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } @@ -482,28 +478,25 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); /* * All Two point conical gradient test create functions may occasionally create edge case shaders */ -GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; +GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { + SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; SkScalar radius1 = 0.f; SkPoint center2; SkScalar radius2; do { - center2.set(random->nextUScalar1(), random->nextUScalar1()); + center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); // Need to make sure the centers are not the same or else focal point will be inside } while (center1 == center2); SkPoint diff = center2 - center1; SkScalar diffLen = diff.length(); // Below makes sure that the focal point is not contained within circle two - radius2 = random->nextRangeF(0.f, diffLen); + radius2 = d->fRandom->nextRangeF(0.f, diffLen); SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center1, radius1, center2, radius2, colors, stops, colorCount, @@ -512,9 +505,9 @@ GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, GrFragmentProcessor* effect; GrColor paintColor; GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &effect)); return effect; } @@ -705,19 +698,16 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); /* * All Two point conical gradient test create functions may occasionally create edge case shaders */ -GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; +GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { + SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; SkScalar radius1 = 0.f; SkPoint center2; SkScalar radius2; do { - center2.set(random->nextUScalar1(), random->nextUScalar1()); + center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); // Below makes sure radius2 is larger enouch such that the focal point // is inside the end circle - SkScalar increase = random->nextUScalar1(); + SkScalar increase = d->fRandom->nextUScalar1(); SkPoint diff = center2 - center1; SkScalar diffLen = diff.length(); radius2 = diffLen + increase; @@ -728,7 +718,7 @@ GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center1, radius1, center2, radius2, colors, stops, colorCount, @@ -736,10 +726,9 @@ GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, SkPaint paint; GrColor paintColor; GrFragmentProcessor* fp; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } @@ -965,18 +954,16 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); /* * All Two point conical gradient test create functions may occasionally create edge case shaders */ -GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; - SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0 +GrFragmentProcessor* +CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { + SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; + SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0 SkPoint center2; SkScalar radius2; do { - center2.set(random->nextUScalar1(), random->nextUScalar1()); + center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); // Below makes sure that circle one is contained within circle two - SkScalar increase = random->nextUScalar1(); + SkScalar increase = d->fRandom->nextUScalar1(); SkPoint diff = center2 - center1; SkScalar diffLen = diff.length(); radius2 = radius1 + diffLen + increase; @@ -987,7 +974,7 @@ GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center1, radius1, center2, radius2, colors, stops, colorCount, @@ -995,10 +982,9 @@ GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, SkPaint paint; GrColor paintColor; GrFragmentProcessor* fp; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } @@ -1208,30 +1194,27 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); /* * All Two point conical gradient test create functions may occasionally create edge case shaders */ -GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture**) { - SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; - SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0 +GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { + SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; + SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius1 != 0 SkPoint center2; SkScalar radius2; SkScalar diffLen; do { - center2.set(random->nextUScalar1(), random->nextUScalar1()); + center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); // If the circles share a center than we can't be in the outside case } while (center1 == center2); SkPoint diff = center2 - center1; diffLen = diff.length(); // Below makes sure that circle one is not contained within circle two // and have radius2 >= radius to match sorting on cpu side - radius2 = radius1 + random->nextRangeF(0.f, diffLen); + radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; SkScalar* stops = stopsArray; SkShader::TileMode tm; - int colorCount = RandomGradientParams(random, colors, &stops, &tm); + int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center1, radius1, center2, radius2, colors, stops, colorCount, @@ -1239,10 +1222,9 @@ GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, SkPaint paint; GrColor paintColor; GrFragmentProcessor* fp; - GrPaint grPaint; - SkAssertResult(shader->asFragmentProcessor(context, paint, - GrTest::TestMatrix(random), NULL, - &paintColor, grPaint.getShaderDataManager(), &fp)); + SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, + GrTest::TestMatrix(d->fRandom), NULL, + &paintColor, d->fShaderDataManager, &fp)); return fp; } diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 58a393140a..2d4694cb84 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -668,15 +668,12 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect); -GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrGeometryProcessor* QuadEdgeEffect::TestCreate(GrProcessorTestData* d) { // Doesn't work without derivative instructions. - return caps.shaderCaps()->shaderDerivativeSupport() ? - QuadEdgeEffect::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - random->nextBool()) : NULL; + return d->fCaps->shaderCaps()->shaderDerivativeSupport() ? + QuadEdgeEffect::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()) : NULL; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 39efd248ea..48aa813182 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -239,28 +239,25 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); -GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrGeometryProcessor* DefaultGeoProc::TestCreate(GrProcessorTestData* d) { uint32_t flags = 0; - if (random->nextBool()) { + if (d->fRandom->nextBool()) { flags |= GrDefaultGeoProcFactory::kColor_GPType; } - if (random->nextBool()) { + if (d->fRandom->nextBool()) { flags |= GrDefaultGeoProcFactory::kCoverage_GPType; } - if (random->nextBool()) { + if (d->fRandom->nextBool()) { flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; } return DefaultGeoProc::Create(flags, - GrRandomColor(random), - GrTest::TestMatrix(random), - GrTest::TestMatrix(random), - random->nextBool(), - random->nextBool(), - GrRandomCoverage(random)); + GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool(), + d->fRandom->nextBool(), + GrRandomCoverage(d->fRandom)); } const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 57e53b69d6..0d7da2ebcf 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -203,14 +203,11 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect); -GrGeometryProcessor* CircleEdgeEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - return CircleEdgeEffect::Create(GrRandomColor(random), - random->nextBool(), - GrTest::TestMatrix(random), - random->nextBool()); +GrGeometryProcessor* CircleEdgeEffect::TestCreate(GrProcessorTestData* d) { + return CircleEdgeEffect::Create(GrRandomColor(d->fRandom), + d->fRandom->nextBool(), + GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } /////////////////////////////////////////////////////////////////////////////// @@ -385,14 +382,11 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect); -GrGeometryProcessor* EllipseEdgeEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - return EllipseEdgeEffect::Create(GrRandomColor(random), - random->nextBool(), - GrTest::TestMatrix(random), - random->nextBool()); +GrGeometryProcessor* EllipseEdgeEffect::TestCreate(GrProcessorTestData* d) { + return EllipseEdgeEffect::Create(GrRandomColor(d->fRandom), + d->fRandom->nextBool(), + GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } /////////////////////////////////////////////////////////////////////////////// @@ -589,14 +583,11 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect); -GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - return DIEllipseEdgeEffect::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - (Mode)(random->nextRangeU(0,2)), - random->nextBool()); +GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(GrProcessorTestData* d) { + return DIEllipseEdgeEffect::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + (Mode)(d->fRandom->nextRangeU(0,2)), + d->fRandom->nextBool()); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index cdea9d01ff..6f492c76ac 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -217,17 +217,15 @@ GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); -GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrGeometryProcessor* GrConicEffect::TestCreate(GrProcessorTestData* d) { GrGeometryProcessor* gp; do { - GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( - random->nextULessThan(kGrProcessorEdgeTypeCnt)); - gp = GrConicEffect::Create(GrRandomColor(random), GrTest::TestMatrix(random), - edgeType, caps, - GrTest::TestMatrix(random), random->nextBool()); + GrPrimitiveEdgeType edgeType = + static_cast<GrPrimitiveEdgeType>( + d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); + gp = GrConicEffect::Create(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom), + edgeType, *d->fCaps, + GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool()); } while (NULL == gp); return gp; } @@ -427,19 +425,16 @@ GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); -GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrGeometryProcessor* GrQuadEffect::TestCreate(GrProcessorTestData* d) { GrGeometryProcessor* gp; do { GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( - random->nextULessThan(kGrProcessorEdgeTypeCnt)); - gp = GrQuadEffect::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - edgeType, caps, - GrTest::TestMatrix(random), - random->nextBool()); + d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); + gp = GrQuadEffect::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + edgeType, *d->fCaps, + GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } while (NULL == gp); return gp; } @@ -650,16 +645,14 @@ GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); -GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrGeometryProcessor* GrCubicEffect::TestCreate(GrProcessorTestData* d) { GrGeometryProcessor* gp; do { - GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( - random->nextULessThan(kGrProcessorEdgeTypeCnt)); - gp = GrCubicEffect::Create(GrRandomColor(random), - GrTest::TestMatrix(random), edgeType, caps); + GrPrimitiveEdgeType edgeType = + static_cast<GrPrimitiveEdgeType>( + d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); + gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), edgeType, *d->fCaps); } while (NULL == gp); return gp; } diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 5d94bd9862..c4ceeba866 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -180,17 +180,14 @@ void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); -GrFragmentProcessor* GrBicubicEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrFragmentProcessor* GrBicubicEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; SkScalar coefficients[16]; for (int i = 0; i < 16; i++) { - coefficients[i] = random->nextSScalar1(); + coefficients[i] = d->fRandom->nextSScalar1(); } - return GrBicubicEffect::Create(textures[texIdx], coefficients); + return GrBicubicEffect::Create(d->fTextures[texIdx], coefficients); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 2871f86ced..4bfa01644c 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -152,28 +152,23 @@ GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); -GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, }; SkShader::TileMode tileModes[] = { - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], }; - GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode : + GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_FilterMode); GrMaskFormat format; - switch (random->nextULessThan(3)) { - default: - SkFAIL("Incomplete enum\n"); + switch (d->fRandom->nextULessThan(3)) { case 0: format = kA8_GrMaskFormat; break; @@ -185,6 +180,7 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, break; } - return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params, - format, GrTest::TestMatrix(random), random->nextBool()); + return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[texIdx], params, + format, GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index d5b8a18e88..8b072f627b 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -128,22 +128,19 @@ void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect); -GrFragmentProcessor* GrConfigConversionEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt)); +GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestData* d) { + PMConversion pmConv = static_cast<PMConversion>(d->fRandom->nextULessThan(kPMConversionCnt)); bool swapRB; if (kNone_PMConversion == pmConv) { swapRB = true; } else { - swapRB = random->nextBool(); + swapRB = d->fRandom->nextBool(); } return SkNEW_ARGS(GrConfigConversionEffect, - (textures[GrProcessorUnitTest::kSkiaPMTextureIdx], + (d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx], swapRB, pmConv, - GrTest::TestMatrix(random))); + GrTest::TestMatrix(d->fRandom))); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp index e80e06a4a6..964e85c708 100644 --- a/src/gpu/effects/GrConstColorProcessor.cpp +++ b/src/gpu/effects/GrConstColorProcessor.cpp @@ -105,18 +105,15 @@ bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor); -GrFragmentProcessor* GrConstColorProcessor::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture*[]) { +GrFragmentProcessor* GrConstColorProcessor::TestCreate(GrProcessorTestData* d) { GrColor color; - int colorPicker = random->nextULessThan(3); + int colorPicker = d->fRandom->nextULessThan(3); switch (colorPicker) { case 0: { - uint32_t a = random->nextULessThan(0x100); - uint32_t r = random->nextULessThan(a+1); - uint32_t g = random->nextULessThan(a+1); - uint32_t b = random->nextULessThan(a+1); + uint32_t a = d->fRandom->nextULessThan(0x100); + uint32_t r = d->fRandom->nextULessThan(a+1); + uint32_t g = d->fRandom->nextULessThan(a+1); + uint32_t b = d->fRandom->nextULessThan(a+1); color = GrColorPackRGBA(r, g, b, a); break; } @@ -124,10 +121,10 @@ GrFragmentProcessor* GrConstColorProcessor::TestCreate(SkRandom* random, color = 0; break; case 2: - color = random->nextULessThan(0x100); + color = d->fRandom->nextULessThan(0x100); color = color | (color << 8) | (color << 16) | (color << 24); break; } - InputMode mode = static_cast<InputMode>(random->nextULessThan(kInputModeCnt)); + InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputModeCnt)); return GrConstColorProcessor::Create(color, mode); } diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index c42ac5326c..a3d032f4a0 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -60,18 +60,15 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect); -GrFragmentProcessor* AARectEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - SkRect rect = SkRect::MakeLTRB(random->nextSScalar1(), - random->nextSScalar1(), - random->nextSScalar1(), - random->nextSScalar1()); +GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) { + SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(), + d->fRandom->nextSScalar1(), + d->fRandom->nextSScalar1(), + d->fRandom->nextSScalar1()); GrFragmentProcessor* fp; do { - GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->nextULessThan( - kGrProcessorEdgeTypeCnt)); + GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( + d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); fp = AARectEffect::Create(edgeType, rect); } while (NULL == fp); @@ -360,20 +357,17 @@ bool GrConvexPolyEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect); -GrFragmentProcessor* GrConvexPolyEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - int count = random->nextULessThan(kMaxEdges) + 1; +GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) { + int count = d->fRandom->nextULessThan(kMaxEdges) + 1; SkScalar edges[kMaxEdges * 3]; for (int i = 0; i < 3 * count; ++i) { - edges[i] = random->nextSScalar1(); + edges[i] = d->fRandom->nextSScalar1(); } GrFragmentProcessor* fp; do { GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( - random->nextULessThan(kGrProcessorEdgeTypeCnt)); + d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); fp = GrConvexPolyEffect::Create(edgeType, count, edges); } while (NULL == fp); return fp; diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index 0dfc3bf54e..9f3c6c1170 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -224,25 +224,22 @@ bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect); -GrFragmentProcessor* GrConvolutionEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; - Direction dir = random->nextBool() ? kX_Direction : kY_Direction; - int radius = random->nextRangeU(1, kMaxKernelRadius); +GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; + Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction; + int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius); float kernel[kMaxKernelWidth]; for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) { - kernel[i] = random->nextSScalar1(); + kernel[i] = d->fRandom->nextSScalar1(); } float bounds[2]; for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { - bounds[i] = random->nextF(); + bounds[i] = d->fRandom->nextF(); } - bool useBounds = random->nextBool(); - return GrConvolutionEffect::Create(textures[texIdx], + bool useBounds = d->fRandom->nextBool(); + return GrConvolutionEffect::Create(d->fTextures[texIdx], dir, radius, kernel, diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp index c732098679..d7f4347b08 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.cpp +++ b/src/gpu/effects/GrCoverageSetOpXP.cpp @@ -245,12 +245,9 @@ void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); -GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture*[]) { - SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp + 1)); - bool invertCoverage = random->nextBool(); +GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d) { + SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1)); + bool invertCoverage = d->fRandom->nextBool(); return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); } diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index 94d50f684e..c1ff3af1ed 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -509,15 +509,11 @@ void GrCustomXferFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { } GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCustomXferFP); -GrFragmentProcessor* GrCustomXferFP::TestCreate(SkRandom* rand, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode); - - GrShaderDataManager shaderDataManager; - return SkNEW_ARGS(GrCustomXferFP, (&shaderDataManager, static_cast<SkXfermode::Mode>(mode), - textures[0])); +GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) { + int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode); + + return SkNEW_ARGS(GrCustomXferFP, (d->fShaderDataManager, static_cast<SkXfermode::Mode>(mode), + d->fTextures[0])); } /////////////////////////////////////////////////////////////////////////////// @@ -817,11 +813,9 @@ void GrCustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, } GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); -GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, - GrContext*, - const GrCaps&, - GrTexture*[]) { - int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode); +GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { + int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, + SkXfermode::kLastSeparableMode); return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); } diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 063bfd1352..26a2506b83 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -957,14 +957,11 @@ DashingCircleEffect::DashingCircleEffect(GrColor color, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); -GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAModeCount)); - return DashingCircleEffect::Create(GrRandomColor(random), - aaMode, GrTest::TestMatrix(random), - random->nextBool()); +GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) { + DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount)); + return DashingCircleEffect::Create(GrRandomColor(d->fRandom), + aaMode, GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } ////////////////////////////////////////////////////////////////////////////// @@ -1195,13 +1192,11 @@ DashingLineEffect::DashingLineEffect(GrColor color, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); -GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - DashAAMode aaMode = static_cast<DashAAMode>(random->nextULessThan(kDashAAModeCount)); - return DashingLineEffect::Create(GrRandomColor(random), - aaMode, GrTest::TestMatrix(random), random->nextBool()); +GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) { + DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount)); + return DashingLineEffect::Create(GrRandomColor(d->fRandom), + aaMode, GrTest::TestMatrix(d->fRandom), + d->fRandom->nextBool()); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp index e3f588ad65..31d58490e9 100644 --- a/src/gpu/effects/GrDisableColorXP.cpp +++ b/src/gpu/effects/GrDisableColorXP.cpp @@ -108,10 +108,7 @@ GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps, GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); -GrXPFactory* GrDisableColorXPFactory::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture*[]) { +GrXPFactory* GrDisableColorXPFactory::TestCreate(GrProcessorTestData*) { return GrDisableColorXPFactory::Create(); } diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index fa05275a32..393a99db57 100755 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -239,33 +239,30 @@ GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); -GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, }; SkShader::TileMode tileModes[] = { - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], }; - GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode : + GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_FilterMode); - return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - textures[texIdx], params, + return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + d->fTextures[texIdx], params, #ifdef SK_GAMMA_APPLY_TO_A8 - random->nextF(), + d->fRandom->nextF(), #endif - random->nextBool() ? + d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0, - random->nextBool()); + d->fRandom->nextBool()); } /////////////////////////////////////////////////////////////////////////////// @@ -465,31 +462,28 @@ GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); -GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx - : GrProcessorUnitTest::kAlphaTextureIdx; +GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx + : GrProcessorUnitTest::kAlphaTextureIdx; static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, }; SkShader::TileMode tileModes[] = { - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], }; - GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode - : GrTextureParams::kNone_FilterMode); + GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode + : GrTextureParams::kNone_FilterMode); - return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - textures[texIdx], + return GrDistanceFieldPathGeoProc::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + d->fTextures[texIdx], params, - random->nextBool() ? + d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0, - random->nextBool()); + d->fRandom->nextBool()); } /////////////////////////////////////////////////////////////////////////////// @@ -725,31 +719,28 @@ GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); -GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, }; SkShader::TileMode tileModes[] = { - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], }; - GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode : + GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_FilterMode); DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; uint32_t flags = kUseLCD_DistanceFieldEffectFlag; - flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; - flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; - return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), - GrTest::TestMatrix(random), - textures[texIdx], params, + flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; + flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; + return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), + GrTest::TestMatrix(d->fRandom), + d->fTextures[texIdx], params, wa, flags, - random->nextBool()); + d->fRandom->nextBool()); } diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index 0c252321ac..eb8466b0b5 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -53,10 +53,7 @@ void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect); -GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*, - GrContext*, - const GrCaps&, - GrTexture*[]) { +GrFragmentProcessor* DitherEffect::TestCreate(GrProcessorTestData*) { return DitherEffect::Create(); } diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 93876adafa..0dd83b4632 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -236,30 +236,28 @@ GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture, GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); -GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(SkRandom* random, - GrContext* context, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; - int width = random->nextRangeU(1, MAX_KERNEL_SIZE); - int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width); +GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; + int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); + int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); SkISize kernelSize = SkISize::Make(width, height); SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); for (int i = 0; i < width * height; i++) { - kernel.get()[i] = random->nextSScalar1(); + kernel.get()[i] = d->fRandom->nextSScalar1(); } - SkScalar gain = random->nextSScalar1(); - SkScalar bias = random->nextSScalar1(); - SkIPoint kernelOffset = SkIPoint::Make(random->nextRangeU(0, kernelSize.width()), - random->nextRangeU(0, kernelSize.height())); - SkIRect bounds = SkIRect::MakeXYWH(random->nextRangeU(0, textures[texIdx]->width()), - random->nextRangeU(0, textures[texIdx]->height()), - random->nextRangeU(0, textures[texIdx]->width()), - random->nextRangeU(0, textures[texIdx]->height())); - GrTextureDomain::Mode tileMode = static_cast<GrTextureDomain::Mode>(random->nextRangeU(0, 2)); - bool convolveAlpha = random->nextBool(); - return GrMatrixConvolutionEffect::Create(textures[texIdx], + SkScalar gain = d->fRandom->nextSScalar1(); + SkScalar bias = d->fRandom->nextSScalar1(); + SkIPoint kernelOffset = SkIPoint::Make(d->fRandom->nextRangeU(0, kernelSize.width()), + d->fRandom->nextRangeU(0, kernelSize.height())); + SkIRect bounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, d->fTextures[texIdx]->width()), + d->fRandom->nextRangeU(0, d->fTextures[texIdx]->height()), + d->fRandom->nextRangeU(0, d->fTextures[texIdx]->width()), + d->fRandom->nextRangeU(0, d->fTextures[texIdx]->height())); + GrTextureDomain::Mode tileMode = + static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2)); + bool convolveAlpha = d->fRandom->nextBool(); + return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], bounds, kernelSize, kernel.get(), diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index 7b9fd0a7c8..1b6df12790 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -75,17 +75,14 @@ bool CircleEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect); -GrFragmentProcessor* CircleEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) { SkPoint center; - center.fX = random->nextRangeScalar(0.f, 1000.f); - center.fY = random->nextRangeScalar(0.f, 1000.f); - SkScalar radius = random->nextRangeF(0.f, 1000.f); + center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); + center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); + SkScalar radius = d->fRandom->nextRangeF(0.f, 1000.f); GrPrimitiveEdgeType et; do { - et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); + et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt); } while (kHairlineAA_GrProcessorEdgeType == et); return CircleEffect::Create(et, center, radius); } @@ -257,18 +254,15 @@ bool EllipseEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect); -GrFragmentProcessor* EllipseEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { +GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) { SkPoint center; - center.fX = random->nextRangeScalar(0.f, 1000.f); - center.fY = random->nextRangeScalar(0.f, 1000.f); - SkScalar rx = random->nextRangeF(0.f, 1000.f); - SkScalar ry = random->nextRangeF(0.f, 1000.f); + center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); + center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); + SkScalar rx = d->fRandom->nextRangeF(0.f, 1000.f); + SkScalar ry = d->fRandom->nextRangeF(0.f, 1000.f); GrPrimitiveEdgeType et; do { - et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); + et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt); } while (kHairlineAA_GrProcessorEdgeType == et); return EllipseEffect::Create(et, center, rx, ry); } diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 6fc3c93e00..b6b57aefea 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -808,11 +808,8 @@ bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); -GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture*[]) { - SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::kLastCoeffMode)); +GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { + SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermode::kLastCoeffMode)); return GrPorterDuffXPFactory::Create(mode); } diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index 0db9c13e38..a31e89ce3e 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -107,19 +107,16 @@ bool CircularRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect); -GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - SkScalar w = random->nextRangeScalar(20.f, 1000.f); - SkScalar h = random->nextRangeScalar(20.f, 1000.f); - SkScalar r = random->nextRangeF(kRadiusMin, 9.f); +GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) { + SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); + SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); + SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f); SkRRect rrect; rrect.setRectXY(SkRect::MakeWH(w, h), r, r); GrFragmentProcessor* fp; do { GrPrimitiveEdgeType et = - (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); + (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt); fp = GrRRectEffect::Create(et, rrect); } while (NULL == fp); return fp; @@ -444,24 +441,21 @@ bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect); -GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps& caps, - GrTexture*[]) { - SkScalar w = random->nextRangeScalar(20.f, 1000.f); - SkScalar h = random->nextRangeScalar(20.f, 1000.f); +GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) { + SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); + SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); SkVector r[4]; - r[SkRRect::kUpperLeft_Corner].fX = random->nextRangeF(kRadiusMin, 9.f); + r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f); // ensure at least one corner really is elliptical do { - r[SkRRect::kUpperLeft_Corner].fY = random->nextRangeF(kRadiusMin, 9.f); + r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f); } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].fX); SkRRect rrect; - if (random->nextBool()) { + if (d->fRandom->nextBool()) { // half the time create a four-radii rrect. - r[SkRRect::kLowerRight_Corner].fX = random->nextRangeF(kRadiusMin, 9.f); - r[SkRRect::kLowerRight_Corner].fY = random->nextRangeF(kRadiusMin, 9.f); + r[SkRRect::kLowerRight_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f); + r[SkRRect::kLowerRight_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f); r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX; r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY; @@ -476,7 +470,8 @@ GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random, } GrFragmentProcessor* fp; do { - GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); + GrPrimitiveEdgeType et = + (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt); fp = GrRRectEffect::Create(et, rrect); } while (NULL == fp); return fp; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index 370b2ce9a9..0f6f4032a4 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -55,30 +55,27 @@ GrGLFragmentProcessor* GrSimpleTextureEffect::createGLInstance() const { GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); -GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode, }; SkShader::TileMode tileModes[] = { - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], - kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], + kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], }; - GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode : - GrTextureParams::kNone_FilterMode); + GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams::kBilerp_FilterMode : + GrTextureParams::kNone_FilterMode); static const GrCoordSet kCoordSets[] = { kLocal_GrCoordSet, kDevice_GrCoordSet }; - GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoordSets))]; + GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kCoordSets))]; - const SkMatrix& matrix = GrTest::TestMatrix(random); - return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet); + const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); + return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet); } diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 7ac3a18996..31f51aad22 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -286,23 +286,20 @@ void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); -GrFragmentProcessor* GrTextureDomainEffect::TestCreate(SkRandom* random, - GrContext*, - const GrCaps&, - GrTexture* textures[]) { - int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : - GrProcessorUnitTest::kAlphaTextureIdx; +GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData* d) { + int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : + GrProcessorUnitTest::kAlphaTextureIdx; SkRect domain; - domain.fLeft = random->nextUScalar1(); - domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1); - domain.fTop = random->nextUScalar1(); - domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1); + domain.fLeft = d->fRandom->nextUScalar1(); + domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); + domain.fTop = d->fRandom->nextUScalar1(); + domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); GrTextureDomain::Mode mode = - (GrTextureDomain::Mode) random->nextULessThan(GrTextureDomain::kModeCount); - const SkMatrix& matrix = GrTest::TestMatrix(random); - bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : false; - GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoordSet; - return GrTextureDomainEffect::Create(textures[texIdx], + (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kModeCount); + const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); + bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false; + GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoordSet; + return GrTextureDomainEffect::Create(d->fTextures[texIdx], matrix, domain, mode, |