Bug 1786281 - Expose AutoHBBlob as a public helper in gfxFontUtils. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D155208
This commit is contained in:
Jonathan Kew 2022-08-22 13:36:16 +00:00
parent 326adff110
commit 166dab3f9d
2 changed files with 14 additions and 15 deletions

View File

@ -25,8 +25,6 @@
#include "mozilla/ServoStyleSet.h"
#include "mozilla/dom/WorkerCommon.h"
#include "harfbuzz/hb.h"
#include "plbase64.h"
#include "mozilla/Logging.h"
@ -1604,19 +1602,6 @@ void gfxFontUtils::GetVariationData(
// AutoSwap_PRUint16 postScriptNameID;
};
// Helper to ensure we free a font table when we return.
class AutoHBBlob {
public:
explicit AutoHBBlob(hb_blob_t* aBlob) : mBlob(aBlob) {}
~AutoHBBlob() { hb_blob_destroy(mBlob); }
operator hb_blob_t*() { return mBlob; }
private:
hb_blob_t* const mBlob;
};
// Load the two font tables we need as harfbuzz blobs; if either is absent,
// just bail out.
AutoHBBlob fvarTable(

View File

@ -11,6 +11,7 @@
#include <new>
#include <utility>
#include "gfxPlatform.h"
#include "harfbuzz/hb.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/Casting.h"
@ -908,6 +909,19 @@ class gfxFontUtils {
// (in bytes).
};
// Helper to ensure we free a font table when we return.
class AutoHBBlob {
public:
explicit AutoHBBlob(hb_blob_t* aBlob) : mBlob(aBlob) {}
~AutoHBBlob() { hb_blob_destroy(mBlob); }
operator hb_blob_t*() { return mBlob; }
private:
hb_blob_t* const mBlob;
};
// for reading big-endian font data on either big or little-endian platforms
static inline uint16_t ReadShortAt(const uint8_t* aBuf, uint32_t aIndex) {