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"; |
29 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16" | 31 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16" |
30 #else | 32 #else |
31 #define GPU_CONFIG_STRING "" | 33 #define GPU_CONFIG_STRING "" |
32 #endif | 34 #endif |
33 #if SK_ANGLE | 35 #if SK_ANGLE |
34 #define ANGLE_CONFIG_STRING "|angle" | 36 #define ANGLE_CONFIG_STRING "|angle" |
35 #else | 37 #else |
36 #define ANGLE_CONFIG_STRING "" | 38 #define ANGLE_CONFIG_STRING "" |
37 #endif | 39 #endif |
38 #if SK_MESA | 40 #if SK_MESA |
(...skipping 26 matching lines...) Expand all Loading... |
65 "playbackCreation: (Only in bench_pictures) Time creation of the \
n" | 67 "playbackCreation: (Only in bench_pictures) Time creation of the \
n" |
66 "\tSkPicturePlayback.\n" | 68 "\tSkPicturePlayback.\n" |
67 "rerecord: (Only in render_pictures) Record the picture as a new s
kp,\n" | 69 "rerecord: (Only in render_pictures) Record the picture as a new s
kp,\n" |
68 "\twith the bitmaps PNG encoded.\n"); | 70 "\twith the bitmaps PNG encoded.\n"); |
69 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m
ode\"."); | 71 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m
ode\"."); |
70 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces
s."); | 72 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces
s."); |
71 DEFINE_double(scale, 1, "Set the scale factor."); | 73 DEFINE_double(scale, 1, "Set the scale factor."); |
72 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p
er larger tile " | 74 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p
er larger tile " |
73 "in the x and y directions."); | 75 "in the x and y directions."); |
74 DEFINE_string(viewport, "", "width height: Set the viewport."); | 76 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 |
75 | 83 |
76 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { | 84 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { |
77 error.reset(); | 85 error.reset(); |
78 | 86 |
79 bool useTiles = false; | 87 bool useTiles = false; |
80 const char* widthString = NULL; | 88 const char* widthString = NULL; |
81 const char* heightString = NULL; | 89 const char* heightString = NULL; |
82 bool isPowerOf2Mode = false; | 90 bool isPowerOf2Mode = false; |
83 bool isCopyMode = false; | 91 bool isCopyMode = false; |
84 const char* mode = NULL; | 92 const char* mode = NULL; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 245 } |
238 SkISize viewport; | 246 SkISize viewport; |
239 viewport.fWidth = atoi(FLAGS_viewport[0]); | 247 viewport.fWidth = atoi(FLAGS_viewport[0]); |
240 viewport.fHeight = atoi(FLAGS_viewport[1]); | 248 viewport.fHeight = atoi(FLAGS_viewport[1]); |
241 renderer->setViewport(viewport); | 249 renderer->setViewport(viewport); |
242 } | 250 } |
243 | 251 |
244 sk_tools::PictureRenderer::SkDeviceTypes deviceType = | 252 sk_tools::PictureRenderer::SkDeviceTypes deviceType = |
245 sk_tools::PictureRenderer::kBitmap_DeviceType; | 253 sk_tools::PictureRenderer::kBitmap_DeviceType; |
246 #if SK_SUPPORT_GPU | 254 #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 |
247 int sampleCount = 0; | 270 int sampleCount = 0; |
248 #endif | 271 #endif |
249 if (FLAGS_config.count() > 0) { | 272 if (FLAGS_config.count() > 0) { |
250 if (0 == strcmp(FLAGS_config[0], "8888")) { | 273 if (0 == strcmp(FLAGS_config[0], "8888")) { |
251 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; | 274 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; |
252 } | 275 } |
253 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
254 else if (0 == strcmp(FLAGS_config[0], "gpu")) { | 277 else if (0 == strcmp(FLAGS_config[0], "gpu")) { |
255 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; | 278 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; |
256 } | 279 } |
(...skipping 21 matching lines...) Expand all Loading... |
278 #if SK_MESA | 301 #if SK_MESA |
279 else if (0 == strcmp(FLAGS_config[0], "mesa")) { | 302 else if (0 == strcmp(FLAGS_config[0], "mesa")) { |
280 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType; | 303 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType; |
281 } | 304 } |
282 #endif | 305 #endif |
283 #endif | 306 #endif |
284 else { | 307 else { |
285 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); | 308 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); |
286 return NULL; | 309 return NULL; |
287 } | 310 } |
288 renderer->setDeviceType(deviceType); | 311 #if SK_SUPPORT_GPU |
| 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 } |
289 #if SK_SUPPORT_GPU | 319 #if SK_SUPPORT_GPU |
290 renderer->setSampleCount(sampleCount); | 320 renderer->setSampleCount(sampleCount); |
291 #endif | 321 #endif |
292 } | 322 } |
293 | 323 |
294 | 324 |
295 sk_tools::PictureRenderer::BBoxHierarchyType bbhType | 325 sk_tools::PictureRenderer::BBoxHierarchyType bbhType |
296 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; | 326 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; |
297 if (FLAGS_bbh.count() > 0) { | 327 if (FLAGS_bbh.count() > 0) { |
298 const char* type = FLAGS_bbh[0]; | 328 const char* type = FLAGS_bbh[0]; |
(...skipping 24 matching lines...) Expand all Loading... |
323 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { | 353 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { |
324 error.printf("--pipe and --bbh cannot be used together\n"); | 354 error.printf("--pipe and --bbh cannot be used together\n"); |
325 return NULL; | 355 return NULL; |
326 } | 356 } |
327 } | 357 } |
328 renderer->setBBoxHierarchyType(bbhType); | 358 renderer->setBBoxHierarchyType(bbhType); |
329 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); | 359 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); |
330 | 360 |
331 return renderer.detach(); | 361 return renderer.detach(); |
332 } | 362 } |
OLD | NEW |