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

Side by Side Diff: printing/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/metafile_skia_wrapper.h ('k') | printing/native_metafile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "printing/native_metafile_skia_wrapper.h" 6 #include "printing/metafile_skia_wrapper.h"
7 #include "third_party/skia/include/core/SkCanvas.h" 7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "third_party/skia/include/core/SkDevice.h" 8 #include "third_party/skia/include/core/SkDevice.h"
9 #include "third_party/skia/include/core/SkMetaData.h" 9 #include "third_party/skia/include/core/SkMetaData.h"
10 10
11 namespace printing { 11 namespace printing {
12 12
13 namespace { 13 namespace {
14 14
15 static const char* kNativeMetafileKey = "CrNativeMetafile"; 15 static const char* kMetafileKey = "CrMetafile";
16 16
17 SkMetaData& getMetaData(SkCanvas* canvas) { 17 SkMetaData& getMetaData(SkCanvas* canvas) {
18 DCHECK(canvas != NULL); 18 DCHECK(canvas != NULL);
19 19
20 SkDevice* device = canvas->getDevice(); 20 SkDevice* device = canvas->getDevice();
21 DCHECK(device != NULL); 21 DCHECK(device != NULL);
22 return device->getMetaData(); 22 return device->getMetaData();
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27
28 // static 27 // static
29 void NativeMetafileSkiaWrapper::SetMetafileOnCanvas(SkCanvas* canvas, 28 void MetafileSkiaWrapper::SetMetafileOnCanvas(SkCanvas* canvas,
30 NativeMetafile* metafile) { 29 Metafile* metafile) {
31 NativeMetafileSkiaWrapper* wrapper = NULL; 30 MetafileSkiaWrapper* wrapper = NULL;
32 if (metafile) 31 if (metafile)
33 wrapper = new NativeMetafileSkiaWrapper(metafile); 32 wrapper = new MetafileSkiaWrapper(metafile);
34 33
35 SkMetaData& meta = getMetaData(canvas); 34 SkMetaData& meta = getMetaData(canvas);
36 meta.setRefCnt(kNativeMetafileKey, wrapper); 35 meta.setRefCnt(kMetafileKey, wrapper);
37 SkSafeUnref(wrapper); 36 SkSafeUnref(wrapper);
38 } 37 }
39 38
40 // static 39 // static
41 NativeMetafile* NativeMetafileSkiaWrapper::GetMetafileFromCanvas( 40 Metafile* MetafileSkiaWrapper::GetMetafileFromCanvas(SkCanvas* canvas) {
42 SkCanvas* canvas) {
43 SkMetaData& meta = getMetaData(canvas); 41 SkMetaData& meta = getMetaData(canvas);
44 SkRefCnt* value; 42 SkRefCnt* value;
45 if (!meta.findRefCnt(kNativeMetafileKey, &value) || !value) 43 if (!meta.findRefCnt(kMetafileKey, &value) || !value)
46 return NULL; 44 return NULL;
47 45
48 return static_cast<NativeMetafileSkiaWrapper*>(value)->metafile_; 46 return static_cast<MetafileSkiaWrapper*>(value)->metafile_;
49 } 47 }
50 48
51 NativeMetafileSkiaWrapper::NativeMetafileSkiaWrapper(NativeMetafile* metafile) 49 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile)
52 : metafile_(metafile) { 50 : metafile_(metafile) {
53 } 51 }
54 52
55 } // namespace printing 53 } // namespace printing
OLDNEW
« no previous file with comments | « printing/metafile_skia_wrapper.h ('k') | printing/native_metafile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698