diff options
author | scroggo <scroggo@google.com> | 2014-12-15 12:54:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-15 12:54:51 -0800 |
commit | f9d610179d7d4198b57b12d06f8d1ca09f580df3 (patch) | |
tree | d53f2e440ad0173132c5902d0b4a04c8fd5cfcf1 /gm | |
parent | 9a0d6d6c88b87b3d0195e5633403325b6e922b8c (diff) |
There can be only one (SkRandom)!
Remove SkLCGRandom. We already decided the new one was better, which is
why we wrote the new SkRandom.
Convert GMs that were using SkLCGRandom to use the improved SkRandom.
Motivated by the fact that these GMs draw differently on some runs. We
believe this to be a result of using the old SkLCGRandom.
Add each of the tests that were using SkLCGRandom to ignore-tests.txt,
since we expect they'll draw differently using SkRandom.
Move a trimmed down version of SkLCGRandom into SkDiscretePathEffect.
In order to preserve the old behavior, trim down SkLCGRandom to only
the methods used by SkDiscretePathEffect, and hide it in
SkDiscretePathEffect's cpp file.
BUG=skia:3241
Review URL: https://codereview.chromium.org/805963002
Diffstat (limited to 'gm')
-rwxr-xr-x | gm/beziers.cpp | 6 | ||||
-rw-r--r-- | gm/circles.cpp | 2 | ||||
-rw-r--r-- | gm/complexclip2.cpp | 2 | ||||
-rw-r--r-- | gm/convexpaths.cpp | 2 | ||||
-rw-r--r-- | gm/cubicpaths.cpp | 4 | ||||
-rw-r--r-- | gm/degeneratesegments.cpp | 2 | ||||
-rw-r--r-- | gm/emptypath.cpp | 2 | ||||
-rw-r--r-- | gm/getpostextpath.cpp | 2 | ||||
-rw-r--r-- | gm/hittestpath.cpp | 2 | ||||
-rw-r--r-- | gm/linepaths.cpp | 4 | ||||
-rw-r--r-- | gm/points.cpp | 4 | ||||
-rw-r--r-- | gm/polygons.cpp | 4 | ||||
-rw-r--r-- | gm/quadpaths.cpp | 4 | ||||
-rw-r--r-- | gm/strokerects.cpp | 4 | ||||
-rw-r--r-- | gm/strokes.cpp | 8 |
15 files changed, 26 insertions, 26 deletions
diff --git a/gm/beziers.cpp b/gm/beziers.cpp index 48033bb385..2371fdd0eb 100755 --- a/gm/beziers.cpp +++ b/gm/beziers.cpp @@ -14,7 +14,7 @@ static const SkScalar SH = SkIntToScalar(H); -static void rnd_quad(SkPath* p, SkPaint* paint, SkLCGRandom& rand) { +static void rnd_quad(SkPath* p, SkPaint* paint, SkRandom& rand) { p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H)); for (int x = 0; x < 2; ++x) { p->quadTo(rand.nextRangeScalar(W / 4, W), rand.nextRangeScalar(0, H), @@ -27,7 +27,7 @@ static void rnd_quad(SkPath* p, SkPaint* paint, SkLCGRandom& rand) { paint->setAlpha(0xFF); } -static void rnd_cubic(SkPath* p, SkPaint* paint, SkLCGRandom& rand) { +static void rnd_cubic(SkPath* p, SkPaint* paint, SkRandom& rand) { p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H)); for (int x = 0; x < 2; ++x) { p->cubicTo(rand.nextRangeScalar(W / 4, W), rand.nextRangeScalar(0, H), @@ -64,7 +64,7 @@ protected: paint.setStrokeWidth(SkIntToScalar(9)/2); paint.setAntiAlias(true); - SkLCGRandom rand; + SkRandom rand; for (int i = 0; i < N; i++) { SkPath p; rnd_quad(&p, &paint, rand); diff --git a/gm/circles.cpp b/gm/circles.cpp index 2c9368be92..6fa682c266 100644 --- a/gm/circles.cpp +++ b/gm/circles.cpp @@ -156,7 +156,6 @@ protected: } virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { - SkLCGRandom rand; // Draw a giant AA circle as the background. SkISize size = this->getISize(); SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth), @@ -168,6 +167,7 @@ protected: giantPaint.setColor(0x80808080); canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPaint); + SkRandom rand; canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); int i; for (i = 0; i < fPaints.count(); ++i) { diff --git a/gm/complexclip2.cpp b/gm/complexclip2.cpp index f99d5b484d..8688c86465 100644 --- a/gm/complexclip2.cpp +++ b/gm/complexclip2.cpp @@ -81,7 +81,7 @@ public: SkRegion::kReplace_Op, }; - SkLCGRandom r; + SkRandom r; for (int i = 0; i < kRows; ++i) { for (int j = 0; j < kCols; ++j) { for (int k = 0; k < 5; ++k) { diff --git a/gm/convexpaths.cpp b/gm/convexpaths.cpp index b869887a97..4f9633d8b7 100644 --- a/gm/convexpaths.cpp +++ b/gm/convexpaths.cpp @@ -265,7 +265,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); - SkLCGRandom rand; + SkRandom rand; canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); // As we've added more paths this has gotten pretty big. Scale the whole thing down. diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp index f171522caa..9c6cffbdb3 100644 --- a/gm/cubicpaths.cpp +++ b/gm/cubicpaths.cpp @@ -140,7 +140,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); @@ -290,7 +290,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); diff --git a/gm/degeneratesegments.cpp b/gm/degeneratesegments.cpp index 17bf83bddc..5435d533f8 100644 --- a/gm/degeneratesegments.cpp +++ b/gm/degeneratesegments.cpp @@ -302,7 +302,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(220*SK_Scalar1, 50*SK_Scalar1); canvas->save(); canvas->translate(2*SK_Scalar1, 30 * SK_Scalar1); // The title diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp index 87e1cc554e..3b6fe8108f 100644 --- a/gm/emptypath.cpp +++ b/gm/emptypath.cpp @@ -73,7 +73,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); int i = 0; canvas->save(); diff --git a/gm/getpostextpath.cpp b/gm/getpostextpath.cpp index a411520258..45701071bb 100644 --- a/gm/getpostextpath.cpp +++ b/gm/getpostextpath.cpp @@ -56,7 +56,7 @@ protected: SkAutoTArray<SkScalar> widths(len); paint.getTextWidths(text, len, &widths[0]); - SkLCGRandom rand; + SkRandom rand; SkScalar x = SkIntToScalar(20); SkScalar y = SkIntToScalar(100); for (int i = 0; i < len; ++i) { diff --git a/gm/hittestpath.cpp b/gm/hittestpath.cpp index d971db9282..caed98fc95 100644 --- a/gm/hittestpath.cpp +++ b/gm/hittestpath.cpp @@ -46,7 +46,7 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkPath path; - SkLCGRandom rand; + SkRandom rand; int scale = 300; for (int i = 0; i < 4; ++i) { diff --git a/gm/linepaths.cpp b/gm/linepaths.cpp index 53a9327878..05900c758e 100644 --- a/gm/linepaths.cpp +++ b/gm/linepaths.cpp @@ -95,7 +95,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); @@ -239,7 +239,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); diff --git a/gm/points.cpp b/gm/points.cpp index 793e2e8f4f..b241fe019e 100644 --- a/gm/points.cpp +++ b/gm/points.cpp @@ -27,7 +27,7 @@ protected: return SkISize::Make(640, 490); } - static void fill_pts(SkPoint pts[], size_t n, SkLCGRandom* rand) { + static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) { for (size_t i = 0; i < n; i++) { // Compute these independently and store in variables, rather // than in the parameter-passing expression, to get consistent @@ -41,7 +41,7 @@ protected: virtual void onDraw(SkCanvas* canvas) { canvas->translate(SK_Scalar1, SK_Scalar1); - SkLCGRandom rand; + SkRandom rand; SkPaint p0, p1, p2, p3; const size_t n = 99; diff --git a/gm/polygons.cpp b/gm/polygons.cpp index 56b2e97ceb..1d639780fd 100644 --- a/gm/polygons.cpp +++ b/gm/polygons.cpp @@ -88,7 +88,7 @@ protected: canvas->translate(x, y); } - static void SetColorAndAlpha(SkPaint* paint, SkLCGRandom* rand) { + static void SetColorAndAlpha(SkPaint* paint, SkRandom* rand) { SkColor color = rand->nextU(); color |= 0xff000000; paint->setColor(color); @@ -113,7 +113,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); - SkLCGRandom rand; + SkRandom rand; // For stroke style painter paint.setStyle(SkPaint::kStroke_Style); for (int join = 0; join < kNumJoins; ++join) { diff --git a/gm/quadpaths.cpp b/gm/quadpaths.cpp index f2c4cf1fc8..1dbb3d090c 100644 --- a/gm/quadpaths.cpp +++ b/gm/quadpaths.cpp @@ -96,7 +96,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); @@ -245,7 +245,7 @@ protected: 20 * SK_Scalar1, titlePaint); - SkLCGRandom rand; + SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); canvas->save(); canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); diff --git a/gm/strokerects.cpp b/gm/strokerects.cpp index f3445cc35d..65eadd1a90 100644 --- a/gm/strokerects.cpp +++ b/gm/strokerects.cpp @@ -37,7 +37,7 @@ protected: return SkISize::Make(W*2, H*2); } - static void rnd_rect(SkRect* r, SkLCGRandom& rand) { + static void rnd_rect(SkRect* r, SkRandom& rand) { SkScalar x = rand.nextUScalar1() * W; SkScalar y = rand.nextUScalar1() * H; SkScalar w = rand.nextUScalar1() * (W >> 2); @@ -65,7 +65,7 @@ protected: , SW - SkIntToScalar(2), SH - SkIntToScalar(2) )); - SkLCGRandom rand; + SkRandom rand; for (int i = 0; i < N; i++) { SkRect r; rnd_rect(&r, rand); diff --git a/gm/strokes.cpp b/gm/strokes.cpp index 81741693cf..2a92c031ae 100644 --- a/gm/strokes.cpp +++ b/gm/strokes.cpp @@ -18,7 +18,7 @@ static const SkScalar SW = SkIntToScalar(W); static const SkScalar SH = SkIntToScalar(H); -static void rnd_rect(SkRect* r, SkPaint* paint, SkLCGRandom& rand) { +static void rnd_rect(SkRect* r, SkPaint* paint, SkRandom& rand) { SkScalar x = rand.nextUScalar1() * W; SkScalar y = rand.nextUScalar1() * H; SkScalar w = rand.nextUScalar1() * (W >> 2); @@ -65,7 +65,7 @@ protected: , SW - SkIntToScalar(2), SH - SkIntToScalar(2) )); - SkLCGRandom rand; + SkRandom rand; for (int i = 0; i < N; i++) { SkRect r; rnd_rect(&r, &paint, rand); @@ -85,7 +85,7 @@ class Strokes2GM : public skiagm::GM { SkPath fPath; public: Strokes2GM() { - SkLCGRandom rand; + SkRandom rand; fPath.moveTo(0, 0); for (int i = 0; i < 13; i++) { SkScalar x = rand.nextUScalar1() * (W >> 1); @@ -129,7 +129,7 @@ protected: SW - SkIntToScalar(2), SH - SkIntToScalar(2))); - SkLCGRandom rand; + SkRandom rand; for (int i = 0; i < N/2; i++) { SkRect r; rnd_rect(&r, &paint, rand); |