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
This commit is contained in:
robertphillips 2015-07-07 10:28:43 -07:00 committed by Commit bot
parent a8db72864a
commit 8e0c1500a7
6 changed files with 18 additions and 21 deletions

View File

@ -1694,7 +1694,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
paint.setPathEffect(NULL);
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
SkAutoGlyphCache autoCache(paint, NULL, NULL);
SkAutoGlyphCache autoCache(paint, &fDevice->surfaceProps(), NULL);
SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;

View File

@ -1949,7 +1949,7 @@ HRESULT SkXPSDevice::CreateTypefaceUse(const SkPaint& paint,
newTypefaceUse.fontData = fontData;
newTypefaceUse.xpsFont = xpsFontResource.release();
SkAutoGlyphCache agc(paint, NULL, &SkMatrix::I());
SkAutoGlyphCache agc(paint, &this->surfaceProps(), &SkMatrix::I());
SkGlyphCache* glyphCache = agc.getCache();
unsigned int glyphCount = glyphCache->getGlyphCount();
newTypefaceUse.glyphsUsed = new SkBitSet(glyphCount);

View File

@ -218,7 +218,7 @@ void GrTextContext::drawPosTextAsPath(GrRenderTarget* rt,
paint.setPathEffect(NULL);
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
SkAutoGlyphCache autoCache(paint, NULL, NULL);
SkAutoGlyphCache autoCache(paint, &fSurfaceProps, NULL);
SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;

View File

@ -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.");

View File

@ -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);

View File

@ -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;
}