OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } | 534 } |
535 } else if (sk_exists(flag)) { | 535 } else if (sk_exists(flag)) { |
536 // assume that FLAGS_images[i] is a valid image if it is a file. | 536 // assume that FLAGS_images[i] is a valid image if it is a file. |
537 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. | 537 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
538 push_codec_srcs(flag); | 538 push_codec_srcs(flag); |
539 push_brd_srcs(flag); | 539 push_brd_srcs(flag); |
540 } | 540 } |
541 } | 541 } |
542 } | 542 } |
543 | 543 |
| 544 #if SK_SUPPORT_GPU |
544 static GrGLStandard get_gpu_api() { | 545 static GrGLStandard get_gpu_api() { |
545 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 546 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
546 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 547 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
547 return kNone_GrGLStandard; | 548 return kNone_GrGLStandard; |
548 } | 549 } |
| 550 #endif |
549 | 551 |
550 static void push_sink(const char* tag, Sink* s) { | 552 static void push_sink(const char* tag, Sink* s) { |
551 SkAutoTDelete<Sink> sink(s); | 553 SkAutoTDelete<Sink> sink(s); |
552 if (!FLAGS_config.contains(tag)) { | 554 if (!FLAGS_config.contains(tag)) { |
553 return; | 555 return; |
554 } | 556 } |
555 // Try a simple Src as a canary. If it fails, skip this sink. | 557 // Try a simple Src as a canary. If it fails, skip this sink. |
556 struct : public Src { | 558 struct : public Src { |
557 Error draw(SkCanvas* c) const override { | 559 Error draw(SkCanvas* c) const override { |
558 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); | 560 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
(...skipping 17 matching lines...) Expand all Loading... |
576 ts.tag = tag; | 578 ts.tag = tag; |
577 } | 579 } |
578 | 580 |
579 static bool gpu_supported() { | 581 static bool gpu_supported() { |
580 #if SK_SUPPORT_GPU | 582 #if SK_SUPPORT_GPU |
581 return FLAGS_gpu; | 583 return FLAGS_gpu; |
582 #else | 584 #else |
583 return false; | 585 return false; |
584 #endif | 586 #endif |
585 } | 587 } |
586 static Sink* create_gpu_sink(const char* tag, GrContextFactory::GLContextType co
ntextType, int samples, bool diText, bool threaded) { | 588 static Sink* create_gpu_sink(const char* tag, GrContextFactory::GLContextType co
ntextType, |
| 589 GrContextFactory::GLContextOptions contextOptions,
int samples, |
| 590 bool diText, bool threaded) { |
587 #if SK_SUPPORT_GPU | 591 #if SK_SUPPORT_GPU |
588 GrContextFactory testFactory; | 592 GrContextFactory testFactory; |
589 const GrGLStandard api = get_gpu_api(); | 593 const GrGLStandard api = get_gpu_api(); |
590 if (testFactory.get(contextType, api)) { | 594 if (testFactory.get(contextType, api, contextOptions)) { |
591 return new GPUSink(contextType, api, samples, diText, threaded); | 595 return new GPUSink(contextType, contextOptions, api, samples, diText, th
readed); |
592 } | 596 } |
593 SkDebugf("WARNING: can not create GPU context for config '%s'. GM tests will
be skipped.\n", tag); | 597 SkDebugf("WARNING: can not create GPU context for config '%s'. GM tests will
be skipped.\n", tag); |
594 #endif | 598 #endif |
595 return nullptr; | 599 return nullptr; |
596 } | 600 } |
597 static Sink* create_sink(const char* tag) { | 601 static Sink* create_sink(const char* tag) { |
598 #define GPU_SINK(t, ...) if (0 == strcmp(t, tag)) { return create_gpu_sink(tag,
__VA_ARGS__); } | 602 #define GPU_SINK(t, ...) if (0 == strcmp(t, tag)) { return create_gpu_sink(tag,
__VA_ARGS__); } |
599 if (gpu_supported()) { | 603 if (gpu_supported()) { |
600 typedef GrContextFactory Gr; | 604 typedef GrContextFactory Gr; |
601 GPU_SINK("gpunull", Gr::kNull_GLContextType, 0, false, F
LAGS_gpu_threading); | 605 GPU_SINK("gpunull", Gr::kNull_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
602 GPU_SINK("gpudebug", Gr::kDebug_GLContextType, 0, false, F
LAGS_gpu_threading); | 606 GPU_SINK("gpudebug", Gr::kDebug_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
603 GPU_SINK("gpu", Gr::kNative_GLContextType, 0, false, F
LAGS_gpu_threading); | 607 GPU_SINK("gpu", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
604 GPU_SINK("gpudft", Gr::kNative_GLContextType, 0, true, F
LAGS_gpu_threading); | 608 GPU_SINK("gpudft", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 0, true, FLAGS_gpu_threading); |
605 GPU_SINK("msaa4", Gr::kNative_GLContextType, 4, false, F
LAGS_gpu_threading); | 609 GPU_SINK("msaa4", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 4, false, FLAGS_gpu_threading); |
606 GPU_SINK("msaa16", Gr::kNative_GLContextType, 16, false, F
LAGS_gpu_threading); | 610 GPU_SINK("msaa16", Gr::kNative_GLContextType, Gr::kNone_GL
ContextOptions, 16, false, FLAGS_gpu_threading); |
607 GPU_SINK("nvprmsaa4", Gr::kNVPR_GLContextType, 4, true, F
LAGS_gpu_threading); | 611 GPU_SINK("nvprmsaa4", Gr::kNative_GLContextType, Gr::kEnableN
VPR_GLContextOptions, 4, true, FLAGS_gpu_threading); |
608 GPU_SINK("nvprmsaa16", Gr::kNVPR_GLContextType, 16, true, F
LAGS_gpu_threading); | 612 GPU_SINK("nvprmsaa16", Gr::kNative_GLContextType, Gr::kEnableN
VPR_GLContextOptions, 16, true, FLAGS_gpu_threading); |
609 #if SK_ANGLE | 613 #if SK_ANGLE |
610 GPU_SINK("angle", Gr::kANGLE_GLContextType, 0, false, F
LAGS_gpu_threading); | 614 GPU_SINK("angle", Gr::kANGLE_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
611 GPU_SINK("angle-gl", Gr::kANGLE_GL_GLContextType, 0, false, F
LAGS_gpu_threading); | 615 GPU_SINK("angle-gl", Gr::kANGLE_GL_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
612 #endif | 616 #endif |
613 #if SK_COMMAND_BUFFER | 617 #if SK_COMMAND_BUFFER |
614 GPU_SINK("commandbuffer", Gr::kCommandBuffer_GLContextType, 0, false, F
LAGS_gpu_threading); | 618 GPU_SINK("commandbuffer", Gr::kCommandBuffer_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
615 #endif | 619 #endif |
616 #if SK_MESA | 620 #if SK_MESA |
617 GPU_SINK("mesa", Gr::kMESA_GLContextType, 0, false, F
LAGS_gpu_threading); | 621 GPU_SINK("mesa", Gr::kMESA_GLContextType, Gr::kNone_GL
ContextOptions, 0, false, FLAGS_gpu_threading); |
618 #endif | 622 #endif |
619 } | 623 } |
620 #undef GPU_SINK | 624 #undef GPU_SINK |
621 | 625 |
622 #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS_
_); } | 626 #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS_
_); } |
623 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 627 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
624 SINK("hwui", HWUISink); | 628 SINK("hwui", HWUISink); |
625 #endif | 629 #endif |
626 | 630 |
627 if (FLAGS_cpu) { | 631 if (FLAGS_cpu) { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 test(reporter, context->fGrContext, context->fGLContext); | 1172 test(reporter, context->fGrContext, context->fGLContext); |
1169 } | 1173 } |
1170 #endif | 1174 #endif |
1171 } // namespace | 1175 } // namespace |
1172 | 1176 |
1173 | 1177 |
1174 template<typename T> | 1178 template<typename T> |
1175 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
rter, | 1179 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
rter, |
1176 GrContextFactory* factory) { | 1180 GrContextFactory* factory) { |
1177 #if SK_SUPPORT_GPU | 1181 #if SK_SUPPORT_GPU |
| 1182 const GrGLStandard api = get_gpu_api(); |
1178 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 1183 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
1179 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 1184 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; |
1180 int contextSelector = kNone_GPUTestContexts; | 1185 int contextSelector = kNone_GPUTestContexts; |
1181 if (GrContextFactory::IsRenderingGLContext(glCtxType)) { | 1186 if (GrContextFactory::IsRenderingGLContext(glCtxType)) { |
1182 contextSelector |= kAllRendering_GPUTestContexts; | 1187 contextSelector |= kAllRendering_GPUTestContexts; |
1183 } | 1188 } |
1184 if (glCtxType == GrContextFactory::kNative_GLContextType) { | 1189 if (glCtxType == GrContextFactory::kNative_GLContextType) { |
1185 contextSelector |= kNative_GPUTestContexts; | 1190 contextSelector |= kNative_GPUTestContexts; |
1186 } | 1191 } |
1187 if (glCtxType == GrContextFactory::kNull_GLContextType) { | 1192 if (glCtxType == GrContextFactory::kNull_GLContextType) { |
1188 contextSelector |= kNull_GPUTestContexts; | 1193 contextSelector |= kNull_GPUTestContexts; |
1189 } | 1194 } |
1190 if ((testContexts & contextSelector) == 0) { | 1195 if ((testContexts & contextSelector) == 0) { |
1191 continue; | 1196 continue; |
1192 } | 1197 } |
1193 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glC
txType)) { | 1198 if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glC
txType, api)) { |
| 1199 call_test(test, reporter, context); |
| 1200 } |
| 1201 if (GrContextFactory::ContextInfo* context = |
| 1202 factory->getContextInfo(glCtxType, api, |
| 1203 GrContextFactory::kEnableNVPR_GLContextOptio
ns)) { |
1194 call_test(test, reporter, context); | 1204 call_test(test, reporter, context); |
1195 } | 1205 } |
1196 } | 1206 } |
1197 #endif | 1207 #endif |
1198 } | 1208 } |
1199 | 1209 |
1200 template | 1210 template |
1201 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, | 1211 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, |
1202 GPUTestContexts testContexts, | 1212 GPUTestContexts testContexts, |
1203 Reporter* reporter, | 1213 Reporter* reporter, |
1204 GrContextFactory* factory); | 1214 GrContextFactory* factory); |
1205 template | 1215 template |
1206 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG
LContext test, | 1216 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG
LContext test, |
1207 GPUTestContexts testC
ontexts, | 1217 GPUTestContexts testC
ontexts, |
1208 Reporter* reporter, | 1218 Reporter* reporter, |
1209 GrContextFactory* fac
tory); | 1219 GrContextFactory* fac
tory); |
1210 } // namespace skiatest | 1220 } // namespace skiatest |
1211 | 1221 |
1212 #if !defined(SK_BUILD_FOR_IOS) | 1222 #if !defined(SK_BUILD_FOR_IOS) |
1213 int main(int argc, char** argv) { | 1223 int main(int argc, char** argv) { |
1214 SkCommandLineFlags::Parse(argc, argv); | 1224 SkCommandLineFlags::Parse(argc, argv); |
1215 return dm_main(); | 1225 return dm_main(); |
1216 } | 1226 } |
1217 #endif | 1227 #endif |
OLD | NEW |