diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 20:58:09 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 20:58:09 +0000 |
commit | 67e16b3941e532e5e20a7c9367c32e845911ce24 (patch) | |
tree | 6f641162d27ad3fd3a5624adf4a21a03b7307139 /printing | |
parent | 62294a083fcafabd5b88417a60555ab298af79e4 (diff) | |
download | chromium_src-67e16b3941e532e5e20a7c9367c32e845911ce24.zip chromium_src-67e16b3941e532e5e20a7c9367c32e845911ce24.tar.gz chromium_src-67e16b3941e532e5e20a7c9367c32e845911ce24.tar.bz2 |
Add metrics to determine what font types are being used with print preview.
This depends on Skia r1444.
BUG=80918
TEST=NONE
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87242
Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=87248
Review URL: http://codereview.chromium.org/7084021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/pdf_metafile_skia.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index f76eb70..2558a84 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -7,23 +7,33 @@ #include "base/eintr_wrapper.h" #include "base/file_descriptor_posix.h" #include "base/file_util.h" +#include "base/hash_tables.h" +#include "base/metrics/histogram.h" #include "skia/ext/vector_platform_device_skia.h" #include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkScalar.h" #include "third_party/skia/include/core/SkStream.h" +#include "third_party/skia/include/core/SkTypeface.h" #include "third_party/skia/include/pdf/SkPDFDevice.h" #include "third_party/skia/include/pdf/SkPDFDocument.h" +#include "third_party/skia/include/pdf/SkPDFFont.h" #include "third_party/skia/include/pdf/SkPDFPage.h" #include "ui/gfx/point.h" #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() {} @@ -71,6 +81,13 @@ 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; @@ -83,6 +100,16 @@ 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(); + it++) { + UMA_HISTOGRAM_ENUMERATION( + "PrintPreview.FontType", + it->second, + SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1); + } + return data_->pdf_doc_.emitPDF(&data_->pdf_stream_); } |