| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "PictureRenderingFlags.h" | 8 #include "PictureRenderingFlags.h" |
| 9 | 9 |
| 10 #include "CopyTilesRenderer.h" | 10 #include "CopyTilesRenderer.h" |
| 11 #include "PictureRenderer.h" | 11 #include "PictureRenderer.h" |
| 12 #include "picture_utils.h" | 12 #include "picture_utils.h" |
| 13 #include "SkCommandLineFlags.h" | 13 #include "SkCommandLineFlags.h" |
| 14 #include "SkData.h" | 14 #include "SkData.h" |
| 15 #include "SkImage.h" | 15 #include "SkImage.h" |
| 16 #include "SkImageDecoder.h" | 16 #include "SkImageDecoder.h" |
| 17 #include "SkString.h" | 17 #include "SkString.h" |
| 18 | 18 |
| 19 // Alphabetized list of flags used by this file or bench_ and render_pictures. | 19 // Alphabetized list of flags used by this file or bench_ and render_pictures. |
| 20 DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarc
hy type to " | 20 DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarc
hy type to " |
| 21 "be used. Accepted values are: none, rtree, quadtree, grid. " | 21 "be used. Accepted values are: none, rtree, quadtree, grid. " |
| 22 "Not compatible with --pipe. With value " | 22 "Not compatible with --pipe. With value " |
| 23 "'grid', width and height must be specified. 'grid' can " | 23 "'grid', width and height must be specified. 'grid' can " |
| 24 "only be used with modes tile, record, and " | 24 "only be used with modes tile, record, and " |
| 25 "playbackCreation."); | 25 "playbackCreation."); |
| 26 | 26 |
| 27 | 27 |
| 28 #if SK_SUPPORT_GPU | 28 #if SK_SUPPORT_GPU |
| 29 static const char kGpuAPINameGL[] = "gl"; | |
| 30 static const char kGpuAPINameGLES[] = "gles"; | |
| 31 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16" | 29 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16" |
| 32 #else | 30 #else |
| 33 #define GPU_CONFIG_STRING "" | 31 #define GPU_CONFIG_STRING "" |
| 34 #endif | 32 #endif |
| 35 #if SK_ANGLE | 33 #if SK_ANGLE |
| 36 #define ANGLE_CONFIG_STRING "|angle" | 34 #define ANGLE_CONFIG_STRING "|angle" |
| 37 #else | 35 #else |
| 38 #define ANGLE_CONFIG_STRING "" | 36 #define ANGLE_CONFIG_STRING "" |
| 39 #endif | 37 #endif |
| 40 #if SK_MESA | 38 #if SK_MESA |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 "playbackCreation: (Only in bench_pictures) Time creation of the \
n" | 65 "playbackCreation: (Only in bench_pictures) Time creation of the \
n" |
| 68 "\tSkPicturePlayback.\n" | 66 "\tSkPicturePlayback.\n" |
| 69 "rerecord: (Only in render_pictures) Record the picture as a new s
kp,\n" | 67 "rerecord: (Only in render_pictures) Record the picture as a new s
kp,\n" |
| 70 "\twith the bitmaps PNG encoded.\n"); | 68 "\twith the bitmaps PNG encoded.\n"); |
| 71 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m
ode\"."); | 69 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m
ode\"."); |
| 72 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces
s."); | 70 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces
s."); |
| 73 DEFINE_double(scale, 1, "Set the scale factor."); | 71 DEFINE_double(scale, 1, "Set the scale factor."); |
| 74 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p
er larger tile " | 72 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p
er larger tile " |
| 75 "in the x and y directions."); | 73 "in the x and y directions."); |
| 76 DEFINE_string(viewport, "", "width height: Set the viewport."); | 74 DEFINE_string(viewport, "", "width height: Set the viewport."); |
| 77 #if SK_SUPPORT_GPU | |
| 78 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " | |
| 79 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | |
| 80 "Defaults to empty string, which selects the API native to the " | |
| 81 "system."); | |
| 82 #endif | |
| 83 | 75 |
| 84 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { | 76 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { |
| 85 error.reset(); | 77 error.reset(); |
| 86 | 78 |
| 87 bool useTiles = false; | 79 bool useTiles = false; |
| 88 const char* widthString = NULL; | 80 const char* widthString = NULL; |
| 89 const char* heightString = NULL; | 81 const char* heightString = NULL; |
| 90 bool isPowerOf2Mode = false; | 82 bool isPowerOf2Mode = false; |
| 91 bool isCopyMode = false; | 83 bool isCopyMode = false; |
| 92 const char* mode = NULL; | 84 const char* mode = NULL; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 237 } |
| 246 SkISize viewport; | 238 SkISize viewport; |
| 247 viewport.fWidth = atoi(FLAGS_viewport[0]); | 239 viewport.fWidth = atoi(FLAGS_viewport[0]); |
| 248 viewport.fHeight = atoi(FLAGS_viewport[1]); | 240 viewport.fHeight = atoi(FLAGS_viewport[1]); |
| 249 renderer->setViewport(viewport); | 241 renderer->setViewport(viewport); |
| 250 } | 242 } |
| 251 | 243 |
| 252 sk_tools::PictureRenderer::SkDeviceTypes deviceType = | 244 sk_tools::PictureRenderer::SkDeviceTypes deviceType = |
| 253 sk_tools::PictureRenderer::kBitmap_DeviceType; | 245 sk_tools::PictureRenderer::kBitmap_DeviceType; |
| 254 #if SK_SUPPORT_GPU | 246 #if SK_SUPPORT_GPU |
| 255 GrGLStandard gpuAPI = kNone_GrGLStandard; | |
| 256 if (1 == FLAGS_gpuAPI.count()) { | |
| 257 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) { | |
| 258 gpuAPI = kGL_GrGLStandard; | |
| 259 } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) { | |
| 260 gpuAPI = kGLES_GrGLStandard; | |
| 261 } else { | |
| 262 error.printf("--gpuAPI invalid api value.\n"); | |
| 263 return NULL; | |
| 264 } | |
| 265 } else if (FLAGS_gpuAPI.count() > 1) { | |
| 266 error.printf("--gpuAPI invalid api value.\n"); | |
| 267 return NULL; | |
| 268 } | |
| 269 | |
| 270 int sampleCount = 0; | 247 int sampleCount = 0; |
| 271 #endif | 248 #endif |
| 272 if (FLAGS_config.count() > 0) { | 249 if (FLAGS_config.count() > 0) { |
| 273 if (0 == strcmp(FLAGS_config[0], "8888")) { | 250 if (0 == strcmp(FLAGS_config[0], "8888")) { |
| 274 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; | 251 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; |
| 275 } | 252 } |
| 276 #if SK_SUPPORT_GPU | 253 #if SK_SUPPORT_GPU |
| 277 else if (0 == strcmp(FLAGS_config[0], "gpu")) { | 254 else if (0 == strcmp(FLAGS_config[0], "gpu")) { |
| 278 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; | 255 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; |
| 279 } | 256 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 301 #if SK_MESA | 278 #if SK_MESA |
| 302 else if (0 == strcmp(FLAGS_config[0], "mesa")) { | 279 else if (0 == strcmp(FLAGS_config[0], "mesa")) { |
| 303 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType; | 280 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType; |
| 304 } | 281 } |
| 305 #endif | 282 #endif |
| 306 #endif | 283 #endif |
| 307 else { | 284 else { |
| 308 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); | 285 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); |
| 309 return NULL; | 286 return NULL; |
| 310 } | 287 } |
| 311 #if SK_SUPPORT_GPU | 288 renderer->setDeviceType(deviceType); |
| 312 if (!renderer->setDeviceType(deviceType, gpuAPI)) { | |
| 313 #else | |
| 314 if (!renderer->setDeviceType(deviceType)) { | |
| 315 #endif | |
| 316 error.printf("Could not create backend for --config %s\n", FLAGS_con
fig[0]); | |
| 317 return NULL; | |
| 318 } | |
| 319 #if SK_SUPPORT_GPU | 289 #if SK_SUPPORT_GPU |
| 320 renderer->setSampleCount(sampleCount); | 290 renderer->setSampleCount(sampleCount); |
| 321 #endif | 291 #endif |
| 322 } | 292 } |
| 323 | 293 |
| 324 | 294 |
| 325 sk_tools::PictureRenderer::BBoxHierarchyType bbhType | 295 sk_tools::PictureRenderer::BBoxHierarchyType bbhType |
| 326 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; | 296 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; |
| 327 if (FLAGS_bbh.count() > 0) { | 297 if (FLAGS_bbh.count() > 0) { |
| 328 const char* type = FLAGS_bbh[0]; | 298 const char* type = FLAGS_bbh[0]; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 353 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { | 323 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { |
| 354 error.printf("--pipe and --bbh cannot be used together\n"); | 324 error.printf("--pipe and --bbh cannot be used together\n"); |
| 355 return NULL; | 325 return NULL; |
| 356 } | 326 } |
| 357 } | 327 } |
| 358 renderer->setBBoxHierarchyType(bbhType); | 328 renderer->setBBoxHierarchyType(bbhType); |
| 359 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); | 329 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); |
| 360 | 330 |
| 361 return renderer.detach(); | 331 return renderer.detach(); |
| 362 } | 332 } |
| OLD | NEW |