3. Canvas#drawText
/mydroid/frameworks/base/graphics/java/android/graphics/Canvas.java
いきなりネイティブを呼んでる。
・パラメータの mNativeCanvasってなんだろう? → 次ページCanvasの
コンストラクタ
Canvas.java:1358
/**
* 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)
*/
public void drawText(String text, float x, float y, Paint paint) {
native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
paint.mNativePaint);
}
12年6月26日火曜日
4. Canvas コンストラクタ:
mNativeCanvasの型は final int
final int mNativeCanvas;
mNativeCanvas に initRasterの戻り値を設定。
initRasterはネイティブ関数
private static native int initRaster(int nativeBitmapOrZero);
・ bitmap.ni()が気になります → 次ページ
Canvas.java:122
/**
* Construct a canvas with the specified bitmap to draw into. The bitmap
* must be mutable.
*
* <p>The initial target density of the canvas is the same as the given
* bitmap's density.
*
* @param bitmap Specifies a mutable bitmap for the canvas to draw into.
*/
public Canvas(Bitmap bitmap) {
if (!bitmap.isMutable()) {
throw new IllegalStateException(
"Immutable bitmap passed to Canvas constructor");
}
throwIfRecycled(bitmap);
mNativeCanvas = initRaster(bitmap.ni());
mFinalizer = new CanvasFinalizer(mNativeCanvas);
mBitmap = bitmap;
mDensity = bitmap.mDensity;
}
12年6月26日火曜日