Chromium Code Reviews| Index: printing/pdf_metafile_skia.cc |
| diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc |
| index 2558a8453a95f34229ee906e3bb17470a90b130e..3463b50dfdfc2c7377155c148bf93c9b6e24f266 100644 |
| --- a/printing/pdf_metafile_skia.cc |
| +++ b/printing/pdf_metafile_skia.cc |
| @@ -22,18 +22,12 @@ |
| #include "ui/gfx/rect.h" |
| #include "ui/gfx/size.h" |
| -namespace { |
| - typedef base::hash_map<SkFontID, SkAdvancedTypefaceMetrics::FontType> |
| - FontTypeMap; |
| -}; |
| - |
| namespace printing { |
| struct PdfMetafileSkiaData { |
| SkRefPtr<SkPDFDevice> current_page_; |
| SkPDFDocument pdf_doc_; |
| SkDynamicMemoryWStream pdf_stream_; |
| - FontTypeMap font_type_stats_; |
| }; |
| PdfMetafileSkia::~PdfMetafileSkia() {} |
| @@ -81,13 +75,6 @@ bool PdfMetafileSkia::StartPage(const gfx::Size& page_size, |
| bool PdfMetafileSkia::FinishPage() { |
| DCHECK(data_->current_page_.get()); |
| - const SkTDArray<SkPDFFont*>& font_resources = |
| - data_->current_page_->getFontResources(); |
| - for (int i = 0; i < font_resources.count(); i++) { |
| - SkFontID key = font_resources[i]->typeface()->uniqueID(); |
| - data_->font_type_stats_[key] = font_resources[i]->getType(); |
| - } |
| - |
| data_->pdf_doc_.appendPage(data_->current_page_); |
| data_->current_page_ = NULL; |
| return true; |
| @@ -101,8 +88,22 @@ bool PdfMetafileSkia::FinishDocument() { |
| if (data_->current_page_.get()) |
| FinishPage(); |
| - for (FontTypeMap::const_iterator it = data_->font_type_stats_.begin(); |
| - it != data_->font_type_stats_.end(); |
| + typedef base::hash_map<SkFontID, SkAdvancedTypefaceMetrics::FontType> |
| + FontTypeMap; |
| + FontTypeMap font_type_stats; |
| + |
| + const SkTDArray<SkPDFPage*>& pages = data_->pdf_doc_.getPages(); |
| + for (int page_number = 0; page_number < pages.count(); page_number++) { |
| + const SkTDArray<SkPDFFont*>& font_resources = |
| + pages[page_number]->getFontResources(); |
| + for (int font = 0; font < font_resources.count(); font++) { |
| + SkFontID key = font_resources[font]->typeface()->uniqueID(); |
|
Chris Guillory
2011/05/31 18:15:45
We can call UMA_HISTOGRAM_ENUMERATION here when th
vandebo (ex-Chrome)
2011/05/31 18:55:11
Good point. Done.
|
| + font_type_stats[key] = font_resources[font]->getType(); |
| + } |
| + } |
| + |
| + for (FontTypeMap::const_iterator it = font_type_stats.begin(); |
| + it != font_type_stats.end(); |
| it++) { |
| UMA_HISTOGRAM_ENUMERATION( |
| "PrintPreview.FontType", |