Java Code Examples for master.flame.danmaku.danmaku.model.IDisplayer#getHeight()

The following examples show how to use master.flame.danmaku.danmaku.model.IDisplayer#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDanmakuParser.java    From letv with Apache License 2.0 5 votes vote down vote up
public BaseDanmakuParser setDisplayer(IDisplayer disp) {
    this.mDisp = disp;
    this.mDispWidth = disp.getWidth();
    this.mDispHeight = disp.getHeight();
    this.mDispDensity = disp.getDensity();
    this.mScaledDensity = disp.getScaledDensity();
    this.mContext.mDanmakuFactory.updateViewportState((float) this.mDispWidth, (float) this.mDispHeight, getViewportSizeFactor());
    this.mContext.mDanmakuFactory.updateMaxDanmakuDuration();
    return this;
}
 
Example 2
Source File: DanmakuRenderer.java    From letv with Apache License 2.0 4 votes vote down vote up
public RenderingState draw(IDisplayer disp, IDanmakus danmakus, long startRenderTime) {
    int lastTotalDanmakuCount = this.mRenderingState.totalDanmakuCount;
    this.mRenderingState.reset();
    IDanmakuIterator itr = danmakus.iterator();
    int orderInScreen = 0;
    this.mStartTimer.update(SystemClock.uptimeMillis());
    int sizeInScreen = danmakus.size();
    BaseDanmaku drawItem = null;
    while (itr.hasNext()) {
        drawItem = itr.next();
        if (!drawItem.hasPassedFilter()) {
            this.mContext.mDanmakuFilters.filter(drawItem, orderInScreen, sizeInScreen, this.mStartTimer, false, this.mContext);
        }
        if (drawItem.time >= startRenderTime && (!(drawItem.priority == (byte) 0 && drawItem.isFiltered()) && drawItem.time >= startRenderTime)) {
            if (!drawItem.isDanmakuTypeFiltered || !drawItem.isFiltered()) {
                if (drawItem.isLate()) {
                    if (this.mCacheManager == null || drawItem.hasDrawingCache()) {
                        break;
                    }
                    this.mCacheManager.addDanmaku(drawItem);
                } else {
                    orderInScreen++;
                    if (!drawItem.isMeasured()) {
                        drawItem.measure(disp, false);
                    }
                    this.mDanmakusRetainer.fix(drawItem, disp, this.mVerifier);
                    if (!drawItem.isOutside() && drawItem.isShown()) {
                        if (drawItem.lines != null || drawItem.getBottom() <= ((float) disp.getHeight())) {
                            int renderingType = drawItem.draw(disp);
                            RenderingState renderingState;
                            if (renderingType == 1) {
                                renderingState = this.mRenderingState;
                                renderingState.cacheHitCount++;
                            } else if (renderingType == 2) {
                                renderingState = this.mRenderingState;
                                renderingState.cacheMissCount++;
                                if (this.mCacheManager != null) {
                                    this.mCacheManager.addDanmaku(drawItem);
                                }
                            }
                            this.mRenderingState.addCount(drawItem.getType(), 1);
                            this.mRenderingState.addTotalCount(1);
                            if (!(this.mOnDanmakuShownListener == null || drawItem.firstShownFlag == this.mContext.mGlobalFlagValues.FIRST_SHOWN_RESET_FLAG)) {
                                drawItem.firstShownFlag = this.mContext.mGlobalFlagValues.FIRST_SHOWN_RESET_FLAG;
                                this.mOnDanmakuShownListener.onDanmakuShown(drawItem);
                            }
                        }
                    }
                }
            }
        }
    }
    this.mRenderingState.nothingRendered = this.mRenderingState.totalDanmakuCount == 0;
    this.mRenderingState.endTime = drawItem != null ? drawItem.time : -1;
    if (this.mRenderingState.nothingRendered) {
        this.mRenderingState.beginTime = -1;
    }
    this.mRenderingState.incrementCount = this.mRenderingState.totalDanmakuCount - lastTotalDanmakuCount;
    this.mRenderingState.consumingTime = this.mStartTimer.update(SystemClock.uptimeMillis());
    return this.mRenderingState;
}
 
Example 3
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
public void fix(BaseDanmaku drawItem, IDisplayer disp, Verifier verifier) {
    if (!drawItem.isOutside()) {
        float topPos = 0.0f;
        int lines = 0;
        boolean willHit = (drawItem.isShown() || this.mVisibleDanmakus.isEmpty()) ? false : true;
        boolean isOutOfVertialEdge = false;
        boolean shown = drawItem.isShown();
        if (!shown) {
            boolean overwriteInsert;
            this.mCancelFixingFlag = false;
            IDanmakuIterator it = this.mVisibleDanmakus.iterator();
            BaseDanmaku insertItem = null;
            BaseDanmaku firstItem = null;
            BaseDanmaku lastItem = null;
            BaseDanmaku minRightRow = null;
            while (!this.mCancelFixingFlag && it.hasNext()) {
                lines++;
                BaseDanmaku item = it.next();
                if (item == drawItem) {
                    insertItem = item;
                    lastItem = null;
                    shown = true;
                    willHit = false;
                    overwriteInsert = false;
                    break;
                }
                if (firstItem == null) {
                    firstItem = item;
                }
                if (drawItem.paintHeight + item.getTop() > ((float) disp.getHeight())) {
                    overwriteInsert = true;
                    break;
                }
                if (minRightRow == null) {
                    minRightRow = item;
                } else if (minRightRow.getRight() >= item.getRight()) {
                    minRightRow = item;
                }
                willHit = DanmakuUtils.willHitInDuration(disp, item, drawItem, drawItem.getDuration(), drawItem.getTimer().currMillisecond);
                if (!willHit) {
                    insertItem = item;
                    overwriteInsert = false;
                    break;
                }
                lastItem = item;
            }
            overwriteInsert = false;
            boolean checkEdge = true;
            if (insertItem != null) {
                if (lastItem != null) {
                    topPos = lastItem.getBottom();
                } else {
                    topPos = insertItem.getTop();
                }
                if (insertItem != drawItem) {
                    this.mVisibleDanmakus.removeItem(insertItem);
                    shown = false;
                }
            } else if (overwriteInsert && minRightRow != null) {
                topPos = minRightRow.getTop();
                checkEdge = false;
                shown = false;
            } else if (lastItem != null) {
                topPos = lastItem.getBottom();
                willHit = false;
            } else if (firstItem != null) {
                topPos = firstItem.getTop();
                this.mVisibleDanmakus.removeItem(firstItem);
                shown = false;
            } else {
                topPos = 0.0f;
            }
            if (checkEdge) {
                isOutOfVertialEdge = isOutVerticalEdge(overwriteInsert, drawItem, disp, topPos, firstItem, lastItem);
            }
            if (isOutOfVertialEdge) {
                topPos = 0.0f;
                willHit = true;
            }
            if (topPos == 0.0f) {
                shown = false;
            }
        }
        if (verifier == null || !verifier.skipLayout(drawItem, topPos, lines, willHit)) {
            if (isOutOfVertialEdge) {
                clear();
            }
            drawItem.layout(disp, drawItem.getLeft(), topPos);
            if (!shown) {
                this.mVisibleDanmakus.addItem(drawItem);
            }
        }
    }
}
 
Example 4
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
protected boolean isOutVerticalEdge(boolean overwriteInsert, BaseDanmaku drawItem, IDisplayer disp, float topPos, BaseDanmaku firstItem, BaseDanmaku lastItem) {
    if (topPos < 0.0f || ((firstItem != null && firstItem.getTop() > 0.0f) || drawItem.paintHeight + topPos > ((float) disp.getHeight()))) {
        return true;
    }
    return false;
}
 
Example 5
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
protected boolean isOutVerticalEdge(boolean overwriteInsert, BaseDanmaku drawItem, IDisplayer disp, float topPos, BaseDanmaku firstItem, BaseDanmaku lastItem) {
    if (drawItem.paintHeight + topPos > ((float) disp.getHeight())) {
        return true;
    }
    return false;
}
 
Example 6
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
public void fix(BaseDanmaku drawItem, IDisplayer disp, Verifier verifier) {
    if (!drawItem.isOutside()) {
        boolean shown = drawItem.isShown();
        float topPos = drawItem.getTop();
        int lines = 0;
        boolean willHit = (drawItem.isShown() || this.mVisibleDanmakus.isEmpty()) ? false : true;
        boolean isOutOfVerticalEdge = false;
        if (topPos < 0.0f) {
            topPos = ((float) disp.getHeight()) - drawItem.paintHeight;
        }
        BaseDanmaku removeItem = null;
        BaseDanmaku firstItem = null;
        if (!shown) {
            this.mCancelFixingFlag = false;
            IDanmakuIterator it = this.mVisibleDanmakus.iterator();
            while (!this.mCancelFixingFlag && it.hasNext()) {
                lines++;
                BaseDanmaku item = it.next();
                if (item == drawItem) {
                    removeItem = null;
                    willHit = false;
                    break;
                }
                if (firstItem == null) {
                    firstItem = item;
                    if (firstItem.getBottom() != ((float) disp.getHeight())) {
                        break;
                    }
                }
                if (topPos < 0.0f) {
                    removeItem = null;
                    break;
                }
                willHit = DanmakuUtils.willHitInDuration(disp, item, drawItem, drawItem.getDuration(), drawItem.getTimer().currMillisecond);
                if (!willHit) {
                    removeItem = item;
                    break;
                }
                topPos = item.getTop() - drawItem.paintHeight;
            }
            isOutOfVerticalEdge = isOutVerticalEdge(false, drawItem, disp, topPos, firstItem, null);
            if (isOutOfVerticalEdge) {
                topPos = ((float) disp.getHeight()) - drawItem.paintHeight;
                willHit = true;
            } else if (topPos >= 0.0f) {
                willHit = false;
            }
        }
        if (verifier == null || !verifier.skipLayout(drawItem, topPos, lines, willHit)) {
            if (isOutOfVerticalEdge) {
                clear();
            }
            drawItem.layout(disp, drawItem.getLeft(), topPos);
            if (!shown) {
                this.mVisibleDanmakus.removeItem(removeItem);
                this.mVisibleDanmakus.addItem(drawItem);
            }
        }
    }
}
 
Example 7
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 4 votes vote down vote up
protected boolean isOutVerticalEdge(boolean overwriteInsert, BaseDanmaku drawItem, IDisplayer disp, float topPos, BaseDanmaku firstItem, BaseDanmaku lastItem) {
    if (topPos < 0.0f || (firstItem != null && firstItem.getBottom() != ((float) disp.getHeight()))) {
        return true;
    }
    return false;
}