Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: printing/pdf_metafile_skia.cc

Issue 6820038: Push the initial transform down into SkPDFDevice. (Chrome side). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 skia::VectorPlatformDeviceSkia* device = 43 // Flip the origin and adjust for the margins.
44 new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(), 44 SkMatrix transform;
45 SkPDFDevice::kFlip_OriginTransform); 45 transform.setTranslate(content_origin.x(),
46 device->setInitialTransform(content_origin.x(), content_origin.y(), 46 page_size.height() - content_origin.y());
47 scale_factor); 47 transform.preScale(scale_factor, -scale_factor);
48
49 skia::VectorPlatformDeviceSkia* device = new skia::VectorPlatformDeviceSkia(
50 page_size.width(), page_size.height(), &transform);
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
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
OLDNEW
« no previous file with comments | « no previous file | skia/ext/vector_platform_device_skia.h » ('j') | skia/ext/vector_platform_device_skia.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698