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

Side by Side Diff: samplecode/SampleText.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 | « samplecode/SampleStrokePath.cpp ('k') | samplecode/SampleTextAlpha.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 2011 Google Inc. 3 * Copyright 2011 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 nn = SkIntToScalar((unsigned int)n); 129 nn = SkIntToScalar((unsigned int)n);
130 mm = m; 130 mm = m;
131 } 131 }
132 132
133 SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm); 133 SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm);
134 SkASSERT(length2 == length); 134 SkASSERT(length2 == length);
135 SkASSERT(mm == width); 135 SkASSERT(mm == width);
136 } 136 }
137 137
138 static SkMWCRandom gRand; 138 static SkRandom gRand;
139 139
140 class SkPowerMode : public SkXfermode { 140 class SkPowerMode : public SkXfermode {
141 public: 141 public:
142 SkPowerMode(SkScalar exponent) { this->init(exponent); } 142 SkPowerMode(SkScalar exponent) { this->init(exponent); }
143 143
144 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 144 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
145 const SkAlpha aa[]) const SK_OVERRIDE; 145 const SkAlpha aa[]) const SK_OVERRIDE;
146 146
147 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); 147 typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&);
148 148
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 SkCanvas canvas(*bm); 280 SkCanvas canvas(*bm);
281 SkPaint paint; 281 SkPaint paint;
282 const char* s = "Lorem ipsum dolor sit amet, consectetuer adipiscing eli t"; 282 const char* s = "Lorem ipsum dolor sit amet, consectetuer adipiscing eli t";
283 283
284 paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag 284 paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag
285 | SkPaint::kDevKernText_Flag); 285 | SkPaint::kDevKernText_Flag);
286 paint.setTextSize(SkIntToScalar(14)); 286 paint.setTextSize(SkIntToScalar(14));
287 canvas.drawText(s, strlen(s), SkIntToScalar(8), SkIntToScalar(14), paint ); 287 canvas.drawText(s, strlen(s), SkIntToScalar(8), SkIntToScalar(14), paint );
288 } 288 }
289 289
290 static void fill_pts(SkPoint pts[], size_t n, SkMWCRandom* rand) { 290 static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) {
291 for (size_t i = 0; i < n; i++) 291 for (size_t i = 0; i < n; i++)
292 pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480); 292 pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480);
293 } 293 }
294 294
295 virtual void onDrawContent(SkCanvas* canvas) { 295 virtual void onDrawContent(SkCanvas* canvas) {
296 SkAutoCanvasRestore restore(canvas, false); 296 SkAutoCanvasRestore restore(canvas, false);
297 { 297 {
298 SkRect r; 298 SkRect r;
299 r.set(0, 0, SkIntToScalar(1000), SkIntToScalar(20)); 299 r.set(0, 0, SkIntToScalar(1000), SkIntToScalar(20));
300 // canvas->saveLayer(&r, NULL, SkCanvas::kHasAlphaLayer_SaveFlag); 300 // canvas->saveLayer(&r, NULL, SkCanvas::kHasAlphaLayer_SaveFlag);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 SkScalar fClickX; 351 SkScalar fClickX;
352 SkMaskFilter* fMF; 352 SkMaskFilter* fMF;
353 353
354 typedef SampleView INHERITED; 354 typedef SampleView INHERITED;
355 }; 355 };
356 356
357 ////////////////////////////////////////////////////////////////////////////// 357 //////////////////////////////////////////////////////////////////////////////
358 358
359 static SkView* MyFactory() { return new TextSpeedView; } 359 static SkView* MyFactory() { return new TextSpeedView; }
360 static SkViewRegister reg(MyFactory); 360 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleStrokePath.cpp ('k') | samplecode/SampleTextAlpha.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698