Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "StaticLayout" |
| 18 | |
| 19 | #include "ScopedIcuLocale.h" |
| 20 | #include "unicode/locid.h" |
| 21 | #include "unicode/brkiter.h" |
| 22 | #include "utils/misc.h" |
| 23 | #include "utils/Log.h" |
Steven Moreland | 2279b25 | 2017-07-19 09:50:45 -0700 | [diff] [blame] | 24 | #include <nativehelper/ScopedStringChars.h> |
| 25 | #include <nativehelper/ScopedPrimitiveArray.h> |
| 26 | #include <nativehelper/JNIHelp.h> |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 27 | #include "core_jni_helpers.h" |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 28 | #include <cstdint> |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 29 | #include <vector> |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 30 | #include <list> |
| 31 | #include <algorithm> |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 32 | |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 33 | #include "SkPaint.h" |
| 34 | #include "SkTypeface.h" |
sergeyv | dccca44 | 2016-03-21 15:38:21 -0700 | [diff] [blame] | 35 | #include <hwui/MinikinSkia.h> |
| 36 | #include <hwui/MinikinUtils.h> |
| 37 | #include <hwui/Paint.h> |
| 38 | #include <minikin/FontCollection.h> |
| 39 | #include <minikin/LineBreaker.h> |
| 40 | #include <minikin/MinikinFont.h> |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 41 | |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 42 | namespace android { |
| 43 | |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 44 | struct JLineBreaksID { |
| 45 | jfieldID breaks; |
| 46 | jfieldID widths; |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 47 | jfieldID ascents; |
| 48 | jfieldID descents; |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 49 | jfieldID flags; |
| 50 | }; |
| 51 | |
| 52 | static jclass gLineBreaks_class; |
| 53 | static JLineBreaksID gLineBreaks_fieldID; |
| 54 | |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 55 | class JNILineBreakerLineWidth : public minikin::LineBreaker::LineWidthDelegate { |
| 56 | public: |
| 57 | JNILineBreakerLineWidth(float firstWidth, int32_t firstLineCount, float restWidth, |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 58 | std::vector<float>&& indents, std::vector<float>&& leftPaddings, |
| 59 | std::vector<float>&& rightPaddings, int32_t indentsAndPaddingsOffset) |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 60 | : mFirstWidth(firstWidth), mFirstLineCount(firstLineCount), mRestWidth(restWidth), |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 61 | mIndents(std::move(indents)), mLeftPaddings(std::move(leftPaddings)), |
| 62 | mRightPaddings(std::move(rightPaddings)), mOffset(indentsAndPaddingsOffset) {} |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 63 | |
| 64 | float getLineWidth(size_t lineNo) override { |
| 65 | const float width = ((ssize_t)lineNo < (ssize_t)mFirstLineCount) |
| 66 | ? mFirstWidth : mRestWidth; |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 67 | return width - get(mIndents, lineNo); |
| 68 | } |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 69 | |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 70 | float getLeftPadding(size_t lineNo) override { |
| 71 | return get(mLeftPaddings, lineNo); |
| 72 | } |
| 73 | |
| 74 | float getRightPadding(size_t lineNo) override { |
| 75 | return get(mRightPaddings, lineNo); |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | private: |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 79 | float get(const std::vector<float>& vec, size_t lineNo) { |
| 80 | if (vec.empty()) { |
| 81 | return 0; |
| 82 | } |
| 83 | const size_t index = lineNo + mOffset; |
| 84 | if (index < vec.size()) { |
| 85 | return vec[index]; |
| 86 | } else { |
| 87 | return vec.back(); |
| 88 | } |
| 89 | } |
| 90 | |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 91 | const float mFirstWidth; |
| 92 | const int32_t mFirstLineCount; |
| 93 | const float mRestWidth; |
| 94 | const std::vector<float> mIndents; |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 95 | const std::vector<float> mLeftPaddings; |
| 96 | const std::vector<float> mRightPaddings; |
| 97 | const int32_t mOffset; |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 100 | static inline std::vector<float> jintArrayToFloatVector(JNIEnv* env, jintArray javaArray) { |
| 101 | if (javaArray == nullptr) { |
| 102 | return std::vector<float>(); |
| 103 | } else { |
| 104 | ScopedIntArrayRO intArr(env, javaArray); |
| 105 | return std::vector<float>(intArr.get(), intArr.get() + intArr.size()); |
| 106 | } |
| 107 | } |
| 108 | |
Roozbeh Pournader | 95c7a13 | 2015-05-12 12:01:06 -0700 | [diff] [blame] | 109 | // set text and set a number of parameters for creating a layout (width, tabstops, strategy, |
| 110 | // hyphenFrequency) |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 111 | static void nSetupParagraph(JNIEnv* env, jclass, jlong nativePtr, jcharArray text, jint length, |
| 112 | jfloat firstWidth, jint firstWidthLineLimit, jfloat restWidth, |
Seigo Nonaka | 09da71a | 2016-11-28 16:24:14 +0900 | [diff] [blame] | 113 | jintArray variableTabStops, jint defaultTabStop, jint strategy, jint hyphenFrequency, |
Roozbeh Pournader | 9a9179d | 2017-08-29 14:14:28 -0700 | [diff] [blame] | 114 | jboolean isJustified, jintArray indents, jintArray leftPaddings, jintArray rightPaddings, |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 115 | jint indentsAndPaddingsOffset) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 116 | minikin::LineBreaker* b = reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 117 | b->resize(length); |
| 118 | env->GetCharArrayRegion(text, 0, length, b->buffer()); |
| 119 | b->setText(); |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 120 | if (variableTabStops == nullptr) { |
| 121 | b->setTabStops(nullptr, 0, defaultTabStop); |
| 122 | } else { |
| 123 | ScopedIntArrayRO stops(env, variableTabStops); |
| 124 | b->setTabStops(stops.get(), stops.size(), defaultTabStop); |
| 125 | } |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 126 | b->setStrategy(static_cast<minikin::BreakStrategy>(strategy)); |
| 127 | b->setHyphenationFrequency(static_cast<minikin::HyphenationFrequency>(hyphenFrequency)); |
Seigo Nonaka | 09da71a | 2016-11-28 16:24:14 +0900 | [diff] [blame] | 128 | b->setJustified(isJustified); |
Seigo Nonaka | bafe197 | 2017-08-24 15:30:29 -0700 | [diff] [blame] | 129 | |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 130 | // TODO: copy indents and paddings only once when LineBreaker is started to be used. |
Seigo Nonaka | 749e57e | 2017-08-29 15:00:05 -0700 | [diff] [blame] | 131 | b->setLineWidthDelegate(std::make_unique<JNILineBreakerLineWidth>( |
Roozbeh Pournader | 0bba742 | 2017-09-28 12:35:10 -0700 | [diff] [blame] | 132 | firstWidth, firstWidthLineLimit, restWidth, jintArrayToFloatVector(env, indents), |
| 133 | jintArrayToFloatVector(env, leftPaddings), jintArrayToFloatVector(env, rightPaddings), |
| 134 | indentsAndPaddingsOffset)); |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 135 | } |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 136 | |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 137 | static void recycleCopy(JNIEnv* env, jobject recycle, jintArray recycleBreaks, |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 138 | jfloatArray recycleWidths, jfloatArray recycleAscents, |
| 139 | jfloatArray recycleDescents, jintArray recycleFlags, |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 140 | jint recycleLength, size_t nBreaks, const jint* breaks, |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 141 | const jfloat* widths, const jfloat* ascents, const jfloat* descents, |
| 142 | const jint* flags) { |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 143 | if ((size_t)recycleLength < nBreaks) { |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 144 | // have to reallocate buffers |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 145 | recycleBreaks = env->NewIntArray(nBreaks); |
| 146 | recycleWidths = env->NewFloatArray(nBreaks); |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 147 | recycleAscents = env->NewFloatArray(nBreaks); |
| 148 | recycleDescents = env->NewFloatArray(nBreaks); |
Raph Levien | 26d443a | 2015-03-30 14:18:32 -0700 | [diff] [blame] | 149 | recycleFlags = env->NewIntArray(nBreaks); |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 150 | |
| 151 | env->SetObjectField(recycle, gLineBreaks_fieldID.breaks, recycleBreaks); |
| 152 | env->SetObjectField(recycle, gLineBreaks_fieldID.widths, recycleWidths); |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 153 | env->SetObjectField(recycle, gLineBreaks_fieldID.ascents, recycleAscents); |
| 154 | env->SetObjectField(recycle, gLineBreaks_fieldID.descents, recycleDescents); |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 155 | env->SetObjectField(recycle, gLineBreaks_fieldID.flags, recycleFlags); |
| 156 | } |
| 157 | // copy data |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 158 | env->SetIntArrayRegion(recycleBreaks, 0, nBreaks, breaks); |
| 159 | env->SetFloatArrayRegion(recycleWidths, 0, nBreaks, widths); |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 160 | env->SetFloatArrayRegion(recycleAscents, 0, nBreaks, ascents); |
| 161 | env->SetFloatArrayRegion(recycleDescents, 0, nBreaks, descents); |
Raph Levien | 26d443a | 2015-03-30 14:18:32 -0700 | [diff] [blame] | 162 | env->SetIntArrayRegion(recycleFlags, 0, nBreaks, flags); |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 163 | } |
| 164 | |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 165 | static jint nComputeLineBreaks(JNIEnv* env, jclass, jlong nativePtr, |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 166 | jobject recycle, jintArray recycleBreaks, |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 167 | jfloatArray recycleWidths, jfloatArray recycleAscents, |
| 168 | jfloatArray recycleDescents, jintArray recycleFlags, |
Seigo Nonaka | 2dd1a55 | 2017-10-06 11:41:00 -0700 | [diff] [blame] | 169 | jint recycleLength, jfloatArray charWidths) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 170 | minikin::LineBreaker* b = reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 171 | |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 172 | size_t nBreaks = b->computeBreaks(); |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 173 | |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 174 | recycleCopy(env, recycle, recycleBreaks, recycleWidths, recycleAscents, recycleDescents, |
| 175 | recycleFlags, recycleLength, nBreaks, b->getBreaks(), b->getWidths(), b->getAscents(), |
| 176 | b->getDescents(), b->getFlags()); |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 177 | |
Seigo Nonaka | 2dd1a55 | 2017-10-06 11:41:00 -0700 | [diff] [blame] | 178 | env->SetFloatArrayRegion(charWidths, 0, b->size(), b->charWidths()); |
| 179 | |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 180 | b->finish(); |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 181 | |
Raph Levien | c94f742 | 2015-03-06 19:19:48 -0800 | [diff] [blame] | 182 | return static_cast<jint>(nBreaks); |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 185 | static jlong nNewBuilder(JNIEnv*, jclass) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 186 | return reinterpret_cast<jlong>(new minikin::LineBreaker); |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static void nFreeBuilder(JNIEnv*, jclass, jlong nativePtr) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 190 | delete reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static void nFinishBuilder(JNIEnv*, jclass, jlong nativePtr) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 194 | minikin::LineBreaker* b = reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 195 | b->finish(); |
| 196 | } |
| 197 | |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 198 | // Basically similar to Paint.getTextRunAdvances but with C++ interface |
Seigo Nonaka | 5cc9348 | 2017-10-02 16:01:14 -0700 | [diff] [blame] | 199 | static void nAddStyleRun(JNIEnv* env, jclass, jlong nativePtr, jlong nativePaint, jint start, |
Seigo Nonaka | f90c9b6 | 2017-10-09 11:10:24 -0700 | [diff] [blame^] | 200 | jint end, jboolean isRtl) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 201 | minikin::LineBreaker* b = reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 202 | Paint* paint = reinterpret_cast<Paint*>(nativePaint); |
Seigo Nonaka | 318ca04 | 2017-08-01 16:36:18 -0700 | [diff] [blame] | 203 | const Typeface* typeface = paint->getAndroidTypeface(); |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 204 | minikin::MinikinPaint minikinPaint; |
Seigo Nonaka | 318ca04 | 2017-08-01 16:36:18 -0700 | [diff] [blame] | 205 | const Typeface* resolvedTypeface = Typeface::resolveDefault(typeface); |
Seigo Nonaka | c706414 | 2017-02-10 16:53:31 +0900 | [diff] [blame] | 206 | minikin::FontStyle style = MinikinUtils::prepareMinikinPaint(&minikinPaint, paint, |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 207 | typeface); |
Seigo Nonaka | 5d518dc | 2017-08-31 14:01:54 -0700 | [diff] [blame] | 208 | |
Seigo Nonaka | f90c9b6 | 2017-10-09 11:10:24 -0700 | [diff] [blame^] | 209 | b->addStyleRun(&minikinPaint, resolvedTypeface->fFontCollection, style, start, end, isRtl); |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Seigo Nonaka | f90c9b6 | 2017-10-09 11:10:24 -0700 | [diff] [blame^] | 212 | static void nAddReplacementRun(JNIEnv* env, jclass, jlong nativePtr, jlong nativePaint, |
| 213 | jint start, jint end, jfloat width) { |
Seigo Nonaka | ae1aa85 | 2016-06-09 19:42:51 +0900 | [diff] [blame] | 214 | minikin::LineBreaker* b = reinterpret_cast<minikin::LineBreaker*>(nativePtr); |
Seigo Nonaka | f90c9b6 | 2017-10-09 11:10:24 -0700 | [diff] [blame^] | 215 | Paint* paint = reinterpret_cast<Paint*>(nativePaint); |
| 216 | b->addReplacement(start, end, width, paint->getMinikinLangListId()); |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 219 | static const JNINativeMethod gMethods[] = { |
Raph Levien | 70616ec | 2015-03-04 10:41:30 -0800 | [diff] [blame] | 220 | // TODO performance: many of these are candidates for fast jni, awaiting guidance |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 221 | {"nNewBuilder", "()J", (void*) nNewBuilder}, |
| 222 | {"nFreeBuilder", "(J)V", (void*) nFreeBuilder}, |
| 223 | {"nFinishBuilder", "(J)V", (void*) nFinishBuilder}, |
Roozbeh Pournader | 9a9179d | 2017-08-29 14:14:28 -0700 | [diff] [blame] | 224 | {"nSetupParagraph", "(J[CIFIF[IIIIZ[I[I[II)V", (void*) nSetupParagraph}, |
Seigo Nonaka | f90c9b6 | 2017-10-09 11:10:24 -0700 | [diff] [blame^] | 225 | {"nAddStyleRun", "(JJIIZ)V", (void*) nAddStyleRun}, |
| 226 | {"nAddReplacementRun", "(JJIIF)V", (void*) nAddReplacementRun}, |
Seigo Nonaka | 2dd1a55 | 2017-10-06 11:41:00 -0700 | [diff] [blame] | 227 | {"nComputeLineBreaks", "(JLandroid/text/StaticLayout$LineBreaks;[I[F[F[F[II[F)I", |
Raph Levien | 4c1f12e | 2015-03-02 16:29:23 -0800 | [diff] [blame] | 228 | (void*) nComputeLineBreaks} |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | int register_android_text_StaticLayout(JNIEnv* env) |
| 232 | { |
Andreas Gampe | 158b6c9 | 2014-11-21 14:03:34 -0800 | [diff] [blame] | 233 | gLineBreaks_class = MakeGlobalRefOrDie(env, |
| 234 | FindClassOrDie(env, "android/text/StaticLayout$LineBreaks")); |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 235 | |
Andreas Gampe | 158b6c9 | 2014-11-21 14:03:34 -0800 | [diff] [blame] | 236 | gLineBreaks_fieldID.breaks = GetFieldIDOrDie(env, gLineBreaks_class, "breaks", "[I"); |
| 237 | gLineBreaks_fieldID.widths = GetFieldIDOrDie(env, gLineBreaks_class, "widths", "[F"); |
Roozbeh Pournader | 737dfea | 2017-08-10 11:32:24 -0700 | [diff] [blame] | 238 | gLineBreaks_fieldID.ascents = GetFieldIDOrDie(env, gLineBreaks_class, "ascents", "[F"); |
| 239 | gLineBreaks_fieldID.descents = GetFieldIDOrDie(env, gLineBreaks_class, "descents", "[F"); |
Raph Levien | 26d443a | 2015-03-30 14:18:32 -0700 | [diff] [blame] | 240 | gLineBreaks_fieldID.flags = GetFieldIDOrDie(env, gLineBreaks_class, "flags", "[I"); |
Anish Athalye | c8f9e62 | 2014-07-21 15:26:34 -0700 | [diff] [blame] | 241 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 242 | return RegisterMethodsOrDie(env, "android/text/StaticLayout", gMethods, NELEM(gMethods)); |
Anish Athalye | 88b5b0b | 2014-06-24 14:39:43 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | } |