Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / 2d / NativeFontResourceDWrite.h
blob0f3feccb185f7b9d7d30d19080791e3d7d913cdd
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_NativeFontResourceDWrite_h
8 #define mozilla_gfx_NativeFontResourceDWrite_h
10 #include <dwrite.h>
12 #include "2D.h"
13 #include "mozilla/AlreadyAddRefed.h"
15 namespace mozilla {
16 namespace gfx {
18 class NativeFontResourceDWrite final : public NativeFontResource {
19 public:
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceDWrite, override)
22 /**
23 * Creates a NativeFontResourceDWrite if data is valid. Note aFontData will be
24 * copied if required and so can be released after calling.
26 * @param aFontData the SFNT data.
27 * @param aDataLength length of data.
28 * @return Referenced NativeFontResourceDWrite or nullptr if invalid.
30 static already_AddRefed<NativeFontResourceDWrite> Create(
31 uint8_t* aFontData, uint32_t aDataLength);
33 already_AddRefed<UnscaledFont> CreateUnscaledFont(
34 uint32_t aIndex, const uint8_t* aInstanceData,
35 uint32_t aInstanceDataLength) final;
37 private:
38 NativeFontResourceDWrite(
39 IDWriteFactory* aFactory, already_AddRefed<IDWriteFontFile> aFontFile,
40 already_AddRefed<IDWriteFontFileStream> aFontFileStream,
41 DWRITE_FONT_FACE_TYPE aFaceType, uint32_t aNumberOfFaces,
42 size_t aDataLength)
43 : NativeFontResource(aDataLength),
44 mFactory(aFactory),
45 mFontFile(aFontFile),
46 mFontFileStream(aFontFileStream),
47 mFaceType(aFaceType),
48 mNumberOfFaces(aNumberOfFaces) {}
50 IDWriteFactory* mFactory;
51 RefPtr<IDWriteFontFile> mFontFile;
52 RefPtr<IDWriteFontFileStream> mFontFileStream;
53 DWRITE_FONT_FACE_TYPE mFaceType;
54 uint32_t mNumberOfFaces;
57 } // namespace gfx
58 } // namespace mozilla
60 #endif // mozilla_gfx_NativeFontResourceDWrite_h