OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkXPSDevice.h" | 9 #include "SkXPSDevice.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 fPixelsPerMeter.set(pixelsPerMeterScale, pixelsPerMeterScale); | 21 fPixelsPerMeter.set(pixelsPerMeterScale, pixelsPerMeterScale); |
22 fDevice.beginPortfolio(stream); | 22 fDevice.beginPortfolio(stream); |
23 } | 23 } |
24 | 24 |
25 virtual ~SkDocument_XPS() { | 25 virtual ~SkDocument_XPS() { |
26 // subclasses must call close() in their destructors | 26 // subclasses must call close() in their destructors |
27 this->close(); | 27 this->close(); |
28 } | 28 } |
29 | 29 |
30 protected: | 30 protected: |
31 virtual SkCanvas* onBeginPage(SkScalar width, | 31 SkCanvas* onBeginPage(SkScalar width, |
32 SkScalar height, | 32 SkScalar height, |
33 const SkRect& trimBox) override { | 33 const SkRect& trimBox) override { |
34 fDevice.beginSheet(fUnitsPerMeter, fPixelsPerMeter, | 34 fDevice.beginSheet(fUnitsPerMeter, fPixelsPerMeter, |
35 SkSize::Make(width, height)); | 35 SkSize::Make(width, height)); |
36 fCanvas.reset(SkNEW_ARGS(SkCanvas, (&fDevice))); | 36 fCanvas.reset(SkNEW_ARGS(SkCanvas, (&fDevice))); |
37 fCanvas->clipRect(trimBox); | 37 fCanvas->clipRect(trimBox); |
38 fCanvas->translate(trimBox.x(), trimBox.y()); | 38 fCanvas->translate(trimBox.x(), trimBox.y()); |
39 return fCanvas.get(); | 39 return fCanvas.get(); |
40 } | 40 } |
41 | 41 |
42 void onEndPage() override { | 42 void onEndPage() override { |
43 SkASSERT(fCanvas.get()); | 43 SkASSERT(fCanvas.get()); |
(...skipping 26 matching lines...) Expand all Loading... |
70 SkDELETE(stream); | 70 SkDELETE(stream); |
71 } | 71 } |
72 | 72 |
73 SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) { | 73 SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) { |
74 SkAutoTDelete<SkFILEWStream> stream(SkNEW_ARGS(SkFILEWStream, (path))); | 74 SkAutoTDelete<SkFILEWStream> stream(SkNEW_ARGS(SkFILEWStream, (path))); |
75 if (!stream->isValid()) { | 75 if (!stream->isValid()) { |
76 return NULL; | 76 return NULL; |
77 } | 77 } |
78 return SkNEW_ARGS(SkDocument_XPS, (stream.detach(), delete_wstream, dpi)); | 78 return SkNEW_ARGS(SkDocument_XPS, (stream.detach(), delete_wstream, dpi)); |
79 } | 79 } |
OLD | NEW |