OLD | NEW |
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 #ifndef PRINTING_NATIVE_METAFILE_H_ | 5 #ifndef PRINTING_NATIVE_METAFILE_H_ |
6 #define PRINTING_NATIVE_METAFILE_H_ | 6 #define PRINTING_NATIVE_METAFILE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 | 11 |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include <windows.h> | 13 #include <windows.h> |
14 #include <vector> | 14 #include <vector> |
15 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
16 #include <ApplicationServices/ApplicationServices.h> | 16 #include <ApplicationServices/ApplicationServices.h> |
17 #include <CoreFoundation/CoreFoundation.h> | 17 #include <CoreFoundation/CoreFoundation.h> |
18 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
19 #endif | 19 #endif |
20 | 20 |
21 class FilePath; | 21 class FilePath; |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Rect; | 24 class Rect; |
25 class Size; | 25 class Size; |
26 class Point; | 26 class Point; |
27 } | 27 } |
28 | 28 |
| 29 namespace skia { |
| 30 class PlatformDevice; |
| 31 } |
| 32 |
29 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
30 namespace base { | 34 namespace base { |
31 class FileDescriptor; | 35 class FileDescriptor; |
32 } | 36 } |
33 #endif | 37 #endif |
34 | 38 |
35 namespace printing { | 39 namespace printing { |
36 | 40 |
37 // This class creates a graphics context that renders into a data stream | 41 // This class creates a graphics context that renders into a data stream |
38 // (usually PDF or EMF). | 42 // (usually PDF or EMF). |
39 class NativeMetafile { | 43 class NativeMetafile { |
40 public: | 44 public: |
41 virtual ~NativeMetafile() {} | 45 virtual ~NativeMetafile() {} |
42 | 46 |
43 // Initializes a fresh new metafile for rendering. Returns false on failure. | 47 // Initializes a fresh new metafile for rendering. Returns false on failure. |
44 // Note: It should only be called from within the renderer process to allocate | 48 // Note: It should only be called from within the renderer process to allocate |
45 // rendering resources. | 49 // rendering resources. |
46 virtual bool Init() = 0; | 50 virtual bool Init() = 0; |
47 | 51 |
48 // Initializes the metafile with the data in |src_buffer|. Returns true | 52 // Initializes the metafile with the data in |src_buffer|. Returns true |
49 // on success. | 53 // on success. |
50 // Note: It should only be called from within the browser process. | 54 // Note: It should only be called from within the browser process. |
51 virtual bool Init(const void* src_buffer, uint32 src_buffer_size) = 0; | 55 virtual bool Init(const void* src_buffer, uint32 src_buffer_size) = 0; |
52 | 56 |
| 57 // This method calls StartPage and then returns an appropriate |
| 58 // VectorPlatformDevice implementation bound to the context created by |
| 59 // StartPage or NULL on error. |
| 60 virtual skia::PlatformDevice* StartPageForVectorCanvas( |
| 61 const gfx::Size& page_size, const gfx::Point& content_origin, |
| 62 const float& scale_factor) = 0; |
| 63 |
53 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
54 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls | 65 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls |
55 // (since StartPage and EndPage do not work in a metafile DC). Only valid | 66 // (since StartPage and EndPage do not work in a metafile DC). Only valid |
56 // when hdc_ is non-NULL. | 67 // when hdc_ is non-NULL. |
57 virtual bool StartPage() = 0; | 68 virtual bool StartPage() = 0; |
58 #elif defined(OS_MACOSX) | 69 #elif defined(OS_MACOSX) |
59 // Prepares a new pdf page at specified |content_origin| with the given | 70 // Prepares a new pdf page at specified |content_origin| with the given |
60 // |page_size| and a |scale_factor| to use for the drawing. | 71 // |page_size| and a |scale_factor| to use for the drawing. |
61 virtual gfx::NativeDrawingContext StartPage(const gfx::Size& page_size, | 72 virtual gfx::NativeDrawingContext StartPage(const gfx::Size& page_size, |
62 const gfx::Point& content_origin, | 73 const gfx::Point& content_origin, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Returns true if writing succeeded. | 191 // Returns true if writing succeeded. |
181 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; | 192 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; |
182 #endif // if defined(OS_CHROMEOS) | 193 #endif // if defined(OS_CHROMEOS) |
183 | 194 |
184 #endif | 195 #endif |
185 }; | 196 }; |
186 | 197 |
187 } // namespace printing | 198 } // namespace printing |
188 | 199 |
189 #endif // PRINTING_NATIVE_METAFILE_H_ | 200 #endif // PRINTING_NATIVE_METAFILE_H_ |
OLD | NEW |