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 28 matching lines...) Expand all Loading... |
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_int32(multi, 1, "Set the number of threads for multi threaded drawing. " | 69 DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. " |
72 "If > 1, requires tiled rendering."); | 70 "If > 1, requires tiled rendering."); |
73 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\"."); |
74 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."); |
75 DEFINE_double(scale, 1, "Set the scale factor."); | 73 DEFINE_double(scale, 1, "Set the scale factor."); |
76 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 " |
77 "in the x and y directions."); | 75 "in the x and y directions."); |
78 DEFINE_string(viewport, "", "width height: Set the viewport."); | 76 DEFINE_string(viewport, "", "width height: Set the viewport."); |
79 #if SK_SUPPORT_GPU | |
80 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " | |
81 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | |
82 "Defaults to empty string, which selects the API native to the " | |
83 "system."); | |
84 #endif | |
85 | 77 |
86 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { | 78 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { |
87 error.reset(); | 79 error.reset(); |
88 | 80 |
89 if (FLAGS_multi <= 0) { | 81 if (FLAGS_multi <= 0) { |
90 error.printf("--multi must be > 0, was %i", FLAGS_multi); | 82 error.printf("--multi must be > 0, was %i", FLAGS_multi); |
91 return NULL; | 83 return NULL; |
92 } | 84 } |
93 | 85 |
94 bool useTiles = false; | 86 bool useTiles = false; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 254 } |
263 SkISize viewport; | 255 SkISize viewport; |
264 viewport.fWidth = atoi(FLAGS_viewport[0]); | 256 viewport.fWidth = atoi(FLAGS_viewport[0]); |
265 viewport.fHeight = atoi(FLAGS_viewport[1]); | 257 viewport.fHeight = atoi(FLAGS_viewport[1]); |
266 renderer->setViewport(viewport); | 258 renderer->setViewport(viewport); |
267 } | 259 } |
268 | 260 |
269 sk_tools::PictureRenderer::SkDeviceTypes deviceType = | 261 sk_tools::PictureRenderer::SkDeviceTypes deviceType = |
270 sk_tools::PictureRenderer::kBitmap_DeviceType; | 262 sk_tools::PictureRenderer::kBitmap_DeviceType; |
271 #if SK_SUPPORT_GPU | 263 #if SK_SUPPORT_GPU |
272 GrGLStandard gpuAPI = kNone_GrGLStandard; | |
273 if (1 == FLAGS_gpuAPI.count()) { | |
274 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) { | |
275 gpuAPI = kGL_GrGLStandard; | |
276 } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) { | |
277 gpuAPI = kGLES_GrGLStandard; | |
278 } else { | |
279 error.printf("--gpuAPI invalid api value.\n"); | |
280 return NULL; | |
281 } | |
282 } else if (FLAGS_gpuAPI.count() > 1) { | |
283 error.printf("--gpuAPI invalid api value.\n"); | |
284 return NULL; | |
285 } | |
286 | |
287 int sampleCount = 0; | 264 int sampleCount = 0; |
288 #endif | 265 #endif |
289 if (FLAGS_config.count() > 0) { | 266 if (FLAGS_config.count() > 0) { |
290 if (0 == strcmp(FLAGS_config[0], "8888")) { | 267 if (0 == strcmp(FLAGS_config[0], "8888")) { |
291 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; | 268 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; |
292 } | 269 } |
293 #if SK_SUPPORT_GPU | 270 #if SK_SUPPORT_GPU |
294 else if (0 == strcmp(FLAGS_config[0], "gpu")) { | 271 else if (0 == strcmp(FLAGS_config[0], "gpu")) { |
295 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; | 272 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; |
296 if (FLAGS_multi > 1) { | 273 if (FLAGS_multi > 1) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 error.printf("Mesa not compatible with multithreaded tiling.\n")
; | 323 error.printf("Mesa not compatible with multithreaded tiling.\n")
; |
347 return NULL; | 324 return NULL; |
348 } | 325 } |
349 } | 326 } |
350 #endif | 327 #endif |
351 #endif | 328 #endif |
352 else { | 329 else { |
353 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); | 330 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0
]); |
354 return NULL; | 331 return NULL; |
355 } | 332 } |
356 #if SK_SUPPORT_GPU | 333 renderer->setDeviceType(deviceType); |
357 if (!renderer->setDeviceType(deviceType, gpuAPI)) { | |
358 #else | |
359 if (!renderer->setDeviceType(deviceType)) { | |
360 #endif | |
361 error.printf("Could not create backend for --config %s\n", FLAGS_con
fig[0]); | |
362 return NULL; | |
363 } | |
364 #if SK_SUPPORT_GPU | 334 #if SK_SUPPORT_GPU |
365 renderer->setSampleCount(sampleCount); | 335 renderer->setSampleCount(sampleCount); |
366 #endif | 336 #endif |
367 } | 337 } |
368 | 338 |
369 | 339 |
370 sk_tools::PictureRenderer::BBoxHierarchyType bbhType | 340 sk_tools::PictureRenderer::BBoxHierarchyType bbhType |
371 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; | 341 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; |
372 if (FLAGS_bbh.count() > 0) { | 342 if (FLAGS_bbh.count() > 0) { |
373 const char* type = FLAGS_bbh[0]; | 343 const char* type = FLAGS_bbh[0]; |
(...skipping 24 matching lines...) Expand all Loading... |
398 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { | 368 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { |
399 error.printf("--pipe and --bbh cannot be used together\n"); | 369 error.printf("--pipe and --bbh cannot be used together\n"); |
400 return NULL; | 370 return NULL; |
401 } | 371 } |
402 } | 372 } |
403 renderer->setBBoxHierarchyType(bbhType); | 373 renderer->setBBoxHierarchyType(bbhType); |
404 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); | 374 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); |
405 | 375 |
406 return renderer.detach(); | 376 return renderer.detach(); |
407 } | 377 } |
OLD | NEW |