summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 21:59:34 +0000
committerkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 21:59:34 +0000
commitc73df9dfae8ef94e2209564e30102a0862bd7580 (patch)
tree8be4e18edf1fe8ef3f534cb2455ebbb15cd6f505 /skia
parentfce166e2029e65921ef7b066529b71db3924128c (diff)
downloadchromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.zip
chromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.tar.gz
chromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.tar.bz2
PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF
BUG=93145 TEST=Please refer to bug report. Review URL: http://codereview.chromium.org/7719014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/platform_device.cc45
-rw-r--r--skia/ext/platform_device.h12
2 files changed, 57 insertions, 0 deletions
diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc
index 9e1dde7..6292273 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;
}
diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h
index 179a8e8..b2972c2 100644
--- a/skia/ext/platform_device.h
+++ b/skia/ext/platform_device.h
@@ -18,6 +18,7 @@
#include "third_party/skia/include/core/SkColor.h"
class SkMatrix;
+class SkMetaData;
class SkPath;
class SkRegion;
@@ -78,6 +79,17 @@ SK_API void InitializeDC(HDC context);
SK_API CGContextRef GetBitmapContext(SkDevice* device);
#endif
+// Following routines are used in print preview workflow to mark the draft mode
+// metafile and preview metafile.
+SkMetaData& getMetaData(const SkCanvas& canvas);
+void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode);
+bool IsDraftMode(const SkCanvas& canvas);
+
+#if defined(OS_MACOSX) || defined(OS_WIN)
+void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview);
+bool IsPreviewMetafile(const SkCanvas& canvas);
+#endif
+
// A SkDevice is basically a wrapper around SkBitmap that provides a surface for
// SkCanvas to draw into. PlatformDevice provides a surface Windows can also
// write to. It also provides functionality to play well with GDI drawing