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

Side by Side Diff: printing/pdf_metafile_skia.cc

Issue 10560021: Mac printing: Autorotate printed pages so their orientation is the same as the destination page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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) 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool shrink_to_fit,
184 bool stretch_to_fit, 184 bool stretch_to_fit,
185 bool center_horizontally, 185 bool center_horizontally,
186 bool center_vertically) const { 186 bool center_vertically,
187 bool autorotate) const {
187 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); 188 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U);
188 if (data_->pdf_cg_.GetDataSize() == 0) { 189 if (data_->pdf_cg_.GetDataSize() == 0) {
189 SkAutoDataUnref data(data_->pdf_stream_.copyToData()); 190 SkAutoDataUnref data(data_->pdf_stream_.copyToData());
190 data_->pdf_cg_.InitFromData(data.bytes(), data.size()); 191 data_->pdf_cg_.InitFromData(data.bytes(), data.size());
191 } 192 }
192 return data_->pdf_cg_.RenderPage(page_number, context, rect, shrink_to_fit, 193 return data_->pdf_cg_.RenderPage(page_number, context, rect, shrink_to_fit,
193 stretch_to_fit, center_horizontally, 194 stretch_to_fit, center_horizontally,
194 center_vertically); 195 center_vertically, autorotate);
195 } 196 }
196 #endif 197 #endif
197 198
198 #if defined(OS_CHROMEOS) 199 #if defined(OS_CHROMEOS)
199 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { 200 bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const {
200 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); 201 DCHECK_GT(data_->pdf_stream_.getOffset(), 0U);
201 202
202 if (fd.fd < 0) { 203 if (fd.fd < 0) {
203 DLOG(ERROR) << "Invalid file descriptor!"; 204 DLOG(ERROR) << "Invalid file descriptor!";
204 return false; 205 return false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 SkAutoDataUnref data(pdf_stream.copyToData()); 242 SkAutoDataUnref data(pdf_stream.copyToData());
242 if (data.size() == 0) 243 if (data.size() == 0)
243 return NULL; 244 return NULL;
244 245
245 PdfMetafileSkia* metafile = new PdfMetafileSkia; 246 PdfMetafileSkia* metafile = new PdfMetafileSkia;
246 metafile->InitFromData(data.bytes(), data.size()); 247 metafile->InitFromData(data.bytes(), data.size());
247 return metafile; 248 return metafile;
248 } 249 }
249 250
250 } // namespace printing 251 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698