Index: printing/pdf_ps_metafile_cairo.h |
diff --git a/printing/pdf_ps_metafile_cairo.h b/printing/pdf_ps_metafile_cairo.h |
index e56b64c65f8563e00baa835b70c402e003485b69..f057658621bbc17e83990bded2cf409dfe0fd954 100644 |
--- a/printing/pdf_ps_metafile_cairo.h |
+++ b/printing/pdf_ps_metafile_cairo.h |
@@ -8,6 +8,8 @@ |
#include <string> |
#include "base/basictypes.h" |
+#include "printing/metafile_factory.h" |
+#include "printing/native_metafile_linux.h" |
typedef struct _cairo_surface cairo_surface_t; |
typedef struct _cairo cairo_t; |
@@ -22,46 +24,44 @@ namespace printing { |
// This class uses Cairo graphics library to generate PostScript/PDF stream |
// and stores rendering results in a string buffer. |
-class PdfPsMetafile { |
- public: |
- enum FileFormat { |
- PDF, |
- PS, |
- }; |
+class PdfPsMetafile: public NativeMetafile { |
- PdfPsMetafile(); |
+ friend class MetafileFactory; |
Avi (use Gerrit)
2011/02/22 19:00:07
private friends
dpapad
2011/02/22 19:29:10
Done.
|
+ |
+ public: |
+ //TODO dpapad: move it to protected (or delete, PDF is supported only anyway) |
vandebo (ex-Chrome)
2011/02/22 22:18:16
+1
dpapad
2011/02/23 00:44:39
Done.
|
// In the renderer process, callers should also call Init(void) to see if the |
// metafile can obtain all necessary rendering resources. |
// In the browser process, callers should also call Init(const void*, uint32) |
// to initialize the buffer |data_| to use SaveTo(). |
explicit PdfPsMetafile(const FileFormat& format); |
- ~PdfPsMetafile(); |
+ virtual ~PdfPsMetafile(); |
// Initializes to a fresh new metafile. Returns true on success. |
// Note: Only call in the renderer to allocate rendering resources. |
- bool Init(); |
+ virtual bool Init(); |
// Initializes a copy of metafile from PDF/PS stream data. |
// Returns true on success. |
// |src_buffer| should point to the shared memory which stores PDF/PS |
// contents generated in the renderer. |
// Note: Only call in the browser to initialize |data_|. |
- bool Init(const void* src_buffer, uint32 src_buffer_size); |
+ virtual bool Init(const void* src_buffer, uint32 src_buffer_size); |
// Sets raw PS/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. |
- bool SetRawData(const void* src_buffer, uint32 src_buffer_size); |
+ virtual bool SetRawData(const void* src_buffer, uint32 src_buffer_size); |
- FileFormat GetFileFormat() const { return format_; } |
+ virtual FileFormat GetFileFormat() const { return format_; } |
// Prepares a new cairo surface/context for rendering a new page. |
// The unit is in point (=1/72 in). |
// Returns NULL when failed. |
- cairo_t* StartPage(double width_in_points, |
+ virtual cairo_t* StartPage(double width_in_points, |
double height_in_points, |
double margin_top_in_points, |
double margin_right_in_points, |
@@ -71,24 +71,24 @@ class PdfPsMetafile { |
// 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. |
- bool FinishPage(); |
+ virtual bool FinishPage(); |
// Closes resulting PDF/PS file. No further rendering is allowed. |
- void Close(); |
+ virtual void Close(); |
// Returns size of PDF/PS contents stored in buffer |data_|. |
// This function should ONLY be called after PDF/PS file is closed. |
- uint32 GetDataSize() const; |
+ virtual uint32 GetDataSize() const; |
// Copies PDF/PS contents stored in buffer |data_| into |dst_buffer|. |
// This function should ONLY be called after PDF/PS file is closed. |
// Returns true only when success. |
- bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; |
+ virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; |
// Saves PDF/PS contents stored in buffer |data_| into the file |
// associated with |fd|. |
// This function should ONLY be called after PDF/PS file is closed. |
- bool SaveTo(const base::FileDescriptor& fd) const; |
+ 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. |
@@ -101,9 +101,12 @@ class PdfPsMetafile { |
// if the context was not created by a PdfPdMetafile object. |
static PdfPsMetafile* FromCairoContext(cairo_t* context); |
+ protected: |
+ PdfPsMetafile(); |
+ |
private: |
// Cleans up all resources. |
- void CleanUpAll(); |
+ virtual void CleanUpAll(); |
vandebo (ex-Chrome)
2011/02/22 22:18:16
private virtual ?
dpapad
2011/02/23 00:44:39
Done.
|
FileFormat format_; |