use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Bitmap_Delegate method nativeErase.
@LayoutlibDelegate
static /*package*/
void nativeErase(int nativeBitmap, int color) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
}
BufferedImage image = delegate.mImage;
Graphics2D g = image.createGraphics();
try {
g.setColor(new java.awt.Color(color, true));
g.fillRect(0, 0, image.getWidth(), image.getHeight());
} finally {
g.dispose();
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Canvas_Delegate method nativeDrawBitmapMatrix.
@LayoutlibDelegate
static /*package*/
void nativeDrawBitmapMatrix(int nCanvas, int nBitmap, int nMatrix, int nPaint) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
return;
}
// get the delegate from the native int, which can be null
Paint_Delegate paintDelegate = Paint_Delegate.getDelegate(nPaint);
// get the delegate from the native int.
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(nBitmap);
if (bitmapDelegate == null) {
return;
}
final BufferedImage image = getImageToDraw(bitmapDelegate, paintDelegate, sBoolOut);
Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
if (matrixDelegate == null) {
return;
}
final AffineTransform mtx = matrixDelegate.getAffineTransform();
canvasDelegate.getSnapshot().draw(new GcSnapshot.Drawable() {
@Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
//FIXME add support for canvas, screen and bitmap densities.
graphics.drawImage(image, mtx, null);
}
}, paintDelegate, true, /*compositeOnly*/
false);
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Canvas_Delegate method native_drawBitmap.
@LayoutlibDelegate
static /*package*/
void native_drawBitmap(Canvas thisCanvas, int nativeCanvas, int bitmap, float left, float top, int nativePaintOrZero, int canvasDensity, int screenDensity, int bitmapDensity) {
// get the delegate from the native int.
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
if (bitmapDelegate == null) {
return;
}
BufferedImage image = bitmapDelegate.getImage();
float right = left + image.getWidth();
float bottom = top + image.getHeight();
drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), (int) left, (int) top, (int) right, (int) bottom);
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Canvas_Delegate method native_drawBitmap.
@LayoutlibDelegate
static /*package*/
void native_drawBitmap(int nativeCanvas, int bitmap, Rect src, Rect dst, int nativePaintOrZero, int screenDensity, int bitmapDensity) {
// get the delegate from the native int.
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
if (bitmapDelegate == null) {
return;
}
BufferedImage image = bitmapDelegate.getImage();
if (src == null) {
drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, 0, 0, image.getWidth(), image.getHeight(), dst.left, dst.top, dst.right, dst.bottom);
} else {
drawBitmap(nativeCanvas, bitmapDelegate, nativePaintOrZero, src.left, src.top, src.width(), src.height(), dst.left, dst.top, dst.right, dst.bottom);
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Matrix_Delegate method native_invert.
@LayoutlibDelegate
static /*package*/
boolean native_invert(int native_object, int inverse) {
Matrix_Delegate d = sManager.getDelegate(native_object);
if (d == null) {
return false;
}
Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
if (inv_mtx == null) {
return false;
}
try {
AffineTransform affineTransform = d.getAffineTransform();
AffineTransform inverseTransform = affineTransform.createInverse();
inv_mtx.mValues[0] = (float) inverseTransform.getScaleX();
inv_mtx.mValues[1] = (float) inverseTransform.getShearX();
inv_mtx.mValues[2] = (float) inverseTransform.getTranslateX();
inv_mtx.mValues[3] = (float) inverseTransform.getScaleX();
inv_mtx.mValues[4] = (float) inverseTransform.getShearY();
inv_mtx.mValues[5] = (float) inverseTransform.getTranslateY();
return true;
} catch (NoninvertibleTransformException e) {
return false;
}
}
Aggregations