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

Unified Diff: printing/emf_win.cc

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: Addressing reviewer's comments 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/emf_win.cc
diff --git a/printing/emf_win.cc b/printing/emf_win.cc
index f2b22fa13f8b865b4c01924254fade83077b0a1b..ff7c304b435093fbe89f859cfdfe9ac807487362 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -68,7 +68,8 @@ bool Emf::CreateDc(HDC sibling, const RECT* rect) {
return hdc_ != NULL;
}
-bool Emf::CreateFileBackedDc(HDC sibling, const RECT* rect,
+bool Emf::CreateFileBackedDc(HDC sibling,
vandebo (ex-Chrome) 2011/03/14 20:24:25 Extra line break.
dpapad 2011/03/14 22:15:12 Done.
+ const RECT* rect,
const FilePath& path) {
DCHECK(!emf_ && !hdc_);
DCHECK(!path.empty());
@@ -85,7 +86,7 @@ bool Emf::CreateFromFile(const FilePath& metafile_path) {
}
-bool Emf::CloseDc() {
+bool Emf::Close() {
DCHECK(!emf_ && hdc_);
emf_ = CloseEnhMetaFile(hdc_);
DCHECK(emf_);
@@ -106,7 +107,7 @@ bool Emf::Playback(HDC hdc, const RECT* rect) const {
RECT bounds;
if (!rect) {
// Get the natural bounds of the EMF buffer.
- bounds = GetBounds().ToRECT();
+ bounds = GetPageBounds(1).ToRECT();
rect = &bounds;
}
return PlayEnhMetaFile(hdc, emf_, rect) != 0;
@@ -123,10 +124,10 @@ bool Emf::SafePlayback(HDC context) const {
emf_,
&Emf::SafePlaybackProc,
reinterpret_cast<void*>(&base_matrix),
- &GetBounds().ToRECT()) != 0;
+ &GetPageBounds(1).ToRECT()) != 0;
}
-gfx::Rect Emf::GetBounds() const {
+gfx::Rect Emf::GetPageBounds(unsigned int page_number) const {
DCHECK(emf_ && !hdc_);
vandebo (ex-Chrome) 2011/03/14 20:24:25 Add DCHECK_EQ(page_number, 1);
dpapad 2011/03/14 22:15:12 Done. static_cast is necessary to avoid compilatio
ENHMETAHEADER header;
if (GetEnhMetaFileHeader(emf_, sizeof(header), &header) != sizeof(header)) {
@@ -173,8 +174,8 @@ bool Emf::GetData(std::vector<uint8>* buffer) const {
return true;
}
-bool Emf::SaveTo(const std::wstring& filename) const {
- HANDLE file = CreateFile(filename.c_str(), GENERIC_WRITE,
+bool Emf::SaveTo(const FilePath& file_path) const {
+ HANDLE file = CreateFile(file_path.value().c_str(), GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, 0, NULL);
if (file == INVALID_HANDLE_VALUE)
@@ -194,6 +195,24 @@ bool Emf::SaveTo(const std::wstring& filename) const {
return success;
}
+bool Emf::StartPage() {
vandebo (ex-Chrome) 2011/03/14 20:24:25 No reason to move these methods.
dpapad 2011/03/14 22:15:12 Done.
vandebo (ex-Chrome) 2011/03/14 22:55:05 The CR still shows them moved. They used to be be
+ DCHECK(hdc_);
+ if (!hdc_)
+ return false;
+ PageBreakRecord record(PageBreakRecord::START_PAGE);
+ return !!GdiComment(hdc_, sizeof(record),
+ reinterpret_cast<const BYTE *>(&record));
+}
+
+bool Emf::FinishPage() {
+ DCHECK(hdc_);
+ if (!hdc_)
+ return false;
+ PageBreakRecord record(PageBreakRecord::END_PAGE);
+ return !!GdiComment(hdc_, sizeof(record),
+ reinterpret_cast<const BYTE *>(&record));
+}
+
int CALLBACK Emf::SafePlaybackProc(HDC hdc,
HANDLETABLE* handle_table,
const ENHMETARECORD* record,
@@ -409,25 +428,6 @@ bool Emf::Record::SafePlayback(const XFORM* base_matrix) const {
return res;
}
-bool Emf::StartPage() {
- DCHECK(hdc_);
- if (!hdc_)
- return false;
- PageBreakRecord record(PageBreakRecord::START_PAGE);
- return !!GdiComment(hdc_, sizeof(record),
- reinterpret_cast<const BYTE *>(&record));
-}
-
-bool Emf::EndPage() {
- DCHECK(hdc_);
- if (!hdc_)
- return false;
- PageBreakRecord record(PageBreakRecord::END_PAGE);
- return !!GdiComment(hdc_, sizeof(record),
- reinterpret_cast<const BYTE *>(&record));
-}
-
-
Emf::Enumerator::Enumerator(const Emf& emf, HDC context, const RECT* rect) {
context_.handle_table = NULL;
context_.objects_count = 0;

Powered by Google App Engine
This is Rietveld 408576698