use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ResurrectionRemix.
the class Canvas_Delegate method nativeDrawBitmapMatrix.
@LayoutlibDelegate
public static void nativeDrawBitmapMatrix(long nCanvas, Bitmap bitmap, long nMatrix, long 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(bitmap);
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 ResurrectionRemix.
the class Region_Delegate method nativeOp.
@LayoutlibDelegate
static /*package*/
boolean nativeOp(long native_dst, int left, int top, int right, int bottom, int op) {
Region_Delegate region = sManager.getDelegate(native_dst);
if (region == null) {
return false;
}
region.mArea = combineShapes(region.mArea, new Rectangle2D.Float(left, top, right - left, bottom - top), 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 ResurrectionRemix.
the class Region_Delegate method nativeGetBounds.
@LayoutlibDelegate
static /*package*/
boolean nativeGetBounds(long native_region, Rect rect) {
Region_Delegate region = sManager.getDelegate(native_region);
if (region == null) {
return true;
}
Rectangle bounds = region.mArea.getBounds();
if (bounds.isEmpty()) {
rect.left = rect.top = rect.right = rect.bottom = 0;
return false;
}
rect.left = bounds.x;
rect.top = bounds.y;
rect.right = bounds.x + bounds.width;
rect.bottom = bounds.y + bounds.height;
return true;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class PathParser_Delegate method nCreatePathFromPathData.
@LayoutlibDelegate
static /*package*/
void nCreatePathFromPathData(long outPathPtr, long pathData) {
Path_Delegate path_delegate = Path_Delegate.getDelegate(outPathPtr);
PathParser_Delegate source = sManager.getDelegate(outPathPtr);
if (source == null || path_delegate == null) {
return;
}
PathDataNode.nodesToPath(source.mPathDataNodes, path_delegate);
}
Aggregations