diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 16:44:20 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 16:44:20 +0000 |
commit | 534c4fb35c8c195c6d82e7e12ac303397e796825 (patch) | |
tree | 1bfdb823901de172173b19f58b0aab493e1bb932 /printing | |
parent | 1c78d786e3889ca1b783ab31ac3a16449e718f6f (diff) | |
download | chromium_src-534c4fb35c8c195c6d82e7e12ac303397e796825.zip chromium_src-534c4fb35c8c195c6d82e7e12ac303397e796825.tar.gz chromium_src-534c4fb35c8c195c6d82e7e12ac303397e796825.tar.bz2 |
PrintPreview: Remove |page_number| from StartPageForVectorCanvas function and |page_slot| from PrintMsg_PrintPage_Params.
We will not add preview pages to the complete metafile in out of order fashion.
BUG=none
TEST=print preview works after code changes.
Review URL: http://codereview.chromium.org/7549001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95092 0039d316-1c4b-4281-b951-d872f2087c98
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 | 17 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.h | 7 |
9 files changed, 20 insertions, 28 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 920d64f..4cb8530 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -404,9 +404,8 @@ bool Emf::Record::SafePlayback(const XFORM* base_matrix) const { } SkDevice* Emf::StartPageForVectorCanvas( - int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, + 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 a4584c9..f7e0ed5 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( - int page_number, const gfx::Size& page_size, - const gfx::Rect& content_area, const float& scale_factor); + 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 dbb838c..84c0556 100644 --- a/printing/metafile.h +++ b/printing/metafile.h @@ -53,9 +53,8 @@ class Metafile { // This method calls StartPage and then returns an appropriate // VectorPlatformDevice implementation bound to the context created by - // StartPage or NULL on error. |page_number| is zero based. + // StartPage or NULL on error. 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 581b158..af2aa5c 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( - int /*page_number*/, const gfx::Size& page_size, - const gfx::Rect& content_area, const float& scale_factor) { + 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 62fd814..6f07ae0 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( - int page_number, const gfx::Size& page_size, - const gfx::Rect& content_area, const float& scale_factor); + 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 0722231..1cf7f7b 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( - int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, + 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 488abe8..5a7f56d 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( - int page_number, const gfx::Size& page_size, - const gfx::Rect& content_area, const float& scale_factor); + 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 638fa7b..bc44131 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -49,11 +49,10 @@ bool PdfMetafileSkia::InitFromData(const void* src_buffer, } SkDevice* PdfMetafileSkia::StartPageForVectorCanvas( - int page_number, const gfx::Size& page_size, const gfx::Rect& content_area, + const gfx::Size& page_size, const gfx::Rect& content_area, const float& scale_factor) { - DCHECK_EQ(outstanding_page_number_, kNoOutstandingPage); - DCHECK_GE(page_number, 0); - outstanding_page_number_ = page_number; + DCHECK(!page_outstanding_); + page_outstanding_ = true; // Adjust for the margins and apply the scale factor. SkMatrix transform; @@ -84,11 +83,9 @@ 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_.setPage(outstanding_page_number_ + 1, - data_->current_page_.get()); - outstanding_page_number_ = kNoOutstandingPage; + data_->pdf_doc_.appendPage(data_->current_page_.get()); + page_outstanding_ = false; return true; } @@ -97,7 +94,7 @@ bool PdfMetafileSkia::FinishDocument() { if (data_->pdf_stream_.getOffset()) return true; - if (outstanding_page_number_ >= 0) + if (page_outstanding_) FinishPage(); data_->current_page_ = NULL; @@ -239,7 +236,7 @@ bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData), - outstanding_page_number_(kNoOutstandingPage) { + page_outstanding_(false) { } PdfMetafileSkia* PdfMetafileSkia::GetMetafileForCurrentPage() { diff --git a/printing/pdf_metafile_skia.h b/printing/pdf_metafile_skia.h index 4ce5337..d3beb3b 100644 --- a/printing/pdf_metafile_skia.h +++ b/printing/pdf_metafile_skia.h @@ -30,7 +30,6 @@ 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); @@ -73,12 +72,10 @@ class PdfMetafileSkia : public Metafile { PdfMetafileSkia* GetMetafileForCurrentPage(); private: - static const int kNoOutstandingPage = -1; - scoped_ptr<PdfMetafileSkiaData> data_; - // Page number of the outstanding page, or kNoOutstandingPage. - int outstanding_page_number_; + // True when finish page is outstanding for current page. + bool page_outstanding_; DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); }; |