| 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/file_path.h" | 7 #include "base/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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { | 167 Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { |
| 168 } | 168 } |
| 169 | 169 |
| 170 Emf::~Emf() { | 170 Emf::~Emf() { |
| 171 DCHECK(!hdc_); | 171 DCHECK(!hdc_); |
| 172 if (emf_) | 172 if (emf_) |
| 173 DeleteEnhMetaFile(emf_); | 173 DeleteEnhMetaFile(emf_); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool Emf::InitToFile(const FilePath& metafile_path) { | 176 bool Emf::InitToFile(const base::FilePath& metafile_path) { |
| 177 DCHECK(!emf_ && !hdc_); | 177 DCHECK(!emf_ && !hdc_); |
| 178 hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); | 178 hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); |
| 179 DCHECK(hdc_); | 179 DCHECK(hdc_); |
| 180 return hdc_ != NULL; | 180 return hdc_ != NULL; |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool Emf::InitFromFile(const FilePath& metafile_path) { | 183 bool Emf::InitFromFile(const base::FilePath& metafile_path) { |
| 184 DCHECK(!emf_ && !hdc_); | 184 DCHECK(!emf_ && !hdc_); |
| 185 emf_ = GetEnhMetaFile(metafile_path.value().c_str()); | 185 emf_ = GetEnhMetaFile(metafile_path.value().c_str()); |
| 186 DCHECK(emf_); | 186 DCHECK(emf_); |
| 187 return emf_ != NULL; | 187 return emf_ != NULL; |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool Emf::Init() { | 190 bool Emf::Init() { |
| 191 DCHECK(!emf_ && !hdc_); | 191 DCHECK(!emf_ && !hdc_); |
| 192 hdc_ = CreateEnhMetaFile(NULL, NULL, NULL, NULL); | 192 hdc_ = CreateEnhMetaFile(NULL, NULL, NULL, NULL); |
| 193 DCHECK(hdc_); | 193 DCHECK(hdc_); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 uint32 size = GetDataSize(); | 270 uint32 size = GetDataSize(); |
| 271 if (!size) | 271 if (!size) |
| 272 return false; | 272 return false; |
| 273 | 273 |
| 274 buffer->resize(size); | 274 buffer->resize(size); |
| 275 if (!GetData(&buffer->front(), size)) | 275 if (!GetData(&buffer->front(), size)) |
| 276 return false; | 276 return false; |
| 277 return true; | 277 return true; |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool Emf::SaveTo(const FilePath& file_path) const { | 280 bool Emf::SaveTo(const base::FilePath& file_path) const { |
| 281 HANDLE file = CreateFile(file_path.value().c_str(), GENERIC_WRITE, | 281 HANDLE file = CreateFile(file_path.value().c_str(), GENERIC_WRITE, |
| 282 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, | 282 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, |
| 283 CREATE_ALWAYS, 0, NULL); | 283 CREATE_ALWAYS, 0, NULL); |
| 284 if (file == INVALID_HANDLE_VALUE) | 284 if (file == INVALID_HANDLE_VALUE) |
| 285 return false; | 285 return false; |
| 286 | 286 |
| 287 bool success = false; | 287 bool success = false; |
| 288 std::vector<uint8> buffer; | 288 std::vector<uint8> buffer; |
| 289 if (GetDataAsVector(&buffer)) { | 289 if (GetDataAsVector(&buffer)) { |
| 290 DWORD written = 0; | 290 DWORD written = 0; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, | 666 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, |
| 667 &page_bounds.ToRECT()); | 667 &page_bounds.ToRECT()); |
| 668 | 668 |
| 669 result->FinishDocument(); | 669 result->FinishDocument(); |
| 670 | 670 |
| 671 return result.release(); | 671 return result.release(); |
| 672 } | 672 } |
| 673 | 673 |
| 674 | 674 |
| 675 } // namespace printing | 675 } // namespace printing |
| OLD | NEW |