From 3f846ae913f0e01eedf889fff062e9a1dc9f4f8b Mon Sep 17 00:00:00 2001 From: bungeman Date: Tue, 3 Nov 2015 11:07:20 -0800 Subject: [PATCH] Take mutex when calling into FreeType. SkScalerContext_FreeType::generateCharToGlyph and generateGlyphToChar do not take a mutex when calling into FreeType, but they need to. The setupSize method also requires the mutex to be locked, which is not a problem since it currently always is, but add a debug assert to ensure that it continues to be. BUG=chromium:542640 Review URL: https://codereview.chromium.org/1431683006 --- src/ports/SkFontHost_FreeType.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 32eafad87c..e8b72b5e09 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -949,6 +949,7 @@ SkScalerContext_FreeType::~SkScalerContext_FreeType() { this face with other context (at different sizes). */ FT_Error SkScalerContext_FreeType::setupSize() { + gFTMutex.assertHeld(); FT_Error err = FT_Activate_Size(fFTSize); if (err != 0) { SkDEBUGF(("SkScalerContext_FreeType::FT_Activate_Size(%s %s, 0x%x, 0x%x) returned 0x%x\n", @@ -968,10 +969,12 @@ unsigned SkScalerContext_FreeType::generateGlyphCount() { } uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni) { + SkAutoMutexAcquire ac(gFTMutex); return SkToU16(FT_Get_Char_Index( fFace, uni )); } SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) { + SkAutoMutexAcquire ac(gFTMutex); // iterate through each cmap entry, looking for matching glyph indices FT_UInt glyphIndex; SkUnichar charCode = FT_Get_First_Char( fFace, &glyphIndex );