OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_PDF_PS_METAFILE_LINUX_H_ | 5 #ifndef PRINTING_PDF_PS_METAFILE_LINUX_H_ |
6 #define PRINTING_PDF_PS_METAFILE_LINUX_H_ | 6 #define PRINTING_PDF_PS_METAFILE_LINUX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 typedef struct _cairo_surface cairo_surface_t; | 12 typedef struct _cairo_surface cairo_surface_t; |
13 typedef struct _cairo cairo_t; | 13 typedef struct _cairo cairo_t; |
14 | 14 |
| 15 namespace base { |
| 16 class FileDescriptor; |
| 17 } |
| 18 |
15 class FilePath; | 19 class FilePath; |
16 | 20 |
17 namespace printing { | 21 namespace printing { |
18 | 22 |
19 // This class uses Cairo graphics library to generate PostScript/PDF stream | 23 // This class uses Cairo graphics library to generate PostScript/PDF stream |
20 // and stores rendering results in a string buffer. | 24 // and stores rendering results in a string buffer. |
21 class PdfPsMetafile { | 25 class PdfPsMetafile { |
22 public: | 26 public: |
23 enum FileFormat { | 27 enum FileFormat { |
24 PDF, | 28 PDF, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 74 |
71 // Returns size of PDF/PS contents stored in buffer |all_pages_|. | 75 // Returns size of PDF/PS contents stored in buffer |all_pages_|. |
72 // This function should ONLY be called after PDF/PS file is closed. | 76 // This function should ONLY be called after PDF/PS file is closed. |
73 unsigned int GetDataSize() const; | 77 unsigned int GetDataSize() const; |
74 | 78 |
75 // Copies PDF/PS contents stored in buffer |all_pages_| into |dst_buffer|. | 79 // Copies PDF/PS contents stored in buffer |all_pages_| into |dst_buffer|. |
76 // This function should ONLY be called after PDF/PS file is closed. | 80 // This function should ONLY be called after PDF/PS file is closed. |
77 // Returns true only when success. | 81 // Returns true only when success. |
78 bool GetData(void* dst_buffer, size_t dst_buffer_size) const; | 82 bool GetData(void* dst_buffer, size_t dst_buffer_size) const; |
79 | 83 |
80 // Saves PDF/PS contents stored in buffer |all_pages_| into |filename| on | 84 // Saves PDF/PS contents stored in buffer |all_pages_| into the file |
81 // the disk. | 85 // associated with |fd|. |
82 // This function should ONLY be called after PDF/PS file is closed. | 86 // This function should ONLY be called after PDF/PS file is closed. |
83 bool SaveTo(const FilePath& filename) const; | 87 bool SaveTo(const base::FileDescriptor& fd) const; |
84 | 88 |
85 private: | 89 private: |
86 // Cleans up all resources. | 90 // Cleans up all resources. |
87 void CleanUpAll(); | 91 void CleanUpAll(); |
88 | 92 |
89 FileFormat format_; | 93 FileFormat format_; |
90 | 94 |
91 // Cairo surface and context for entire PDF/PS file. | 95 // Cairo surface and context for entire PDF/PS file. |
92 cairo_surface_t* surface_; | 96 cairo_surface_t* surface_; |
93 cairo_t* context_; | 97 cairo_t* context_; |
94 | 98 |
95 // Cairo surface and context for current page only. | 99 // Cairo surface and context for current page only. |
96 cairo_surface_t* page_surface_; | 100 cairo_surface_t* page_surface_; |
97 cairo_t* page_context_; | 101 cairo_t* page_context_; |
98 | 102 |
99 // Buffer stores PDF/PS contents for entire PDF/PS file. | 103 // Buffer stores PDF/PS contents for entire PDF/PS file. |
100 std::string all_pages_; | 104 std::string all_pages_; |
101 | 105 |
102 // Buffer stores PDF/PS contents for current page only. | 106 // Buffer stores PDF/PS contents for current page only. |
103 std::string current_page_; | 107 std::string current_page_; |
104 | 108 |
105 DISALLOW_COPY_AND_ASSIGN(PdfPsMetafile); | 109 DISALLOW_COPY_AND_ASSIGN(PdfPsMetafile); |
106 }; | 110 }; |
107 | 111 |
108 } // namespace printing | 112 } // namespace printing |
109 | 113 |
110 #endif // PRINTING_PDF_PS_METAFILE_LINUX_H_ | 114 #endif // PRINTING_PDF_PS_METAFILE_LINUX_H_ |
OLD | NEW |