Use SkMWRandom in GLPrograms test.

R=jvanverth@google.com
Review URL: https://codereview.appspot.com/7306097

git-svn-id: http://skia.googlecode.com/svn/trunk@7721 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrEffectUnitTest.h b/include/gpu/GrEffectUnitTest.h
index 3d251e2..03a302c 100644
--- a/include/gpu/GrEffectUnitTest.h
+++ b/include/gpu/GrEffectUnitTest.h
@@ -24,7 +24,7 @@
 /**
  * A helper for use in GrEffect::TestCreate functions.
  */
-const SkMatrix& TestMatrix(SkRandom*);
+const SkMatrix& TestMatrix(SkMWCRandom*);
 
 }
 
@@ -37,14 +37,14 @@
 class GrEffectTestFactory : GrNoncopyable {
 public:
 
-    typedef GrEffectRef* (*CreateProc)(SkRandom*, GrContext*, GrTexture* dummyTextures[]);
+    typedef GrEffectRef* (*CreateProc)(SkMWCRandom*, GrContext*, GrTexture* dummyTextures[]);
 
     GrEffectTestFactory(CreateProc createProc) {
         fCreateProc = createProc;
         GetFactories()->push_back(this);
     }
 
-    static GrEffectRef* CreateStage(SkRandom* random,
+    static GrEffectRef* CreateStage(SkMWCRandom* random,
                                     GrContext* context,
                                     GrTexture* dummyTextures[]) {
         uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
@@ -62,11 +62,11 @@
  */
 #define GR_DECLARE_EFFECT_TEST                                                      \
     static GrEffectTestFactory gTestFactory;                                        \
-    static GrEffectRef* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
+    static GrEffectRef* TestCreate(SkMWCRandom*, GrContext*, GrTexture* dummyTextures[2])
 
 /** GrEffect subclasses should insert this macro in their implementation file. They must then
  *  also implement this static function:
- *      GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2]);
+ *      GrEffect* TestCreate(SkMWCRandom*, GrContext*, GrTexture* dummyTextures[2]);
  * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses.
  * The first texture has config kSkia8888_GrPixelConfig and the second has
  * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
@@ -80,7 +80,7 @@
 // The unit test relies on static initializers. Just declare the TestCreate function so that
 // its definitions will compile.
 #define GR_DECLARE_EFFECT_TEST \
-    static GrEffectRef* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
+    static GrEffectRef* TestCreate(SkMWCRandom*, GrContext*, GrTexture* dummyTextures[2])
 #define GR_DEFINE_EFFECT_TEST(X)
 
 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp
index 1d8de07..992060c 100644
--- a/src/effects/SkBicubicImageFilter.cpp
+++ b/src/effects/SkBicubicImageFilter.cpp
@@ -320,7 +320,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrBicubicEffect);
 
-GrEffectRef* GrBicubicEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrBicubicEffect::TestCreate(SkMWCRandom* random,
                                          GrContext* context,
                                          GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 1582464..73e9616 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -462,7 +462,7 @@
 
 GR_DEFINE_EFFECT_TEST(ColorMatrixEffect);
 
-GrEffectRef* ColorMatrixEffect::TestCreate(SkRandom* random,
+GrEffectRef* ColorMatrixEffect::TestCreate(SkMWCRandom* random,
                                            GrContext*,
                                            GrTexture* dummyTextures[2]) {
     SkColorMatrix colorMatrix;
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index f652bb2..ee0906c 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -359,7 +359,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrDisplacementMapEffect);
 
-GrEffectRef* GrDisplacementMapEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrDisplacementMapEffect::TestCreate(SkMWCRandom* random,
                                                  GrContext* context,
                                                  GrTexture* textures[]) {
     int texIdxDispl = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 498c8e0..e195262 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -947,13 +947,13 @@
 #if SK_SUPPORT_GPU
 
 namespace {
-SkPoint3 random_point3(SkRandom* random) {
+SkPoint3 random_point3(SkMWCRandom* random) {
     return SkPoint3(SkScalarToFloat(random->nextSScalar1()),
                     SkScalarToFloat(random->nextSScalar1()),
                     SkScalarToFloat(random->nextSScalar1()));
 }
 
-SkLight* create_random_light(SkRandom* random) {
+SkLight* create_random_light(SkMWCRandom* random) {
     int type = random->nextULessThan(3);
     switch (type) {
         case 0: {
@@ -1079,7 +1079,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrDiffuseLightingEffect);
 
-GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrDiffuseLightingEffect::TestCreate(SkMWCRandom* random,
                                                  GrContext* context,
                                                  GrTexture* textures[]) {
     SkScalar surfaceScale = random->nextSScalar1();
@@ -1290,7 +1290,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrSpecularLightingEffect);
 
-GrEffectRef* GrSpecularLightingEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrSpecularLightingEffect::TestCreate(SkMWCRandom* random,
                                                   GrContext* context,
                                                   GrTexture* textures[]) {
     SkScalar surfaceScale = random->nextSScalar1();
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index e0ab4d0..b577a1d 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -200,7 +200,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrMagnifierEffect);
 
-GrEffectRef* GrMagnifierEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrMagnifierEffect::TestCreate(SkMWCRandom* random,
                                            GrContext* context,
                                            GrTexture** textures) {
     const int kMaxWidth = 200;
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 97af7ad..0addc23 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -535,7 +535,7 @@
 // Allows for a 5x5 kernel (or 25x1, for that matter).
 #define MAX_KERNEL_SIZE 25
 
-GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkMWCRandom* random,
                                                    GrContext* context,
                                                    GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 8010034..b40130b 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -419,7 +419,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrMorphologyEffect);
 
-GrEffectRef* GrMorphologyEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrMorphologyEffect::TestCreate(SkMWCRandom* random,
                                             GrContext* context,
                                             GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 5c00794..cf7ddc5 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -369,7 +369,7 @@
 
 GR_DEFINE_EFFECT_TEST(ColorTableEffect);
 
-GrEffectRef* ColorTableEffect::TestCreate(SkRandom* random,
+GrEffectRef* ColorTableEffect::TestCreate(SkMWCRandom* random,
                                           GrContext* context,
                                           GrTexture* textures[]) {
     static unsigned kAllFlags = SkTable_ColorFilter::kR_Flag | SkTable_ColorFilter::kG_Flag |
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 6c95374..261ad8f 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -870,7 +870,7 @@
     }
 }
 
-int GrGradientEffect::RandomGradientParams(SkRandom* random,
+int GrGradientEffect::RandomGradientParams(SkMWCRandom* random,
                                            SkColor colors[],
                                            SkScalar** stops,
                                            SkShader::TileMode* tm) {
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 7bcda14..271a2b6 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -246,7 +246,7 @@
         passed to the gradient factory rather than the array.
     */
     static const int kMaxRandomGradientColors = 4;
-    static int RandomGradientParams(SkRandom* r,
+    static int RandomGradientParams(SkMWCRandom* r,
                                     SkColor colors[kMaxRandomGradientColors],
                                     SkScalar** stops,
                                     SkShader::TileMode* tm);
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index f6bae72..adc60f8 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -516,7 +516,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrLinearGradient);
 
-GrEffectRef* GrLinearGradient::TestCreate(SkRandom* random,
+GrEffectRef* GrLinearGradient::TestCreate(SkMWCRandom* random,
                                           GrContext* context,
                                           GrTexture**) {
     SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()},
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 07f1c19..ff3a2aa 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -533,7 +533,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrRadialGradient);
 
-GrEffectRef* GrRadialGradient::TestCreate(SkRandom* random,
+GrEffectRef* GrRadialGradient::TestCreate(SkMWCRandom* random,
                                           GrContext* context,
                                           GrTexture**) {
     SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 458ddbc..b5d94aa 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -453,7 +453,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrSweepGradient);
 
-GrEffectRef* GrSweepGradient::TestCreate(SkRandom* random,
+GrEffectRef* GrSweepGradient::TestCreate(SkMWCRandom* random,
                                          GrContext* context,
                                          GrTexture**) {
     SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index f1acd55..5c11d4c 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -451,7 +451,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrConical2Gradient);
 
-GrEffectRef* GrConical2Gradient::TestCreate(SkRandom* random,
+GrEffectRef* GrConical2Gradient::TestCreate(SkMWCRandom* random,
                                             GrContext* context,
                                             GrTexture**) {
     SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 4eaf487..6bb475a 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -487,7 +487,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrRadial2Gradient);
 
-GrEffectRef* GrRadial2Gradient::TestCreate(SkRandom* random,
+GrEffectRef* GrRadial2Gradient::TestCreate(SkMWCRandom* random,
                                            GrContext* context,
                                            GrTexture**) {
     SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
diff --git a/src/gpu/GrEffect.cpp b/src/gpu/GrEffect.cpp
index 40a519a..6e743e7 100644
--- a/src/gpu/GrEffect.cpp
+++ b/src/gpu/GrEffect.cpp
@@ -21,7 +21,7 @@
 #endif
 
 namespace GrEffectUnitTest {
-const SkMatrix& TestMatrix(SkRandom* random) {
+const SkMatrix& TestMatrix(SkMWCRandom* random) {
     static SkMatrix gMatrices[5];
     static bool gOnce;
     if (!gOnce) {
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 92df82d..1dd51c8 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -131,7 +131,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrConfigConversionEffect);
 
-GrEffectRef* GrConfigConversionEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrConfigConversionEffect::TestCreate(SkMWCRandom* random,
                                                   GrContext* context,
                                                   GrTexture* textures[]) {
     PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt));
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 8968857..12c32f0 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -178,7 +178,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrConvolutionEffect);
 
-GrEffectRef* GrConvolutionEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrConvolutionEffect::TestCreate(SkMWCRandom* random,
                                              GrContext* context,
                                              GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index b674879..0fe083b 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -67,7 +67,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect);
 
-GrEffectRef* GrSimpleTextureEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random,
                                                GrContext* context,
                                                GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index 833c198..39c992e 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -186,7 +186,7 @@
 
 GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect);
 
-GrEffectRef* GrTextureDomainEffect::TestCreate(SkRandom* random,
+GrEffectRef* GrTextureDomainEffect::TestCreate(SkMWCRandom* random,
                                                GrContext* context,
                                                GrTexture* textures[]) {
     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index ad3d2c6..d4873ca 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -20,20 +20,6 @@
 #include "SkRandom.h"
 #include "Test.h"
 
-namespace {
-
-const GrEffectRef* create_random_effect(SkMWCRandom* random,
-                                        GrContext* context,
-                                        GrTexture* dummyTextures[]) {
-    // TODO: Make GrTestFactory use SkMWCRandom and simply pass along param random
-    SkRandom sk_random;
-    sk_random.setSeed(random->nextU());
-    GrEffectRef* effect = GrEffectTestFactory::CreateStage(&sk_random, context, dummyTextures);
-    GrAssert(effect);
-    return effect;
-}
-}
-
 void GrGLProgram::Desc::setRandom(SkMWCRandom* random,
                                   const GrGpuGL* gpu,
                                   const GrEffectStage stages[GrDrawState::kNumStages]) {
@@ -118,9 +104,10 @@
             // enable the stage?
             if (random.nextBool()) {
                 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
-                SkAutoTUnref<const GrEffectRef> effect(create_random_effect(&random,
-                                                                            getContext(),
-                                                                            dummyTextures));
+                SkAutoTUnref<const GrEffectRef> effect(GrEffectTestFactory::CreateStage(
+                                                                                &random,
+                                                                                this->getContext(),
+                                                                                dummyTextures));
                 stages[s].setEffect(effect.get());
             }
         }