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

Side by Side Diff: printing/native_metafile_skia_wrapper.cc

Issue 6826027: Connect the right metafiles for print preview on Linux and Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile problems Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/native_metafile_skia_wrapper.h ('k') | printing/pdf_metafile_cairo_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/logging.h"
6 #include "printing/native_metafile_skia_wrapper.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"
10
11 namespace printing {
12
13 namespace {
14
15 static const char* kNativeMetafileKey = "CrNativeMetafile";
16
17 SkMetaData& getMetaData(SkCanvas* canvas) {
18 DCHECK(canvas != NULL);
19
20 SkDevice* device = canvas->getDevice();
21 DCHECK(device != NULL);
22 return device->getMetaData();
23 }
24
25 } // namespace
26
27
28 // static
29 void NativeMetafileSkiaWrapper::SetMetafileOnCanvas(SkCanvas* canvas,
30 NativeMetafile* metafile) {
31 NativeMetafileSkiaWrapper* wrapper = NULL;
32 if (metafile)
33 wrapper = new NativeMetafileSkiaWrapper(metafile);
34
35 SkMetaData& meta = getMetaData(canvas);
36 meta.setRefCnt(kNativeMetafileKey, wrapper);
37 SkSafeUnref(wrapper);
38 }
39
40 // static
41 NativeMetafile* NativeMetafileSkiaWrapper::GetMetafileFromCanvas(
42 SkCanvas* canvas) {
43 SkMetaData& meta = getMetaData(canvas);
44 SkRefCnt* value;
45 if (!meta.findRefCnt(kNativeMetafileKey, &value) || !value)
46 return NULL;
47
48 return static_cast<NativeMetafileSkiaWrapper*>(value)->metafile_;
49 }
50
51 NativeMetafileSkiaWrapper::NativeMetafileSkiaWrapper(NativeMetafile* metafile)
52 : metafile_(metafile) {
53 }
54
55 } // namespace printing
OLDNEW
« no previous file with comments | « printing/native_metafile_skia_wrapper.h ('k') | printing/pdf_metafile_cairo_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698