use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Bitmap_Delegate method nativeCopy.
@LayoutlibDelegate
static /*package*/
Bitmap nativeCopy(long srcBitmap, int nativeConfig, boolean isMutable) {
Bitmap_Delegate srcBmpDelegate = sManager.getDelegate(srcBitmap);
if (srcBmpDelegate == null) {
return null;
}
BufferedImage srcImage = srcBmpDelegate.getImage();
int width = srcImage.getWidth();
int height = srcImage.getHeight();
int imageType = getBufferedImageType();
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
// copy the source image into the image.
int[] argb = new int[width * height];
srcImage.getRGB(0, 0, width, height, argb, 0, width);
image.setRGB(0, 0, width, height, argb, 0, width);
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable), Bitmap.getDefaultDensity());
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Bitmap_Delegate method nativeCreate.
// ---- native methods ----
@LayoutlibDelegate
static /*package*/
Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean isMutable) {
int imageType = getBufferedImageType();
// create the image
BufferedImage image = new BufferedImage(width, height, imageType);
if (colors != null) {
image.setRGB(0, 0, width, height, colors, offset, stride);
}
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable), Bitmap.getDefaultDensity());
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Canvas_Delegate method native_setMatrix.
@LayoutlibDelegate
public static void native_setMatrix(long nCanvas, long nMatrix) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
if (canvasDelegate == null) {
return;
}
Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
if (matrixDelegate == null) {
return;
}
// get the current top graphics2D object.
GcSnapshot snapshot = canvasDelegate.getSnapshot();
// get the AffineTransform of the given matrix
AffineTransform matrixTx = matrixDelegate.getAffineTransform();
// give it to the graphics2D as a new matrix replacing all previous transform
snapshot.setTransform(matrixTx);
if (matrixDelegate.hasPerspective()) {
assert false;
Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + "supports affine transformations.", null, null);
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Preference_Delegate method getView.
@LayoutlibDelegate
static /*package*/
View getView(Preference pref, View convertView, ViewGroup parent) {
Context context = pref.getContext();
BridgeContext bc = context instanceof BridgeContext ? ((BridgeContext) context) : null;
convertView = pref.getView_Original(convertView, parent);
if (bc != null) {
Object cookie = bc.getCookie(pref);
if (cookie != null) {
bc.addViewKey(convertView, cookie);
}
}
return convertView;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Canvas_Delegate method native_drawBitmap.
@LayoutlibDelegate
public static void native_drawBitmap(long nativeCanvas, int[] colors, int offset, int stride, final float x, final float y, int width, int height, boolean hasAlpha, long nativePaintOrZero) {
// create a temp BufferedImage containing the content.
final BufferedImage image = new BufferedImage(width, height, hasAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);
image.setRGB(0, 0, width, height, colors, offset, stride);
draw(nativeCanvas, nativePaintOrZero, true, /*compositeOnly*/
false, /*forceSrcMode*/
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);
}
graphics.drawImage(image, (int) x, (int) y, null);
}
});
}
Aggregations