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

Unified Diff: printing/metafile_skia_wrapper.cc

Issue 8052020: Revert 103021 - PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | « printing/metafile_skia_wrapper.h ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/metafile_skia_wrapper.cc
===================================================================
--- printing/metafile_skia_wrapper.cc (revision 103025)
+++ printing/metafile_skia_wrapper.cc (working copy)
@@ -2,8 +2,8 @@
// 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 "printing/metafile_skia_wrapper.h"
-#include "skia/ext/platform_device.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "third_party/skia/include/core/SkMetaData.h"
@@ -12,25 +12,34 @@
namespace {
+const char* kDraftModeKey = "CrDraftMode";
const char* kMetafileKey = "CrMetafile";
+SkMetaData& getMetaData(SkCanvas* canvas) {
+ DCHECK(canvas != NULL);
+
+ SkDevice* device = canvas->getDevice();
+ DCHECK(device != NULL);
+ return device->getMetaData();
+}
+
} // namespace
// static
-void MetafileSkiaWrapper::SetMetafileOnCanvas(const SkCanvas& canvas,
+void MetafileSkiaWrapper::SetMetafileOnCanvas(SkCanvas* canvas,
Metafile* metafile) {
MetafileSkiaWrapper* wrapper = NULL;
if (metafile)
wrapper = new MetafileSkiaWrapper(metafile);
- SkMetaData& meta = skia::getMetaData(canvas);
+ SkMetaData& meta = getMetaData(canvas);
meta.setRefCnt(kMetafileKey, wrapper);
SkSafeUnref(wrapper);
}
// static
-Metafile* MetafileSkiaWrapper::GetMetafileFromCanvas(const SkCanvas& canvas) {
- SkMetaData& meta = skia::getMetaData(canvas);
+Metafile* MetafileSkiaWrapper::GetMetafileFromCanvas(SkCanvas* canvas) {
+ SkMetaData& meta = getMetaData(canvas);
SkRefCnt* value;
if (!meta.findRefCnt(kMetafileKey, &value) || !value)
return NULL;
@@ -38,6 +47,21 @@
return static_cast<MetafileSkiaWrapper*>(value)->metafile_;
}
+// static
+void MetafileSkiaWrapper::SetDraftMode(SkCanvas* canvas, bool draft_mode) {
+ SkMetaData& meta = getMetaData(canvas);
+ meta.setBool(kDraftModeKey, draft_mode);
+}
+
+// static
+bool MetafileSkiaWrapper::GetDraftMode(SkCanvas* canvas) {
+ SkMetaData& meta = getMetaData(canvas);
+ bool draft_mode;
+ if (!meta.findBool(kDraftModeKey, &draft_mode))
+ draft_mode = false;
+ return draft_mode;
+}
+
MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile)
: metafile_(metafile) {
}
« no previous file with comments | « printing/metafile_skia_wrapper.h ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698