| 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 "skia/ext/vector_platform_device_skia.h" | 10 #include "skia/ext/vector_platform_device_skia.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 bool PdfMetafileSkia::InitFromData(const void* src_buffer, | 33 bool PdfMetafileSkia::InitFromData(const void* src_buffer, |
| 34 uint32 src_buffer_size) { | 34 uint32 src_buffer_size) { |
| 35 return data_->pdf_stream_.write(src_buffer, src_buffer_size); | 35 return data_->pdf_stream_.write(src_buffer, src_buffer_size); |
| 36 } | 36 } |
| 37 | 37 |
| 38 skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas( | 38 skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas( |
| 39 const gfx::Size& page_size, const gfx::Point& content_origin, | 39 const gfx::Size& page_size, const gfx::Point& content_origin, |
| 40 const float& scale_factor) { | 40 const float& scale_factor) { |
| 41 DCHECK(data_->current_page_.get() == NULL); | 41 DCHECK(data_->current_page_.get() == NULL); |
| 42 | 42 |
| 43 // Adjust for the margins and apply the scale factor. |
| 44 SkMatrix transform; |
| 45 transform.setTranslate(content_origin.x(), content_origin.y()); |
| 46 transform.preScale(scale_factor, scale_factor); |
| 47 |
| 43 skia::VectorPlatformDeviceSkia* device = | 48 skia::VectorPlatformDeviceSkia* device = |
| 44 new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(), | 49 new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(), |
| 45 SkPDFDevice::kFlip_OriginTransform); | 50 transform); |
| 46 device->setInitialTransform(content_origin.x(), content_origin.y(), | |
| 47 scale_factor); | |
| 48 data_->current_page_ = device->PdfDevice(); | 51 data_->current_page_ = device->PdfDevice(); |
| 49 return device; | 52 return device; |
| 50 } | 53 } |
| 51 | 54 |
| 52 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, | 55 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, |
| 53 const gfx::Point& content_origin, | 56 const gfx::Point& content_origin, |
| 54 const float& scale_factor) { | 57 const float& scale_factor) { |
| 55 NOTREACHED(); | 58 NOTREACHED(); |
| 56 return NULL; | 59 return NULL; |
| 57 } | 60 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 result = false; | 159 result = false; |
| 157 } | 160 } |
| 158 } | 161 } |
| 159 return result; | 162 return result; |
| 160 } | 163 } |
| 161 #endif | 164 #endif |
| 162 | 165 |
| 163 PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData) {} | 166 PdfMetafileSkia::PdfMetafileSkia() : data_(new PdfMetafileSkiaData) {} |
| 164 | 167 |
| 165 } // namespace printing | 168 } // namespace printing |
| OLD | NEW |