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

Side by Side Diff: include/core/SkDocument.h

Issue 935843007: Remove unused parameters to SkDocument::CreatePDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove SkPicture::EncodeBitmap Created 5 years, 10 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
« no previous file with comments | « no previous file | include/core/SkPicture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SkDocument_DEFINED 8 #ifndef SkDocument_DEFINED
9 #define SkDocument_DEFINED 9 #define SkDocument_DEFINED
10 10
(...skipping 17 matching lines...) Expand all
28 * a. canvas = doc->beginPage(...) 28 * a. canvas = doc->beginPage(...)
29 * b. draw_my_content(canvas); 29 * b. draw_my_content(canvas);
30 * c. doc->endPage(); 30 * c. doc->endPage();
31 * 3. Close the document with doc->close(). 31 * 3. Close the document with doc->close().
32 */ 32 */
33 class SK_API SkDocument : public SkRefCnt { 33 class SK_API SkDocument : public SkRefCnt {
34 public: 34 public:
35 SK_DECLARE_INST_COUNT(SkDocument) 35 SK_DECLARE_INST_COUNT(SkDocument)
36 36
37 /** 37 /**
38 * Create a PDF-backed document, writing the results into a file. 38 * Create a PDF-backed document, writing the results into a SkWStream.
39 * If there is an error trying to create the doc, returns NULL. 39 *
40 * encoder sets the DCTEncoder for images, to encode a bitmap 40 * PDF pages are sized in point units. 1 pt == 1/72 inch == 127/360 mm.
41 * as JPEG (DCT). 41 *
42 * rasterDpi - the DPI at which features without native PDF support 42 * @param SkWStream* A PDF document will be written to this
43 * will be rasterized (e.g. draw image with perspective, 43 * stream. The document may write to the stream at
44 * draw text with perspective, ...) 44 * anytime during its lifetime, until either close() is
45 * A larger DPI would create a PDF that reflects the original 45 * called or the document is deleted.
46 * intent with better fidelity, but it can make for larger 46 * @param dpi The DPI (pixels-per-inch) at which features without
47 * PDF files too, which would use more memory while rendering, 47 * native PDF support will be rasterized (e.g. draw image
48 * and it would be slower to be processed or sent online or 48 * with perspective, draw text with perspective, ...) A
49 * to printer. 49 * larger DPI would create a PDF that reflects the
50 * original intent with better fidelity, but it can make
51 * for larger PDF files too, which would use more memory
52 * while rendering, and it would be slower to be processed
53 * or sent online or to printer.
54 * @returns NULL if there is an error, otherwise a newly created
55 * PDF-backed SkDocument.
50 */ 56 */
51 static SkDocument* CreatePDF( 57 static SkDocument* CreatePDF(SkWStream*,
52 const char filename[], 58 SkScalar dpi = SK_ScalarDefaultRasterDPI);
53 SkPicture::EncodeBitmap encoder = NULL,
54 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
55 59
56 /** 60 /**
57 * Create a PDF-backed document, writing the results into a stream. 61 * Create a PDF-backed document, writing the results into a file.
58 * If there is an error trying to create the doc, returns NULL. 62 */
59 * 63 static SkDocument* CreatePDF(const char outputFilePath[],
60 * The document may write to the stream at anytime during its lifetime, 64 SkScalar dpi = SK_ScalarDefaultRasterDPI);
61 * until either close() is called or the document is deleted. Once close()
62 * has been called, and all of the data has been written to the stream,
63 * if there is a Done proc provided, it will be called with the stream.
64 * The proc can delete the stream, or whatever it needs to do.
65 * encoder sets the DCTEncoder for images, to encode a bitmap
66 * as JPEG (DCT).
67 * Done - clean up method intended to allow deletion of the stream.
68 * Its aborted parameter is true if the cleanup is due to an abort
69 * call. It is false otherwise.
70 * rasterDpi - the DPI at which features without native PDF support
71 * will be rasterized (e.g. draw image with perspective,
72 * draw text with perspective, ...)
73 * A larger DPI would create a PDF that reflects the original
74 * intent with better fidelity, but it can make for larger
75 * PDF files too, which would use more memory while rendering,
76 * and it would be slower to be processed or sent online or
77 * to printer. */
78 static SkDocument* CreatePDF(
79 SkWStream*, void (*Done)(SkWStream*,bool aborted) = NULL,
80 SkPicture::EncodeBitmap encoder = NULL,
81 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
82 65
83 /** 66 /**
84 * Begin a new page for the document, returning the canvas that will draw 67 * Begin a new page for the document, returning the canvas that will draw
85 * into the page. The document owns this canvas, and it will go out of 68 * into the page. The document owns this canvas, and it will go out of
86 * scope when endPage() or close() is called, or the document is deleted. 69 * scope when endPage() or close() is called, or the document is deleted.
87 */ 70 */
88 SkCanvas* beginPage(SkScalar width, SkScalar height, 71 SkCanvas* beginPage(SkScalar width, SkScalar height,
89 const SkRect* content = NULL); 72 const SkRect* content = NULL);
90 73
91 /** 74 /**
(...skipping 13 matching lines...) Expand all
105 bool close(); 88 bool close();
106 89
107 /** 90 /**
108 * Call abort() to stop producing the document immediately. 91 * Call abort() to stop producing the document immediately.
109 * The stream output must be ignored, and should not be trusted. 92 * The stream output must be ignored, and should not be trusted.
110 */ 93 */
111 void abort(); 94 void abort();
112 95
113 protected: 96 protected:
114 SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted)); 97 SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));
98
115 // note: subclasses must call close() in their destructor, as the base class 99 // note: subclasses must call close() in their destructor, as the base class
116 // cannot do this for them. 100 // cannot do this for them.
117 virtual ~SkDocument(); 101 virtual ~SkDocument();
118 102
119 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, 103 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
120 const SkRect& content) = 0; 104 const SkRect& content) = 0;
121 virtual void onEndPage() = 0; 105 virtual void onEndPage() = 0;
122 virtual bool onClose(SkWStream*) = 0; 106 virtual bool onClose(SkWStream*) = 0;
123 virtual void onAbort() = 0; 107 virtual void onAbort() = 0;
124 108
125 // Allows subclasses to write to the stream as pages are written. 109 // Allows subclasses to write to the stream as pages are written.
126 SkWStream* getStream() { return fStream; } 110 SkWStream* getStream() { return fStream; }
127 111
128 enum State { 112 enum State {
129 kBetweenPages_State, 113 kBetweenPages_State,
130 kInPage_State, 114 kInPage_State,
131 kClosed_State 115 kClosed_State
132 }; 116 };
133 State getState() const { return fState; } 117 State getState() const { return fState; }
134 118
135 private: 119 private:
136 SkWStream* fStream; 120 SkWStream* fStream;
137 void (*fDoneProc)(SkWStream*, bool aborted); 121 void (*fDoneProc)(SkWStream*, bool aborted);
138 State fState; 122 State fState;
139 123
140 typedef SkRefCnt INHERITED; 124 typedef SkRefCnt INHERITED;
141 }; 125 };
142 126
143 #endif 127 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698