| 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 #ifndef SkDocument_DEFINED | 8 #ifndef SkDocument_DEFINED |
| 9 #define SkDocument_DEFINED | 9 #define SkDocument_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
| 13 #include "SkRect.h" | 13 #include "SkRect.h" |
| 14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 15 #include "SkString.h" | 15 #include "SkString.h" |
| 16 #include "SkTime.h" | 16 #include "SkTime.h" |
| 17 | 17 |
| 18 class SkCanvas; | 18 class SkCanvas; |
| 19 class SkPixelSerializer; |
| 19 class SkWStream; | 20 class SkWStream; |
| 20 | 21 |
| 21 /** SK_ScalarDefaultDPI is 72 DPI. | 22 /** SK_ScalarDefaultDPI is 72 DPI. |
| 22 */ | 23 */ |
| 23 #define SK_ScalarDefaultRasterDPI 72.0f | 24 #define SK_ScalarDefaultRasterDPI 72.0f |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * High-level API for creating a document-based canvas. To use.. | 27 * High-level API for creating a document-based canvas. To use.. |
| 27 * | 28 * |
| 28 * 1. Create a document, specifying a stream to store the output. | 29 * 1. Create a document, specifying a stream to store the output. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 51 * for larger PDF files too, which would use more memory | 52 * for larger PDF files too, which would use more memory |
| 52 * while rendering, and it would be slower to be processed | 53 * while rendering, and it would be slower to be processed |
| 53 * or sent online or to printer. | 54 * or sent online or to printer. |
| 54 * @returns NULL if there is an error, otherwise a newly created | 55 * @returns NULL if there is an error, otherwise a newly created |
| 55 * PDF-backed SkDocument. | 56 * PDF-backed SkDocument. |
| 56 */ | 57 */ |
| 57 static SkDocument* CreatePDF(SkWStream*, | 58 static SkDocument* CreatePDF(SkWStream*, |
| 58 SkScalar dpi = SK_ScalarDefaultRasterDPI); | 59 SkScalar dpi = SK_ScalarDefaultRasterDPI); |
| 59 | 60 |
| 60 /** | 61 /** |
| 62 * @param jpegEncoder For PDF documents, if a jpegEncoder is set, |
| 63 * use it to encode SkImages and SkBitmaps as [JFIF]JPEGs. |
| 64 * This feature is deprecated and is only supplied for |
| 65 * backwards compatability. |
| 66 * |
| 67 * The prefered method to create PDFs with JPEG images is |
| 68 * to use SkImage::NewFromEncoded() and not jpegEncoder. |
| 69 * Chromium uses NewFromEncoded. |
| 70 * |
| 71 * If the encoder is unset, or if jpegEncoder->onEncode() |
| 72 * returns NULL, fall back on encoding images losslessly |
| 73 * with Deflate. |
| 74 */ |
| 75 static SkDocument* CreatePDF(SkWStream*, |
| 76 SkScalar dpi, |
| 77 SkPixelSerializer* jpegEncoder); |
| 78 |
| 79 /** |
| 61 * Create a PDF-backed document, writing the results into a file. | 80 * Create a PDF-backed document, writing the results into a file. |
| 62 */ | 81 */ |
| 63 static SkDocument* CreatePDF(const char outputFilePath[], | 82 static SkDocument* CreatePDF(const char outputFilePath[], |
| 64 SkScalar dpi = SK_ScalarDefaultRasterDPI); | 83 SkScalar dpi = SK_ScalarDefaultRasterDPI); |
| 65 | 84 |
| 66 /** | 85 /** |
| 67 * Create a XPS-backed document, writing the results into the stream. | 86 * Create a XPS-backed document, writing the results into the stream. |
| 68 * Returns NULL if XPS is not supported. | 87 * Returns NULL if XPS is not supported. |
| 69 */ | 88 */ |
| 70 static SkDocument* CreateXPS(SkWStream* stream, | 89 static SkDocument* CreateXPS(SkWStream* stream, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 177 |
| 159 private: | 178 private: |
| 160 SkWStream* fStream; | 179 SkWStream* fStream; |
| 161 void (*fDoneProc)(SkWStream*, bool aborted); | 180 void (*fDoneProc)(SkWStream*, bool aborted); |
| 162 State fState; | 181 State fState; |
| 163 | 182 |
| 164 typedef SkRefCnt INHERITED; | 183 typedef SkRefCnt INHERITED; |
| 165 }; | 184 }; |
| 166 | 185 |
| 167 #endif | 186 #endif |
| OLD | NEW |