OLD | NEW |
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SkScalar rasterDpi) | 298 SkScalar rasterDpi) |
299 : SkDocument(stream, doneProc) | 299 : SkDocument(stream, doneProc) |
300 , fRasterDpi(rasterDpi) {} | 300 , fRasterDpi(rasterDpi) {} |
301 | 301 |
302 virtual ~SkDocument_PDF() { | 302 virtual ~SkDocument_PDF() { |
303 // subclasses must call close() in their destructors | 303 // subclasses must call close() in their destructors |
304 this->close(); | 304 this->close(); |
305 } | 305 } |
306 | 306 |
307 protected: | 307 protected: |
308 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, | 308 SkCanvas* onBeginPage(SkScalar width, SkScalar height, |
309 const SkRect& trimBox) override { | 309 const SkRect& trimBox) override { |
310 SkASSERT(!fCanvas.get()); | 310 SkASSERT(!fCanvas.get()); |
311 | 311 |
312 SkISize pageSize = SkISize::Make( | 312 SkISize pageSize = SkISize::Make( |
313 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); | 313 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); |
314 SkAutoTUnref<SkPDFDevice> device( | 314 SkAutoTUnref<SkPDFDevice> device( |
315 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); | 315 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); |
316 fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get()))); | 316 fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get()))); |
317 fPageDevices.push(device.detach()); | 317 fPageDevices.push(device.detach()); |
318 fCanvas->clipRect(trimBox); | 318 fCanvas->clipRect(trimBox); |
319 fCanvas->translate(trimBox.x(), trimBox.y()); | 319 fCanvas->translate(trimBox.x(), trimBox.y()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { | 356 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { |
357 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); | 357 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); |
358 if (!stream->isValid()) { | 358 if (!stream->isValid()) { |
359 SkDELETE(stream); | 359 SkDELETE(stream); |
360 return NULL; | 360 return NULL; |
361 } | 361 } |
362 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; | 362 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; |
363 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); | 363 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); |
364 } | 364 } |
OLD | NEW |