Пример #1
0
 protected RenderingState drawDanmakus(AbsDisplayer<?> disp, DanmakuTimer timer) {
   if (danmakuList != null) {
     Canvas canvas = (Canvas) disp.getExtraData();
     if (clearFlag > 0) {
       DrawHelper.clearCanvas(canvas);
       clearFlag--;
     } else {
       float[] refreshRect = mRenderer.getRefreshArea().mRefreshRect;
       mRectCache.push(refreshRect);
       float[] rect = mRectCache.getRect();
       DrawHelper.clearCanvas(
           canvas,
           Math.max(0, rect[0]),
           Math.max(0, rect[1]),
           Math.min(disp.getWidth(), rect[2]),
           Math.min(disp.getHeight(), rect[3]));
     }
     long currMills = timer.currMillisecond;
     danmakus = danmakuList.sub(currMills - DanmakuFactory.MAX_DANMAKU_DURATION - 100, currMills);
     if (danmakus != null) {
       return mRenderer.draw(mDisp, danmakus, mStartRenderTime);
     }
   }
   return null;
 }
Пример #2
0
 protected boolean handleOnDanmakuConfigChanged(
     DanmakuGlobalConfig config, DanmakuConfigTag tag, Object[] values) {
   boolean handled = false;
   if (tag == null || DanmakuConfigTag.MAXIMUM_NUMS_IN_SCREEN.equals(tag)) {
     handled = true;
   } else if (DanmakuConfigTag.DUPLICATE_MERGING_ENABLED.equals(tag)) {
     Boolean enable = (Boolean) values[0];
     if (enable != null) {
       if (enable) {
         DanmakuFilters.getDefault().registerFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
       } else {
         DanmakuFilters.getDefault().unregisterFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
       }
       handled = true;
     }
   } else if (DanmakuConfigTag.SCALE_TEXTSIZE.equals(tag)
       || DanmakuConfigTag.SCROLL_SPEED_FACTOR.equals(tag)) {
     requestClearRetainer();
     handled = false;
   } else if (DanmakuConfigTag.MAXIMUN_LINES.equals(tag)
       || DanmakuConfigTag.OVERLAPPING_ENABLE.equals(tag)) {
     if (mRenderer != null) {
       mRenderer.setVerifierEnabled(
           DanmakuGlobalConfig.DEFAULT.isPreventOverlappingEnabled()
               || DanmakuGlobalConfig.DEFAULT.isMaxLinesLimited());
     }
     handled = true;
   }
   return handled;
 }
Пример #3
0
 protected RenderingState drawDanmakus(AbsDisplayer<?> disp, DanmakuTimer timer) {
   if (clearRetainerFlag) {
     DanmakusRetainer.clear();
     clearRetainerFlag = false;
   }
   if (danmakuList != null) {
     Canvas canvas = (Canvas) disp.getExtraData();
     DrawHelper.clearCanvas(canvas);
     if (mIsHidden) {
       return mRenderingState;
     }
     long beginMills = timer.currMillisecond - DanmakuFactory.MAX_DANMAKU_DURATION - 100;
     long endMills = timer.currMillisecond + DanmakuFactory.MAX_DANMAKU_DURATION;
     if (mLastBeginMills > beginMills || timer.currMillisecond > mLastEndMills) {
       IDanmakus subDanmakus = danmakuList.sub(beginMills, endMills);
       if (subDanmakus != null) {
         danmakus = subDanmakus;
       } else {
         danmakus.clear();
       }
       mLastBeginMills = beginMills;
       mLastEndMills = endMills;
     } else {
       beginMills = mLastBeginMills;
       endMills = mLastEndMills;
     }
     if (danmakus != null && !danmakus.isEmpty()) {
       RenderingState renderingState =
           mRenderingState = mRenderer.draw(mDisp, danmakus, mStartRenderTime);
       if (renderingState.nothingRendered) {
         if (renderingState.beginTime == RenderingState.UNKNOWN_TIME) {
           renderingState.beginTime = beginMills;
         }
         if (renderingState.endTime == RenderingState.UNKNOWN_TIME) {
           renderingState.endTime = endMills;
         }
       }
       return renderingState;
     } else {
       mRenderingState.nothingRendered = true;
       mRenderingState.beginTime = beginMills;
       mRenderingState.endTime = endMills;
       return mRenderingState;
     }
   }
   return null;
 }
Пример #4
0
 public DrawTask(DanmakuTimer timer, AbsDisplayer<?> disp, TaskListener taskListener) {
   mTaskListener = taskListener;
   mRenderer = new DanmakuRenderer();
   mRenderer.setVerifierEnabled(
       DanmakuGlobalConfig.DEFAULT.isPreventOverlappingEnabled()
           || DanmakuGlobalConfig.DEFAULT.isMaxLinesLimited());
   mDisp = disp;
   initTimer(timer);
   Boolean enable = DanmakuGlobalConfig.DEFAULT.isDuplicateMergingEnabled();
   if (enable != null) {
     if (enable) {
       DanmakuFilters.getDefault().registerFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
     } else {
       DanmakuFilters.getDefault().unregisterFilter(DanmakuFilters.TAG_DUPLICATE_FILTER);
     }
   }
 }
Пример #5
0
 @Override
 public void quit() {
   DanmakuGlobalConfig.DEFAULT.unregisterAllConfigChangedCallbacks();
   if (mRenderer != null) mRenderer.release();
 }
Пример #6
0
 @Override
 public void reset() {
   if (danmakus != null) danmakus.clear();
   if (mRenderer != null) mRenderer.clear();
 }
Пример #7
0
 @Override
 public void quit() {
   if (mRenderer != null) mRenderer.release();
 }