From 7a4d6a99e99d8be9763fe9f00dca80a67f4ebcef Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Mon, 14 Oct 2013 08:29:43 -0400 Subject: Merge skia changes from the skia chrome/m30_1599 branch. This captures revisions r11503 to r11657 (inclusive). This range appears large, but covers a span of just 3 commits one of which has already been cherry-picked into this repository. bug: 10285384 Change-Id: I614888fe1b65f31a713a689ccb3a9db6265b60e8 --- src/gpu/GrTextContext.cpp | 4 ++-- src/ports/SkFontHost_fontconfig.cpp | 9 +++++++++ tests/FontMgrTest.cpp | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index 8f0f1cfde6..5a2c315baf 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -152,13 +152,13 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, if (fStrike->getGlyphAtlas(glyph, scaler)) { goto HAS_ATLAS; } - +#if 0 // M30 specific revert of font cache improvement to fix https://code.google.com/p/chromium/issues/detail?id=303803 // try to clear out an unused atlas before we flush fContext->getFontCache()->freeAtlasExceptFor(fStrike); if (fStrike->getGlyphAtlas(glyph, scaler)) { goto HAS_ATLAS; } - +#endif // before we purge the cache, we must flush any accumulated draws this->flushGlyphs(); fContext->flush(); diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp index 012ce90c8c..0db44b242f 100644 --- a/src/ports/SkFontHost_fontconfig.cpp +++ b/src/ports/SkFontHost_fontconfig.cpp @@ -109,6 +109,15 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface( return NULL; } + // check if we, in fact, already have this. perhaps fontconfig aliased the + // requested name to some other name we actually have... + rec.fFamilyName = outFamilyName.c_str(); + rec.fStyle = outStyle; + face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec); + if (face) { + return face; + } + face = SkNEW_ARGS(FontConfigTypeface, (outStyle, indentity, outFamilyName)); SkTypefaceCache::Add(face, style); // SkDebugf("add face <%s> <%s> %p [%d]\n", familyName, outFamilyName.c_str(), face, face->getRefCnt()); diff --git a/tests/FontMgrTest.cpp b/tests/FontMgrTest.cpp index 6b6ee9a73f..00ff79b897 100644 --- a/tests/FontMgrTest.cpp +++ b/tests/FontMgrTest.cpp @@ -11,6 +11,27 @@ #include "SkFontMgr.h" #include "SkTypeface.h" +/* + * If the font backend is going to "alias" some font names to other fonts + * (e.g. sans -> Arial) then we want to at least get the same typeface back + * if we request the alias name multiple times. + */ +static void test_badnames(skiatest::Reporter* reporter) { + const char* inName = "sans"; + SkAutoTUnref first(SkTypeface::CreateFromName(inName, SkTypeface::kNormal)); + + SkString name; + for (int i = 0; i < 10; ++i) { + SkAutoTUnref face(SkTypeface::CreateFromName(inName, SkTypeface::kNormal)); +#if 0 + face->getFamilyName(&name); + printf("request %s, received %s, first id %x received %x\n", + inName, name.c_str(), first->uniqueID(), face->uniqueID()); +#endif + REPORTER_ASSERT(reporter, first->uniqueID() == face->uniqueID()); + } +} + static void test_fontiter(skiatest::Reporter* reporter, bool verbose) { SkAutoTUnref fm(SkFontMgr::RefDefault()); int count = fm->countFamilies(); @@ -49,6 +70,7 @@ DEFINE_bool(verboseFontMgr, false, "run verbose fontmgr tests."); static void TestFontMgr(skiatest::Reporter* reporter) { test_fontiter(reporter, FLAGS_verboseFontMgr); + test_badnames(reporter); } #include "TestClassDef.h" -- cgit v1.2.3