Bug 1203809 - pass textperf obj into gfxFontGroup constructor. r=m_kato

This commit is contained in:
John Daggett 2015-09-11 13:24:33 +09:00
parent 0caae9da18
commit 978a916be5
19 changed files with 54 additions and 40 deletions

View File

@ -3951,16 +3951,16 @@ gfxFontGroup *CanvasRenderingContext2D::GetCurrentFontStyle()
if (err.Failed() || !fontUpdated) {
gfxFontStyle style;
style.size = kDefaultFontSize;
gfxTextPerfMetrics* tp = nullptr;
if (presShell && !presShell->IsDestroying()) {
tp = presShell->GetPresContext()->GetTextPerfMetrics();
}
CurrentState().fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(FontFamilyList(eFamily_sans_serif),
&style,
&style, tp,
nullptr);
if (CurrentState().fontGroup) {
CurrentState().font = kDefaultFontStyle;
if (presShell && !presShell->IsDestroying()) {
CurrentState().fontGroup->SetTextPerfMetrics(
presShell->GetPresContext()->GetTextPerfMetrics());
}
} else {
NS_ERROR("Default canvas font is invalid");
}

View File

@ -151,8 +151,7 @@ nsFontMetrics::Init(const nsFont& aFont,
aFont.AddFontFeaturesToStyle(&style);
mFontGroup = gfxPlatform::GetPlatform()->
CreateFontGroup(aFont.fontlist, &style, aUserFontSet);
mFontGroup->SetTextPerfMetrics(aTextPerf);
CreateFontGroup(aFont.fontlist, &style, aTextPerf, aUserFontSet);
return NS_OK;
}

View File

@ -249,7 +249,7 @@ static bool
RunTest (TestEntry *test, gfxContext *ctx) {
nsRefPtr<gfxFontGroup> fontGroup;
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle, nullptr);
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle, nullptr, nullptr);
nsAutoPtr<gfxTextRun> textRun;
gfxTextRunFactory::Parameters params = {

View File

@ -63,7 +63,7 @@ RunTest (TestEntry *test, gfxContext *ctx) {
false, false,
NS_LITERAL_STRING(""));
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16, nullptr);
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16, nullptr, nullptr);
}
nsAutoPtr<gfxTextRun> textRun;

View File

@ -109,7 +109,7 @@ TEST(Gfx, WordCache) {
nsRefPtr<gfxFontGroup> fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(
NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style,
nullptr);
nullptr, nullptr);
gfxTextRunFactory::Parameters params = {
ctx, nullptr, nullptr, nullptr, 0, 60

View File

@ -317,10 +317,11 @@ gfxAndroidPlatform::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlag
gfxFontGroup *
gfxAndroidPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
FT_Library

View File

@ -69,10 +69,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
nsAString& aFamilyName);
virtual gfxFontGroup*
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet);
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
virtual bool FontHintingEnabled() override;
virtual bool RequiresLinearZoom() override;

View File

@ -1256,7 +1256,7 @@ PrepareSortPattern(FcPattern *aPattern, double aFallbackSize,
gfxPangoFontGroup::gfxPangoFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet)
: gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet),
: gfxFontGroup(aFontFamilyList, aStyle, nullptr, aUserFontSet),
mPangoLanguage(GuessPangoLanguage(aStyle->language))
{
// This language is passed to the font for shaping.

View File

@ -37,6 +37,7 @@ class nsIURI;
class nsIAtom;
class nsIObserver;
class SRGBOverrideObserver;
class gfxTextPerfMetrics;
namespace mozilla {
namespace gl {
@ -332,11 +333,11 @@ public:
/**
* Create the appropriate platform font group
*/
virtual gfxFontGroup
*CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet) = 0;
virtual gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) = 0;
/**
* Look up a local platform font using the full font face name.

View File

@ -241,11 +241,12 @@ gfxPlatformGtk::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFa
gfxFontGroup *
gfxPlatformGtk::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet)
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
if (sUseFcFontList) {
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
return new gfxPangoFontGroup(aFontFamilyList, aStyle, aUserFontSet);

View File

@ -50,9 +50,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
nsAString& aFamilyName) override;
virtual gfxFontGroup* CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet) override;
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to

View File

@ -141,9 +141,10 @@ gfxPlatformMac::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFa
gfxFontGroup *
gfxPlatformMac::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
// these will move to gfxPlatform once all platforms support the fontlist

View File

@ -37,6 +37,7 @@ public:
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,

View File

@ -122,6 +122,7 @@ gfxQtPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFam
gfxFontGroup *
gfxQtPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
return new gfxPangoFontGroup(aFontFamilyList, aStyle, aUserFontSet);

View File

@ -41,9 +41,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) override;
virtual gfxFontGroup *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet) override;
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to

View File

@ -1536,13 +1536,14 @@ gfxTextRun::Dump(FILE* aOutput) {
gfxFontGroup::gfxFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
: mFamilyList(aFontFamilyList)
, mStyle(*aStyle)
, mUnderlineOffset(UNDERLINE_OFFSET_NOT_SET)
, mHyphenWidth(-1)
, mUserFontSet(aUserFontSet)
, mTextPerf(nullptr)
, mTextPerf(aTextPerf)
, mPageLang(gfxPlatform::GetFontPrefLangFor(aStyle->language))
, mSkipDrawing(false)
, mSkipUpdateUserFonts(false)
@ -1993,8 +1994,8 @@ gfxFontGroup::GetFirstMathFont()
gfxFontGroup *
gfxFontGroup::Copy(const gfxFontStyle *aStyle)
{
gfxFontGroup *fg = new gfxFontGroup(mFamilyList, aStyle, mUserFontSet);
fg->SetTextPerfMetrics(mTextPerf);
gfxFontGroup *fg =
new gfxFontGroup(mFamilyList, aStyle, mTextPerf, mUserFontSet);
return fg;
}

View File

@ -732,8 +732,9 @@ public:
static void Shutdown(); // platform must call this to release the languageAtomService
gfxFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet = nullptr);
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet = nullptr);
virtual ~gfxFontGroup();
@ -844,7 +845,6 @@ public:
// used when logging text performance
gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
void SetTextPerfMetrics(gfxTextPerfMetrics *aTextPerf) { mTextPerf = aTextPerf; }
// This will call UpdateUserFonts() if the user font set is changed.
void SetUserFontSet(gfxUserFontSet *aUserFontSet);

View File

@ -1027,9 +1027,10 @@ gfxWindowsPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString&
gfxFontGroup *
gfxWindowsPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
gfxFontEntry*

View File

@ -182,9 +182,11 @@ public:
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
gfxFontGroup *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet);
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to support @font-face src local() )