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

Side by Side Diff: tests/DrawBitmapRectTest.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 | « tests/ColorTest.cpp ('k') | tests/GLProgramsTest.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 "Test.h" 8 #include "Test.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkMatrixUtils.h" 13 #include "SkMatrixUtils.h"
14 14
15 static void rand_matrix(SkMatrix* mat, SkMWCRandom& rand, unsigned mask) { 15 static void rand_matrix(SkMatrix* mat, SkRandom& rand, unsigned mask) {
16 mat->setIdentity(); 16 mat->setIdentity();
17 if (mask & SkMatrix::kTranslate_Mask) { 17 if (mask & SkMatrix::kTranslate_Mask) {
18 mat->postTranslate(rand.nextSScalar1(), rand.nextSScalar1()); 18 mat->postTranslate(rand.nextSScalar1(), rand.nextSScalar1());
19 } 19 }
20 if (mask & SkMatrix::kScale_Mask) { 20 if (mask & SkMatrix::kScale_Mask) {
21 mat->postScale(rand.nextSScalar1(), rand.nextSScalar1()); 21 mat->postScale(rand.nextSScalar1(), rand.nextSScalar1());
22 } 22 }
23 if (mask & SkMatrix::kAffine_Mask) { 23 if (mask & SkMatrix::kAffine_Mask) {
24 mat->postRotate(rand.nextSScalar1() * 360); 24 mat->postRotate(rand.nextSScalar1() * 360);
25 } 25 }
26 if (mask & SkMatrix::kPerspective_Mask) { 26 if (mask & SkMatrix::kPerspective_Mask) {
27 mat->setPerspX(rand.nextSScalar1()); 27 mat->setPerspX(rand.nextSScalar1());
28 mat->setPerspY(rand.nextSScalar1()); 28 mat->setPerspY(rand.nextSScalar1());
29 } 29 }
30 } 30 }
31 31
32 static void rand_size(SkISize* size, SkMWCRandom& rand) { 32 static void rand_size(SkISize* size, SkRandom& rand) {
33 size->set(rand.nextU() & 0xFFFF, rand.nextU() & 0xFFFF); 33 size->set(rand.nextU() & 0xFFFF, rand.nextU() & 0xFFFF);
34 } 34 }
35 35
36 static bool treat_as_sprite(const SkMatrix& mat, const SkISize& size, 36 static bool treat_as_sprite(const SkMatrix& mat, const SkISize& size,
37 unsigned bits) { 37 unsigned bits) {
38 return SkTreatAsSprite(mat, size.width(), size.height(), bits); 38 return SkTreatAsSprite(mat, size.width(), size.height(), bits);
39 } 39 }
40 40
41 static void test_treatAsSprite(skiatest::Reporter* reporter) { 41 static void test_treatAsSprite(skiatest::Reporter* reporter) {
42 const unsigned bilerBits = kSkSubPixelBitsForBilerp; 42 const unsigned bilerBits = kSkSubPixelBitsForBilerp;
43 43
44 SkMatrix mat; 44 SkMatrix mat;
45 SkISize size; 45 SkISize size;
46 SkMWCRandom rand; 46 SkRandom rand;
47 47
48 // assert: translate-only no-filter can always be treated as sprite 48 // assert: translate-only no-filter can always be treated as sprite
49 for (int i = 0; i < 1000; ++i) { 49 for (int i = 0; i < 1000; ++i) {
50 rand_matrix(&mat, rand, SkMatrix::kTranslate_Mask); 50 rand_matrix(&mat, rand, SkMatrix::kTranslate_Mask);
51 for (int j = 0; j < 1000; ++j) { 51 for (int j = 0; j < 1000; ++j) {
52 rand_size(&size, rand); 52 rand_size(&size, rand);
53 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, 0)); 53 REPORTER_ASSERT(reporter, treat_as_sprite(mat, size, 0));
54 } 54 }
55 } 55 }
56 56
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 REPORTER_ASSERT(reporter, check_for_all_zeros(dst)); 265 REPORTER_ASSERT(reporter, check_for_all_zeros(dst));
266 266
267 test_nan_antihair(); 267 test_nan_antihair();
268 test_giantrepeat_crbug118018(reporter); 268 test_giantrepeat_crbug118018(reporter);
269 269
270 test_treatAsSprite(reporter); 270 test_treatAsSprite(reporter);
271 } 271 }
272 272
273 #include "TestClassDef.h" 273 #include "TestClassDef.h"
274 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect) 274 DEFINE_TESTCLASS("DrawBitmapRect", TestDrawBitmapRectClass, TestDrawBitmapRect)
OLDNEW
« no previous file with comments | « tests/ColorTest.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698