OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrTestUtils.h" | 8 #include "GrTestUtils.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 | 10 |
11 #ifdef GR_TEST_UTILS | |
12 | |
11 namespace GrTest { | 13 namespace GrTest { |
12 const SkMatrix& TestMatrix(SkRandom* random) { | 14 const SkMatrix& TestMatrix(SkRandom* random) { |
13 static SkMatrix gMatrices[5]; | 15 static SkMatrix gMatrices[5]; |
14 static bool gOnce; | 16 static bool gOnce; |
15 if (!gOnce) { | 17 if (!gOnce) { |
16 gMatrices[0].reset(); | 18 gMatrices[0].reset(); |
17 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); | 19 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); |
18 gMatrices[2].setRotate(SkIntToScalar(17)); | 20 gMatrices[2].setRotate(SkIntToScalar(17)); |
19 gMatrices[3].setRotate(SkIntToScalar(185)); | 21 gMatrices[3].setRotate(SkIntToScalar(185)); |
20 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); | 22 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); |
21 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); | 23 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); |
22 gMatrices[4].setRotate(SkIntToScalar(215)); | 24 gMatrices[4].setRotate(SkIntToScalar(215)); |
23 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); | 25 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); |
24 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); | 26 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); |
25 gOnce = true; | 27 gOnce = true; |
26 } | 28 } |
27 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))]; | 29 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))]; |
28 } | 30 } |
31 | |
32 const SkRect& TestRect(SkRandom* random) { | |
33 static SkRect gRects[1]; | |
brucedawson
2015/04/30 20:19:35
Why is this array declared as having just one elem
| |
34 static bool gOnce; | |
35 if (!gOnce) { | |
36 gRects[0] = SkRect::MakeWH(1.f, 1.f); | |
37 gRects[1] = SkRect::MakeWH(1.0f, 256.0f); | |
38 gRects[2] = SkRect::MakeWH(256.0f, 1.0f); | |
39 gRects[4] = SkRect::MakeLargest(); | |
40 gRects[5] = SkRect::MakeLTRB(-65535.0f, -65535.0f, 65535.0f, 65535.0f); | |
41 gRects[6] = SkRect::MakeLTRB(10.0f, 10.0f, -10.0f, -10.0f); | |
42 gOnce = true; | |
43 } | |
44 return gRects[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRe cts)))]; | |
45 } | |
29 }; | 46 }; |
47 | |
48 #endif | |
OLD | NEW |