Always use minikin namespace.
Here is a new policy of the namespace of minikin. - All components should be in minikin namespace. - All tests are also in minikin namespace and no anonymous namespace. Bug: 29233740 Change-Id: I71a8a35049bb8d624f7a78797231e90fed1e2b8c
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
#include <minikin/Hyphenator.h>
|
||||
|
||||
using android::Hyphenator;
|
||||
using minikin::Hyphenator;
|
||||
|
||||
Hyphenator* loadHybFile(const char* fn) {
|
||||
struct stat statbuf;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#ifndef MINIKIN_ANALYZE_STYLE_H
|
||||
#define MINIKIN_ANALYZE_STYLE_H
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
bool analyzeStyle(const uint8_t* os2_data, size_t os2_size, int* weight, bool* italic);
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_ANALYZE_STYLE_H
|
||||
#endif // MINIKIN_ANALYZE_STYLE_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <minikin/SparseBitSet.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class CmapCoverage {
|
||||
public:
|
||||
@@ -27,6 +27,6 @@ public:
|
||||
bool* has_cmap_format14_subtable);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_CMAP_COVERAGE_H
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <minikin/MinikinFont.h>
|
||||
#include <minikin/FontFamily.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class FontCollection : public MinikinRefCounted {
|
||||
public:
|
||||
@@ -98,6 +98,6 @@ private:
|
||||
std::vector<Range> mRanges;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_COLLECTION_H
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <minikin/MinikinRefCounted.h>
|
||||
#include <minikin/SparseBitSet.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class MinikinFont;
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
return bits == other.bits && mLanguageListId == other.mLanguageListId;
|
||||
}
|
||||
|
||||
hash_t hash() const;
|
||||
android::hash_t hash() const;
|
||||
|
||||
// Looks up a language list from an internal cache and returns its ID.
|
||||
// If the passed language list is not in the cache, registers it and returns newly assigned ID.
|
||||
@@ -75,7 +75,7 @@ enum FontVariant {
|
||||
VARIANT_ELEGANT = 2,
|
||||
};
|
||||
|
||||
inline hash_t hash_type(const FontStyle &style) {
|
||||
inline android::hash_t hash_type(const FontStyle &style) {
|
||||
return style.hash();
|
||||
}
|
||||
|
||||
@@ -158,6 +158,6 @@ private:
|
||||
bool mCoverageValid;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_FAMILY_H
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef MINIKIN_GRAPHEME_BREAK_H
|
||||
#define MINIKIN_GRAPHEME_BREAK_H
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class GraphemeBreak {
|
||||
public:
|
||||
@@ -42,6 +42,6 @@ public:
|
||||
size_t offset, MoveOpt opt);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_GRAPHEME_BREAK_H
|
||||
#endif // MINIKIN_GRAPHEME_BREAK_H
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef MINIKIN_HYPHENATOR_H
|
||||
#define MINIKIN_HYPHENATOR_H
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// hyb file header; implementation details are in the .cpp file
|
||||
struct Header;
|
||||
@@ -78,6 +78,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_HYPHENATOR_H
|
||||
|
||||
@@ -34,17 +34,13 @@ public:
|
||||
Bitmap(int width, int height);
|
||||
~Bitmap();
|
||||
void writePnm(std::ofstream& o) const;
|
||||
void drawGlyph(const android::GlyphBitmap& bitmap, int x, int y);
|
||||
void drawGlyph(const GlyphBitmap& bitmap, int x, int y);
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
uint8_t* buf;
|
||||
};
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
namespace android {
|
||||
|
||||
struct LayoutGlyph {
|
||||
// index into mFaces and mHbFonts vectors. We could imagine
|
||||
// moving this into a run length representation, because it's
|
||||
@@ -160,6 +156,6 @@ private:
|
||||
MinikinRect mBounds;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_LAYOUT_H
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "minikin/Hyphenator.h"
|
||||
#include "minikin/WordBreaker.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
enum BreakStrategy {
|
||||
kBreakStrategy_Greedy = 0,
|
||||
@@ -243,6 +243,6 @@ class LineBreaker {
|
||||
int mFirstTabIndex;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_LINE_BREAKER_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <minikin/Layout.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
float getRunAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
|
||||
size_t offset);
|
||||
@@ -27,6 +27,6 @@ float getRunAdvance(const float* advances, const uint16_t* buf, size_t start, si
|
||||
size_t getOffsetForAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
|
||||
float advance);
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_MEASUREMENT_H
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// An abstraction for platform fonts, allowing Minikin to be used with
|
||||
// multiple actual implementations of fonts.
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// The hyphen edit represents an edit to the string when a word is
|
||||
// hyphenated. The most common hyphen edit is adding a "-" at the end
|
||||
@@ -137,6 +137,6 @@ private:
|
||||
const int32_t mUniqueId;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_H
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// An abstraction for platform fonts, allowing Minikin to be used with
|
||||
// multiple actual implementations of fonts.
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
struct GlyphBitmap {
|
||||
uint8_t *buffer;
|
||||
@@ -65,6 +65,6 @@ private:
|
||||
static int32_t sIdCounter;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_FREETYPE_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef MINIKIN_REF_COUNTED_H
|
||||
#define MINIKIN_REF_COUNTED_H
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class MinikinRefCounted {
|
||||
public:
|
||||
@@ -54,6 +54,6 @@ private:
|
||||
T* mObj;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_REF_COUNTED_H
|
||||
#endif // MINIKIN_REF_COUNTED_H
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// This is an implementation of a set of integers. It is optimized for
|
||||
// values that are somewhat sparse, in the ballpark of a maximum value
|
||||
@@ -87,6 +87,6 @@ private:
|
||||
// Note: this thing cannot be used in vectors yet. If that were important, we'd need to
|
||||
// make the copy constructor work, and probably set up move traits as well.
|
||||
|
||||
}; // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_SPARSE_BIT_SET_H
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "unicode/brkiter.h"
|
||||
#include <memory>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class WordBreaker {
|
||||
public:
|
||||
@@ -68,6 +68,6 @@ private:
|
||||
bool mInEmailOrUrl;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_WORD_BREAKER_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <minikin/AnalyzeStyle.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// should we have a single FontAnalyzer class this stuff lives in, to avoid dup?
|
||||
static int32_t readU16(const uint8_t* data, size_t offset) {
|
||||
@@ -40,4 +40,4 @@ bool analyzeStyle(const uint8_t* os2_data, size_t os2_size, int* weight, bool* i
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -25,7 +25,7 @@ using std::vector;
|
||||
#include <minikin/SparseBitSet.h>
|
||||
#include <minikin/CmapCoverage.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// These could perhaps be optimized to use __builtin_bswap16 and friends.
|
||||
static uint32_t readU16(const uint8_t* data, size_t offset) {
|
||||
@@ -203,4 +203,4 @@ bool CmapCoverage::getCoverage(SparseBitSet& coverage, const uint8_t* cmap_data,
|
||||
return success;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
template <typename T>
|
||||
static inline T max(T a, T b) {
|
||||
@@ -77,7 +77,7 @@ uint32_t FontCollection::sNextId = 0;
|
||||
|
||||
FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
|
||||
mMaxChar(0) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
mId = sNextId++;
|
||||
vector<uint32_t> lastChar;
|
||||
size_t nTypefaces = typefaces.size();
|
||||
@@ -362,7 +362,7 @@ bool FontCollection::hasVariationSelector(uint32_t baseCodepoint,
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
|
||||
// Currently mRanges can not be used here since it isn't aware of the variation sequence.
|
||||
for (size_t i = 0; i < mVSFamilyVec.size(); i++) {
|
||||
@@ -471,4 +471,4 @@ uint32_t FontCollection::getId() const {
|
||||
return mId;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
FontStyle::FontStyle(int variant, int weight, bool italic)
|
||||
: FontStyle(FontLanguageListCache::kEmptyListId, variant, weight, italic) {
|
||||
@@ -48,15 +48,15 @@ FontStyle::FontStyle(uint32_t languageListId, int variant, int weight, bool ital
|
||||
: bits(pack(variant, weight, italic)), mLanguageListId(languageListId) {
|
||||
}
|
||||
|
||||
hash_t FontStyle::hash() const {
|
||||
uint32_t hash = JenkinsHashMix(0, bits);
|
||||
hash = JenkinsHashMix(hash, mLanguageListId);
|
||||
return JenkinsHashWhiten(hash);
|
||||
android::hash_t FontStyle::hash() const {
|
||||
uint32_t hash = android::JenkinsHashMix(0, bits);
|
||||
hash = android::JenkinsHashMix(hash, mLanguageListId);
|
||||
return android::JenkinsHashWhiten(hash);
|
||||
}
|
||||
|
||||
// static
|
||||
uint32_t FontStyle::registerLanguageList(const std::string& languages) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
return FontLanguageListCache::getId(languages);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ FontFamily::~FontFamily() {
|
||||
}
|
||||
|
||||
bool FontFamily::addFont(MinikinFont* typeface) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
const uint32_t os2Tag = MinikinFont::MakeTag('O', 'S', '/', '2');
|
||||
HbBlob os2Table(getFontTable(typeface, os2Tag));
|
||||
if (os2Table.get() == nullptr) return false;
|
||||
@@ -96,7 +96,7 @@ bool FontFamily::addFont(MinikinFont* typeface) {
|
||||
}
|
||||
|
||||
void FontFamily::addFont(MinikinFont* typeface, FontStyle style) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
addFontLocked(typeface, style);
|
||||
}
|
||||
|
||||
@@ -214,4 +214,4 @@ bool FontFamily::hasVSTable() const {
|
||||
return mHasVSTable;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <hb.h>
|
||||
#include <unicode/uloc.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
#define SCRIPT_TAG(c1, c2, c3, c4) \
|
||||
(((uint32_t)(c1)) << 24 | ((uint32_t)(c2)) << 16 | ((uint32_t)(c3)) << 8 | \
|
||||
@@ -183,4 +183,4 @@ FontLanguages::FontLanguages(std::vector<FontLanguage>&& languages)
|
||||
}
|
||||
|
||||
#undef SCRIPT_TAG
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <hb.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// Due to the limits in font fallback score calculation, we can't use anything more than 17
|
||||
// languages.
|
||||
@@ -121,6 +121,6 @@ private:
|
||||
void operator=(const FontLanguages&) = delete;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_LANGUAGE_H
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "MinikinInternal.h"
|
||||
#include "FontLanguage.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
const uint32_t FontLanguageListCache::kEmptyListId;
|
||||
|
||||
@@ -152,4 +152,4 @@ FontLanguageListCache* FontLanguageListCache::getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <minikin/FontFamily.h>
|
||||
#include "FontLanguage.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
class FontLanguageListCache {
|
||||
public:
|
||||
@@ -51,6 +51,6 @@ private:
|
||||
std::unordered_map<std::string, uint32_t> mLanguageListLookupTable;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_FONT_LANGUAGE_LIST_CACHE_H
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <minikin/GraphemeBreak.h>
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
int32_t tailoredGraphemeClusterBreak(uint32_t c) {
|
||||
// Characters defined as Control that we want to treat them as Extend.
|
||||
@@ -209,4 +209,4 @@ size_t GraphemeBreak::getTextRunCursor(const uint16_t* buf, size_t start, size_t
|
||||
return offset;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <minikin/MinikinFont.h>
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
static hb_blob_t* referenceTable(hb_face_t* /* face */, hb_tag_t tag, void* userData) {
|
||||
MinikinFont* font = reinterpret_cast<MinikinFont*>(userData);
|
||||
@@ -44,7 +44,7 @@ static hb_blob_t* referenceTable(hb_face_t* /* face */, hb_tag_t tag, void* user
|
||||
HB_MEMORY_MODE_READONLY, const_cast<void*>(buffer), destroy);
|
||||
}
|
||||
|
||||
class HbFontCache : private OnEntryRemoved<int32_t, hb_font_t*> {
|
||||
class HbFontCache : private android::OnEntryRemoved<int32_t, hb_font_t*> {
|
||||
public:
|
||||
HbFontCache() : mCache(kMaxEntries) {
|
||||
mCache.setOnEntryRemovedListener(this);
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
private:
|
||||
static const size_t kMaxEntries = 100;
|
||||
|
||||
LruCache<int32_t, hb_font_t*> mCache;
|
||||
android::LruCache<int32_t, hb_font_t*> mCache;
|
||||
};
|
||||
|
||||
HbFontCache* getFontCacheLocked() {
|
||||
@@ -141,4 +141,4 @@ hb_font_t* getHbFontLocked(MinikinFont* minikinFont) {
|
||||
return hb_font_reference(font);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
struct hb_font_t;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
class MinikinFont;
|
||||
|
||||
void purgeHbFontCacheLocked();
|
||||
void purgeHbFontLocked(const MinikinFont* minikinFont);
|
||||
hb_font_t* getHbFontLocked(MinikinFont* minikinFont);
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
#endif // MINIKIN_HBFONT_CACHE_H
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
static const uint16_t CHAR_SOFT_HYPHEN = 0x00AD;
|
||||
|
||||
@@ -232,4 +232,4 @@ void Hyphenator::hyphenateFromCodes(uint8_t* result, const uint16_t* codes, size
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -63,7 +63,7 @@ void Bitmap::writePnm(std::ofstream &o) const {
|
||||
o.close();
|
||||
}
|
||||
|
||||
void Bitmap::drawGlyph(const android::GlyphBitmap& bitmap, int x, int y) {
|
||||
void Bitmap::drawGlyph(const GlyphBitmap& bitmap, int x, int y) {
|
||||
int bmw = bitmap.width;
|
||||
int bmh = bitmap.height;
|
||||
x += bitmap.left;
|
||||
@@ -85,10 +85,6 @@ void Bitmap::drawGlyph(const android::GlyphBitmap& bitmap, int x, int y) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
namespace android {
|
||||
|
||||
const int kDirection_Mask = 0x1;
|
||||
|
||||
struct LayoutContext {
|
||||
@@ -120,7 +116,7 @@ public:
|
||||
}
|
||||
bool operator==(const LayoutCacheKey &other) const;
|
||||
|
||||
hash_t hash() const {
|
||||
android::hash_t hash() const {
|
||||
return mHash;
|
||||
}
|
||||
|
||||
@@ -157,12 +153,12 @@ private:
|
||||
bool mIsRtl;
|
||||
// Note: any fields added to MinikinPaint must also be reflected here.
|
||||
// TODO: language matching (possibly integrate into style)
|
||||
hash_t mHash;
|
||||
android::hash_t mHash;
|
||||
|
||||
hash_t computeHash() const;
|
||||
android::hash_t computeHash() const;
|
||||
};
|
||||
|
||||
class LayoutCache : private OnEntryRemoved<LayoutCacheKey, Layout*> {
|
||||
class LayoutCache : private android::OnEntryRemoved<LayoutCacheKey, Layout*> {
|
||||
public:
|
||||
LayoutCache() : mCache(kMaxEntries) {
|
||||
mCache.setOnEntryRemovedListener(this);
|
||||
@@ -190,7 +186,7 @@ private:
|
||||
delete value;
|
||||
}
|
||||
|
||||
LruCache<LayoutCacheKey, Layout*> mCache;
|
||||
android::LruCache<LayoutCacheKey, Layout*> mCache;
|
||||
|
||||
//static const size_t kMaxEntries = LruCache<LayoutCacheKey, Layout*>::kUnlimitedCapacity;
|
||||
|
||||
@@ -204,7 +200,7 @@ static unsigned int disabledDecomposeCompatibility(hb_unicode_funcs_t*, hb_codep
|
||||
return 0;
|
||||
}
|
||||
|
||||
class LayoutEngine : public Singleton<LayoutEngine> {
|
||||
class LayoutEngine : public ::android::Singleton<LayoutEngine> {
|
||||
public:
|
||||
LayoutEngine() {
|
||||
unicodeFunctions = hb_unicode_funcs_create(hb_icu_get_unicode_funcs());
|
||||
@@ -220,8 +216,6 @@ public:
|
||||
LayoutCache layoutCache;
|
||||
};
|
||||
|
||||
ANDROID_SINGLETON_STATIC_INSTANCE(LayoutEngine);
|
||||
|
||||
bool LayoutCacheKey::operator==(const LayoutCacheKey& other) const {
|
||||
return mId == other.mId
|
||||
&& mStart == other.mStart
|
||||
@@ -238,23 +232,23 @@ bool LayoutCacheKey::operator==(const LayoutCacheKey& other) const {
|
||||
&& !memcmp(mChars, other.mChars, mNchars * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
hash_t LayoutCacheKey::computeHash() const {
|
||||
uint32_t hash = JenkinsHashMix(0, mId);
|
||||
hash = JenkinsHashMix(hash, mStart);
|
||||
hash = JenkinsHashMix(hash, mCount);
|
||||
hash = JenkinsHashMix(hash, hash_type(mStyle));
|
||||
hash = JenkinsHashMix(hash, hash_type(mSize));
|
||||
hash = JenkinsHashMix(hash, hash_type(mScaleX));
|
||||
hash = JenkinsHashMix(hash, hash_type(mSkewX));
|
||||
hash = JenkinsHashMix(hash, hash_type(mLetterSpacing));
|
||||
hash = JenkinsHashMix(hash, hash_type(mPaintFlags));
|
||||
hash = JenkinsHashMix(hash, hash_type(mHyphenEdit.hasHyphen()));
|
||||
hash = JenkinsHashMix(hash, hash_type(mIsRtl));
|
||||
hash = JenkinsHashMixShorts(hash, mChars, mNchars);
|
||||
return JenkinsHashWhiten(hash);
|
||||
android::hash_t LayoutCacheKey::computeHash() const {
|
||||
uint32_t hash = android::JenkinsHashMix(0, mId);
|
||||
hash = android::JenkinsHashMix(hash, mStart);
|
||||
hash = android::JenkinsHashMix(hash, mCount);
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mStyle));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mSize));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mScaleX));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mSkewX));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mLetterSpacing));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mPaintFlags));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mHyphenEdit.hasHyphen()));
|
||||
hash = android::JenkinsHashMix(hash, hash_type(mIsRtl));
|
||||
hash = android::JenkinsHashMixShorts(hash, mChars, mNchars);
|
||||
return android::JenkinsHashWhiten(hash);
|
||||
}
|
||||
|
||||
hash_t hash_type(const LayoutCacheKey& key) {
|
||||
android::hash_t hash_type(const LayoutCacheKey& key) {
|
||||
return key.hash();
|
||||
}
|
||||
|
||||
@@ -578,7 +572,7 @@ BidiText::BidiText(const uint16_t* buf, size_t start, size_t count, size_t bufSi
|
||||
|
||||
void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
|
||||
int bidiFlags, const FontStyle &style, const MinikinPaint &paint) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
|
||||
LayoutContext ctx;
|
||||
ctx.style = style;
|
||||
@@ -597,7 +591,7 @@ void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bu
|
||||
float Layout::measureText(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
|
||||
int bidiFlags, const FontStyle &style, const MinikinPaint &paint,
|
||||
const FontCollection* collection, float* advances) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
|
||||
LayoutContext ctx;
|
||||
ctx.style = style;
|
||||
@@ -965,10 +959,17 @@ void Layout::getBounds(MinikinRect* bounds) {
|
||||
}
|
||||
|
||||
void Layout::purgeCaches() {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
LayoutCache& layoutCache = LayoutEngine::getInstance().layoutCache;
|
||||
layoutCache.clear();
|
||||
purgeHbFontCacheLocked();
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
// Unable to define the static data member outside of android.
|
||||
// TODO: introduce our own Singleton to drop android namespace.
|
||||
namespace android {
|
||||
ANDROID_SINGLETON_STATIC_INSTANCE(minikin::LayoutEngine);
|
||||
} // namespace android
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "LayoutUtils.h"
|
||||
|
||||
namespace minikin {
|
||||
|
||||
/**
|
||||
* For the purpose of layout, a word break is a boundary with no
|
||||
* kerning or complex script processing. This is necessarily a
|
||||
@@ -74,3 +76,5 @@ size_t getNextWordBreakForCache(
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace minikin {
|
||||
|
||||
/**
|
||||
* Return offset of previous word break. It is either < offset or == 0.
|
||||
*
|
||||
@@ -39,4 +41,5 @@ size_t getPrevWordBreakForCache(
|
||||
size_t getNextWordBreakForCache(
|
||||
const uint16_t* chars, size_t offset, size_t len);
|
||||
|
||||
} // namespace minikin
|
||||
#endif // MINIKIN_LAYOUT_UTILS_H
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
const int CHAR_TAB = 0x0009;
|
||||
|
||||
@@ -441,4 +441,4 @@ void LineBreaker::finish() {
|
||||
mLinePenalty = 0.0f;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <minikin/GraphemeBreak.h>
|
||||
#include <minikin/Measurement.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// These could be considered helper methods of layout, but need only be loosely coupled, so
|
||||
// are separate.
|
||||
@@ -119,4 +119,4 @@ size_t getOffsetForAdvance(const float* advances, const uint16_t* buf, size_t st
|
||||
return best;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include <minikin/MinikinFont.h>
|
||||
#include "HbFontCache.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
MinikinFont::~MinikinFont() {
|
||||
purgeHbFontLocked(this);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <minikin/MinikinFontFreeType.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
int32_t MinikinFontFreeType::sIdCounter = 0;
|
||||
|
||||
@@ -97,4 +97,4 @@ MinikinFontFreeType* MinikinFontFreeType::GetFreeType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
Mutex gMinikinLock;
|
||||
android::Mutex gMinikinLock;
|
||||
|
||||
void assertMinikinLocked() {
|
||||
#ifdef ENABLE_RACE_DETECTION
|
||||
@@ -88,4 +88,4 @@ hb_blob_t* getFontTable(MinikinFont* minikinFont, uint32_t tag) {
|
||||
return blob;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
|
||||
#include <minikin/MinikinFont.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// All external Minikin interfaces are designed to be thread-safe.
|
||||
// Presently, that's implemented by through a global lock, and having
|
||||
// all external interfaces take that lock.
|
||||
|
||||
extern Mutex gMinikinLock;
|
||||
extern android::Mutex gMinikinLock;
|
||||
|
||||
// Aborts if gMinikinLock is not acquired. Do nothing on the release build.
|
||||
void assertMinikinLocked();
|
||||
@@ -74,6 +74,6 @@ private:
|
||||
hb_blob_t* mBlob;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_INTERNAL_H
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
|
||||
#include <minikin/MinikinRefCounted.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
void MinikinRefCounted::Ref() {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
this->RefLocked();
|
||||
}
|
||||
|
||||
void MinikinRefCounted::Unref() {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
this->UnrefLocked();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <string.h>
|
||||
#include <minikin/SparseBitSet.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
const uint32_t SparseBitSet::kNotFound;
|
||||
|
||||
@@ -146,4 +146,4 @@ uint32_t SparseBitSet::nextSetBit(uint32_t fromIndex) const {
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <unicode/uchar.h>
|
||||
#include <unicode/utf16.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
const uint32_t CHAR_SOFT_HYPHEN = 0x00AD;
|
||||
const uint32_t CHAR_ZWJ = 0x200D;
|
||||
@@ -258,4 +258,4 @@ void WordBreaker::finish() {
|
||||
utext_close(&mUText);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -27,7 +27,7 @@ UNICODE_EMOJI_TEMPLATE="""
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
namespace generated {
|
||||
|
||||
int32_t EMOJI_LIST[] = {
|
||||
@@ -35,7 +35,7 @@ int32_t EMOJI_LIST[] = {
|
||||
};
|
||||
|
||||
} // namespace generated
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_UNICODE_EMOJI_H
|
||||
"""
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <minikin/MinikinFont.h>
|
||||
#include "MinikinSkia.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
MinikinFontSkia::MinikinFontSkia(SkTypeface *typeface) :
|
||||
MinikinFont(typeface->uniqueID()),
|
||||
@@ -68,4 +68,4 @@ SkTypeface *MinikinFontSkia::GetSkTypeface() {
|
||||
return mTypeface;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
namespace android {
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
namespace minikin {
|
||||
|
||||
class MinikinFontSkia : public MinikinFont {
|
||||
public:
|
||||
@@ -21,4 +36,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <minikin/Layout.h>
|
||||
|
||||
using std::vector;
|
||||
using namespace android;
|
||||
using namespace minikin;
|
||||
|
||||
FT_Library library; // TODO: this should not be a global
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
using std::vector;
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
FT_Library library; // TODO: this should not be a global
|
||||
|
||||
@@ -145,8 +145,8 @@ int runMinikinTest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace minikin
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
return android::runMinikinTest();
|
||||
return minikin::runMinikinTest();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "FontLanguage.h"
|
||||
|
||||
using android::FontLanguage;
|
||||
namespace minikin {
|
||||
|
||||
static void BM_FontLanguage_en_US(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
@@ -32,3 +32,5 @@ static void BM_FontLanguage_en_Latn_US(benchmark::State& state) {
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_FontLanguage_en_Latn_US);
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -25,16 +25,7 @@
|
||||
#include "UnicodeUtils.h"
|
||||
#include "minikin/FontFamily.h"
|
||||
|
||||
using android::AutoMutex;
|
||||
using android::FontCollection;
|
||||
using android::FontFamily;
|
||||
using android::FontLanguage;
|
||||
using android::FontLanguages;
|
||||
using android::FontLanguageListCache;
|
||||
using android::FontStyle;
|
||||
using android::MinikinAutoUnref;
|
||||
using android::MinikinFont;
|
||||
using android::gMinikinLock;
|
||||
namespace minikin {
|
||||
|
||||
const char kItemizeFontXml[] = kTestFontDir "itemize.xml";
|
||||
const char kEmojiFont[] = kTestFontDir "Emoji.ttf";
|
||||
@@ -64,7 +55,7 @@ void itemize(FontCollection* collection, const char* str, FontStyle style,
|
||||
|
||||
result->clear();
|
||||
ParseUnicode(buf, BUF_SIZE, str, &len, NULL);
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
collection->itemize(buf, len, style, result);
|
||||
}
|
||||
|
||||
@@ -76,7 +67,7 @@ const std::string& getFontPath(const FontCollection::Run& run) {
|
||||
|
||||
// Utility function to obtain FontLanguages from string.
|
||||
const FontLanguages& registerAndGetFontLanguages(const std::string& lang_string) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
return FontLanguageListCache::getById(FontLanguageListCache::getId(lang_string));
|
||||
}
|
||||
|
||||
@@ -673,12 +664,12 @@ TEST_F(FontCollectionItemizeTest, itemize_vs_sequence_but_no_base_char) {
|
||||
// point.
|
||||
const std::string kVSTestFont = kTestFontDir "VarioationSelectorTest-Regular.ttf";
|
||||
|
||||
std::vector<android::FontFamily*> families;
|
||||
FontFamily* family1 = new FontFamily(android::VARIANT_DEFAULT);
|
||||
std::vector<FontFamily*> families;
|
||||
FontFamily* family1 = new FontFamily(VARIANT_DEFAULT);
|
||||
family1->addFont(new MinikinFontForTest(kLatinFont));
|
||||
families.push_back(family1);
|
||||
|
||||
FontFamily* family2 = new FontFamily(android::VARIANT_DEFAULT);
|
||||
FontFamily* family2 = new FontFamily(VARIANT_DEFAULT);
|
||||
family2->addFont(new MinikinFontForTest(kVSTestFont));
|
||||
families.push_back(family2);
|
||||
|
||||
@@ -1372,3 +1363,5 @@ TEST_F(FontCollectionItemizeTest, itemize_PrivateUseArea) {
|
||||
EXPECT_EQ(4, runs[0].end);
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "MinikinFontForTest.h"
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
// The test font has following glyphs.
|
||||
// U+82A6
|
||||
@@ -107,4 +107,4 @@ TEST(FontCollectionTest, hasVariationSelectorTest_emoji) {
|
||||
EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0F));
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -25,19 +25,19 @@
|
||||
#include "MinikinFontForTest.h"
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
typedef ICUTestBase FontLanguagesTest;
|
||||
typedef ICUTestBase FontLanguageTest;
|
||||
|
||||
static const FontLanguages& createFontLanguages(const std::string& input) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
uint32_t langId = FontLanguageListCache::getId(input);
|
||||
return FontLanguageListCache::getById(langId);
|
||||
}
|
||||
|
||||
static FontLanguage createFontLanguage(const std::string& input) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
uint32_t langId = FontLanguageListCache::getId(input);
|
||||
return FontLanguageListCache::getById(langId)[0];
|
||||
}
|
||||
@@ -354,7 +354,7 @@ TEST_F(FontFamilyTest, hasVariationSelectorTest) {
|
||||
MinikinAutoUnref<FontFamily> family(new FontFamily);
|
||||
family->addFont(minikinFont.get());
|
||||
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
|
||||
const uint32_t kVS1 = 0xFE00;
|
||||
const uint32_t kVS2 = 0xFE01;
|
||||
@@ -406,11 +406,11 @@ TEST_F(FontFamilyTest, hasVSTableTest) {
|
||||
MinikinAutoUnref<MinikinFontForTest> minikinFont(new MinikinFontForTest(testCase.fontPath));
|
||||
MinikinAutoUnref<FontFamily> family(new FontFamily);
|
||||
family->addFont(minikinFont.get());
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
family->getCoverage();
|
||||
|
||||
EXPECT_EQ(testCase.hasVSTable, family->hasVSTable());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ICUTestBase.h"
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
typedef ICUTestBase FontLanguageListCacheTest;
|
||||
|
||||
@@ -31,7 +31,7 @@ TEST_F(FontLanguageListCacheTest, getId) {
|
||||
EXPECT_NE(0UL, FontStyle::registerLanguageList("jp"));
|
||||
EXPECT_NE(0UL, FontStyle::registerLanguageList("en,zh-Hans"));
|
||||
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
EXPECT_EQ(0UL, FontLanguageListCache::getId(""));
|
||||
|
||||
EXPECT_EQ(FontLanguageListCache::getId("en"), FontLanguageListCache::getId("en"));
|
||||
@@ -50,7 +50,7 @@ TEST_F(FontLanguageListCacheTest, getId) {
|
||||
}
|
||||
|
||||
TEST_F(FontLanguageListCacheTest, getById) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
uint32_t enLangId = FontLanguageListCache::getId("en");
|
||||
uint32_t jpLangId = FontLanguageListCache::getId("jp");
|
||||
FontLanguage english = FontLanguageListCache::getById(enLangId)[0];
|
||||
@@ -70,4 +70,4 @@ TEST_F(FontLanguageListCacheTest, getById) {
|
||||
EXPECT_EQ(japanese, langs2[1]);
|
||||
}
|
||||
|
||||
} // android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <UnicodeUtils.h>
|
||||
#include <minikin/GraphemeBreak.h>
|
||||
|
||||
using namespace android;
|
||||
namespace minikin {
|
||||
|
||||
bool IsBreak(const char* src) {
|
||||
const size_t BUF_SIZE = 256;
|
||||
@@ -188,3 +188,5 @@ TEST(GraphemeBreak, offsets) {
|
||||
EXPECT_TRUE(GraphemeBreak::isGraphemeBreak(string, 2, 3, 4));
|
||||
EXPECT_TRUE(GraphemeBreak::isGraphemeBreak(string, 2, 3, 5));
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -26,19 +26,18 @@
|
||||
#include "MinikinFontForTest.h"
|
||||
#include <minikin/MinikinFont.h>
|
||||
|
||||
namespace android {
|
||||
namespace {
|
||||
namespace minikin {
|
||||
|
||||
class HbFontCacheTest : public testing::Test {
|
||||
public:
|
||||
virtual void TearDown() {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
purgeHbFontCacheLocked();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(HbFontCacheTest, getHbFontLockedTest) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
|
||||
MinikinFontForTest fontA(kTestFontDir "Regular.ttf");
|
||||
MinikinFontForTest fontB(kTestFontDir "Bold.ttf");
|
||||
@@ -62,7 +61,7 @@ TEST_F(HbFontCacheTest, getHbFontLockedTest) {
|
||||
}
|
||||
|
||||
TEST_F(HbFontCacheTest, purgeCacheTest) {
|
||||
AutoMutex _l(gMinikinLock);
|
||||
android::AutoMutex _l(gMinikinLock);
|
||||
MinikinFontForTest minikinFont(kTestFontDir "Regular.ttf");
|
||||
|
||||
hb_font_t* font = getHbFontLocked(&minikinFont);
|
||||
@@ -83,5 +82,4 @@ TEST_F(HbFontCacheTest, purgeCacheTest) {
|
||||
EXPECT_EQ(nullptr, hb_font_get_user_data(font, &key));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
namespace minikin {
|
||||
|
||||
class ICUTestBase : public testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() override {
|
||||
@@ -48,5 +50,5 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace minikin
|
||||
#endif // MINIKIN_TEST_ICU_TEST_BASE_H
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "LayoutUtils.h"
|
||||
|
||||
namespace {
|
||||
namespace minikin {
|
||||
|
||||
void ExpectNextWordBreakForCache(size_t offset_in, const char* query_str) {
|
||||
const size_t BUF_SIZE = 256U;
|
||||
@@ -507,4 +507,4 @@ TEST(WordBreakTest, goPrevWordBreakTest) {
|
||||
ExpectPrevWordBreakForCache(1000, "U+4444 U+302D U+302D | U+4444");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace minikin
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "MinikinInternal.h"
|
||||
|
||||
namespace android {
|
||||
namespace minikin {
|
||||
|
||||
TEST(MinikinInternalTest, isEmojiTest) {
|
||||
EXPECT_TRUE(isEmoji(0x0023)); // NUMBER SIGN
|
||||
@@ -31,4 +31,4 @@ TEST(MinikinInternalTest, isEmojiTest) {
|
||||
EXPECT_FALSE(isEmoji(0x29E3D)); // A han character.
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace minikin
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#define UTF16(codepoint) U16_LEAD(codepoint), U16_TRAIL(codepoint)
|
||||
|
||||
using namespace android;
|
||||
namespace minikin {
|
||||
|
||||
typedef ICUTestBase WordBreakerTest;
|
||||
|
||||
@@ -388,3 +388,5 @@ TEST_F(WordBreakerTest, emailStartsWithSlash) {
|
||||
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
|
||||
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -24,31 +24,33 @@
|
||||
#include "FontLanguage.h"
|
||||
#include "MinikinFontForTest.h"
|
||||
|
||||
android::FontCollection* getFontCollection(const char* fontDir, const char* fontXml) {
|
||||
namespace minikin {
|
||||
|
||||
FontCollection* getFontCollection(const char* fontDir, const char* fontXml) {
|
||||
xmlDoc* doc = xmlReadFile(fontXml, NULL, 0);
|
||||
xmlNode* familySet = xmlDocGetRootElement(doc);
|
||||
|
||||
std::vector<android::FontFamily*> families;
|
||||
std::vector<FontFamily*> families;
|
||||
for (xmlNode* familyNode = familySet->children; familyNode; familyNode = familyNode->next) {
|
||||
if (xmlStrcmp(familyNode->name, (const xmlChar*)"family") != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
xmlChar* variantXmlch = xmlGetProp(familyNode, (const xmlChar*)"variant");
|
||||
int variant = android::VARIANT_DEFAULT;
|
||||
int variant = VARIANT_DEFAULT;
|
||||
if (variantXmlch) {
|
||||
if (xmlStrcmp(variantXmlch, (const xmlChar*)"elegant") == 0) {
|
||||
variant = android::VARIANT_ELEGANT;
|
||||
variant = VARIANT_ELEGANT;
|
||||
} else if (xmlStrcmp(variantXmlch, (const xmlChar*)"compact") == 0) {
|
||||
variant = android::VARIANT_COMPACT;
|
||||
variant = VARIANT_COMPACT;
|
||||
}
|
||||
}
|
||||
|
||||
xmlChar* lang = xmlGetProp(familyNode, (const xmlChar*)"lang");
|
||||
uint32_t langId = android::FontStyle::registerLanguageList(
|
||||
uint32_t langId = FontStyle::registerLanguageList(
|
||||
std::string((const char*)lang, xmlStrlen(lang)));
|
||||
|
||||
android::FontFamily* family = new android::FontFamily(langId, variant);
|
||||
FontFamily* family = new FontFamily(langId, variant);
|
||||
|
||||
for (xmlNode* fontNode = familyNode->children; fontNode; fontNode = fontNode->next) {
|
||||
if (xmlStrcmp(fontNode->name, (const xmlChar*)"font") != 0) {
|
||||
@@ -66,16 +68,18 @@ android::FontCollection* getFontCollection(const char* fontDir, const char* font
|
||||
LOG_ALWAYS_FATAL_IF(access(fontPath.c_str(), R_OK) != 0,
|
||||
"%s is not found", fontPath.c_str());
|
||||
|
||||
family->addFont(new MinikinFontForTest(fontPath), android::FontStyle(weight, italic));
|
||||
family->addFont(new MinikinFontForTest(fontPath), FontStyle(weight, italic));
|
||||
}
|
||||
families.push_back(family);
|
||||
}
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
android::FontCollection* collection = new android::FontCollection(families);
|
||||
FontCollection* collection = new FontCollection(families);
|
||||
collection->Ref();
|
||||
for (size_t i = 0; i < families.size(); ++i) {
|
||||
families[i]->Unref();
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <minikin/FontCollection.h>
|
||||
|
||||
namespace minikin {
|
||||
|
||||
/**
|
||||
* Returns FontCollection from installed fonts.
|
||||
*
|
||||
@@ -27,6 +29,7 @@
|
||||
*
|
||||
* Caller must unref the returned pointer.
|
||||
*/
|
||||
android::FontCollection* getFontCollection(const char* fontDir, const char* fontXml);
|
||||
FontCollection* getFontCollection(const char* fontDir, const char* fontXml);
|
||||
|
||||
} // namespace minikin
|
||||
#endif // MINIKIN_FONT_TEST_UTILS_H
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
namespace minikin {
|
||||
|
||||
MinikinFontForTest::MinikinFontForTest(const std::string& font_path) :
|
||||
MinikinFontForTest(font_path, SkTypeface::CreateFromFile(font_path.c_str())) {
|
||||
}
|
||||
@@ -36,18 +38,18 @@ MinikinFontForTest::~MinikinFontForTest() {
|
||||
}
|
||||
|
||||
float MinikinFontForTest::GetHorizontalAdvance(uint32_t /* glyph_id */,
|
||||
const android::MinikinPaint& /* paint */) const {
|
||||
const MinikinPaint& /* paint */) const {
|
||||
LOG_ALWAYS_FATAL("MinikinFontForTest::GetHorizontalAdvance is not yet implemented");
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void MinikinFontForTest::GetBounds(android::MinikinRect* /* bounds */, uint32_t /* glyph_id */,
|
||||
const android::MinikinPaint& /* paint */) const {
|
||||
void MinikinFontForTest::GetBounds(MinikinRect* /* bounds */, uint32_t /* glyph_id */,
|
||||
const MinikinPaint& /* paint */) const {
|
||||
LOG_ALWAYS_FATAL("MinikinFontForTest::GetBounds is not yet implemented");
|
||||
}
|
||||
|
||||
const void* MinikinFontForTest::GetTable(uint32_t tag, size_t* size,
|
||||
android::MinikinDestroyFunc* destroy) {
|
||||
MinikinDestroyFunc* destroy) {
|
||||
const size_t tableSize = mTypeface->getTableSize(tag);
|
||||
*size = tableSize;
|
||||
if (tableSize == 0) {
|
||||
@@ -61,3 +63,5 @@ const void* MinikinFontForTest::GetTable(uint32_t tag, size_t* size,
|
||||
*destroy = free;
|
||||
return buf;
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -21,17 +21,19 @@
|
||||
|
||||
class SkTypeface;
|
||||
|
||||
class MinikinFontForTest : public android::MinikinFont {
|
||||
namespace minikin {
|
||||
|
||||
class MinikinFontForTest : public MinikinFont {
|
||||
public:
|
||||
explicit MinikinFontForTest(const std::string& font_path);
|
||||
MinikinFontForTest(const std::string& font_path, SkTypeface* typeface);
|
||||
~MinikinFontForTest();
|
||||
|
||||
// MinikinFont overrides.
|
||||
float GetHorizontalAdvance(uint32_t glyph_id, const android::MinikinPaint &paint) const;
|
||||
void GetBounds(android::MinikinRect* bounds, uint32_t glyph_id,
|
||||
const android::MinikinPaint& paint) const;
|
||||
const void* GetTable(uint32_t tag, size_t* size, android::MinikinDestroyFunc* destroy);
|
||||
float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint &paint) const;
|
||||
void GetBounds(MinikinRect* bounds, uint32_t glyph_id,
|
||||
const MinikinPaint& paint) const;
|
||||
const void* GetTable(uint32_t tag, size_t* size, MinikinDestroyFunc* destroy);
|
||||
|
||||
const std::string& fontPath() const { return mFontPath; }
|
||||
private:
|
||||
@@ -39,4 +41,6 @@ private:
|
||||
const std::string mFontPath;
|
||||
};
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
#endif // MINIKIN_TEST_MINIKIN_FONT_FOR_TEST_H
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <unicode/utf.h>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace minikin {
|
||||
|
||||
// src is of the form "U+1F431 | 'h' 'i'". Position of "|" gets saved to offset if non-null.
|
||||
// Size is returned in an out parameter because gtest needs a void return for ASSERT to work.
|
||||
void ParseUnicode(uint16_t* buf, size_t buf_size, const char* src, size_t* result_size,
|
||||
@@ -94,3 +96,5 @@ TEST(UnicodeUtils, parse) {
|
||||
EXPECT_EQ(buf[2], 0xDC31);
|
||||
EXPECT_EQ(buf[3], 'a');
|
||||
}
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
@@ -14,5 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
void ParseUnicode(uint16_t* buf, size_t buf_size, const char* src, size_t* result_size,
|
||||
namespace minikin {
|
||||
|
||||
void ParseUnicode(uint16_t* buf, size_t buf_size, const char* src, size_t* result_size,
|
||||
size_t* offset);
|
||||
|
||||
} // namespace minikin
|
||||
|
||||
Reference in New Issue
Block a user