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 24 matching lines...) Expand all Loading... |
35 SkSize::Make(width, height)); | 35 SkSize::Make(width, height)); |
36 fCanvas.reset(new SkCanvas(&fDevice)); | 36 fCanvas.reset(new 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()); |
44 fCanvas->flush(); | 44 fCanvas->flush(); |
45 fCanvas.reset(NULL); | 45 fCanvas.reset(nullptr); |
46 fDevice.endSheet(); | 46 fDevice.endSheet(); |
47 } | 47 } |
48 | 48 |
49 bool onClose(SkWStream*) override { | 49 bool onClose(SkWStream*) override { |
50 SkASSERT(!fCanvas.get()); | 50 SkASSERT(!fCanvas.get()); |
51 return fDevice.endPortfolio(); | 51 return fDevice.endPortfolio(); |
52 } | 52 } |
53 | 53 |
54 void onAbort() override {} | 54 void onAbort() override {} |
55 | 55 |
56 private: | 56 private: |
57 SkXPSDevice fDevice; | 57 SkXPSDevice fDevice; |
58 SkAutoTUnref<SkCanvas> fCanvas; | 58 SkAutoTUnref<SkCanvas> fCanvas; |
59 SkVector fUnitsPerMeter; | 59 SkVector fUnitsPerMeter; |
60 SkVector fPixelsPerMeter; | 60 SkVector fPixelsPerMeter; |
61 }; | 61 }; |
62 | 62 |
63 /////////////////////////////////////////////////////////////////////////////// | 63 /////////////////////////////////////////////////////////////////////////////// |
64 | 64 |
65 SkDocument* SkDocument::CreateXPS(SkWStream* stream, SkScalar dpi) { | 65 SkDocument* SkDocument::CreateXPS(SkWStream* stream, SkScalar dpi) { |
66 return stream ? new SkDocument_XPS(stream, NULL, dpi) : NULL; | 66 return stream ? new SkDocument_XPS(stream, nullptr, dpi) : nullptr; |
67 } | 67 } |
68 | 68 |
69 static void delete_wstream(SkWStream* stream, bool aborted) { delete stream; } | 69 static void delete_wstream(SkWStream* stream, bool aborted) { delete stream; } |
70 | 70 |
71 SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) { | 71 SkDocument* SkDocument::CreateXPS(const char path[], SkScalar dpi) { |
72 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path)); | 72 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path)); |
73 if (!stream->isValid()) { | 73 if (!stream->isValid()) { |
74 return NULL; | 74 return nullptr; |
75 } | 75 } |
76 return new SkDocument_XPS(stream.detach(), delete_wstream, dpi); | 76 return new SkDocument_XPS(stream.detach(), delete_wstream, dpi); |
77 } | 77 } |
OLD | NEW |