diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-30 03:19:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-30 03:19:13 +0000 |
commit | cf07457a31c8183ae97b5294f5c14a86a146ed73 (patch) | |
tree | a616d86900046dbc791fcb1e17ff29e92e4ef363 | |
parent | 76bb3cd4b66dc86bd80c52ee74d980dde332b70f (diff) | |
parent | 211125ea3a4691ba68026b744531d5fdcc8ff32d (diff) | |
download | minikin-cf07457a31c8183ae97b5294f5c14a86a146ed73.tar.gz |
Snap for 10884074 from 211125ea3a4691ba68026b744531d5fdcc8ff32d to 24Q1-release
Change-Id: Ie2dd6572618acaa62594a5ba9bbb7e9d94bd6a09
-rw-r--r-- | TEST_MAPPING | 4 | ||||
-rw-r--r-- | libs/minikin/Android.bp | 2 | ||||
-rw-r--r-- | libs/minikin/FeatureFlags.h | 42 | ||||
-rw-r--r-- | libs/minikin/GreedyLineBreaker.cpp | 15 | ||||
-rw-r--r-- | libs/minikin/OptimalLineBreaker.cpp | 4 | ||||
-rw-r--r-- | tests/perftests/Android.bp | 1 | ||||
-rw-r--r-- | tests/stresstest/Android.bp | 1 | ||||
-rw-r--r-- | tests/unittest/Android.bp | 1 |
8 files changed, 61 insertions, 9 deletions
diff --git a/TEST_MAPPING b/TEST_MAPPING index cef0b6b..287c353 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -7,7 +7,7 @@ "name": "CtsTextTestCases", "options": [ { - "exclude-annotation": "android.platform.test.annotations.FlakyTest" + "exclude-annotation": "androidx.test.filters.FlakyTest" }, { "exclude-annotation": "androidx.test.filters.LargeTest" @@ -18,7 +18,7 @@ "name": "CtsGraphicsTestCases", "options": [ { - "exclude-annotation": "android.platform.test.annotations.FlakyTest" + "exclude-annotation": "androidx.test.filters.FlakyTest" } ] } diff --git a/libs/minikin/Android.bp b/libs/minikin/Android.bp index 4cb76a2..4bce209 100644 --- a/libs/minikin/Android.bp +++ b/libs/minikin/Android.bp @@ -89,10 +89,12 @@ cc_library { android: { shared_libs: [ "libicu", + "aconfig_text_flags_c_lib", ], export_shared_lib_headers: [ "libicu", ], + cppflags: [ "-DUSE_FEATURE_FLAGS" ], }, host: { shared_libs: [ diff --git a/libs/minikin/FeatureFlags.h b/libs/minikin/FeatureFlags.h new file mode 100644 index 0000000..f5c1122 --- /dev/null +++ b/libs/minikin/FeatureFlags.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 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. + */ + +#ifndef MINIKIN_FEATURE_FLAGS_H +#define MINIKIN_FEATURE_FLAGS_H + +#ifdef USE_FEATURE_FLAGS +#include <com_android_text_flags.h> +#endif // USE_FEATURE_FLAGS + +namespace features { + +#ifdef USE_FEATURE_FLAGS + +inline bool phrase_strict_fallback() { + return com_android_text_flags_phrase_strict_fallback(); +} + +#else + +inline bool phrase_strict_fallback() { + return true; +} + +#endif // USE_FEATURE_FLAGS + +} // namespace features + +#endif // FEATURE_FLAGS diff --git a/libs/minikin/GreedyLineBreaker.cpp b/libs/minikin/GreedyLineBreaker.cpp index 5e11978..66e3dd9 100644 --- a/libs/minikin/GreedyLineBreaker.cpp +++ b/libs/minikin/GreedyLineBreaker.cpp @@ -16,17 +16,17 @@ #define LOG_TAG "GreedyLineBreak" -#include "minikin/Characters.h" -#include "minikin/LineBreaker.h" -#include "minikin/MeasuredText.h" -#include "minikin/Range.h" -#include "minikin/U16StringPiece.h" - +#include "FeatureFlags.h" #include "HyphenatorMap.h" #include "LineBreakerUtil.h" #include "Locale.h" #include "LocaleListCache.h" #include "WordBreaker.h" +#include "minikin/Characters.h" +#include "minikin/LineBreaker.h" +#include "minikin/MeasuredText.h" +#include "minikin/Range.h" +#include "minikin/U16StringPiece.h" namespace minikin { @@ -293,6 +293,9 @@ bool GreedyLineBreaker::doLineBreakWithGraphemeBounds(const Range& range) { } bool GreedyLineBreaker::doLineBreakWithFallback(const Range& range) { + if (!features::phrase_strict_fallback()) { + return false; + } Run* targetRun = nullptr; for (const auto& run : mMeasuredText.runs) { if (run->getRange().contains(range)) { diff --git a/libs/minikin/OptimalLineBreaker.cpp b/libs/minikin/OptimalLineBreaker.cpp index e170313..d3db0ec 100644 --- a/libs/minikin/OptimalLineBreaker.cpp +++ b/libs/minikin/OptimalLineBreaker.cpp @@ -19,6 +19,7 @@ #include <algorithm> #include <limits> +#include "FeatureFlags.h" #include "HyphenatorMap.h" #include "LayoutUtils.h" #include "LineBreakerUtil.h" @@ -167,7 +168,8 @@ std::vector<DesperateBreak> populateDesperatePoints(const U16StringPiece& textBu const Range& range, const Run& run) { std::vector<DesperateBreak> out; - if (run.lineBreakWordStyle() == LineBreakWordStyle::None) { + if (!features::phrase_strict_fallback() || + run.lineBreakWordStyle() == LineBreakWordStyle::None) { ParaWidth width = measured.widths[range.getStart()]; for (uint32_t i = range.getStart() + 1; i < range.getEnd(); ++i) { const float w = measured.widths[i]; diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp index cf57667..362ba10 100644 --- a/tests/perftests/Android.bp +++ b/tests/perftests/Android.bp @@ -37,6 +37,7 @@ cc_benchmark { "libminikin-tests-util", "libminikin", "libxml2", + "aconfig_text_flags_c_lib", ], shared_libs: [ diff --git a/tests/stresstest/Android.bp b/tests/stresstest/Android.bp index e08a984..7e0379c 100644 --- a/tests/stresstest/Android.bp +++ b/tests/stresstest/Android.bp @@ -28,6 +28,7 @@ cc_test { "libminikin-tests-util", "libminikin", "libxml2", + "aconfig_text_flags_c_lib", ], // Shared libraries which are dependencies of minikin; these are not automatically diff --git a/tests/unittest/Android.bp b/tests/unittest/Android.bp index 27d8cc6..0d6634c 100644 --- a/tests/unittest/Android.bp +++ b/tests/unittest/Android.bp @@ -41,6 +41,7 @@ cc_test { "libutils", "libz", "libcutils", + "aconfig_text_flags_c_lib", ], srcs: [ |