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

Side by Side Diff: src/pdf/SkPDFDocument.cpp

Issue 1802963002: SkPDF: SkPDFDevice has ptr to SkPDFDocument (Closed) Base URL: https://skia.googlesource.com/skia.git@SkPdfBigSerializeRefactor
Patch Set: better explanation Created 4 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 | « src/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFShader.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 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 "SkPDFCanon.h" 8 #include "SkPDFCanon.h"
9 #include "SkPDFCanvas.h" 9 #include "SkPDFCanvas.h"
10 #include "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height, 269 SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height,
270 const SkRect& trimBox) { 270 const SkRect& trimBox) {
271 SkASSERT(!fCanvas.get()); // endPage() was called before this. 271 SkASSERT(!fCanvas.get()); // endPage() was called before this.
272 if (fPageDevices.empty()) { 272 if (fPageDevices.empty()) {
273 // if this is the first page if the document. 273 // if this is the first page if the document.
274 fObjectSerializer.serializeHeader(this->getStream(), fMetadata); 274 fObjectSerializer.serializeHeader(this->getStream(), fMetadata);
275 } 275 }
276 SkISize pageSize = SkISize::Make( 276 SkISize pageSize = SkISize::Make(
277 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 277 SkScalarRoundToInt(width), SkScalarRoundToInt(height));
278 sk_sp<SkPDFDevice> device( 278 sk_sp<SkPDFDevice> device(
279 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); 279 SkPDFDevice::Create(pageSize, fRasterDpi, this));
280 fCanvas = sk_make_sp<SkPDFCanvas>(device); 280 fCanvas = sk_make_sp<SkPDFCanvas>(device);
281 fPageDevices.push_back(std::move(device)); 281 fPageDevices.push_back(std::move(device));
282 fCanvas->clipRect(trimBox); 282 fCanvas->clipRect(trimBox);
283 fCanvas->translate(trimBox.x(), trimBox.y()); 283 fCanvas->translate(trimBox.x(), trimBox.y());
284 return fCanvas.get(); 284 return fCanvas.get();
285 } 285 }
286 286
287 void SkPDFDocument::onEndPage() { 287 void SkPDFDocument::onEndPage() {
288 SkASSERT(fCanvas.get()); 288 SkASSERT(fCanvas.get());
289 fCanvas->flush(); 289 fCanvas->flush();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release(); 394 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release();
395 } 395 }
396 396
397 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 397 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
398 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; 398 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
399 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path)); 399 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
400 return stream->isValid() 400 return stream->isValid()
401 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase() 401 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase()
402 : nullptr; 402 : nullptr;
403 } 403 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.h ('k') | src/pdf/SkPDFShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698