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