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" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 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."); |
73 DEFINE_double(scale, 1, "Set the scale factor."); | 73 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 " | 74 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p
er larger tile " |
75 "in the x and y directions."); | 75 "in the x and y directions."); |
76 DEFINE_string(viewport, "", "width height: Set the viewport."); | 76 DEFINE_string(viewport, "", "width height: Set the viewport."); |
77 #if SK_SUPPORT_GPU | 77 #if SK_SUPPORT_GPU |
78 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " | 78 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " |
79 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | 79 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " |
80 "Defaults to empty string, which selects the API native to the " | 80 "Defaults to empty string, which selects the API native to the " |
81 "system."); | 81 "system."); |
| 82 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling
back to " |
| 83 "software path rendering."); |
82 #endif | 84 #endif |
83 | 85 |
84 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { | 86 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { |
85 error.reset(); | 87 error.reset(); |
86 | 88 |
87 bool useTiles = false; | 89 bool useTiles = false; |
88 const char* widthString = NULL; | 90 const char* widthString = NULL; |
89 const char* heightString = NULL; | 91 const char* heightString = NULL; |
90 bool isPowerOf2Mode = false; | 92 bool isPowerOf2Mode = false; |
91 bool isCopyMode = false; | 93 bool isCopyMode = false; |
92 const char* mode = NULL; | 94 const char* mode = NULL; |
93 bool gridSupported = false; | 95 bool gridSupported = false; |
94 | 96 |
| 97 #if SK_SUPPORT_GPU |
| 98 GrContext::Options grContextOpts; |
| 99 grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks; |
| 100 #define RENDERER_ARGS (grContextOpts) |
| 101 #else |
| 102 #define RENDERER_ARGS () |
| 103 #endif |
| 104 |
95 SkAutoTUnref<sk_tools::PictureRenderer> renderer; | 105 SkAutoTUnref<sk_tools::PictureRenderer> renderer; |
96 if (FLAGS_mode.count() >= 1) { | 106 if (FLAGS_mode.count() >= 1) { |
97 mode = FLAGS_mode[0]; | 107 mode = FLAGS_mode[0]; |
98 if (0 == strcmp(mode, "record")) { | 108 if (0 == strcmp(mode, "record")) { |
99 renderer.reset(SkNEW(sk_tools::RecordPictureRenderer)); | 109 renderer.reset(SkNEW_ARGS(sk_tools::RecordPictureRenderer, RENDERER_
ARGS)); |
100 gridSupported = true; | 110 gridSupported = true; |
101 } else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile") | 111 } else if (0 == strcmp(mode, "tile") || 0 == strcmp(mode, "pow2tile") |
102 || 0 == strcmp(mode, "copyTile")) { | 112 || 0 == strcmp(mode, "copyTile")) { |
103 useTiles = true; | 113 useTiles = true; |
104 | 114 |
105 if (0 == strcmp(mode, "pow2tile")) { | 115 if (0 == strcmp(mode, "pow2tile")) { |
106 isPowerOf2Mode = true; | 116 isPowerOf2Mode = true; |
107 } else if (0 == strcmp(mode, "copyTile")) { | 117 } else if (0 == strcmp(mode, "copyTile")) { |
108 isCopyMode = true; | 118 isCopyMode = true; |
109 } else { | 119 } else { |
110 gridSupported = true; | 120 gridSupported = true; |
111 } | 121 } |
112 | 122 |
113 if (FLAGS_mode.count() < 2) { | 123 if (FLAGS_mode.count() < 2) { |
114 error.printf("Missing width for --mode %s\n", mode); | 124 error.printf("Missing width for --mode %s\n", mode); |
115 return NULL; | 125 return NULL; |
116 } | 126 } |
117 | 127 |
118 widthString = FLAGS_mode[1]; | 128 widthString = FLAGS_mode[1]; |
119 if (FLAGS_mode.count() < 3) { | 129 if (FLAGS_mode.count() < 3) { |
120 error.printf("Missing height for --mode %s\n", mode); | 130 error.printf("Missing height for --mode %s\n", mode); |
121 return NULL; | 131 return NULL; |
122 } | 132 } |
123 | 133 |
124 heightString = FLAGS_mode[2]; | 134 heightString = FLAGS_mode[2]; |
125 } else if (0 == strcmp(mode, "playbackCreation") && kBench_PictureTool =
= tool) { | 135 } else if (0 == strcmp(mode, "playbackCreation") && kBench_PictureTool =
= tool) { |
126 renderer.reset(SkNEW(sk_tools::PlaybackCreationRenderer)); | 136 renderer.reset(SkNEW_ARGS(sk_tools::PlaybackCreationRenderer, RENDER
ER_ARGS)); |
127 gridSupported = true; | 137 gridSupported = true; |
128 // undocumented | 138 // undocumented |
129 } else if (0 == strcmp(mode, "gatherPixelRefs") && kBench_PictureTool ==
tool) { | 139 } else if (0 == strcmp(mode, "gatherPixelRefs") && kBench_PictureTool ==
tool) { |
| 140 #if SK_SUPPORT_GPU |
| 141 renderer.reset(sk_tools::CreateGatherPixelRefsRenderer(grContextOpts
)); |
| 142 #else |
130 renderer.reset(sk_tools::CreateGatherPixelRefsRenderer()); | 143 renderer.reset(sk_tools::CreateGatherPixelRefsRenderer()); |
| 144 #endif |
131 } else if (0 == strcmp(mode, "rerecord") && kRender_PictureTool == tool)
{ | 145 } else if (0 == strcmp(mode, "rerecord") && kRender_PictureTool == tool)
{ |
132 renderer.reset(SkNEW(sk_tools::RecordPictureRenderer)); | 146 renderer.reset(SkNEW_ARGS(sk_tools::RecordPictureRenderer, RENDERER_
ARGS)); |
133 // Allow 'mode' to be set to 'simple', but do not create a renderer, so
we can | 147 // Allow 'mode' to be set to 'simple', but do not create a renderer, so
we can |
134 // ensure that pipe does not override a mode besides simple. The rendere
r will | 148 // ensure that pipe does not override a mode besides simple. The rendere
r will |
135 // be created below. | 149 // be created below. |
136 } else if (0 == strcmp(mode, "simple")) { | 150 } else if (0 == strcmp(mode, "simple")) { |
137 gridSupported = true; | 151 gridSupported = true; |
138 } else { | 152 } else { |
139 error.printf("%s is not a valid mode for --mode\n", mode); | 153 error.printf("%s is not a valid mode for --mode\n", mode); |
140 return NULL; | 154 return NULL; |
141 } | 155 } |
142 } | 156 } |
(...skipping 17 matching lines...) Expand all Loading... |
160 if (xTiles != -1 && yTiles != -1) { | 174 if (xTiles != -1 && yTiles != -1) { |
161 x = xTiles; | 175 x = xTiles; |
162 y = yTiles; | 176 y = yTiles; |
163 if (x <= 0 || y <= 0) { | 177 if (x <= 0 || y <= 0) { |
164 error.printf("--tiles must be given values > 0\n"); | 178 error.printf("--tiles must be given values > 0\n"); |
165 return NULL; | 179 return NULL; |
166 } | 180 } |
167 } else { | 181 } else { |
168 x = y = 4; | 182 x = y = 4; |
169 } | 183 } |
| 184 #if SK_SUPPORT_GPU |
| 185 tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (grConte
xtOpts, x, y))); |
| 186 #else |
170 tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y)))
; | 187 tiledRenderer.reset(SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y)))
; |
| 188 #endif |
171 } else { | 189 } else { |
172 tiledRenderer.reset(SkNEW(sk_tools::TiledPictureRenderer)); | 190 tiledRenderer.reset(SkNEW_ARGS(sk_tools::TiledPictureRenderer, RENDE
RER_ARGS)); |
173 } | 191 } |
174 | 192 |
175 if (isPowerOf2Mode) { | 193 if (isPowerOf2Mode) { |
176 int minWidth = atoi(widthString); | 194 int minWidth = atoi(widthString); |
177 if (!SkIsPow2(minWidth) || minWidth < 0) { | 195 if (!SkIsPow2(minWidth) || minWidth < 0) { |
178 SkString err; | 196 SkString err; |
179 error.printf("-mode %s must be given a width" | 197 error.printf("-mode %s must be given a width" |
180 " value that is a power of two\n", mode); | 198 " value that is a power of two\n", mode); |
181 return NULL; | 199 return NULL; |
182 } | 200 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 error.printf("Pipe rendering is currently not compatible with tiling
.\n" | 241 error.printf("Pipe rendering is currently not compatible with tiling
.\n" |
224 "Turning off pipe.\n"); | 242 "Turning off pipe.\n"); |
225 } | 243 } |
226 | 244 |
227 } else { // useTiles | 245 } else { // useTiles |
228 if (FLAGS_pipe) { | 246 if (FLAGS_pipe) { |
229 if (renderer != NULL) { | 247 if (renderer != NULL) { |
230 error.printf("Pipe is incompatible with other modes.\n"); | 248 error.printf("Pipe is incompatible with other modes.\n"); |
231 return NULL; | 249 return NULL; |
232 } | 250 } |
233 renderer.reset(SkNEW(sk_tools::PipePictureRenderer)); | 251 renderer.reset(SkNEW_ARGS(sk_tools::PipePictureRenderer, RENDERER_AR
GS)); |
234 } | 252 } |
235 } | 253 } |
236 | 254 |
237 if (NULL == renderer) { | 255 if (NULL == renderer) { |
238 renderer.reset(SkNEW(sk_tools::SimplePictureRenderer)); | 256 renderer.reset(SkNEW_ARGS(sk_tools::SimplePictureRenderer, RENDERER_ARGS
)); |
239 } | 257 } |
240 | 258 |
241 if (FLAGS_viewport.count() > 0) { | 259 if (FLAGS_viewport.count() > 0) { |
242 if (FLAGS_viewport.count() != 2) { | 260 if (FLAGS_viewport.count() != 2) { |
243 error.printf("--viewport requires a width and a height.\n"); | 261 error.printf("--viewport requires a width and a height.\n"); |
244 return NULL; | 262 return NULL; |
245 } | 263 } |
246 SkISize viewport; | 264 SkISize viewport; |
247 viewport.fWidth = atoi(FLAGS_viewport[0]); | 265 viewport.fWidth = atoi(FLAGS_viewport[0]); |
248 viewport.fHeight = atoi(FLAGS_viewport[1]); | 266 viewport.fHeight = atoi(FLAGS_viewport[1]); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { | 371 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
bbhType) { |
354 error.printf("--pipe and --bbh cannot be used together\n"); | 372 error.printf("--pipe and --bbh cannot be used together\n"); |
355 return NULL; | 373 return NULL; |
356 } | 374 } |
357 } | 375 } |
358 renderer->setBBoxHierarchyType(bbhType); | 376 renderer->setBBoxHierarchyType(bbhType); |
359 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); | 377 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); |
360 | 378 |
361 return renderer.detach(); | 379 return renderer.detach(); |
362 } | 380 } |
OLD | NEW |