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

Side by Side Diff: src/gpu/GrTestUtils.cpp

Issue 2108403005: Move GrNonAAFillRectPerspectiveBatch to its own file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix overlength line Created 4 years, 5 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
« no previous file with comments | « include/gpu/GrTestUtils.h ('k') | src/gpu/batches/GrNonAAFillRectBatch.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 * 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 "GrStyle.h" 9 #include "GrStyle.h"
10 #include "SkDashPathPriv.h" 10 #include "SkDashPathPriv.h"
11 #include "SkMatrix.h" 11 #include "SkMatrix.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkRRect.h" 13 #include "SkRRect.h"
14 14
15 #ifdef GR_TEST_UTILS 15 #ifdef GR_TEST_UTILS
16 16
17 static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) { 17 static const SkMatrix& test_matrix(SkRandom* random,
18 bool includeNonPerspective,
19 bool includePerspective) {
18 static SkMatrix gMatrices[5]; 20 static SkMatrix gMatrices[5];
19 static const int kPerspectiveCount = 1; 21 static const int kPerspectiveCount = 1;
20 static bool gOnce; 22 static bool gOnce;
21 if (!gOnce) { 23 if (!gOnce) {
22 gOnce = true; 24 gOnce = true;
23 gMatrices[0].reset(); 25 gMatrices[0].reset();
24 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); 26 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100));
25 gMatrices[2].setRotate(SkIntToScalar(17)); 27 gMatrices[2].setRotate(SkIntToScalar(17));
26 gMatrices[3].setRotate(SkIntToScalar(185)); 28 gMatrices[3].setRotate(SkIntToScalar(185));
27 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); 29 gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33));
28 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); 30 gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf);
29 31
30 // Perspective matrices 32 // Perspective matrices
31 gMatrices[4].setRotate(SkIntToScalar(215)); 33 gMatrices[4].setRotate(SkIntToScalar(215));
32 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); 34 gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f);
33 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); 35 gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f);
34 } 36 }
35 37
36 uint32_t count = static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)); 38 uint32_t count = static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices));
37 if (includePerspective) { 39 if (includeNonPerspective && includePerspective) {
38 return gMatrices[random->nextULessThan(count)]; 40 return gMatrices[random->nextULessThan(count)];
41 } else if (!includeNonPerspective) {
42 return gMatrices[count - 1 - random->nextULessThan(kPerspectiveCount)];
39 } else { 43 } else {
44 SkASSERT(includeNonPerspective && !includePerspective);
40 return gMatrices[random->nextULessThan(count - kPerspectiveCount)]; 45 return gMatrices[random->nextULessThan(count - kPerspectiveCount)];
41 } 46 }
42 } 47 }
43 48
44 namespace GrTest { 49 namespace GrTest {
45 const SkMatrix& TestMatrix(SkRandom* random) { return test_matrix(random, true); } 50 const SkMatrix& TestMatrix(SkRandom* random) { return test_matrix(random, true, true); }
46 51
47 const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) { 52 const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) {
48 static SkMatrix gMatrices[5]; 53 static SkMatrix gMatrices[5];
49 static bool gOnce; 54 static bool gOnce;
50 if (!gOnce) { 55 if (!gOnce) {
51 gOnce = true; 56 gOnce = true;
52 // identity 57 // identity
53 gMatrices[0].reset(); 58 gMatrices[0].reset();
54 // translation 59 // translation
55 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); 60 gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // 90 degress rotation 94 // 90 degress rotation
90 gMatrices[5].setRotate(90); 95 gMatrices[5].setRotate(90);
91 96
92 for (size_t i = 0; i < SK_ARRAY_COUNT(gMatrices); i++) { 97 for (size_t i = 0; i < SK_ARRAY_COUNT(gMatrices); i++) {
93 SkASSERT(gMatrices[i].rectStaysRect()); 98 SkASSERT(gMatrices[i].rectStaysRect());
94 } 99 }
95 } 100 }
96 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))]; 101 return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT( gMatrices)))];
97 } 102 }
98 103
99 const SkMatrix& TestMatrixInvertible(SkRandom* random) { return test_matrix(rand om, false); } 104 const SkMatrix& TestMatrixInvertible(SkRandom* random) { return test_matrix(rand om, true, false); }
105 const SkMatrix& TestMatrixPerspective(SkRandom* random) { return test_matrix(ran dom, false, true); }
100 106
101 const SkRect& TestRect(SkRandom* random) { 107 const SkRect& TestRect(SkRandom* random) {
102 static SkRect gRects[7]; 108 static SkRect gRects[7];
103 static bool gOnce; 109 static bool gOnce;
104 if (!gOnce) { 110 if (!gOnce) {
105 gOnce = true; 111 gOnce = true;
106 gRects[0] = SkRect::MakeWH(1.f, 1.f); 112 gRects[0] = SkRect::MakeWH(1.f, 1.f);
107 gRects[1] = SkRect::MakeWH(1.0f, 256.0f); 113 gRects[1] = SkRect::MakeWH(1.0f, 256.0f);
108 gRects[2] = SkRect::MakeWH(256.0f, 1.0f); 114 gRects[2] = SkRect::MakeWH(256.0f, 1.0f);
109 gRects[3] = SkRect::MakeLargest(); 115 gRects[3] = SkRect::MakeLargest();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 info->fCount = fCount; 286 info->fCount = fCount;
281 info->fPhase = fPhase; 287 info->fPhase = fPhase;
282 } 288 }
283 return kDash_DashType; 289 return kDash_DashType;
284 } 290 }
285 291
286 292
287 } // namespace GrTest 293 } // namespace GrTest
288 294
289 #endif 295 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrTestUtils.h ('k') | src/gpu/batches/GrNonAAFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698