OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 static inline int getByte(uint32_t value, int index) { | 212 static inline int getByte(uint32_t value, int index) { |
213 SkASSERT(0 <= index && index < 4); | 213 SkASSERT(0 <= index && index < 4); |
214 return (value >> (index * 8)) & 0xFF; | 214 return (value >> (index * 8)) & 0xFF; |
215 } | 215 } |
216 | 216 |
217 static int MaxByteDiff(uint32_t v1, uint32_t v2) { | 217 static int MaxByteDiff(uint32_t v1, uint32_t v2) { |
218 return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1,
1) - getByte(v2, 1))), | 218 return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1,
1) - getByte(v2, 1))), |
219 SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1,
3) - getByte(v2, 3)))); | 219 SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1,
3) - getByte(v2, 3)))); |
220 } | 220 } |
221 | 221 |
222 namespace { | |
223 class AutoRestoreBbhType { | 222 class AutoRestoreBbhType { |
224 public: | 223 public: |
225 AutoRestoreBbhType() { | 224 AutoRestoreBbhType() { |
226 fRenderer = NULL; | 225 fRenderer = NULL; |
227 fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; | 226 fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; |
228 } | 227 } |
229 | 228 |
230 void set(sk_tools::PictureRenderer* renderer, | 229 void set(sk_tools::PictureRenderer* renderer, |
231 sk_tools::PictureRenderer::BBoxHierarchyType bbhType) { | 230 sk_tools::PictureRenderer::BBoxHierarchyType bbhType) { |
232 fRenderer = renderer; | 231 fRenderer = renderer; |
233 fSavedBbhType = renderer->getBBoxHierarchyType(); | 232 fSavedBbhType = renderer->getBBoxHierarchyType(); |
234 renderer->setBBoxHierarchyType(bbhType); | 233 renderer->setBBoxHierarchyType(bbhType); |
235 } | 234 } |
236 | 235 |
237 ~AutoRestoreBbhType() { | 236 ~AutoRestoreBbhType() { |
238 if (NULL != fRenderer) { | 237 if (NULL != fRenderer) { |
239 fRenderer->setBBoxHierarchyType(fSavedBbhType); | 238 fRenderer->setBBoxHierarchyType(fSavedBbhType); |
240 } | 239 } |
241 } | 240 } |
242 | 241 |
243 private: | 242 private: |
244 sk_tools::PictureRenderer* fRenderer; | 243 sk_tools::PictureRenderer* fRenderer; |
245 sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType; | 244 sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType; |
246 }; | 245 }; |
247 } | |
248 | 246 |
249 /** | 247 /** |
250 * Render the SKP file(s) within inputPath, writing their bitmap images into out
putDir. | 248 * Render the SKP file(s) within inputPath, writing their bitmap images into out
putDir. |
251 * | 249 * |
252 * @param inputPath path to an individual SKP file, or a directory of SKP files | 250 * @param inputPath path to an individual SKP file, or a directory of SKP files |
253 * @param outputDir if not NULL, write the image(s) generated into this director
y | 251 * @param outputDir if not NULL, write the image(s) generated into this director
y |
254 * @param renderer PictureRenderer to use to render the SKPs | 252 * @param renderer PictureRenderer to use to render the SKPs |
255 * @param jsonSummaryPtr if not NULL, add the image(s) generated to this summary | 253 * @param jsonSummaryPtr if not NULL, add the image(s) generated to this summary |
256 */ | 254 */ |
257 static bool render_picture(const SkString& inputPath, const SkString* outputDir, | 255 static bool render_picture(const SkString& inputPath, const SkString* outputDir, |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); | 487 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); |
490 } | 488 } |
491 return 0; | 489 return 0; |
492 } | 490 } |
493 | 491 |
494 #if !defined SK_BUILD_FOR_IOS | 492 #if !defined SK_BUILD_FOR_IOS |
495 int main(int argc, char * const argv[]) { | 493 int main(int argc, char * const argv[]) { |
496 return tool_main(argc, (char**) argv); | 494 return tool_main(argc, (char**) argv); |
497 } | 495 } |
498 #endif | 496 #endif |
OLD | NEW |