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 30 matching lines...) Expand all Loading... |
41 PdfMetafileSkia::~PdfMetafileSkia() {} | 41 PdfMetafileSkia::~PdfMetafileSkia() {} |
42 | 42 |
43 bool PdfMetafileSkia::Init() { | 43 bool PdfMetafileSkia::Init() { |
44 return true; | 44 return true; |
45 } | 45 } |
46 bool PdfMetafileSkia::InitFromData(const void* src_buffer, | 46 bool PdfMetafileSkia::InitFromData(const void* src_buffer, |
47 uint32 src_buffer_size) { | 47 uint32 src_buffer_size) { |
48 return data_->pdf_stream_.write(src_buffer, src_buffer_size); | 48 return data_->pdf_stream_.write(src_buffer, src_buffer_size); |
49 } | 49 } |
50 | 50 |
51 SkDevice* PdfMetafileSkia::StartPageForVectorCanvas( | 51 SkBaseDevice* PdfMetafileSkia::StartPageForVectorCanvas( |
52 const gfx::Size& page_size, const gfx::Rect& content_area, | 52 const gfx::Size& page_size, const gfx::Rect& content_area, |
53 const float& scale_factor) { | 53 const float& scale_factor) { |
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), |
(...skipping 177 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 |