diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 20:02:27 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 20:02:27 +0000 |
commit | 72f966bbd75a095ef73a121e16f5713172b51d09 (patch) | |
tree | 6f7404eb02a40fa2337d59a3d5a65b2fe4368d28 /printing/pdf_metafile_mac.h | |
parent | d5ceb91979a8f47ca1e7e22a608eeaa7db933a14 (diff) | |
download | chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.zip chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.tar.gz chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.tar.bz2 |
Enable the RenderViewTest printing tests on the Mac.
Migrates some test APIs from wstring path names to FilePath objects, and fixes some gcc compilation issues, to allow the tests to build on Mac.
Moves rendering logic and some other pdf logic into PdfMetafile to avoid duplication with unit test code. Switches rendering from the deprecated CGContextDrawPDFDocument to the newer (but less convenient) CGContextDrawPDFPage.
Added debugging helpers to PdfMetafile: SaveTo, matching the other platform metafiles, and context retain count checking to get early warning of issues that will cause printing failure.
BUG=24750
TEST=N/A
Review URL: http://codereview.chromium.org/274052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_metafile_mac.h')
-rw-r--r-- | printing/pdf_metafile_mac.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/printing/pdf_metafile_mac.h b/printing/pdf_metafile_mac.h index 607abf5..61ba98e 100644 --- a/printing/pdf_metafile_mac.h +++ b/printing/pdf_metafile_mac.h @@ -5,12 +5,17 @@ #ifndef PRINTING_PDF_METAFILE_MAC_H_ #define PRINTING_PDF_METAFILE_MAC_H_ -#import <ApplicationServices/ApplicationServices.h> -#import <CoreFoundation/CoreFoundation.h> +#include <ApplicationServices/ApplicationServices.h> +#include <CoreFoundation/CoreFoundation.h> #include "base/basictypes.h" #include "base/scoped_cftyperef.h" +namespace gfx { +class Rect; +} +class FilePath; + namespace printing { // This class creates a graphics context that renders into a PDF data stream. @@ -45,6 +50,17 @@ class PdfMetafile { // Closes the PDF file; no further rendering is allowed. void Close(); + // Renders the given page into |rect| in the given context. + // Pages use a 1-based index. + bool RenderPage(unsigned int page_number, CGContextRef context, + const CGRect rect) const; + + size_t GetPageCount() const; + + // Returns the bounds of the given page. + // Pages use a 1-based index. + gfx::Rect GetPageBounds(unsigned int page_number) const; + // Returns the size of the underlying PDF data. Only valid after Close() has // been called. unsigned int GetDataSize() const; @@ -54,13 +70,23 @@ class PdfMetafile { // Returns true if the copy succeeds. bool GetData(void* dst_buffer, size_t dst_buffer_size) const; + // Saves the raw PDF data to the given file. For testing only. + // Returns true if writing succeeded. + bool SaveTo(const FilePath& file_path) const; + private: + // Returns a CGPDFDocumentRef version of pdf_data_. + CGPDFDocumentRef GetPDFDocument() const; + // Context for rendering to the pdf. scoped_cftyperef<CGContextRef> context_; // PDF backing store. scoped_cftyperef<CFMutableDataRef> pdf_data_; + // Lazily-created CGPDFDocument representation of pdf_data_. + mutable scoped_cftyperef<CGPDFDocumentRef> pdf_doc_; + // Whether or not a page is currently open. bool page_is_open_; |