| Index: gm/gmmain.cpp
|
| diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
|
| index b73971441c78e7590a01776597534e213d8fde8b..6773f1b5210edffdbe7d3e8cde2b041a16fb47cb 100644
|
| --- a/gm/gmmain.cpp
|
| +++ b/gm/gmmain.cpp
|
| @@ -65,6 +65,7 @@ class GrContextFactory;
|
| class GrContext;
|
| class GrSurface;
|
| typedef int GLContextType;
|
| +typedef int GrGLStandard;
|
| #endif
|
|
|
| #define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message")
|
| @@ -1341,6 +1342,10 @@ static const PDFRasterizerData kPDFRasterizers[] = {
|
|
|
| static const char kDefaultsConfigStr[] = "defaults";
|
| static const char kExcludeConfigChar = '~';
|
| +#if SK_SUPPORT_GPU
|
| +static const char kGpuApiNameGL[] = "gl";
|
| +static const char kGpuApiNameGLES[] = "gles";
|
| +#endif
|
|
|
| static SkString configUsage() {
|
| SkString result;
|
| @@ -1430,6 +1435,10 @@ DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
|
| DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip.");
|
| DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing.");
|
| #if SK_SUPPORT_GPU
|
| +DEFINE_string(forceGpuApi, "", "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(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte size or "
|
| "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means "
|
| "use the default. 0 for either disables the cache.");
|
| @@ -1711,12 +1720,14 @@ ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm,
|
| const SkTDArray<size_t> &configs,
|
| const SkTDArray<const PDFRasterizerData*> &pdfRasterizers,
|
| const SkTDArray<SkScalar> &tileGridReplayScales,
|
| - GrContextFactory *grFactory);
|
| + GrContextFactory *grFactory,
|
| + GrGLStandard forcedGpuApi);
|
| ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm,
|
| const SkTDArray<size_t> &configs,
|
| const SkTDArray<const PDFRasterizerData*> &pdfRasterizers,
|
| const SkTDArray<SkScalar> &tileGridReplayScales,
|
| - GrContextFactory *grFactory) {
|
| + GrContextFactory *grFactory,
|
| + GrGLStandard forcedGpuApi) {
|
| const char renderModeDescriptor[] = "";
|
| ErrorCombination errorsForAllConfigs;
|
| uint32_t gmFlags = gm->getFlags();
|
| @@ -1766,7 +1777,7 @@ ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm,
|
| if (FLAGS_resetGpuContext) {
|
| grFactory->destroyContexts();
|
| }
|
| - GrContext* gr = grFactory->get(config.fGLContextType);
|
| + GrContext* gr = grFactory->get(config.fGLContextType, forcedGpuApi);
|
| bool grSuccess = false;
|
| if (gr) {
|
| // create a render target to back the device
|
| @@ -1937,7 +1948,7 @@ static bool prepare_subdirectories(const char *root, bool useFileHierarchy,
|
| }
|
|
|
| static bool parse_flags_configs(SkTDArray<size_t>* outConfigs,
|
| - GrContextFactory* grFactory) {
|
| + GrContextFactory* grFactory, GrGLStandard forcedGpuApi) {
|
| SkTDArray<size_t> excludeConfigs;
|
|
|
| for (int i = 0; i < FLAGS_config.count(); i++) {
|
| @@ -2004,7 +2015,7 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs,
|
| for (int i = 0; i < outConfigs->count(); ++i) {
|
| size_t index = (*outConfigs)[i];
|
| if (kGPU_Backend == gRec[index].fBackend) {
|
| - GrContext* ctx = grFactory->get(gRec[index].fGLContextType);
|
| + GrContext* ctx = grFactory->get(gRec[index].fGLContextType, forcedGpuApi);
|
| if (NULL == ctx) {
|
| SkDebugf("GrContext could not be created for config %s. Config will be skipped.\n",
|
| gRec[index].fName);
|
| @@ -2158,6 +2169,24 @@ static bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) {
|
| }
|
| return true;
|
| }
|
| +
|
| +static bool parse_flags_gpu_api(GrGLStandard* forcedGpuApi) {
|
| + if (0 == FLAGS_forceGpuApi.count()) {
|
| + *forcedGpuApi = kNone_GrGLStandard;
|
| + return true;
|
| + }
|
| + if (1 == FLAGS_forceGpuApi.count()) {
|
| + if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGL) == 0) {
|
| + *forcedGpuApi = kGL_GrGLStandard;
|
| + return true;
|
| + } else if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGLES) == 0) {
|
| + *forcedGpuApi = kGLES_GrGLStandard;
|
| + return true;
|
| + }
|
| + }
|
| + SkDebugf("--forceGpuApi invalid api value");
|
| + return false;
|
| +}
|
| #endif
|
|
|
| static bool parse_flags_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales) {
|
| @@ -2256,8 +2285,10 @@ int tool_main(int argc, char** argv) {
|
| SkTDArray<const PDFRasterizerData*> pdfRasterizers;
|
| SkTDArray<SkScalar> tileGridReplayScales;
|
| #if SK_SUPPORT_GPU
|
| + GrGLStandard forcedGpuApi = kNone_GrGLStandard;
|
| GrContextFactory* grFactory = new GrContextFactory;
|
| #else
|
| + GrGLStandard forcedGpuApi = 0;
|
| GrContextFactory* grFactory = NULL;
|
| #endif
|
|
|
| @@ -2270,11 +2301,12 @@ int tool_main(int argc, char** argv) {
|
| !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) ||
|
| #if SK_SUPPORT_GPU
|
| !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) ||
|
| + !parse_flags_gpu_api(&forcedGpuApi) ||
|
| #endif
|
| !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) ||
|
| !parse_flags_resource_path() ||
|
| !parse_flags_jpeg_quality() ||
|
| - !parse_flags_configs(&configs, grFactory) ||
|
| + !parse_flags_configs(&configs, grFactory, forcedGpuApi) ||
|
| !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) ||
|
| !parse_flags_gmmain_paths(&gmmain)) {
|
| return -1;
|
| @@ -2356,7 +2388,8 @@ int tool_main(int argc, char** argv) {
|
| SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName,
|
| size.width(), size.height());
|
| if (!FLAGS_dryRun)
|
| - run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplayScales, grFactory);
|
| + run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplayScales,
|
| + grFactory, forcedGpuApi);
|
| }
|
|
|
| if (FLAGS_dryRun)
|
| @@ -2435,7 +2468,7 @@ int tool_main(int argc, char** argv) {
|
| ConfigData config = gRec[configs[i]];
|
|
|
| if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) {
|
| - GrContext* gr = grFactory->get(config.fGLContextType);
|
| + GrContext* gr = grFactory->get(config.fGLContextType, forcedGpuApi);
|
|
|
| SkDebugf("config: %s %x\n", config.fName, gr);
|
| gr->printCacheStats();
|
| @@ -2448,7 +2481,7 @@ int tool_main(int argc, char** argv) {
|
| ConfigData config = gRec[configs[i]];
|
|
|
| if (kGPU_Backend == config.fBackend) {
|
| - GrContext* gr = grFactory->get(config.fGLContextType);
|
| + GrContext* gr = grFactory->get(config.fGLContextType, forcedGpuApi);
|
|
|
| gr->dumpFontCache();
|
| }
|
|
|