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

Side by Side Diff: printing/metafile_skia_wrapper.cc

Issue 559263002: Replaced Metafile with PdfMetafileSkia in renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thu Sep 11 15:46:31 PDT 2014 Created 6 years, 3 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
« no previous file with comments | « printing/metafile_skia_wrapper.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 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 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 "printing/metafile_skia_wrapper.h" 5 #include "printing/metafile_skia_wrapper.h"
6 #include "skia/ext/platform_device.h" 6 #include "skia/ext/platform_device.h"
7 #include "skia/ext/refptr.h" 7 #include "skia/ext/refptr.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkDevice.h" 9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "third_party/skia/include/core/SkMetaData.h" 10 #include "third_party/skia/include/core/SkMetaData.h"
11 11
12 namespace printing { 12 namespace printing {
13 13
14 namespace { 14 namespace {
15 15
16 const char* kMetafileKey = "CrMetafile"; 16 const char* kMetafileKey = "CrMetafile";
17 const char* kCustomScaleKey = "CrCustomScale"; 17 const char* kCustomScaleKey = "CrCustomScale";
18 18
19 } // namespace 19 } // namespace
20 20
21 // static 21 // static
22 void MetafileSkiaWrapper::SetMetafileOnCanvas(const SkCanvas& canvas, 22 void MetafileSkiaWrapper::SetMetafileOnCanvas(const SkCanvas& canvas,
23 Metafile* metafile) { 23 PdfMetafileSkia* metafile) {
24 skia::RefPtr<MetafileSkiaWrapper> wrapper; 24 skia::RefPtr<MetafileSkiaWrapper> wrapper;
25 if (metafile) 25 if (metafile)
26 wrapper = skia::AdoptRef(new MetafileSkiaWrapper(metafile)); 26 wrapper = skia::AdoptRef(new MetafileSkiaWrapper(metafile));
27 27
28 SkMetaData& meta = skia::getMetaData(canvas); 28 SkMetaData& meta = skia::getMetaData(canvas);
29 meta.setRefCnt(kMetafileKey, wrapper.get()); 29 meta.setRefCnt(kMetafileKey, wrapper.get());
30 } 30 }
31 31
32 // static 32 // static
33 Metafile* MetafileSkiaWrapper::GetMetafileFromCanvas(const SkCanvas& canvas) { 33 PdfMetafileSkia* MetafileSkiaWrapper::GetMetafileFromCanvas(
34 const SkCanvas& canvas) {
34 SkMetaData& meta = skia::getMetaData(canvas); 35 SkMetaData& meta = skia::getMetaData(canvas);
35 SkRefCnt* value; 36 SkRefCnt* value;
36 if (!meta.findRefCnt(kMetafileKey, &value) || !value) 37 if (!meta.findRefCnt(kMetafileKey, &value) || !value)
37 return NULL; 38 return NULL;
38 39
39 return static_cast<MetafileSkiaWrapper*>(value)->metafile_; 40 return static_cast<MetafileSkiaWrapper*>(value)->metafile_;
40 } 41 }
41 42
42 // static 43 // static
43 void MetafileSkiaWrapper::SetCustomScaleOnCanvas(const SkCanvas& canvas, 44 void MetafileSkiaWrapper::SetCustomScaleOnCanvas(const SkCanvas& canvas,
44 double scale) { 45 double scale) {
45 SkMetaData& meta = skia::getMetaData(canvas); 46 SkMetaData& meta = skia::getMetaData(canvas);
46 meta.setScalar(kCustomScaleKey, SkFloatToScalar(scale)); 47 meta.setScalar(kCustomScaleKey, SkFloatToScalar(scale));
47 } 48 }
48 49
49 // static 50 // static
50 bool MetafileSkiaWrapper::GetCustomScaleOnCanvas(const SkCanvas& canvas, 51 bool MetafileSkiaWrapper::GetCustomScaleOnCanvas(const SkCanvas& canvas,
51 double* scale) { 52 double* scale) {
52 SkMetaData& meta = skia::getMetaData(canvas); 53 SkMetaData& meta = skia::getMetaData(canvas);
53 SkScalar value; 54 SkScalar value;
54 if (!meta.findScalar(kCustomScaleKey, &value)) 55 if (!meta.findScalar(kCustomScaleKey, &value))
55 return false; 56 return false;
56 57
57 *scale = SkScalarToFloat(value); 58 *scale = SkScalarToFloat(value);
58 return true; 59 return true;
59 } 60 }
60 61
61 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile) 62 MetafileSkiaWrapper::MetafileSkiaWrapper(PdfMetafileSkia* metafile)
62 : metafile_(metafile) { 63 : metafile_(metafile) {
63 } 64 }
64 65
65 } // namespace printing 66 } // namespace printing
OLDNEW
« no previous file with comments | « printing/metafile_skia_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698