| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
| 40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 41 #include "wtf/text/CharacterNames.h" | 41 #include "wtf/text/CharacterNames.h" |
| 42 | 42 |
| 43 #include <hb.h> | 43 #include <hb.h> |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 class FontPlatformData; | 47 class FontPlatformData; |
| 48 struct HarfBuzzFontData; | |
| 49 | 48 |
| 50 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { | 49 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { |
| 51 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); | 50 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); |
| 52 public: | 51 public: |
| 52 static const hb_tag_t vertTag; |
| 53 static const hb_tag_t vrt2Tag; |
| 53 | 54 |
| 54 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) | 55 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6
4_t uniqueID) |
| 55 { | 56 { |
| 56 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); | 57 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); |
| 57 } | 58 } |
| 58 ~HarfBuzzFace(); | 59 ~HarfBuzzFace(); |
| 59 | 60 |
| 60 // In order to support the restricting effect of unicode-range optionally a | 61 // In order to support the restricting effect of unicode-range optionally a |
| 61 // range restriction can be passed in, which will restrict which glyphs we | 62 // range restriction can be passed in, which will restrict which glyphs we |
| 62 // return in the harfBuzzGetGlyph function. | 63 // return in the harfBuzzGetGlyph function. |
| 63 hb_font_t* getScaledFont(PassRefPtr<UnicodeRangeSet> = nullptr); | 64 hb_font_t* createFont(PassRefPtr<UnicodeRangeSet> = nullptr) const; |
| 64 hb_face_t* face() const { return m_face; } | 65 hb_face_t* face() const { return m_face; } |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 HarfBuzzFace(FontPlatformData*, uint64_t); | 68 HarfBuzzFace(FontPlatformData*, uint64_t); |
| 68 | 69 |
| 69 hb_face_t* createFace(); | 70 hb_face_t* createFace(); |
| 70 void prepareHarfBuzzFontData(); | |
| 71 | 71 |
| 72 FontPlatformData* m_platformData; | 72 FontPlatformData* m_platformData; |
| 73 uint64_t m_uniqueID; | 73 uint64_t m_uniqueID; |
| 74 hb_face_t* m_face; | 74 hb_face_t* m_face; |
| 75 OwnPtr<hb_font_t> m_unscaledFont; | 75 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; |
| 76 OwnPtr<HarfBuzzFontData> m_harfBuzzFontData; | |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 } // namespace blink | 78 } // namespace blink |
| 80 | 79 |
| 81 namespace WTF { | 80 namespace WTF { |
| 82 | 81 |
| 83 template<typename T> struct OwnedPtrDeleter; | 82 template<typename T> struct OwnedPtrDeleter; |
| 84 template<> struct OwnedPtrDeleter<hb_font_t> { | 83 template<> struct OwnedPtrDeleter<hb_font_t> { |
| 85 STATIC_ONLY(OwnedPtrDeleter); | 84 STATIC_ONLY(OwnedPtrDeleter); |
| 86 static void deletePtr(hb_font_t* font) | 85 static void deletePtr(hb_font_t* font) |
| 87 { | 86 { |
| 88 if (font) | 87 if (font) |
| 89 hb_font_destroy(font); | 88 hb_font_destroy(font); |
| 90 } | 89 } |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace WTF | 92 } // namespace WTF |
| 94 | 93 |
| 95 #endif // HarfBuzzFace_h | 94 #endif // HarfBuzzFace_h |
| OLD | NEW |