diff options
author | Raph Levien <raph@google.com> | 2014-05-05 16:11:17 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2014-05-12 10:28:15 -0700 |
commit | b80c1f19c58b927820a8a24bf2218e5645724608 (patch) | |
tree | e00dec46530cfec05ea82512605ff2bf3ff32f28 /include/minikin/MinikinFont.h | |
parent | ecc2d34ac23a497988f21e5f415b53c007b9d8c5 (diff) | |
download | android_frameworks_minikin-b80c1f19c58b927820a8a24bf2218e5645724608.tar.gz android_frameworks_minikin-b80c1f19c58b927820a8a24bf2218e5645724608.tar.bz2 android_frameworks_minikin-b80c1f19c58b927820a8a24bf2218e5645724608.zip |
Better refcounting and locking
All major externally accessible objects (especially FontFamily and
FontCollection) are now reference counted. In addition, there is a
global lock intended to make operations thread-safe.
WIP notice: in this version of the patch, not all external API entry
points are protected by the lock. That should be fixed.
Change-Id: I14106196e99eb101e8bf1bcb4b81359759d2086c
Diffstat (limited to 'include/minikin/MinikinFont.h')
-rw-r--r-- | include/minikin/MinikinFont.h | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/include/minikin/MinikinFont.h b/include/minikin/MinikinFont.h index e84f5df..568f19d 100644 --- a/include/minikin/MinikinFont.h +++ b/include/minikin/MinikinFont.h @@ -17,6 +17,8 @@ #ifndef MINIKIN_FONT_H #define MINIKIN_FONT_H +#include <minikin/MinikinRefCounted.h> + // An abstraction for platform fonts, allowing Minikin to be used with // multiple actual implementations of fonts. @@ -56,15 +58,8 @@ struct MinikinRect { class MinikinFontFreeType; -class MinikinFont { +class MinikinFont : public MinikinRefCounted { public: - void Ref() { mRefcount_++; } - void Unref() { if (--mRefcount_ == 0) { delete this; } } - - MinikinFont() : mRefcount_(1) { } - - virtual ~MinikinFont() { }; - virtual bool GetGlyph(uint32_t codepoint, uint32_t *glyph) const = 0; virtual float GetHorizontalAdvance(uint32_t glyph_id, @@ -82,14 +77,6 @@ public: return ((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) | ((uint32_t)c3 << 8) | (uint32_t)c4; } - - // This is used to implement a downcast without RTTI - virtual MinikinFontFreeType* GetFreeType() { - return NULL; - } - -private: - int mRefcount_; }; } // namespace android |