Index: tests/Test.cpp |
diff --git a/tests/Test.cpp b/tests/Test.cpp |
index daa23b132cccbebd67e4ab1a7cde4983669a49d6..3bad156599faaeb03e61a8cbbe4447a01ed639f8 100644 |
--- a/tests/Test.cpp |
+++ b/tests/Test.cpp |
@@ -7,9 +7,11 @@ |
*/ |
#include "Test.h" |
+#include "SkCommandLineFlags.h" |
#include "SkError.h" |
#include "SkString.h" |
#include "SkTArray.h" |
+#include "SkTLS.h" |
#include "SkTime.h" |
#if SK_SUPPORT_GPU |
@@ -19,6 +21,9 @@ |
class GrContext; |
#endif |
+DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); |
+DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); |
bsalomon
2014/02/24 20:23:14
Does this mean the same flag is used for test and
mtklein
2014/02/24 20:36:12
Sort of. Right now one is --resources and the oth
|
+ |
using namespace skiatest; |
Reporter::Reporter() : fTestCount(0) { |
@@ -114,23 +119,33 @@ void Test::run() { |
} |
+SkString Test::GetTmpDir() { |
+ const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; |
+ return SkString(tmpDir); |
+} |
+ |
+SkString Test::GetResourcePath() { |
+ const char* resourcePath = FLAGS_resourcePath.isEmpty() ? NULL : FLAGS_resourcePath[0]; |
+ return SkString(resourcePath); |
+} |
+ |
+ |
/////////////////////////////////////////////////////////////////////////////// |
#if SK_SUPPORT_GPU |
-#include "GrContextFactory.h" |
-GrContextFactory gGrContextFactory; |
-#endif |
+# include "GrContextFactory.h" |
-GrContextFactory* GpuTest::GetGrContextFactory() { |
-#if SK_SUPPORT_GPU |
- return &gGrContextFactory; |
-#else |
- return NULL; |
-#endif |
+static void* new_gr_context_factory() { |
+ return SkNEW(GrContextFactory); |
} |
-void GpuTest::DestroyContexts() { |
-#if SK_SUPPORT_GPU |
- gGrContextFactory.destroyContexts(); |
-#endif |
+static void delete_gr_context_factory(void* factory) { |
+ SkDELETE((GrContextFactory*) factory); |
+} |
+GrContextFactory* GpuTest::GetGrContextFactory() { |
+ return reinterpret_cast<GrContextFactory*>(SkTLS::Get(&new_gr_context_factory, |
+ &delete_gr_context_factory)); |
} |
+#else // SK_GPU_SUPPORT |
+GrContextFactory* GpuTest::GetGrContextFactory() { return NULL; } |
+#endif |