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

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

Issue 72833002: Fix DocumentTest/SkDocument memory leaks (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added comment Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/doc/SkDocument.cpp » ('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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 * Create a PDF-backed document, writing the results into a stream. 57 * Create a PDF-backed document, writing the results into a stream.
58 * If there is an error trying to create the doc, returns NULL. 58 * If there is an error trying to create the doc, returns NULL.
59 * 59 *
60 * The document may write to the stream at anytime during its lifetime, 60 * The document may write to the stream at anytime during its lifetime,
61 * until either close() is called or the document is deleted. Once close() 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, 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. 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. 64 * The proc can delete the stream, or whatever it needs to do.
65 * encoder sets the DCTEncoder for images, to encode a bitmap 65 * encoder sets the DCTEncoder for images, to encode a bitmap
66 * as JPEG (DCT). 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.
67 * rasterDpi - the DPI at which features without native PDF support 70 * rasterDpi - the DPI at which features without native PDF support
68 * will be rasterized (e.g. draw image with perspective, 71 * will be rasterized (e.g. draw image with perspective,
69 * draw text with perspective, ...) 72 * draw text with perspective, ...)
70 * A larger DPI would create a PDF that reflects the original 73 * A larger DPI would create a PDF that reflects the original
71 * intent with better fidelity, but it can make for larger 74 * intent with better fidelity, but it can make for larger
72 * PDF files too, which would use more memory while rendering, 75 * PDF files too, which would use more memory while rendering,
73 * and it would be slower to be processed or sent online or 76 * and it would be slower to be processed or sent online or
74 * to printer. */ 77 * to printer. */
75 static SkDocument* CreatePDF( 78 static SkDocument* CreatePDF(
76 SkWStream*, void (*Done)(SkWStream*) = NULL, 79 SkWStream*, void (*Done)(SkWStream*,bool aborted) = NULL,
77 SkPicture::EncodeBitmap encoder = NULL, 80 SkPicture::EncodeBitmap encoder = NULL,
78 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI); 81 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
79 82
80 /** 83 /**
81 * Begin a new page for the document, returning the canvas that will draw 84 * Begin a new page for the document, returning the canvas that will draw
82 * into the page. The document owns this canvas, and it will go out of 85 * into the page. The document owns this canvas, and it will go out of
83 * scope when endPage() or close() is called, or the document is deleted. 86 * scope when endPage() or close() is called, or the document is deleted.
84 */ 87 */
85 SkCanvas* beginPage(SkScalar width, SkScalar height, 88 SkCanvas* beginPage(SkScalar width, SkScalar height,
86 const SkRect* content = NULL); 89 const SkRect* content = NULL);
(...skipping 14 matching lines...) Expand all
101 */ 104 */
102 bool close(); 105 bool close();
103 106
104 /** 107 /**
105 * Call abort() to stop producing the document immediately. 108 * Call abort() to stop producing the document immediately.
106 * The stream output must be ignored, and should not be trusted. 109 * The stream output must be ignored, and should not be trusted.
107 */ 110 */
108 void abort(); 111 void abort();
109 112
110 protected: 113 protected:
111 SkDocument(SkWStream*, void (*)(SkWStream*)); 114 SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));
112 // note: subclasses must call close() in their destructor, as the base class 115 // note: subclasses must call close() in their destructor, as the base class
113 // cannot do this for them. 116 // cannot do this for them.
114 virtual ~SkDocument(); 117 virtual ~SkDocument();
115 118
116 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, 119 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
117 const SkRect& content) = 0; 120 const SkRect& content) = 0;
118 virtual void onEndPage() = 0; 121 virtual void onEndPage() = 0;
119 virtual bool onClose(SkWStream*) = 0; 122 virtual bool onClose(SkWStream*) = 0;
120 virtual void onAbort() = 0; 123 virtual void onAbort() = 0;
121 124
122 enum State { 125 enum State {
123 kBetweenPages_State, 126 kBetweenPages_State,
124 kInPage_State, 127 kInPage_State,
125 kClosed_State 128 kClosed_State
126 }; 129 };
127 State getState() const { return fState; } 130 State getState() const { return fState; }
128 131
129 private: 132 private:
130 SkWStream* fStream; 133 SkWStream* fStream;
131 void (*fDoneProc)(SkWStream*); 134 void (*fDoneProc)(SkWStream*, bool aborted);
132 State fState; 135 State fState;
133 136
134 typedef SkRefCnt INHERITED; 137 typedef SkRefCnt INHERITED;
135 }; 138 };
136 139
137 #endif 140 #endif
OLDNEW
« no previous file with comments | « no previous file | src/doc/SkDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698