Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / 2d / SFNTData.h
blob334438efc0495d56b1da5676d4691ed334129911
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_gfx_SFNTData_h
8 #define mozilla_gfx_SFNTData_h
10 #include "mozilla/UniquePtr.h"
11 #include "mozilla/Vector.h"
13 namespace mozilla {
14 namespace gfx {
16 class SFNTData final {
17 public:
18 /**
19 * Creates an SFNTData if the header is a format that we understand and
20 * aDataLength is sufficient for the length information in the header data.
21 * Note that the data is NOT copied, so must exist the SFNTData's lifetime.
23 * @param aFontData the SFNT data.
24 * @param aDataLength length
25 * @return UniquePtr to a SFNTData or nullptr if the header is invalid.
27 static UniquePtr<SFNTData> Create(const uint8_t* aFontData,
28 uint32_t aDataLength);
30 /**
31 * Creates a unique key for the given font data and variation settings.
33 * @param aFontData the SFNT data
34 * @param aDataLength length
35 * @return unique key to be used for caching
37 static uint64_t GetUniqueKey(const uint8_t* aFontData, uint32_t aDataLength,
38 uint32_t aVarDataSize, const void* aVarData);
40 ~SFNTData();
42 private:
43 SFNTData() = default;
45 bool AddFont(const uint8_t* aFontData, uint32_t aDataLength,
46 uint32_t aOffset);
48 uint32_t HashHeadAndCmapTables();
50 // Internal representation of single font in font file.
51 class Font;
53 Vector<Font*> mFonts;
56 } // namespace gfx
57 } // namespace mozilla
59 #endif // mozilla_gfx_SFNTData_h