| 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_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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 /* TODO(caryclark): The set up of PluginInstance::PrintPDFOutput may result in | 173 /* TODO(caryclark): The set up of PluginInstance::PrintPDFOutput may result in |
| 174 rasterized output. Even if that flow uses PdfMetafileCg::RenderPage, | 174 rasterized output. Even if that flow uses PdfMetafileCg::RenderPage, |
| 175 the drawing of the PDF into the canvas may result in a rasterized output. | 175 the drawing of the PDF into the canvas may result in a rasterized output. |
| 176 PDFMetafileSkia::RenderPage should be not implemented as shown and instead | 176 PDFMetafileSkia::RenderPage should be not implemented as shown and instead |
| 177 should do something like the following CL in PluginInstance::PrintPDFOutput: | 177 should do something like the following CL in PluginInstance::PrintPDFOutput: |
| 178 http://codereview.chromium.org/7200040/diff/1/webkit/plugins/ppapi/ppapi_plugin_
instance.cc | 178 http://codereview.chromium.org/7200040/diff/1/webkit/plugins/ppapi/ppapi_plugin_
instance.cc |
| 179 */ | 179 */ |
| 180 bool PdfMetafileSkia::RenderPage(unsigned int page_number, | 180 bool PdfMetafileSkia::RenderPage(unsigned int page_number, |
| 181 CGContextRef context, | 181 CGContextRef context, |
| 182 const CGRect rect, | 182 const CGRect rect, |
| 183 bool shrink_to_fit, | 183 const MacRenderPageParams& params) const { |
| 184 bool stretch_to_fit, | |
| 185 bool center_horizontally, | |
| 186 bool center_vertically) const { | |
| 187 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); | 184 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); |
| 188 if (data_->pdf_cg_.GetDataSize() == 0) { | 185 if (data_->pdf_cg_.GetDataSize() == 0) { |
| 189 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); | 186 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); |
| 190 data_->pdf_cg_.InitFromData(data.bytes(), data.size()); | 187 data_->pdf_cg_.InitFromData(data.bytes(), data.size()); |
| 191 } | 188 } |
| 192 return data_->pdf_cg_.RenderPage(page_number, context, rect, shrink_to_fit, | 189 return data_->pdf_cg_.RenderPage(page_number, context, rect, params); |
| 193 stretch_to_fit, center_horizontally, | |
| 194 center_vertically); | |
| 195 } | 190 } |
| 196 #endif | 191 #endif |
| 197 | 192 |
| 198 #if defined(OS_CHROMEOS) | 193 #if defined(OS_CHROMEOS) |
| 199 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { | 194 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { |
| 200 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); | 195 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); |
| 201 | 196 |
| 202 if (fd.fd < 0) { | 197 if (fd.fd < 0) { |
| 203 DLOG(ERROR) << "Invalid file descriptor!"; | 198 DLOG(ERROR) << "Invalid file descriptor!"; |
| 204 return false; | 199 return false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 SkAutoDataUnref data(pdf_stream.copyToData()); | 236 SkAutoDataUnref data(pdf_stream.copyToData()); |
| 242 if (data.size() == 0) | 237 if (data.size() == 0) |
| 243 return NULL; | 238 return NULL; |
| 244 | 239 |
| 245 PdfMetafileSkia* metafile = new PdfMetafileSkia; | 240 PdfMetafileSkia* metafile = new PdfMetafileSkia; |
| 246 metafile->InitFromData(data.bytes(), data.size()); | 241 metafile->InitFromData(data.bytes(), data.size()); |
| 247 return metafile; | 242 return metafile; |
| 248 } | 243 } |
| 249 | 244 |
| 250 } // namespace printing | 245 } // namespace printing |
| OLD | NEW |