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

Side by Side Diff: printing/pdf_metafile_skia.cc

Issue 7754001: Revert 98230 - CL removing inheritance of SkDevice from PlatformDevice. (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.
64 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height()); 65 SkISize pdf_page_size = SkISize::Make(page_size.width(), page_size.height());
65 SkISize pdf_content_size = 66 SkISize pdf_content_size =
66 SkISize::Make(content_area.width(), content_area.height()); 67 SkISize::Make(content_area.width(), content_area.height());
67 SkRefPtr<SkPDFDevice> pdf_device = 68 SkRefPtr<SkPDFDevice> pdf_device =
68 new skia::VectorPlatformDeviceSkia(pdf_page_size, pdf_content_size, 69 new SkPDFDevice(pdf_page_size, pdf_content_size, transform);
69 transform); 70 pdf_device->unref(); // SkRefPtr and new both took a reference.
70 data_->current_page_ = pdf_device; 71 skia::VectorPlatformDeviceSkia* device =
71 return pdf_device.get(); 72 new skia::VectorPlatformDeviceSkia(pdf_device.get());
73 data_->current_page_ = device->PdfDevice();
74 return device;
72 } 75 }
73 76
74 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, 77 bool PdfMetafileSkia::StartPage(const gfx::Size& page_size,
75 const gfx::Rect& content_area, 78 const gfx::Rect& content_area,
76 const float& scale_factor) { 79 const float& scale_factor) {
77 NOTREACHED(); 80 NOTREACHED();
78 return NULL; 81 return NULL;
79 } 82 }
80 83
81 bool PdfMetafileSkia::FinishPage() { 84 bool PdfMetafileSkia::FinishPage() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 SkAutoDataUnref data(pdf_stream.copyToData()); 251 SkAutoDataUnref data(pdf_stream.copyToData());
249 if (data.size() == 0) 252 if (data.size() == 0)
250 return NULL; 253 return NULL;
251 254
252 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia; 255 PdfMetafileSkia* metafile = new printing::PdfMetafileSkia;
253 metafile->InitFromData(data.bytes(), data.size()); 256 metafile->InitFromData(data.bytes(), data.size());
254 return metafile; 257 return metafile;
255 } 258 }
256 259
257 } // namespace printing 260 } // 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