Index: skia/ext/platform_canvas.cc |
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc |
index cf362b3ce3a3f95fad61c51db39d9b355db93514..79040eb77a66d6c2729d13a8e890cfefdeed180c 100644 |
--- a/skia/ext/platform_canvas.cc |
+++ b/skia/ext/platform_canvas.cc |
@@ -4,9 +4,33 @@ |
#include "skia/ext/platform_canvas.h" |
+#include "base/logging.h" |
f(malita)
2015/11/24 23:13:23
Is this needed/used?
Tom Hudson
2015/11/25 15:50:35
Yeah, we're getting DCHECK from there. We could mi
f(malita)
2015/11/25 20:33:04
Ah, got you. DCHECK is fine.
|
#include "skia/ext/bitmap_platform_device.h" |
+#include "skia/ext/platform_device.h" |
+#include "third_party/skia/include/core/SkMetaData.h" |
#include "third_party/skia/include/core/SkTypes.h" |
+namespace { |
+ |
+#if defined(OS_MACOSX) |
+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 |
+ |
namespace skia { |
SkBaseDevice* GetTopDevice(const SkCanvas& canvas) { |
@@ -82,4 +106,32 @@ SkCanvas* CreateCanvas(const skia::RefPtr<SkBaseDevice>& device, OnFailureType f |
return new SkCanvas(device.get()); |
} |
+SkMetaData& getMetaData(const SkCanvas& canvas) { |
+ SkBaseDevice* device = canvas.getDevice(); |
+ DCHECK(device != NULL); |
+ return device->getMetaData(); |
+} |
+ |
+#if defined(OS_MACOSX) |
+void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview) { |
+ SetBoolMetaData(canvas, kIsPreviewMetafileKey, is_preview); |
+} |
+ |
+bool IsPreviewMetafile(const SkCanvas& canvas) { |
+ return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
+} |
+ |
+SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas) { |
f(malita)
2015/11/24 23:13:23
I don't think we need SK_API here.
Tom Hudson
2015/11/25 15:50:35
I think we do, see header file for the 5 invocatio
f(malita)
2015/11/25 20:33:04
Hmm, how about SetIsPreviewMetafile & IsPreviewMet
Tom Hudson
2015/11/30 16:14:42
D'oh, yes. Done.
|
+ SkBaseDevice* device = GetTopDevice(canvas); |
+ PlatformDevice* platform_device = GetPlatformDevice(device); |
+ if (platform_device) |
+ return platform_device->GetBitmapContext(); |
+ |
+ return NULL; |
f(malita)
2015/11/24 23:13:23
Nit: nullptr?
Nit^2: maybe
return platform_dev
Tom Hudson
2015/11/25 15:50:35
Done.
Also changed other NULLs in this file to nu
|
+ |
+} |
+ |
+#endif |
+ |
+ |
} // namespace skia |