Bug 1626570 - Improve handling of copying arrays in gfx/thebes. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D72345
This commit is contained in:
Simon Giesecke 2020-05-05 10:56:14 +00:00
parent ae6bdc7e8b
commit ea61234b3c
16 changed files with 37 additions and 38 deletions

View File

@ -41,7 +41,7 @@ UserDataKey gfxContext::sDontUseAsSourceKey;
# define CURRENTSTATE_CHANGED()
#endif
PatternFromState::operator mozilla::gfx::Pattern &() {
PatternFromState::operator mozilla::gfx::Pattern&() {
gfxContext::AzureState& state = mContext->CurrentState();
if (state.pattern) {

View File

@ -503,8 +503,8 @@ class gfxContext final {
Rect rect;
Matrix transform;
};
nsTArray<PushedClip> pushedClips;
nsTArray<Float> dashPattern;
CopyableTArray<PushedClip> pushedClips;
CopyableTArray<Float> dashPattern;
StrokeOptions strokeOptions;
RefPtr<DrawTarget> drawTarget;
mozilla::gfx::AntialiasMode aaMode;

View File

@ -1951,12 +1951,11 @@ bool gfxFcPlatformFontList::FindAndAddFamilies(
// Because the FcConfigSubstitute call is quite expensive, we cache the
// actual font families found via this process. So check the cache first:
AutoTArray<FamilyAndGeneric, 10> cachedFamilies;
if (mFcSubstituteCache.Get(familyName, &cachedFamilies)) {
if (cachedFamilies.IsEmpty()) {
if (auto* cachedFamilies = mFcSubstituteCache.GetValue(familyName)) {
if (cachedFamilies->IsEmpty()) {
return false;
}
aOutput->AppendElements(cachedFamilies);
aOutput->AppendElements(*cachedFamilies);
return true;
}
@ -1976,6 +1975,7 @@ bool gfxFcPlatformFontList::FindAndAddFamilies(
FcConfigSubstitute(nullptr, fontWithSentinel, FcMatchPattern);
// Add all font family matches until reaching the sentinel.
AutoTArray<FamilyAndGeneric, 10> cachedFamilies;
FcChar8* substName = nullptr;
for (int i = 0; FcPatternGetString(fontWithSentinel, FC_FAMILY, i,
&substName) == FcResultMatch;

View File

@ -346,7 +346,7 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
// font list is rebuilt (e.g. due to a fontconfig configuration change),
// these pointers will be invalidated. InitFontList() flushes the cache
// in this case.
nsDataHashtable<nsCStringHashKey, nsTArray<FamilyAndGeneric>>
nsDataHashtable<nsCStringHashKey, CopyableTArray<FamilyAndGeneric>>
mFcSubstituteCache;
nsCOMPtr<nsITimer> mCheckFontUpdatesTimer;

View File

@ -97,7 +97,7 @@ struct gfxFontStyle {
// (3) are guaranteed to be mutually exclusive
// custom opentype feature settings
nsTArray<gfxFontFeature> featureSettings;
CopyableTArray<gfxFontFeature> featureSettings;
// Some font-variant property values require font-specific settings
// defined via @font-feature-values rules. These are resolved after
@ -110,7 +110,7 @@ struct gfxFontStyle {
RefPtr<gfxFontFeatureValueSet> featureValueLookup;
// opentype variation settings
nsTArray<gfxFontVariation> variationSettings;
CopyableTArray<gfxFontVariation> variationSettings;
// The logical size of the font, in pixels
gfxFloat size;

View File

@ -1948,8 +1948,8 @@ bool gfxFontFamily::CheckForLegacyFamilyNames(gfxPlatformFontList* aFontList) {
const uint32_t kNAME = TRUETYPE_TAG('n', 'a', 'm', 'e');
// Make a local copy of the array of font faces, in case of changes
// during the iteration.
AutoTArray<RefPtr<gfxFontEntry>, 8> faces(mAvailableFonts);
for (auto& fe : faces) {
for (auto& fe :
CopyableAutoTArray<RefPtr<gfxFontEntry>, 8>(mAvailableFonts)) {
if (!fe) {
continue;
}
@ -1982,13 +1982,11 @@ void gfxFontFamily::ReadFaceNames(gfxPlatformFontList* aPlatformFontList,
if (!mOtherFamilyNamesInitialized && aFontInfoData &&
aFontInfoData->mLoadOtherNames && !asyncFontLoaderDisabled) {
AutoTArray<nsCString, 4> otherFamilyNames;
bool foundOtherNames =
aFontInfoData->GetOtherFamilyNames(mName, otherFamilyNames);
if (foundOtherNames) {
uint32_t i, n = otherFamilyNames.Length();
const auto* otherFamilyNames = aFontInfoData->GetOtherFamilyNames(mName);
if (otherFamilyNames) {
uint32_t i, n = otherFamilyNames->Length();
for (i = 0; i < n; i++) {
aPlatformFontList->AddOtherFamilyName(this, otherFamilyNames[i]);
aPlatformFontList->AddOtherFamilyName(this, (*otherFamilyNames)[i]);
}
}
mOtherFamilyNamesInitialized = true;

View File

@ -37,7 +37,7 @@ class gfxFontFeatureValueSet final {
struct ValueList {
ValueList(const nsAString& aName, const nsTArray<uint32_t>& aSelectors)
: name(aName), featureSelectors(aSelectors) {}
: name(aName), featureSelectors(aSelectors.Clone()) {}
nsString name;
nsTArray<uint32_t> featureSelectors;
};

View File

@ -84,9 +84,9 @@ class FontInfoData {
}
// fetches localized family name data from cached font data
virtual bool GetOtherFamilyNames(const nsACString& aFamilyName,
nsTArray<nsCString>& aOtherFamilyNames) {
return mOtherFamilyNames.Get(aFamilyName, &aOtherFamilyNames);
const nsTArray<nsCString>* GetOtherFamilyNames(
const nsACString& aFamilyName) {
return mOtherFamilyNames.GetValue(aFamilyName);
}
nsTArray<nsCString> mFontFamiliesToLoad;
@ -116,7 +116,8 @@ class FontInfoData {
nsDataHashtable<nsCStringHashKey, FontFaceData> mFontFaceData;
// canonical family name ==> array of localized family names
nsDataHashtable<nsCStringHashKey, nsTArray<nsCString> > mOtherFamilyNames;
nsDataHashtable<nsCStringHashKey, CopyableTArray<nsCString> >
mOtherFamilyNames;
};
// gfxFontInfoLoader - helper class for loading font info on async thread

View File

@ -1853,7 +1853,7 @@ void gfxFontUtils::GetVariationData(
int32_t(coords[j]) / 65536.0f};
instance.mValues.AppendElement(value);
}
aInstances->AppendElement(instance);
aInstances->AppendElement(std::move(instance));
}
}
if (aAxes) {

View File

@ -317,8 +317,8 @@ class gfxSparseBitSet {
private:
friend struct IPC::ParamTraits<gfxSparseBitSet>;
friend struct IPC::ParamTraits<gfxSparseBitSet::Block>;
nsTArray<uint16_t> mBlockIndex;
nsTArray<Block> mBlocks;
CopyableTArray<uint16_t> mBlockIndex;
CopyableTArray<Block> mBlocks;
};
namespace IPC {

View File

@ -35,7 +35,7 @@ struct gfxFontVariationValue {
// to be used.
struct gfxFontVariationInstance {
nsCString mName;
nsTArray<gfxFontVariationValue> mValues;
CopyableTArray<gfxFontVariationValue> mValues;
};
#endif

View File

@ -20,7 +20,7 @@ struct GradientCacheKey : public PLDHashEntryHdr {
typedef const GradientCacheKey& KeyType;
typedef const GradientCacheKey* KeyTypePointer;
enum { ALLOW_MEMMOVE = true };
const nsTArray<GradientStop> mStops;
const CopyableTArray<GradientStop> mStops;
ExtendMode mExtend;
BackendType mBackendType;

View File

@ -376,7 +376,7 @@ void gfxPlatformFontList::ApplyWhitelist(
// and just leave the fontlist unchanged.
return;
}
aFamilies = accepted;
aFamilies = std::move(accepted);
}
bool gfxPlatformFontList::FamilyInList(const nsACString& aName,
@ -1242,8 +1242,8 @@ gfxFontEntry* gfxPlatformFontList::GetOrCreateFontEntry(
return fe;
}
void gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily* aFamilyEntry,
nsCString& aOtherFamilyName) {
void gfxPlatformFontList::AddOtherFamilyName(
gfxFontFamily* aFamilyEntry, const nsCString& aOtherFamilyName) {
nsAutoCString key;
GenerateFontListKey(aOtherFamilyName, key);

View File

@ -280,7 +280,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
// name lookup table methods
void AddOtherFamilyName(gfxFontFamily* aFamilyEntry,
nsCString& aOtherFamilyName);
const nsCString& aOtherFamilyName);
void AddFullname(gfxFontEntry* aFontEntry, const nsCString& aFullname);

View File

@ -113,7 +113,7 @@ gfxUserFontEntry::gfxUserFontEntry(
mLoader(nullptr),
mFontSet(aFontSet) {
mIsUserFontContainer = true;
mSrcList = aFontFaceSrcList;
mSrcList = aFontFaceSrcList.Clone();
mSrcIndex = 0;
mWeightRange = aWeight;
mStretchRange = aStretch;
@ -139,8 +139,8 @@ void gfxUserFontEntry::UpdateAttributes(
mWeightRange = aWeight;
mStretchRange = aStretch;
mStyleRange = aStyle;
mFeatureSettings = aFeatureSettings;
mVariationSettings = aVariationSettings;
mFeatureSettings = aFeatureSettings.Clone();
mVariationSettings = aVariationSettings.Clone();
mLanguageOverride = aLanguageOverride;
mCharacterMap = aUnicodeRanges;
mRangeFlags = aRangeFlags;

View File

@ -907,7 +907,7 @@ nsTArray<uint8_t> gfxWindowsPlatform::GetPlatformCMSOutputProfileData() {
GetInitContentDeviceData();
if (contentDeviceData) {
MOZ_ASSERT(!contentDeviceData->cmsOutputProfileData().IsEmpty());
return contentDeviceData->cmsOutputProfileData();
return contentDeviceData->cmsOutputProfileData().Clone();
}
// Otherwise we need to ask the parent for the updated color profile
@ -918,7 +918,7 @@ nsTArray<uint8_t> gfxWindowsPlatform::GetPlatformCMSOutputProfileData() {
}
if (!mCachedOutputColorProfile.IsEmpty()) {
return nsTArray<uint8_t>(mCachedOutputColorProfile);
return mCachedOutputColorProfile.Clone();
}
mCachedOutputColorProfile = [&] {
@ -959,7 +959,7 @@ nsTArray<uint8_t> gfxWindowsPlatform::GetPlatformCMSOutputProfileData() {
return result;
}();
return nsTArray<uint8_t>(mCachedOutputColorProfile);
return mCachedOutputColorProfile.Clone();
}
void gfxWindowsPlatform::GetDLLVersion(char16ptr_t aDLLPath,