am fb2cdc4c: Merge "Revert "Revert "Use getRunAdvance to position cursor""" into mnc-dev

* commit 'fb2cdc4ca131ff95179414854eca02a098a29a8a':
  Revert "Revert "Use getRunAdvance to position cursor""
This commit is contained in:
Raph Levien
2015-06-01 22:10:07 +00:00
committed by Android Git Automerger
2 changed files with 5 additions and 6 deletions

View File

@@ -1121,6 +1121,7 @@ public abstract class Layout {
* closest to the specified horizontal position. * closest to the specified horizontal position.
*/ */
public int getOffsetForHorizontal(int line, float horiz) { public int getOffsetForHorizontal(int line, float horiz) {
// TODO: use Paint.getOffsetForAdvance to avoid binary search
int max = getLineEnd(line) - 1; int max = getLineEnd(line) - 1;
int min = getLineStart(line); int min = getLineStart(line);
Directions dirs = getLineDirections(line); Directions dirs = getLineDirections(line);

View File

@@ -739,16 +739,14 @@ class TextLine {
float ret = 0; float ret = 0;
int contextLen = contextEnd - contextStart;
if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) { if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor != 0 || runIsRtl))) {
if (mCharsValid) { if (mCharsValid) {
ret = wp.getTextRunAdvances(mChars, start, runLen, ret = wp.getRunAdvance(mChars, start, contextEnd, contextStart, contextEnd,
contextStart, contextLen, runIsRtl, null, 0); runIsRtl, end);
} else { } else {
int delta = mStart; int delta = mStart;
ret = wp.getTextRunAdvances(mText, delta + start, ret = wp.getRunAdvance(mText, delta + start, delta + contextEnd,
delta + end, delta + contextStart, delta + contextEnd, delta + contextStart, delta + contextEnd, runIsRtl, delta + end);
runIsRtl, null, 0);
} }
} }