Chromium Code Reviews| Index: printing/pdf_ps_metafile_cairo.h |
| diff --git a/printing/pdf_ps_metafile_cairo.h b/printing/pdf_ps_metafile_cairo.h |
| index 645a462b4e7fafe96e908699e0b6afccf657e69e..081173db22ab261de3ea22da533ea02f9a7af0ac 100644 |
| --- a/printing/pdf_ps_metafile_cairo.h |
| +++ b/printing/pdf_ps_metafile_cairo.h |
| @@ -9,45 +9,26 @@ |
| #include "base/basictypes.h" |
| #include "base/gtest_prod_util.h" |
| -#include "printing/native_metafile_linux.h" |
| - |
| -typedef struct _cairo_surface cairo_surface_t; |
| -typedef struct _cairo cairo_t; |
| - |
| -namespace base { |
| -struct FileDescriptor; |
| -} |
| - |
| -class FilePath; |
| +#include "printing/native_metafile.h" |
| namespace printing { |
| -// This class uses Cairo graphics library to generate PostScript/PDF stream |
| -// and stores rendering results in a string buffer. |
| -class PdfPsMetafile : public NativeMetafile { |
| +// Implementing NativeMetafile |
|
Lei Zhang
2011/03/04 12:02:36
nit: Unnecessary comment. Same for all the other m
dpapad
2011/03/04 19:19:43
When attempting to unify the interfaces, the comme
Lei Zhang
2011/03/04 19:36:40
Imagine someone who has never read the code before
dpapad
2011/03/04 21:48:19
Done.
|
| +class PdfPsMetafile : public NativeMetafile { |
| public: |
| virtual ~PdfPsMetafile(); |
| - |
| - // Initializes to a fresh new metafile. Returns true on success. |
| - // Note: Only call in the renderer to allocate rendering resources. |
| virtual bool Init(); |
| - |
| - // Initializes a copy of metafile from PDF stream data. |
| - // Returns true on success. |
| - // |src_buffer| should point to the shared memory which stores PDF |
| - // contents generated in the renderer. |
| - // Note: Only call in the browser to initialize |data_|. |
| virtual bool Init(const void* src_buffer, uint32 src_buffer_size); |
| - // Sets raw PDF data for the document. This is used when a cairo drawing |
| - // surface has already been created. This method will cause all subsequent |
| - // drawing on the surface to be discarded (in Close()). If Init() has not yet |
| - // been called this method simply calls the second version of Init. |
| - virtual bool SetRawData(const void* src_buffer, uint32 src_buffer_size); |
| + virtual uint32 GetDataSize() const; |
| + virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; |
| + |
| + virtual bool FinishPage(); |
| + virtual void Close(); |
| - // Prepares a new cairo surface/context for rendering a new page. |
| - // The unit is in point (=1/72 in). |
| - // Returns NULL when failed. |
| + virtual bool SaveTo(const FilePath& file_path) const; |
| + |
| + virtual bool SetRawData(const void* src_buffer, uint32 src_buffer_size); |
| virtual cairo_t* StartPage(double width_in_points, |
| double height_in_points, |
| double margin_top_in_points, |
| @@ -55,28 +36,6 @@ class PdfPsMetafile : public NativeMetafile { |
| double margin_bottom_in_points, |
| double margin_left_in_points); |
| - // Destroys the surface and the context used in rendering current page. |
| - // The results of current page will be appended into buffer |data_|. |
| - // Returns true on success. |
| - virtual bool FinishPage(); |
| - |
| - // Closes resulting PDF file. No further rendering is allowed. |
| - virtual void Close(); |
| - |
| - // Returns size of PDF contents stored in buffer |data_|. |
| - // This function should ONLY be called after PDF file is closed. |
| - virtual uint32 GetDataSize() const; |
| - |
| - // Copies PDF contents stored in buffer |data_| into |dst_buffer|. |
| - // This function should ONLY be called after PDF file is closed. |
| - // Returns true only when success. |
| - virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; |
| - |
| - // Saves PDF contents stored in buffer |data_| into the file |
| - // associated with |fd|. |
| - // This function should ONLY be called after PDF file is closed. |
| - virtual bool SaveTo(const base::FileDescriptor& fd) const; |
| - |
| // The hardcoded margins, in points. These values are based on 72 dpi, |
| // with 0.25 margins on top, left, and right, and 0.56 on bottom. |
| static const double kTopMarginInInch; |