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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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 | « src/core/SkYUVPlanesCache.cpp ('k') | src/doc/SkDocument_XPS.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 2011 Google Inc. 2 * Copyright 2011 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 "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 entry->fFont->getFontSubset(entry->fGlyphSet)); 56 entry->fFont->getFontSubset(entry->fGlyphSet));
57 if (subsetFont) { 57 if (subsetFont) {
58 substituteMap->setSubstitute(entry->fFont, subsetFont.get()); 58 substituteMap->setSubstitute(entry->fFont, subsetFont.get());
59 } 59 }
60 entry = iterator.next(); 60 entry = iterator.next();
61 } 61 }
62 } 62 }
63 63
64 static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) { 64 static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) {
65 SkAutoTDelete<SkStreamAsset> content(pageDevice->content()); 65 SkAutoTDelete<SkStreamAsset> content(pageDevice->content());
66 return SkNEW_ARGS(SkPDFStream, (content.get())); 66 return new SkPDFStream(content.get());
67 } 67 }
68 68
69 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { 69 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) {
70 SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page"))); 70 SkAutoTUnref<SkPDFDict> page(new SkPDFDict("Page"));
71 page->insertObject("Resources", pageDevice->createResourceDict()); 71 page->insertObject("Resources", pageDevice->createResourceDict());
72 page->insertObject("MediaBox", pageDevice->copyMediaBox()); 72 page->insertObject("MediaBox", pageDevice->copyMediaBox());
73 if (SkPDFArray* annots = pageDevice->getAnnotations()) { 73 if (SkPDFArray* annots = pageDevice->getAnnotations()) {
74 SkASSERT(annots->size() > 0); 74 SkASSERT(annots->size() > 0);
75 page->insertObject("Annots", SkRef(annots)); 75 page->insertObject("Annots", SkRef(annots));
76 } 76 }
77 page->insertObjRef("Contents", create_pdf_page_content(pageDevice)); 77 page->insertObjRef("Contents", create_pdf_page_content(pageDevice));
78 return page.detach(); 78 return page.detach();
79 } 79 }
80 80
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 } 156 }
157 157
158 static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, 158 static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices,
159 SkWStream* stream) { 159 SkWStream* stream) {
160 if (pageDevices.isEmpty()) { 160 if (pageDevices.isEmpty()) {
161 return false; 161 return false;
162 } 162 }
163 163
164 SkTDArray<SkPDFDict*> pages; 164 SkTDArray<SkPDFDict*> pages;
165 SkAutoTUnref<SkPDFDict> dests(SkNEW(SkPDFDict)); 165 SkAutoTUnref<SkPDFDict> dests(new SkPDFDict);
166 166
167 for (int i = 0; i < pageDevices.count(); i++) { 167 for (int i = 0; i < pageDevices.count(); i++) {
168 SkASSERT(pageDevices[i]); 168 SkASSERT(pageDevices[i]);
169 SkASSERT(i == 0 || 169 SkASSERT(i == 0 ||
170 pageDevices[i - 1]->getCanon() == pageDevices[i]->getCanon()); 170 pageDevices[i - 1]->getCanon() == pageDevices[i]->getCanon());
171 SkAutoTUnref<SkPDFDict> page(create_pdf_page(pageDevices[i])); 171 SkAutoTUnref<SkPDFDict> page(create_pdf_page(pageDevices[i]));
172 pageDevices[i]->appendDestinations(dests, page.get()); 172 pageDevices[i]->appendDestinations(dests, page.get());
173 pages.push(page.detach()); 173 pages.push(page.detach());
174 } 174 }
175 175
176 SkTDArray<SkPDFDict*> pageTree; 176 SkTDArray<SkPDFDict*> pageTree;
177 SkAutoTUnref<SkPDFDict> docCatalog(SkNEW_ARGS(SkPDFDict, ("Catalog"))); 177 SkAutoTUnref<SkPDFDict> docCatalog(new SkPDFDict("Catalog"));
178 178
179 SkPDFDict* pageTreeRoot; 179 SkPDFDict* pageTreeRoot;
180 generate_page_tree(pages, &pageTree, &pageTreeRoot); 180 generate_page_tree(pages, &pageTree, &pageTreeRoot);
181 docCatalog->insertObjRef("Pages", SkRef(pageTreeRoot)); 181 docCatalog->insertObjRef("Pages", SkRef(pageTreeRoot));
182 182
183 if (dests->size() > 0) { 183 if (dests->size() > 0) {
184 docCatalog->insertObjRef("Dests", dests.detach()); 184 docCatalog->insertObjRef("Dests", dests.detach());
185 } 185 }
186 186
187 /* TODO(vandebo): output intent 187 /* TODO(vandebo): output intent
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 protected: 302 protected:
303 SkCanvas* onBeginPage(SkScalar width, SkScalar height, 303 SkCanvas* onBeginPage(SkScalar width, SkScalar height,
304 const SkRect& trimBox) override { 304 const SkRect& trimBox) override {
305 SkASSERT(!fCanvas.get()); 305 SkASSERT(!fCanvas.get());
306 306
307 SkISize pageSize = SkISize::Make( 307 SkISize pageSize = SkISize::Make(
308 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 308 SkScalarRoundToInt(width), SkScalarRoundToInt(height));
309 SkAutoTUnref<SkPDFDevice> device( 309 SkAutoTUnref<SkPDFDevice> device(
310 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); 310 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
311 fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get()))); 311 fCanvas.reset(new SkCanvas(device.get()));
312 fPageDevices.push(device.detach()); 312 fPageDevices.push(device.detach());
313 fCanvas->clipRect(trimBox); 313 fCanvas->clipRect(trimBox);
314 fCanvas->translate(trimBox.x(), trimBox.y()); 314 fCanvas->translate(trimBox.x(), trimBox.y());
315 return fCanvas.get(); 315 return fCanvas.get();
316 } 316 }
317 317
318 void onEndPage() override { 318 void onEndPage() override {
319 SkASSERT(fCanvas.get()); 319 SkASSERT(fCanvas.get());
320 fCanvas->flush(); 320 fCanvas->flush();
321 fCanvas.reset(NULL); 321 fCanvas.reset(NULL);
(...skipping 16 matching lines...) Expand all
338 private: 338 private:
339 SkPDFCanon fCanon; 339 SkPDFCanon fCanon;
340 SkTDArray<const SkPDFDevice*> fPageDevices; 340 SkTDArray<const SkPDFDevice*> fPageDevices;
341 SkAutoTUnref<SkCanvas> fCanvas; 341 SkAutoTUnref<SkCanvas> fCanvas;
342 SkScalar fRasterDpi; 342 SkScalar fRasterDpi;
343 }; 343 };
344 } // namespace 344 } // namespace
345 /////////////////////////////////////////////////////////////////////////////// 345 ///////////////////////////////////////////////////////////////////////////////
346 346
347 SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) { 347 SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
348 return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, NULL, dpi)) : NULL; 348 return stream ? new SkDocument_PDF(stream, NULL, dpi) : NULL;
349 } 349 }
350 350
351 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 351 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
352 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 352 SkFILEWStream* stream = new SkFILEWStream(path);
353 if (!stream->isValid()) { 353 if (!stream->isValid()) {
354 SkDELETE(stream); 354 delete stream;
355 return NULL; 355 return NULL;
356 } 356 }
357 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; 357 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
358 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); 358 return new SkDocument_PDF(stream, delete_wstream, dpi);
359 } 359 }
OLDNEW
« no previous file with comments | « src/core/SkYUVPlanesCache.cpp ('k') | src/doc/SkDocument_XPS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698