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 "skia/ext/platform_device.h" | 6 #include "skia/ext/platform_device.h" |
6 | 7 |
7 #include "third_party/skia/include/core/SkMetaData.h" | 8 #include "third_party/skia/include/core/SkMetaData.h" |
8 | 9 |
9 namespace skia { | 10 namespace skia { |
10 | 11 |
11 namespace { | 12 namespace { |
13 | |
12 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; | 14 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; |
13 } | 15 const char* kDraftModeKey = "CrDraftMode"; |
16 | |
17 #if defined(OS_MACOSX) || defined(OS_WIN) | |
18 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; | |
19 #endif | |
20 | |
21 } // namespace | |
14 | 22 |
15 void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { | 23 void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { |
16 SkMetaData& meta_data = device->getMetaData(); | 24 SkMetaData& meta_data = device->getMetaData(); |
17 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); | 25 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); |
18 } | 26 } |
19 | 27 |
20 PlatformDevice* GetPlatformDevice(SkDevice* device) { | 28 PlatformDevice* GetPlatformDevice(SkDevice* device) { |
21 SkMetaData& meta_data = device->getMetaData(); | 29 SkMetaData& meta_data = device->getMetaData(); |
22 PlatformDevice* device_behaviour = NULL; | 30 PlatformDevice* device_behaviour = NULL; |
23 if (meta_data.findPtr(kDevicePlatformBehaviour, | 31 if (meta_data.findPtr(kDevicePlatformBehaviour, |
24 reinterpret_cast<void**>(&device_behaviour))) | 32 reinterpret_cast<void**>(&device_behaviour))) |
25 return device_behaviour; | 33 return device_behaviour; |
26 | 34 |
27 return NULL; | 35 return NULL; |
28 } | 36 } |
29 | 37 |
38 SkMetaData& getMetaData(SkCanvas* canvas) { | |
39 DCHECK(canvas != NULL); | |
40 | |
41 SkDevice* device = canvas->getDevice(); | |
42 DCHECK(device != NULL); | |
43 return device->getMetaData(); | |
44 } | |
45 | |
46 void SetDraftMode(SkCanvas* canvas, bool draft_mode) { | |
vandebo (ex-Chrome)
2011/09/26 21:01:45
You might as well make these generic and pull them
kmadhusu
2011/09/27 00:35:14
Done.
| |
47 SkMetaData& meta = getMetaData(canvas); | |
48 meta.setBool(kDraftModeKey, draft_mode); | |
49 } | |
50 | |
51 bool GetDraftMode(SkCanvas* canvas) { | |
52 SkMetaData& meta = getMetaData(canvas); | |
53 bool draft_mode; | |
54 if (!meta.findBool(kDraftModeKey, &draft_mode)) | |
55 draft_mode = false; | |
56 return draft_mode; | |
57 } | |
58 | |
59 #if defined(OS_MACOSX) || defined(OS_WIN) | |
60 void SetIsPreviewMetafile(SkCanvas* canvas, bool is_preview) { | |
61 SkMetaData& meta = getMetaData(canvas); | |
62 meta.setBool(kIsPreviewMetafileKey, is_preview); | |
63 } | |
64 | |
65 bool IsPreviewMetafile(SkCanvas* canvas) { | |
66 SkMetaData& meta = getMetaData(canvas); | |
67 bool is_preview_metafile; | |
68 if (!meta.findBool(kIsPreviewMetafileKey, &is_preview_metafile)) | |
69 is_preview_metafile = false; | |
70 return is_preview_metafile; | |
71 } | |
72 #endif | |
73 | |
30 bool PlatformDevice::IsNativeFontRenderingAllowed() { | 74 bool PlatformDevice::IsNativeFontRenderingAllowed() { |
31 return true; | 75 return true; |
32 } | 76 } |
33 | 77 |
34 bool PlatformDevice::AlphaBlendUsed() const { | 78 bool PlatformDevice::AlphaBlendUsed() const { |
35 return false; | 79 return false; |
36 } | 80 } |
37 | 81 |
38 } // namespace skia | 82 } // namespace skia |
OLD | NEW |