diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 16:06:25 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 16:06:25 +0000 |
commit | 830cf7481fce9545527467d0b578b09baf0e6bb4 (patch) | |
tree | 9fd45614c7e4211af156a6016504229ba5728e5c /printing | |
parent | 00b1a06d7d0b2d1205bd913bb97d341d3e5ae4fb (diff) | |
download | chromium_src-830cf7481fce9545527467d0b578b09baf0e6bb4.zip chromium_src-830cf7481fce9545527467d0b578b09baf0e6bb4.tar.gz chromium_src-830cf7481fce9545527467d0b578b09baf0e6bb4.tar.bz2 |
Added a DCHECK to validate the metafile page count while handling alpha blend transparency.
Added a member variable |page_count_| in emf_win.h to track the pages count.
BUG=none
TEST=windows printing works after code changes.
Review URL: http://codereview.chromium.org/6790002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80167 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/emf_win.cc | 3 | ||||
-rw-r--r-- | printing/emf_win.h | 5 | ||||
-rw-r--r-- | printing/emf_win_unittest.cc | 1 |
3 files changed, 6 insertions, 3 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 467d4b3..849e125 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -49,7 +49,7 @@ bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits, return !!supported; } -Emf::Emf() : emf_(NULL), hdc_(NULL) { +Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { } Emf::~Emf() { @@ -421,6 +421,7 @@ bool Emf::StartPage(const gfx::Size& /*page_size*/, DCHECK(hdc_); if (!hdc_) return false; + page_count_++; PageBreakRecord record(PageBreakRecord::START_PAGE); return !!GdiComment(hdc_, sizeof(record), reinterpret_cast<const BYTE *>(&record)); diff --git a/printing/emf_win.h b/printing/emf_win.h index 5f9bd5a..ecc1028 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -70,8 +70,7 @@ class Emf : public NativeMetafile { virtual gfx::Rect GetPageBounds(unsigned int page_number) const; virtual unsigned int GetPageCount() const { - // TODO(dpapad): count the number of times StartPage() is called - return 1; + return page_count_; } virtual HDC context() const { @@ -106,6 +105,8 @@ class Emf : public NativeMetafile { // Valid when generating EMF data through a virtual HDC. HDC hdc_; + int page_count_; + DISALLOW_COPY_AND_ASSIGN(Emf); }; diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc index b401f5b..3ea1282 100644 --- a/printing/emf_win_unittest.cc +++ b/printing/emf_win_unittest.cc @@ -141,6 +141,7 @@ TEST_F(EmfPrintingTest, PageBreak) { EXPECT_TRUE(emf.FinishPage()); --pages; } + EXPECT_EQ(3U, emf.GetPageCount()); EXPECT_TRUE(emf.FinishDocument()); size = emf.GetDataSize(); EXPECT_TRUE(emf.GetDataAsVector(&data)); |