Chromium Code Reviews| Index: skia/ext/platform_device.cc |
| diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc |
| index 9e1dde76667d7e023f0969e9364008c1210ae583..f85c6da019dc1d69a9c399b998ff8c97010ddf57 100644 |
| --- a/skia/ext/platform_device.cc |
| +++ b/skia/ext/platform_device.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/logging.h" |
| #include "skia/ext/platform_device.h" |
| #include "third_party/skia/include/core/SkMetaData.h" |
| @@ -9,9 +10,29 @@ |
| namespace skia { |
| namespace { |
| + |
| const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; |
| +const char* kDraftModeKey = "CrDraftMode"; |
| + |
| +#if defined(OS_MACOSX) || defined(OS_WIN) |
| +const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; |
| +#endif |
| + |
| +void SetBoolMetaData(const SkCanvas* canvas, const char* key, bool value) { |
| + SkMetaData& meta = skia::getMetaData(canvas); |
| + meta.setBool(key, value); |
| +} |
| + |
| +bool GetBoolMetaData(const SkCanvas* canvas, const char* key) { |
| + bool value; |
| + SkMetaData& meta = skia::getMetaData(canvas); |
| + if (!meta.findBool(key, &value)) |
| + value = false; |
| + return value; |
| } |
| +} // namespace |
| + |
| void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { |
| SkMetaData& meta_data = device->getMetaData(); |
| meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); |
| @@ -27,6 +48,32 @@ PlatformDevice* GetPlatformDevice(SkDevice* device) { |
| return NULL; |
| } |
| +SkMetaData& getMetaData(const SkCanvas* canvas) { |
| + DCHECK(canvas != NULL); |
| + |
|
vandebo (ex-Chrome)
2011/09/27 16:49:00
nit: extra line
kmadhusu
2011/09/27 18:15:01
Done.
|
| + SkDevice* device = canvas->getDevice(); |
| + DCHECK(device != NULL); |
| + return device->getMetaData(); |
| +} |
| + |
| +void SetIsDraftMode(const SkCanvas* canvas, bool draft_mode) { |
| + SetBoolMetaData(canvas, kDraftModeKey, draft_mode); |
| +} |
| + |
| +bool IsDraftMode(const SkCanvas* canvas) { |
| + return GetBoolMetaData(canvas, kDraftModeKey); |
| +} |
| + |
| +#if defined(OS_MACOSX) || defined(OS_WIN) |
| +void SetIsPreviewMetafile(const SkCanvas* canvas, bool is_preview) { |
| + SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
| +} |
| + |
| +bool IsPreviewMetafile(const SkCanvas* canvas) { |
| + return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
| +} |
| +#endif |
| + |
| bool PlatformDevice::IsNativeFontRenderingAllowed() { |
| return true; |
| } |