mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
ported from UXP: Issue #2191 - Require implementation of gfxFont::GetScaledFont and remove unnecessary gfxPlatform::GetScaledFontForFont. (0f7750cd)
This commit is contained in:
@@ -682,38 +682,35 @@ 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));
|
||||
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::DWRITE_FONT_FACE;
|
||||
nativeFont.mFont = GetFontFace();
|
||||
|
||||
if (wantCairo) {
|
||||
mAzureScaledFont = Factory::CreateScaledFontWithCairo(nativeFont,
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
} else if (aTarget->GetBackendType() == BackendType::SKIA) {
|
||||
gfxDWriteFontEntry *fe =
|
||||
static_cast<gfxDWriteFontEntry*>(mFontEntry.get());
|
||||
bool useEmbeddedBitmap = (fe->IsCJKFont() && HasBitmapStrikeForSize(NS_lround(mAdjustedSize)));
|
||||
|
||||
const gfxFontStyle* fontStyle = GetStyle();
|
||||
mAzureScaledFont =
|
||||
const gfxFontStyle* fontStyle = GetStyle();
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontForDWriteFont(mFontFace, fontStyle,
|
||||
GetAdjustedSize(),
|
||||
useEmbeddedBitmap,
|
||||
GetForceGDIClassic());
|
||||
} else {
|
||||
mAzureScaledFont = Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
GetAdjustedSize());
|
||||
}
|
||||
|
||||
mAzureScaledFontIsCairo = wantCairo;
|
||||
if (!mAzureScaledFont) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,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
|
||||
*/
|
||||
@@ -174,6 +177,21 @@ 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, GetAdjustedSize());
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd)
|
||||
{
|
||||
@@ -212,7 +230,7 @@ gfxFT2Font::FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd)
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
gfxFT2Font::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
@@ -221,7 +239,7 @@ gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
gfxFT2Font::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
|
||||
@@ -27,6 +27,9 @@ public: // new functions
|
||||
|
||||
FT2FontEntry *GetFontEntry();
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::ScaledFont>
|
||||
GetScaledFont(DrawTarget *aTarget) override;
|
||||
|
||||
struct CachedGlyphData {
|
||||
CachedGlyphData()
|
||||
: glyphIndex(0xffffffffU) { }
|
||||
|
||||
@@ -1105,6 +1105,20 @@ gfxFontconfigFont::~gfxFontconfigFont()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxFontconfigFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
||||
{
|
||||
if (!mAzureScaledFont) {
|
||||
mAzureScaledFont =
|
||||
Factory::CreateScaledFontForFontconfigFont(GetCairoScaledFont(),
|
||||
GetPattern(),
|
||||
GetAdjustedSize());
|
||||
}
|
||||
|
||||
RefPtr<ScaledFont> scaledFont(mAzureScaledFont);
|
||||
return scaledFont.forget();
|
||||
}
|
||||
|
||||
gfxFcPlatformFontList::gfxFcPlatformFontList()
|
||||
: mLocalNames(64)
|
||||
, mGenericMappings(32)
|
||||
|
||||
@@ -217,6 +217,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();
|
||||
|
||||
|
||||
@@ -1842,8 +1842,7 @@ public:
|
||||
|
||||
virtual FontType GetType() const = 0;
|
||||
|
||||
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
|
||||
@@ -130,6 +131,26 @@ 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,
|
||||
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,
|
||||
|
||||
@@ -1152,16 +1152,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->GetAdjustedSize());
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::ComputeTileSize()
|
||||
{
|
||||
@@ -2285,19 +2275,6 @@ gfxPlatform::DisableBufferRotation()
|
||||
sBufferRotationCheckPref = false;
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
if (aTarget->GetBackendType() == BackendType::CAIRO || aTarget->GetBackendType() == BackendType::SKIA) {
|
||||
nativeFont.mType = NativeFontType::CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
gfxPlatform::UsesOffMainThreadCompositing()
|
||||
{
|
||||
|
||||
@@ -229,9 +229,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);
|
||||
|
||||
@@ -765,9 +762,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;
|
||||
|
||||
@@ -585,25 +585,6 @@ gfxPlatformGtk::GetGdkDrawable(cairo_surface_t *target)
|
||||
}
|
||||
#endif
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
switch (aTarget->GetBackendType()) {
|
||||
case BackendType::CAIRO:
|
||||
case BackendType::SKIA:
|
||||
if (aFont->GetType() == gfxFont::FONT_TYPE_FONTCONFIG) {
|
||||
gfxFontconfigFontBase* fcFont = static_cast<gfxFontconfigFontBase*>(aFont);
|
||||
return Factory::CreateScaledFontForFontconfigFont(
|
||||
fcFont->GetCairoScaledFont(),
|
||||
fcFont->GetPattern(),
|
||||
fcFont->GetAdjustedSize());
|
||||
}
|
||||
MOZ_FALLTHROUGH;
|
||||
default:
|
||||
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;
|
||||
|
||||
@@ -135,13 +135,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,
|
||||
|
||||
@@ -602,44 +602,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) {
|
||||
gfxDWriteFont *font = static_cast<gfxDWriteFont*>(aFont);
|
||||
|
||||
NativeFont nativeFont;
|
||||
nativeFont.mType = NativeFontType::DWRITE_FONT_FACE;
|
||||
nativeFont.mFont = font->GetFontFace();
|
||||
|
||||
if (aTarget->GetBackendType() == BackendType::CAIRO) {
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont,
|
||||
font->GetAdjustedSize(),
|
||||
font->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
font->GetAdjustedSize());
|
||||
}
|
||||
|
||||
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->GetAdjustedSize(),
|
||||
aFont->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
static const char kFontAparajita[] = "Aparajita";
|
||||
static const char kFontArabicTypesetting[] = "Arabic Typesetting";
|
||||
static const char kFontArial[] = "Arial";
|
||||
|
||||
@@ -122,9 +122,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,
|
||||
|
||||
Reference in New Issue
Block a user