diff options
author | Raph Levien <raph@google.com> | 2016-04-08 10:28:47 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2016-04-08 10:28:47 -0700 |
commit | 29abb82198868908ece4600284fa8b7d3ed73f3b (patch) | |
tree | cfd8f4b51e737388cba8127ae520bf1511b57707 | |
parent | aaa4e3470270496e6eb80704eadecb2cb7c56bf0 (diff) | |
download | android_frameworks_minikin-29abb82198868908ece4600284fa8b7d3ed73f3b.tar.gz android_frameworks_minikin-29abb82198868908ece4600284fa8b7d3ed73f3b.tar.bz2 android_frameworks_minikin-29abb82198868908ece4600284fa8b7d3ed73f3b.zip |
Update minikin/sample code to use new GetTable
We changed the signature of the MinikinFont::GetTable method. This
patch updates the sample code, and fixes the build.
Change-Id: I1977be868bf7636986fc802915f3dd54c418a73a
-rw-r--r-- | sample/MinikinSkia.cpp | 22 | ||||
-rw-r--r-- | sample/MinikinSkia.h | 3 |
2 files changed, 14 insertions, 11 deletions
diff --git a/sample/MinikinSkia.cpp b/sample/MinikinSkia.cpp index feda8ad..c4971bb 100644 --- a/sample/MinikinSkia.cpp +++ b/sample/MinikinSkia.cpp @@ -47,16 +47,20 @@ void MinikinFontSkia::GetBounds(MinikinRect* bounds, uint32_t glyph_id, bounds->mBottom = skBounds.fBottom; } -bool MinikinFontSkia::GetTable(uint32_t tag, uint8_t *buf, size_t *size) { - if (buf == NULL) { - const size_t tableSize = mTypeface->getTableSize(tag); - *size = tableSize; - return tableSize != 0; - } else { - const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf); - *size = actualSize; - return actualSize != 0; +const void* MinikinFontSkia::GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy) { + // we don't have a buffer to the font data, copy to own buffer + const size_t tableSize = mTypeface->getTableSize(tag); + *size = tableSize; + if (tableSize == 0) { + return nullptr; } + void* buf = malloc(tableSize); + if (buf == nullptr) { + return nullptr; + } + mTypeface->getTableData(tag, 0, tableSize, buf); + *destroy = free; + return buf; } SkTypeface *MinikinFontSkia::GetSkTypeface() { diff --git a/sample/MinikinSkia.h b/sample/MinikinSkia.h index 25ac1b0..e1d7bf6 100644 --- a/sample/MinikinSkia.h +++ b/sample/MinikinSkia.h @@ -12,8 +12,7 @@ public: void GetBounds(MinikinRect* bounds, uint32_t glyph_id, const MinikinPaint& paint) const; - // If buf is NULL, just update size - bool GetTable(uint32_t tag, uint8_t *buf, size_t *size); + const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy); int32_t GetUniqueId() const; |