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

Unified Diff: skia/ext/platform_device.cc

Issue 7719014: PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 3 months 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
« no previous file with comments | « skia/ext/platform_device.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/platform_device.cc
diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc
index 9e1dde76667d7e023f0969e9364008c1210ae583..6292273a8b51169f67d7290e1a356cc0ca8238d6 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,30 @@ PlatformDevice* GetPlatformDevice(SkDevice* device) {
return NULL;
}
+SkMetaData& getMetaData(const SkCanvas& canvas) {
+ 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;
}
« no previous file with comments | « skia/ext/platform_device.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698