Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / printing / metafile_skia_wrapper.cc
blob90a9c7c72cf138c91968657ce07017a14222c22c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "printing/metafile_skia_wrapper.h"
6 #include "skia/ext/platform_device.h"
7 #include "skia/ext/refptr.h"
8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "third_party/skia/include/core/SkMetaData.h"
12 namespace printing {
14 namespace {
16 const char* kMetafileKey = "CrMetafile";
18 } // namespace
20 // static
21 void MetafileSkiaWrapper::SetMetafileOnCanvas(const SkCanvas& canvas,
22 PdfMetafileSkia* metafile) {
23 skia::RefPtr<MetafileSkiaWrapper> wrapper;
24 if (metafile)
25 wrapper = skia::AdoptRef(new MetafileSkiaWrapper(metafile));
27 SkMetaData& meta = skia::getMetaData(canvas);
28 meta.setRefCnt(kMetafileKey, wrapper.get());
31 // static
32 PdfMetafileSkia* MetafileSkiaWrapper::GetMetafileFromCanvas(
33 const SkCanvas& canvas) {
34 SkMetaData& meta = skia::getMetaData(canvas);
35 SkRefCnt* value;
36 if (!meta.findRefCnt(kMetafileKey, &value) || !value)
37 return NULL;
39 return static_cast<MetafileSkiaWrapper*>(value)->metafile_;
42 MetafileSkiaWrapper::MetafileSkiaWrapper(PdfMetafileSkia* metafile)
43 : metafile_(metafile) {
46 } // namespace printing