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

Unified Diff: src/pdf/SkPDFFont.h

Issue 2253283004: SkPDF: in-place font subsetting (Closed) Base URL: https://skia.googlesource.com/skia.git@SkPdfCacheMetrics
Patch Set: 2016-08-18 (Thursday) 16:02:16 EDT Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFFont.h
diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h
index f2f1df4c244c2102adebfcb20aeccbb90754d888..abf164c0137b503fd09827fecce39eb16cab69f8 100644
--- a/src/pdf/SkPDFFont.h
+++ b/src/pdf/SkPDFFont.h
@@ -18,48 +18,6 @@
class SkPDFCanon;
class SkPDFFont;
-class SkPDFGlyphSet : SkNoncopyable {
-public:
- SkPDFGlyphSet();
- SkPDFGlyphSet(SkPDFGlyphSet&& o) : fBitSet(std::move(o.fBitSet)) {}
-
- void set(const uint16_t* glyphIDs, int numGlyphs);
- bool has(uint16_t glyphID) const;
- void exportTo(SkTDArray<uint32_t>* glyphIDs) const;
- const SkBitSet& bitSet() const { return fBitSet; }
-
-private:
- SkBitSet fBitSet;
-};
-
-class SkPDFGlyphSetMap : SkNoncopyable {
-public:
- struct FontGlyphSetPair : SkNoncopyable {
- FontGlyphSetPair() : fFont(nullptr) {}
- FontGlyphSetPair(FontGlyphSetPair&& o)
- : fFont(o.fFont)
- , fGlyphSet(std::move(o.fGlyphSet)) {
- o.fFont = nullptr;
- }
- SkPDFFont* fFont;
- SkPDFGlyphSet fGlyphSet;
- };
-
- SkPDFGlyphSetMap();
- ~SkPDFGlyphSetMap();
-
- const FontGlyphSetPair* begin() const { return fMap.begin(); }
- const FontGlyphSetPair* end() const { return fMap.end(); }
-
- void noteGlyphUsage(SkPDFFont* font, const uint16_t* glyphIDs,
- int numGlyphs);
-
-private:
- SkPDFGlyphSet* getGlyphSetForFont(SkPDFFont* font);
-
- SkTArray<FontGlyphSetPair> fMap;
-};
-
/** \class SkPDFFont
A PDF Object class representing a font. The font may have resources
attached to it in order to embed the font. SkPDFFonts are canonicalized
@@ -112,6 +70,10 @@ public:
int glyphsToPDFFontEncodingCount(const SkGlyphID* glyphIDs,
int numGlyphs) const;
+ void noteGlyphUsage(const SkGlyphID* glyphs, int count) {
+ fGlyphUsage.setAll(glyphs, count);
+ }
+
/** Get the font resource for the passed typeface and glyphID. The
* reference count of the object is incremented and it is the caller's
* responsibility to unreference it when done. This is needed to
@@ -128,14 +90,10 @@ public:
static const SkAdvancedTypefaceMetrics* GetMetrics(SkTypeface* typeface,
SkPDFCanon* canon);
- /** Subset the font based on usage set. Returns a SkPDFFont instance with
- * subset.
- * @param usage Glyph subset requested.
- * @return nullptr if font does not support subsetting, a new instance
- * of SkPDFFont otherwise.
+ /** Subset the font based on current usage.
+ * Must be called before emitObject().
*/
- virtual sk_sp<SkPDFObject> getFontSubset(SkPDFCanon* canon,
- const SkPDFGlyphSet* usage);
+ virtual void getFontSubset(SkPDFCanon*) = 0;
/**
* Return false iff the typeface has its NotEmbeddable flag set.
@@ -145,23 +103,24 @@ public:
protected:
// Common constructor to handle common members.
- SkPDFFont(sk_sp<SkTypeface> typeface,
- SkAdvancedTypefaceMetrics::FontType fontType);
+ struct Info {
+ sk_sp<SkTypeface> fTypeface;
+ SkGlyphID fFirstGlyphID;
+ SkGlyphID fLastGlyphID;
+ SkAdvancedTypefaceMetrics::FontType fFontType;
+ };
+ SkPDFFont(Info);
SkGlyphID firstGlyphID() const { return fFirstGlyphID; }
SkGlyphID lastGlyphID() const { return fLastGlyphID; }
-
+ const SkBitSet& glyphUsage() const { return fGlyphUsage; }
sk_sp<SkTypeface> refTypeface() const { return fTypeface; }
- /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs,
- * including the passed glyphID.
- */
- void adjustGlyphRangeForSingleByteEncoding(SkGlyphID glyphID);
-
void drop() override;
private:
sk_sp<SkTypeface> fTypeface;
+ SkBitSet fGlyphUsage;
// The glyph IDs accessible with this font. For Type1 (non CID) fonts,
// this will be a subset if the font has more than 255 glyphs.
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698