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 9792001: Roll Skia to 3470, which changes most of the pdf includes to be private. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright Created 8 years, 9 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 | « DEPS ('k') | skia/skia.gyp » ('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) 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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "skia/ext/vector_platform_device_skia.h" 12 #include "skia/ext/vector_platform_device_skia.h"
13 #include "third_party/skia/include/core/SkData.h" 13 #include "third_party/skia/include/core/SkData.h"
14 #include "third_party/skia/include/core/SkRefCnt.h" 14 #include "third_party/skia/include/core/SkRefCnt.h"
15 #include "third_party/skia/include/core/SkScalar.h" 15 #include "third_party/skia/include/core/SkScalar.h"
16 #include "third_party/skia/include/core/SkStream.h" 16 #include "third_party/skia/include/core/SkStream.h"
17 #include "third_party/skia/include/core/SkTypeface.h" 17 #include "third_party/skia/include/core/SkTypeface.h"
18 #include "third_party/skia/include/pdf/SkPDFDevice.h" 18 #include "third_party/skia/include/pdf/SkPDFDevice.h"
19 #include "third_party/skia/include/pdf/SkPDFDocument.h" 19 #include "third_party/skia/include/pdf/SkPDFDocument.h"
20 #include "third_party/skia/include/pdf/SkPDFFont.h"
21 #include "third_party/skia/include/pdf/SkPDFPage.h"
22 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
23 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
24 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
25 23
26 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
27 #include "printing/pdf_metafile_cg_mac.h" 25 #include "printing/pdf_metafile_cg_mac.h"
28 #endif 26 #endif
29 27
30 namespace printing { 28 namespace printing {
31 29
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 86
89 bool PdfMetafileSkia::FinishDocument() { 87 bool PdfMetafileSkia::FinishDocument() {
90 // Don't do anything if we've already set the data in InitFromData. 88 // Don't do anything if we've already set the data in InitFromData.
91 if (data_->pdf_stream_.getOffset()) 89 if (data_->pdf_stream_.getOffset())
92 return true; 90 return true;
93 91
94 if (page_outstanding_) 92 if (page_outstanding_)
95 FinishPage(); 93 FinishPage();
96 94
97 data_->current_page_ = NULL; 95 data_->current_page_ = NULL;
98 base::hash_set<SkFontID> font_set;
99 96
100 const SkTDArray<SkPDFPage*>& pages = data_->pdf_doc_.getPages(); 97 int font_counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1];
101 for (int page_number = 0; page_number < pages.count(); page_number++) { 98 // Work around bug in skia for the moment.
102 const SkTDArray<SkPDFFont*>& font_resources = 99 memset(font_counts, 0, sizeof(font_counts));
103 pages[page_number]->getFontResources(); 100 data_->pdf_doc_.getCountOfFontTypes(font_counts);
104 for (int font = 0; font < font_resources.count(); font++) { 101 for (int type = 0;
105 SkFontID font_id = font_resources[font]->typeface()->uniqueID(); 102 type <= SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
106 if (font_set.find(font_id) == font_set.end()) { 103 type++) {
107 font_set.insert(font_id); 104 for (int count = 0; count < font_counts[type]; count++) {
108 UMA_HISTOGRAM_ENUMERATION( 105 UMA_HISTOGRAM_ENUMERATION(
109 "PrintPreview.FontType", 106 "PrintPreview.FontType", type,
110 font_resources[font]->getType(), 107 SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1);
111 SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1);
112 }
113 } 108 }
114 } 109 }
115 110
116 return data_->pdf_doc_.emitPDF(&data_->pdf_stream_); 111 return data_->pdf_doc_.emitPDF(&data_->pdf_stream_);
117 } 112 }
118 113
119 uint32 PdfMetafileSkia::GetDataSize() const { 114 uint32 PdfMetafileSkia::GetDataSize() const {
120 return data_->pdf_stream_.getOffset(); 115 return data_->pdf_stream_.getOffset();
121 } 116 }
122 117
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 SkAutoDataUnref data(pdf_stream.copyToData()); 243 SkAutoDataUnref data(pdf_stream.copyToData());
249 if (data.size() == 0) 244 if (data.size() == 0)
250 return NULL; 245 return NULL;
251 246
252 PdfMetafileSkia* metafile = new PdfMetafileSkia; 247 PdfMetafileSkia* metafile = new PdfMetafileSkia;
253 metafile->InitFromData(data.bytes(), data.size()); 248 metafile->InitFromData(data.bytes(), data.size());
254 return metafile; 249 return metafile;
255 } 250 }
256 251
257 } // namespace printing 252 } // namespace printing
OLDNEW
« no previous file with comments | « DEPS ('k') | skia/skia.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698