1 // Copyright (c) 2011 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 "third_party/skia/include/core/SkCanvas.h"
8 #include "third_party/skia/include/core/SkDevice.h"
9 #include "third_party/skia/include/core/SkMetaData.h"
15 const char* kMetafileKey
= "CrMetafile";
20 void MetafileSkiaWrapper::SetMetafileOnCanvas(const SkCanvas
& canvas
,
22 MetafileSkiaWrapper
* wrapper
= NULL
;
24 wrapper
= new MetafileSkiaWrapper(metafile
);
26 SkMetaData
& meta
= skia::getMetaData(canvas
);
27 meta
.setRefCnt(kMetafileKey
, wrapper
);
32 Metafile
* MetafileSkiaWrapper::GetMetafileFromCanvas(const SkCanvas
& canvas
) {
33 SkMetaData
& meta
= skia::getMetaData(canvas
);
35 if (!meta
.findRefCnt(kMetafileKey
, &value
) || !value
)
38 return static_cast<MetafileSkiaWrapper
*>(value
)->metafile_
;
41 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile
* metafile
)
42 : metafile_(metafile
) {
45 } // namespace printing