Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: tools/PictureRenderingFlags.cpp

Issue 338633011: Deprecate SkPicture::clone(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add define for chrome Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 "\tpicture is large enough, it is broken into larger tiles to avoi d\n" 59 "\tpicture is large enough, it is broken into larger tiles to avoi d\n"
60 "\tcreating a large canvas.\n" 60 "\tcreating a large canvas.\n"
61 // TODO: If bench_pictures and render_pictures were two separate targets, we cou ld use build flags 61 // TODO: If bench_pictures and render_pictures were two separate targets, we cou ld use build flags
62 // to determine which modes to display. 62 // to determine which modes to display.
63 "record: (Only in bench_pictures) Time recording from a picture to a new\n" 63 "record: (Only in bench_pictures) Time recording from a picture to a new\n"
64 "\tpicture.\n" 64 "\tpicture.\n"
65 "playbackCreation: (Only in bench_pictures) Time creation of the \ n" 65 "playbackCreation: (Only in bench_pictures) Time creation of the \ n"
66 "\tSkPicturePlayback.\n" 66 "\tSkPicturePlayback.\n"
67 "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"
68 "\twith the bitmaps PNG encoded.\n"); 68 "\twith the bitmaps PNG encoded.\n");
69 DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. "
70 "If > 1, requires tiled rendering.");
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 75
78 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { 76 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
79 error.reset(); 77 error.reset();
80 78
81 if (FLAGS_multi <= 0) {
82 error.printf("--multi must be > 0, was %i", FLAGS_multi);
83 return NULL;
84 }
85
86 bool useTiles = false; 79 bool useTiles = false;
87 const char* widthString = NULL; 80 const char* widthString = NULL;
88 const char* heightString = NULL; 81 const char* heightString = NULL;
89 bool isPowerOf2Mode = false; 82 bool isPowerOf2Mode = false;
90 bool isCopyMode = false; 83 bool isCopyMode = false;
91 const char* mode = NULL; 84 const char* mode = NULL;
92 bool gridSupported = false; 85 bool gridSupported = false;
93 86
94 SkAutoTUnref<sk_tools::PictureRenderer> renderer; 87 SkAutoTUnref<sk_tools::PictureRenderer> renderer;
95 if (FLAGS_mode.count() >= 1) { 88 if (FLAGS_mode.count() >= 1) {
96 mode = FLAGS_mode[0]; 89 mode = FLAGS_mode[0];
97 if (0 == strcmp(mode, "record")) { 90 if (0 == strcmp(mode, "record")) {
98 renderer.reset(SkNEW(sk_tools::RecordPictureRenderer)); 91 renderer.reset(SkNEW(sk_tools::RecordPictureRenderer));
99 gridSupported = true; 92 gridSupported = true;
100 // undocumented
101 } else if (0 == strcmp(mode, "clone")) {
102 renderer.reset(sk_tools::CreatePictureCloneRenderer());
103 } else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile") 93 } else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile")
104 || 0 == strcmp(mode, "copyTile")) { 94 || 0 == strcmp(mode, "copyTile")) {
105 useTiles = true; 95 useTiles = true;
106 96
107 if (0 == strcmp(mode, "pow2tile")) { 97 if (0 == strcmp(mode, "pow2tile")) {
108 isPowerOf2Mode = true; 98 isPowerOf2Mode = true;
109 } else if (0 == strcmp(mode, "copyTile")) { 99 } else if (0 == strcmp(mode, "copyTile")) {
110 isCopyMode = true; 100 isCopyMode = true;
111 } else { 101 } else {
112 gridSupported = true; 102 gridSupported = true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 x = xTiles; 153 x = xTiles;
164 y = yTiles; 154 y = yTiles;
165 if (x <= 0 || y <= 0) { 155 if (x <= 0 || y <= 0) {
166 error.printf("--tiles must be given values > 0\n"); 156 error.printf("--tiles must be given values > 0\n");
167 return NULL; 157 return NULL;
168 } 158 }
169 } else { 159 } else {
170 x = y = 4; 160 x = y = 4;
171 } 161 }
172 tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y))) ; 162 tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y))) ;
173 } else if (FLAGS_multi > 1) {
174 tiledRenderer.reset(SkNEW_ARGS(sk_tools::MultiCorePictureRenderer,
175 (FLAGS_multi)));
176 } else { 163 } else {
177 tiledRenderer.reset(SkNEW(sk_tools::TiledPictureRenderer)); 164 tiledRenderer.reset(SkNEW(sk_tools::TiledPictureRenderer));
178 } 165 }
179 166
180 if (isPowerOf2Mode) { 167 if (isPowerOf2Mode) {
181 int minWidth = atoi(widthString); 168 int minWidth = atoi(widthString);
182 if (!SkIsPow2(minWidth) || minWidth < 0) { 169 if (!SkIsPow2(minWidth) || minWidth < 0) {
183 SkString err; 170 SkString err;
184 error.printf("-mode %s must be given a width" 171 error.printf("-mode %s must be given a width"
185 " value that is a power of two\n", mode); 172 " value that is a power of two\n", mode);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 210 }
224 } 211 }
225 212
226 renderer.reset(tiledRenderer.detach()); 213 renderer.reset(tiledRenderer.detach());
227 if (FLAGS_pipe) { 214 if (FLAGS_pipe) {
228 error.printf("Pipe rendering is currently not compatible with tiling .\n" 215 error.printf("Pipe rendering is currently not compatible with tiling .\n"
229 "Turning off pipe.\n"); 216 "Turning off pipe.\n");
230 } 217 }
231 218
232 } else { // useTiles 219 } else { // useTiles
233 if (FLAGS_multi > 1) {
234 error.printf("Multithreaded drawing requires tiled rendering.\n");
235 return NULL;
236 }
237 if (FLAGS_pipe) { 220 if (FLAGS_pipe) {
238 if (renderer != NULL) { 221 if (renderer != NULL) {
239 error.printf("Pipe is incompatible with other modes.\n"); 222 error.printf("Pipe is incompatible with other modes.\n");
240 return NULL; 223 return NULL;
241 } 224 }
242 renderer.reset(SkNEW(sk_tools::PipePictureRenderer)); 225 renderer.reset(SkNEW(sk_tools::PipePictureRenderer));
243 } 226 }
244 } 227 }
245 228
246 if (NULL == renderer) { 229 if (NULL == renderer) {
(...skipping 16 matching lines...) Expand all
263 #if SK_SUPPORT_GPU 246 #if SK_SUPPORT_GPU
264 int sampleCount = 0; 247 int sampleCount = 0;
265 #endif 248 #endif
266 if (FLAGS_config.count() > 0) { 249 if (FLAGS_config.count() > 0) {
267 if (0 == strcmp(FLAGS_config[0], "8888")) { 250 if (0 == strcmp(FLAGS_config[0], "8888")) {
268 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; 251 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType;
269 } 252 }
270 #if SK_SUPPORT_GPU 253 #if SK_SUPPORT_GPU
271 else if (0 == strcmp(FLAGS_config[0], "gpu")) { 254 else if (0 == strcmp(FLAGS_config[0], "gpu")) {
272 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; 255 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
273 if (FLAGS_multi > 1) {
274 error.printf("GPU not compatible with multithreaded tiling.\n");
275 return NULL;
276 }
277 } 256 }
278 else if (0 == strcmp(FLAGS_config[0], "msaa4")) { 257 else if (0 == strcmp(FLAGS_config[0], "msaa4")) {
279 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; 258 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
280 if (FLAGS_multi > 1) {
281 error.printf("GPU not compatible with multithreaded tiling.\n");
282 return NULL;
283 }
284 sampleCount = 4; 259 sampleCount = 4;
285 } 260 }
286 else if (0 == strcmp(FLAGS_config[0], "msaa16")) { 261 else if (0 == strcmp(FLAGS_config[0], "msaa16")) {
287 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; 262 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
288 if (FLAGS_multi > 1) {
289 error.printf("GPU not compatible with multithreaded tiling.\n");
290 return NULL;
291 }
292 sampleCount = 16; 263 sampleCount = 16;
293 } 264 }
294 else if (0 == strcmp(FLAGS_config[0], "nvprmsaa4")) { 265 else if (0 == strcmp(FLAGS_config[0], "nvprmsaa4")) {
295 deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType; 266 deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
296 if (FLAGS_multi > 1) {
297 error.printf("GPU not compatible with multithreaded tiling.\n");
298 return NULL;
299 }
300 sampleCount = 4; 267 sampleCount = 4;
301 } 268 }
302 else if (0 == strcmp(FLAGS_config[0], "nvprmsaa16")) { 269 else if (0 == strcmp(FLAGS_config[0], "nvprmsaa16")) {
303 deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType; 270 deviceType = sk_tools::PictureRenderer::kNVPR_DeviceType;
304 if (FLAGS_multi > 1) {
305 error.printf("GPU not compatible with multithreaded tiling.\n");
306 return NULL;
307 }
308 sampleCount = 16; 271 sampleCount = 16;
309 } 272 }
310 #if SK_ANGLE 273 #if SK_ANGLE
311 else if (0 == strcmp(FLAGS_config[0], "angle")) { 274 else if (0 == strcmp(FLAGS_config[0], "angle")) {
312 deviceType = sk_tools::PictureRenderer::kAngle_DeviceType; 275 deviceType = sk_tools::PictureRenderer::kAngle_DeviceType;
313 if (FLAGS_multi > 1) {
314 error.printf("Angle not compatible with multithreaded tiling.\n" );
315 return NULL;
316 }
317 } 276 }
318 #endif 277 #endif
319 #if SK_MESA 278 #if SK_MESA
320 else if (0 == strcmp(FLAGS_config[0], "mesa")) { 279 else if (0 == strcmp(FLAGS_config[0], "mesa")) {
321 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType; 280 deviceType = sk_tools::PictureRenderer::kMesa_DeviceType;
322 if (FLAGS_multi > 1) {
323 error.printf("Mesa not compatible with multithreaded tiling.\n") ;
324 return NULL;
325 }
326 } 281 }
327 #endif 282 #endif
328 #endif 283 #endif
329 else { 284 else {
330 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 ]);
331 return NULL; 286 return NULL;
332 } 287 }
333 renderer->setDeviceType(deviceType); 288 renderer->setDeviceType(deviceType);
334 #if SK_SUPPORT_GPU 289 #if SK_SUPPORT_GPU
335 renderer->setSampleCount(sampleCount); 290 renderer->setSampleCount(sampleCount);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) { 323 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) {
369 error.printf("--pipe and --bbh cannot be used together\n"); 324 error.printf("--pipe and --bbh cannot be used together\n");
370 return NULL; 325 return NULL;
371 } 326 }
372 } 327 }
373 renderer->setBBoxHierarchyType(bbhType); 328 renderer->setBBoxHierarchyType(bbhType);
374 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); 329 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale));
375 330
376 return renderer.detach(); 331 return renderer.detach();
377 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698