Index: skia/ext/platform_device.cc |
diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc |
index 9e1dde76667d7e023f0969e9364008c1210ae583..05733046b66436d4404caf2e3f96b0bb872cef3a 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,8 +10,15 @@ |
namespace skia { |
namespace { |
+ |
const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; |
-} |
+const char* kDraftModeKey = "CrDraftMode"; |
+ |
+#if defined(OS_MACOSX) || defined(OS_WIN) |
+const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile"; |
+#endif |
+ |
+} // namespace |
void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { |
SkMetaData& meta_data = device->getMetaData(); |
@@ -27,6 +35,42 @@ PlatformDevice* GetPlatformDevice(SkDevice* device) { |
return NULL; |
} |
+SkMetaData& getMetaData(SkCanvas* canvas) { |
+ DCHECK(canvas != NULL); |
+ |
+ SkDevice* device = canvas->getDevice(); |
+ DCHECK(device != NULL); |
+ return device->getMetaData(); |
+} |
+ |
+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.
|
+ SkMetaData& meta = getMetaData(canvas); |
+ meta.setBool(kDraftModeKey, draft_mode); |
+} |
+ |
+bool GetDraftMode(SkCanvas* canvas) { |
+ SkMetaData& meta = getMetaData(canvas); |
+ bool draft_mode; |
+ if (!meta.findBool(kDraftModeKey, &draft_mode)) |
+ draft_mode = false; |
+ return draft_mode; |
+} |
+ |
+#if defined(OS_MACOSX) || defined(OS_WIN) |
+void SetIsPreviewMetafile(SkCanvas* canvas, bool is_preview) { |
+ SkMetaData& meta = getMetaData(canvas); |
+ meta.setBool(kIsPreviewMetafileKey, is_preview); |
+} |
+ |
+bool IsPreviewMetafile(SkCanvas* canvas) { |
+ SkMetaData& meta = getMetaData(canvas); |
+ bool is_preview_metafile; |
+ if (!meta.findBool(kIsPreviewMetafileKey, &is_preview_metafile)) |
+ is_preview_metafile = false; |
+ return is_preview_metafile; |
+} |
+#endif |
+ |
bool PlatformDevice::IsNativeFontRenderingAllowed() { |
return true; |
} |