| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "skia/ext/vector_platform_device_win.h" | |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 #include "ui/gfx/codec/jpeg_codec.h" | 13 #include "ui/gfx/codec/jpeg_codec.h" |
| 15 #include "ui/gfx/codec/png_codec.h" | 14 #include "ui/gfx/codec/png_codec.h" |
| 16 #include "ui/gfx/gdi_util.h" | 15 #include "ui/gfx/gdi_util.h" |
| 17 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
| 18 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 const int kCustomGdiCommentSignature = 0xdeadbabe; | 21 const int kCustomGdiCommentSignature = 0xdeadbabe; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 break; | 405 break; |
| 407 } | 406 } |
| 408 default: { | 407 default: { |
| 409 res = Play(); | 408 res = Play(); |
| 410 break; | 409 break; |
| 411 } | 410 } |
| 412 } | 411 } |
| 413 return res; | 412 return res; |
| 414 } | 413 } |
| 415 | 414 |
| 416 skia::PlatformDevice* Emf::StartPageForVectorCanvas( | |
| 417 const gfx::Size& page_size, const gfx::Point& content_origin, | |
| 418 const float& scale_factor) { | |
| 419 if (!StartPage(page_size, content_origin, scale_factor)) | |
| 420 return NULL; | |
| 421 | |
| 422 return skia::VectorPlatformDeviceFactory::CreateDevice(page_size.width(), | |
| 423 page_size.height(), | |
| 424 true, hdc_); | |
| 425 } | |
| 426 | |
| 427 bool Emf::StartPage(const gfx::Size& /*page_size*/, | 415 bool Emf::StartPage(const gfx::Size& /*page_size*/, |
| 428 const gfx::Point& /*content_origin*/, | 416 const gfx::Point& /*content_origin*/, |
| 429 const float& scale_factor) { | 417 const float& scale_factor) { |
| 430 DCHECK_EQ(1.0f, scale_factor); // We don't support scaling here. | 418 DCHECK_EQ(scale_factor, 1); |
| 431 DCHECK(hdc_); | 419 DCHECK(hdc_); |
| 432 if (!hdc_) | 420 if (!hdc_) |
| 433 return false; | 421 return false; |
| 434 PageBreakRecord record(PageBreakRecord::START_PAGE); | 422 PageBreakRecord record(PageBreakRecord::START_PAGE); |
| 435 return !!GdiComment(hdc_, sizeof(record), | 423 return !!GdiComment(hdc_, sizeof(record), |
| 436 reinterpret_cast<const BYTE *>(&record)); | 424 reinterpret_cast<const BYTE *>(&record)); |
| 437 } | 425 } |
| 438 | 426 |
| 439 bool Emf::FinishPage() { | 427 bool Emf::FinishPage() { |
| 440 DCHECK(hdc_); | 428 DCHECK(hdc_); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } else { | 472 } else { |
| 485 DCHECK_EQ(emf.context_.handle_table, handle_table); | 473 DCHECK_EQ(emf.context_.handle_table, handle_table); |
| 486 DCHECK_EQ(emf.context_.objects_count, objects_count); | 474 DCHECK_EQ(emf.context_.objects_count, objects_count); |
| 487 DCHECK_EQ(emf.context_.hdc, hdc); | 475 DCHECK_EQ(emf.context_.hdc, hdc); |
| 488 } | 476 } |
| 489 emf.items_.push_back(Record(&emf.context_, record)); | 477 emf.items_.push_back(Record(&emf.context_, record)); |
| 490 return 1; | 478 return 1; |
| 491 } | 479 } |
| 492 | 480 |
| 493 } // namespace printing | 481 } // namespace printing |
| OLD | NEW |