Search in sources :

Example 1 with IDanmakuIterator

use of master.flame.danmaku.danmaku.model.IDanmakuIterator in project ABPlayer by winkstu.

the class DrawTask method removeUnusedLiveDanmakusIn.

protected void removeUnusedLiveDanmakusIn(int msec) {
    if (danmakuList == null || danmakuList.isEmpty())
        return;
    synchronized (danmakuList) {
        long startTime = System.currentTimeMillis();
        IDanmakuIterator it = danmakuList.iterator();
        while (it.hasNext()) {
            BaseDanmaku danmaku = it.next();
            boolean isTimeout = danmaku.isTimeOut();
            if (isTimeout && danmaku.isLive) {
                it.remove();
            }
            if (!isTimeout || System.currentTimeMillis() - startTime > msec) {
                break;
            }
        }
    }
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakuIterator(master.flame.danmaku.danmaku.model.IDanmakuIterator)

Example 2 with IDanmakuIterator

use of master.flame.danmaku.danmaku.model.IDanmakuIterator in project ABPlayer by winkstu.

the class DanmakuFactory method updateSpecialDanmakusDate.

private static void updateSpecialDanmakusDate(float scaleX, float scaleY) {
    IDanmakus list = sSpecialDanmakus;
    IDanmakuIterator it = list.iterator();
    while (it.hasNext()) {
        SpecialDanmaku speicalDanmaku = (SpecialDanmaku) it.next();
        fillTranslationData(speicalDanmaku, speicalDanmaku.beginX, speicalDanmaku.beginY, speicalDanmaku.endX, speicalDanmaku.endY, speicalDanmaku.translationDuration, speicalDanmaku.translationStartDelay, scaleX, scaleY);
        LinePath[] linePaths = speicalDanmaku.linePaths;
        if (linePaths != null && linePaths.length > 0) {
            int length = linePaths.length;
            float[][] points = new float[length + 1][2];
            for (int j = 0; j < length; j++) {
                points[j] = linePaths[j].getBeginPoint();
                points[j + 1] = linePaths[j].getEndPoint();
            }
            fillLinePathData(speicalDanmaku, points, scaleX, scaleY);
        }
    }
}
Also used : IDanmakuIterator(master.flame.danmaku.danmaku.model.IDanmakuIterator) LinePath(master.flame.danmaku.danmaku.model.SpecialDanmaku.LinePath) SpecialDanmaku(master.flame.danmaku.danmaku.model.SpecialDanmaku) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus)

Example 3 with IDanmakuIterator

use of master.flame.danmaku.danmaku.model.IDanmakuIterator in project ABPlayer by winkstu.

the class DanmakuRenderer method draw.

@Override
public RenderingState draw(IDisplayer disp, IDanmakus danmakus, long startRenderTime) {
    int lastTotalDanmakuCount = mRenderingState.totalDanmakuCount;
    mRenderingState.reset();
    IDanmakuIterator itr = danmakus.iterator();
    int orderInScreen = 0;
    mStartTimer.update(System.currentTimeMillis());
    int sizeInScreen = danmakus.size();
    BaseDanmaku drawItem = null;
    while (itr.hasNext()) {
        drawItem = itr.next();
        if (drawItem.isLate()) {
            break;
        }
        if (drawItem.time < startRenderTime || (drawItem.priority == 0 && DanmakuFilters.getDefault().filter(drawItem, orderInScreen, sizeInScreen, mStartTimer, false))) {
            continue;
        }
        if (drawItem.getType() == BaseDanmaku.TYPE_SCROLL_RL) {
            // 同屏弹幕密度只对滚动弹幕有效
            orderInScreen++;
        }
        // measure
        if (!drawItem.isMeasured()) {
            drawItem.measure(disp);
        }
        // layout
        DanmakusRetainer.fix(drawItem, disp);
        // draw
        if (!drawItem.isOutside() && drawItem.isShown()) {
            if (drawItem.lines == null && drawItem.getBottom() > disp.getHeight()) {
                // skip bottom outside danmaku
                continue;
            }
            int renderingType = drawItem.draw(disp);
            if (renderingType == IRenderer.CACHE_RENDERING) {
                mRenderingState.cacheHitCount++;
            } else if (renderingType == IRenderer.TEXT_RENDERING) {
                mRenderingState.cacheMissCount++;
            }
            mRenderingState.addCount(drawItem.getType(), 1);
            mRenderingState.addTotalCount(1);
        }
    }
    mRenderingState.nothingRendered = (mRenderingState.totalDanmakuCount == 0);
    mRenderingState.endTime = drawItem != null ? drawItem.time : RenderingState.UNKNOWN_TIME;
    if (mRenderingState.nothingRendered) {
        mRenderingState.beginTime = RenderingState.UNKNOWN_TIME;
    }
    mRenderingState.incrementCount = mRenderingState.totalDanmakuCount - lastTotalDanmakuCount;
    mRenderingState.consumingTime = mStartTimer.update(System.currentTimeMillis());
    return mRenderingState;
}
Also used : BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) IDanmakuIterator(master.flame.danmaku.danmaku.model.IDanmakuIterator)

Aggregations

IDanmakuIterator (master.flame.danmaku.danmaku.model.IDanmakuIterator)3 BaseDanmaku (master.flame.danmaku.danmaku.model.BaseDanmaku)2 IDanmakus (master.flame.danmaku.danmaku.model.IDanmakus)1 SpecialDanmaku (master.flame.danmaku.danmaku.model.SpecialDanmaku)1 LinePath (master.flame.danmaku.danmaku.model.SpecialDanmaku.LinePath)1