mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1385029 - require implementation of gfxFont::GetScaledFont and remove unnecessary gfxPlatform::GetScaledFontForFont. r=jfkthame
MozReview-Commit-ID: GP1Aekecb0s
This commit is contained in:
parent
2276117381
commit
a21ad6d19e
@ -262,12 +262,6 @@ gfxAndroidPlatform::GetFTLibrary()
|
||||
return gPlatformFTLibrary;
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
return GetScaledFontForFontWithCairoSkia(aTarget, aFont);
|
||||
}
|
||||
|
||||
bool
|
||||
gfxAndroidPlatform::FontHintingEnabled()
|
||||
{
|
||||
|
@ -32,9 +32,6 @@ public:
|
||||
gfxImageFormat aFormat) override;
|
||||
|
||||
virtual gfxImageFormat GetOffscreenFormat() override { return mOffscreenFormat; }
|
||||
|
||||
already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override;
|
||||
|
||||
// to support IPC font list (sharing between chrome and content)
|
||||
void GetSystemFontList(InfallibleTArray<FontListEntry>* retValue);
|
||||
|
@ -679,35 +679,23 @@ gfxDWriteFont::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
||||
{
|
||||
bool wantCairo = aTarget->GetBackendType() == BackendType::CAIRO;
|
||||
if (mAzureScaledFont && mAzureScaledFontIsCairo == wantCairo) {
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
if (!mAzureScaledFont) {
|
||||
gfxDWriteFontEntry *fe =
|
||||
static_cast<gfxDWriteFontEntry*>(mFontEntry.get());
|
||||
bool useEmbeddedBitmap =
|
||||
fe->IsCJKFont() &&
|
||||
HasBitmapStrikeForSize(NS_lround(mAdjustedSize));
|
||||
bool forceGDI = GetForceGDIClassic();
|
||||
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::DWRITE_FONT_FACE;
|
||||
nativeFont.mFont = GetFontFace();
|
||||
IDWriteRenderingParams* params = gfxWindowsPlatform::GetPlatform()->GetRenderingParams(
|
||||
mUseClearType ?
|
||||
(forceGDI ?
|
||||
gfxWindowsPlatform::TEXT_RENDERING_GDI_CLASSIC :
|
||||
gfxWindowsPlatform::TEXT_RENDERING_NORMAL) :
|
||||
gfxWindowsPlatform::TEXT_RENDERING_NO_CLEARTYPE);
|
||||
|
||||
if (wantCairo) {
|
||||
mAzureScaledFont = Factory::CreateScaledFontWithCairo(nativeFont,
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
} else {
|
||||
gfxDWriteFontEntry *fe =
|
||||
static_cast<gfxDWriteFontEntry*>(mFontEntry.get());
|
||||
bool useEmbeddedBitmap = (fe->IsCJKFont() && HasBitmapStrikeForSize(NS_lround(mAdjustedSize)));
|
||||
bool forceGDI = GetForceGDIClassic();
|
||||
|
||||
IDWriteRenderingParams* params = gfxWindowsPlatform::GetPlatform()->GetRenderingParams(
|
||||
mUseClearType ?
|
||||
(forceGDI ?
|
||||
gfxWindowsPlatform::TEXT_RENDERING_GDI_CLASSIC : gfxWindowsPlatform::TEXT_RENDERING_NORMAL) :
|
||||
gfxWindowsPlatform::TEXT_RENDERING_NO_CLEARTYPE);
|
||||
|
||||
const gfxFontStyle* fontStyle = GetStyle();
|
||||
mAzureScaledFont =
|
||||
const gfxFontStyle* fontStyle = GetStyle();
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontForDWriteFont(mFontFace, fontStyle,
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
@ -716,10 +704,21 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
||||
params,
|
||||
params->GetGamma(),
|
||||
params->GetEnhancedContrast());
|
||||
}
|
||||
if (!mAzureScaledFont) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
mAzureScaledFontIsCairo = wantCairo;
|
||||
if (aTarget->GetBackendType() == BackendType::CAIRO) {
|
||||
if (!mAzureScaledFont->GetCairoScaledFont()) {
|
||||
cairo_scaled_font_t* cairoScaledFont = GetCairoScaledFont();
|
||||
if (!cairoScaledFont) {
|
||||
return nullptr;
|
||||
}
|
||||
mAzureScaledFont->SetCairoScaledFont(cairoScaledFont);
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
@ -105,7 +105,6 @@ protected:
|
||||
bool mNeedsBold;
|
||||
bool mUseSubpixelPositions;
|
||||
bool mAllowManualShowGlyphs;
|
||||
bool mAzureScaledFontIsCairo;
|
||||
static bool mUseClearType;
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
/**
|
||||
* gfxFT2Font
|
||||
*/
|
||||
@ -157,7 +160,7 @@ gfxFT2Font::AddRange(const char16_t *aText, uint32_t aOffset,
|
||||
}
|
||||
}
|
||||
|
||||
gfxFT2Font::gfxFT2Font(const RefPtr<mozilla::gfx::UnscaledFontFreeType>& aUnscaledFont,
|
||||
gfxFT2Font::gfxFT2Font(const RefPtr<UnscaledFontFreeType>& aUnscaledFont,
|
||||
cairo_scaled_font_t *aCairoFont,
|
||||
FT2FontEntry *aFontEntry,
|
||||
const gfxFontStyle *aFontStyle,
|
||||
@ -173,6 +176,23 @@ gfxFT2Font::~gfxFT2Font()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxFT2Font::GetScaledFont(DrawTarget *aTarget)
|
||||
{
|
||||
if (!mAzureScaledFont) {
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = GetCairoScaledFont();
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize());
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::FillGlyphDataForChar(FT_Face face, uint32_t ch, CachedGlyphData *gd)
|
||||
{
|
||||
@ -208,7 +228,7 @@ gfxFT2Font::FillGlyphDataForChar(FT_Face face, uint32_t ch, CachedGlyphData *gd)
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
gfxFT2Font::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
@ -217,7 +237,7 @@ gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
gfxFT2Font::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
|
@ -28,6 +28,9 @@ public: // new functions
|
||||
|
||||
FT2FontEntry *GetFontEntry();
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFont(DrawTarget *aTarget) override;
|
||||
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const override;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
|
@ -1206,6 +1206,21 @@ gfxFontconfigFont::~gfxFontconfigFont()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxFontconfigFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
||||
{
|
||||
if (!mAzureScaledFont) {
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontForFontconfigFont(GetCairoScaledFont(),
|
||||
GetPattern(),
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize());
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
gfxFcPlatformFontList::gfxFcPlatformFontList()
|
||||
: mLocalNames(64)
|
||||
, mGenericMappings(32)
|
||||
|
@ -222,6 +222,9 @@ public:
|
||||
virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; }
|
||||
virtual FcPattern *GetPattern() const { return mPattern; }
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFont(DrawTarget *aTarget) override;
|
||||
|
||||
private:
|
||||
virtual ~gfxFontconfigFont();
|
||||
|
||||
|
@ -1831,10 +1831,7 @@ public:
|
||||
return mUnscaledFont;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(DrawTarget* aTarget)
|
||||
{
|
||||
return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this);
|
||||
}
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(DrawTarget* aTarget) = 0;
|
||||
|
||||
bool KerningDisabled() {
|
||||
return mKerningSet && !mKerningEnabled;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define ROUND(x) floor((x) + 0.5)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::unicode;
|
||||
|
||||
static inline cairo_antialias_t
|
||||
@ -135,6 +136,27 @@ gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
|
||||
return true;
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxGDIFont::GetScaledFont(DrawTarget *aTarget)
|
||||
{
|
||||
if (!mAzureScaledFont) {
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::GDI_FONT_FACE;
|
||||
LOGFONT lf;
|
||||
GetObject(GetHFONT(), sizeof(LOGFONT), &lf);
|
||||
nativeFont.mFont = &lf;
|
||||
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontWithCairo(nativeFont,
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
gfxFont::RunMetrics
|
||||
gfxGDIFont::Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
|
@ -35,6 +35,9 @@ public:
|
||||
|
||||
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFont(DrawTarget *aTarget) override;
|
||||
|
||||
/* override Measure to add padding for antialiasing */
|
||||
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
|
@ -1276,17 +1276,6 @@ gfxPlatform::GetWrappedDataSourceSurface(gfxASurface* aSurface)
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
aFont->GetUnscaledFont(),
|
||||
aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::ComputeTileSize()
|
||||
{
|
||||
@ -2579,17 +2568,6 @@ gfxPlatform::DisableBufferRotation()
|
||||
sBufferRotationCheckPref = false;
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
aFont->GetUnscaledFont(),
|
||||
aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
gfxPlatform::UsesOffMainThreadCompositing()
|
||||
{
|
||||
|
@ -239,9 +239,6 @@ public:
|
||||
static already_AddRefed<DataSourceSurface>
|
||||
GetWrappedDataSourceSurface(gfxASurface *aSurface);
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
|
||||
|
||||
already_AddRefed<DrawTarget>
|
||||
CreateOffscreenContentDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
|
||||
|
||||
@ -780,9 +777,6 @@ protected:
|
||||
*/
|
||||
static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName);
|
||||
|
||||
static already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont);
|
||||
|
||||
virtual bool CanUseHardwareVideoDecoding();
|
||||
|
||||
int8_t mAllowDownloadableFonts;
|
||||
|
@ -567,20 +567,6 @@ gfxPlatformGtk::GetGdkDrawable(cairo_surface_t *target)
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
if (aFont->GetType() == gfxFont::FONT_TYPE_FONTCONFIG) {
|
||||
gfxFontconfigFontBase* fcFont = static_cast<gfxFontconfigFontBase*>(aFont);
|
||||
return Factory::CreateScaledFontForFontconfigFont(
|
||||
fcFont->GetCairoScaledFont(),
|
||||
fcFont->GetPattern(),
|
||||
fcFont->GetUnscaledFont(),
|
||||
fcFont->GetAdjustedSize());
|
||||
}
|
||||
return GetScaledFontForFontWithCairoSkia(aTarget, aFont);
|
||||
}
|
||||
|
||||
#ifdef GL_PROVIDER_GLX
|
||||
|
||||
class GLXVsyncSource final : public VsyncSource
|
||||
|
@ -35,9 +35,6 @@ public:
|
||||
CreateOffscreenSurface(const IntSize& aSize,
|
||||
gfxImageFormat aFormat) override;
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override;
|
||||
|
||||
virtual nsresult GetFontList(nsIAtom *aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsTArray<nsString>& aListOfFonts) override;
|
||||
|
@ -133,13 +133,6 @@ gfxPlatformMac::CreateOffscreenSurface(const IntSize& aSize,
|
||||
return newSurface.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatformMac::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
gfxMacFont *font = static_cast<gfxMacFont*>(aFont);
|
||||
return font->GetScaledFont(aTarget);
|
||||
}
|
||||
|
||||
gfxFontGroup *
|
||||
gfxPlatformMac::CreateFontGroup(const FontFamilyList& aFontFamilyList,
|
||||
const gfxFontStyle *aStyle,
|
||||
|
@ -30,9 +30,6 @@ public:
|
||||
CreateOffscreenSurface(const IntSize& aSize,
|
||||
gfxImageFormat aFormat) override;
|
||||
|
||||
already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override;
|
||||
|
||||
gfxFontGroup*
|
||||
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
|
||||
const gfxFontStyle *aStyle,
|
||||
|
@ -554,34 +554,6 @@ gfxWindowsPlatform::CreateOffscreenSurface(const IntSize& aSize,
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
if (aFont->GetType() == gfxFont::FONT_TYPE_DWRITE) {
|
||||
return aFont->GetScaledFont(aTarget);
|
||||
}
|
||||
|
||||
NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_GDI,
|
||||
"Fonts on windows should be GDI or DWrite!");
|
||||
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::GDI_FONT_FACE;
|
||||
LOGFONT lf;
|
||||
GetObject(static_cast<gfxGDIFont*>(aFont)->GetHFONT(), sizeof(LOGFONT), &lf);
|
||||
nativeFont.mFont = &lf;
|
||||
|
||||
if (aTarget->GetBackendType() == BackendType::CAIRO) {
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont,
|
||||
aFont->GetUnscaledFont(),
|
||||
aFont->GetAdjustedSize(),
|
||||
aFont->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
aFont->GetUnscaledFont(),
|
||||
aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
static const char kFontAparajita[] = "Aparajita";
|
||||
static const char kFontArabicTypesetting[] = "Arabic Typesetting";
|
||||
static const char kFontArial[] = "Arial";
|
||||
|
@ -121,9 +121,6 @@ public:
|
||||
CreateOffscreenSurface(const IntSize& aSize,
|
||||
gfxImageFormat aFormat) override;
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override;
|
||||
|
||||
enum RenderMode {
|
||||
/* Use GDI and windows surfaces */
|
||||
RENDER_GDI = 0,
|
||||
|
@ -87,7 +87,7 @@ random-if(winWidget) == 305643-1.html 305643-1-ref.html # depends on windows ver
|
||||
== 413542-1.html 413542-1-ref.html
|
||||
== 413542-2.html 413542-2-ref.html
|
||||
fails-if(webrender) == 413928-1.html 413928-1-ref.html
|
||||
== 413928-2.html 413928-2-ref.html
|
||||
fails-if(webrender) == 413928-2.html 413928-2-ref.html
|
||||
== 425338-1a.html 425338-1-ref.html
|
||||
== 425338-1b.html 425338-1-ref.html
|
||||
== 489517-1.html 489517-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user