OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "printing/metafile_skia_wrapper.h" | 6 #include "printing/metafile_skia_wrapper.h" |
7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
8 #include "third_party/skia/include/core/SkDevice.h" | 8 #include "third_party/skia/include/core/SkDevice.h" |
9 #include "third_party/skia/include/core/SkMetaData.h" | 9 #include "third_party/skia/include/core/SkMetaData.h" |
10 | 10 |
11 namespace printing { | 11 namespace printing { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 const char* kDraftModeKey = "CrDraftMode"; | 15 const char* kDraftModeKey = "CrDraftMode"; |
16 const char* kMetafileKey = "CrMetafile"; | 16 const char* kMetafileKey = "CrMetafile"; |
17 | 17 |
| 18 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 19 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; |
| 20 #endif |
| 21 |
18 SkMetaData& getMetaData(SkCanvas* canvas) { | 22 SkMetaData& getMetaData(SkCanvas* canvas) { |
19 DCHECK(canvas != NULL); | 23 DCHECK(canvas != NULL); |
20 | 24 |
21 SkDevice* device = canvas->getDevice(); | 25 SkDevice* device = canvas->getDevice(); |
22 DCHECK(device != NULL); | 26 DCHECK(device != NULL); |
23 return device->getMetaData(); | 27 return device->getMetaData(); |
24 } | 28 } |
25 | 29 |
26 } // namespace | 30 } // namespace |
27 | 31 |
(...skipping 27 matching lines...) Expand all Loading... |
55 | 59 |
56 // static | 60 // static |
57 bool MetafileSkiaWrapper::GetDraftMode(SkCanvas* canvas) { | 61 bool MetafileSkiaWrapper::GetDraftMode(SkCanvas* canvas) { |
58 SkMetaData& meta = getMetaData(canvas); | 62 SkMetaData& meta = getMetaData(canvas); |
59 bool draft_mode; | 63 bool draft_mode; |
60 if (!meta.findBool(kDraftModeKey, &draft_mode)) | 64 if (!meta.findBool(kDraftModeKey, &draft_mode)) |
61 draft_mode = false; | 65 draft_mode = false; |
62 return draft_mode; | 66 return draft_mode; |
63 } | 67 } |
64 | 68 |
| 69 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 70 // static |
| 71 void MetafileSkiaWrapper::SetIsPreviewMetafile(SkCanvas* canvas, |
| 72 bool is_preview) { |
| 73 SkMetaData& meta = getMetaData(canvas); |
| 74 meta.setBool(kIsPreviewMetafileKey, is_preview); |
| 75 } |
| 76 |
| 77 // static |
| 78 bool MetafileSkiaWrapper::IsPreviewMetafile(SkCanvas* canvas) { |
| 79 SkMetaData& meta = getMetaData(canvas); |
| 80 bool is_preview_metafile; |
| 81 if (!meta.findBool(kIsPreviewMetafileKey, &is_preview_metafile)) |
| 82 is_preview_metafile = false; |
| 83 return is_preview_metafile; |
| 84 } |
| 85 #endif |
| 86 |
65 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile) | 87 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile) |
66 : metafile_(metafile) { | 88 : metafile_(metafile) { |
67 } | 89 } |
68 | 90 |
69 } // namespace printing | 91 } // namespace printing |
OLD | NEW |