| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void (*doneProc)(SkWStream*, bool), | 324 void (*doneProc)(SkWStream*, bool), |
| 325 SkScalar rasterDpi) | 325 SkScalar rasterDpi) |
| 326 : SkDocument(stream, doneProc) | 326 : SkDocument(stream, doneProc) |
| 327 , fRasterDpi(rasterDpi) {} | 327 , fRasterDpi(rasterDpi) {} |
| 328 | 328 |
| 329 virtual ~SkDocument_PDF() { | 329 virtual ~SkDocument_PDF() { |
| 330 // subclasses must call close() in their destructors | 330 // subclasses must call close() in their destructors |
| 331 this->close(); | 331 this->close(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void setDCTEncoder(SkData* (*encoder)(const SkPixmap&)) override { |
| 335 fCanon.fEncoder = encoder; |
| 336 } |
| 337 |
| 334 protected: | 338 protected: |
| 335 SkCanvas* onBeginPage(SkScalar width, SkScalar height, | 339 SkCanvas* onBeginPage(SkScalar width, SkScalar height, |
| 336 const SkRect& trimBox) override { | 340 const SkRect& trimBox) override { |
| 337 SkASSERT(!fCanvas.get()); | 341 SkASSERT(!fCanvas.get()); |
| 338 | 342 |
| 339 SkISize pageSize = SkISize::Make( | 343 SkISize pageSize = SkISize::Make( |
| 340 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); | 344 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); |
| 341 SkAutoTUnref<SkPDFDevice> device( | 345 SkAutoTUnref<SkPDFDevice> device( |
| 342 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); | 346 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); |
| 343 fCanvas.reset(new SkCanvas(device.get())); | 347 fCanvas.reset(new SkCanvas(device.get())); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 395 |
| 392 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { | 396 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { |
| 393 SkFILEWStream* stream = new SkFILEWStream(path); | 397 SkFILEWStream* stream = new SkFILEWStream(path); |
| 394 if (!stream->isValid()) { | 398 if (!stream->isValid()) { |
| 395 delete stream; | 399 delete stream; |
| 396 return nullptr; | 400 return nullptr; |
| 397 } | 401 } |
| 398 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; | 402 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; |
| 399 return new SkDocument_PDF(stream, delete_wstream, dpi); | 403 return new SkDocument_PDF(stream, delete_wstream, dpi); |
| 400 } | 404 } |
| OLD | NEW |