use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class ViewGroup_Delegate method drawChild.
/**
* Overrides the original drawChild call in ViewGroup to draw the shadow.
*/
@LayoutlibDelegate
static /*package*/
boolean drawChild(ViewGroup thisVG, Canvas canvas, View child, long drawingTime) {
if (child.getZ() > thisVG.getZ()) {
// The background's bounds are set lazily. Make sure they are set correctly so that
// the outline obtained is correct.
child.setBackgroundBounds();
ViewOutlineProvider outlineProvider = child.getOutlineProvider();
if (outlineProvider != null) {
Outline outline = child.mAttachInfo.mTmpOutline;
outlineProvider.getOutline(child, outline);
if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) {
int restoreTo = transformCanvas(thisVG, canvas, child);
drawShadow(thisVG, canvas, child, outline);
canvas.restoreToCount(restoreTo);
}
}
}
return thisVG.drawChild_Original(canvas, child, drawingTime);
}
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);
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class PathParser_Delegate method nParseStringForPath.
@LayoutlibDelegate
static /*package*/
void nParseStringForPath(long pathPtr, @NonNull String pathString, int stringLength) {
Path_Delegate path_delegate = Path_Delegate.getDelegate(pathPtr);
if (path_delegate == null) {
return;
}
assert pathString.length() == stringLength;
PathDataNode.nodesToPath(createNodesFromPathData(pathString), path_delegate);
}
use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by DirtyUnicorns.
the class Region_Delegate method nativeSetPath.
@LayoutlibDelegate
static /*package*/
boolean nativeSetPath(long native_dst, long native_path, long 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