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 Point; | 24 class Point; |
25 class Rect; | 25 class Rect; |
26 class Size; | 26 class Size; |
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 InitFromData(const void* src_buffer, uint32 src_buffer_size) = 0; | 55 virtual bool InitFromData(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 // Prepares a context for rendering a new page at the specified | 64 // Prepares a context for rendering a new page at the specified |
54 // |content_origin| with the given |page_size| and a |scale_factor| to use for | 65 // |content_origin| with the given |page_size| and a |scale_factor| to use for |
55 // the drawing. The units are in points (=1/72 in). Returns true on success. | 66 // the drawing. The units are in points (=1/72 in). Returns true on success. |
56 virtual bool StartPage(const gfx::Size& page_size, | 67 virtual bool StartPage(const gfx::Size& page_size, |
57 const gfx::Point& content_origin, | 68 const gfx::Point& content_origin, |
58 const float& scale_factor) = 0; | 69 const float& scale_factor) = 0; |
59 | 70 |
60 // Closes the current page and destroys the context used in rendering that | 71 // Closes the current page and destroys the context used in rendering that |
61 // page. The results of current page will be appended into the underlying | 72 // page. The results of current page will be appended into the underlying |
62 // data stream. Returns true on success. | 73 // data stream. Returns true on success. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Returns true if writing succeeded. | 177 // Returns true if writing succeeded. |
167 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; | 178 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; |
168 #endif // if defined(OS_CHROMEOS) | 179 #endif // if defined(OS_CHROMEOS) |
169 | 180 |
170 #endif | 181 #endif |
171 }; | 182 }; |
172 | 183 |
173 } // namespace printing | 184 } // namespace printing |
174 | 185 |
175 #endif // PRINTING_NATIVE_METAFILE_H_ | 186 #endif // PRINTING_NATIVE_METAFILE_H_ |
OLD | NEW |