Loading tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +6 −1 Original line number Diff line number Diff line Loading @@ -977,7 +977,7 @@ public final class Canvas_Delegate { /*package*/ static void native_drawText(long nativeCanvas, final char[] text, final int index, final int count, final float startX, final float startY, final int flags, long paint, long typeface) { final long typeface) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { Loading @@ -985,6 +985,11 @@ public final class Canvas_Delegate { public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) { // WARNING: the logic in this method is similar to Paint_Delegate.measureText. // Any change to this method should be reflected in Paint.measureText // assert that the typeface passed is actually the one stored in paint. assert (typeface == paintDelegate.mNativeTypeface); // Paint.TextAlign indicates how the text is positioned relative to X. // LEFT is the default and there's nothing to do. float x = startX; Loading tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +16 −6 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public class Paint_Delegate { private Locale mLocale = Locale.getDefault(); // Used only to assert invariants. public long mNativeTypeface; // ---- Public Helper methods ---- Loading Loading @@ -888,6 +890,7 @@ public class Paint_Delegate { } delegate.mTypeface = Typeface_Delegate.getDelegate(typeface); delegate.mNativeTypeface = typeface; delegate.updateFontObject(); return typeface; } Loading Loading @@ -966,15 +969,10 @@ public class Paint_Delegate { } @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(long native_object, long native_typeface /*ignored*/, /*package*/ static float native_getTextRunAdvances(long native_object, long native_typeface, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { // native_typeface is passed here since Framework's old implementation did not have the // typeface object associated with the Paint. Since, we follow the new framework way, // we store the typeface with the paint and use it directly. if (advances != null) for (int i = advancesIndex; i< advancesIndex+count; i++) advances[i]=0; Loading @@ -983,6 +981,12 @@ public class Paint_Delegate { if (delegate == null) { return 0.f; } // native_typeface is passed here since Framework's old implementation did not have the // typeface object associated with the Paint. Since, we follow the new framework way, // we store the typeface with the paint and use it directly. assert (native_typeface == delegate.mNativeTypeface); boolean isRtl = isRtl(flags); int limit = index + count; Loading Loading @@ -1054,6 +1058,10 @@ public class Paint_Delegate { if (delegate == null) { return; } // assert that the typeface passed is actually the one that we had stored. assert (native_typeface == delegate.mNativeTypeface); delegate.measureText(text, index, count, isRtl(bidiFlags)).roundOut(bounds); } Loading @@ -1080,6 +1088,7 @@ public class Paint_Delegate { mJoin = paint.mJoin; mTextAlign = paint.mTextAlign; mTypeface = paint.mTypeface; mNativeTypeface = paint.mNativeTypeface; mStrokeWidth = paint.mStrokeWidth; mStrokeMiter = paint.mStrokeMiter; mTextSize = paint.mTextSize; Loading @@ -1103,6 +1112,7 @@ public class Paint_Delegate { mJoin = Paint.Join.MITER.nativeInt; mTextAlign = 0; mTypeface = Typeface_Delegate.getDelegate(Typeface.sDefaults[0].native_instance); mNativeTypeface = 0; mStrokeWidth = 1.f; mStrokeMiter = 4.f; mTextSize = 20.f; Loading Loading
tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java +6 −1 Original line number Diff line number Diff line Loading @@ -977,7 +977,7 @@ public final class Canvas_Delegate { /*package*/ static void native_drawText(long nativeCanvas, final char[] text, final int index, final int count, final float startX, final float startY, final int flags, long paint, long typeface) { final long typeface) { draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/, new GcSnapshot.Drawable() { Loading @@ -985,6 +985,11 @@ public final class Canvas_Delegate { public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) { // WARNING: the logic in this method is similar to Paint_Delegate.measureText. // Any change to this method should be reflected in Paint.measureText // assert that the typeface passed is actually the one stored in paint. assert (typeface == paintDelegate.mNativeTypeface); // Paint.TextAlign indicates how the text is positioned relative to X. // LEFT is the default and there's nothing to do. float x = startX; Loading
tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java +16 −6 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public class Paint_Delegate { private Locale mLocale = Locale.getDefault(); // Used only to assert invariants. public long mNativeTypeface; // ---- Public Helper methods ---- Loading Loading @@ -888,6 +890,7 @@ public class Paint_Delegate { } delegate.mTypeface = Typeface_Delegate.getDelegate(typeface); delegate.mNativeTypeface = typeface; delegate.updateFontObject(); return typeface; } Loading Loading @@ -966,15 +969,10 @@ public class Paint_Delegate { } @LayoutlibDelegate /*package*/ static float native_getTextRunAdvances(long native_object, long native_typeface /*ignored*/, /*package*/ static float native_getTextRunAdvances(long native_object, long native_typeface, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { // native_typeface is passed here since Framework's old implementation did not have the // typeface object associated with the Paint. Since, we follow the new framework way, // we store the typeface with the paint and use it directly. if (advances != null) for (int i = advancesIndex; i< advancesIndex+count; i++) advances[i]=0; Loading @@ -983,6 +981,12 @@ public class Paint_Delegate { if (delegate == null) { return 0.f; } // native_typeface is passed here since Framework's old implementation did not have the // typeface object associated with the Paint. Since, we follow the new framework way, // we store the typeface with the paint and use it directly. assert (native_typeface == delegate.mNativeTypeface); boolean isRtl = isRtl(flags); int limit = index + count; Loading Loading @@ -1054,6 +1058,10 @@ public class Paint_Delegate { if (delegate == null) { return; } // assert that the typeface passed is actually the one that we had stored. assert (native_typeface == delegate.mNativeTypeface); delegate.measureText(text, index, count, isRtl(bidiFlags)).roundOut(bounds); } Loading @@ -1080,6 +1088,7 @@ public class Paint_Delegate { mJoin = paint.mJoin; mTextAlign = paint.mTextAlign; mTypeface = paint.mTypeface; mNativeTypeface = paint.mNativeTypeface; mStrokeWidth = paint.mStrokeWidth; mStrokeMiter = paint.mStrokeMiter; mTextSize = paint.mTextSize; Loading @@ -1103,6 +1112,7 @@ public class Paint_Delegate { mJoin = Paint.Join.MITER.nativeInt; mTextAlign = 0; mTypeface = Typeface_Delegate.getDelegate(Typeface.sDefaults[0].native_instance); mNativeTypeface = 0; mStrokeWidth = 1.f; mStrokeMiter = 4.f; mTextSize = 20.f; Loading