Implement getMinLineWidth for LineWidthDelegate

Minikin needs getMinLineWidth() implemented for supporting desperate
breaks in optimal line breaking. This CL implements it for
StaticLayout.

Bug: 68058572
Test: bit CtsTextTestCases:android.text.cts.StaticLayoutLineBreakingTest
Change-Id: I56f6a592c688d816c201279d35fad65e36dffd84
diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp
index c1419ba..d89c833 100644
--- a/core/jni/android_text_StaticLayout.cpp
+++ b/core/jni/android_text_StaticLayout.cpp
@@ -67,6 +67,18 @@
             return width - get(mIndents, lineNo);
         }
 
+        float getMinLineWidth() override {
+            // A simpler algorithm would have been simply looping until the larger of
+            // mFirstLineCount and mIndents.size()-mOffset, but that does unnecessary calculations
+            // when mFirstLineCount is large. Instead, we measure the first line, all the lines that
+            // have an indent, and the first line after firstWidth ends and restWidth starts.
+            float minWidth = std::min(getLineWidth(0), getLineWidth(mFirstLineCount));
+            for (size_t lineNo = 1; lineNo + mOffset < mIndents.size(); lineNo++) {
+                minWidth = std::min(minWidth, getLineWidth(lineNo));
+            }
+            return minWidth;
+        }
+
         float getLeftPadding(size_t lineNo) override {
             return get(mLeftPaddings, lineNo);
         }