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

Side by Side Diff: gm/mixedxfermodes.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/linepaths.cpp ('k') | gm/nested.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 14 matching lines...) Expand all
25 virtual SkString onShortName() SK_OVERRIDE { 25 virtual SkString onShortName() SK_OVERRIDE {
26 return SkString("mixed_xfermodes"); 26 return SkString("mixed_xfermodes");
27 } 27 }
28 28
29 virtual SkISize onISize() SK_OVERRIDE { 29 virtual SkISize onISize() SK_OVERRIDE {
30 return make_isize(790, 640); 30 return make_isize(790, 640);
31 } 31 }
32 32
33 void drawShape(SkCanvas* canvas, 33 void drawShape(SkCanvas* canvas,
34 const SkPaint& paint, 34 const SkPaint& paint,
35 SkMWCRandom* random) { 35 SkRandom* random) {
36 static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntTo Scalar(-50), 36 static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntTo Scalar(-50),
37 SkIntToScalar(75), SkIntToS calar(105)); 37 SkIntToScalar(75), SkIntToS calar(105));
38 int shape = random->nextULessThan(5); 38 int shape = random->nextULessThan(5);
39 switch (shape) { 39 switch (shape) {
40 case 0: 40 case 0:
41 canvas->drawCircle(0, 0, 50, paint); 41 canvas->drawCircle(0, 0, 50, paint);
42 break; 42 break;
43 case 1: 43 case 1:
44 canvas->drawRoundRect(kRect, SkIntToScalar(10), SkIntToScalar(20), p aint); 44 canvas->drawRoundRect(kRect, SkIntToScalar(10), SkIntToScalar(20), p aint);
45 break; 45 break;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 SkMatrix lm; 96 SkMatrix lm;
97 lm.setScale(SkIntToScalar(20), SkIntToScalar(20)); 97 lm.setScale(SkIntToScalar(20), SkIntToScalar(20));
98 fBG->setLocalMatrix(lm); 98 fBG->setLocalMatrix(lm);
99 99
100 SkPaint bgPaint; 100 SkPaint bgPaint;
101 bgPaint.setShader(fBG.get()); 101 bgPaint.setShader(fBG.get());
102 canvas->drawPaint(bgPaint); 102 canvas->drawPaint(bgPaint);
103 SkISize size = canvas->getDeviceSize(); 103 SkISize size = canvas->getDeviceSize();
104 SkScalar maxScale = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig ht))) / 300; 104 SkScalar maxScale = SkScalarSqrt((SkIntToScalar(size.fWidth * size.fHeig ht))) / 300;
105 SkMWCRandom random; 105 SkRandom random;
106 for (int i = 0; i < kNumShapes; ++i) { 106 for (int i = 0; i < kNumShapes; ++i) {
107 SkScalar s = random.nextRangeScalar(SK_Scalar1 / 8, SK_Scalar1) * ma xScale; 107 SkScalar s = random.nextRangeScalar(SK_Scalar1 / 8, SK_Scalar1) * ma xScale;
108 SkScalar r = random.nextRangeScalar(0, SkIntToScalar(360)); 108 SkScalar r = random.nextRangeScalar(0, SkIntToScalar(360));
109 SkScalar dx = random.nextRangeScalar(0, SkIntToScalar(size.fWidth)); 109 SkScalar dx = random.nextRangeScalar(0, SkIntToScalar(size.fWidth));
110 SkScalar dy = random.nextRangeScalar(0, SkIntToScalar(size.fHeight)) ; 110 SkScalar dy = random.nextRangeScalar(0, SkIntToScalar(size.fHeight)) ;
111 SkColor color = random.nextU(); 111 SkColor color = random.nextU();
112 SkXfermode::Mode mode = 112 SkXfermode::Mode mode =
113 static_cast<SkXfermode::Mode>(random.nextULessThan(SkXfermode::k LastMode + 1)); 113 static_cast<SkXfermode::Mode>(random.nextULessThan(SkXfermode::k LastMode + 1));
114 114
115 SkPaint p; 115 SkPaint p;
(...skipping 23 matching lines...) Expand all
139 SkPath fConvexPath; 139 SkPath fConvexPath;
140 typedef GM INHERITED; 140 typedef GM INHERITED;
141 }; 141 };
142 142
143 ////////////////////////////////////////////////////////////////////////////// 143 //////////////////////////////////////////////////////////////////////////////
144 144
145 static GM* MyFactory(void*) { return new MixedXfermodesGM; } 145 static GM* MyFactory(void*) { return new MixedXfermodesGM; }
146 static GMRegistry reg(MyFactory); 146 static GMRegistry reg(MyFactory);
147 147
148 } 148 }
OLDNEW
« no previous file with comments | « gm/linepaths.cpp ('k') | gm/nested.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698