summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/graphics/Paint.java
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-03-27 15:35:53 -0700
committerVictoria Lease <violets@google.com>2013-03-28 15:56:14 -0700
commit626d3c228116103e95d4429b06dad70f9812561a (patch)
treef103c07cc4d153466752bec15a91520eda6dc584 /graphics/java/android/graphics/Paint.java
parent44bed6af1d40e529b51d992507d7dd3370abf262 (diff)
downloadframeworks_base-626d3c228116103e95d4429b06dad70f9812561a.zip
frameworks_base-626d3c228116103e95d4429b06dad70f9812561a.tar.gz
frameworks_base-626d3c228116103e95d4429b06dad70f9812561a.tar.bz2
bidiFlags != SkPaint::Flags
We've a number of native functions in the text layout path that take a bidiFlags argument. We've a number of callers of those functions passing in SkPaint::Flags in that slot. This completely breaks text directionality for the affected functions, as SkPaint::kAntiAlias_Flag happens to share values with kBidi_RTL, resulting in anti-aliased SkPaints measuring text as if it were RTL, and non-anti-aliased SkPaints measuring text as if it were LTR, regardless of the actual text directionality. Oops! To address the issue, this commit replaces erroneous calls to SkPaint.getFlags() with the value of Paint.mBidiFlags, and includes the necessary plumbing to get that value where it needs to be. Bug: 8471481 Change-Id: I2d04b70defed3130fc1ad13f4c9098f5fce4ffde
Diffstat (limited to 'graphics/java/android/graphics/Paint.java')
-rw-r--r--graphics/java/android/graphics/Paint.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index d5cee3a..1485d8d 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1295,17 +1295,17 @@ public class Paint {
return 0f;
}
if (!mHasCompatScaling) {
- return (float) Math.ceil(native_measureText(text, index, count));
+ return (float) Math.ceil(native_measureText(text, index, count, mBidiFlags));
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- float w = native_measureText(text, index, count);
+ float w = native_measureText(text, index, count, mBidiFlags);
setTextSize(oldSize);
return (float) Math.ceil(w*mInvCompatScaling);
}
- private native float native_measureText(char[] text, int index, int count);
+ private native float native_measureText(char[] text, int index, int count, int bidiFlags);
/**
* Return the width of the text.
@@ -1327,17 +1327,17 @@ public class Paint {
return 0f;
}
if (!mHasCompatScaling) {
- return (float) Math.ceil(native_measureText(text, start, end));
+ return (float) Math.ceil(native_measureText(text, start, end, mBidiFlags));
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- float w = native_measureText(text, start, end);
+ float w = native_measureText(text, start, end, mBidiFlags);
setTextSize(oldSize);
return (float) Math.ceil(w*mInvCompatScaling);
}
- private native float native_measureText(String text, int start, int end);
+ private native float native_measureText(String text, int start, int end, int bidiFlags);
/**
* Return the width of the text.
@@ -1355,16 +1355,16 @@ public class Paint {
}
if (!mHasCompatScaling) {
- return (float) Math.ceil(native_measureText(text));
+ return (float) Math.ceil(native_measureText(text, mBidiFlags));
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- float w = native_measureText(text);
+ float w = native_measureText(text, mBidiFlags);
setTextSize(oldSize);
return (float) Math.ceil(w*mInvCompatScaling);
}
- private native float native_measureText(String text);
+ private native float native_measureText(String text, int bidiFlags);
/**
* Return the width of the text.
@@ -1431,12 +1431,12 @@ public class Paint {
return 0;
}
if (!mHasCompatScaling) {
- return native_breakText(text, index, count, maxWidth, measuredWidth);
+ return native_breakText(text, index, count, maxWidth, mBidiFlags, measuredWidth);
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- int res = native_breakText(text, index, count, maxWidth*mCompatScaling,
+ int res = native_breakText(text, index, count, maxWidth*mCompatScaling, mBidiFlags,
measuredWidth);
setTextSize(oldSize);
if (measuredWidth != null) measuredWidth[0] *= mInvCompatScaling;
@@ -1444,7 +1444,7 @@ public class Paint {
}
private native int native_breakText(char[] text, int index, int count,
- float maxWidth, float[] measuredWidth);
+ float maxWidth, int bidiFlags, float[] measuredWidth);
/**
* Measure the text, stopping early if the measured width exceeds maxWidth.
@@ -1521,12 +1521,12 @@ public class Paint {
return 0;
}
if (!mHasCompatScaling) {
- return native_breakText(text, measureForwards, maxWidth, measuredWidth);
+ return native_breakText(text, measureForwards, maxWidth, mBidiFlags, measuredWidth);
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- int res = native_breakText(text, measureForwards, maxWidth*mCompatScaling,
+ int res = native_breakText(text, measureForwards, maxWidth*mCompatScaling, mBidiFlags,
measuredWidth);
setTextSize(oldSize);
if (measuredWidth != null) measuredWidth[0] *= mInvCompatScaling;
@@ -1534,7 +1534,7 @@ public class Paint {
}
private native int native_breakText(String text, boolean measureForwards,
- float maxWidth, float[] measuredWidth);
+ float maxWidth, int bidiFlags, float[] measuredWidth);
/**
* Return the advance widths for the characters in the string.
@@ -1560,12 +1560,12 @@ public class Paint {
return 0;
}
if (!mHasCompatScaling) {
- return native_getTextWidths(mNativePaint, text, index, count, widths);
+ return native_getTextWidths(mNativePaint, text, index, count, mBidiFlags, widths);
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- int res = native_getTextWidths(mNativePaint, text, index, count, widths);
+ int res = native_getTextWidths(mNativePaint, text, index, count, mBidiFlags, widths);
setTextSize(oldSize);
for (int i=0; i<res; i++) {
widths[i] *= mInvCompatScaling;
@@ -1642,12 +1642,12 @@ public class Paint {
return 0;
}
if (!mHasCompatScaling) {
- return native_getTextWidths(mNativePaint, text, start, end, widths);
+ return native_getTextWidths(mNativePaint, text, start, end, mBidiFlags, widths);
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- int res = native_getTextWidths(mNativePaint, text, start, end, widths);
+ int res = native_getTextWidths(mNativePaint, text, start, end, mBidiFlags, widths);
setTextSize(oldSize);
for (int i=0; i<res; i++) {
widths[i] *= mInvCompatScaling;
@@ -2073,7 +2073,7 @@ public class Paint {
if (bounds == null) {
throw new NullPointerException("need bounds Rect");
}
- nativeGetStringBounds(mNativePaint, text, start, end, bounds);
+ nativeGetStringBounds(mNativePaint, text, start, end, mBidiFlags, bounds);
}
/**
@@ -2093,7 +2093,7 @@ public class Paint {
if (bounds == null) {
throw new NullPointerException("need bounds Rect");
}
- nativeGetCharArrayBounds(mNativePaint, text, index, count, bounds);
+ nativeGetCharArrayBounds(mNativePaint, text, index, count, mBidiFlags, bounds);
}
@Override
@@ -2140,9 +2140,9 @@ public class Paint {
String locale);
private static native int native_getTextWidths(int native_object,
- char[] text, int index, int count, float[] widths);
+ char[] text, int index, int count, int bidiFlags, float[] widths);
private static native int native_getTextWidths(int native_object,
- String text, int start, int end, float[] widths);
+ String text, int start, int end, int bidiFlags, float[] widths);
private static native int native_getTextGlyphs(int native_object,
String text, int start, int end, int contextStart, int contextEnd,
@@ -2165,8 +2165,8 @@ public class Paint {
private static native void native_getTextPath(int native_object, int bidiFlags,
String text, int start, int end, float x, float y, int path);
private static native void nativeGetStringBounds(int nativePaint,
- String text, int start, int end, Rect bounds);
+ String text, int start, int end, int bidiFlags, Rect bounds);
private static native void nativeGetCharArrayBounds(int nativePaint,
- char[] text, int index, int count, Rect bounds);
+ char[] text, int index, int count, int bidiFlags, Rect bounds);
private static native void finalizer(int nativePaint);
}