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

Side by Side Diff: printing/pdf_metafile_skia.cc

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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),
62 SkFloatToScalar(scale_factor)); 62 SkFloatToScalar(scale_factor));
63 63
64 // TODO(ctguil): Refactor: don't create the PDF device explicitly here.
65 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); 64 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height());
66 SkISize pdf_content_size = 65 SkISize pdf_content_size =
67 SkISize::Make(content_area.width(), content_area.height()); 66 SkISize::Make(content_area.width(), content_area.height());
68 SkRefPtr<SkPDFDevice> pdf_device = 67 SkRefPtr<SkPDFDevice> pdf_device =
69 new SkPDFDevice(pdf_page_size, pdf_content_size, transform); 68 new skia::VectorPlatformDeviceSkia(pdf_page_size, pdf_content_size,
70 pdf_device->unref(); // SkRefPtr and new both took a reference. 69 transform);
71 skia::VectorPlatformDeviceSkia* device = 70 data_->current_page_ = pdf_device;
72 new skia::VectorPlatformDeviceSkia(pdf_device.get()); 71 return pdf_device.get();
73 data_->current_page_ = device->PdfDevice();
74 return device;
75 } 72 }
76 73
77 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, 74 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size,
78 const gfx::Rect& content_area, 75 const gfx::Rect& content_area,
79 const float& scale_factor) { 76 const float& scale_factor) {
80 NOTREACHED(); 77 NOTREACHED();
81 return NULL; 78 return NULL;
82 } 79 }
83 80
84 bool PdfMetafileSkia::FinishPage() { 81 bool PdfMetafileSkia::FinishPage() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 SkAutoDataUnref data(pdf_stream.copyToData()); 248 SkAutoDataUnref data(pdf_stream.copyToData());
252 if (data.size() == 0) 249 if (data.size() == 0)
253 return NULL; 250 return NULL;
254 251
255 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia; 252 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia;
256 metafile->InitFromData(data.bytes(), data.size()); 253 metafile->InitFromData(data.bytes(), data.size());
257 return metafile; 254 return metafile;
258 } 255 }
259 256
260 } // namespace printing 257 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698