Bug 1353000 - Respect the round-to-pixels flags when caching shaped-word data. r=jrmuizel

This commit is contained in:
Jonathan Kew 2017-04-12 14:55:13 +01:00
Родитель 626370224b
Коммит 25183dff43
2 изменённых файлов: 42 добавлений и 17 удалений

Просмотреть файл

@ -2587,7 +2587,7 @@ gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
CacheHashKey key(aText, aLength, aHash,
aRunScript,
aAppUnitsPerDevUnit,
aFlags);
aFlags, aRounding);
CacheHashEntry *entry = mWordCache->PutEntry(key);
if (!entry) {
@ -2621,7 +2621,7 @@ gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
#endif
sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
aFlags);
aFlags, aRounding);
entry->mShapedWord.reset(sw);
if (!sw) {
NS_WARNING("failed to create gfxShapedWord - expect missing text");
@ -2646,6 +2646,7 @@ gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
}
if (sw->GetLength() != aKey->mLength ||
sw->GetFlags() != aKey->mFlags ||
sw->GetRounding() != aKey->mRounding ||
sw->GetAppUnitsPerDevUnit() != aKey->mAppUnitsPerDevUnit ||
sw->GetScript() != aKey->mScript) {
return false;

Просмотреть файл

@ -1190,7 +1190,8 @@ public:
static gfxShapedWord* Create(const uint8_t *aText, uint32_t aLength,
Script aRunScript,
int32_t aAppUnitsPerDevUnit,
uint32_t aFlags) {
uint32_t aFlags,
gfxFontShaper::RoundingFlags aRounding) {
NS_ASSERTION(aLength <= gfxPlatform::GetPlatform()->WordCacheCharLimit(),
"excessive length for gfxShapedWord!");
@ -1206,13 +1207,15 @@ public:
// Construct in the pre-allocated storage, using placement new
return new (storage) gfxShapedWord(aText, aLength, aRunScript,
aAppUnitsPerDevUnit, aFlags);
aAppUnitsPerDevUnit, aFlags,
aRounding);
}
static gfxShapedWord* Create(const char16_t *aText, uint32_t aLength,
Script aRunScript,
int32_t aAppUnitsPerDevUnit,
uint32_t aFlags) {
uint32_t aFlags,
gfxFontShaper::RoundingFlags aRounding) {
NS_ASSERTION(aLength <= gfxPlatform::GetPlatform()->WordCacheCharLimit(),
"excessive length for gfxShapedWord!");
@ -1224,7 +1227,8 @@ public:
LossyAppendUTF16toASCII(nsDependentSubstring(aText, aLength),
narrowText);
return Create((const uint8_t*)(narrowText.BeginReading()),
aLength, aRunScript, aAppUnitsPerDevUnit, aFlags);
aLength, aRunScript, aAppUnitsPerDevUnit, aFlags,
aRounding);
}
uint32_t size =
@ -1236,7 +1240,8 @@ public:
}
return new (storage) gfxShapedWord(aText, aLength, aRunScript,
aAppUnitsPerDevUnit, aFlags);
aAppUnitsPerDevUnit, aFlags,
aRounding);
}
// Override operator delete to properly free the object that was
@ -1272,6 +1277,10 @@ public:
return mScript;
}
gfxFontShaper::RoundingFlags GetRounding() const {
return mRounding;
}
void ResetAge() {
mAgeCounter = 0;
}
@ -1292,10 +1301,12 @@ private:
// Construct storage for a ShapedWord, ready to receive glyph data
gfxShapedWord(const uint8_t *aText, uint32_t aLength,
Script aRunScript,
int32_t aAppUnitsPerDevUnit, uint32_t aFlags)
int32_t aAppUnitsPerDevUnit, uint32_t aFlags,
gfxFontShaper::RoundingFlags aRounding)
: gfxShapedText(aLength, aFlags | gfxTextRunFactory::TEXT_IS_8BIT,
aAppUnitsPerDevUnit)
, mScript(aRunScript)
, mRounding(aRounding)
, mAgeCounter(0)
{
memset(mCharGlyphsStorage, 0, aLength * sizeof(CompressedGlyph));
@ -1305,9 +1316,11 @@ private:
gfxShapedWord(const char16_t *aText, uint32_t aLength,
Script aRunScript,
int32_t aAppUnitsPerDevUnit, uint32_t aFlags)
int32_t aAppUnitsPerDevUnit, uint32_t aFlags,
gfxFontShaper::RoundingFlags aRounding)
: gfxShapedText(aLength, aFlags, aAppUnitsPerDevUnit)
, mScript(aRunScript)
, mRounding(aRounding)
, mAgeCounter(0)
{
memset(mCharGlyphsStorage, 0, aLength * sizeof(CompressedGlyph));
@ -1318,6 +1331,8 @@ private:
Script mScript;
gfxFontShaper::RoundingFlags mRounding;
uint32_t mAgeCounter;
// The mCharGlyphsStorage array is actually a variable-size member;
@ -2032,18 +2047,23 @@ protected:
int32_t mAppUnitsPerDevUnit;
PLDHashNumber mHashKey;
bool mTextIs8Bit;
RoundingFlags mRounding;
CacheHashKey(const uint8_t *aText, uint32_t aLength,
uint32_t aStringHash,
Script aScriptCode, int32_t aAppUnitsPerDevUnit,
uint32_t aFlags)
uint32_t aFlags, RoundingFlags aRounding)
: mLength(aLength),
mFlags(aFlags),
mScript(aScriptCode),
mAppUnitsPerDevUnit(aAppUnitsPerDevUnit),
mHashKey(aStringHash + static_cast<int32_t>(aScriptCode) +
aAppUnitsPerDevUnit * 0x100 + aFlags * 0x10000),
mTextIs8Bit(true)
mHashKey(aStringHash
+ static_cast<int32_t>(aScriptCode)
+ aAppUnitsPerDevUnit * 0x100
+ aFlags * 0x10000
+ int(aRounding)),
mTextIs8Bit(true),
mRounding(aRounding)
{
NS_ASSERTION(aFlags & gfxTextRunFactory::TEXT_IS_8BIT,
"8-bit flag should have been set");
@ -2053,14 +2073,18 @@ protected:
CacheHashKey(const char16_t *aText, uint32_t aLength,
uint32_t aStringHash,
Script aScriptCode, int32_t aAppUnitsPerDevUnit,
uint32_t aFlags)
uint32_t aFlags, RoundingFlags aRounding)
: mLength(aLength),
mFlags(aFlags),
mScript(aScriptCode),
mAppUnitsPerDevUnit(aAppUnitsPerDevUnit),
mHashKey(aStringHash + static_cast<int32_t>(aScriptCode) +
aAppUnitsPerDevUnit * 0x100 + aFlags * 0x10000),
mTextIs8Bit(false)
mHashKey(aStringHash
+ static_cast<int32_t>(aScriptCode)
+ aAppUnitsPerDevUnit * 0x100
+ aFlags * 0x10000
+ int(aRounding)),
mTextIs8Bit(false),
mRounding(aRounding)
{
// We can NOT assert that TEXT_IS_8BIT is false in aFlags here,
// because this might be an 8bit-only word from a 16-bit textrun,