Search in sources :

Example 1 with CachedPathIterator

use of com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator in project platform_frameworks_base by android.

the class PathMeasure_Delegate method native_getSegment.

@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
    if (startD < 0) {
        startD = 0;
    }
    if (startD >= stopD) {
        return false;
    }
    PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
    assert pathMeasure != null;
    CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
    float accLength = startD;
    // Whether the output has zero length or not
    boolean isZeroLength = true;
    float[] points = new float[6];
    iterator.jumpToSegment(accLength);
    while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
        int type = iterator.currentSegment(points, stopD - accLength);
        if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
            if (startWithMoveTo) {
                startWithMoveTo = false;
                // a first moveto
                if (type != PathIterator.SEG_MOVETO) {
                    float[] lastPoint = new float[2];
                    iterator.getCurrentSegmentEnd(lastPoint);
                    Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
                }
            }
            isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
            switch(type) {
                case PathIterator.SEG_MOVETO:
                    Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_CLOSE:
                    Path_Delegate.native_close(native_dst_path);
                    break;
                case PathIterator.SEG_CUBICTO:
                    Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;
                case PathIterator.SEG_QUADTO:
                    Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
                    break;
                default:
                    assert false;
            }
        }
        accLength += iterator.getCurrentSegmentLength();
        iterator.next();
    }
    return !isZeroLength;
}
Also used : CachedPathIterator(com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 2 with CachedPathIterator

use of com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator in project android_frameworks_base by DirtyUnicorns.

the class PathMeasure_Delegate method native_getSegment.

@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
    if (startD < 0) {
        startD = 0;
    }
    if (startD >= stopD) {
        return false;
    }
    PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
    assert pathMeasure != null;
    CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
    float accLength = startD;
    // Whether the output has zero length or not
    boolean isZeroLength = true;
    float[] points = new float[6];
    iterator.jumpToSegment(accLength);
    while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
        int type = iterator.currentSegment(points, stopD - accLength);
        if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
            if (startWithMoveTo) {
                startWithMoveTo = false;
                // a first moveto
                if (type != PathIterator.SEG_MOVETO) {
                    float[] lastPoint = new float[2];
                    iterator.getCurrentSegmentEnd(lastPoint);
                    Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
                }
            }
            isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
            switch(type) {
                case PathIterator.SEG_MOVETO:
                    Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_CLOSE:
                    Path_Delegate.native_close(native_dst_path);
                    break;
                case PathIterator.SEG_CUBICTO:
                    Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;
                case PathIterator.SEG_QUADTO:
                    Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
                    break;
                default:
                    assert false;
            }
        }
        accLength += iterator.getCurrentSegmentLength();
        iterator.next();
    }
    return !isZeroLength;
}
Also used : CachedPathIterator(com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 3 with CachedPathIterator

use of com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator in project android_frameworks_base by AOSPA.

the class PathMeasure_Delegate method native_getSegment.

@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
    if (startD < 0) {
        startD = 0;
    }
    if (startD >= stopD) {
        return false;
    }
    PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
    assert pathMeasure != null;
    CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
    float accLength = startD;
    // Whether the output has zero length or not
    boolean isZeroLength = true;
    float[] points = new float[6];
    iterator.jumpToSegment(accLength);
    while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
        int type = iterator.currentSegment(points, stopD - accLength);
        if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
            if (startWithMoveTo) {
                startWithMoveTo = false;
                // a first moveto
                if (type != PathIterator.SEG_MOVETO) {
                    float[] lastPoint = new float[2];
                    iterator.getCurrentSegmentEnd(lastPoint);
                    Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
                }
            }
            isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
            switch(type) {
                case PathIterator.SEG_MOVETO:
                    Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_CLOSE:
                    Path_Delegate.native_close(native_dst_path);
                    break;
                case PathIterator.SEG_CUBICTO:
                    Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;
                case PathIterator.SEG_QUADTO:
                    Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
                    break;
                default:
                    assert false;
            }
        }
        accLength += iterator.getCurrentSegmentLength();
        iterator.next();
    }
    return !isZeroLength;
}
Also used : CachedPathIterator(com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 4 with CachedPathIterator

use of com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator in project android_frameworks_base by ResurrectionRemix.

the class PathMeasure_Delegate method native_getSegment.

@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
    if (startD < 0) {
        startD = 0;
    }
    if (startD >= stopD) {
        return false;
    }
    PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
    assert pathMeasure != null;
    CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
    float accLength = startD;
    // Whether the output has zero length or not
    boolean isZeroLength = true;
    float[] points = new float[6];
    iterator.jumpToSegment(accLength);
    while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
        int type = iterator.currentSegment(points, stopD - accLength);
        if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
            if (startWithMoveTo) {
                startWithMoveTo = false;
                // a first moveto
                if (type != PathIterator.SEG_MOVETO) {
                    float[] lastPoint = new float[2];
                    iterator.getCurrentSegmentEnd(lastPoint);
                    Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
                }
            }
            isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
            switch(type) {
                case PathIterator.SEG_MOVETO:
                    Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_CLOSE:
                    Path_Delegate.native_close(native_dst_path);
                    break;
                case PathIterator.SEG_CUBICTO:
                    Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;
                case PathIterator.SEG_QUADTO:
                    Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
                    break;
                default:
                    assert false;
            }
        }
        accLength += iterator.getCurrentSegmentLength();
        iterator.next();
    }
    return !isZeroLength;
}
Also used : CachedPathIterator(com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 5 with CachedPathIterator

use of com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator in project android_frameworks_base by crdroidandroid.

the class PathMeasure_Delegate method native_getSegment.

@LayoutlibDelegate
static /*package*/
boolean native_getSegment(long native_instance, float startD, float stopD, long native_dst_path, boolean startWithMoveTo) {
    if (startD < 0) {
        startD = 0;
    }
    if (startD >= stopD) {
        return false;
    }
    PathMeasure_Delegate pathMeasure = sManager.getDelegate(native_instance);
    assert pathMeasure != null;
    CachedPathIterator iterator = pathMeasure.mOriginalPathIterator.iterator();
    float accLength = startD;
    // Whether the output has zero length or not
    boolean isZeroLength = true;
    float[] points = new float[6];
    iterator.jumpToSegment(accLength);
    while (!iterator.isDone() && (stopD - accLength > 0.1f)) {
        int type = iterator.currentSegment(points, stopD - accLength);
        if (accLength - iterator.getCurrentSegmentLength() <= stopD) {
            if (startWithMoveTo) {
                startWithMoveTo = false;
                // a first moveto
                if (type != PathIterator.SEG_MOVETO) {
                    float[] lastPoint = new float[2];
                    iterator.getCurrentSegmentEnd(lastPoint);
                    Path_Delegate.native_moveTo(native_dst_path, lastPoint[0], lastPoint[1]);
                }
            }
            isZeroLength = isZeroLength && iterator.getCurrentSegmentLength() > 0;
            switch(type) {
                case PathIterator.SEG_MOVETO:
                    Path_Delegate.native_moveTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    Path_Delegate.native_lineTo(native_dst_path, points[0], points[1]);
                    break;
                case PathIterator.SEG_CLOSE:
                    Path_Delegate.native_close(native_dst_path);
                    break;
                case PathIterator.SEG_CUBICTO:
                    Path_Delegate.native_cubicTo(native_dst_path, points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;
                case PathIterator.SEG_QUADTO:
                    Path_Delegate.native_quadTo(native_dst_path, points[0], points[1], points[2], points[3]);
                    break;
                default:
                    assert false;
            }
        }
        accLength += iterator.getCurrentSegmentLength();
        iterator.next();
    }
    return !isZeroLength;
}
Also used : CachedPathIterator(com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Aggregations

CachedPathIterator (com.android.layoutlib.bridge.util.CachedPathIteratorFactory.CachedPathIterator)5 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)5