TextLayoutCache - add glyphs caching
- cache glyphs after Harfbuzz shaping - use "m" prefix for member variables - add temporary API for drawing text with glyphs - update BiDiTest app Change-Id: I619b3f313b15f010018daad21b3e5e486619b4e4
This commit is contained in:
@@ -1329,29 +1329,6 @@ public class Canvas {
|
||||
paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the glyphs, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param glyphs The glyphs to be drawn
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*
|
||||
* @hide
|
||||
*
|
||||
* Used only for BiDi / RTL Tests
|
||||
*/
|
||||
public void drawGlyphs(char[] glyphs, int index, int count, float x, float y,
|
||||
Paint paint) {
|
||||
if ((index | count | (index + count) |
|
||||
(glyphs.length - index - count)) < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
native_drawGlyphs(mNativeCanvas, glyphs, index, count, x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
@@ -1417,6 +1394,70 @@ public class Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param text The text to be drawn
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*
|
||||
* @hide
|
||||
*
|
||||
* Used only for BiDi / RTL Tests
|
||||
*/
|
||||
public void drawTextWithGlyphs(char[] text, int index, int count, float x, float y,
|
||||
Paint paint) {
|
||||
if ((index | count | (index + count) |
|
||||
(text.length - index - count)) < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
native_drawTextWithGlyphs(mNativeCanvas, text, index, count, x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param text The text to be drawn
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*
|
||||
* @hide
|
||||
*
|
||||
* Used only for BiDi / RTL Tests
|
||||
*/
|
||||
public void drawTextWithGlyphs(String text, float x, float y, Paint paint) {
|
||||
native_drawTextWithGlyphs(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the glyphs, with origin at (x,y), using the specified paint. The
|
||||
* origin is interpreted based on the Align setting in the paint.
|
||||
*
|
||||
* @param glyphs The glyphs to be drawn
|
||||
* @param x The x-coordinate of the origin of the text being drawn
|
||||
* @param y The y-coordinate of the origin of the text being drawn
|
||||
* @param paint The paint used for the text (e.g. color, size, style)
|
||||
*
|
||||
* @hide
|
||||
*
|
||||
* Used only for BiDi / RTL Tests
|
||||
*/
|
||||
public void drawGlyphs(char[] glyphs, int index, int count, float x, float y,
|
||||
Paint paint) {
|
||||
if ((index | count | (index + count) |
|
||||
(glyphs.length - index - count)) < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
native_drawGlyphs(mNativeCanvas, glyphs, index, count, x, y, paint.mBidiFlags,
|
||||
paint.mNativePaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a run of all LTR or all RTL text, with shaping. This does not run
|
||||
* bidi on the provided text, but renders it as a uniform right-to-left or
|
||||
@@ -1745,9 +1786,17 @@ public class Canvas {
|
||||
private static native void native_drawText(int nativeCanvas, String text,
|
||||
int start, int end, float x,
|
||||
float y, int flags, int paint);
|
||||
|
||||
private static native void native_drawTextWithGlyphs(int nativeCanvas, char[] text,
|
||||
int index, int count, float x,
|
||||
float y, int flags, int paint);
|
||||
private static native void native_drawTextWithGlyphs(int nativeCanvas, String text,
|
||||
int start, int end, float x,
|
||||
float y, int flags, int paint);
|
||||
private static native void native_drawGlyphs(int nativeCanvas, char[] glyphs,
|
||||
int index, int count, float x,
|
||||
float y, int flags, int paint);
|
||||
|
||||
private static native void native_drawTextRun(int nativeCanvas, String text,
|
||||
int start, int end, int contextStart, int contextEnd,
|
||||
float x, float y, int flags, int paint);
|
||||
|
||||
Reference in New Issue
Block a user