Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(939)

Unified Diff: skia/ext/platform_canvas.cc

Issue 1462163002: Move uncoupled code out of skia/ext/platform_device.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-draft-metadata
Patch Set: Mac compile fixes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698