| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "printing/emf_win.h" | 5 #include "printing/emf_win.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/win/scoped_gdi_object.h" | 10 #include "base/win/scoped_gdi_object.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ExtEscape(dc, escape, size, reinterpret_cast<LPCSTR>(bits), | 162 ExtEscape(dc, escape, size, reinterpret_cast<LPCSTR>(bits), |
| 163 sizeof(supported), reinterpret_cast<LPSTR>(&supported)); | 163 sizeof(supported), reinterpret_cast<LPSTR>(&supported)); |
| 164 } | 164 } |
| 165 return !!supported; | 165 return !!supported; |
| 166 } | 166 } |
| 167 | 167 |
| 168 Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { | 168 Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { |
| 169 } | 169 } |
| 170 | 170 |
| 171 Emf::~Emf() { | 171 Emf::~Emf() { |
| 172 Close(); |
| 173 } |
| 174 |
| 175 void Emf::Close() { |
| 172 DCHECK(!hdc_); | 176 DCHECK(!hdc_); |
| 173 if (emf_) | 177 if (emf_) |
| 174 DeleteEnhMetaFile(emf_); | 178 DeleteEnhMetaFile(emf_); |
| 179 emf_ = NULL; |
| 175 } | 180 } |
| 176 | 181 |
| 177 bool Emf::InitToFile(const base::FilePath& metafile_path) { | 182 bool Emf::InitToFile(const base::FilePath& metafile_path) { |
| 178 DCHECK(!emf_ && !hdc_); | 183 DCHECK(!emf_ && !hdc_); |
| 179 hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); | 184 hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); |
| 180 DCHECK(hdc_); | 185 DCHECK(hdc_); |
| 181 return hdc_ != NULL; | 186 return hdc_ != NULL; |
| 182 } | 187 } |
| 183 | 188 |
| 184 bool Emf::InitFromFile(const base::FilePath& metafile_path) { | 189 bool Emf::InitFromFile(const base::FilePath& metafile_path) { |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 RECT rect = page_bounds.ToRECT(); | 674 RECT rect = page_bounds.ToRECT(); |
| 670 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect); | 675 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect); |
| 671 | 676 |
| 672 result->FinishDocument(); | 677 result->FinishDocument(); |
| 673 | 678 |
| 674 return result.release(); | 679 return result.release(); |
| 675 } | 680 } |
| 676 | 681 |
| 677 | 682 |
| 678 } // namespace printing | 683 } // namespace printing |
| OLD | NEW |