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

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

Issue 966863002: PDF: Canon now owns a reference to all interned objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-27 (Friday) 15:27:08 EST Created 5 years, 9 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 | src/pdf/SkPDFBitmap.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 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkPDFCanon.h" 9 #include "SkPDFCanon.h"
10 #include "SkPDFDocument.h" 10 #include "SkPDFDocument.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 fCanvas.reset(NULL); 49 fCanvas.reset(NULL);
50 fDevice.reset(NULL); 50 fDevice.reset(NULL);
51 } 51 }
52 52
53 bool onClose(SkWStream* stream) SK_OVERRIDE { 53 bool onClose(SkWStream* stream) SK_OVERRIDE {
54 SkASSERT(!fCanvas.get()); 54 SkASSERT(!fCanvas.get());
55 SkASSERT(!fDevice.get()); 55 SkASSERT(!fDevice.get());
56 56
57 bool success = fDoc->emitPDF(stream); 57 bool success = fDoc->emitPDF(stream);
58 fDoc.free(); 58 fDoc.free();
59 SkDEBUGCODE(fCanon.assertEmpty()); 59 fCanon.reset();
60 return success; 60 return success;
61 } 61 }
62 62
63 void onAbort() SK_OVERRIDE { 63 void onAbort() SK_OVERRIDE {
64 fDoc.free(); 64 fDoc.free();
65 SkDEBUGCODE(fCanon.assertEmpty()); 65 fCanon.reset();
66 } 66 }
67 67
68 private: 68 private:
69 SkPDFCanon fCanon; 69 SkPDFCanon fCanon;
70 SkAutoTDelete<SkPDFDocument> fDoc; 70 SkAutoTDelete<SkPDFDocument> fDoc;
71 SkAutoTUnref<SkPDFDevice> fDevice; 71 SkAutoTUnref<SkPDFDevice> fDevice;
72 SkAutoTUnref<SkCanvas> fCanvas; 72 SkAutoTUnref<SkCanvas> fCanvas;
73 SkScalar fRasterDpi; 73 SkScalar fRasterDpi;
74 }; 74 };
75 75
76 /////////////////////////////////////////////////////////////////////////////// 76 ///////////////////////////////////////////////////////////////////////////////
77 77
78 SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) { 78 SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
79 return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, NULL, dpi)) : NULL; 79 return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, NULL, dpi)) : NULL;
80 } 80 }
81 81
82 static void delete_wstream(SkWStream* stream, bool aborted) { 82 static void delete_wstream(SkWStream* stream, bool aborted) {
83 SkDELETE(stream); 83 SkDELETE(stream);
84 } 84 }
85 85
86 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 86 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
87 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 87 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
88 if (!stream->isValid()) { 88 if (!stream->isValid()) {
89 SkDELETE(stream); 89 SkDELETE(stream);
90 return NULL; 90 return NULL;
91 } 91 }
92 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); 92 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi));
93 } 93 }
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFBitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698