Chromium Code Reviews| 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/pdf_metafile_skia.h" | 5 #include "printing/pdf_metafile_skia.h" |
| 6 | 6 |
| 7 #include "base/eintr_wrapper.h" | 7 #include "base/eintr_wrapper.h" |
| 8 #include "base/file_descriptor_posix.h" | 8 #include "base/file_descriptor_posix.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 DCHECK(!page_outstanding_); | 54 DCHECK(!page_outstanding_); |
| 55 page_outstanding_ = true; | 55 page_outstanding_ = true; |
| 56 | 56 |
| 57 // Adjust for the margins and apply the scale factor. | 57 // Adjust for the margins and apply the scale factor. |
| 58 SkMatrix transform; | 58 SkMatrix transform; |
| 59 transform.setTranslate(SkIntToScalar(content_area.x()), | 59 transform.setTranslate(SkIntToScalar(content_area.x()), |
| 60 SkIntToScalar(content_area.y())); | 60 SkIntToScalar(content_area.y())); |
| 61 transform.preScale(SkFloatToScalar(scale_factor), | 61 transform.preScale(SkFloatToScalar(scale_factor), |
| 62 SkFloatToScalar(scale_factor)); | 62 SkFloatToScalar(scale_factor)); |
| 63 | 63 |
| 64 // TODO(ctguil): Refactor: don't create the PDF device explicitly here. | 64 // TODO(ctguil): Refactor: don't create the PDF device explicitly here. |
|
vandebo (ex-Chrome)
2011/08/23 17:40:35
nit: remove now old comment.
Jeff Timanus
2011/08/23 21:13:02
Done.
| |
| 65 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); | 65 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); |
| 66 SkISize pdf_content_size = | 66 SkISize pdf_content_size = |
| 67 SkISize::Make(content_area.width(), content_area.height()); | 67 SkISize::Make(content_area.width(), content_area.height()); |
| 68 SkRefPtr<SkPDFDevice> pdf_device = | 68 SkRefPtr<SkPDFDevice> pdf_device = |
| 69 new SkPDFDevice(pdf_page_size, pdf_content_size, transform); | 69 new skia::VectorPlatformDeviceSkia(pdf_page_size, pdf_content_size, |
| 70 pdf_device->unref(); // SkRefPtr and new both took a reference. | 70 transform); |
| 71 skia::VectorPlatformDeviceSkia* device = | 71 data_->current_page_ = pdf_device; |
| 72 new skia::VectorPlatformDeviceSkia(pdf_device.get()); | 72 return pdf_device.get(); |
| 73 data_->current_page_ = device->PdfDevice(); | |
| 74 return device; | |
| 75 } | 73 } |
| 76 | 74 |
| 77 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, | 75 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, |
| 78 const gfx::Rect& content_area, | 76 const gfx::Rect& content_area, |
| 79 const float& scale_factor) { | 77 const float& scale_factor) { |
| 80 NOTREACHED(); | 78 NOTREACHED(); |
| 81 return NULL; | 79 return NULL; |
| 82 } | 80 } |
| 83 | 81 |
| 84 bool PdfMetafileSkia::FinishPage() { | 82 bool PdfMetafileSkia::FinishPage() { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 SkAutoDataUnref data(pdf_stream.copyToData()); | 249 SkAutoDataUnref data(pdf_stream.copyToData()); |
| 252 if (data.size() == 0) | 250 if (data.size() == 0) |
| 253 return NULL; | 251 return NULL; |
| 254 | 252 |
| 255 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia; | 253 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia; |
| 256 metafile->InitFromData(data.bytes(), data.size()); | 254 metafile->InitFromData(data.bytes(), data.size()); |
| 257 return metafile; | 255 return metafile; |
| 258 } | 256 } |
| 259 | 257 |
| 260 } // namespace printing | 258 } // namespace printing |
| OLD | NEW |