diff --git a/engine/flutter/third_party/txt/src/minikin/FontFamily.h b/engine/flutter/third_party/txt/src/minikin/FontFamily.h index aedb92cf7d9419353ccef960ec01a1369da79302..4abe3a206cdf08c96e871352e2a7172251c949d7 100644 --- a/engine/flutter/third_party/txt/src/minikin/FontFamily.h +++ b/engine/flutter/third_party/txt/src/minikin/FontFamily.h @@ -74,6 +74,7 @@ class FontStyle { static uint32_t pack(int variant, int weight, bool italic); +public: uint32_t bits; uint32_t mLanguageListId; }; diff --git a/engine/flutter/third_party/txt/src/minikin/Hyphenator.h b/engine/flutter/third_party/txt/src/minikin/Hyphenator.h index a627a6078e8872078b14aa65d781350ca79cf0dc..97ab237db24337378840b9237e38fcffaeca8799 100644 --- a/engine/flutter/third_party/txt/src/minikin/Hyphenator.h +++ b/engine/flutter/third_party/txt/src/minikin/Hyphenator.h @@ -120,6 +120,7 @@ class HyphenEdit { uint32_t getStart() const { return hyphen & MASK_START_OF_LINE; } private: + public: uint32_t hyphen; }; diff --git a/engine/flutter/third_party/txt/src/minikin/Layout.cpp b/engine/flutter/third_party/txt/src/minikin/Layout.cpp index 1ce0712f4185b2ec2f7e619ccfd0a877f860b1bb..8cc418162a11675f72465c589dddc437e6f8764a 100644 --- a/engine/flutter/third_party/txt/src/minikin/Layout.cpp +++ b/engine/flutter/third_party/txt/src/minikin/Layout.cpp @@ -14,6 +14,12 @@ * limitations under the License. */ +#include +#include +#include +#include +#include +#include #define LOG_TAG "Minikin" #include @@ -62,7 +68,9 @@ struct LayoutContext { // Layout cache datatypes class LayoutCacheKey { + void log2file(FILE *f) const; public: + void log2file() const; LayoutCacheKey(const std::shared_ptr& collection, const MinikinPaint& paint, FontStyle style, @@ -145,7 +153,9 @@ class LayoutCache : private android::OnEntryRemoved { key.copyText(); layout = new Layout(); key.doLayout(layout, ctx, collection); + key.log2file(); mCache.put(key, layout); + ALOGE(mCache.size()); } return layout; } @@ -185,6 +195,40 @@ class LayoutEngine { } }; +void LayoutCacheKey::log2file(FILE *f) const +{ + time_t t=time(0); + static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock(&m); + fprintf(f, "%.24s: LayoutCacheKey(%p): mId(%u), mStart(%zu), mCount(%zu), mStyle(%u,%u), mSize(%f), mScaleX(%f), mSkewX(%f), mLetterSpacing(%f), mPaintFlags(%d), mHyphenEdit(%u), mIsRtl(%d), mNchars(%zu), mChars(", + ctime(&t), this, mId , mStart , mCount , mStyle.bits, mStyle.mLanguageListId , mSize , mScaleX , mSkewX , mLetterSpacing , mPaintFlags , mHyphenEdit.hyphen , mIsRtl , mNchars); + if (mNchars) fprintf(f, "%04hx", mChars[0]); + for (size_t i=1; i, char16_t> conv; + char16_t *p = (char16_t*)mChars; + static_assert(sizeof(char16_t) == sizeof(uint16_t), "char16_t == uint16_t"); + auto s = conv.to_bytes(p, p+mNchars); + fprintf(f, "(%s)", s.c_str()); + fprintf(f, "\n"); + pthread_mutex_unlock(&m); +} + +void LayoutCacheKey::log2file() const +{ + char tmp[64]; + sprintf(tmp, "/dev/asan/LayoutCacheKey_%d.txt", getpid()); + FILE *fp = fopen(tmp, "a"); + if (fp) { + log2file(fp); + fclose(fp); + } else { + ALOGE("open LayoutCacheKey log file fail"); + } +} + bool LayoutCacheKey::operator==(const LayoutCacheKey& other) const { return mId == other.mId && mStart == other.mStart && mCount == other.mCount && mStyle == other.mStyle && mSize == other.mSize &&