diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 21:54:06 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 21:54:06 +0000 |
commit | 7d748990b39550c77aa914ba6846885dd7352e10 (patch) | |
tree | 3777582ee9816b3488f218b594db1918e5ebe752 /printing/metafile_skia_wrapper.cc | |
parent | 03e204f307255e8f39aeb002f94b8eb04137e7f9 (diff) | |
download | chromium_src-7d748990b39550c77aa914ba6846885dd7352e10.zip chromium_src-7d748990b39550c77aa914ba6846885dd7352e10.tar.gz chromium_src-7d748990b39550c77aa914ba6846885dd7352e10.tar.bz2 |
Connect the right metafiles for print preview on Linux and Windows.
+ Remove the NativeMetafileFactory since we can't just use preview flag.
+ Update each Metafile constructor site to use PreviewMetafile or NativeMetafileImpl.
+ Fix misc. problems blocking pdf generation on Windows.
+ Rename the metafile interface.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6826027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/metafile_skia_wrapper.cc')
-rw-r--r-- | printing/metafile_skia_wrapper.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/printing/metafile_skia_wrapper.cc b/printing/metafile_skia_wrapper.cc new file mode 100644 index 0000000..22b58c8 --- /dev/null +++ b/printing/metafile_skia_wrapper.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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 "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkDevice.h" +#include "third_party/skia/include/core/SkMetaData.h" + +namespace printing { + +namespace { + +static 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(SkCanvas* canvas, + Metafile* metafile) { + MetafileSkiaWrapper* wrapper = NULL; + if (metafile) + wrapper = new MetafileSkiaWrapper(metafile); + + SkMetaData& meta = getMetaData(canvas); + meta.setRefCnt(kMetafileKey, wrapper); + SkSafeUnref(wrapper); +} + +// static +Metafile* MetafileSkiaWrapper::GetMetafileFromCanvas(SkCanvas* canvas) { + SkMetaData& meta = getMetaData(canvas); + SkRefCnt* value; + if (!meta.findRefCnt(kMetafileKey, &value) || !value) + return NULL; + + return static_cast<MetafileSkiaWrapper*>(value)->metafile_; +} + +MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile) + : metafile_(metafile) { +} + +} // namespace printing |