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

Side by Side Diff: printing/native_metafile_skia_wrapper.cc

Issue 6733036: Make PluginInstance::PrintPDFOutput-metafile implementation agnostic on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unref of potentially NULL object pointed out by thestig@. Created 9 years, 9 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_ps_metafile_cairo.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/SkRefDict.h"
10
11 namespace printing {
12
13 namespace {
14
15 static const char* kNativeMetafileKey = "CrNativeMetafile";
16
17 SkRefDict& getRefDict(SkCanvas* canvas) {
18 DCHECK(canvas != NULL);
19
20 SkDevice* device = canvas->getDevice();
21 DCHECK(device != NULL);
22 return device->getRefDict();
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 SkRefDict& dict = getRefDict(canvas);
36 dict.set(kNativeMetafileKey, wrapper);
37 SkSafeUnred(wrapper);
Lei Zhang 2011/03/24 21:54:12 typo :)
vandebo (ex-Chrome) 2011/03/24 21:58:09 Done.
38 }
39
40 // static
41 NativeMetafile* NativeMetafileSkiaWrapper::GetMetafileFromCanvas(
42 SkCanvas* canvas) {
43 SkRefDict& dict = getRefDict(canvas);
44 SkRefCnt* value = dict.find(kNativeMetafileKey);
45 if (!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_ps_metafile_cairo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698