зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d09fb3a5cedf (bug 1376026)
This commit is contained in:
Родитель
cd6ff28835
Коммит
fbc9f302f1
17
gfx/2d/2D.h
17
gfx/2d/2D.h
|
@ -1520,13 +1520,12 @@ public:
|
|||
*
|
||||
* @param aData Pointer to the data
|
||||
* @param aSize Size of the TrueType data
|
||||
* @param aBackendType Type of the reference DrawTarget the font should be created for.
|
||||
* @param aFontType Type of NativeFontResource that should be created.
|
||||
* @param aType Type of NativeFontResource that should be created.
|
||||
* @param aFontContext Optional native font context to be used to create the NativeFontResource.
|
||||
* @return a NativeFontResource of nullptr if failed.
|
||||
*/
|
||||
static already_AddRefed<NativeFontResource>
|
||||
CreateNativeFontResource(uint8_t *aData, uint32_t aSize, BackendType aBackendType, FontType aFontType, void* aFontContext = nullptr);
|
||||
CreateNativeFontResource(uint8_t *aData, uint32_t aSize, FontType aType, void* aFontContext = nullptr);
|
||||
|
||||
/**
|
||||
* This creates an unscaled font of the given type based on font descriptor
|
||||
|
@ -1662,13 +1661,16 @@ public:
|
|||
* Returns true on success, or false on failure and leaves the D2D1/Direct3D11 devices unset.
|
||||
*/
|
||||
static bool SetDirect3D11Device(ID3D11Device *aDevice);
|
||||
static bool SetDWriteFactory(IDWriteFactory *aFactory);
|
||||
static ID3D11Device *GetDirect3D11Device();
|
||||
static ID2D1Device *GetD2D1Device();
|
||||
static uint32_t GetD2D1DeviceSeq();
|
||||
static IDWriteFactory *GetDWriteFactory();
|
||||
static IDWriteFactory* EnsureDWriteFactory();
|
||||
static bool SupportsD2D1();
|
||||
|
||||
static already_AddRefed<GlyphRenderingOptions>
|
||||
CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams);
|
||||
|
||||
static uint64_t GetD2DVRAMUsageDrawTarget();
|
||||
static uint64_t GetD2DVRAMUsageSourceSurface();
|
||||
static void D2DCleanup();
|
||||
|
@ -1679,10 +1681,7 @@ public:
|
|||
const RefPtr<UnscaledFont>& aUnscaledFont,
|
||||
Float aSize,
|
||||
bool aUseEmbeddedBitmap,
|
||||
bool aForceGDIMode,
|
||||
IDWriteRenderingParams *aParams,
|
||||
Float aGamma,
|
||||
Float aContrast);
|
||||
bool aForceGDIMode);
|
||||
|
||||
static void UpdateSystemTextQuality();
|
||||
|
||||
|
@ -1690,8 +1689,6 @@ private:
|
|||
static ID2D1Device *mD2D1Device;
|
||||
static ID3D11Device *mD3D11Device;
|
||||
static IDWriteFactory *mDWriteFactory;
|
||||
static bool mDWriteFactoryInitialized;
|
||||
static Mutex* mDWriteFactoryLock;
|
||||
#endif
|
||||
|
||||
static DrawEventRecorder *mRecorder;
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "Tools.h"
|
||||
#include "nsAppRunner.h"
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// decltype is not usable for overloaded functions.
|
||||
|
@ -34,6 +32,7 @@ namespace gfx {
|
|||
|
||||
uint64_t DrawTargetD2D1::mVRAMUsageDT;
|
||||
uint64_t DrawTargetD2D1::mVRAMUsageSS;
|
||||
IDWriteFactory *DrawTargetD2D1::mDWriteFactory;
|
||||
ID2D1Factory1* DrawTargetD2D1::mFactory = nullptr;
|
||||
|
||||
ID2D1Factory1 *D2DFactory1()
|
||||
|
@ -609,7 +608,7 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *aFont,
|
|||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions*)
|
||||
const GlyphRenderingOptions *aRenderingOptions)
|
||||
{
|
||||
if (aFont->GetType() != FontType::DWRITE) {
|
||||
gfxDebug() << *this << ": Ignoring drawing call for incompatible font.";
|
||||
|
@ -618,7 +617,16 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *aFont,
|
|||
|
||||
ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
|
||||
|
||||
IDWriteRenderingParams *params = font->mParams;
|
||||
IDWriteRenderingParams *params = nullptr;
|
||||
if (aRenderingOptions) {
|
||||
if (aRenderingOptions->GetType() != FontType::DWRITE) {
|
||||
gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
|
||||
// This should never happen.
|
||||
MOZ_ASSERT(false);
|
||||
} else {
|
||||
params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderingOptions)->mParams;
|
||||
}
|
||||
}
|
||||
|
||||
AntialiasMode aaMode = font->GetDefaultAAMode();
|
||||
|
||||
|
@ -1248,6 +1256,33 @@ DrawTargetD2D1::factory()
|
|||
return mFactory;
|
||||
}
|
||||
|
||||
IDWriteFactory*
|
||||
DrawTargetD2D1::GetDWriteFactory()
|
||||
{
|
||||
if (mDWriteFactory) {
|
||||
return mDWriteFactory;
|
||||
}
|
||||
|
||||
decltype(DWriteCreateFactory)* createDWriteFactory;
|
||||
HMODULE dwriteModule = LoadLibraryW(L"dwrite.dll");
|
||||
createDWriteFactory = (decltype(DWriteCreateFactory)*)
|
||||
GetProcAddress(dwriteModule, "DWriteCreateFactory");
|
||||
|
||||
if (!createDWriteFactory) {
|
||||
gfxWarning() << "Failed to locate DWriteCreateFactory function.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HRESULT hr = createDWriteFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown**>(&mDWriteFactory));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
gfxWarning() << "Failed to create DWrite Factory.";
|
||||
}
|
||||
|
||||
return mDWriteFactory;
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetD2D1::CleanupD2D()
|
||||
{
|
||||
|
|
|
@ -155,6 +155,7 @@ public:
|
|||
|
||||
static ID2D1Factory1 *factory();
|
||||
static void CleanupD2D();
|
||||
static IDWriteFactory *GetDWriteFactory();
|
||||
|
||||
operator std::string() const {
|
||||
std::stringstream stream;
|
||||
|
@ -293,6 +294,7 @@ private:
|
|||
bool mDidComplexBlendWithListInList;
|
||||
|
||||
static ID2D1Factory1 *mFactory;
|
||||
static IDWriteFactory *mDWriteFactory;
|
||||
// This value is uesed to verify if the DrawTarget is created by a stale device.
|
||||
uint32_t mDeviceSeq;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <d3d10_1.h>
|
||||
#include "HelpersD2D.h"
|
||||
#include "HelpersWinFonts.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#endif
|
||||
|
||||
#include "DrawTargetDual.h"
|
||||
|
@ -204,8 +203,6 @@ static uint32_t mDeviceSeq = 0;
|
|||
ID3D11Device *Factory::mD3D11Device = nullptr;
|
||||
ID2D1Device *Factory::mD2D1Device = nullptr;
|
||||
IDWriteFactory *Factory::mDWriteFactory = nullptr;
|
||||
bool Factory::mDWriteFactoryInitialized = false;
|
||||
Mutex* Factory::mDWriteFactoryLock = nullptr;
|
||||
#endif
|
||||
|
||||
DrawEventRecorder *Factory::mRecorder;
|
||||
|
@ -232,10 +229,6 @@ Factory::Init(const Config& aConfig)
|
|||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
mFTLock = new Mutex("Factory::mFTLock");
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
mDWriteFactoryLock = new Mutex("Factory::mDWriteFactoryLock");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -254,13 +247,6 @@ Factory::ShutDown()
|
|||
mFTLock = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
if (mDWriteFactoryLock) {
|
||||
delete mDWriteFactoryLock;
|
||||
mDWriteFactoryLock = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -567,26 +553,38 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont,
|
|||
}
|
||||
|
||||
already_AddRefed<NativeFontResource>
|
||||
Factory::CreateNativeFontResource(uint8_t *aData, uint32_t aSize, BackendType aBackendType, FontType aFontType, void* aFontContext)
|
||||
Factory::CreateNativeFontResource(uint8_t *aData, uint32_t aSize, FontType aType, void* aFontContext)
|
||||
{
|
||||
switch (aFontType) {
|
||||
switch (aType) {
|
||||
#ifdef WIN32
|
||||
case FontType::DWRITE:
|
||||
{
|
||||
bool needsCairo = aBackendType == BackendType::CAIRO ||
|
||||
aBackendType == BackendType::SKIA;
|
||||
return NativeFontResourceDWrite::Create(aData, aSize, needsCairo);
|
||||
return NativeFontResourceDWrite::Create(aData, aSize,
|
||||
/* aNeedsCairo = */ false);
|
||||
}
|
||||
case FontType::GDI:
|
||||
return NativeFontResourceGDI::Create(aData, aSize);
|
||||
#elif defined(XP_DARWIN)
|
||||
case FontType::MAC:
|
||||
return NativeFontResourceMac::Create(aData, aSize);
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
case FontType::FONTCONFIG:
|
||||
return NativeFontResourceFontconfig::Create(aData, aSize,
|
||||
static_cast<FT_Library>(aFontContext));
|
||||
#endif
|
||||
case FontType::CAIRO:
|
||||
#ifdef USE_SKIA
|
||||
case FontType::SKIA:
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (GetDWriteFactory()) {
|
||||
return NativeFontResourceDWrite::Create(aData, aSize,
|
||||
/* aNeedsCairo = */ true);
|
||||
} else {
|
||||
return NativeFontResourceGDI::Create(aData, aSize);
|
||||
}
|
||||
#elif defined(XP_DARWIN)
|
||||
return NativeFontResourceMac::Create(aData, aSize);
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
return NativeFontResourceFontconfig::Create(aData, aSize,
|
||||
static_cast<FT_Library>(aFontContext));
|
||||
#else
|
||||
gfxWarning() << "Unable to create cairo scaled font from truetype data";
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
default:
|
||||
gfxWarning() << "Unable to create requested font resource from truetype data";
|
||||
return nullptr;
|
||||
|
@ -758,6 +756,13 @@ Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceForma
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
Factory::SetDWriteFactory(IDWriteFactory *aFactory)
|
||||
{
|
||||
mDWriteFactory = aFactory;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Factory::SetDirect3D11Device(ID3D11Device *aDevice)
|
||||
{
|
||||
|
@ -813,43 +818,18 @@ Factory::GetDWriteFactory()
|
|||
return mDWriteFactory;
|
||||
}
|
||||
|
||||
IDWriteFactory*
|
||||
Factory::EnsureDWriteFactory()
|
||||
{
|
||||
MOZ_ASSERT(mDWriteFactoryLock);
|
||||
MutexAutoLock lock(*mDWriteFactoryLock);
|
||||
|
||||
if (mDWriteFactoryInitialized) {
|
||||
return mDWriteFactory;
|
||||
}
|
||||
|
||||
mDWriteFactoryInitialized = true;
|
||||
|
||||
HMODULE dwriteModule = LoadLibraryW(L"dwrite.dll");
|
||||
decltype(DWriteCreateFactory)* createDWriteFactory = (decltype(DWriteCreateFactory)*)
|
||||
GetProcAddress(dwriteModule, "DWriteCreateFactory");
|
||||
|
||||
if (!createDWriteFactory) {
|
||||
gfxWarning() << "Failed to locate DWriteCreateFactory function.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HRESULT hr = createDWriteFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown**>(&mDWriteFactory));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
gfxWarning() << "Failed to create DWrite Factory.";
|
||||
}
|
||||
|
||||
return mDWriteFactory;
|
||||
}
|
||||
|
||||
bool
|
||||
Factory::SupportsD2D1()
|
||||
{
|
||||
return !!D2DFactory1();
|
||||
}
|
||||
|
||||
already_AddRefed<GlyphRenderingOptions>
|
||||
Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
|
||||
{
|
||||
return MakeAndAddRef<GlyphRenderingOptionsDWrite>(aParams);
|
||||
}
|
||||
|
||||
BYTE sSystemTextQuality = CLEARTYPE_QUALITY;
|
||||
void
|
||||
Factory::UpdateSystemTextQuality()
|
||||
|
@ -887,14 +867,10 @@ Factory::CreateScaledFontForDWriteFont(IDWriteFontFace* aFontFace,
|
|||
const RefPtr<UnscaledFont>& aUnscaledFont,
|
||||
float aSize,
|
||||
bool aUseEmbeddedBitmap,
|
||||
bool aForceGDIMode,
|
||||
IDWriteRenderingParams* aParams,
|
||||
Float aGamma,
|
||||
Float aContrast)
|
||||
bool aForceGDIMode)
|
||||
{
|
||||
return MakeAndAddRef<ScaledFontDWrite>(aFontFace, aUnscaledFont, aSize,
|
||||
aUseEmbeddedBitmap, aForceGDIMode,
|
||||
aParams, aGamma, aContrast,
|
||||
aStyle);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,5 +76,20 @@ InlineTranslator::CreateDrawTarget(ReferencePtr aRefPtr,
|
|||
return drawTarget.forget();
|
||||
}
|
||||
|
||||
FontType
|
||||
InlineTranslator::GetDesiredFontType()
|
||||
{
|
||||
switch (mBaseDT->GetBackendType()) {
|
||||
case BackendType::DIRECT2D:
|
||||
return FontType::DWRITE;
|
||||
case BackendType::CAIRO:
|
||||
return FontType::CAIRO;
|
||||
case BackendType::SKIA:
|
||||
return FontType::SKIA;
|
||||
default:
|
||||
return FontType::CAIRO;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -173,6 +173,8 @@ public:
|
|||
|
||||
mozilla::gfx::DrawTarget* GetReferenceDrawTarget() final { return mBaseDT; }
|
||||
|
||||
mozilla::gfx::FontType GetDesiredFontType() final;
|
||||
|
||||
void* GetFontContext() final { return mFontContext; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "DrawTargetD2D1.h"
|
||||
#include "Logging.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
{
|
||||
if (!mInstance) {
|
||||
mInstance = new DWriteFontFileLoader();
|
||||
Factory::GetDWriteFactory()->
|
||||
DrawTargetD2D1::GetDWriteFactory()->
|
||||
RegisterFontFileLoader(mInstance);
|
||||
}
|
||||
return mInstance;
|
||||
|
@ -221,7 +222,7 @@ already_AddRefed<NativeFontResourceDWrite>
|
|||
NativeFontResourceDWrite::Create(uint8_t *aFontData, uint32_t aDataLength,
|
||||
bool aNeedsCairo)
|
||||
{
|
||||
IDWriteFactory *factory = Factory::EnsureDWriteFactory();
|
||||
IDWriteFactory *factory = DrawTargetD2D1::GetDWriteFactory();
|
||||
if (!factory) {
|
||||
gfxWarning() << "Failed to get DWrite Factory.";
|
||||
return nullptr;
|
||||
|
|
|
@ -24,7 +24,7 @@ const uint32_t kMagicInt = 0xc001feed;
|
|||
// loss of backwards compatibility. Old streams will not work in a player
|
||||
// using a newer major revision. And new streams will not work in a player
|
||||
// using an older major revision.
|
||||
const uint16_t kMajorRevision = 10;
|
||||
const uint16_t kMajorRevision = 9;
|
||||
// A change in minor revision means additions of new events. New streams will
|
||||
// not play in older players.
|
||||
const uint16_t kMinorRevision = 0;
|
||||
|
@ -111,6 +111,7 @@ public:
|
|||
const IntSize &aSize,
|
||||
SurfaceFormat aFormat);
|
||||
virtual DrawTarget *GetReferenceDrawTarget() = 0;
|
||||
virtual FontType GetDesiredFontType() = 0;
|
||||
virtual void* GetFontContext() { return nullptr; }
|
||||
};
|
||||
|
||||
|
|
|
@ -847,9 +847,7 @@ public:
|
|||
}
|
||||
|
||||
explicit RecordedFontData(UnscaledFont *aUnscaledFont)
|
||||
: RecordedEventDerived(FONTDATA)
|
||||
, mType(aUnscaledFont->GetType())
|
||||
, mData(nullptr)
|
||||
: RecordedEventDerived(FONTDATA), mData(nullptr)
|
||||
{
|
||||
mGetFontFileDataSucceeded = aUnscaledFont->GetFontFileData(&FontDataProc, this);
|
||||
}
|
||||
|
@ -873,7 +871,6 @@ public:
|
|||
private:
|
||||
friend class RecordedEvent;
|
||||
|
||||
FontType mType;
|
||||
uint8_t* mData;
|
||||
RecordedFontDetails mFontDetails;
|
||||
|
||||
|
@ -2645,8 +2642,8 @@ RecordedFontData::PlayEvent(Translator *aTranslator) const
|
|||
{
|
||||
RefPtr<NativeFontResource> fontResource =
|
||||
Factory::CreateNativeFontResource(mData, mFontDetails.size,
|
||||
aTranslator->GetReferenceDrawTarget()->GetBackendType(),
|
||||
mType, aTranslator->GetFontContext());
|
||||
aTranslator->GetDesiredFontType(),
|
||||
aTranslator->GetFontContext());
|
||||
if (!fontResource) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2661,7 +2658,6 @@ RecordedFontData::Record(S &aStream) const
|
|||
{
|
||||
MOZ_ASSERT(mGetFontFileDataSucceeded);
|
||||
|
||||
WriteElement(aStream, mType);
|
||||
WriteElement(aStream, mFontDetails.fontDataKey);
|
||||
WriteElement(aStream, mFontDetails.size);
|
||||
aStream.write((const char*)mData, mFontDetails.size);
|
||||
|
@ -2700,10 +2696,8 @@ RecordedFontData::GetFontDetails(RecordedFontDetails& fontDetails)
|
|||
inline
|
||||
RecordedFontData::RecordedFontData(istream &aStream)
|
||||
: RecordedEventDerived(FONTDATA)
|
||||
, mType(FontType::SKIA)
|
||||
, mData(nullptr)
|
||||
{
|
||||
ReadElement(aStream, mType);
|
||||
ReadElement(aStream, mFontDetails.fontDataKey);
|
||||
ReadElement(aStream, mFontDetails.size);
|
||||
mData = new uint8_t[mFontDetails.size];
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DrawTargetD2D1.h"
|
||||
#include "ScaledFontDWrite.h"
|
||||
#include "UnscaledFontDWrite.h"
|
||||
#include "PathD2D.h"
|
||||
#include "gfxFont.h"
|
||||
#include "Logging.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -108,24 +108,16 @@ ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace *aFontFace,
|
|||
Float aSize,
|
||||
bool aUseEmbeddedBitmap,
|
||||
bool aForceGDIMode,
|
||||
IDWriteRenderingParams* aParams,
|
||||
Float aGamma,
|
||||
Float aContrast,
|
||||
const gfxFontStyle* aStyle)
|
||||
: ScaledFontBase(aUnscaledFont, aSize)
|
||||
, mFontFace(aFontFace)
|
||||
, mUseEmbeddedBitmap(aUseEmbeddedBitmap)
|
||||
, mForceGDIMode(aForceGDIMode)
|
||||
, mParams(aParams)
|
||||
, mGamma(aGamma)
|
||||
, mContrast(aContrast)
|
||||
{
|
||||
if (aStyle) {
|
||||
mStyle = SkFontStyle(aStyle->weight,
|
||||
DWriteFontStretchFromStretch(aStyle->stretch),
|
||||
aStyle->style == NS_FONT_STYLE_NORMAL ?
|
||||
SkFontStyle::kUpright_Slant : SkFontStyle::kItalic_Slant);
|
||||
}
|
||||
mStyle = SkFontStyle(aStyle->weight,
|
||||
DWriteFontStretchFromStretch(aStyle->stretch),
|
||||
aStyle->style == NS_FONT_STYLE_NORMAL ?
|
||||
SkFontStyle::kUpright_Slant : SkFontStyle::kItalic_Slant);
|
||||
}
|
||||
|
||||
already_AddRefed<Path>
|
||||
|
@ -151,12 +143,12 @@ SkTypeface*
|
|||
ScaledFontDWrite::GetSkTypeface()
|
||||
{
|
||||
if (!mTypeface) {
|
||||
IDWriteFactory *factory = Factory::GetDWriteFactory();
|
||||
IDWriteFactory *factory = DrawTargetD2D1::GetDWriteFactory();
|
||||
if (!factory) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mTypeface = SkCreateTypefaceFromDWriteFont(factory, mFontFace, mStyle, mForceGDIMode, mGamma, mContrast);
|
||||
mTypeface = SkCreateTypefaceFromDWriteFont(factory, mFontFace, mStyle, mForceGDIMode);
|
||||
}
|
||||
return mTypeface;
|
||||
}
|
||||
|
@ -280,34 +272,12 @@ UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, void *aBat
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ScaledFontDWrite::GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton)
|
||||
{
|
||||
InstanceData instance(this);
|
||||
aCb(reinterpret_cast<uint8_t*>(&instance), sizeof(instance), aBaton);
|
||||
return true;
|
||||
}
|
||||
|
||||
already_AddRefed<ScaledFont>
|
||||
UnscaledFontDWrite::CreateScaledFont(Float aGlyphSize,
|
||||
const uint8_t* aInstanceData,
|
||||
uint32_t aInstanceDataLength)
|
||||
{
|
||||
if (aInstanceDataLength < sizeof(ScaledFontDWrite::InstanceData)) {
|
||||
gfxWarning() << "DWrite scaled font instance data is truncated.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ScaledFontDWrite::InstanceData *instanceData =
|
||||
reinterpret_cast<const ScaledFontDWrite::InstanceData*>(aInstanceData);
|
||||
RefPtr<ScaledFontBase> scaledFont =
|
||||
new ScaledFontDWrite(mFontFace, this, aGlyphSize,
|
||||
instanceData->mUseEmbeddedBitmap,
|
||||
instanceData->mForceGDIMode,
|
||||
nullptr,
|
||||
instanceData->mGamma,
|
||||
instanceData->mContrast);
|
||||
|
||||
RefPtr<ScaledFontBase> scaledFont = new ScaledFontDWrite(mFontFace, this, aGlyphSize);
|
||||
if (mNeedsCairo && !scaledFont->PopulateCairoScaledFont()) {
|
||||
gfxWarning() << "Unable to create cairo scaled font DWrite font.";
|
||||
return nullptr;
|
||||
|
|
|
@ -15,9 +15,6 @@ struct gfxFontStyle;
|
|||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class NativeFontResourceDWrite;
|
||||
class UnscaledFontDWrite;
|
||||
|
||||
class ScaledFontDWrite final : public ScaledFontBase
|
||||
{
|
||||
public:
|
||||
|
@ -29,8 +26,6 @@ public:
|
|||
, mFontFace(aFont)
|
||||
, mUseEmbeddedBitmap(false)
|
||||
, mForceGDIMode(false)
|
||||
, mGamma(2.2f)
|
||||
, mContrast(1.0f)
|
||||
{}
|
||||
|
||||
ScaledFontDWrite(IDWriteFontFace *aFontFace,
|
||||
|
@ -38,10 +33,7 @@ public:
|
|||
Float aSize,
|
||||
bool aUseEmbeddedBitmap,
|
||||
bool aForceGDIMode,
|
||||
IDWriteRenderingParams *aParams,
|
||||
Float aContrast,
|
||||
Float aGamma,
|
||||
const gfxFontStyle* aStyle = nullptr);
|
||||
const gfxFontStyle* aStyle);
|
||||
|
||||
FontType GetType() const override { return FontType::DWRITE; }
|
||||
|
||||
|
@ -54,8 +46,6 @@ public:
|
|||
|
||||
bool CanSerialize() override { return true; }
|
||||
|
||||
bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
|
||||
|
||||
AntialiasMode GetDefaultAAMode() override;
|
||||
|
||||
bool UseEmbeddedBitmaps() { return mUseEmbeddedBitmap; }
|
||||
|
@ -69,39 +59,29 @@ public:
|
|||
RefPtr<IDWriteFontFace> mFontFace;
|
||||
bool mUseEmbeddedBitmap;
|
||||
bool mForceGDIMode;
|
||||
// DrawTargetD2D1 requires the IDWriteRenderingParams,
|
||||
// but we also separately need to store the gamma and contrast
|
||||
// since Skia needs to be able to access these without having
|
||||
// to use the full set of DWrite parameters (which would be
|
||||
// required to recreate an IDWriteRenderingParams) in a
|
||||
// DrawTargetRecording playback.
|
||||
RefPtr<IDWriteRenderingParams> mParams;
|
||||
Float mGamma;
|
||||
Float mContrast;
|
||||
|
||||
protected:
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_font_face_t* GetCairoFontFace() override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsDWrite, override)
|
||||
explicit GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams)
|
||||
: mParams(aParams)
|
||||
{
|
||||
}
|
||||
|
||||
FontType GetType() const override { return FontType::DWRITE; }
|
||||
|
||||
private:
|
||||
friend class NativeFontResourceDWrite;
|
||||
friend class UnscaledFontDWrite;
|
||||
friend class DrawTargetD2D;
|
||||
friend class DrawTargetD2D1;
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
InstanceData(ScaledFontDWrite* aScaledFont)
|
||||
: mUseEmbeddedBitmap(aScaledFont->mUseEmbeddedBitmap)
|
||||
, mForceGDIMode(aScaledFont->mForceGDIMode)
|
||||
, mGamma(aScaledFont->mGamma)
|
||||
, mContrast(aScaledFont->mContrast)
|
||||
{}
|
||||
|
||||
bool mUseEmbeddedBitmap;
|
||||
bool mForceGDIMode;
|
||||
Float mGamma;
|
||||
Float mContrast;
|
||||
};
|
||||
RefPtr<IDWriteRenderingParams> mParams;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -53,9 +53,7 @@ struct IDWriteFontFallback;
|
|||
SK_API SkTypeface* SkCreateTypefaceFromDWriteFont(IDWriteFactory* aFactory,
|
||||
IDWriteFontFace* aFontFace,
|
||||
SkFontStyle aStyle,
|
||||
bool aForceGDI,
|
||||
float aGamma,
|
||||
float aContrast);
|
||||
bool aForceGDI);
|
||||
|
||||
SK_API sk_sp<SkFontMgr> SkFontMgr_New_GDI();
|
||||
SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
|
||||
|
|
|
@ -341,11 +341,9 @@ SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) {
|
|||
SkTypeface* SkCreateTypefaceFromDWriteFont(IDWriteFactory* aFactory,
|
||||
IDWriteFontFace* aFontFace,
|
||||
SkFontStyle aStyle,
|
||||
bool aForceGDI,
|
||||
float aGamma,
|
||||
float aContrast)
|
||||
bool aForceGDI)
|
||||
{
|
||||
return DWriteFontTypeface::Create(aFactory, aFontFace, aStyle, aForceGDI, aGamma, aContrast);
|
||||
return DWriteFontTypeface::Create(aFactory, aFontFace, aStyle, aForceGDI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -251,6 +251,10 @@ SkScalerContext* DWriteFontTypeface::onCreateScalerContext(const SkScalerContext
|
|||
return new SkScalerContext_DW(sk_ref_sp(const_cast<DWriteFontTypeface*>(this)), effects, desc);
|
||||
}
|
||||
|
||||
#ifdef MOZ_SKIA
|
||||
IDWriteRenderingParams* GetDwriteRenderingParams(bool aGDI);
|
||||
#endif
|
||||
|
||||
void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
|
||||
if (rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) {
|
||||
rec->fMaskFormat = SkMask::kA8_Format;
|
||||
|
@ -284,11 +288,13 @@ void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
|
|||
}
|
||||
}
|
||||
#elif defined(MOZ_SKIA)
|
||||
rec->setContrast(fContrast);
|
||||
IDWriteRenderingParams* params = GetDwriteRenderingParams(ForceGDI());
|
||||
SkASSERT(params);
|
||||
rec->setContrast(params->GetEnhancedContrast());
|
||||
|
||||
// GDI gamma should be 2.3
|
||||
// See the LUT gamma values comment for GDI fonts.
|
||||
float gamma = ForceGDI() ? 2.3f : fGamma;
|
||||
float gamma = ForceGDI() ? 2.3f : params->GetGamma();
|
||||
rec->setDeviceGamma(gamma);
|
||||
rec->setPaintGamma(gamma);
|
||||
#endif
|
||||
|
|
|
@ -53,8 +53,6 @@ private:
|
|||
, fDWriteFont(SkSafeRefComPtr(font))
|
||||
, fDWriteFontFace(SkRefComPtr(fontFace))
|
||||
, fForceGDI(false)
|
||||
, fGamma(2.2f)
|
||||
, fContrast(1.0f)
|
||||
{
|
||||
if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
|
||||
// IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
|
||||
|
@ -83,16 +81,12 @@ public:
|
|||
static DWriteFontTypeface* Create(IDWriteFactory* factory,
|
||||
IDWriteFontFace* fontFace,
|
||||
SkFontStyle aStyle,
|
||||
bool aForceGDI,
|
||||
float aGamma,
|
||||
float aContrast) {
|
||||
bool aForceGDI) {
|
||||
DWriteFontTypeface* typeface =
|
||||
new DWriteFontTypeface(aStyle, factory, fontFace,
|
||||
nullptr, nullptr,
|
||||
nullptr, nullptr);
|
||||
typeface->fForceGDI = aForceGDI;
|
||||
typeface->fGamma = aGamma;
|
||||
typeface->fContrast = aContrast;
|
||||
return typeface;
|
||||
}
|
||||
|
||||
|
@ -145,8 +139,6 @@ protected:
|
|||
private:
|
||||
typedef SkTypeface INHERITED;
|
||||
bool fForceGDI;
|
||||
float fGamma;
|
||||
float fContrast;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -158,7 +158,7 @@ gfxDWriteFontFileLoader::CreateCustomFontFile(FallibleTArray<uint8_t>& aFontData
|
|||
MOZ_ASSERT(aFontFile);
|
||||
MOZ_ASSERT(aFontFileStream);
|
||||
|
||||
IDWriteFactory *factory = mozilla::gfx::Factory::GetDWriteFactory();
|
||||
IDWriteFactory *factory = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory();
|
||||
if (!factory) {
|
||||
gfxCriticalError() << "Failed to get DWrite Factory in CreateCustomFontFile.";
|
||||
return E_FAIL;
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
{
|
||||
if (!mInstance) {
|
||||
mInstance = new gfxDWriteFontFileLoader();
|
||||
mozilla::gfx::Factory::GetDWriteFactory()->
|
||||
gfxWindowsPlatform::GetPlatform()->GetDWriteFactory()->
|
||||
RegisterFontFileLoader(mInstance);
|
||||
}
|
||||
return mInstance;
|
||||
|
|
|
@ -613,7 +613,7 @@ gfxDWriteFontEntry::CreateFontFace(IDWriteFontFace **aFontFace,
|
|||
hr = mFont->CreateFontFace(getter_AddRefs(mFontFace));
|
||||
} else if (mFontFile) {
|
||||
IDWriteFontFile *fontFile = mFontFile.get();
|
||||
hr = Factory::GetDWriteFactory()->
|
||||
hr = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory()->
|
||||
CreateFontFace(mFaceType,
|
||||
1,
|
||||
&fontFile,
|
||||
|
@ -644,7 +644,7 @@ gfxDWriteFontEntry::CreateFontFace(IDWriteFontFace **aFontFace,
|
|||
if (FAILED(mFontFace->GetFiles(&numberOfFiles, files.Elements()))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
HRESULT hr = Factory::GetDWriteFactory()->
|
||||
HRESULT hr = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory()->
|
||||
CreateFontFace(mFontFace->GetType(),
|
||||
numberOfFiles,
|
||||
files.Elements(),
|
||||
|
@ -883,7 +883,7 @@ gfxDWriteFontList::InitFontListForPlatform()
|
|||
mFontSubstitutes.Clear();
|
||||
mNonExistingFonts.Clear();
|
||||
|
||||
hr = Factory::GetDWriteFactory()->
|
||||
hr = gfxWindowsPlatform::GetPlatform()->GetDWriteFactory()->
|
||||
GetGdiInterop(getter_AddRefs(mGDIInterop));
|
||||
if (FAILED(hr)) {
|
||||
Telemetry::Accumulate(Telemetry::DWRITEFONT_INIT_PROBLEM,
|
||||
|
@ -894,7 +894,7 @@ gfxDWriteFontList::InitFontListForPlatform()
|
|||
QueryPerformanceCounter(&t2); // base-class/interop initialization
|
||||
|
||||
RefPtr<IDWriteFactory> factory =
|
||||
Factory::GetDWriteFactory();
|
||||
gfxWindowsPlatform::GetPlatform()->GetDWriteFactory();
|
||||
|
||||
hr = factory->GetSystemFontCollection(getter_AddRefs(mSystemFonts));
|
||||
NS_ASSERTION(SUCCEEDED(hr), "GetSystemFontCollection failed!");
|
||||
|
@ -1425,7 +1425,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh,
|
|||
HRESULT hr;
|
||||
|
||||
RefPtr<IDWriteFactory> dwFactory =
|
||||
Factory::GetDWriteFactory();
|
||||
gfxWindowsPlatform::GetPlatform()->GetDWriteFactory();
|
||||
if (!dwFactory) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -599,6 +599,19 @@ gfxDWriteFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
|
|||
return width;
|
||||
}
|
||||
|
||||
already_AddRefed<GlyphRenderingOptions>
|
||||
gfxDWriteFont::GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams)
|
||||
{
|
||||
if (mUseClearType) {
|
||||
return Factory::CreateDWriteGlyphRenderingOptions(
|
||||
gfxWindowsPlatform::GetPlatform()->GetRenderingParams(GetForceGDIClassic() ?
|
||||
gfxWindowsPlatform::TEXT_RENDERING_GDI_CLASSIC : gfxWindowsPlatform::TEXT_RENDERING_NORMAL));
|
||||
} else {
|
||||
return Factory::CreateDWriteGlyphRenderingOptions(gfxWindowsPlatform::GetPlatform()->
|
||||
GetRenderingParams(gfxWindowsPlatform::TEXT_RENDERING_NO_CLEARTYPE));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
gfxDWriteFont::GetForceGDIClassic()
|
||||
{
|
||||
|
@ -694,17 +707,10 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
|||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
GetCairoScaledFont());
|
||||
} else {
|
||||
} else if (aTarget->GetBackendType() == BackendType::SKIA) {
|
||||
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 =
|
||||
|
@ -712,10 +718,11 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
|
|||
GetUnscaledFont(),
|
||||
GetAdjustedSize(),
|
||||
useEmbeddedBitmap,
|
||||
forceGDI,
|
||||
params,
|
||||
params->GetGamma(),
|
||||
params->GetEnhancedContrast());
|
||||
GetForceGDIClassic());
|
||||
} else {
|
||||
mAzureScaledFont = Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
GetUnscaledFont(),
|
||||
GetAdjustedSize());
|
||||
}
|
||||
|
||||
mAzureScaledFontIsCairo = wantCairo;
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget,
|
||||
uint16_t aGID) override;
|
||||
|
||||
virtual already_AddRefed<mozilla::gfx::GlyphRenderingOptions>
|
||||
GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) override;
|
||||
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const override;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
|
|
|
@ -80,6 +80,14 @@ using namespace mozilla::layers;
|
|||
using namespace mozilla::widget;
|
||||
using namespace mozilla::image;
|
||||
|
||||
IDWriteRenderingParams* GetDwriteRenderingParams(bool aGDI)
|
||||
{
|
||||
gfxWindowsPlatform::TextRenderingMode mode = aGDI ?
|
||||
gfxWindowsPlatform::TEXT_RENDERING_GDI_CLASSIC :
|
||||
gfxWindowsPlatform::TEXT_RENDERING_NORMAL;
|
||||
return gfxWindowsPlatform::GetPlatform()->GetRenderingParams(mode);
|
||||
}
|
||||
|
||||
DCFromDrawTarget::DCFromDrawTarget(DrawTarget& aDrawTarget)
|
||||
{
|
||||
mDC = nullptr;
|
||||
|
@ -355,7 +363,7 @@ gfxWindowsPlatform::InitAcceleration()
|
|||
UpdateRenderMode();
|
||||
|
||||
// If we have Skia and we didn't init dwrite already, do it now.
|
||||
if (!DWriteAvailable() && GetDefaultContentBackend() == BackendType::SKIA) {
|
||||
if (!mDWriteFactory && GetDefaultContentBackend() == BackendType::SKIA) {
|
||||
InitDWriteSupport();
|
||||
}
|
||||
|
||||
|
@ -381,10 +389,26 @@ bool
|
|||
gfxWindowsPlatform::InitDWriteSupport()
|
||||
{
|
||||
mozilla::ScopedGfxFeatureReporter reporter("DWrite");
|
||||
if (!Factory::EnsureDWriteFactory()) {
|
||||
decltype(DWriteCreateFactory)* createDWriteFactory = (decltype(DWriteCreateFactory)*)
|
||||
GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory");
|
||||
if (!createDWriteFactory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// I need a direct pointer to be able to cast to IUnknown**, I also need to
|
||||
// remember to release this because the nsRefPtr will AddRef it.
|
||||
RefPtr<IDWriteFactory> factory;
|
||||
HRESULT hr = createDWriteFactory(
|
||||
DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory),
|
||||
(IUnknown **)((IDWriteFactory **)getter_AddRefs(factory)));
|
||||
if (FAILED(hr) || !factory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mDWriteFactory = factory;
|
||||
Factory::SetDWriteFactory(mDWriteFactory);
|
||||
|
||||
SetupClearTypeParams();
|
||||
reporter.SetSuccessful();
|
||||
return true;
|
||||
|
@ -491,7 +515,7 @@ gfxWindowsPlatform::CreatePlatformFontList()
|
|||
|
||||
// bug 630201 - older pre-RTM versions of Direct2D/DirectWrite cause odd
|
||||
// crashers so blacklist them altogether
|
||||
if (IsNotWin7PreRTM() && DWriteAvailable()) {
|
||||
if (IsNotWin7PreRTM() && GetDWriteFactory()) {
|
||||
pfl = new gfxDWriteFontList();
|
||||
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
||||
return pfl;
|
||||
|
@ -555,7 +579,22 @@ already_AddRefed<ScaledFont>
|
|||
gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
if (aFont->GetType() == gfxFont::FONT_TYPE_DWRITE) {
|
||||
return aFont->GetScaledFont(aTarget);
|
||||
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->GetUnscaledFont(),
|
||||
font->GetAdjustedSize(),
|
||||
font->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont,
|
||||
font->GetUnscaledFont(),
|
||||
font->GetAdjustedSize());
|
||||
}
|
||||
|
||||
NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_GDI,
|
||||
|
@ -1103,7 +1142,7 @@ gfxWindowsPlatform::FontsPrefsChanged(const char *aPref)
|
|||
void
|
||||
gfxWindowsPlatform::SetupClearTypeParams()
|
||||
{
|
||||
if (DWriteAvailable()) {
|
||||
if (GetDWriteFactory()) {
|
||||
// any missing prefs will default to invalid (-1) and be ignored;
|
||||
// out-of-range values will also be ignored
|
||||
FLOAT gamma = -1.0;
|
||||
|
@ -1158,7 +1197,7 @@ gfxWindowsPlatform::SetupClearTypeParams()
|
|||
}
|
||||
|
||||
RefPtr<IDWriteRenderingParams> defaultRenderingParams;
|
||||
Factory::GetDWriteFactory()->CreateRenderingParams(getter_AddRefs(defaultRenderingParams));
|
||||
GetDWriteFactory()->CreateRenderingParams(getter_AddRefs(defaultRenderingParams));
|
||||
// For EnhancedContrast, we override the default if the user has not set it
|
||||
// in the registry (by using the ClearType Tuner).
|
||||
if (contrast < 0.0 || contrast > 10.0) {
|
||||
|
@ -1214,14 +1253,14 @@ gfxWindowsPlatform::SetupClearTypeParams()
|
|||
|
||||
mRenderingParams[TEXT_RENDERING_NO_CLEARTYPE] = defaultRenderingParams;
|
||||
|
||||
HRESULT hr = Factory::GetDWriteFactory()->CreateCustomRenderingParams(
|
||||
HRESULT hr = GetDWriteFactory()->CreateCustomRenderingParams(
|
||||
gamma, contrast, level, dwriteGeometry, renderMode,
|
||||
getter_AddRefs(mRenderingParams[TEXT_RENDERING_NORMAL]));
|
||||
if (FAILED(hr) || !mRenderingParams[TEXT_RENDERING_NORMAL]) {
|
||||
mRenderingParams[TEXT_RENDERING_NORMAL] = defaultRenderingParams;
|
||||
}
|
||||
|
||||
hr = Factory::GetDWriteFactory()->CreateCustomRenderingParams(
|
||||
hr = GetDWriteFactory()->CreateCustomRenderingParams(
|
||||
gamma, contrast, level,
|
||||
dwriteGeometry, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
|
||||
getter_AddRefs(mRenderingParams[TEXT_RENDERING_GDI_CLASSIC]));
|
||||
|
@ -1526,7 +1565,7 @@ gfxWindowsPlatform::InitializeD2D()
|
|||
}
|
||||
|
||||
// Using Direct2D depends on DWrite support.
|
||||
if (!DWriteAvailable() && !InitDWriteSupport()) {
|
||||
if (!mDWriteFactory && !InitDWriteSupport()) {
|
||||
d2d1.SetFailed(FeatureStatus::Failed, "Failed to initialize DirectWrite support",
|
||||
NS_LITERAL_CSTRING("FEATURE_FAILURE_D2D_DWRITE"));
|
||||
return;
|
||||
|
|
|
@ -192,7 +192,8 @@ public:
|
|||
|
||||
void SetupClearTypeParams();
|
||||
|
||||
inline bool DWriteAvailable() const { return !!mozilla::gfx::Factory::GetDWriteFactory(); }
|
||||
IDWriteFactory *GetDWriteFactory() { return mDWriteFactory; }
|
||||
inline bool DWriteEnabled() { return !!mDWriteFactory; }
|
||||
inline DWRITE_MEASURING_MODE DWriteMeasuringMode() { return mMeasuringMode; }
|
||||
|
||||
IDWriteRenderingParams *GetRenderingParams(TextRenderingMode aRenderMode)
|
||||
|
@ -258,6 +259,7 @@ private:
|
|||
void InitializeD2DConfig();
|
||||
void InitializeDirectDrawConfig();
|
||||
|
||||
RefPtr<IDWriteFactory> mDWriteFactory;
|
||||
RefPtr<IDWriteRenderingParams> mRenderingParams[TEXT_RENDERING_COUNT];
|
||||
DWRITE_MEASURING_MODE mMeasuringMode;
|
||||
|
||||
|
|
|
@ -83,5 +83,20 @@ PrintTranslator::CreateDrawTarget(ReferencePtr aRefPtr,
|
|||
return drawTarget.forget();
|
||||
}
|
||||
|
||||
FontType
|
||||
PrintTranslator::GetDesiredFontType()
|
||||
{
|
||||
switch (mBaseDT->GetBackendType()) {
|
||||
case BackendType::DIRECT2D:
|
||||
return FontType::DWRITE;
|
||||
case BackendType::CAIRO:
|
||||
return FontType::CAIRO;
|
||||
case BackendType::SKIA:
|
||||
return FontType::SKIA;
|
||||
default:
|
||||
return FontType::CAIRO;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layout
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -175,6 +175,8 @@ public:
|
|||
|
||||
mozilla::gfx::DrawTarget* GetReferenceDrawTarget() final { return mBaseDT; }
|
||||
|
||||
mozilla::gfx::FontType GetDesiredFontType() final;
|
||||
|
||||
private:
|
||||
RefPtr<nsDeviceContext> mDeviceContext;
|
||||
RefPtr<DrawTarget> mBaseDT;
|
||||
|
|
Загрузка…
Ссылка в новой задаче