зеркало из https://github.com/mozilla/gecko-dev.git
Bug 736276 - Only create the SkTypeface in ScaledFontCairo when necessary r=jrmuizel
This commit is contained in:
Родитель
5ee1188ac5
Коммит
602e1332d6
|
@ -34,26 +34,34 @@ namespace gfx {
|
||||||
// is a requirement when we consider runtime switchable backends and so on
|
// is a requirement when we consider runtime switchable backends and so on
|
||||||
ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize)
|
ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize)
|
||||||
: ScaledFontBase(aSize)
|
: ScaledFontBase(aSize)
|
||||||
{
|
{
|
||||||
mScaledFont = aScaledFont;
|
mScaledFont = aScaledFont;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
||||||
cairo_font_face_t* fontFace = cairo_scaled_font_get_font_face(aScaledFont);
|
SkTypeface* ScaledFontCairo::GetSkTypeface()
|
||||||
FT_Face face = cairo_ft_scaled_font_lock_face(aScaledFont);
|
{
|
||||||
|
if (!mTypeface) {
|
||||||
|
cairo_font_face_t* fontFace = cairo_scaled_font_get_font_face(mScaledFont);
|
||||||
|
FT_Face face = cairo_ft_scaled_font_lock_face(mScaledFont);
|
||||||
|
|
||||||
int style = SkTypeface::kNormal;
|
int style = SkTypeface::kNormal;
|
||||||
|
|
||||||
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
|
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
|
||||||
style |= SkTypeface::kItalic;
|
style |= SkTypeface::kItalic;
|
||||||
|
|
||||||
if (face->style_flags & FT_STYLE_FLAG_BOLD)
|
if (face->style_flags & FT_STYLE_FLAG_BOLD)
|
||||||
style |= SkTypeface::kBold;
|
style |= SkTypeface::kBold;
|
||||||
|
|
||||||
bool isFixedWidth = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
|
bool isFixedWidth = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
|
||||||
cairo_ft_scaled_font_unlock_face(aScaledFont);
|
cairo_ft_scaled_font_unlock_face(mScaledFont);
|
||||||
|
|
||||||
mTypeface = SkCreateTypefaceFromCairoFont(fontFace, (SkTypeface::Style)style, isFixedWidth);
|
mTypeface = SkCreateTypefaceFromCairoFont(fontFace, (SkTypeface::Style)style, isFixedWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mTypeface;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@ class ScaledFontCairo : public ScaledFontBase
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize);
|
ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize);
|
||||||
|
|
||||||
|
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
||||||
|
virtual SkTypeface* GetSkTypeface();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to be able to tell Skia whether or not to use
|
// We need to be able to tell Skia whether or not to use
|
||||||
|
|
Загрузка…
Ссылка в новой задаче