Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Unified Diff: printing/pdf_ps_metafile_cairo.h

Issue 6611032: Unifying NativeMetafile class interface (as much as possible) for Linux, Mac, Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing dead code, using gfx::Size in PdfPsMetafile::StartPage Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0f1cc972f5f6bcf0613075162723263f1775c077 100644
--- a/printing/pdf_ps_metafile_cairo.h
+++ b/printing/pdf_ps_metafile_cairo.h
@@ -9,75 +9,41 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-#include "printing/native_metafile_linux.h"
+#include "printing/native_metafile.h"
typedef struct _cairo_surface cairo_surface_t;
-typedef struct _cairo cairo_t;
-
-namespace base {
-struct FileDescriptor;
-}
-
-class FilePath;
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 {
+// This class uses Cairo graphics library to generate PDF stream and stores
+// rendering results in a string buffer.
+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.
+ //NativeMetafile methods.
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);
-
- // Prepares a new cairo surface/context for rendering a new page.
- // The unit is in point (=1/72 in).
- // Returns NULL when failed.
- virtual cairo_t* StartPage(double width_in_points,
- double height_in_points,
- double margin_top_in_points,
- double margin_right_in_points,
- 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();
+ virtual uint32 GetDataSize() const;
+ virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const;
- // Closes resulting PDF file. No further rendering is allowed.
+ virtual bool FinishPage();
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;
+ virtual bool SaveTo(const FilePath& file_path) 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;
+ virtual gfx::Rect GetPageBounds(unsigned int page_number) const;
+ virtual unsigned int GetPageCount() const { return 1; }
- // 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;
+ virtual PlatformContext* StartPage(const gfx::Size& page_size,
+ double margin_top_in_points,
+ double margin_right_in_points,
+ double margin_bottom_in_points,
+ double margin_left_in_points);
- // The hardcoded margins, in points. These values are based on 72 dpi,
+virtual bool SetRawData(const void* src_buffer, uint32 src_buffer_size);
+ // 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;
static const double kRightMarginInInch;
@@ -86,7 +52,7 @@ class PdfPsMetafile : public NativeMetafile {
// Returns the PdfPsMetafile object that owns the given context. Returns NULL
// if the context was not created by a PdfPsMetafile object.
- static PdfPsMetafile* FromCairoContext(cairo_t* context);
+ static PdfPsMetafile* FromCairoContext(PlatformContext* context);
protected:
PdfPsMetafile();
@@ -100,7 +66,7 @@ class PdfPsMetafile : public NativeMetafile {
// Cairo surface and context for entire PDF file.
cairo_surface_t* surface_;
- cairo_t* context_;
+ PlatformContext* context_;
// Buffer stores PDF contents for entire PDF file.
std::string data_;

Powered by Google App Engine
This is Rietveld 408576698