From 2fdcf62495d27f95b130013ae0b45f9c0dc03593 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Thu, 9 Jun 2016 19:40:58 +0900 Subject: [PATCH] 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 --- engine/src/flutter/app/HyphTool.cpp | 2 +- .../flutter/include/minikin/AnalyzeStyle.h | 6 +- .../flutter/include/minikin/CmapCoverage.h | 4 +- .../flutter/include/minikin/FontCollection.h | 4 +- .../src/flutter/include/minikin/FontFamily.h | 8 +-- .../flutter/include/minikin/GraphemeBreak.h | 6 +- .../src/flutter/include/minikin/Hyphenator.h | 4 +- engine/src/flutter/include/minikin/Layout.h | 8 +-- .../src/flutter/include/minikin/LineBreaker.h | 4 +- .../src/flutter/include/minikin/Measurement.h | 4 +- .../src/flutter/include/minikin/MinikinFont.h | 4 +- .../include/minikin/MinikinFontFreeType.h | 4 +- .../include/minikin/MinikinRefCounted.h | 6 +- .../flutter/include/minikin/SparseBitSet.h | 4 +- .../src/flutter/include/minikin/WordBreaker.h | 4 +- .../src/flutter/libs/minikin/AnalyzeStyle.cpp | 4 +- .../src/flutter/libs/minikin/CmapCoverage.cpp | 4 +- .../flutter/libs/minikin/FontCollection.cpp | 8 +-- .../src/flutter/libs/minikin/FontFamily.cpp | 18 +++--- .../src/flutter/libs/minikin/FontLanguage.cpp | 4 +- .../src/flutter/libs/minikin/FontLanguage.h | 4 +- .../libs/minikin/FontLanguageListCache.cpp | 4 +- .../libs/minikin/FontLanguageListCache.h | 4 +- .../flutter/libs/minikin/GraphemeBreak.cpp | 4 +- .../src/flutter/libs/minikin/HbFontCache.cpp | 8 +-- engine/src/flutter/libs/minikin/HbFontCache.h | 4 +- .../src/flutter/libs/minikin/Hyphenator.cpp | 4 +- engine/src/flutter/libs/minikin/Layout.cpp | 63 ++++++++++--------- .../src/flutter/libs/minikin/LayoutUtils.cpp | 4 ++ engine/src/flutter/libs/minikin/LayoutUtils.h | 3 + .../src/flutter/libs/minikin/LineBreaker.cpp | 4 +- .../src/flutter/libs/minikin/Measurement.cpp | 4 +- .../src/flutter/libs/minikin/MinikinFont.cpp | 4 +- .../libs/minikin/MinikinFontFreeType.cpp | 4 +- .../flutter/libs/minikin/MinikinInternal.cpp | 6 +- .../flutter/libs/minikin/MinikinInternal.h | 6 +- .../libs/minikin/MinikinRefCounted.cpp | 8 +-- .../src/flutter/libs/minikin/SparseBitSet.cpp | 4 +- .../src/flutter/libs/minikin/WordBreaker.cpp | 4 +- .../libs/minikin/unicode_emoji_h_gen.py | 4 +- engine/src/flutter/sample/MinikinSkia.cpp | 4 +- engine/src/flutter/sample/MinikinSkia.h | 19 +++++- engine/src/flutter/sample/example.cpp | 1 - engine/src/flutter/sample/example_skia.cpp | 6 +- .../flutter/tests/perftests/FontLanguage.cpp | 4 +- .../unittest/FontCollectionItemizeTest.cpp | 23 +++---- .../tests/unittest/FontCollectionTest.cpp | 4 +- .../flutter/tests/unittest/FontFamilyTest.cpp | 12 ++-- .../unittest/FontLanguageListCacheTest.cpp | 8 +-- .../tests/unittest/GraphemeBreakTests.cpp | 4 +- .../tests/unittest/HbFontCacheTest.cpp | 12 ++-- .../src/flutter/tests/unittest/ICUTestBase.h | 4 +- .../tests/unittest/LayoutUtilsTest.cpp | 4 +- .../tests/unittest/MinikinInternalTest.cpp | 4 +- .../tests/unittest/WordBreakerTests.cpp | 4 +- .../src/flutter/tests/util/FontTestUtils.cpp | 22 ++++--- engine/src/flutter/tests/util/FontTestUtils.h | 5 +- .../flutter/tests/util/MinikinFontForTest.cpp | 12 ++-- .../flutter/tests/util/MinikinFontForTest.h | 14 +++-- .../src/flutter/tests/util/UnicodeUtils.cpp | 4 ++ engine/src/flutter/tests/util/UnicodeUtils.h | 6 +- 61 files changed, 238 insertions(+), 198 deletions(-) diff --git a/engine/src/flutter/app/HyphTool.cpp b/engine/src/flutter/app/HyphTool.cpp index 730abadcba..e421cf9671 100644 --- a/engine/src/flutter/app/HyphTool.cpp +++ b/engine/src/flutter/app/HyphTool.cpp @@ -7,7 +7,7 @@ #include #include -using android::Hyphenator; +using minikin::Hyphenator; Hyphenator* loadHybFile(const char* fn) { struct stat statbuf; diff --git a/engine/src/flutter/include/minikin/AnalyzeStyle.h b/engine/src/flutter/include/minikin/AnalyzeStyle.h index 298947742a..b4cd915108 100644 --- a/engine/src/flutter/include/minikin/AnalyzeStyle.h +++ b/engine/src/flutter/include/minikin/AnalyzeStyle.h @@ -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 \ No newline at end of file +#endif // MINIKIN_ANALYZE_STYLE_H diff --git a/engine/src/flutter/include/minikin/CmapCoverage.h b/engine/src/flutter/include/minikin/CmapCoverage.h index 56abac7bec..19b43f38de 100644 --- a/engine/src/flutter/include/minikin/CmapCoverage.h +++ b/engine/src/flutter/include/minikin/CmapCoverage.h @@ -19,7 +19,7 @@ #include -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 diff --git a/engine/src/flutter/include/minikin/FontCollection.h b/engine/src/flutter/include/minikin/FontCollection.h index c3c183db3b..c9c8520be6 100644 --- a/engine/src/flutter/include/minikin/FontCollection.h +++ b/engine/src/flutter/include/minikin/FontCollection.h @@ -23,7 +23,7 @@ #include #include -namespace android { +namespace minikin { class FontCollection : public MinikinRefCounted { public: @@ -98,6 +98,6 @@ private: std::vector mRanges; }; -} // namespace android +} // namespace minikin #endif // MINIKIN_FONT_COLLECTION_H diff --git a/engine/src/flutter/include/minikin/FontFamily.h b/engine/src/flutter/include/minikin/FontFamily.h index 81033d23fd..f4b1f468d7 100644 --- a/engine/src/flutter/include/minikin/FontFamily.h +++ b/engine/src/flutter/include/minikin/FontFamily.h @@ -26,7 +26,7 @@ #include #include -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 diff --git a/engine/src/flutter/include/minikin/GraphemeBreak.h b/engine/src/flutter/include/minikin/GraphemeBreak.h index 3120101585..b501f6784f 100644 --- a/engine/src/flutter/include/minikin/GraphemeBreak.h +++ b/engine/src/flutter/include/minikin/GraphemeBreak.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 \ No newline at end of file +#endif // MINIKIN_GRAPHEME_BREAK_H diff --git a/engine/src/flutter/include/minikin/Hyphenator.h b/engine/src/flutter/include/minikin/Hyphenator.h index 9605205a29..f922dcbfb7 100644 --- a/engine/src/flutter/include/minikin/Hyphenator.h +++ b/engine/src/flutter/include/minikin/Hyphenator.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 diff --git a/engine/src/flutter/include/minikin/Layout.h b/engine/src/flutter/include/minikin/Layout.h index d9bb01f1a7..87d5e0534b 100644 --- a/engine/src/flutter/include/minikin/Layout.h +++ b/engine/src/flutter/include/minikin/Layout.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 diff --git a/engine/src/flutter/include/minikin/LineBreaker.h b/engine/src/flutter/include/minikin/LineBreaker.h index 1d81404045..feaffe74e3 100644 --- a/engine/src/flutter/include/minikin/LineBreaker.h +++ b/engine/src/flutter/include/minikin/LineBreaker.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 diff --git a/engine/src/flutter/include/minikin/Measurement.h b/engine/src/flutter/include/minikin/Measurement.h index 7bcab669de..b00c2120a7 100644 --- a/engine/src/flutter/include/minikin/Measurement.h +++ b/engine/src/flutter/include/minikin/Measurement.h @@ -19,7 +19,7 @@ #include -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 diff --git a/engine/src/flutter/include/minikin/MinikinFont.h b/engine/src/flutter/include/minikin/MinikinFont.h index 4951514518..9d4f937089 100644 --- a/engine/src/flutter/include/minikin/MinikinFont.h +++ b/engine/src/flutter/include/minikin/MinikinFont.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 diff --git a/engine/src/flutter/include/minikin/MinikinFontFreeType.h b/engine/src/flutter/include/minikin/MinikinFontFreeType.h index baa08df3b7..34c3fd92d4 100644 --- a/engine/src/flutter/include/minikin/MinikinFontFreeType.h +++ b/engine/src/flutter/include/minikin/MinikinFontFreeType.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 diff --git a/engine/src/flutter/include/minikin/MinikinRefCounted.h b/engine/src/flutter/include/minikin/MinikinRefCounted.h index 603aff0cce..0ee44747c1 100644 --- a/engine/src/flutter/include/minikin/MinikinRefCounted.h +++ b/engine/src/flutter/include/minikin/MinikinRefCounted.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 \ No newline at end of file +#endif // MINIKIN_REF_COUNTED_H diff --git a/engine/src/flutter/include/minikin/SparseBitSet.h b/engine/src/flutter/include/minikin/SparseBitSet.h index 72b83057c6..00babbbf2f 100644 --- a/engine/src/flutter/include/minikin/SparseBitSet.h +++ b/engine/src/flutter/include/minikin/SparseBitSet.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 diff --git a/engine/src/flutter/include/minikin/WordBreaker.h b/engine/src/flutter/include/minikin/WordBreaker.h index 4eff9d1755..0f95bb208a 100644 --- a/engine/src/flutter/include/minikin/WordBreaker.h +++ b/engine/src/flutter/include/minikin/WordBreaker.h @@ -26,7 +26,7 @@ #include "unicode/brkiter.h" #include -namespace android { +namespace minikin { class WordBreaker { public: @@ -68,6 +68,6 @@ private: bool mInEmailOrUrl; }; -} // namespace +} // namespace minikin #endif // MINIKIN_WORD_BREAKER_H diff --git a/engine/src/flutter/libs/minikin/AnalyzeStyle.cpp b/engine/src/flutter/libs/minikin/AnalyzeStyle.cpp index 0961645290..333f008f7f 100644 --- a/engine/src/flutter/libs/minikin/AnalyzeStyle.cpp +++ b/engine/src/flutter/libs/minikin/AnalyzeStyle.cpp @@ -19,7 +19,7 @@ #include -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 diff --git a/engine/src/flutter/libs/minikin/CmapCoverage.cpp b/engine/src/flutter/libs/minikin/CmapCoverage.cpp index 2961d2ffa8..3dc2cd3074 100644 --- a/engine/src/flutter/libs/minikin/CmapCoverage.cpp +++ b/engine/src/flutter/libs/minikin/CmapCoverage.cpp @@ -25,7 +25,7 @@ using std::vector; #include #include -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 diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index b1b0aaf95f..90b67d2550 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -30,7 +30,7 @@ using std::vector; -namespace android { +namespace minikin { template static inline T max(T a, T b) { @@ -77,7 +77,7 @@ uint32_t FontCollection::sNextId = 0; FontCollection::FontCollection(const vector& typefaces) : mMaxChar(0) { - AutoMutex _l(gMinikinLock); + android::AutoMutex _l(gMinikinLock); mId = sNextId++; vector 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 diff --git a/engine/src/flutter/libs/minikin/FontFamily.cpp b/engine/src/flutter/libs/minikin/FontFamily.cpp index e2d86f0bbb..99edb87473 100644 --- a/engine/src/flutter/libs/minikin/FontFamily.cpp +++ b/engine/src/flutter/libs/minikin/FontFamily.cpp @@ -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 diff --git a/engine/src/flutter/libs/minikin/FontLanguage.cpp b/engine/src/flutter/libs/minikin/FontLanguage.cpp index bccb4bf9e8..9cfa0aa664 100644 --- a/engine/src/flutter/libs/minikin/FontLanguage.cpp +++ b/engine/src/flutter/libs/minikin/FontLanguage.cpp @@ -21,7 +21,7 @@ #include #include -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&& languages) } #undef SCRIPT_TAG -} // namespace android +} // namespace minikin diff --git a/engine/src/flutter/libs/minikin/FontLanguage.h b/engine/src/flutter/libs/minikin/FontLanguage.h index f944174a86..f28a4a8e72 100644 --- a/engine/src/flutter/libs/minikin/FontLanguage.h +++ b/engine/src/flutter/libs/minikin/FontLanguage.h @@ -22,7 +22,7 @@ #include -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 diff --git a/engine/src/flutter/libs/minikin/FontLanguageListCache.cpp b/engine/src/flutter/libs/minikin/FontLanguageListCache.cpp index 6b661f0384..bf46d4f6ea 100644 --- a/engine/src/flutter/libs/minikin/FontLanguageListCache.cpp +++ b/engine/src/flutter/libs/minikin/FontLanguageListCache.cpp @@ -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 diff --git a/engine/src/flutter/libs/minikin/FontLanguageListCache.h b/engine/src/flutter/libs/minikin/FontLanguageListCache.h index c961882f0a..9bf156f9de 100644 --- a/engine/src/flutter/libs/minikin/FontLanguageListCache.h +++ b/engine/src/flutter/libs/minikin/FontLanguageListCache.h @@ -22,7 +22,7 @@ #include #include "FontLanguage.h" -namespace android { +namespace minikin { class FontLanguageListCache { public: @@ -51,6 +51,6 @@ private: std::unordered_map mLanguageListLookupTable; }; -} // namespace android +} // namespace minikin #endif // MINIKIN_FONT_LANGUAGE_LIST_CACHE_H diff --git a/engine/src/flutter/libs/minikin/GraphemeBreak.cpp b/engine/src/flutter/libs/minikin/GraphemeBreak.cpp index 45dd0fff69..dc5a761937 100644 --- a/engine/src/flutter/libs/minikin/GraphemeBreak.cpp +++ b/engine/src/flutter/libs/minikin/GraphemeBreak.cpp @@ -22,7 +22,7 @@ #include #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 diff --git a/engine/src/flutter/libs/minikin/HbFontCache.cpp b/engine/src/flutter/libs/minikin/HbFontCache.cpp index 3be942d7b9..45c3f5807b 100644 --- a/engine/src/flutter/libs/minikin/HbFontCache.cpp +++ b/engine/src/flutter/libs/minikin/HbFontCache.cpp @@ -26,7 +26,7 @@ #include #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(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(buffer), destroy); } -class HbFontCache : private OnEntryRemoved { +class HbFontCache : private android::OnEntryRemoved { public: HbFontCache() : mCache(kMaxEntries) { mCache.setOnEntryRemovedListener(this); @@ -74,7 +74,7 @@ public: private: static const size_t kMaxEntries = 100; - LruCache mCache; + android::LruCache mCache; }; HbFontCache* getFontCacheLocked() { @@ -141,4 +141,4 @@ hb_font_t* getHbFontLocked(MinikinFont* minikinFont) { return hb_font_reference(font); } -} // namespace android +} // namespace minikin diff --git a/engine/src/flutter/libs/minikin/HbFontCache.h b/engine/src/flutter/libs/minikin/HbFontCache.h index 449b354c2d..fba685aeb2 100644 --- a/engine/src/flutter/libs/minikin/HbFontCache.h +++ b/engine/src/flutter/libs/minikin/HbFontCache.h @@ -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 diff --git a/engine/src/flutter/libs/minikin/Hyphenator.cpp b/engine/src/flutter/libs/minikin/Hyphenator.cpp index c5eb60b8e5..c170c6bd48 100644 --- a/engine/src/flutter/libs/minikin/Hyphenator.cpp +++ b/engine/src/flutter/libs/minikin/Hyphenator.cpp @@ -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 diff --git a/engine/src/flutter/libs/minikin/Layout.cpp b/engine/src/flutter/libs/minikin/Layout.cpp index 9c1d6a873a..713ac84f0a 100644 --- a/engine/src/flutter/libs/minikin/Layout.cpp +++ b/engine/src/flutter/libs/minikin/Layout.cpp @@ -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 { +class LayoutCache : private android::OnEntryRemoved { public: LayoutCache() : mCache(kMaxEntries) { mCache.setOnEntryRemovedListener(this); @@ -190,7 +186,7 @@ private: delete value; } - LruCache mCache; + android::LruCache mCache; //static const size_t kMaxEntries = LruCache::kUnlimitedCapacity; @@ -204,7 +200,7 @@ static unsigned int disabledDecomposeCompatibility(hb_unicode_funcs_t*, hb_codep return 0; } -class LayoutEngine : public Singleton { +class LayoutEngine : public ::android::Singleton { 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 + diff --git a/engine/src/flutter/libs/minikin/LayoutUtils.cpp b/engine/src/flutter/libs/minikin/LayoutUtils.cpp index 418268286c..4e59afd6b2 100644 --- a/engine/src/flutter/libs/minikin/LayoutUtils.cpp +++ b/engine/src/flutter/libs/minikin/LayoutUtils.cpp @@ -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 diff --git a/engine/src/flutter/libs/minikin/LayoutUtils.h b/engine/src/flutter/libs/minikin/LayoutUtils.h index 83ddd0a255..f35e843cfa 100644 --- a/engine/src/flutter/libs/minikin/LayoutUtils.h +++ b/engine/src/flutter/libs/minikin/LayoutUtils.h @@ -19,6 +19,8 @@ #include +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 diff --git a/engine/src/flutter/libs/minikin/LineBreaker.cpp b/engine/src/flutter/libs/minikin/LineBreaker.cpp index 2a71f044d2..1940062eaf 100644 --- a/engine/src/flutter/libs/minikin/LineBreaker.cpp +++ b/engine/src/flutter/libs/minikin/LineBreaker.cpp @@ -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 diff --git a/engine/src/flutter/libs/minikin/Measurement.cpp b/engine/src/flutter/libs/minikin/Measurement.cpp index 1ba6678373..a9655e4eaf 100644 --- a/engine/src/flutter/libs/minikin/Measurement.cpp +++ b/engine/src/flutter/libs/minikin/Measurement.cpp @@ -23,7 +23,7 @@ #include #include -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 diff --git a/engine/src/flutter/libs/minikin/MinikinFont.cpp b/engine/src/flutter/libs/minikin/MinikinFont.cpp index ef42e9b12f..8aee01de7e 100644 --- a/engine/src/flutter/libs/minikin/MinikinFont.cpp +++ b/engine/src/flutter/libs/minikin/MinikinFont.cpp @@ -17,10 +17,10 @@ #include #include "HbFontCache.h" -namespace android { +namespace minikin { MinikinFont::~MinikinFont() { purgeHbFontLocked(this); } -} // namespace android +} // namespace minikin diff --git a/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp b/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp index 4a1b115082..6f56a8dd55 100644 --- a/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp +++ b/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp @@ -25,7 +25,7 @@ #include -namespace android { +namespace minikin { int32_t MinikinFontFreeType::sIdCounter = 0; @@ -97,4 +97,4 @@ MinikinFontFreeType* MinikinFontFreeType::GetFreeType() { return this; } -} // namespace android +} // namespace minikin diff --git a/engine/src/flutter/libs/minikin/MinikinInternal.cpp b/engine/src/flutter/libs/minikin/MinikinInternal.cpp index 7fcc7b7f8b..b1ca2df669 100644 --- a/engine/src/flutter/libs/minikin/MinikinInternal.cpp +++ b/engine/src/flutter/libs/minikin/MinikinInternal.cpp @@ -22,9 +22,9 @@ #include -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 diff --git a/engine/src/flutter/libs/minikin/MinikinInternal.h b/engine/src/flutter/libs/minikin/MinikinInternal.h index 88cc9475c8..88c0d5f510 100644 --- a/engine/src/flutter/libs/minikin/MinikinInternal.h +++ b/engine/src/flutter/libs/minikin/MinikinInternal.h @@ -25,13 +25,13 @@ #include -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 diff --git a/engine/src/flutter/libs/minikin/MinikinRefCounted.cpp b/engine/src/flutter/libs/minikin/MinikinRefCounted.cpp index 9fa3ae4631..6914a012f8 100644 --- a/engine/src/flutter/libs/minikin/MinikinRefCounted.cpp +++ b/engine/src/flutter/libs/minikin/MinikinRefCounted.cpp @@ -20,16 +20,16 @@ #include -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 diff --git a/engine/src/flutter/libs/minikin/SparseBitSet.cpp b/engine/src/flutter/libs/minikin/SparseBitSet.cpp index de0791445c..d78dd246ed 100644 --- a/engine/src/flutter/libs/minikin/SparseBitSet.cpp +++ b/engine/src/flutter/libs/minikin/SparseBitSet.cpp @@ -19,7 +19,7 @@ #include #include -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 diff --git a/engine/src/flutter/libs/minikin/WordBreaker.cpp b/engine/src/flutter/libs/minikin/WordBreaker.cpp index 38f03caf6a..a852eddddf 100644 --- a/engine/src/flutter/libs/minikin/WordBreaker.cpp +++ b/engine/src/flutter/libs/minikin/WordBreaker.cpp @@ -23,7 +23,7 @@ #include #include -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 diff --git a/engine/src/flutter/libs/minikin/unicode_emoji_h_gen.py b/engine/src/flutter/libs/minikin/unicode_emoji_h_gen.py index 7233ef621e..5186455188 100644 --- a/engine/src/flutter/libs/minikin/unicode_emoji_h_gen.py +++ b/engine/src/flutter/libs/minikin/unicode_emoji_h_gen.py @@ -27,7 +27,7 @@ UNICODE_EMOJI_TEMPLATE=""" #include -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 """ diff --git a/engine/src/flutter/sample/MinikinSkia.cpp b/engine/src/flutter/sample/MinikinSkia.cpp index e2ecde02d1..c920ca63e5 100644 --- a/engine/src/flutter/sample/MinikinSkia.cpp +++ b/engine/src/flutter/sample/MinikinSkia.cpp @@ -4,7 +4,7 @@ #include #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 diff --git a/engine/src/flutter/sample/MinikinSkia.h b/engine/src/flutter/sample/MinikinSkia.h index 6eb9065cc2..92f5ed2f52 100644 --- a/engine/src/flutter/sample/MinikinSkia.h +++ b/engine/src/flutter/sample/MinikinSkia.h @@ -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 diff --git a/engine/src/flutter/sample/example.cpp b/engine/src/flutter/sample/example.cpp index f4c6a07a4a..a27918ea75 100644 --- a/engine/src/flutter/sample/example.cpp +++ b/engine/src/flutter/sample/example.cpp @@ -28,7 +28,6 @@ #include using std::vector; -using namespace android; using namespace minikin; FT_Library library; // TODO: this should not be a global diff --git a/engine/src/flutter/sample/example_skia.cpp b/engine/src/flutter/sample/example_skia.cpp index f892b8c987..bd2d779b9e 100644 --- a/engine/src/flutter/sample/example_skia.cpp +++ b/engine/src/flutter/sample/example_skia.cpp @@ -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(); } diff --git a/engine/src/flutter/tests/perftests/FontLanguage.cpp b/engine/src/flutter/tests/perftests/FontLanguage.cpp index ac7af6f909..8f77e12b75 100644 --- a/engine/src/flutter/tests/perftests/FontLanguage.cpp +++ b/engine/src/flutter/tests/perftests/FontLanguage.cpp @@ -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 diff --git a/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp b/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp index 8ad9472490..8ae703ea12 100644 --- a/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp +++ b/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp @@ -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 families; - FontFamily* family1 = new FontFamily(android::VARIANT_DEFAULT); + std::vector 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 diff --git a/engine/src/flutter/tests/unittest/FontCollectionTest.cpp b/engine/src/flutter/tests/unittest/FontCollectionTest.cpp index 5a03f60d26..a22067a5b0 100644 --- a/engine/src/flutter/tests/unittest/FontCollectionTest.cpp +++ b/engine/src/flutter/tests/unittest/FontCollectionTest.cpp @@ -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 diff --git a/engine/src/flutter/tests/unittest/FontFamilyTest.cpp b/engine/src/flutter/tests/unittest/FontFamilyTest.cpp index 1b2457695c..384703f8c4 100644 --- a/engine/src/flutter/tests/unittest/FontFamilyTest.cpp +++ b/engine/src/flutter/tests/unittest/FontFamilyTest.cpp @@ -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 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 minikinFont(new MinikinFontForTest(testCase.fontPath)); MinikinAutoUnref 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 diff --git a/engine/src/flutter/tests/unittest/FontLanguageListCacheTest.cpp b/engine/src/flutter/tests/unittest/FontLanguageListCacheTest.cpp index 2a046713c9..81d84a8a28 100644 --- a/engine/src/flutter/tests/unittest/FontLanguageListCacheTest.cpp +++ b/engine/src/flutter/tests/unittest/FontLanguageListCacheTest.cpp @@ -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 diff --git a/engine/src/flutter/tests/unittest/GraphemeBreakTests.cpp b/engine/src/flutter/tests/unittest/GraphemeBreakTests.cpp index cec5308877..07ddf82ce6 100644 --- a/engine/src/flutter/tests/unittest/GraphemeBreakTests.cpp +++ b/engine/src/flutter/tests/unittest/GraphemeBreakTests.cpp @@ -18,7 +18,7 @@ #include #include -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 diff --git a/engine/src/flutter/tests/unittest/HbFontCacheTest.cpp b/engine/src/flutter/tests/unittest/HbFontCacheTest.cpp index 2dee61aff0..82adc4f768 100644 --- a/engine/src/flutter/tests/unittest/HbFontCacheTest.cpp +++ b/engine/src/flutter/tests/unittest/HbFontCacheTest.cpp @@ -26,19 +26,18 @@ #include "MinikinFontForTest.h" #include -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 diff --git a/engine/src/flutter/tests/unittest/ICUTestBase.h b/engine/src/flutter/tests/unittest/ICUTestBase.h index 3bcfaf3694..f915cf80ce 100644 --- a/engine/src/flutter/tests/unittest/ICUTestBase.h +++ b/engine/src/flutter/tests/unittest/ICUTestBase.h @@ -26,6 +26,8 @@ #include #include +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 diff --git a/engine/src/flutter/tests/unittest/LayoutUtilsTest.cpp b/engine/src/flutter/tests/unittest/LayoutUtilsTest.cpp index f4fbb18107..e7e6c273d6 100644 --- a/engine/src/flutter/tests/unittest/LayoutUtilsTest.cpp +++ b/engine/src/flutter/tests/unittest/LayoutUtilsTest.cpp @@ -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 diff --git a/engine/src/flutter/tests/unittest/MinikinInternalTest.cpp b/engine/src/flutter/tests/unittest/MinikinInternalTest.cpp index 9c1a1e54a4..e314dd1be5 100644 --- a/engine/src/flutter/tests/unittest/MinikinInternalTest.cpp +++ b/engine/src/flutter/tests/unittest/MinikinInternalTest.cpp @@ -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 diff --git a/engine/src/flutter/tests/unittest/WordBreakerTests.cpp b/engine/src/flutter/tests/unittest/WordBreakerTests.cpp index 8ed87cc506..bacf3178a1 100644 --- a/engine/src/flutter/tests/unittest/WordBreakerTests.cpp +++ b/engine/src/flutter/tests/unittest/WordBreakerTests.cpp @@ -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 diff --git a/engine/src/flutter/tests/util/FontTestUtils.cpp b/engine/src/flutter/tests/util/FontTestUtils.cpp index fdc3ed6ee9..76d3ea20a2 100644 --- a/engine/src/flutter/tests/util/FontTestUtils.cpp +++ b/engine/src/flutter/tests/util/FontTestUtils.cpp @@ -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 families; + std::vector 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 diff --git a/engine/src/flutter/tests/util/FontTestUtils.h b/engine/src/flutter/tests/util/FontTestUtils.h index 5258a766ae..69ba841b43 100644 --- a/engine/src/flutter/tests/util/FontTestUtils.h +++ b/engine/src/flutter/tests/util/FontTestUtils.h @@ -19,6 +19,8 @@ #include +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 diff --git a/engine/src/flutter/tests/util/MinikinFontForTest.cpp b/engine/src/flutter/tests/util/MinikinFontForTest.cpp index 66dd4ea473..ae8ef72bcf 100644 --- a/engine/src/flutter/tests/util/MinikinFontForTest.cpp +++ b/engine/src/flutter/tests/util/MinikinFontForTest.cpp @@ -22,6 +22,8 @@ #include +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 diff --git a/engine/src/flutter/tests/util/MinikinFontForTest.h b/engine/src/flutter/tests/util/MinikinFontForTest.h index e527d21e34..56f63adaff 100644 --- a/engine/src/flutter/tests/util/MinikinFontForTest.h +++ b/engine/src/flutter/tests/util/MinikinFontForTest.h @@ -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 diff --git a/engine/src/flutter/tests/util/UnicodeUtils.cpp b/engine/src/flutter/tests/util/UnicodeUtils.cpp index 501fc9f480..bb652ff63d 100644 --- a/engine/src/flutter/tests/util/UnicodeUtils.cpp +++ b/engine/src/flutter/tests/util/UnicodeUtils.cpp @@ -18,6 +18,8 @@ #include #include +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 diff --git a/engine/src/flutter/tests/util/UnicodeUtils.h b/engine/src/flutter/tests/util/UnicodeUtils.h index 4f1b06a2fc..64b90c91b1 100644 --- a/engine/src/flutter/tests/util/UnicodeUtils.h +++ b/engine/src/flutter/tests/util/UnicodeUtils.h @@ -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