#if SK_SUPPORT_GPU
+static const char kGpuAPINameGL[] = "gl";
+static const char kGpuAPINameGLES[] = "gles";
#define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16"
#else
#define GPU_CONFIG_STRING ""
"\tSkPicturePlayback.\n"
"rerecord: (Only in render_pictures) Record the picture as a new skp,\n"
"\twith the bitmaps PNG encoded.\n");
-DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. "
- "If > 1, requires tiled rendering.");
DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"mode\".");
DEFINE_string2(readPath, r, "", "skp files or directories of skp files to process.");
DEFINE_double(scale, 1, "Set the scale factor.");
DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles per larger tile "
"in the x and y directions.");
DEFINE_string(viewport, "", "width height: Set the viewport.");
+#if SK_SUPPORT_GPU
+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.");
+#endif
sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
error.reset();
- if (FLAGS_multi <= 0) {
- error.printf("--multi must be > 0, was %i", FLAGS_multi);
- return NULL;
- }
-
bool useTiles = false;
const char* widthString = NULL;
const char* heightString = NULL;
if (0 == strcmp(mode, "record")) {
renderer.reset(SkNEW(sk_tools::RecordPictureRenderer));
gridSupported = true;
- // undocumented
- } else if (0 == strcmp(mode, "clone")) {
- renderer.reset(sk_tools::CreatePictureCloneRenderer());
} else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile")
|| 0 == strcmp(mode, "copyTile")) {
useTiles = true;
x = y = 4;
}
tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y)));
- } else if (FLAGS_multi > 1) {
- tiledRenderer.reset(SkNEW_ARGS(sk_tools::MultiCorePictureRenderer,
- (FLAGS_multi)));
} else {
tiledRenderer.reset(SkNEW(sk_tools::TiledPictureRenderer));
}
}
} else { // useTiles
- if (FLAGS_multi > 1) {
- error.printf("Multithreaded drawing requires tiled rendering.\n");
- return NULL;
- }
if (FLAGS_pipe) {
if (renderer != NULL) {
error.printf("Pipe is incompatible with other modes.\n");
sk_tools::PictureRenderer::SkDeviceTypes deviceType =
sk_tools::PictureRenderer::kBitmap_DeviceType;
#if SK_SUPPORT_GPU
+ GrGLStandard gpuAPI = kNone_GrGLStandard;
+ if (1 == FLAGS_gpuAPI.count()) {
+ if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) {
+ gpuAPI = kGL_GrGLStandard;
+ } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) {
+ gpuAPI = kGLES_GrGLStandard;
+ } else {
+ error.printf("--gpuAPI invalid api value.\n");
+ return NULL;
+ }
+ } else if (FLAGS_gpuAPI.count() > 1) {
+ error.printf("--gpuAPI invalid api value.\n");
+ return NULL;
+ }
+
int sampleCount = 0;
#endif
if (FLAGS_config.count() > 0) {
#if SK_SUPPORT_GPU
else if (0 == strcmp(FLAGS_config[0], "gpu")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
else if (0 == strcmp(FLAGS_config[0], "msaa4")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 4;
}
else if (0 == strcmp(FLAGS_config[0], "msaa16")) {
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 16;
}
else if (0 == strcmp(FLAGS_config[0], "nvprmsaa4")) {
deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 4;
}
else if (0 == strcmp(FLAGS_config[0], "nvprmsaa16")) {
deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("GPU not compatible with multithreaded tiling.\n");
- return NULL;
- }
sampleCount = 16;
}
#if SK_ANGLE
else if (0 == strcmp(FLAGS_config[0], "angle")) {
deviceType = sk_tools::PictureRenderer::kAngle_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("Angle not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
#endif
#if SK_MESA
else if (0 == strcmp(FLAGS_config[0], "mesa")) {
deviceType = sk_tools::PictureRenderer::kMesa_DeviceType;
- if (FLAGS_multi > 1) {
- error.printf("Mesa not compatible with multithreaded tiling.\n");
- return NULL;
- }
}
#endif
#endif
error.printf("%s is not a valid mode for --config\n", FLAGS_config[0]);
return NULL;
}
- renderer->setDeviceType(deviceType);
+#if SK_SUPPORT_GPU
+ if (!renderer->setDeviceType(deviceType, gpuAPI)) {
+#else
+ if (!renderer->setDeviceType(deviceType)) {
+#endif
+ error.printf("Could not create backend for --config %s\n", FLAGS_config[0]);
+ return NULL;
+ }
#if SK_SUPPORT_GPU
renderer->setSampleCount(sampleCount);
#endif