Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / tools / PictureRenderingFlags.cpp
index 5acec26..ccec158 100644 (file)
@@ -26,6 +26,8 @@ DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarc
 
 
 #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 ""
@@ -66,23 +68,22 @@ DEFINE_string(mode, "simple", "Run in the corresponding mode:\n"
               "\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;
@@ -97,9 +98,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
         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;
@@ -170,9 +168,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
                 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));
         }
@@ -230,10 +225,6 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
         }
 
     } 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");
@@ -261,6 +252,21 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
     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) {
@@ -270,59 +276,31 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
 #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
@@ -330,7 +308,14 @@ sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
             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