OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "PageCachingDocument.h" | 8 #include "PageCachingDocument.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDocument.h" | 10 #include "SkDocument.h" |
11 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 typedef void (*DoneProc)(SkWStream*, bool); | 17 typedef void (*DoneProc)(SkWStream*, bool); |
18 typedef SkData* (*Encoder)(size_t*, const SkBitmap&); | 18 typedef SkData* (*Encoder)(size_t*, const SkBitmap&); |
19 | 19 |
20 // This class allows us to compare the relative memory consumption of | 20 // This class allows us to compare the relative memory consumption of |
21 // the PDF and SkPicture backends. | 21 // the PDF and SkPicture backends. |
22 class PageCachingDocument : public SkDocument { | 22 class PageCachingDocument : public SkDocument { |
23 public: | 23 public: |
24 PageCachingDocument(SkWStream*, DoneProc, Encoder, SkScalar rasterDpi); | 24 PageCachingDocument(SkWStream*, DoneProc, Encoder, SkScalar rasterDpi); |
25 virtual ~PageCachingDocument(); | 25 virtual ~PageCachingDocument(); |
26 virtual SkCanvas* onBeginPage(SkScalar width, | 26 virtual SkCanvas* onBeginPage(SkScalar width, |
27 SkScalar height, | 27 SkScalar height, |
28 const SkRect& content) SK_OVERRIDE; | 28 const SkRect& content) override; |
29 void onEndPage() SK_OVERRIDE; | 29 void onEndPage() override; |
30 bool onClose(SkWStream*) SK_OVERRIDE; | 30 bool onClose(SkWStream*) override; |
31 void onAbort() SK_OVERRIDE; | 31 void onAbort() override; |
32 | 32 |
33 private: | 33 private: |
34 struct Page { | 34 struct Page { |
35 SkScalar fWidth; | 35 SkScalar fWidth; |
36 SkScalar fHeight; | 36 SkScalar fHeight; |
37 SkAutoTUnref<SkPicture> fPic; | 37 SkAutoTUnref<SkPicture> fPic; |
38 }; | 38 }; |
39 SkPictureRecorder fRecorder; | 39 SkPictureRecorder fRecorder; |
40 SkTDArray<Page> fPages; | 40 SkTDArray<Page> fPages; |
41 Encoder fEncoder; | 41 Encoder fEncoder; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void PageCachingDocument::onAbort() { | 89 void PageCachingDocument::onAbort() { |
90 } | 90 } |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 SkDocument* CreatePageCachingDocument(SkWStream* stream, | 93 SkDocument* CreatePageCachingDocument(SkWStream* stream, |
94 DoneProc done, | 94 DoneProc done, |
95 Encoder encoder, | 95 Encoder encoder, |
96 SkScalar rasterDpi) { | 96 SkScalar rasterDpi) { |
97 return SkNEW_ARGS(PageCachingDocument, (stream, done, encoder, rasterDpi)); | 97 return SkNEW_ARGS(PageCachingDocument, (stream, done, encoder, rasterDpi)); |
98 } | 98 } |
OLD | NEW |