diff options
author | robertphillips <robertphillips@google.com> | 2015-07-07 10:28:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-07 10:28:43 -0700 |
commit | 8e0c1500a78f450115ce1a8de438d66e2e892cdc (patch) | |
tree | 6f16385ef3eb1f6ab954bcb1aa6cc10cb642b5e5 /src/pdf | |
parent | a8db72864a43ad1fbba3c2892cf5cd88060a43ef (diff) |
Propagate SkSurfaceProps when known
This CL just closes the loop on some low hanging fruit w.r.t. propagating surface properties.
Review URL: https://codereview.chromium.org/1214853025
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.h | 3 | ||||
-rw-r--r-- | src/pdf/SkPDFFont.cpp | 24 |
3 files changed, 15 insertions, 18 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index d044900ae3..422a895419 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1161,7 +1161,7 @@ void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len, SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); while (numGlyphs > consumedGlyphCount) { - updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); + this->updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); SkPDFFont* font = content.entry()->fState.fFont; int availableGlyphs = font->glyphsToPDFFontEncoding( @@ -1206,14 +1206,14 @@ void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len, SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); content.entry()->fContent.writeText("BT\n"); - updateFont(textPaint, glyphIDs[0], content.entry()); + this->updateFont(textPaint, glyphIDs[0], content.entry()); for (size_t i = 0; i < numGlyphs; i++) { SkPDFFont* font = content.entry()->fState.fFont; uint16_t encodedValue = glyphIDs[i]; if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { // The current pdf font cannot encode the current glyph. // Try to get a pdf font which can encode the current glyph. - updateFont(textPaint, glyphIDs[i], content.entry()); + this->updateFont(textPaint, glyphIDs[i], content.entry()); font = content.entry()->fState.fFont; if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { SkDEBUGFAIL("PDF could not encode glyph."); diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 18be58de43..f58e74cc88 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -273,8 +273,7 @@ private: int addGraphicStateResource(SkPDFObject* gs); int addXObjectResource(SkPDFObject* xObject); - void updateFont(const SkPaint& paint, uint16_t glyphID, - ContentEntry* contentEntry); + void updateFont(const SkPaint& paint, uint16_t glyphID, ContentEntry* contentEntry); int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID); void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry); diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index dd01458981..d8755ae9a3 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -894,8 +894,7 @@ SkPDFFont* SkPDFFont::Create(SkPDFCanon* canon, return new SkPDFType0Font(info, typeface); } if (type == SkAdvancedTypefaceMetrics::kType1_Font) { - return new SkPDFType1Font(info, typeface, glyphID, - relatedFontDescriptor); + return new SkPDFType1Font(info, typeface, glyphID, relatedFontDescriptor); } SkASSERT(type == SkAdvancedTypefaceMetrics::kCFF_Font || @@ -990,12 +989,11 @@ void SkPDFFont::populateToUnicodeTable(const SkPDFGlyphSet* subset) { // class SkPDFType0Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType0Font::SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, - SkTypeface* typeface) +SkPDFType0Font::SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface) : SkPDFFont(info, typeface, NULL) { SkDEBUGCODE(fPopulated = false); if (!canSubset()) { - populate(NULL); + this->populate(NULL); } } @@ -1005,8 +1003,7 @@ SkPDFFont* SkPDFType0Font::getFontSubset(const SkPDFGlyphSet* subset) { if (!canSubset()) { return NULL; } - SkPDFType0Font* newSubset = - new SkPDFType0Font(fontInfo(), typeface()); + SkPDFType0Font* newSubset = new SkPDFType0Font(fontInfo(), typeface()); newSubset->populate(subset); return newSubset; } @@ -1031,7 +1028,7 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { descendantFonts->appendObjRef(newCIDFont.detach()); this->insertObject("DescendantFonts", descendantFonts.detach()); - populateToUnicodeTable(subset); + this->populateToUnicodeTable(subset); SkDEBUGCODE(fPopulated = true); return true; @@ -1045,7 +1042,7 @@ SkPDFCIDFont::SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, const SkPDFGlyphSet* subset) : SkPDFFont(info, typeface, NULL) { - populate(subset); + this->populate(subset); } SkPDFCIDFont::~SkPDFCIDFont() {} @@ -1202,7 +1199,7 @@ SkPDFType1Font::SkPDFType1Font(const SkAdvancedTypefaceMetrics* info, uint16_t glyphID, SkPDFDict* relatedFontDescriptor) : SkPDFFont(info, typeface, relatedFontDescriptor) { - populate(glyphID); + this->populate(glyphID); } SkPDFType1Font::~SkPDFType1Font() {} @@ -1325,7 +1322,7 @@ SkPDFType3Font::SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID) : SkPDFFont(info, typeface, NULL) { - populate(glyphID); + this->populate(glyphID); } SkPDFType3Font::~SkPDFType3Font() {} @@ -1334,7 +1331,8 @@ bool SkPDFType3Font::populate(uint16_t glyphID) { SkPaint paint; paint.setTypeface(typeface()); paint.setTextSize(1000); - SkAutoGlyphCache autoCache(paint, NULL, NULL); + const SkSurfaceProps props(0, kUnknown_SkPixelGeometry); + SkAutoGlyphCache autoCache(paint, &props, NULL); SkGlyphCache* cache = autoCache.getCache(); // If fLastGlyphID isn't set (because there is not fFontInfo), look it up. if (lastGlyphID() == 0) { @@ -1397,7 +1395,7 @@ bool SkPDFType3Font::populate(uint16_t glyphID) { this->insertObject("Widths", widthArray.detach()); this->insertName("CIDToGIDMap", "Identity"); - populateToUnicodeTable(NULL); + this->populateToUnicodeTable(NULL); return true; } |