OLD | NEW |
1 // Copyright (c) 2010 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" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/gfx/codec/jpeg_codec.h" | 14 #include "ui/gfx/codec/jpeg_codec.h" |
14 #include "ui/gfx/codec/png_codec.h" | 15 #include "ui/gfx/codec/png_codec.h" |
15 #include "ui/gfx/gdi_util.h" | 16 #include "ui/gfx/gdi_util.h" |
16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 const int kCustomGdiCommentSignature = 0xdeadbabe; | 20 const int kCustomGdiCommentSignature = 0xdeadbabe; |
20 struct PageBreakRecord { | 21 struct PageBreakRecord { |
21 int signature; | 22 int signature; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 break; | 404 break; |
404 } | 405 } |
405 default: { | 406 default: { |
406 res = Play(); | 407 res = Play(); |
407 break; | 408 break; |
408 } | 409 } |
409 } | 410 } |
410 return res; | 411 return res; |
411 } | 412 } |
412 | 413 |
| 414 skia::PlatformDevice* Emf::StartPageForVectorCanvas( |
| 415 const gfx::Size& page_size, const gfx::Point& /*content_origin*/, |
| 416 const float& scale_factor) { |
| 417 DCHECK_EQ(1.0f, scale_factor); // We don't support scaling here. |
| 418 if (!StartPage()) |
| 419 return NULL; |
| 420 |
| 421 return skia::VectorPlatformDeviceFactory::CreateDevice(page_size.width(), |
| 422 page_size.height(), |
| 423 true, hdc_); |
| 424 } |
| 425 |
413 bool Emf::StartPage() { | 426 bool Emf::StartPage() { |
414 DCHECK(hdc_); | 427 DCHECK(hdc_); |
415 if (!hdc_) | 428 if (!hdc_) |
416 return false; | 429 return false; |
417 PageBreakRecord record(PageBreakRecord::START_PAGE); | 430 PageBreakRecord record(PageBreakRecord::START_PAGE); |
418 return !!GdiComment(hdc_, sizeof(record), | 431 return !!GdiComment(hdc_, sizeof(record), |
419 reinterpret_cast<const BYTE *>(&record)); | 432 reinterpret_cast<const BYTE *>(&record)); |
420 } | 433 } |
421 | 434 |
422 bool Emf::FinishPage() { | 435 bool Emf::FinishPage() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 } else { | 480 } else { |
468 DCHECK_EQ(emf.context_.handle_table, handle_table); | 481 DCHECK_EQ(emf.context_.handle_table, handle_table); |
469 DCHECK_EQ(emf.context_.objects_count, objects_count); | 482 DCHECK_EQ(emf.context_.objects_count, objects_count); |
470 DCHECK_EQ(emf.context_.hdc, hdc); | 483 DCHECK_EQ(emf.context_.hdc, hdc); |
471 } | 484 } |
472 emf.items_.push_back(Record(&emf.context_, record)); | 485 emf.items_.push_back(Record(&emf.context_, record)); |
473 return 1; | 486 return 1; |
474 } | 487 } |
475 | 488 |
476 } // namespace printing | 489 } // namespace printing |
OLD | NEW |