Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkPDFDocument.h" | 9 #include "SkPDFDocument.h" |
| 10 #include "SkPDFDevice.h" | 10 #include "SkPDFDevice.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 mediaBoxSize.set(SkScalarRoundToInt(width), SkScalarRoundToInt(height)); | 37 mediaBoxSize.set(SkScalarRoundToInt(width), SkScalarRoundToInt(height)); |
| 38 | 38 |
| 39 fDevice = SkNEW_ARGS(SkPDFDevice, (mediaBoxSize, mediaBoxSize, SkMatrix: :I())); | 39 fDevice = SkNEW_ARGS(SkPDFDevice, (mediaBoxSize, mediaBoxSize, SkMatrix: :I())); |
| 40 if (fEncoder) { | 40 if (fEncoder) { |
| 41 fDevice->setDCTEncoder(fEncoder); | 41 fDevice->setDCTEncoder(fEncoder); |
| 42 } | 42 } |
| 43 if (fRasterDpi != 0) { | 43 if (fRasterDpi != 0) { |
| 44 fDevice->setRasterDpi(fRasterDpi); | 44 fDevice->setRasterDpi(fRasterDpi); |
| 45 } | 45 } |
| 46 fCanvas = SkNEW_ARGS(SkCanvas, (fDevice)); | 46 fCanvas = SkNEW_ARGS(SkCanvas, (fDevice)); |
| 47 fCanvas->translate(trimBox.x(), trimBox.y()); | |
| 48 fCanvas->clipRect(SkRect::MakeWH(trimBox.width(), trimBox.height())); | |
|
vandebo (ex-Chrome)
2014/11/11 15:44:53
Do headers and footers still work with this approa
| |
| 47 return fCanvas; | 49 return fCanvas; |
| 48 } | 50 } |
| 49 | 51 |
| 50 virtual void onEndPage() SK_OVERRIDE { | 52 virtual void onEndPage() SK_OVERRIDE { |
| 51 SkASSERT(fCanvas); | 53 SkASSERT(fCanvas); |
| 52 SkASSERT(fDevice); | 54 SkASSERT(fDevice); |
| 53 | 55 |
| 54 fCanvas->flush(); | 56 fCanvas->flush(); |
| 55 fDoc->appendPage(fDevice); | 57 fDoc->appendPage(fDevice); |
| 56 | 58 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 SkDocument* SkDocument::CreatePDF(const char path[], | 101 SkDocument* SkDocument::CreatePDF(const char path[], |
| 100 SkPicture::EncodeBitmap enc, | 102 SkPicture::EncodeBitmap enc, |
| 101 SkScalar dpi) { | 103 SkScalar dpi) { |
| 102 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); | 104 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); |
| 103 if (!stream->isValid()) { | 105 if (!stream->isValid()) { |
| 104 SkDELETE(stream); | 106 SkDELETE(stream); |
| 105 return NULL; | 107 return NULL; |
| 106 } | 108 } |
| 107 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi)); | 109 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi)); |
| 108 } | 110 } |
| OLD | NEW |