use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Bitmap_Delegate method nativeCopy.
@LayoutlibDelegate
static /*package*/
Bitmap nativeCopy(int 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(nativeConfig);
// 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, isMutable, Bitmap.getDefaultDensity());
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Paint_Delegate method nativeGetCharArrayBounds.
@LayoutlibDelegate
static /*package*/
void nativeGetCharArrayBounds(int nativePaint, char[] text, int index, int count, int bidiFlags, Rect bounds) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(nativePaint);
if (delegate == null) {
return;
}
// See MeasureText
if (delegate.mFonts.size() > 0) {
FontInfo mainInfo = delegate.mFonts.get(0);
Rectangle2D rect = mainInfo.mFont.getStringBounds(text, index, index + count, delegate.mFontContext);
bounds.set(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Region_Delegate method nativeOp.
@LayoutlibDelegate
static /*package*/
boolean nativeOp(int native_dst, Rect rect, int native_region, int op) {
Region_Delegate region = sManager.getDelegate(native_dst);
if (region == null) {
return false;
}
region.mArea = combineShapes(region.mArea, new Rectangle2D.Float(rect.left, rect.top, rect.width(), rect.height()), op);
assert region.mArea != null;
if (region.mArea != null) {
region.mArea = new Area();
}
return region.mArea.getBounds().isEmpty() == false;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Region_Delegate method scale.
@LayoutlibDelegate
static /*package*/
void scale(Region thisRegion, float scale, Region dst) {
Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
if (regionDelegate == null) {
return;
}
Region_Delegate targetRegionDelegate = sManager.getDelegate(dst.mNativeRegion);
if (targetRegionDelegate == null) {
return;
}
if (regionDelegate.mArea.isEmpty()) {
targetRegionDelegate.mArea = new Area();
} else {
targetRegionDelegate.mArea = new Area(regionDelegate.mArea);
AffineTransform mtx = new AffineTransform();
mtx.scale(scale, scale);
targetRegionDelegate.mArea.transform(mtx);
}
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.
the class Region_Delegate method nativeSetPath.
@LayoutlibDelegate
static /*package*/
boolean nativeSetPath(int native_dst, int native_path, int native_clip) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
return true;
}
Path_Delegate path = Path_Delegate.getDelegate(native_path);
if (path == null) {
return true;
}
dstRegion.mArea = new Area(path.getJavaShape());
Region_Delegate clip = sManager.getDelegate(native_clip);
if (clip != null) {
dstRegion.mArea.subtract(clip.getJavaArea());
}
return dstRegion.mArea.getBounds().isEmpty() == false;
}
Aggregations