SkPDF: Glyph Useage Map improvements
Instead of having a fFontGlyphUsage on each device and one on each
document, just have the one on the document, and never merge.
Make fGlyphUsage accesible on SkPDFDocument.
Remove SkPDFGlyphSetMap::merge, ::reset, and SkPDFGlyphSet::merge.
SkPDFGlyphSetMap has an TArray of SkPDFGlyphSet, not TDArray of
SkPDFGlyphSet pointers. SkPDFGlyphSet and SkPDFBitset get move
constructors.
All tests produce exactly identical output PDFs.
BUG=skia:5434
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2112943002
Review-Url: https://codereview.chromium.org/2112943002
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index c56d1ca..221f240 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -270,7 +270,6 @@
fCanvas->flush();
fCanvas.reset(nullptr);
SkASSERT(fPageDevice);
- fGlyphUsage.merge(fPageDevice->getFontGlyphUsage());
auto page = sk_make_sp<SkPDFDict>("Page");
page->insertObject("Resources", fPageDevice->makeResourceDict());
page->insertObject("MediaBox", fPageDevice->copyMediaBox());
@@ -293,6 +292,7 @@
fPages.reset();
fCanon.reset();
renew(&fObjectSerializer);
+ renew(&fGlyphUsage);
}
#ifdef SK_SUPPORT_LEGACY_DOCUMENT_API
@@ -356,6 +356,7 @@
fPages.reset();
fCanon.reset();
renew(&fObjectSerializer);
+ renew(&fGlyphUsage);
return false;
}
auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
@@ -377,7 +378,7 @@
// Build font subsetting info before calling addObjectRecursively().
for (const auto& entry : fGlyphUsage) {
sk_sp<SkPDFFont> subsetFont(
- entry.fFont->getFontSubset(entry.fGlyphSet));
+ entry.fFont->getFontSubset(&entry.fGlyphSet));
if (subsetFont) {
fObjectSerializer.fSubstituteMap.setSubstitute(
entry.fFont, subsetFont.get());
@@ -389,6 +390,7 @@
fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
fCanon.reset();
renew(&fObjectSerializer);
+ renew(&fGlyphUsage);
return true;
}