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.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return gfx::Rect(); | 239 return gfx::Rect(); |
240 } | 240 } |
241 // Add 1 to right and bottom because it's inclusive rectangle. | 241 // Add 1 to right and bottom because it's inclusive rectangle. |
242 // See ENHMETAHEADER. | 242 // See ENHMETAHEADER. |
243 return gfx::Rect(header.rclBounds.left, | 243 return gfx::Rect(header.rclBounds.left, |
244 header.rclBounds.top, | 244 header.rclBounds.top, |
245 header.rclBounds.right - header.rclBounds.left + 1, | 245 header.rclBounds.right - header.rclBounds.left + 1, |
246 header.rclBounds.bottom - header.rclBounds.top + 1); | 246 header.rclBounds.bottom - header.rclBounds.top + 1); |
247 } | 247 } |
248 | 248 |
| 249 unsigned int Emf::GetPageCount() const { |
| 250 return 1; |
| 251 } |
| 252 |
| 253 HDC Emf::context() const { |
| 254 return hdc_; |
| 255 } |
| 256 |
249 uint32 Emf::GetDataSize() const { | 257 uint32 Emf::GetDataSize() const { |
250 DCHECK(emf_ && !hdc_); | 258 DCHECK(emf_ && !hdc_); |
251 return GetEnhMetaFileBits(emf_, 0, NULL); | 259 return GetEnhMetaFileBits(emf_, 0, NULL); |
252 } | 260 } |
253 | 261 |
254 bool Emf::GetData(void* buffer, uint32 size) const { | 262 bool Emf::GetData(void* buffer, uint32 size) const { |
255 DCHECK(emf_ && !hdc_); | 263 DCHECK(emf_ && !hdc_); |
256 DCHECK(buffer && size); | 264 DCHECK(buffer && size); |
257 uint32 size2 = | 265 uint32 size2 = |
258 GetEnhMetaFileBits(emf_, size, reinterpret_cast<BYTE*>(buffer)); | 266 GetEnhMetaFileBits(emf_, size, reinterpret_cast<BYTE*>(buffer)); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 emf.emf(), | 473 emf.emf(), |
466 &Emf::Enumerator::EnhMetaFileProc, | 474 &Emf::Enumerator::EnhMetaFileProc, |
467 reinterpret_cast<void*>(this), | 475 reinterpret_cast<void*>(this), |
468 rect)) { | 476 rect)) { |
469 NOTREACHED(); | 477 NOTREACHED(); |
470 items_.clear(); | 478 items_.clear(); |
471 } | 479 } |
472 DCHECK_EQ(context_.hdc, context); | 480 DCHECK_EQ(context_.hdc, context); |
473 } | 481 } |
474 | 482 |
| 483 Emf::Enumerator::~Enumerator() { |
| 484 } |
| 485 |
475 Emf::Enumerator::const_iterator Emf::Enumerator::begin() const { | 486 Emf::Enumerator::const_iterator Emf::Enumerator::begin() const { |
476 return items_.begin(); | 487 return items_.begin(); |
477 } | 488 } |
478 | 489 |
479 Emf::Enumerator::const_iterator Emf::Enumerator::end() const { | 490 Emf::Enumerator::const_iterator Emf::Enumerator::end() const { |
480 return items_.end(); | 491 return items_.end(); |
481 } | 492 } |
482 | 493 |
483 int CALLBACK Emf::Enumerator::EnhMetaFileProc(HDC hdc, | 494 int CALLBACK Emf::Enumerator::EnhMetaFileProc(HDC hdc, |
484 HANDLETABLE* handle_table, | 495 HANDLETABLE* handle_table, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 RECT rect = page_bounds.ToRECT(); | 590 RECT rect = page_bounds.ToRECT(); |
580 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect); | 591 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect); |
581 | 592 |
582 result->FinishDocument(); | 593 result->FinishDocument(); |
583 | 594 |
584 return result.Pass(); | 595 return result.Pass(); |
585 } | 596 } |
586 | 597 |
587 | 598 |
588 } // namespace printing | 599 } // namespace printing |
OLD | NEW |