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/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 const MacRenderPageParams& params) const { | 185 const MacRenderPageParams& params) const { |
186 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); | 186 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); |
187 if (data_->pdf_cg_.GetDataSize() == 0) { | 187 if (data_->pdf_cg_.GetDataSize() == 0) { |
188 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); | 188 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); |
189 data_->pdf_cg_.InitFromData(data->bytes(), data->size()); | 189 data_->pdf_cg_.InitFromData(data->bytes(), data->size()); |
190 } | 190 } |
191 return data_->pdf_cg_.RenderPage(page_number, context, rect, params); | 191 return data_->pdf_cg_.RenderPage(page_number, context, rect, params); |
192 } | 192 } |
193 #endif | 193 #endif |
194 | 194 |
195 #if defined(OS_CHROMEOS) | 195 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
196 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { | 196 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { |
197 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); | 197 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); |
198 | 198 |
199 if (fd.fd < 0) { | 199 if (fd.fd < 0) { |
200 DLOG(ERROR) << "Invalid file descriptor!"; | 200 DLOG(ERROR) << "Invalid file descriptor!"; |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 bool result = true; | 204 bool result = true; |
205 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); | 205 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (data->size() == 0) | 239 if (data->size() == 0) |
240 return NULL; | 240 return NULL; |
241 | 241 |
242 PdfMetafileSkia* metafile = new PdfMetafileSkia; | 242 PdfMetafileSkia* metafile = new PdfMetafileSkia; |
243 metafile->InitFromData(data->bytes(), | 243 metafile->InitFromData(data->bytes(), |
244 base::checked_numeric_cast<uint32>(data->size())); | 244 base::checked_numeric_cast<uint32>(data->size())); |
245 return metafile; | 245 return metafile; |
246 } | 246 } |
247 | 247 |
248 } // namespace printing | 248 } // namespace printing |
OLD | NEW |