Skip to content

Commit

Permalink
DrawHandler: sync timer if DanmakuView is hidden during drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiao committed Nov 13, 2015
1 parent e9d4642 commit 32b1665
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package master.flame.danmaku.controller;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Handler;
Expand Down Expand Up @@ -103,20 +102,16 @@ public interface Callback {

private final RenderingState mRenderingState = new RenderingState();

@SuppressLint("Deprecated")
private int mSkipFrames;

private static final int MAX_RECORD_SIZE = 500;

private LinkedList<Long> mDrawTimes = new LinkedList<Long>();
private LinkedList<Long> mDrawTimes = new LinkedList<>();

private UpdateThread mThread;

private final boolean mUpdateInNewThread;

private long mCordonTime = 30;

@SuppressWarnings("unused")
private long mCordonTime2 = 60;

private long mFrameUpdateRate = 16;
Expand Down Expand Up @@ -287,7 +282,6 @@ public void run() {
}
quitFlag = true;
syncTimerIfNeeded();
mSkipFrames = 0;
if (mThread != null) {
notifyRendering();
quitUpdateThread();
Expand Down Expand Up @@ -350,6 +344,10 @@ private void updateInCurrentThread() {
}
d = mDanmakuView.drawDanmakus();
removeMessages(UPDATE);
if (d > mCordonTime2) { // this situation may be cuased by ui-thread waiting of DanmakuView, so we sync-timer at once
timer.add(d);
mDrawTimes.clear();
}
if (!mDanmakusVisible) {
waitRendering(INDEFINITE_TIME);
return;
Expand Down Expand Up @@ -392,6 +390,10 @@ public void run() {
continue;
}
d = mDanmakuView.drawDanmakus();
if (d > mCordonTime2) { // this situation may be cuased by ui-thread waiting of DanmakuView, so we sync-timer at once
timer.add(d);
mDrawTimes.clear();
}
if (!mDanmakusVisible) {
waitRendering(INDEFINITE_TIME);
} else if (mRenderingState.nothingRendered && mIdleSleep) {
Expand Down Expand Up @@ -589,7 +591,6 @@ private void notifyRendering() {
if(drawTask != null) {
drawTask.requestClear();
}
mSkipFrames = 0;
if (mUpdateInNewThread) {
synchronized (this) {
mDrawTimes.clear();
Expand Down

0 comments on commit 32b1665

Please sign in to comment.