aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-10-09 16:13:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-10 12:34:22 +0000
commitb6c5e5b956af9777349a6ab362ce86e430e59765 (patch)
tree13808cf986c576535f3d7c80ad12ef08089e3b32
parent532a0916265e272c330f48f877052b0df6dcc16d (diff)
DM: move skiatest functions into separate file.
Motivation: allows reuse. Change-Id: I5732305a213acd83de4ba4e84e0ae27d094cf649 Reviewed-on: https://skia-review.googlesource.com/57241 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
-rw-r--r--BUILD.gn1
-rw-r--r--dm/DM.cpp65
-rw-r--r--dm/DMGpuTestProcs.cpp78
3 files changed, 79 insertions, 65 deletions
diff --git a/BUILD.gn b/BUILD.gn
index b5ae1de1c8..a65a211ab3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1332,6 +1332,7 @@ if (skia_enable_tools) {
test_app("dm") {
sources = [
"dm/DM.cpp",
+ "dm/DMGpuTestProcs.cpp",
"dm/DMJsonWriter.cpp",
"dm/DMSrcSink.cpp",
]
diff --git a/dm/DM.cpp b/dm/DM.cpp
index ea8ec2742e..6b76a92a1e 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1438,68 +1438,3 @@ int main(int argc, char** argv) {
return 0;
}
-
-// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
-// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
-namespace skiatest {
-
-#if SK_SUPPORT_GPU
-bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
- return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type);
-}
-bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) {
- return kVulkan_GrBackend == GrContextFactory::ContextTypeBackend(type);
-}
-bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
- return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type);
-}
-bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
- return type == GrContextFactory::kNullGL_ContextType;
-}
-#else
-bool IsGLContextType(int) { return false; }
-bool IsVulkanContextType(int) { return false; }
-bool IsRenderingGLContextType(int) { return false; }
-bool IsNullGLContextType(int) { return false; }
-#endif
-
-void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contextTypeFilter,
- Reporter* reporter, GrContextFactory* factory) {
-#if SK_SUPPORT_GPU
-
-#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
- static constexpr auto kNativeGLType = GrContextFactory::kGL_ContextType;
-#else
- static constexpr auto kNativeGLType = GrContextFactory::kGLES_ContextType;
-#endif
-
- for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
- GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
- // Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
- // desktop since tests do not account for not fixing http://skbug.com/2809
- if (contextType == GrContextFactory::kGL_ContextType ||
- contextType == GrContextFactory::kGLES_ContextType) {
- if (contextType != kNativeGLType) {
- continue;
- }
- }
- ContextInfo ctxInfo = factory->getContextInfo(contextType,
- GrContextFactory::ContextOverrides::kDisableNVPR);
- if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
- continue;
- }
- ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
- if (ctxInfo.grContext()) {
- (*test)(reporter, ctxInfo);
- ctxInfo.grContext()->flush();
- }
- ctxInfo = factory->getContextInfo(contextType,
- GrContextFactory::ContextOverrides::kRequireNVPRSupport);
- if (ctxInfo.grContext()) {
- (*test)(reporter, ctxInfo);
- ctxInfo.grContext()->flush();
- }
- }
-#endif
-}
-} // namespace skiatest
diff --git a/dm/DMGpuTestProcs.cpp b/dm/DMGpuTestProcs.cpp
new file mode 100644
index 0000000000..c3ec588b81
--- /dev/null
+++ b/dm/DMGpuTestProcs.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+
+using sk_gpu_test::GrContextFactory;
+using sk_gpu_test::GLTestContext;
+using sk_gpu_test::ContextInfo;
+
+// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
+// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
+namespace skiatest {
+
+#if SK_SUPPORT_GPU
+bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
+ return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type);
+}
+bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) {
+ return kVulkan_GrBackend == GrContextFactory::ContextTypeBackend(type);
+}
+bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
+ return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type);
+}
+bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
+ return type == GrContextFactory::kNullGL_ContextType;
+}
+#else
+bool IsGLContextType(int) { return false; }
+bool IsVulkanContextType(int) { return false; }
+bool IsRenderingGLContextType(int) { return false; }
+bool IsNullGLContextType(int) { return false; }
+#endif
+
+void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contextTypeFilter,
+ Reporter* reporter, GrContextFactory* factory) {
+#if SK_SUPPORT_GPU
+
+#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
+ static constexpr auto kNativeGLType = GrContextFactory::kGL_ContextType;
+#else
+ static constexpr auto kNativeGLType = GrContextFactory::kGLES_ContextType;
+#endif
+
+ for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
+ GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
+ // Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
+ // desktop since tests do not account for not fixing http://skbug.com/2809
+ if (contextType == GrContextFactory::kGL_ContextType ||
+ contextType == GrContextFactory::kGLES_ContextType) {
+ if (contextType != kNativeGLType) {
+ continue;
+ }
+ }
+ ContextInfo ctxInfo = factory->getContextInfo(contextType,
+ GrContextFactory::ContextOverrides::kDisableNVPR);
+ if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
+ continue;
+ }
+
+ ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
+ if (ctxInfo.grContext()) {
+ (*test)(reporter, ctxInfo);
+ ctxInfo.grContext()->flush();
+ }
+ ctxInfo = factory->getContextInfo(contextType,
+ GrContextFactory::ContextOverrides::kRequireNVPRSupport);
+ if (ctxInfo.grContext()) {
+ (*test)(reporter, ctxInfo);
+ ctxInfo.grContext()->flush();
+ }
+ }
+#endif
+}
+} // namespace skiatest