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

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: 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 25 matching lines...) Expand all
36 #include "wtf/Noncopyable.h" 36 #include "wtf/Noncopyable.h"
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 template<typename T>
47 class HarfBuzzScopedPtr {
48 STACK_ALLOCATED();
49 WTF_MAKE_NONCOPYABLE(HarfBuzzScopedPtr);
50 public:
51 typedef void (*DestroyFunction)(T*);
52
53 HarfBuzzScopedPtr(T* ptr, DestroyFunction destroy)
54 : m_ptr(ptr)
55 , m_destroy(destroy)
56 {
57 ASSERT(m_destroy);
58 }
59 ~HarfBuzzScopedPtr()
60 {
61 if (m_ptr)
62 (*m_destroy)(m_ptr);
63 }
64
65 T* get() { return m_ptr; }
66 void set(T* ptr) { m_ptr = ptr; }
67 private:
68 T* m_ptr;
69 DestroyFunction m_destroy;
70 };
71
46 class FontPlatformData; 72 class FontPlatformData;
73 struct HarfBuzzFontData;
47 74
48 class HarfBuzzFace : public RefCounted<HarfBuzzFace> { 75 class HarfBuzzFace : public RefCounted<HarfBuzzFace> {
49 WTF_MAKE_NONCOPYABLE(HarfBuzzFace); 76 WTF_MAKE_NONCOPYABLE(HarfBuzzFace);
50 public: 77 public:
51 static const hb_tag_t vertTag;
52 static const hb_tag_t vrt2Tag;
53 78
54 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6 4_t uniqueID) 79 static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint6 4_t uniqueID)
55 { 80 {
56 return adoptRef(new HarfBuzzFace(platformData, uniqueID)); 81 return adoptRef(new HarfBuzzFace(platformData, uniqueID));
57 } 82 }
58 ~HarfBuzzFace(); 83 ~HarfBuzzFace();
59 84
60 // In order to support the restricting effect of unicode-range optionally a 85 // 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 86 // range restriction can be passed in, which will restrict which glyphs we
62 // return in the harfBuzzGetGlyph function. 87 // return in the harfBuzzGetGlyph function.
63 hb_font_t* createFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCodepoi nt) const; 88 hb_font_t* createFont(unsigned rangeFrom = 0, unsigned rangeTo = kMaxCodepoi nt) const;
64 hb_face_t* face() const { return m_face; } 89 hb_face_t* face() const { return m_face; }
65 90
66 private: 91 private:
67 HarfBuzzFace(FontPlatformData*, uint64_t); 92 HarfBuzzFace(FontPlatformData*, uint64_t);
68 93
69 hb_face_t* createFace(); 94 hb_face_t* createFace();
95 void prepareHarfBuzzFontData();
70 96
71 FontPlatformData* m_platformData; 97 FontPlatformData* m_platformData;
72 uint64_t m_uniqueID; 98 uint64_t m_uniqueID;
73 hb_face_t* m_face; 99 hb_face_t* m_face;
74 WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry; 100 hb_font_t* m_unscaledFont;
101 OwnPtr<HarfBuzzFontData> m_harfBuzzFontData;
75 }; 102 };
76 103
77 } // namespace blink 104 } // namespace blink
78 105
79 namespace WTF { 106 namespace WTF {
80 107
81 template<typename T> struct OwnedPtrDeleter; 108 template<typename T> struct OwnedPtrDeleter;
82 template<> struct OwnedPtrDeleter<hb_font_t> { 109 template<> struct OwnedPtrDeleter<hb_font_t> {
83 STATIC_ONLY(OwnedPtrDeleter); 110 STATIC_ONLY(OwnedPtrDeleter);
84 static void deletePtr(hb_font_t* font) 111 static void deletePtr(hb_font_t* font)
85 { 112 {
86 if (font) 113 if (font)
87 hb_font_destroy(font); 114 hb_font_destroy(font);
88 } 115 }
89 }; 116 };
90 117
91 } // namespace WTF 118 } // namespace WTF
92 119
93 #endif // HarfBuzzFace_h 120 #endif // HarfBuzzFace_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698