| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (!path->endsWith(".")) { | 75 if (!path->endsWith(".")) { |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 path->append(new_extension); | 78 path->append(new_extension); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 int gJpegQuality = 100; | 84 int gJpegQuality = 100; |
| 85 static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap
) { | 85 // the size_t* parameter is deprecated, so we ignore it |
| 86 static SkData* encode_to_dct_data(size_t*, const SkBitmap& bitmap) { |
| 86 if (gJpegQuality == -1) { | 87 if (gJpegQuality == -1) { |
| 87 return NULL; | 88 return NULL; |
| 88 } | 89 } |
| 89 | 90 |
| 90 SkBitmap bm = bitmap; | 91 SkBitmap bm = bitmap; |
| 91 #if defined(SK_BUILD_FOR_MAC) | 92 #if defined(SK_BUILD_FOR_MAC) |
| 92 // Workaround bug #1043 where bitmaps with referenced pixels cause | 93 // Workaround bug #1043 where bitmaps with referenced pixels cause |
| 93 // CGImageDestinationFinalize to crash | 94 // CGImageDestinationFinalize to crash |
| 94 SkBitmap copy; | 95 SkBitmap copy; |
| 95 bitmap.deepCopyTo(©, bitmap.config()); | 96 bitmap.deepCopyTo(©, bitmap.config()); |
| 96 bm = copy; | 97 bm = copy; |
| 97 #endif | 98 #endif |
| 98 | 99 |
| 99 SkPixelRef* pr = bm.pixelRef(); | |
| 100 if (pr != NULL) { | |
| 101 SkData* data = pr->refEncodedData(); | |
| 102 if (data != NULL) { | |
| 103 *pixelRefOffset = bm.pixelRefOffset(); | |
| 104 return data; | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 *pixelRefOffset = 0; | |
| 109 return SkImageEncoder::EncodeData(bm, | 100 return SkImageEncoder::EncodeData(bm, |
| 110 SkImageEncoder::kJPEG_Type, | 101 SkImageEncoder::kJPEG_Type, |
| 111 gJpegQuality); | 102 gJpegQuality); |
| 112 } | 103 } |
| 113 | 104 |
| 114 /** Builds the output filename. path = dir/name, and it replaces expected | 105 /** Builds the output filename. path = dir/name, and it replaces expected |
| 115 * .skp extension with .pdf extention. | 106 * .skp extension with .pdf extention. |
| 116 * @param path Output filename. | 107 * @param path Output filename. |
| 117 * @param name The name of the file. | 108 * @param name The name of the file. |
| 118 * @returns false if the file did not has the expected extension. | 109 * @returns false if the file did not has the expected extension. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 295 } |
| 305 #endif | 296 #endif |
| 306 return 0; | 297 return 0; |
| 307 } | 298 } |
| 308 | 299 |
| 309 #if !defined SK_BUILD_FOR_IOS | 300 #if !defined SK_BUILD_FOR_IOS |
| 310 int main(int argc, char * const argv[]) { | 301 int main(int argc, char * const argv[]) { |
| 311 return tool_main(argc, (char**) argv); | 302 return tool_main(argc, (char**) argv); |
| 312 } | 303 } |
| 313 #endif | 304 #endif |
| OLD | NEW |