Revert of Add config options to run different GPU APIs to dm and nanobench (patchset #21 id:400001 of https://codereview.chromium.org/1490113005/ )
Reason for revert: The Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug builder fails after this CL. Links to specific builds: http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1689 http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1690 http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1691 Original issue's description: > Add config options to run different GPU APIs to dm and nanobench > > Add extended config specification form that can be used to run different > gpu backend with different APIs. > > The configs can be specified with the form: > gpu(api=string,dit=bool,nvpr=bool,samples=int) > > This replaces and removes the --gpuAPI flag. > > All existing configs should still work. > > Adds following documentation: > > out/Debug/dm --help config > > Flags: > --config: type: string default: 565 8888 gpu nonrendering > Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4 > nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg > xps or use extended form 'backend(option=value,...)'. > > Extended form: 'backend(option=value,...)' > > Possible backends and options: > > gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend > api type: string default: native. > Select graphics API to use with gpu backend. > Options: > native Use platform default OpenGL or OpenGL ES backend. > gl Use OpenGL. > gles Use OpenGL ES. > debug Use debug OpenGL. > null Use null OpenGL. > dit type: bool default: false. > Use device independent text. > nvpr type: bool default: false. > Use NV_path_rendering OpenGL and OpenGL ES extension. > samples type: int default: 0. > Use multisampling with N samples. > > Predefined configs: > > gpu = gpu() > msaa4 = gpu(samples=4) > msaa16 = gpu(samples=16) > nvprmsaa4 = gpu(nvpr=true,samples=4) > nvprmsaa16 = gpu(nvpr=true,samples=16) > gpudft = gpu(dit=true) > gpudebug = gpu(api=debug) > gpunull = gpu(api=null) > debug = gpu(api=debug) > nullgpu = gpu(api=null) > > BUG=skia:2992 > > Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23 > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005 > > Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b > > Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd TBR=mtklein@google.com,bsalomon@google.com,joshualitt@google.com,scroggo@google.com,kkinnunen@nvidia.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:2992 Review URL: https://codereview.chromium.org/1548683002
This commit is contained in:
parent
c53b82ec0e
commit
0f515bd428
@ -28,7 +28,6 @@
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCodec.h"
|
||||
#include "SkCommonFlags.h"
|
||||
#include "SkCommonFlagsConfig.h"
|
||||
#include "SkData.h"
|
||||
#include "SkForceLinking.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -169,10 +168,11 @@ struct GPUTarget : public Target {
|
||||
0;
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->config.ctxType,
|
||||
kNone_GrGLStandard,
|
||||
this->config.ctxOptions),
|
||||
SkSurface::kNo_Budgeted, info,
|
||||
this->config.samples, &props));
|
||||
this->gl = gGrFactory->getContextInfo(this->config.ctxType,
|
||||
this->gl = gGrFactory->getContextInfo(this->config.ctxType, kNone_GrGLStandard,
|
||||
this->config.ctxOptions)->fGLContext;
|
||||
if (!this->surface.get()) {
|
||||
return false;
|
||||
@ -390,7 +390,7 @@ static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT
|
||||
if (!is_cpu_config_allowed(name)) {
|
||||
return false;
|
||||
}
|
||||
if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) {
|
||||
if (const GrContext* ctx = gGrFactory->get(ctxType, kNone_GrGLStandard, ctxOptions)) {
|
||||
return sampleCnt <= ctx->caps()->maxSampleCount();
|
||||
}
|
||||
return false;
|
||||
@ -446,13 +446,11 @@ static void create_configs(SkTDArray<Config>* configs) {
|
||||
GPU_CONFIG(gpudft, kNative_GLContextType, kNone_GLContextOptions, 0, true)
|
||||
GPU_CONFIG(debug, kDebug_GLContextType, kNone_GLContextOptions, 0, false)
|
||||
GPU_CONFIG(nullgpu, kNull_GLContextType, kNone_GLContextOptions, 0, false)
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#ifdef SK_ANGLE
|
||||
GPU_CONFIG(angle, kANGLE_GLContextType, kNone_GLContextOptions, 0, false)
|
||||
#endif
|
||||
GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, kNone_GLContextOptions, 0, false)
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
#ifdef SK_COMMAND_BUFFER
|
||||
GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, kNone_GLContextOptions, 0, false)
|
||||
#endif
|
||||
#if SK_MESA
|
||||
@ -1168,7 +1166,7 @@ int nanobench_main() {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
|
||||
GrContext* context = gGrFactory->get(configs[i].ctxType,
|
||||
configs[i].ctxOptions);
|
||||
kNone_GrGLStandard, configs[i].ctxOptions);
|
||||
context->printCacheStats();
|
||||
context->printGpuStats();
|
||||
}
|
||||
|
167
dm/DM.cpp
167
dm/DM.cpp
@ -15,7 +15,6 @@
|
||||
#include "SkChecksum.h"
|
||||
#include "SkCodec.h"
|
||||
#include "SkCommonFlags.h"
|
||||
#include "SkCommonFlagsConfig.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkForceLinking.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -200,7 +199,7 @@ struct TaggedSrc : public SkAutoTDelete<Src> {
|
||||
};
|
||||
|
||||
struct TaggedSink : public SkAutoTDelete<Sink> {
|
||||
SkString tag;
|
||||
const char* tag;
|
||||
};
|
||||
|
||||
static const bool kMemcpyOK = true;
|
||||
@ -542,9 +541,19 @@ static void gather_srcs() {
|
||||
}
|
||||
}
|
||||
|
||||
static void push_sink(const SkCommandLineConfig& config, Sink* s) {
|
||||
SkAutoTDelete<Sink> sink(s);
|
||||
#if SK_SUPPORT_GPU
|
||||
static GrGLStandard get_gpu_api() {
|
||||
if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
|
||||
if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
|
||||
return kNone_GrGLStandard;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void push_sink(const char* tag, Sink* s) {
|
||||
SkAutoTDelete<Sink> sink(s);
|
||||
if (!FLAGS_config.contains(tag)) {
|
||||
return;
|
||||
}
|
||||
// Try a simple Src as a canary. If it fails, skip this sink.
|
||||
struct : public Src {
|
||||
Error draw(SkCanvas* c) const override {
|
||||
@ -560,13 +569,13 @@ static void push_sink(const SkCommandLineConfig& config, Sink* s) {
|
||||
SkString log;
|
||||
Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
|
||||
if (err.isFatal()) {
|
||||
SkDebugf("Could not run %s: %s\n", config.getTag().c_str(), err.c_str());
|
||||
SkDebugf("Could not run %s: %s\n", tag, err.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
TaggedSink& ts = gSinks.push_back();
|
||||
ts.reset(sink.detach());
|
||||
ts.tag = config.getTag();
|
||||
ts.tag = tag;
|
||||
}
|
||||
|
||||
static bool gpu_supported() {
|
||||
@ -576,32 +585,45 @@ static bool gpu_supported() {
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Sink* create_sink(const SkCommandLineConfig* config) {
|
||||
static Sink* create_gpu_sink(const char* tag, GrContextFactory::GLContextType contextType,
|
||||
GrContextFactory::GLContextOptions contextOptions, int samples,
|
||||
bool diText, bool threaded) {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (gpu_supported()) {
|
||||
if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
|
||||
GrContextFactory::GLContextType contextType = gpuConfig->getContextType();
|
||||
GrContextFactory::GLContextOptions contextOptions =
|
||||
GrContextFactory::kNone_GLContextOptions;
|
||||
if (gpuConfig->getUseNVPR()) {
|
||||
contextOptions = static_cast<GrContextFactory::GLContextOptions>(
|
||||
contextOptions | GrContextFactory::kEnableNVPR_GLContextOptions);
|
||||
}
|
||||
GrContextFactory testFactory;
|
||||
if (!testFactory.get(contextType, contextOptions)) {
|
||||
SkDebugf("WARNING: can not create GPU context for config '%s'. "
|
||||
"GM tests will be skipped.\n", gpuConfig->getTag().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return new GPUSink(contextType, contextOptions, gpuConfig->getSamples(),
|
||||
gpuConfig->getUseDIText(), FLAGS_gpu_threading);
|
||||
}
|
||||
GrContextFactory testFactory;
|
||||
const GrGLStandard api = get_gpu_api();
|
||||
if (testFactory.get(contextType, api, contextOptions)) {
|
||||
return new GPUSink(contextType, contextOptions, api, samples, diText, threaded);
|
||||
}
|
||||
SkDebugf("WARNING: can not create GPU context for config '%s'. GM tests will be skipped.\n", tag);
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
static Sink* create_sink(const char* tag) {
|
||||
#define GPU_SINK(t, ...) if (0 == strcmp(t, tag)) { return create_gpu_sink(tag, __VA_ARGS__); }
|
||||
if (gpu_supported()) {
|
||||
typedef GrContextFactory Gr;
|
||||
GPU_SINK("gpunull", Gr::kNull_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("gpudebug", Gr::kDebug_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("gpu", Gr::kNative_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("gpudft", Gr::kNative_GLContextType, Gr::kNone_GLContextOptions, 0, true, FLAGS_gpu_threading);
|
||||
GPU_SINK("msaa4", Gr::kNative_GLContextType, Gr::kNone_GLContextOptions, 4, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("msaa16", Gr::kNative_GLContextType, Gr::kNone_GLContextOptions, 16, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("nvprmsaa4", Gr::kNative_GLContextType, Gr::kEnableNVPR_GLContextOptions, 4, true, FLAGS_gpu_threading);
|
||||
GPU_SINK("nvprmsaa16", Gr::kNative_GLContextType, Gr::kEnableNVPR_GLContextOptions, 16, true, FLAGS_gpu_threading);
|
||||
#if SK_ANGLE
|
||||
GPU_SINK("angle", Gr::kANGLE_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
GPU_SINK("angle-gl", Gr::kANGLE_GL_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
GPU_SINK("commandbuffer", Gr::kCommandBuffer_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
#endif
|
||||
#if SK_MESA
|
||||
GPU_SINK("mesa", Gr::kMESA_GLContextType, Gr::kNone_GLContextOptions, 0, false, FLAGS_gpu_threading);
|
||||
#endif
|
||||
}
|
||||
#undef GPU_SINK
|
||||
|
||||
#define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink(__VA_ARGS__); }
|
||||
|
||||
#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
SINK("hwui", HWUISink);
|
||||
#endif
|
||||
@ -620,8 +642,8 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static Sink* create_via(const SkString& tag, Sink* wrapped) {
|
||||
#define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); }
|
||||
static Sink* create_via(const char* tag, Sink* wrapped) {
|
||||
#define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); }
|
||||
VIA("twice", ViaTwice, wrapped);
|
||||
VIA("pipe", ViaPipe, wrapped);
|
||||
VIA("serialize", ViaSerialization, wrapped);
|
||||
@ -652,24 +674,17 @@ static Sink* create_via(const SkString& tag, Sink* wrapped) {
|
||||
}
|
||||
|
||||
static void gather_sinks() {
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(FLAGS_config, &configs);
|
||||
for (int i = 0; i < configs.count(); i++) {
|
||||
const SkCommandLineConfig& config = *configs[i];
|
||||
Sink* sink = create_sink(&config);
|
||||
if (sink == nullptr) {
|
||||
SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
|
||||
config.getTag().c_str());
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < FLAGS_config.count(); i++) {
|
||||
const char* config = FLAGS_config[i];
|
||||
SkTArray<SkString> parts;
|
||||
SkStrSplit(config, "-", &parts);
|
||||
|
||||
const SkTArray<SkString>& parts = config.getViaParts();
|
||||
for (int j = parts.count(); j-- > 0;) {
|
||||
const SkString& part = parts[j];
|
||||
Sink* next = create_via(part, sink);
|
||||
Sink* sink = nullptr;
|
||||
for (int i = parts.count(); i-- > 0;) {
|
||||
const char* part = parts[i].c_str();
|
||||
Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part, sink);
|
||||
if (next == nullptr) {
|
||||
SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
|
||||
part.c_str());
|
||||
SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part);
|
||||
delete sink;
|
||||
sink = nullptr;
|
||||
break;
|
||||
@ -791,7 +806,7 @@ struct Task {
|
||||
// - this Src / Sink combination is on the blacklist;
|
||||
// - it's a dry run.
|
||||
SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : "");
|
||||
SkString whyBlacklisted = is_blacklisted(task->sink.tag.c_str(), task->src.tag.c_str(),
|
||||
SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag.c_str(),
|
||||
task->src.options.c_str(), name.c_str());
|
||||
if (!whyBlacklisted.isEmpty()) {
|
||||
note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
|
||||
@ -803,15 +818,15 @@ struct Task {
|
||||
SkBitmap bitmap;
|
||||
SkDynamicMemoryWStream stream;
|
||||
if (FLAGS_pre_log) {
|
||||
SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag.c_str());
|
||||
SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag);
|
||||
}
|
||||
start(task->sink.tag.c_str(), task->src.tag, task->src.options, name.c_str());
|
||||
start(task->sink.tag, task->src.tag, task->src.options, name.c_str());
|
||||
Error err = task->sink->draw(*task->src, &bitmap, &stream, &log);
|
||||
if (!err.isEmpty()) {
|
||||
auto elapsed = now_ms() - timerStart;
|
||||
if (err.isFatal()) {
|
||||
fail(SkStringPrintf("%s %s %s %s: %s",
|
||||
task->sink.tag.c_str(),
|
||||
task->sink.tag,
|
||||
task->src.tag.c_str(),
|
||||
task->src.options.c_str(),
|
||||
name.c_str(),
|
||||
@ -819,7 +834,7 @@ struct Task {
|
||||
} else {
|
||||
note.appendf(" (skipped: %s)", err.c_str());
|
||||
}
|
||||
done(elapsed, task->sink.tag.c_str(), task->src.tag, task->src.options,
|
||||
done(elapsed, task->sink.tag, task->src.tag, task->src.options,
|
||||
name, note, log);
|
||||
return;
|
||||
}
|
||||
@ -852,11 +867,11 @@ struct Task {
|
||||
}
|
||||
|
||||
if (!FLAGS_readPath.isEmpty() &&
|
||||
!gGold.contains(Gold(task->sink.tag.c_str(), task->src.tag.c_str(),
|
||||
!gGold.contains(Gold(task->sink.tag, task->src.tag.c_str(),
|
||||
task->src.options.c_str(), name, md5))) {
|
||||
fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
|
||||
md5.c_str(),
|
||||
task->sink.tag.c_str(),
|
||||
task->sink.tag,
|
||||
task->src.tag.c_str(),
|
||||
task->src.options.c_str(),
|
||||
name.c_str(),
|
||||
@ -873,7 +888,7 @@ struct Task {
|
||||
}
|
||||
}
|
||||
}
|
||||
done(now_ms()-timerStart, task->sink.tag.c_str(), task->src.tag.c_str(), task->src.options.c_str(),
|
||||
done(now_ms()-timerStart, task->sink.tag, task->src.tag.c_str(), task->src.options.c_str(),
|
||||
name, note, log);
|
||||
}
|
||||
|
||||
@ -884,7 +899,7 @@ struct Task {
|
||||
const SkBitmap* bitmap) {
|
||||
JsonWriter::BitmapResult result;
|
||||
result.name = task.src->name();
|
||||
result.config = task.sink.tag.c_str();
|
||||
result.config = task.sink.tag;
|
||||
result.sourceType = task.src.tag;
|
||||
result.sourceOptions = task.src.options;
|
||||
result.ext = ext;
|
||||
@ -912,7 +927,7 @@ struct Task {
|
||||
return; // Content-addressed. If it exists already, we're done.
|
||||
}
|
||||
} else {
|
||||
path = SkOSPath::Join(dir, task.sink.tag.c_str());
|
||||
path = SkOSPath::Join(dir, task.sink.tag);
|
||||
sk_mkdir(path.c_str());
|
||||
path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
|
||||
sk_mkdir(path.c_str());
|
||||
@ -1164,48 +1179,28 @@ template<typename T>
|
||||
void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* reporter,
|
||||
GrContextFactory* factory) {
|
||||
#if SK_SUPPORT_GPU
|
||||
// Iterate over context types, except 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
|
||||
GrContextFactory::GLContextType contextTypes[] = {
|
||||
GrContextFactory::kNative_GLContextType,
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
GrContextFactory::kANGLE_GLContextType,
|
||||
#endif
|
||||
GrContextFactory::kANGLE_GL_GLContextType,
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
GrContextFactory::kCommandBuffer_GLContextType,
|
||||
#endif
|
||||
#if SK_MESA
|
||||
GrContextFactory::kMESA_GLContextType,
|
||||
#endif
|
||||
GrContextFactory::kNull_GLContextType,
|
||||
GrContextFactory::kDebug_GLContextType,
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTypeCnt - 2,
|
||||
"Skipping unexpected GLContextType for GPU tests");
|
||||
|
||||
for (auto& contextType : contextTypes) {
|
||||
const GrGLStandard api = get_gpu_api();
|
||||
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
|
||||
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
|
||||
int contextSelector = kNone_GPUTestContexts;
|
||||
if (GrContextFactory::IsRenderingGLContext(contextType)) {
|
||||
if (GrContextFactory::IsRenderingGLContext(glCtxType)) {
|
||||
contextSelector |= kAllRendering_GPUTestContexts;
|
||||
} else if (contextType == GrContextFactory::kNative_GLContextType) {
|
||||
} else if (glCtxType == GrContextFactory::kNative_GLContextType) {
|
||||
contextSelector |= kNative_GPUTestContexts;
|
||||
} else if (contextType == GrContextFactory::kNull_GLContextType) {
|
||||
} else if (glCtxType == GrContextFactory::kNull_GLContextType) {
|
||||
contextSelector |= kNull_GPUTestContexts;
|
||||
} else if (contextType == GrContextFactory::kDebug_GLContextType) {
|
||||
} else if (glCtxType == GrContextFactory::kDebug_GLContextType) {
|
||||
contextSelector |= kDebug_GPUTestContexts;
|
||||
}
|
||||
if ((testContexts & contextSelector) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (GrContextFactory::ContextInfo* context = factory->getContextInfo(contextType)) {
|
||||
if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glCtxType, api)) {
|
||||
call_test(test, reporter, context);
|
||||
}
|
||||
if (GrContextFactory::ContextInfo* context =
|
||||
factory->getContextInfo(contextType, GrContextFactory::kEnableNVPR_GLContextOptions)) {
|
||||
factory->getContextInfo(glCtxType, api,
|
||||
GrContextFactory::kEnableNVPR_GLContextOptions)) {
|
||||
call_test(test, reporter, context);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,14 @@ static const bool kGPUDisabled = false;
|
||||
static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory,
|
||||
GrContextFactory::GLContextType type,
|
||||
GrContextFactory::GLContextOptions options,
|
||||
GrGLStandard gpuAPI,
|
||||
SkImageInfo info,
|
||||
int samples,
|
||||
bool useDIText) {
|
||||
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
|
||||
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, options), SkSurface::kNo_Budgeted,
|
||||
info, samples, &props);
|
||||
return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI, options),
|
||||
SkSurface::kNo_Budgeted, info, samples, &props);
|
||||
}
|
||||
|
||||
} // namespace DM
|
||||
@ -91,6 +92,7 @@ static const bool kGPUDisabled = true;
|
||||
static inline SkSurface* NewGpuSurface(GrContextFactory*,
|
||||
GrContextFactory::GLContextType,
|
||||
GrContextFactory::GLContextOptions,
|
||||
GrGLStandard,
|
||||
SkImageInfo,
|
||||
int,
|
||||
bool) {
|
||||
|
@ -790,11 +790,13 @@ DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?");
|
||||
|
||||
GPUSink::GPUSink(GrContextFactory::GLContextType ct,
|
||||
GrContextFactory::GLContextOptions options,
|
||||
GrGLStandard gpuAPI,
|
||||
int samples,
|
||||
bool diText,
|
||||
bool threaded)
|
||||
: fContextType(ct)
|
||||
, fContextOptions(options)
|
||||
, fGpuAPI(gpuAPI)
|
||||
, fSampleCount(samples)
|
||||
, fUseDIText(diText)
|
||||
, fThreaded(threaded) {}
|
||||
@ -824,7 +826,8 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
|
||||
const SkImageInfo info =
|
||||
SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul_SkAlphaType);
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
NewGpuSurface(&factory, fContextType, fContextOptions, info, fSampleCount, fUseDIText));
|
||||
NewGpuSurface(&factory, fContextType, fContextOptions, fGpuAPI, info, fSampleCount,
|
||||
fUseDIText));
|
||||
if (!surface) {
|
||||
return "Could not create a surface.";
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
class GPUSink : public Sink {
|
||||
public:
|
||||
GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions,
|
||||
int samples, bool diText, bool threaded);
|
||||
GrGLStandard, int samples, bool diText, bool threaded);
|
||||
|
||||
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
|
||||
int enclave() const override;
|
||||
@ -224,6 +224,7 @@ public:
|
||||
private:
|
||||
GrContextFactory::GLContextType fContextType;
|
||||
GrContextFactory::GLContextOptions fContextOptions;
|
||||
GrGLStandard fGpuAPI;
|
||||
int fSampleCount;
|
||||
bool fUseDIText;
|
||||
bool fThreaded;
|
||||
|
@ -29,15 +29,9 @@
|
||||
{
|
||||
'target_name': 'flags_common',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
'../include/gpu',
|
||||
'../src/gpu',
|
||||
],
|
||||
'sources': [
|
||||
'../tools/flags/SkCommonFlags.cpp',
|
||||
'../tools/flags/SkCommonFlags.h',
|
||||
'../tools/flags/SkCommonFlagsConfig.cpp',
|
||||
'../tools/flags/SkCommonFlagsConfig.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'skia_lib.gyp:skia_lib',
|
||||
@ -45,8 +39,6 @@
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'../include/gpu',
|
||||
'../src/gpu',
|
||||
'../tools/flags',
|
||||
],
|
||||
}
|
||||
|
@ -267,22 +267,7 @@ template <> inline void SkTSwap(SkString& a, SkString& b) {
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
enum SkStrSplitMode {
|
||||
// Strictly return all results. If the input is ",," and the separator is ',' this will return
|
||||
// an array of three empty strings.
|
||||
kStrict_SkStrSplitMode,
|
||||
|
||||
// Only nonempty results will be added to the results. Multiple separators will be
|
||||
// coalesced. Separators at the beginning and end of the input will be ignored. If the input is
|
||||
// ",," and the separator is ',', this will return an empty vector.
|
||||
kCoalesce_SkStrSplitMode
|
||||
};
|
||||
|
||||
// Split str on any characters in delimiters into out. (Think, strtok with a sane API.)
|
||||
void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMode,
|
||||
SkTArray<SkString>* out);
|
||||
inline void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out) {
|
||||
SkStrSplit(str, delimiters, kCoalesce_SkStrSplitMode, out);
|
||||
}
|
||||
void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out);
|
||||
|
||||
#endif
|
||||
|
@ -14,12 +14,7 @@ class SK_API SkNullGLContext : public SkGLContext {
|
||||
public:
|
||||
~SkNullGLContext() override;
|
||||
|
||||
static SkNullGLContext* Create();
|
||||
// FIXME: remove once Chromium has been updated.
|
||||
static SkNullGLContext* Create(GrGLStandard forcedAPI) {
|
||||
SkASSERT(forcedAPI == kNone_GrGLStandard);
|
||||
(void)forcedAPI; return Create();
|
||||
}
|
||||
static SkNullGLContext* Create(GrGLStandard);
|
||||
|
||||
class ContextState;
|
||||
|
||||
|
@ -15,25 +15,18 @@
|
||||
class SkANGLEGLContext : public SkGLContext {
|
||||
public:
|
||||
~SkANGLEGLContext() override;
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
static SkANGLEGLContext* CreateDirectX() {
|
||||
SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
#endif
|
||||
static SkANGLEGLContext* CreateOpenGL() {
|
||||
SkANGLEGLContext* ctx = new SkANGLEGLContext(true);
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) {
|
||||
if (kGL_GrGLStandard == forcedGpuAPI) {
|
||||
return NULL;
|
||||
}
|
||||
SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend);
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
|
||||
void destroyEGLImage(GrEGLImage) const override;
|
||||
GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
|
||||
|
@ -16,7 +16,10 @@ class SkCommandBufferGLContext : public SkGLContext {
|
||||
public:
|
||||
~SkCommandBufferGLContext() override;
|
||||
|
||||
static SkCommandBufferGLContext* Create() {
|
||||
static SkCommandBufferGLContext* Create(GrGLStandard forcedGpuAPI) {
|
||||
if (kGL_GrGLStandard == forcedGpuAPI) {
|
||||
return nullptr;
|
||||
}
|
||||
SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext;
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
|
@ -624,34 +624,15 @@ SkString SkStringPrintf(const char* format, ...) {
|
||||
return formattedOutput;
|
||||
}
|
||||
|
||||
void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMode,
|
||||
SkTArray<SkString>* out) {
|
||||
if (splitMode == kCoalesce_SkStrSplitMode) {
|
||||
// Skip any delimiters.
|
||||
str += strspn(str, delimiters);
|
||||
}
|
||||
if (!*str) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out) {
|
||||
const char* end = str + strlen(str);
|
||||
while (str != end) {
|
||||
// Find a token.
|
||||
const size_t len = strcspn(str, delimiters);
|
||||
if (splitMode == kStrict_SkStrSplitMode || len > 0) {
|
||||
out->push_back().set(str, len);
|
||||
str += len;
|
||||
}
|
||||
|
||||
if (!*str) {
|
||||
return;
|
||||
}
|
||||
if (splitMode == kCoalesce_SkStrSplitMode) {
|
||||
// Skip any delimiters.
|
||||
str += strspn(str, delimiters);
|
||||
} else {
|
||||
// Skip one delimiter.
|
||||
str += 1;
|
||||
}
|
||||
out->push_back().set(str, len);
|
||||
str += len;
|
||||
// Skip any delimiters.
|
||||
str += strspn(str, delimiters);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,13 @@
|
||||
#include "GrCaps.h"
|
||||
|
||||
GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType type,
|
||||
GrGLStandard forcedGpuAPI,
|
||||
GLContextOptions options) {
|
||||
for (int i = 0; i < fContexts.count(); ++i) {
|
||||
if (fContexts[i]->fType == type &&
|
||||
fContexts[i]->fOptions == options) {
|
||||
fContexts[i]->fOptions == options &&
|
||||
(forcedGpuAPI == kNone_GrGLStandard ||
|
||||
forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) {
|
||||
fContexts[i]->fGLContext->makeCurrent();
|
||||
return fContexts[i];
|
||||
}
|
||||
@ -36,39 +39,31 @@ GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty
|
||||
SkAutoTUnref<GrContext> grCtx;
|
||||
switch (type) {
|
||||
case kNative_GLContextType:
|
||||
glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard));
|
||||
glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI));
|
||||
break;
|
||||
case kGL_GLContextType:
|
||||
glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard));
|
||||
break;
|
||||
case kGLES_GLContextType:
|
||||
glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard));
|
||||
break;
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#ifdef SK_ANGLE
|
||||
case kANGLE_GLContextType:
|
||||
glCtx.reset(SkANGLEGLContext::CreateDirectX());
|
||||
glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false));
|
||||
break;
|
||||
#endif
|
||||
case kANGLE_GL_GLContextType:
|
||||
glCtx.reset(SkANGLEGLContext::CreateOpenGL());
|
||||
glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true));
|
||||
break;
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
#ifdef SK_COMMAND_BUFFER
|
||||
case kCommandBuffer_GLContextType:
|
||||
glCtx.reset(SkCommandBufferGLContext::Create());
|
||||
glCtx.reset(SkCommandBufferGLContext::Create(forcedGpuAPI));
|
||||
break;
|
||||
#endif
|
||||
#if SK_MESA
|
||||
#ifdef SK_MESA
|
||||
case kMESA_GLContextType:
|
||||
glCtx.reset(SkMesaGLContext::Create());
|
||||
glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI));
|
||||
break;
|
||||
#endif
|
||||
case kNull_GLContextType:
|
||||
glCtx.reset(SkNullGLContext::Create());
|
||||
glCtx.reset(SkNullGLContext::Create(forcedGpuAPI));
|
||||
break;
|
||||
case kDebug_GLContextType:
|
||||
glCtx.reset(SkDebugGLContext::Create());
|
||||
glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI));
|
||||
break;
|
||||
}
|
||||
if (nullptr == glCtx.get()) {
|
||||
|
@ -24,23 +24,19 @@
|
||||
class GrContextFactory : SkNoncopyable {
|
||||
public:
|
||||
enum GLContextType {
|
||||
kNative_GLContextType, //! OpenGL or OpenGL ES context.
|
||||
kGL_GLContextType, //! OpenGL context.
|
||||
kGLES_GLContextType, //! OpenGL ES context.
|
||||
kNative_GLContextType,
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
kANGLE_GLContextType, //! ANGLE on DirectX OpenGL ES context.
|
||||
#endif
|
||||
kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context.
|
||||
kANGLE_GLContextType,
|
||||
kANGLE_GL_GLContextType,
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES context.
|
||||
kCommandBuffer_GLContextType,
|
||||
#endif
|
||||
#if SK_MESA
|
||||
kMESA_GLContextType, //! MESA OpenGL context
|
||||
kMESA_GLContextType,
|
||||
#endif
|
||||
kNull_GLContextType, //! Non-rendering OpenGL mock context.
|
||||
kDebug_GLContextType, //! Non-rendering, state verifying OpenGL context.
|
||||
kNull_GLContextType,
|
||||
kDebug_GLContextType,
|
||||
kLastGLContextType = kDebug_GLContextType
|
||||
};
|
||||
|
||||
@ -69,15 +65,11 @@ public:
|
||||
switch (type) {
|
||||
case kNative_GLContextType:
|
||||
return "native";
|
||||
case kGL_GLContextType:
|
||||
return "gl";
|
||||
case kGLES_GLContextType:
|
||||
return "gles";
|
||||
case kNull_GLContextType:
|
||||
return "null";
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
case kANGLE_GLContextType:
|
||||
return "angle";
|
||||
#endif
|
||||
case kANGLE_GL_GLContextType:
|
||||
return "angle-gl";
|
||||
#endif
|
||||
@ -89,8 +81,6 @@ public:
|
||||
case kMESA_GLContextType:
|
||||
return "mesa";
|
||||
#endif
|
||||
case kNull_GLContextType:
|
||||
return "null";
|
||||
case kDebug_GLContextType:
|
||||
return "debug";
|
||||
default:
|
||||
@ -134,14 +124,15 @@ public:
|
||||
* Get a context initialized with a type of GL context. It also makes the GL context current.
|
||||
* Pointer is valid until destroyContexts() is called.
|
||||
*/
|
||||
ContextInfo* getContextInfo(GLContextType type,
|
||||
ContextInfo* getContextInfo(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard,
|
||||
GLContextOptions options = kNone_GLContextOptions);
|
||||
|
||||
/**
|
||||
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
|
||||
*/
|
||||
GrContext* get(GLContextType type, GLContextOptions options = kNone_GLContextOptions) {
|
||||
if (ContextInfo* info = this->getContextInfo(type, options)) {
|
||||
GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard,
|
||||
GLContextOptions options = kNone_GLContextOptions) {
|
||||
if (ContextInfo* info = this->getContextInfo(type, forcedGpuAPI, options)) {
|
||||
return info->fGrContext;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -578,7 +578,10 @@ static void set_current_context_from_interface(const GrGLInterface* interface) {
|
||||
}
|
||||
#endif
|
||||
|
||||
SkNullGLContext* SkNullGLContext::Create() {
|
||||
SkNullGLContext* SkNullGLContext::Create(GrGLStandard forcedGpuAPI) {
|
||||
if (kGLES_GrGLStandard == forcedGpuAPI) {
|
||||
return nullptr;
|
||||
}
|
||||
SkNullGLContext* ctx = new SkNullGLContext;
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
|
@ -180,12 +180,7 @@ GrGLuint SkANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
|
||||
}
|
||||
|
||||
SkGLContext* SkANGLEGLContext::createNew() const {
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
SkGLContext* ctx = fIsGLBackend ? SkANGLEGLContext::CreateOpenGL()
|
||||
: SkANGLEGLContext::CreateDirectX();
|
||||
#else
|
||||
SkGLContext* ctx = SkANGLEGLContext::CreateOpenGL();
|
||||
#endif
|
||||
SkGLContext* ctx = SkANGLEGLContext::Create(this->gl()->fStandard, fIsGLBackend);
|
||||
if (ctx) {
|
||||
ctx->makeCurrent();
|
||||
}
|
||||
|
@ -14,7 +14,10 @@ class SkDebugGLContext : public SkGLContext {
|
||||
public:
|
||||
~SkDebugGLContext() override;
|
||||
|
||||
static SkDebugGLContext* Create() {
|
||||
static SkDebugGLContext* Create(GrGLStandard forcedGpuAPI) {
|
||||
if (kGLES_GrGLStandard == forcedGpuAPI) {
|
||||
return nullptr;
|
||||
}
|
||||
return new SkDebugGLContext;
|
||||
}
|
||||
private:
|
||||
|
@ -19,7 +19,10 @@ private:
|
||||
public:
|
||||
~SkMesaGLContext() override;
|
||||
|
||||
static SkMesaGLContext* Create() {
|
||||
static SkMesaGLContext* Create(GrGLStandard forcedGpuAPI) {
|
||||
if (kGLES_GrGLStandard == forcedGpuAPI) {
|
||||
return nullptr;
|
||||
}
|
||||
SkMesaGLContext* ctx = new SkMesaGLContext;
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
|
@ -435,21 +435,17 @@ DEF_GPUTEST(GLPrograms, reporter, factory) {
|
||||
return;
|
||||
}
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
// Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
|
||||
if (type == GrContextFactory::kANGLE_GLContextType) {
|
||||
maxStages = 2;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
// Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
|
||||
// TODO(hendrikw): This only needs to happen with the ANGLE comand buffer backend.
|
||||
if (type == GrContextFactory::kCommandBuffer_GLContextType) {
|
||||
maxStages = 2;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest(context, maxStages));
|
||||
}
|
||||
|
@ -17,14 +17,10 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
|
||||
// Test that if NVPR is requested, the context always has path rendering
|
||||
// or the context creation fails.
|
||||
GrContextFactory testFactory;
|
||||
// Test that if NVPR is possible, caps are in sync.
|
||||
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
|
||||
GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
|
||||
GrContext* context = testFactory.get(glCtxType,
|
||||
GrContextFactory::kEnableNVPR_GLContextOptions);
|
||||
if (!context) {
|
||||
continue;
|
||||
}
|
||||
GrContext* context = testFactory.get(GrContextFactory::kNative_GLContextType,
|
||||
kNone_GrGLStandard,
|
||||
GrContextFactory::kEnableNVPR_GLContextOptions);
|
||||
if (context) {
|
||||
REPORTER_ASSERT(
|
||||
reporter,
|
||||
context->caps()->shaderCaps()->pathRenderingSupport());
|
||||
|
@ -201,62 +201,9 @@ DEF_TEST(String_SkStrSplit, r) {
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("\n", "\n", &results);
|
||||
REPORTER_ASSERT(r, results.count() == 0);
|
||||
REPORTER_ASSERT(r, results.count() == 1);
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("", "\n", &results);
|
||||
REPORTER_ASSERT(r, results.count() == 0);
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("a", "\n", &results);
|
||||
REPORTER_ASSERT(r, results.count() == 1);
|
||||
REPORTER_ASSERT(r, results[0].equals("a"));
|
||||
}
|
||||
DEF_TEST(String_SkStrSplit_All, r) {
|
||||
SkTArray<SkString> results;
|
||||
SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 13);
|
||||
REPORTER_ASSERT(r, results[0].equals("a"));
|
||||
REPORTER_ASSERT(r, results[1].equals(""));
|
||||
REPORTER_ASSERT(r, results[2].equals("b"));
|
||||
REPORTER_ASSERT(r, results[3].equals("c"));
|
||||
REPORTER_ASSERT(r, results[4].equals("dee"));
|
||||
REPORTER_ASSERT(r, results[5].equals(""));
|
||||
REPORTER_ASSERT(r, results[6].equals("f"));
|
||||
REPORTER_ASSERT(r, results[7].equals(""));
|
||||
REPORTER_ASSERT(r, results[8].equals(""));
|
||||
REPORTER_ASSERT(r, results[9].equals(""));
|
||||
REPORTER_ASSERT(r, results[10].equals(""));
|
||||
REPORTER_ASSERT(r, results[11].equals("g"));
|
||||
REPORTER_ASSERT(r, results[12].equals(""));
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("\n", "\n", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 2);
|
||||
REPORTER_ASSERT(r, results[0].equals(""));
|
||||
REPORTER_ASSERT(r, results[1].equals(""));
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("", "\n", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 0);
|
||||
|
||||
results.reset();
|
||||
SkStrSplit("a", "\n", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 1);
|
||||
REPORTER_ASSERT(r, results[0].equals("a"));
|
||||
|
||||
results.reset();
|
||||
SkStrSplit(",,", ",", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 3);
|
||||
REPORTER_ASSERT(r, results[0].equals(""));
|
||||
REPORTER_ASSERT(r, results[1].equals(""));
|
||||
REPORTER_ASSERT(r, results[2].equals(""));
|
||||
|
||||
results.reset();
|
||||
SkStrSplit(",a,b,", ",", kStrict_SkStrSplitMode, &results);
|
||||
REPORTER_ASSERT(r, results.count() == 4);
|
||||
REPORTER_ASSERT(r, results[0].equals(""));
|
||||
REPORTER_ASSERT(r, results[1].equals("a"));
|
||||
REPORTER_ASSERT(r, results[2].equals("b"));
|
||||
REPORTER_ASSERT(r, results[3].equals(""));
|
||||
}
|
||||
|
@ -1,314 +0,0 @@
|
||||
/*
|
||||
* 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 "SkCommonFlagsConfig.h"
|
||||
#include "Test.h"
|
||||
#include <initializer_list>
|
||||
|
||||
namespace {
|
||||
// The code
|
||||
// SkCommandLineFlags::StringArray FLAGS_config1 = make_string_array({"a", "b"})
|
||||
// can be used to construct string array that one gets with command line flags.
|
||||
// For example, the call above is equivalent of
|
||||
// DEFINE_string(config1, "a b", "");
|
||||
// in cases where the default command line flag value ("a b") is used.
|
||||
// make_string_array can be used to construct StringArray strings that have spaces in
|
||||
// them.
|
||||
SkCommandLineFlags::StringArray make_string_array(std::initializer_list<const char*> strings) {
|
||||
SkTArray<SkString> array;
|
||||
for (auto& s : strings) {
|
||||
array.push_back(SkString(s));
|
||||
}
|
||||
return SkCommandLineFlags::StringArray(array);
|
||||
}
|
||||
}
|
||||
DEF_TEST(ParseConfigs_Gpu, reporter) {
|
||||
// Parses a normal config and returns correct "tag".
|
||||
// Gpu config defaults work.
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"});
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
|
||||
REPORTER_ASSERT(reporter, configs.count() == 1);
|
||||
REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu"));
|
||||
REPORTER_ASSERT(reporter, configs[0]->getViaParts().count() == 0);
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType()
|
||||
== GrContextFactory::kNative_GLContextType);
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
DEF_TEST(ParseConfigs_OutParam, reporter) {
|
||||
// Clears the out parameter.
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"});
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
REPORTER_ASSERT(reporter, configs.count() == 1);
|
||||
REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu"));
|
||||
SkCommandLineFlags::StringArray config2 = make_string_array({"8888"});
|
||||
ParseConfigs(config2, &configs);
|
||||
REPORTER_ASSERT(reporter, configs.count() == 1);
|
||||
REPORTER_ASSERT(reporter, configs[0]->getTag().equals("8888"));
|
||||
}
|
||||
|
||||
DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
|
||||
// Parses all default configs and returns correct "tag".
|
||||
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
"565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16", "msaa4",
|
||||
"nonrendering", "null", "nullgpu", "nvprmsaa16", "nvprmsaa4", "pdf", "pdf_poppler",
|
||||
"skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui"
|
||||
});
|
||||
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
|
||||
REPORTER_ASSERT(reporter, configs.count() == config1.count());
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 0);
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[2]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[3]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[4]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getUseDIText());
|
||||
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 16);
|
||||
REPORTER_ASSERT(reporter, configs[8]->asConfigGpu()->getSamples() == 4);
|
||||
REPORTER_ASSERT(reporter, !configs[9]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[10]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[11]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getSamples() == 16);
|
||||
REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getUseNVPR());
|
||||
REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getSamples() == 4);
|
||||
REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getUseNVPR());
|
||||
REPORTER_ASSERT(reporter, !configs[14]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[15]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[16]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[17]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu());
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
REPORTER_ASSERT(reporter, configs[19]->asConfigGpu());
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
|
||||
#endif
|
||||
REPORTER_ASSERT(reporter, configs[20]->asConfigGpu());
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[20]->asConfigGpu());
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
REPORTER_ASSERT(reporter, configs[21]->asConfigGpu());
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[21]->asConfigGpu());
|
||||
#endif
|
||||
#if SK_MESA
|
||||
REPORTER_ASSERT(reporter, configs[22]->asConfigGpu());
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[22]->asConfigGpu());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) {
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
"gpu(nvpr=true,dit=true)",
|
||||
"gpu(api=angle)",
|
||||
"gpu(api=angle-gl)",
|
||||
"gpu(api=mesa,samples=77)",
|
||||
"gpu(dit=true,api=commandbuffer)",
|
||||
"gpu()",
|
||||
"gpu(api=gles)"
|
||||
});
|
||||
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
REPORTER_ASSERT(reporter, configs.count() == config1.count());
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kNative_GLContextType);
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR());
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText());
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kANGLE_GLContextType);
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
|
||||
#endif
|
||||
REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kANGLE_GL_GLContextType);
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu());
|
||||
#endif
|
||||
#if SK_MESA
|
||||
REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kMESA_GLContextType);
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu());
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kCommandBuffer_GLContextType);
|
||||
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu());
|
||||
#endif
|
||||
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kNative_GLContextType);
|
||||
REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR());
|
||||
REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText());
|
||||
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0);
|
||||
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() ==
|
||||
GrContextFactory::kGLES_GLContextType);
|
||||
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR());
|
||||
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText());
|
||||
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) {
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
"gpu(nvpr=1)", // Number as bool.
|
||||
"gpu(api=gl,)", // Trailing in comma.
|
||||
"gpu(api=angle-glu)", // Unknown api.
|
||||
"gpu(api=,samples=0)", // Empty api.
|
||||
"gpu(samples=true)", // Value true as a number.
|
||||
"gpu(samples=0,samples=0)", // Duplicate option key.
|
||||
"gpu(,samples=0)", // Leading comma.
|
||||
"gpu(samples=54", // Missing closing parenthesis.
|
||||
",,",
|
||||
"gpu(", // Missing parenthesis.
|
||||
"samples=54" // No backend.
|
||||
"gpu(nvpr=true )", // Space.
|
||||
});
|
||||
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
REPORTER_ASSERT(reporter, configs.count() == config1.count());
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i]));
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) {
|
||||
// These just list explicitly some properties of the system.
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
// Options are not canonized -> two same configs have a different tag.
|
||||
"gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)",
|
||||
// API native is alias for gl or gles, but it's not canonized -> different tag.
|
||||
"gpu(api=native)", "gpu(api=gl)", "gpu(api=gles)", ""
|
||||
// Default values are not canonized -> different tag.
|
||||
"gpu", "gpu()", "gpu(samples=0)", "gpu(api=native,samples=0)"
|
||||
});
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
REPORTER_ASSERT(reporter, configs.count() == config1.count());
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu"));
|
||||
REPORTER_ASSERT(reporter, configs[i]->asConfigGpu());
|
||||
#else
|
||||
REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
DEF_TEST(ParseConfigs_ViaParsing, reporter) {
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
"a-b-c-8888",
|
||||
"zz-qq-gpu",
|
||||
"a-angle-gl"
|
||||
});
|
||||
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
const struct {
|
||||
const char* backend;
|
||||
const char* vias[3];
|
||||
} expectedConfigs[] = {
|
||||
{"8888", {"a", "b", "c"}},
|
||||
{"gpu", {"zz", "qq", nullptr}},
|
||||
{"angle-gl", {"a", nullptr, nullptr}} // The angle-gl tag is only tag that contains
|
||||
// hyphen.
|
||||
};
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfigs[i].backend));
|
||||
for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].vias)); ++j) {
|
||||
if (!expectedConfigs[i].vias[j]) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == j);
|
||||
break;
|
||||
}
|
||||
REPORTER_ASSERT(reporter,
|
||||
configs[i]->getViaParts()[j].equals(expectedConfigs[i].vias[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEF_TEST(ParseConfigs_ViaParsingExtendedForm, reporter) {
|
||||
SkCommandLineFlags::StringArray config1 = make_string_array({
|
||||
"zz-qq-gpu(api=gles)",
|
||||
"a-gpu(samples=1",
|
||||
"abc-def-angle-gl(samples=1)",
|
||||
});
|
||||
|
||||
SkCommandLineConfigArray configs;
|
||||
ParseConfigs(config1, &configs);
|
||||
const struct {
|
||||
const char* backend;
|
||||
const char* vias[3];
|
||||
} expectedConfigs[] = {
|
||||
#if SK_SUPPORT_GPU
|
||||
{"gpu", {"zz", "qq", nullptr}},
|
||||
#else
|
||||
{"gpu(api=gles)", {"zz", "qq", nullptr}},
|
||||
#endif
|
||||
{"gpu(samples=1", {"a", nullptr, nullptr}}, // This is not extended form, but via still
|
||||
// works as expected.
|
||||
{"gl(samples=1)", {"abc", "def", "angle"}} // This is not extended form. Also
|
||||
// angle-gl is not a "backend" in this case.
|
||||
};
|
||||
for (int i = 0; i < config1.count(); ++i) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
|
||||
REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfigs[i].backend));
|
||||
for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].vias)); ++j) {
|
||||
if (!expectedConfigs[i].vias[j]) {
|
||||
REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() ==
|
||||
static_cast<int>(j));
|
||||
break;
|
||||
}
|
||||
REPORTER_ASSERT(reporter,
|
||||
configs[i]->getViaParts()[j].equals(expectedConfigs[i].vias[j]));
|
||||
}
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
|
||||
REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu());
|
||||
#endif
|
||||
}
|
@ -22,10 +22,8 @@ template <typename T> static void ignore_result(const T&) {}
|
||||
|
||||
bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName,
|
||||
SkCommandLineFlags::StringArray* pStrings,
|
||||
const char* defaultValue, const char* helpString,
|
||||
const char* extendedHelpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpString,
|
||||
extendedHelpString);
|
||||
const char* defaultValue, const char* helpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpString);
|
||||
info->fDefaultString.set(defaultValue);
|
||||
|
||||
info->fStrings = pStrings;
|
||||
@ -153,16 +151,29 @@ void SkCommandLineFlags::SetUsage(const char* usage) {
|
||||
// Maximum line length for the help message.
|
||||
#define LINE_LENGTH 72
|
||||
|
||||
static void print_indented(const SkString& text) {
|
||||
size_t length = text.size();
|
||||
const char* currLine = text.c_str();
|
||||
static void print_help_for_flag(const SkFlagInfo* flag) {
|
||||
SkDebugf(" --%s", flag->name().c_str());
|
||||
const SkString& shortName = flag->shortName();
|
||||
if (shortName.size() > 0) {
|
||||
SkDebugf(" or -%s", shortName.c_str());
|
||||
}
|
||||
SkDebugf(":\ttype: %s", flag->typeAsString().c_str());
|
||||
if (flag->defaultValue().size() > 0) {
|
||||
SkDebugf("\tdefault: %s", flag->defaultValue().c_str());
|
||||
}
|
||||
SkDebugf("\n");
|
||||
const SkString& help = flag->help();
|
||||
size_t length = help.size();
|
||||
const char* currLine = help.c_str();
|
||||
const char* stop = currLine + length;
|
||||
while (currLine < stop) {
|
||||
int lineBreak = SkStrFind(currLine, "\n");
|
||||
if (lineBreak < 0) {
|
||||
lineBreak = static_cast<int>(strlen(currLine));
|
||||
if (strlen(currLine) < LINE_LENGTH) {
|
||||
// Only one line length's worth of text left.
|
||||
SkDebugf(" %s\n", currLine);
|
||||
break;
|
||||
}
|
||||
if (lineBreak > LINE_LENGTH) {
|
||||
int lineBreak = SkStrFind(currLine, "\n");
|
||||
if (lineBreak < 0 || lineBreak > LINE_LENGTH) {
|
||||
// No line break within line length. Will need to insert one.
|
||||
// Find a space before the line break.
|
||||
int spaceIndex = LINE_LENGTH - 1;
|
||||
@ -187,26 +198,6 @@ static void print_indented(const SkString& text) {
|
||||
currLine += lineBreak;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void print_help_for_flag(const SkFlagInfo* flag) {
|
||||
SkDebugf(" --%s", flag->name().c_str());
|
||||
const SkString& shortName = flag->shortName();
|
||||
if (shortName.size() > 0) {
|
||||
SkDebugf(" or -%s", shortName.c_str());
|
||||
}
|
||||
SkDebugf(":\ttype: %s", flag->typeAsString().c_str());
|
||||
if (flag->defaultValue().size() > 0) {
|
||||
SkDebugf("\tdefault: %s", flag->defaultValue().c_str());
|
||||
}
|
||||
SkDebugf("\n");
|
||||
const SkString& help = flag->help();
|
||||
print_indented(help);
|
||||
SkDebugf("\n");
|
||||
}
|
||||
static void print_extended_help_for_flag(const SkFlagInfo* flag) {
|
||||
print_help_for_flag(flag);
|
||||
print_indented(flag->extendedHelp());
|
||||
SkDebugf("\n");
|
||||
}
|
||||
|
||||
@ -257,10 +248,6 @@ void SkCommandLineFlags::Parse(int argc, char** argv) {
|
||||
CompareFlagsByName());
|
||||
for (int i = 0; i < allFlags.count(); ++i) {
|
||||
print_help_for_flag(allFlags[i]);
|
||||
if (allFlags[i]->extendedHelp().size() > 0) {
|
||||
SkDebugf(" Use '--help %s' for more information.\n",
|
||||
allFlags[i]->name().c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (SkFlagInfo* flag = SkCommandLineFlags::gHead; flag;
|
||||
@ -268,7 +255,7 @@ void SkCommandLineFlags::Parse(int argc, char** argv) {
|
||||
for (int k = 0; k < helpFlags.count(); k++) {
|
||||
if (flag->name().equals(helpFlags[k]) ||
|
||||
flag->shortName().equals(helpFlags[k])) {
|
||||
print_extended_help_for_flag(flag);
|
||||
print_help_for_flag(flag);
|
||||
helpFlags.remove(k);
|
||||
break;
|
||||
}
|
||||
|
@ -76,11 +76,6 @@
|
||||
* as its value. All strings that follow the flag on the command line (until
|
||||
* a string that begins with '-') will be entries in the array.
|
||||
*
|
||||
* DEFINE_extended_string(args, .., .., extendedHelpString);
|
||||
*
|
||||
* creates a similar string array flag as DEFINE_string. The flag will have extended help text
|
||||
* (extendedHelpString) that can the user can see with '--help <args>' flag.
|
||||
*
|
||||
* Any flag can be referenced from another file after using the following:
|
||||
*
|
||||
* DECLARE_x(name);
|
||||
@ -119,10 +114,6 @@ public:
|
||||
*/
|
||||
class StringArray {
|
||||
public:
|
||||
StringArray() { }
|
||||
explicit StringArray(const SkTArray<SkString>& strings)
|
||||
: fStrings(strings) {
|
||||
}
|
||||
const char* operator[](int i) const {
|
||||
SkASSERT(i >= 0 && i < fStrings.count());
|
||||
return fStrings[i].c_str();
|
||||
@ -213,15 +204,7 @@ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(nam
|
||||
nullptr, \
|
||||
&FLAGS_##name, \
|
||||
defaultValue, \
|
||||
helpString, nullptr)
|
||||
#define DEFINE_extended_string(name, defaultValue, helpString, extendedHelpString) \
|
||||
SkCommandLineFlags::StringArray FLAGS_##name; \
|
||||
SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
|
||||
nullptr, \
|
||||
&FLAGS_##name, \
|
||||
defaultValue, \
|
||||
helpString, \
|
||||
extendedHelpString)
|
||||
helpString)
|
||||
|
||||
// string2 allows specifying a short name. There is an assert that shortName
|
||||
// is only 1 character.
|
||||
@ -231,7 +214,7 @@ SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(nam
|
||||
TO_STRING(shortName), \
|
||||
&FLAGS_##name, \
|
||||
defaultValue, \
|
||||
helpString, nullptr)
|
||||
helpString)
|
||||
|
||||
#define DECLARE_string(name) extern SkCommandLineFlags::StringArray FLAGS_##name;
|
||||
|
||||
@ -290,7 +273,7 @@ public:
|
||||
*/
|
||||
static bool CreateBoolFlag(const char* name, const char* shortName, bool* pBool,
|
||||
bool defaultValue, const char* helpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString, nullptr);
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString);
|
||||
info->fBoolValue = pBool;
|
||||
*info->fBoolValue = info->fDefaultBool = defaultValue;
|
||||
return true;
|
||||
@ -304,15 +287,14 @@ public:
|
||||
*/
|
||||
static bool CreateStringFlag(const char* name, const char* shortName,
|
||||
SkCommandLineFlags::StringArray* pStrings,
|
||||
const char* defaultValue, const char* helpString,
|
||||
const char* extendedHelpString);
|
||||
const char* defaultValue, const char* helpString);
|
||||
|
||||
/**
|
||||
* See comments for CreateBoolFlag.
|
||||
*/
|
||||
static bool CreateIntFlag(const char* name, int32_t* pInt,
|
||||
int32_t defaultValue, const char* helpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString, nullptr);
|
||||
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString);
|
||||
info->fIntValue = pInt;
|
||||
*info->fIntValue = info->fDefaultInt = defaultValue;
|
||||
return true;
|
||||
@ -320,7 +302,7 @@ public:
|
||||
|
||||
static bool CreateIntFlag(const char* name, const char* shortName, int32_t* pInt,
|
||||
int32_t defaultValue, const char* helpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString, nullptr);
|
||||
SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString);
|
||||
info->fIntValue = pInt;
|
||||
*info->fIntValue = info->fDefaultInt = defaultValue;
|
||||
return true;
|
||||
@ -331,7 +313,7 @@ public:
|
||||
*/
|
||||
static bool CreateDoubleFlag(const char* name, double* pDouble,
|
||||
double defaultValue, const char* helpString) {
|
||||
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString, nullptr);
|
||||
SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString);
|
||||
info->fDoubleValue = pDouble;
|
||||
*info->fDoubleValue = info->fDefaultDouble = defaultValue;
|
||||
return true;
|
||||
@ -401,7 +383,6 @@ public:
|
||||
const SkString& shortName() const { return fShortName; }
|
||||
|
||||
const SkString& help() const { return fHelpString; }
|
||||
const SkString& extendedHelp() const { return fExtendedHelpString; }
|
||||
|
||||
SkString defaultValue() const {
|
||||
SkString result;
|
||||
@ -440,13 +421,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString,
|
||||
const char* extendedHelpString)
|
||||
SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString)
|
||||
: fName(name)
|
||||
, fShortName(shortName)
|
||||
, fFlagType(type)
|
||||
, fHelpString(helpString)
|
||||
, fExtendedHelpString(extendedHelpString)
|
||||
, fBoolValue(nullptr)
|
||||
, fDefaultBool(false)
|
||||
, fIntValue(nullptr)
|
||||
@ -474,7 +453,6 @@ private:
|
||||
SkString fShortName;
|
||||
FlagTypes fFlagType;
|
||||
SkString fHelpString;
|
||||
SkString fExtendedHelpString;
|
||||
bool* fBoolValue;
|
||||
bool fDefaultBool;
|
||||
int32_t* fIntValue;
|
||||
|
@ -7,6 +7,11 @@
|
||||
|
||||
#include "SkCommonFlags.h"
|
||||
|
||||
DEFINE_string(config, "565 8888 gpu nonrendering angle hwui ", "Options: "
|
||||
"565 8888 angle debug gpu gpudebug gpudft gpunull hwui mesa "
|
||||
"msaa16 msaa4 nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
|
||||
"pdf skp svg xps (and maybe more)");
|
||||
|
||||
DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
|
||||
|
||||
DEFINE_bool(dryRun, false,
|
||||
@ -14,6 +19,11 @@ DEFINE_bool(dryRun, false,
|
||||
|
||||
DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
|
||||
|
||||
DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
|
||||
"forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
|
||||
"Defaults to empty string, which selects the API native to the "
|
||||
"system.");
|
||||
|
||||
DEFINE_string(images, "", "Directory of images to decode.");
|
||||
|
||||
DEFINE_string2(match, m, nullptr,
|
||||
|
@ -10,9 +10,11 @@
|
||||
|
||||
#include "SkCommandLineFlags.h"
|
||||
|
||||
DECLARE_string(config);
|
||||
DECLARE_bool(cpu);
|
||||
DECLARE_bool(dryRun);
|
||||
DECLARE_bool(gpu);
|
||||
DECLARE_string(gpuAPI);
|
||||
DECLARE_string(images);
|
||||
DECLARE_string(match);
|
||||
DECLARE_bool(quiet);
|
||||
|
@ -1,336 +0,0 @@
|
||||
/*
|
||||
* 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 "SkCommonFlagsConfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char defaultConfigs[] =
|
||||
"565 8888 gpu nonrendering"
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
" angle"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
" hwui"
|
||||
#endif
|
||||
;
|
||||
|
||||
static const char configHelp[] =
|
||||
"Options: 565 8888 debug gpu gpudebug gpudft gpunull "
|
||||
"msaa16 msaa4 nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
|
||||
"pdf pdf_poppler skp svg xps"
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
" angle"
|
||||
#endif
|
||||
" angle-gl"
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
" commandbuffer"
|
||||
#endif
|
||||
#if SK_MESA
|
||||
" mesa"
|
||||
#endif
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
" hwui"
|
||||
#endif
|
||||
" or use extended form 'backend(option=value,...)'.\n";
|
||||
|
||||
static const char configExtendedHelp[] =
|
||||
"Extended form: 'backend(option=value,...)'\n\n"
|
||||
"Possible backends and options:\n"
|
||||
#if SK_SUPPORT_GPU
|
||||
"\n"
|
||||
"gpu(api=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n"
|
||||
"\tapi\ttype: string\tdefault: native.\n"
|
||||
"\t Select graphics API to use with gpu backend.\n"
|
||||
"\t Options:\n"
|
||||
"\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n"
|
||||
"\t\tgl \t\t\tUse OpenGL.\n"
|
||||
"\t\tgles \t\t\tUse OpenGL ES.\n"
|
||||
"\t\tdebug \t\t\tUse debug OpenGL.\n"
|
||||
"\t\tnull \t\t\tUse null OpenGL.\n"
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
"\t\tangle\t\t\tUse ANGLE DirectX.\n"
|
||||
#endif
|
||||
"\t\tangle-gl\t\t\tUse ANGLE OpenGL.\n"
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
"\t\tcommandbuffer\t\tUse command buffer.\n"
|
||||
#endif
|
||||
#if SK_MESA
|
||||
"\t\tmesa\t\t\tUse MESA.\n"
|
||||
#endif
|
||||
"\tdit\ttype: bool\tdefault: false.\n"
|
||||
"\t Use device independent text.\n"
|
||||
"\tnvpr\ttype: bool\tdefault: false.\n"
|
||||
"\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
|
||||
"\tsamples\ttype: int\tdefault: 0.\n"
|
||||
"\t Use multisampling with N samples.\n"
|
||||
"\n"
|
||||
"Predefined configs:\n\n"
|
||||
"\tgpu \t= gpu()\n"
|
||||
"\tmsaa4 \t= gpu(samples=4)\n"
|
||||
"\tmsaa16 \t= gpu(samples=16)\n"
|
||||
"\tnvprmsaa4\t= gpu(nvpr=true,samples=4)\n"
|
||||
"\tnvprmsaa16\t= gpu(nvpr=true,samples=16)\n"
|
||||
"\tgpudft \t= gpu(dit=true)\n"
|
||||
"\tgpudebug \t= gpu(api=debug)\n"
|
||||
"\tgpunull \t= gpu(api=null)\n"
|
||||
"\tdebug \t= gpu(api=debug)\n"
|
||||
"\tnullgpu \t= gpu(api=null)\n"
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
"\tangle \t= gpu(api=angle)\n"
|
||||
#endif
|
||||
"\tangle-gl \t= gpu(api=angle-gl)\n"
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
"\tcommandbuffer\t= gpu(api=commandbuffer)\n"
|
||||
#endif
|
||||
#if SK_MESA
|
||||
"\tmesa \t= gpu(api=mesa)\n"
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp);
|
||||
|
||||
static const struct {
|
||||
const char* predefinedConfig;
|
||||
const char* backend;
|
||||
const char* options;
|
||||
} gPredefinedConfigs[] = {
|
||||
#if SK_SUPPORT_GPU
|
||||
{ "gpu", "gpu", "" },
|
||||
{ "msaa4", "gpu", "samples=4" },
|
||||
{ "msaa16", "gpu", "samples=16" },
|
||||
{ "nvprmsaa4", "gpu", "nvpr=true,samples=4" },
|
||||
{ "nvprmsaa16", "gpu", "nvpr=true,samples=16" },
|
||||
{ "gpudft", "gpu", "dit=true" },
|
||||
{ "gpudebug", "gpu", "api=debug" },
|
||||
{ "gpunull", "gpu", "api=null" },
|
||||
{ "debug", "gpu", "api=debug" },
|
||||
{ "nullgpu", "gpu", "api=null" }
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
, { "angle", "gpu", "api=angle" }
|
||||
#endif
|
||||
, { "angle-gl", "gpu", "api=angle-gl" }
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
, { "commandbuffer", "gpu", "api=commandbuffer" }
|
||||
#endif
|
||||
#if SK_MESA
|
||||
, { "mesa", "gpu", "api=mesa" }
|
||||
#endif
|
||||
#else
|
||||
{ "", "", "" }
|
||||
#endif
|
||||
};
|
||||
|
||||
SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& backend,
|
||||
const SkTArray<SkString>& viaParts)
|
||||
: fTag(tag)
|
||||
, fBackend(backend)
|
||||
, fViaParts(viaParts) {
|
||||
}
|
||||
SkCommandLineConfig::~SkCommandLineConfig() {
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
|
||||
const SkString& tag, const SkTArray<SkString>& viaParts,
|
||||
ContextType contextType, bool useNVPR, bool useDIText, int samples)
|
||||
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
|
||||
, fContextType(contextType)
|
||||
, fUseNVPR(useNVPR)
|
||||
, fUseDIText(useDIText)
|
||||
, fSamples(samples) {
|
||||
}
|
||||
static bool parse_option_int(const SkString& value, int* outInt) {
|
||||
if (value.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
char* endptr = nullptr;
|
||||
long intValue = strtol(value.c_str(), &endptr, 10);
|
||||
if (*endptr != '\0') {
|
||||
return false;
|
||||
}
|
||||
*outInt = static_cast<int>(intValue);
|
||||
return true;
|
||||
}
|
||||
static bool parse_option_bool(const SkString& value, bool* outBool) {
|
||||
if (value.equals("true")) {
|
||||
*outBool = true;
|
||||
return true;
|
||||
}
|
||||
if (value.equals("false")) {
|
||||
*outBool = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool parse_option_gpu_api(const SkString& value,
|
||||
SkCommandLineConfigGpu::ContextType* outContextType) {
|
||||
if (value.equals("native")) {
|
||||
*outContextType = GrContextFactory::kNative_GLContextType;
|
||||
return true;
|
||||
}
|
||||
if (value.equals("gl")) {
|
||||
*outContextType = GrContextFactory::kGL_GLContextType;
|
||||
return true;
|
||||
}
|
||||
if (value.equals("gles")) {
|
||||
*outContextType = GrContextFactory::kGLES_GLContextType;
|
||||
return true;
|
||||
}
|
||||
if (value.equals("debug")) {
|
||||
*outContextType = GrContextFactory::kDebug_GLContextType;
|
||||
return true;
|
||||
}
|
||||
if (value.equals("null")) {
|
||||
*outContextType = GrContextFactory::kNull_GLContextType;
|
||||
return true;
|
||||
}
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
if (value.equals("angle")) {
|
||||
*outContextType = GrContextFactory::kANGLE_GLContextType;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
if (value.equals("angle-gl")) {
|
||||
*outContextType = GrContextFactory::kANGLE_GL_GLContextType;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
if (value.equals("commandbuffer")) {
|
||||
*outContextType = GrContextFactory::kCommandBuffer_GLContextType;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if SK_MESA
|
||||
if (value.equals("mesa")) {
|
||||
*outContextType = GrContextFactory::kMESA_GLContextType;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
|
||||
const SkTArray<SkString>& vias,
|
||||
const SkString& options) {
|
||||
// Defaults for GPU backend.
|
||||
bool seenAPI = false;
|
||||
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_GLContextType;
|
||||
bool seenUseNVPR = false;
|
||||
bool useNVPR = false;
|
||||
bool seenUseDIText =false;
|
||||
bool useDIText = false;
|
||||
bool seenSamples = false;
|
||||
int samples = 0;
|
||||
|
||||
SkTArray<SkString> optionParts;
|
||||
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
|
||||
for (int i = 0; i < optionParts.count(); ++i) {
|
||||
SkTArray<SkString> keyValueParts;
|
||||
SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValueParts);
|
||||
if (keyValueParts.count() != 2) {
|
||||
return nullptr;
|
||||
}
|
||||
const SkString& key = keyValueParts[0];
|
||||
const SkString& value = keyValueParts[1];
|
||||
bool valueOk = false;
|
||||
if (key.equals("api") && !seenAPI) {
|
||||
valueOk = parse_option_gpu_api(value, &contextType);
|
||||
seenAPI = true;
|
||||
} else if (key.equals("nvpr") && !seenUseNVPR) {
|
||||
valueOk = parse_option_bool(value, &useNVPR);
|
||||
seenUseNVPR = true;
|
||||
} else if (key.equals("dit") && !seenUseDIText) {
|
||||
valueOk = parse_option_bool(value, &useDIText);
|
||||
seenUseDIText = true;
|
||||
} else if (key.equals("samples") && !seenSamples) {
|
||||
valueOk = parse_option_int(value, &samples);
|
||||
seenSamples = true;
|
||||
}
|
||||
if (!valueOk) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ParseConfigs(const SkCommandLineFlags::StringArray& configs,
|
||||
SkCommandLineConfigArray* outResult) {
|
||||
outResult->reset();
|
||||
for (int i = 0; i < configs.count(); ++i) {
|
||||
SkString extendedBackend;
|
||||
SkString extendedOptions;
|
||||
SkString simpleBackend;
|
||||
SkTArray<SkString> vias;
|
||||
|
||||
SkString tag(configs[i]);
|
||||
SkTArray<SkString> parts;
|
||||
SkStrSplit(tag.c_str(), "(", kStrict_SkStrSplitMode, &parts);
|
||||
if (parts.count() == 2) {
|
||||
SkTArray<SkString> parts2;
|
||||
SkStrSplit(parts[1].c_str(), ")", kStrict_SkStrSplitMode, &parts2);
|
||||
if (parts2.count() == 2 && parts2[1].isEmpty()) {
|
||||
SkStrSplit(parts[0].c_str(), "-", kStrict_SkStrSplitMode, &vias);
|
||||
if (vias.count()) {
|
||||
extendedBackend = vias[vias.count() - 1];
|
||||
vias.pop_back();
|
||||
} else {
|
||||
extendedBackend = parts[0];
|
||||
}
|
||||
extendedOptions = parts2[0];
|
||||
simpleBackend.printf("%s(%s)", extendedBackend.c_str(), extendedOptions.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (extendedBackend.isEmpty()) {
|
||||
simpleBackend = tag;
|
||||
SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias);
|
||||
if (vias.count()) {
|
||||
simpleBackend = vias[vias.count() - 1];
|
||||
vias.pop_back();
|
||||
}
|
||||
// Note: no #if SK_ANGLE: this is a special rule in the via-tag grammar.
|
||||
if (vias.count() && simpleBackend.equals("gl") &&
|
||||
vias[vias.count() - 1].equals("angle")) {
|
||||
simpleBackend = "angle-gl";
|
||||
vias.pop_back();
|
||||
}
|
||||
|
||||
for (auto& predefinedConfig : gPredefinedConfigs) {
|
||||
if (simpleBackend.equals(predefinedConfig.predefinedConfig)) {
|
||||
extendedBackend = predefinedConfig.backend;
|
||||
extendedOptions = predefinedConfig.options;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SkCommandLineConfig* parsedConfig = nullptr;
|
||||
#if SK_SUPPORT_GPU
|
||||
if (extendedBackend.equals("gpu")) {
|
||||
parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOptions);
|
||||
}
|
||||
#endif
|
||||
if (!parsedConfig) {
|
||||
parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
|
||||
}
|
||||
outResult->emplace_back(parsedConfig);
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SK_COMMON_FLAGS_CONFIG_H
|
||||
#define SK_COMMON_FLAGS_CONFIG_H
|
||||
|
||||
#include "SkCommandLineFlags.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContextFactory.h"
|
||||
#endif
|
||||
|
||||
DECLARE_string(config);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
class SkCommandLineConfigGpu;
|
||||
#endif
|
||||
|
||||
// SkCommandLineConfig represents a Skia rendering configuration string.
|
||||
// The string has following form:
|
||||
// tag:
|
||||
// [via-]*backend
|
||||
// where 'backend' consists of chars excluding hyphen or "angle-gl"
|
||||
// and each 'via' consists of chars excluding hyphen.
|
||||
class SkCommandLineConfig {
|
||||
public:
|
||||
SkCommandLineConfig(const SkString& tag, const SkString& backend,
|
||||
const SkTArray<SkString>& viaParts);
|
||||
virtual ~SkCommandLineConfig();
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual const SkCommandLineConfigGpu* asConfigGpu() const { return nullptr; }
|
||||
#endif
|
||||
const SkString& getTag() const { return fTag; }
|
||||
const SkString& getBackend() const { return fBackend; }
|
||||
const SkTArray<SkString>& getViaParts() const { return fViaParts; }
|
||||
private:
|
||||
SkString fTag;
|
||||
SkString fBackend;
|
||||
SkTArray<SkString> fViaParts;
|
||||
};
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
// SkCommandLineConfigGpu is a SkCommandLineConfig that extracts information out of the backend
|
||||
// part of the tag. It is constructed tags that have:
|
||||
// * backends of form "gpu(option=value,option2=value,...)"
|
||||
// * backends that represent a shorthand of above (such as "msaa16" representing "gpu(samples=16)")
|
||||
class SkCommandLineConfigGpu : public SkCommandLineConfig {
|
||||
public:
|
||||
typedef GrContextFactory::GLContextType ContextType;
|
||||
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
|
||||
ContextType contextType, bool useNVPR, bool useDIText, int samples);
|
||||
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
|
||||
ContextType getContextType() const { return fContextType; }
|
||||
bool getUseNVPR() const { return fUseNVPR; }
|
||||
bool getUseDIText() const { return fUseDIText; }
|
||||
int getSamples() const { return fSamples; }
|
||||
|
||||
private:
|
||||
ContextType fContextType;
|
||||
bool fUseNVPR;
|
||||
bool fUseDIText;
|
||||
int fSamples;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef SkTArray<SkAutoTDelete<SkCommandLineConfig>, true> SkCommandLineConfigArray;
|
||||
void ParseConfigs(const SkCommandLineFlags::StringArray& configList,
|
||||
SkCommandLineConfigArray* outResult);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user