aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTestUtils.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-04-28 13:31:18 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-28 13:31:18 -0700
commit4eaf9cef5a76098f78efac30beb966ac833d32c2 (patch)
tree6e00047af770562183852a2cce07e18c0c978cf4 /src/gpu/GrTestUtils.cpp
parent5190a481f9e74f024352743a8499b0ad858a1310 (diff)
create GrTestUtils.h, move some common functions into it
Diffstat (limited to 'src/gpu/GrTestUtils.cpp')
-rw-r--r--src/gpu/GrTestUtils.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
new file mode 100644
index 0000000000..c132663d20
--- /dev/null
+++ b/src/gpu/GrTestUtils.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrTestUtils.h"
+#include "SkMatrix.h"
+
+namespace GrTest {
+const SkMatrix& TestMatrix(SkRandom* random) {
+ static SkMatrix gMatrices[5];
+ static bool gOnce;
+ if (!gOnce) {
+ gMatrices[0].reset();
+ gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100));
+ gMatrices[2].setRotate(SkIntToScalar(17));
+ gMatrices[3].setRotate(SkIntToScalar(185));
+ gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33));
+ gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf);
+ gMatrices[4].setRotate(SkIntToScalar(215));
+ gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f);
+ gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f);
+ gOnce = true;
+ }
+ return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))];
+}
+};