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

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: 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
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 SkRefDict& getRefDict(SkCanvas* canvas) {
16 DCHECK(canvas != NULL);
17
18 SkDevice* device = canvas->getDevice();
19 DCHECK(device != NULL);
20 return device->getRefDict();
21 }
22
23 } // namespace
24
25 // static
26 const char* NativeMetafileSkiaWrapper::kNativeMetafileKey = "CrNativeMetafile";
27
28 // static
29 void NativeMetafileSkiaWrapper::SetMetafileOnCanvas(SkCanvas* canvas,
30 NativeMetafile* metafile) {
31 NativeMetafileSkiaWrapper* wrapper = NULL;
32 if (metafile)
Lei Zhang 2011/03/24 21:28:27 What happens if |metafile| is NULL? Do we need thi
vandebo (ex-Chrome) 2011/03/24 21:44:45 There's no reason to store an entry in the SkRefDi
33 wrapper = new NativeMetafileSkiaWrapper(metafile);
34
35 SkRefDict& dict = getRefDict(canvas);
36 dict.set(kNativeMetafileKey, wrapper);
37 wrapper->unref();
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

Powered by Google App Engine
This is Rietveld 408576698