Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / gfxFT2Fonts.h
blobf0e390c5a60cc350b49014b5cf8a000de71ee3af
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_FT2FONTS_H
7 #define GFX_FT2FONTS_H
9 #include "mozilla/MemoryReporting.h"
10 #include "cairo.h"
11 #include "gfxTypes.h"
12 #include "gfxFont.h"
13 #include "gfxFT2FontBase.h"
14 #include "gfxContext.h"
15 #include "gfxFontUtils.h"
16 #include "gfxUserFontSet.h"
18 class FT2FontEntry;
20 class gfxFT2Font : public gfxFT2FontBase {
21 public: // new functions
22 gfxFT2Font(cairo_scaled_font_t *aCairoFont,
23 FT2FontEntry *aFontEntry,
24 const gfxFontStyle *aFontStyle,
25 bool aNeedsBold);
26 virtual ~gfxFT2Font ();
28 FT2FontEntry *GetFontEntry();
30 static already_AddRefed<gfxFT2Font>
31 GetOrMakeFont(const nsAString& aName, const gfxFontStyle *aStyle,
32 bool aNeedsBold = false);
34 static already_AddRefed<gfxFT2Font>
35 GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle,
36 bool aNeedsBold = false);
38 struct CachedGlyphData {
39 CachedGlyphData()
40 : glyphIndex(0xffffffffU) { }
42 CachedGlyphData(uint32_t gid)
43 : glyphIndex(gid) { }
45 uint32_t glyphIndex;
46 int32_t lsbDelta;
47 int32_t rsbDelta;
48 int32_t xAdvance;
51 const CachedGlyphData* GetGlyphDataForChar(uint32_t ch) {
52 CharGlyphMapEntryType *entry = mCharGlyphCache.PutEntry(ch);
54 if (!entry)
55 return nullptr;
57 if (entry->mData.glyphIndex == 0xffffffffU) {
58 // this is a new entry, fill it
59 FillGlyphDataForChar(ch, &entry->mData);
62 return &entry->mData;
65 virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
66 FontCacheSizes* aSizes) const;
67 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
68 FontCacheSizes* aSizes) const;
70 #ifdef USE_SKIA
71 virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
72 #endif
74 protected:
75 virtual bool ShapeText(gfxContext *aContext,
76 const char16_t *aText,
77 uint32_t aOffset,
78 uint32_t aLength,
79 int32_t aScript,
80 gfxShapedText *aShapedText);
82 void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd);
84 void AddRange(const char16_t *aText,
85 uint32_t aOffset,
86 uint32_t aLength,
87 gfxShapedText *aShapedText);
89 typedef nsBaseHashtableET<nsUint32HashKey, CachedGlyphData> CharGlyphMapEntryType;
90 typedef nsTHashtable<CharGlyphMapEntryType> CharGlyphMap;
91 CharGlyphMap mCharGlyphCache;
94 #endif /* GFX_FT2FONTS_H */