Chromium Code Reviews| 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/pdf_metafile_cg_mac.h" | 5 #include "printing/pdf_metafile_cg_mac.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 context_.reset(CGPDFContextCreate(pdf_consumer, nullptr, nullptr)); | 80 context_.reset(CGPDFContextCreate(pdf_consumer, nullptr, nullptr)); |
| 81 if (!context_.get()) { | 81 if (!context_.get()) { |
| 82 LOG(ERROR) << "Failed to create pdf context for metafile"; | 82 LOG(ERROR) << "Failed to create pdf context for metafile"; |
| 83 pdf_data_.reset(); | 83 pdf_data_.reset(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool PdfMetafileCg::InitFromData(const void* src_buffer, | 89 bool PdfMetafileCg::InitFromData(const void* src_buffer, |
| 90 uint32_t src_buffer_size) { | 90 size_t src_buffer_size) { |
| 91 DCHECK(!context_.get()); | 91 DCHECK(!context_.get()); |
| 92 DCHECK(!pdf_data_.get()); | 92 DCHECK(!pdf_data_.get()); |
| 93 | 93 |
| 94 if (!src_buffer || src_buffer_size == 0) { | 94 if (!src_buffer || !src_buffer_size) |
| 95 return false; | 95 return false; |
| 96 } | |
| 97 | 96 |
| 98 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size)); | 97 pdf_data_.reset(CFDataCreateMutable(kCFAllocatorDefault, src_buffer_size)); |
|
Will Harris
2016/10/27 22:52:34
is a CFIndex the same type as a size_t? I have no
Lei Zhang
2016/10/27 23:15:14
Neither do I, but I found https://opensource.apple
| |
| 99 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer), | 98 CFDataAppendBytes(pdf_data_, static_cast<const UInt8*>(src_buffer), |
| 100 src_buffer_size); | 99 src_buffer_size); |
| 101 | 100 |
| 102 return true; | 101 return true; |
| 103 } | 102 } |
| 104 | 103 |
| 105 void PdfMetafileCg::StartPage(const gfx::Size& page_size, | 104 void PdfMetafileCg::StartPage(const gfx::Size& page_size, |
| 106 const gfx::Rect& content_area, | 105 const gfx::Rect& content_area, |
| 107 const float& scale_factor) { | 106 const float& scale_factor) { |
| 108 DCHECK(context_.get()); | 107 DCHECK(context_.get()); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 288 |
| 290 if (!pdf_doc_.get()) { | 289 if (!pdf_doc_.get()) { |
| 291 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( | 290 ScopedCFTypeRef<CGDataProviderRef> pdf_data_provider( |
| 292 CGDataProviderCreateWithCFData(pdf_data_)); | 291 CGDataProviderCreateWithCFData(pdf_data_)); |
| 293 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); | 292 pdf_doc_.reset(CGPDFDocumentCreateWithProvider(pdf_data_provider)); |
| 294 } | 293 } |
| 295 return pdf_doc_.get(); | 294 return pdf_doc_.get(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 } // namespace printing | 297 } // namespace printing |
| OLD | NEW |