diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 06:36:58 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 06:36:58 +0000 |
commit | 481edc5493d2a5bd85ee882b3cf1a21f487a2a94 (patch) | |
tree | b35c073123e217e8306d0d96467a7297bc7e6991 /printing/emf_win.cc | |
parent | 12b251a3514d18fc598766a1277bb3ca36bc9448 (diff) | |
download | chromium_src-481edc5493d2a5bd85ee882b3cf1a21f487a2a94.zip chromium_src-481edc5493d2a5bd85ee882b3cf1a21f487a2a94.tar.gz chromium_src-481edc5493d2a5bd85ee882b3cf1a21f487a2a94.tar.bz2 |
Cleanup NativeMetafile (win) interface and EMF class.
- Rename CreateDc to Init() and remove unused argument (all non-test calls were CreateDc(NULL, NULL). [This matches cross platform interface.]
- Remove CreateFileBackedDc from the NativeMetafile interface and make InitToFile() in the EMF class.
- Remove CreateFromFile from the NativeMetafile interface and make it InitFromFile() in the EMF class.
- Move the CloseEmf method into the destructor, making the Emf class a use once class (matches actual use).
BUG=NONE
TEST=NONE
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=78666
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=78669
Review URL: http://codereview.chromium.org/6695013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/emf_win.cc')
-rw-r--r-- | printing/emf_win.cc | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 8609c34..c411a40 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -53,41 +53,39 @@ Emf::Emf() : emf_(NULL), hdc_(NULL) { } Emf::~Emf() { - CloseEmf(); - DCHECK(!emf_ && !hdc_); + DCHECK(!hdc_); + if (emf_) + DeleteEnhMetaFile(emf_); } -bool Emf::InitFromData(const void* src_buffer, uint32 src_buffer_size) { +bool Emf::InitToFile(const FilePath& metafile_path) { DCHECK(!emf_ && !hdc_); - emf_ = SetEnhMetaFileBits(src_buffer_size, - reinterpret_cast<const BYTE*>(src_buffer)); - return emf_ != NULL; + hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); + DCHECK(hdc_); + return hdc_ != NULL; } -bool Emf::CreateDc(HDC sibling, const RECT* rect) { +bool Emf::InitFromFile(const FilePath& metafile_path) { DCHECK(!emf_ && !hdc_); - hdc_ = CreateEnhMetaFile(sibling, NULL, rect, NULL); - DCHECK(hdc_); - return hdc_ != NULL; + emf_ = GetEnhMetaFile(metafile_path.value().c_str()); + DCHECK(emf_); + return emf_ != NULL; } -bool Emf::CreateFileBackedDc(HDC sibling, const RECT* rect, - const FilePath& path) { +bool Emf::Init() { DCHECK(!emf_ && !hdc_); - DCHECK(!path.empty()); - hdc_ = CreateEnhMetaFile(sibling, path.value().c_str(), rect, NULL); + hdc_ = CreateEnhMetaFile(NULL, NULL, NULL, NULL); DCHECK(hdc_); return hdc_ != NULL; } -bool Emf::CreateFromFile(const FilePath& metafile_path) { +bool Emf::InitFromData(const void* src_buffer, uint32 src_buffer_size) { DCHECK(!emf_ && !hdc_); - emf_ = GetEnhMetaFile(metafile_path.value().c_str()); - DCHECK(emf_); + emf_ = SetEnhMetaFileBits(src_buffer_size, + reinterpret_cast<const BYTE*>(src_buffer)); return emf_ != NULL; } - bool Emf::FinishDocument() { DCHECK(!emf_ && hdc_); emf_ = CloseEnhMetaFile(hdc_); @@ -96,14 +94,6 @@ bool Emf::FinishDocument() { return emf_ != NULL; } -void Emf::CloseEmf() { - DCHECK(!hdc_); - if (emf_) { - DeleteEnhMetaFile(emf_); - emf_ = NULL; - } -} - bool Emf::Playback(HDC hdc, const RECT* rect) const { DCHECK(emf_ && !hdc_); RECT bounds; |