From 4af61863f3da2e6f8951854e4343e6898e1e86f8 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Wed, 5 Apr 2023 18:40:25 +0800 Subject: Issue #2191 - Get rid of gfxFontconfigUtils.h since gfxFontconfigFontBase is unnecessary. Backported from Mozilla bug 1385029. --- gfx/thebes/gfxFcPlatformFontList.cpp | 19 +++++++++++-- gfx/thebes/gfxFcPlatformFontList.h | 17 +++++++---- gfx/thebes/gfxFontconfigUtils.h | 55 ------------------------------------ gfx/thebes/gfxPlatformGtk.cpp | 1 - gfx/thebes/gfxPlatformGtk.h | 4 --- 5 files changed, 28 insertions(+), 68 deletions(-) delete mode 100644 gfx/thebes/gfxFontconfigUtils.h (limited to 'gfx') diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 75e8fb76a0..4f5966d948 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -55,6 +55,20 @@ using namespace mozilla::unicode; gfxPlatform::GetLog(eGfxLog_cmapdata), \ LogLevel::Debug) +template <> +class nsAutoRefTraits : public nsPointerRefTraits +{ +public: + static void Release(FcFontSet *ptr) { FcFontSetDestroy(ptr); } +}; + +template <> +class nsAutoRefTraits : public nsPointerRefTraits +{ +public: + static void Release(FcObjectSet *ptr) { FcObjectSetDestroy(ptr); } +}; + static const FcChar8* ToFcChar8Ptr(const char* aStr) { @@ -1078,8 +1092,9 @@ gfxFontconfigFont::gfxFontconfigFont(cairo_scaled_font_t *aScaledFont, gfxFloat aAdjustedSize, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, - bool aNeedsBold) : - gfxFontconfigFontBase(aScaledFont, aPattern, aFontEntry, aFontStyle) + bool aNeedsBold) + : gfxFT2FontBase(aScaledFont, aFontEntry, aFontStyle) + , mPattern(aPattern) { mAdjustedSize = aAdjustedSize; } diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index aa8f614a90..dcad65c863 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -11,6 +11,7 @@ #include "gfxFT2FontBase.h" #include "gfxPlatformFontList.h" #include "mozilla/mozalloc.h" +#include "nsAutoRef.h" #include "nsClassHashtable.h" #include @@ -20,13 +21,12 @@ #include #include -#include "gfxFontconfigUtils.h" // xxx - only for nsAutoRefTraits, etc. - template <> -class nsAutoRefTraits : public nsPointerRefTraits +class nsAutoRefTraits : public nsPointerRefTraits { public: - static void Release(FcObjectSet *ptr) { FcObjectSetDestroy(ptr); } + static void Release(FcPattern *ptr) { FcPatternDestroy(ptr); } + static void AddRef(FcPattern *ptr) { FcPatternReference(ptr); } }; template <> @@ -205,7 +205,7 @@ protected: bool mForceScalable; }; -class gfxFontconfigFont : public gfxFontconfigFontBase { +class gfxFontconfigFont : public gfxFT2FontBase { public: gfxFontconfigFont(cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, @@ -214,8 +214,13 @@ public: const gfxFontStyle *aFontStyle, bool aNeedsBold); -protected: + virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; } + virtual FcPattern *GetPattern() const { return mPattern; } + +private: virtual ~gfxFontconfigFont(); + + nsCountedRef mPattern; }; class nsILanguageAtomService; diff --git a/gfx/thebes/gfxFontconfigUtils.h b/gfx/thebes/gfxFontconfigUtils.h deleted file mode 100644 index 3f502c1243..0000000000 --- a/gfx/thebes/gfxFontconfigUtils.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -#ifndef GFX_FONTCONFIG_UTILS_H -#define GFX_FONTCONFIG_UTILS_H - -#include "gfxPlatform.h" - -#include "nsAutoRef.h" -#include "gfxFT2FontBase.h" - -#include - - -template <> -class nsAutoRefTraits : public nsPointerRefTraits -{ -public: - static void Release(FcPattern *ptr) { FcPatternDestroy(ptr); } - static void AddRef(FcPattern *ptr) { FcPatternReference(ptr); } -}; - -template <> -class nsAutoRefTraits : public nsPointerRefTraits -{ -public: - static void Release(FcFontSet *ptr) { FcFontSetDestroy(ptr); } -}; - -template <> -class nsAutoRefTraits : public nsPointerRefTraits -{ -public: - static void Release(FcCharSet *ptr) { FcCharSetDestroy(ptr); } -}; - -class gfxFontconfigFontBase : public gfxFT2FontBase { -public: - gfxFontconfigFontBase(cairo_scaled_font_t *aScaledFont, - FcPattern *aPattern, - gfxFontEntry *aFontEntry, - const gfxFontStyle *aFontStyle) - : gfxFT2FontBase(aScaledFont, aFontEntry, aFontStyle) - , mPattern(aPattern) { } - - virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; } - virtual FcPattern *GetPattern() const { return mPattern; } - -private: - nsCountedRef mPattern; -}; - -#endif /* GFX_FONTCONFIG_UTILS_H */ diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index d8bafac918..476d250273 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -13,7 +13,6 @@ #include "nsUnicodeProperties.h" #include "gfx2DGlue.h" #include "gfxFcPlatformFontList.h" -#include "gfxFontconfigUtils.h" #include "gfxConfig.h" #include "gfxContext.h" #include "gfxUserFontSet.h" diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index cfaca45074..585eeab0ac 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -22,8 +22,6 @@ struct _XDisplay; typedef struct _XDisplay Display; #endif // MOZ_X11 -class gfxFontconfigUtils; - class gfxPlatformGtk : public gfxPlatform { public: gfxPlatformGtk(); @@ -141,8 +139,6 @@ public: #endif // MOZ_X11 protected: - static gfxFontconfigUtils *sFontconfigUtils; - int8_t mMaxGenericSubstitutions; private: -- cgit v1.2.3