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

Side by Side Diff: src/doc/SkDocument_PDF.cpp

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 | « src/doc/SkDocument.cpp ('k') | tests/DocumentTest.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 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkPDFDocument.h" 9 #include "SkPDFDocument.h"
10 #include "SkPDFDeviceFlattener.h" 10 #include "SkPDFDeviceFlattener.h"
11 11
12 class SkDocument_PDF : public SkDocument { 12 class SkDocument_PDF : public SkDocument {
13 public: 13 public:
14 SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*), 14 SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*,bool),
15 SkPicture::EncodeBitmap encoder, 15 SkPicture::EncodeBitmap encoder,
16 SkScalar rasterDpi) 16 SkScalar rasterDpi)
17 : SkDocument(stream, doneProc) 17 : SkDocument(stream, doneProc)
18 , fEncoder(encoder) 18 , fEncoder(encoder)
19 , fRasterDpi(rasterDpi) { 19 , fRasterDpi(rasterDpi) {
20 fDoc = SkNEW(SkPDFDocument); 20 fDoc = SkNEW(SkPDFDocument);
21 fCanvas = NULL; 21 fCanvas = NULL;
22 fDevice = NULL; 22 fDevice = NULL;
23 } 23 }
24 24
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 private: 79 private:
80 SkPDFDocument* fDoc; 80 SkPDFDocument* fDoc;
81 SkPDFDeviceFlattener* fDevice; 81 SkPDFDeviceFlattener* fDevice;
82 SkCanvas* fCanvas; 82 SkCanvas* fCanvas;
83 SkPicture::EncodeBitmap fEncoder; 83 SkPicture::EncodeBitmap fEncoder;
84 SkScalar fRasterDpi; 84 SkScalar fRasterDpi;
85 }; 85 };
86 86
87 /////////////////////////////////////////////////////////////////////////////// 87 ///////////////////////////////////////////////////////////////////////////////
88 88
89 SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*), 89 SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*,boo l),
90 SkPicture::EncodeBitmap enc, 90 SkPicture::EncodeBitmap enc,
91 SkScalar dpi) { 91 SkScalar dpi) {
92 return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc, dpi)) : NULL; 92 return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc, dpi)) : NULL;
93 } 93 }
94 94
95 static void delete_wstream(SkWStream* stream) { 95 static void delete_wstream(SkWStream* stream, bool aborted) {
96 SkDELETE(stream); 96 SkDELETE(stream);
97 } 97 }
98 98
99 SkDocument* SkDocument::CreatePDF(const char path[], 99 SkDocument* SkDocument::CreatePDF(const char path[],
100 SkPicture::EncodeBitmap enc, 100 SkPicture::EncodeBitmap enc,
101 SkScalar dpi) { 101 SkScalar dpi) {
102 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 102 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
103 if (!stream->isValid()) { 103 if (!stream->isValid()) {
104 SkDELETE(stream); 104 SkDELETE(stream);
105 return NULL; 105 return NULL;
106 } 106 }
107 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi)); 107 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi));
108 } 108 }
OLDNEW
« no previous file with comments | « src/doc/SkDocument.cpp ('k') | tests/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698