fix up test create functions
TBR=bsalomon@google.com
BUG=skia:
Review URL: https://codereview.chromium.org/1213623022
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 006b9e6..36c046b 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -207,17 +207,13 @@
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 302e8b6..007ff26 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -139,19 +139,15 @@
///////////////////////////////////////////////////////////////////////////////
-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();
+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();
- GrShaderDataManager shaderDataManager;
- return SkNEW_ARGS(GrArithmeticFP, (&shaderDataManager, k1, k2, k3, k4, enforcePMColor,
- textures[0]));
+ return SkNEW_ARGS(GrArithmeticFP, (d->fShaderDataManager, k1, k2, k3, k4, enforcePMColor,
+ d->fTextures[0]));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
@@ -305,15 +301,12 @@
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 22a9ac6..0436f08 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -821,14 +821,11 @@
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 @@
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 ac3bee0..f4a2260 100644
--- a/src/effects/SkColorFilters.cpp
+++ b/src/effects/SkColorFilters.cpp
@@ -344,20 +344,17 @@
}
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 6401aaa..16275d5 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -531,13 +531,10 @@
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 932a4b1..817206f 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -527,31 +527,27 @@
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 1b309ab..3a96bc3 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1597,19 +1597,16 @@
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 @@
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 96d04e2..ba704b3 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -207,19 +207,16 @@
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 5eccb0d..f284360 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -543,19 +543,16 @@
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 38a7784..b661120 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -602,20 +602,18 @@
/////////////////////////////////////////////////////////////////////
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);
+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 = random->nextBool() ?
+ SkShader* shader = d->fRandom->nextBool() ?
SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed,
stitchTiles ? &tileSize : NULL) :
SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed,
@@ -625,8 +623,8 @@
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 e4bc778..faffa4a 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -551,21 +551,18 @@
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 @@
));
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 2fbe435..8e2edcf 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -527,28 +527,24 @@
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 b46a044..2a039df 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -501,28 +501,24 @@
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 4bf8098..95d8a2e 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -245,26 +245,22 @@
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 07722e9..38b266d 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -187,16 +187,13 @@
/*
* 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 @@
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 @@
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 @@
/*
* 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* 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 @@
/*
* 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 @@
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 @@
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 @@
/*
* 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 @@
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 @@
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 @@
/*
* 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 @@
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;
}