OLD | NEW |
| (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 "printing/native_metafile_factory.h" | |
6 | |
7 #include "base/memory/scoped_ptr.h" | |
8 | |
9 #if defined(OS_WIN) | |
10 #include "printing/emf_win.h" | |
11 #elif defined(OS_MACOSX) | |
12 #include "printing/pdf_metafile_cg_mac.h" | |
13 #elif defined(OS_POSIX) | |
14 #include "printing/pdf_metafile_cairo_linux.h" | |
15 #endif | |
16 | |
17 namespace printing { | |
18 | |
19 // static | |
20 NativeMetafile* NativeMetafileFactory::Create() { | |
21 scoped_ptr<NativeMetafile> metafile(CreateNewMetafile()); | |
22 if (!metafile->Init()) | |
23 return NULL; | |
24 return metafile.release(); | |
25 } | |
26 | |
27 // static | |
28 NativeMetafile* NativeMetafileFactory::CreateFromData( | |
29 const void* src_buffer, uint32 src_buffer_size) { | |
30 scoped_ptr<NativeMetafile> metafile(CreateNewMetafile()); | |
31 if (!metafile->InitFromData(src_buffer, src_buffer_size)) | |
32 return NULL; | |
33 return metafile.release(); | |
34 } | |
35 | |
36 // static | |
37 NativeMetafile* NativeMetafileFactory::CreateNewMetafile(){ | |
38 #if defined(OS_WIN) | |
39 return new printing::Emf; | |
40 #elif defined(OS_MACOSX) | |
41 return new printing::PdfMetafileCg; | |
42 #elif defined(OS_POSIX) | |
43 return new printing::PdfMetafileCairo; | |
44 #endif | |
45 } | |
46 | |
47 } // namespace printing | |
OLD | NEW |