diff options
Diffstat (limited to 'printing')
-rw-r--r-- | printing/emf_win.cc | 3 | ||||
-rw-r--r-- | printing/emf_win.h | 4 | ||||
-rw-r--r-- | printing/metafile.h | 3 | ||||
-rw-r--r-- | printing/pdf_metafile_cairo_linux.cc | 4 | ||||
-rw-r--r-- | printing/pdf_metafile_cairo_linux.h | 4 | ||||
-rw-r--r-- | printing/pdf_metafile_cg_mac.cc | 2 | ||||
-rw-r--r-- | printing/pdf_metafile_cg_mac.h | 4 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.cc | 21 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.h | 10 |
9 files changed, 30 insertions, 25 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 4cb8530..920d64f 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -404,8 +404,9 @@ bool Emf::Record::SafePlayback(const XFORM* base_matrix) const { } SkDevice* Emf::StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, + int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) { + DCHECK(page_number == page_count_); if (!StartPage(page_size, content_area, scale_factor)) return NULL; diff --git a/printing/emf_win.h b/printing/emf_win.h index f7e0ed5..a4584c9 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -46,8 +46,8 @@ class Emf : public Metafile { virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); virtual SkDevice* StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, - const float& scale_factor); + int page_number, const gfx::Size& page_size, + const gfx::Rect& content_area, const float& scale_factor); // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls // (since StartPage and EndPage do not work in a metafile DC). Only valid // when hdc_ is non-NULL. |page_size|, |content_area|, and |scale_factor| are diff --git a/printing/metafile.h b/printing/metafile.h index 84c0556..dbb838c 100644 --- a/printing/metafile.h +++ b/printing/metafile.h @@ -53,8 +53,9 @@ class Metafile { // This method calls StartPage and then returns an appropriate // VectorPlatformDevice implementation bound to the context created by - // StartPage or NULL on error. + // StartPage or NULL on error. |page_number| is zero based. virtual SkDevice* StartPageForVectorCanvas( + int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) = 0; diff --git a/printing/pdf_metafile_cairo_linux.cc b/printing/pdf_metafile_cairo_linux.cc index af2aa5c..581b158 100644 --- a/printing/pdf_metafile_cairo_linux.cc +++ b/printing/pdf_metafile_cairo_linux.cc @@ -119,8 +119,8 @@ bool PdfMetafileCairo::InitFromData(const void* src_buffer, } SkDevice* PdfMetafileCairo::StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, - const float& scale_factor) { + int /*page_number*/, const gfx::Size& page_size, + const gfx::Rect& content_area, const float& scale_factor) { if (!StartPage(page_size, content_area, scale_factor)) return NULL; diff --git a/printing/pdf_metafile_cairo_linux.h b/printing/pdf_metafile_cairo_linux.h index 6f07ae0..62fd814 100644 --- a/printing/pdf_metafile_cairo_linux.h +++ b/printing/pdf_metafile_cairo_linux.h @@ -37,8 +37,8 @@ class PdfMetafileCairo : public Metafile { virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); virtual SkDevice* StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, - const float& scale_factor); + int page_number, const gfx::Size& page_size, + const gfx::Rect& content_area, const float& scale_factor); virtual bool StartPage(const gfx::Size& page_size, const gfx::Rect& content_area, diff --git a/printing/pdf_metafile_cg_mac.cc b/printing/pdf_metafile_cg_mac.cc index 994f58f..6206552 100644 --- a/printing/pdf_metafile_cg_mac.cc +++ b/printing/pdf_metafile_cg_mac.cc @@ -107,7 +107,7 @@ bool PdfMetafileCg::InitFromData(const void* src_buffer, } SkDevice* PdfMetafileCg::StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, + int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) { NOTIMPLEMENTED(); return NULL; diff --git a/printing/pdf_metafile_cg_mac.h b/printing/pdf_metafile_cg_mac.h index 5a7f56d..488abe8 100644 --- a/printing/pdf_metafile_cg_mac.h +++ b/printing/pdf_metafile_cg_mac.h @@ -36,8 +36,8 @@ class PdfMetafileCg : public Metafile, public base::ThreadChecker { // Not implemented on mac. virtual SkDevice* StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, - const float& scale_factor); + int page_number, const gfx::Size& page_size, + const gfx::Rect& content_area, const float& scale_factor); virtual bool StartPage(const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor); diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index 1f08ad0..638fa7b 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -49,10 +49,11 @@ bool PdfMetafileSkia::InitFromData(const void* src_buffer, } SkDevice* PdfMetafileSkia::StartPageForVectorCanvas( - const gfx::Size& page_size, const gfx::Rect& content_area, + int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) { - DCHECK (!page_outstanding_); - page_outstanding_ = true; + DCHECK_EQ(outstanding_page_number_, kNoOutstandingPage); + DCHECK_GE(page_number, 0); + outstanding_page_number_ = page_number; // Adjust for the margins and apply the scale factor. SkMatrix transform; @@ -83,9 +84,11 @@ bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, bool PdfMetafileSkia::FinishPage() { DCHECK(data_->current_page_.get()); + DCHECK_GE(outstanding_page_number_, 0); - data_->pdf_doc_.appendPage(data_->current_page_.get()); - page_outstanding_ = false; + data_->pdf_doc_.setPage(outstanding_page_number_ + 1, + data_->current_page_.get()); + outstanding_page_number_ = kNoOutstandingPage; return true; } @@ -94,7 +97,7 @@ bool PdfMetafileSkia::FinishDocument() { if (data_->pdf_stream_.getOffset()) return true; - if (page_outstanding_) + if (outstanding_page_number_ >= 0) FinishPage(); data_->current_page_ = NULL; @@ -236,11 +239,11 @@ bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData), - draft_(false), - page_outstanding_(false) {} + outstanding_page_number_(kNoOutstandingPage) { +} PdfMetafileSkia* PdfMetafileSkia::GetMetafileForCurrentPage() { - SkPDFDocument pdf_doc; + SkPDFDocument pdf_doc(SkPDFDocument::kDraftMode_Flags); SkDynamicMemoryWStream pdf_stream; if (!pdf_doc.appendPage(data_->current_page_.get())) return NULL; diff --git a/printing/pdf_metafile_skia.h b/printing/pdf_metafile_skia.h index 5d6d448..4ce5337 100644 --- a/printing/pdf_metafile_skia.h +++ b/printing/pdf_metafile_skia.h @@ -30,6 +30,7 @@ class PdfMetafileSkia : public Metafile { virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); virtual SkDevice* StartPageForVectorCanvas( + int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor); @@ -72,13 +73,12 @@ class PdfMetafileSkia : public Metafile { PdfMetafileSkia* GetMetafileForCurrentPage(); private: - scoped_ptr<PdfMetafileSkiaData> data_; + static const int kNoOutstandingPage = -1; - // True when a draft version of metafile is requested. - mutable bool draft_; + scoped_ptr<PdfMetafileSkiaData> data_; - // True when finish page is outstanding for current page. - bool page_outstanding_; + // Page number of the outstanding page, or kNoOutstandingPage. + int outstanding_page_number_; DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); }; |