diff --git a/engine/src/flutter/include/minikin/Layout.h b/engine/src/flutter/include/minikin/Layout.h index 83eb963b717..cb68db9c3dd 100644 --- a/engine/src/flutter/include/minikin/Layout.h +++ b/engine/src/flutter/include/minikin/Layout.h @@ -59,7 +59,7 @@ struct LayoutGlyph { }; // Internal state used during layout operation -class LayoutContext; +struct LayoutContext; enum { kBidi_LTR = 0, diff --git a/engine/src/flutter/libs/minikin/Android.mk b/engine/src/flutter/libs/minikin/Android.mk index 4d34c114702..c728b09b84e 100644 --- a/engine/src/flutter/libs/minikin/Android.mk +++ b/engine/src/flutter/libs/minikin/Android.mk @@ -50,6 +50,7 @@ LOCAL_MODULE := libminikin LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include LOCAL_SRC_FILES := $(minikin_src_files) LOCAL_C_INCLUDES := $(minikin_c_includes) +LOCAL_CPPFLAGS += -Werror -Wall -Wextra LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries) include $(BUILD_SHARED_LIBRARY) @@ -61,6 +62,7 @@ LOCAL_MODULE_TAGS := optional LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include LOCAL_SRC_FILES := $(minikin_src_files) LOCAL_C_INCLUDES := $(minikin_c_includes) +LOCAL_CPPFLAGS += -Werror -Wall -Wextra LOCAL_SHARED_LIBRARIES := $(minikin_shared_libraries) include $(BUILD_STATIC_LIBRARY) @@ -73,6 +75,7 @@ LOCAL_MODULE := libminikin_host LOCAL_MODULE_TAGS := optional LOCAL_EXPORT_C_INCLUDE_DIRS := frameworks/minikin/include LOCAL_C_INCLUDES := $(minikin_c_includes) +LOCAL_CPPFLAGS += -Werror -Wall -Wextra LOCAL_SHARED_LIBRARIES := liblog libicuuc-host LOCAL_SRC_FILES := Hyphenator.cpp diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index 4c0070c2b1e..2c228802597 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -43,7 +43,7 @@ FontCollection::FontCollection(const vector& typefaces) : vector lastChar; size_t nTypefaces = typefaces.size(); #ifdef VERBOSE_DEBUG - ALOGD("nTypefaces = %d\n", nTypefaces); + ALOGD("nTypefaces = %zd\n", nTypefaces); #endif const FontStyle defaultStyle; for (size_t i = 0; i < nTypefaces; i++) { @@ -72,7 +72,7 @@ FontCollection::FontCollection(const vector& typefaces) : mRanges.push_back(dummy); Range* range = &mRanges.back(); #ifdef VERBOSE_DEBUG - ALOGD("i=%d: range start = %d\n", i, offset); + ALOGD("i=%zd: range start = %zd\n", i, offset); #endif range->start = offset; for (size_t j = 0; j < nTypefaces; j++) { @@ -82,7 +82,7 @@ FontCollection::FontCollection(const vector& typefaces) : offset++; uint32_t nextChar = family->getCoverage()->nextSetBit((i + 1) << kLogCharsPerPage); #ifdef VERBOSE_DEBUG - ALOGD("nextChar = %d (j = %d)\n", nextChar, j); + ALOGD("nextChar = %d (j = %zd)\n", nextChar, j); #endif lastChar[j] = nextChar; } @@ -110,7 +110,7 @@ FontFamily* FontCollection::getFamilyForChar(uint32_t ch, uint32_t vs, } const Range& range = mRanges[ch >> kLogCharsPerPage]; #ifdef VERBOSE_DEBUG - ALOGD("querying range %d:%d\n", range.start, range.end); + ALOGD("querying range %zd:%zd\n", range.start, range.end); #endif FontFamily* bestFamily = nullptr; int bestScore = -1; diff --git a/engine/src/flutter/libs/minikin/FontFamily.cpp b/engine/src/flutter/libs/minikin/FontFamily.cpp index dfd37fe5930..1ff5a6bce4b 100644 --- a/engine/src/flutter/libs/minikin/FontFamily.cpp +++ b/engine/src/flutter/libs/minikin/FontFamily.cpp @@ -258,8 +258,8 @@ const SparseBitSet* FontFamily::getCoverage() { } CmapCoverage::getCoverage(mCoverage, cmapData.get(), cmapSize); // TODO: Error check? #ifdef VERBOSE_DEBUG - ALOGD("font coverage length=%d, first ch=%x\n", mCoverage->length(), - mCoverage->nextSetBit(0)); + ALOGD("font coverage length=%d, first ch=%x\n", mCoverage.length(), + mCoverage.nextSetBit(0)); #endif mCoverageValid = true; } diff --git a/engine/src/flutter/libs/minikin/HbFaceCache.cpp b/engine/src/flutter/libs/minikin/HbFaceCache.cpp index fde2fa869f2..235f7f1b0c2 100644 --- a/engine/src/flutter/libs/minikin/HbFaceCache.cpp +++ b/engine/src/flutter/libs/minikin/HbFaceCache.cpp @@ -18,6 +18,7 @@ #include "HbFaceCache.h" +#include #include #include @@ -26,7 +27,7 @@ namespace android { -static hb_blob_t* referenceTable(hb_face_t* face, hb_tag_t tag, void* userData) { +static hb_blob_t* referenceTable(hb_face_t* /* face */, hb_tag_t tag, void* userData) { MinikinFont* font = reinterpret_cast(userData); size_t length = 0; bool ok = font->GetTable(tag, NULL, &length); @@ -39,7 +40,7 @@ static hb_blob_t* referenceTable(hb_face_t* face, hb_tag_t tag, void* userData) } ok = font->GetTable(tag, reinterpret_cast(buffer), &length); #ifdef VERBOSE_DEBUG - ALOGD("referenceTable %c%c%c%c length=%d %d", + ALOGD("referenceTable %c%c%c%c length=%zd %d", (tag >>24)&0xff, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff, length, ok); #endif if (!ok) { @@ -50,11 +51,6 @@ static hb_blob_t* referenceTable(hb_face_t* face, hb_tag_t tag, void* userData) HB_MEMORY_MODE_WRITABLE, buffer, free); } -static unsigned int disabledDecomposeCompatibility( - hb_unicode_funcs_t*, hb_codepoint_t, hb_codepoint_t*, void*) { - return 0; -} - class HbFaceCache : private OnEntryRemoved { public: HbFaceCache() : mCache(kMaxEntries) { @@ -62,7 +58,7 @@ public: } // callback for OnEntryRemoved - void operator()(int32_t& key, hb_face_t*& value) { + void operator()(int32_t& /* key */, hb_face_t*& value) { hb_face_destroy(value); } diff --git a/engine/src/flutter/libs/minikin/Layout.cpp b/engine/src/flutter/libs/minikin/Layout.cpp index 6d62d5d7d8e..3b140faa2b8 100644 --- a/engine/src/flutter/libs/minikin/Layout.cpp +++ b/engine/src/flutter/libs/minikin/Layout.cpp @@ -276,16 +276,17 @@ void Layout::setFontCollection(const FontCollection* collection) { mCollection = collection; } -static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData) -{ +static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* /* hbFont */, void* fontData, + hb_codepoint_t glyph, void* /* userData */) { MinikinPaint* paint = reinterpret_cast(fontData); MinikinFont* font = paint->font; float advance = font->GetHorizontalAdvance(glyph, *paint); return 256 * advance + 0.5; } -static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData) -{ +static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t* /* hbFont */, void* /* fontData */, + hb_codepoint_t /* glyph */, hb_position_t* /* x */, hb_position_t* /* y */, + void* /* userData */) { // Just return true, following the way that Harfbuzz-FreeType // implementation does. return true; @@ -709,7 +710,7 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t ctx->paint.fakery = mFaces[font_ix].fakery; hb_font_t* hbFont = ctx->hbFonts[font_ix]; #ifdef VERBOSE_DEBUG - ALOGD("Run %u, font %d [%d:%d]", run_ix, font_ix, run.start, run.end); + ALOGD("Run %zu, font %d [%d:%d]", run_ix, font_ix, run.start, run.end); #endif hb_font_set_ppem(hbFont, size * scaleX, size); @@ -804,7 +805,7 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t if (info[i].cluster - start < count) { mAdvances[info[i].cluster - start] += xAdvance; } else { - ALOGE("cluster %d (start %d) out of bounds of count %d", + ALOGE("cluster %zu (start %zu) out of bounds of count %zu", info[i].cluster - start, start, count); } x += xAdvance; diff --git a/engine/src/flutter/libs/minikin/LineBreaker.cpp b/engine/src/flutter/libs/minikin/LineBreaker.cpp index a832ca20e26..a2507e0ba87 100644 --- a/engine/src/flutter/libs/minikin/LineBreaker.cpp +++ b/engine/src/flutter/libs/minikin/LineBreaker.cpp @@ -249,7 +249,7 @@ void LineBreaker::addWordBreak(size_t offset, ParaWidth preBreak, ParaWidth post cand.penalty = SCORE_DESPERATE; cand.hyphenEdit = 0; #if VERBOSE_DEBUG - ALOGD("desperate cand: %d %g:%g", + ALOGD("desperate cand: %zd %g:%g", mCandidates.size(), cand.postBreak, cand.preBreak); #endif addCandidate(cand); @@ -264,7 +264,7 @@ void LineBreaker::addWordBreak(size_t offset, ParaWidth preBreak, ParaWidth post cand.penalty = penalty; cand.hyphenEdit = hyph; #if VERBOSE_DEBUG - ALOGD("cand: %d %g:%g", mCandidates.size(), cand.postBreak, cand.preBreak); + ALOGD("cand: %zd %g:%g", mCandidates.size(), cand.postBreak, cand.preBreak); #endif addCandidate(cand); } @@ -409,7 +409,7 @@ void LineBreaker::computeBreaksOptimal(bool isRectangle) { mCandidates[i].prev = bestPrev; mCandidates[i].lineNumber = mCandidates[bestPrev].lineNumber + 1; #if VERBOSE_DEBUG - ALOGD("break %d: score=%g, prev=%d", i, mCandidates[i].score, mCandidates[i].prev); + ALOGD("break %zd: score=%g, prev=%zd", i, mCandidates[i].score, mCandidates[i].prev); #endif } finishBreaksOptimal(); diff --git a/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp b/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp index cbeed615932..c9eb456be5f 100644 --- a/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp +++ b/engine/src/flutter/libs/minikin/MinikinFontFreeType.cpp @@ -47,8 +47,8 @@ float MinikinFontFreeType::GetHorizontalAdvance(uint32_t glyph_id, return advance * (1.0 / 65536); } -void MinikinFontFreeType::GetBounds(MinikinRect* bounds, uint32_t glyph_id, - const MinikinPaint& paint) const { +void MinikinFontFreeType::GetBounds(MinikinRect* /* bounds */, uint32_t /* glyph_id*/, + const MinikinPaint& /* paint */) const { // TODO: NYI } @@ -66,8 +66,8 @@ int32_t MinikinFontFreeType::GetUniqueId() const { return mUniqueId; } -bool MinikinFontFreeType::Render(uint32_t glyph_id, - const MinikinPaint &paint, GlyphBitmap *result) { +bool MinikinFontFreeType::Render(uint32_t glyph_id, const MinikinPaint& /* paint */, + GlyphBitmap *result) { FT_Error error; FT_Int32 load_flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings error = FT_Load_Glyph(mTypeface, glyph_id, load_flags); diff --git a/engine/src/flutter/tests/Android.mk b/engine/src/flutter/tests/Android.mk index b69b8f243f6..b6bc15c0dcf 100644 --- a/engine/src/flutter/tests/Android.mk +++ b/engine/src/flutter/tests/Android.mk @@ -54,4 +54,6 @@ LOCAL_C_INCLUDES := \ external/libxml2/include \ external/skia/src/core +LOCAL_CPPFLAGS += -Werror -Wall -Wextra + include $(BUILD_NATIVE_TEST) diff --git a/engine/src/flutter/tests/HbFaceCacheTest.cpp b/engine/src/flutter/tests/HbFaceCacheTest.cpp index fbaf0eab150..76eec5b5a83 100644 --- a/engine/src/flutter/tests/HbFaceCacheTest.cpp +++ b/engine/src/flutter/tests/HbFaceCacheTest.cpp @@ -35,18 +35,18 @@ public: MockMinikinFont(int32_t id) : mId(id) { } - virtual float GetHorizontalAdvance( - uint32_t glyph_id, const MinikinPaint &paint) const { + virtual float GetHorizontalAdvance(uint32_t /* glyph_id */, + const MinikinPaint& /* paint */) const { LOG_ALWAYS_FATAL("MockMinikinFont::GetHorizontalAdvance is not implemented."); return 0.0f; } - virtual void GetBounds(MinikinRect* bounds, uint32_t glyph_id, - const MinikinPaint &paint) const { + virtual void GetBounds(MinikinRect* /* bounds */, uint32_t /* glyph_id */, + const MinikinPaint& /* paint */) const { LOG_ALWAYS_FATAL("MockMinikinFont::GetBounds is not implemented."); } - virtual bool GetTable(uint32_t tag, uint8_t *buf, size_t *size) { + virtual bool GetTable(uint32_t /* tag */, uint8_t* /* buf */, size_t* /* size */) { LOG_ALWAYS_FATAL("MockMinikinFont::GetTable is not implemented."); return false; } diff --git a/engine/src/flutter/tests/MinikinFontForTest.cpp b/engine/src/flutter/tests/MinikinFontForTest.cpp index 033241e26dc..ed7075188b5 100644 --- a/engine/src/flutter/tests/MinikinFontForTest.cpp +++ b/engine/src/flutter/tests/MinikinFontForTest.cpp @@ -29,14 +29,14 @@ MinikinFontForTest::MinikinFontForTest(const std::string& font_path) : mFontPath MinikinFontForTest::~MinikinFontForTest() { } -float MinikinFontForTest::GetHorizontalAdvance( - uint32_t glyph_id, const android::MinikinPaint &paint) const { +float MinikinFontForTest::GetHorizontalAdvance(uint32_t /* glyph_id */, + const android::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(android::MinikinRect* /* bounds */, uint32_t /* glyph_id */, + const android::MinikinPaint& /* paint */) const { LOG_ALWAYS_FATAL("MinikinFontForTest::GetBounds is not yet implemented"); }