Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.h

Issue 1733193002: Move glyph lookup to hb-ot-font and remove glyph cache in HarfBuzzFace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated memory management, no more ref'ing, OwnPtr in HarfBuzzFace Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
39 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
40 #include "wtf/text/CharacterNames.h" 40 #include "wtf/text/CharacterNames.h"
41 41
42 #include <hb.h> 42 #include <hb.h>
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class FontPlatformData; 46 class FontPlatformData;
47 struct HarfBuzzFontData;
47 48
48 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { 49 class HarfBuzzFace : public RefCounted<HarfBuzzFace> {
49 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); 50 WTF_MAKE_NONCOPYABLE(HarfBuzzFace);
50 public: 51 public:
51 static const hb_tag_t vertTag;
52 static const hb_tag_t vrt2Tag;
53 52
54 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6 4_t uniqueID) 53 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6 4_t uniqueID)
55 { 54 {
56 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); 55 return adoptRef(new HarfBuzzFace(platformData, uniqueID));
57 } 56 }
58 ~HarfBuzzFace(); 57 ~HarfBuzzFace();
59 58
60 // In order to support the restricting effect of unicode-range optionally a 59 // 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 60 // range restriction can be passed in, which will restrict which glyphs we
62 // return in the harfBuzzGetGlyph function. 61 // return in the harfBuzzGetGlyph function.
63 hb_font_t* createFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCodepoi nt) const; 62 hb_font_t* getScaledFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCode point);
64 hb_face_t* face() const { return m_face; } 63 hb_face_t* face() const { return m_face; }
65 64
66 private: 65 private:
67 HarfBuzzFace(FontPlatformData*, uint64_t); 66 HarfBuzzFace(FontPlatformData*, uint64_t);
68 67
69 hb_face_t* createFace(); 68 hb_face_t* createFace();
69 void prepareHarfBuzzFontData();
70 70
71 FontPlatformData* m_platformData; 71 FontPlatformData* m_platformData;
72 uint64_t m_uniqueID; 72 uint64_t m_uniqueID;
73 hb_face_t* m_face; 73 hb_face_t* m_face;
74 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; 74 OwnPtr<hb_font_t> m_unscaledFont;
75 OwnPtr<HarfBuzzFontData> m_harfBuzzFontData;
75 }; 76 };
76 77
77 } // namespace blink 78 } // namespace blink
78 79
79 namespace WTF { 80 namespace WTF {
80 81
81 template<typename T> struct OwnedPtrDeleter; 82 template<typename T> struct OwnedPtrDeleter;
82 template<> struct OwnedPtrDeleter<hb_font_t> { 83 template<> struct OwnedPtrDeleter<hb_font_t> {
83 STATIC_ONLY(OwnedPtrDeleter); 84 STATIC_ONLY(OwnedPtrDeleter);
84 static void deletePtr(hb_font_t* font) 85 static void deletePtr(hb_font_t* font)
85 { 86 {
86 if (font) 87 if (font)
87 hb_font_destroy(font); 88 hb_font_destroy(font);
88 } 89 }
89 }; 90 };
90 91
91 } // namespace WTF 92 } // namespace WTF
92 93
93 #endif // HarfBuzzFace_h 94 #endif // HarfBuzzFace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698