зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1309205 - part 1 - allow querying FT_Library from gfxPlatform so that Moz2d Factory can use it. r=jfkthame
MozReview-Commit-ID: 7kxseOOVvWi
This commit is contained in:
Родитель
2877f826cb
Коммит
d5f91aa244
12
gfx/2d/2D.h
12
gfx/2d/2D.h
|
@ -42,6 +42,9 @@ typedef _cairo_scaled_font cairo_scaled_font_t;
|
|||
struct _FcPattern;
|
||||
typedef _FcPattern FcPattern;
|
||||
|
||||
struct FT_LibraryRec_;
|
||||
typedef FT_LibraryRec_* FT_Library;
|
||||
|
||||
struct ID3D11Texture2D;
|
||||
struct ID3D11Device;
|
||||
struct ID2D1Device;
|
||||
|
@ -1494,6 +1497,15 @@ public:
|
|||
CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
static void SetFTLibrary(FT_Library aFTLibrary);
|
||||
static FT_Library GetFTLibrary();
|
||||
|
||||
private:
|
||||
static FT_Library mFTLibrary;
|
||||
public:
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
static already_AddRefed<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
|
||||
|
||||
|
|
|
@ -156,6 +156,10 @@ namespace gfx {
|
|||
// In Gecko, this value is managed by gfx.logging.level in gfxPrefs.
|
||||
int32_t LoggingPrefs::sGfxLogLevel = LOG_DEFAULT;
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
FT_Library Factory::mFTLibrary = nullptr;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
ID3D11Device *Factory::mD3D11Device = nullptr;
|
||||
ID2D1Device *Factory::mD2D1Device = nullptr;
|
||||
|
@ -192,6 +196,12 @@ Factory::ShutDown()
|
|||
delete sConfig;
|
||||
sConfig = nullptr;
|
||||
}
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
if (mFTLibrary) {
|
||||
mFTLibrary = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -569,6 +579,21 @@ Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB)
|
|||
}
|
||||
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
void
|
||||
Factory::SetFTLibrary(FT_Library aFTLibrary)
|
||||
{
|
||||
mFTLibrary = aFTLibrary;
|
||||
}
|
||||
|
||||
FT_Library
|
||||
Factory::GetFTLibrary()
|
||||
{
|
||||
MOZ_ASSERT(mFTLibrary);
|
||||
return mFTLibrary;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
already_AddRefed<DrawTarget>
|
||||
Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat)
|
||||
|
|
|
@ -19,8 +19,6 @@ namespace mozilla {
|
|||
};
|
||||
using mozilla::dom::FontListEntry;
|
||||
|
||||
typedef struct FT_LibraryRec_ *FT_Library;
|
||||
|
||||
class gfxAndroidPlatform : public gfxPlatform {
|
||||
public:
|
||||
gfxAndroidPlatform();
|
||||
|
@ -60,7 +58,7 @@ public:
|
|||
virtual bool FontHintingEnabled() override;
|
||||
virtual bool RequiresLinearZoom() override;
|
||||
|
||||
FT_Library GetFTLibrary();
|
||||
FT_Library GetFTLibrary() override;
|
||||
|
||||
virtual bool CanRenderContentToDataSurface() const override {
|
||||
return true;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "nsIInputStream.h"
|
||||
#define gfxToolkitPlatform gfxAndroidPlatform
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
#include <dirent.h>
|
||||
|
@ -85,7 +84,8 @@ public:
|
|||
|
||||
NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(),
|
||||
"can't use AutoFTFace for fonts without a filename");
|
||||
FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary();
|
||||
FT_Library ft = gfxPlatform::GetPlatform()->GetFTLibrary();
|
||||
MOZ_ASSERT(ft);
|
||||
|
||||
// A relative path (no initial "/") means this is a resource in
|
||||
// omnijar, not an installed font on the device.
|
||||
|
@ -256,7 +256,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
|
|||
// eventually deleted.
|
||||
FT_Face face;
|
||||
FT_Error error =
|
||||
FT_New_Memory_Face(gfxToolkitPlatform::GetPlatform()->GetFTLibrary(),
|
||||
FT_New_Memory_Face(gfxPlatform::GetPlatform()->GetFTLibrary(),
|
||||
aFontData, aLength, 0, &face);
|
||||
if (error != FT_Err_Ok) {
|
||||
free((void*)aFontData);
|
||||
|
@ -974,7 +974,7 @@ gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName,
|
|||
return;
|
||||
}
|
||||
|
||||
FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary();
|
||||
FT_Library ftLibrary = gfxPlatform::GetPlatform()->GetFTLibrary();
|
||||
FT_Face dummy;
|
||||
if (FT_Err_Ok == FT_New_Face(ftLibrary, aFileName.get(), -1, &dummy)) {
|
||||
LOG(("reading font info via FreeType for %s", aFileName.get()));
|
||||
|
@ -1126,7 +1126,7 @@ gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive,
|
|||
return;
|
||||
}
|
||||
|
||||
FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary();
|
||||
FT_Library ftLibrary = gfxPlatform::GetPlatform()->GetFTLibrary();
|
||||
|
||||
FT_Face dummy;
|
||||
if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf.get(), bufSize, 0, &dummy)) {
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
const uint8_t* aFontData,
|
||||
uint32_t aLength);
|
||||
|
||||
static FT_Library GetFTLibrary();
|
||||
|
||||
private:
|
||||
|
||||
virtual gfxFont *GetFontAt(int32_t i, uint32_t aCh = 0x20);
|
||||
|
@ -116,9 +118,6 @@ private:
|
|||
nsIAtom *aLanguage,
|
||||
nsTArray<nsString>& aGenericFamilies);
|
||||
|
||||
|
||||
friend class gfxSystemFcFontEntry;
|
||||
static FT_Library GetFTLibrary();
|
||||
};
|
||||
|
||||
#endif /* GFX_FONTCONFIG_FONTS_H */
|
||||
|
|
|
@ -743,6 +743,10 @@ gfxPlatform::Init()
|
|||
MOZ_CRASH("Could not initialize gfxFontCache");
|
||||
}
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
Factory::SetFTLibrary(gPlatform->GetFTLibrary());
|
||||
#endif
|
||||
|
||||
/* Create and register our CMS Override observer. */
|
||||
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
|
||||
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver, GFX_PREF_CMS_FORCE_SRGB);
|
||||
|
|
|
@ -39,6 +39,7 @@ class nsIAtom;
|
|||
class nsIObserver;
|
||||
class SRGBOverrideObserver;
|
||||
class gfxTextPerfMetrics;
|
||||
typedef struct FT_LibraryRec_ *FT_Library;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
@ -699,6 +700,10 @@ public:
|
|||
*/
|
||||
virtual void ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData);
|
||||
|
||||
virtual FT_Library GetFTLibrary() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
gfxPlatform();
|
||||
virtual ~gfxPlatform();
|
||||
|
|
|
@ -348,6 +348,16 @@ gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName,
|
|||
aFontData, aLength);
|
||||
}
|
||||
|
||||
FT_Library
|
||||
gfxPlatformGtk::GetFTLibrary()
|
||||
{
|
||||
if (sUseFcFontList) {
|
||||
return gfxFcPlatformFontList::GetFTLibrary();
|
||||
}
|
||||
|
||||
return gfxPangoFontGroup::GetFTLibrary();
|
||||
}
|
||||
|
||||
bool
|
||||
gfxPlatformGtk::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
||||
{
|
||||
|
|
|
@ -95,6 +95,8 @@ public:
|
|||
*/
|
||||
virtual void FlushContentDrawing() override;
|
||||
|
||||
FT_Library GetFTLibrary() override;
|
||||
|
||||
#if (MOZ_WIDGET_GTK == 2)
|
||||
static void SetGdkDrawable(cairo_surface_t *target,
|
||||
GdkDrawable *drawable);
|
||||
|
|
Загрузка…
Ссылка в новой задаче