opt
This commit is contained in:
@@ -4,6 +4,7 @@ import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
@@ -66,7 +67,23 @@ public class SimpleHandlerThreadPool {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
msg.obj = points.get( i );
|
||||
renderHandler.sendMessageDelayed( msg, ( i + 1 ) * 10 );
|
||||
renderHandler.sendMessageDelayed( msg, points.get(i).delay );
|
||||
}
|
||||
}
|
||||
|
||||
private long startMove = 0;
|
||||
private int lastIndex = 0;
|
||||
|
||||
private void slowTest(){
|
||||
if (startMove == 0) {
|
||||
startMove = SystemClock.uptimeMillis();
|
||||
} else {
|
||||
long diff = SystemClock.uptimeMillis() - startMove;
|
||||
int index = (int) (diff / 30);
|
||||
if (index - lastIndex > 1) {
|
||||
Logger.e("MapRenderSlow", "miss " + (index - lastIndex) + " diff: " + diff);
|
||||
}
|
||||
lastIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +92,11 @@ public class SimpleHandlerThreadPool {
|
||||
*
|
||||
* @param pointData
|
||||
*/
|
||||
private void moveMarker( BaseDrawer.MovingPoint pointData ) {
|
||||
if ( pointData == null ) {
|
||||
private void moveMarker(BaseDrawer.MovingPoint pointData) {
|
||||
if (pointData == null) {
|
||||
return;
|
||||
}
|
||||
// slowTest();
|
||||
pointData.move();
|
||||
}
|
||||
|
||||
@@ -175,6 +193,8 @@ public class SimpleHandlerThreadPool {
|
||||
return;
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
IMogoMarker marker = markerCache.get( uniqueKey );
|
||||
CloudRoadData lastPosition = roadDataCache.put( uniqueKey, cloudRoadData );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
@@ -217,21 +237,26 @@ public class SimpleHandlerThreadPool {
|
||||
|
||||
SnapshotSetDataDrawer.getInstance().changeIconResourceIfNecessary( cloudRoadData, marker );
|
||||
|
||||
// final IMogoMarker finalMarker = marker;
|
||||
final IMogoMarker finalMarker = marker;
|
||||
Logger.d( TAG, "work in " + Thread.currentThread().getName() );
|
||||
|
||||
if ( lastPosition != null ) {
|
||||
MogoLatLng endLatLon = new MogoLatLng( cloudRoadData.getWgslat(),cloudRoadData.getWgslon() );
|
||||
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
|
||||
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
interval -= cost;
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.getWgslat(), lastPosition.getWgslon() );
|
||||
BaseDrawer.MovingPoint endPoint = new BaseDrawer.MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.delay = interval;
|
||||
endPoint.angle = ( float ) cloudRoadData.getHeading();
|
||||
|
||||
BaseDrawer.MovingPoint startPoint = new BaseDrawer.MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.delay = 0;
|
||||
startPoint.angle = ( float ) lastPosition.getHeading();
|
||||
List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, interval );
|
||||
Message msg = new Message();
|
||||
@@ -258,6 +283,7 @@ public class SimpleHandlerThreadPool {
|
||||
// // 由于地图现在不支持addDynamicAnchorPosition并发,所以工作线程仅做相关计算,真正绘制发送到另外一条绘制线程中做
|
||||
// if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
// long interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get( uniqueKey );
|
||||
// interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
|
||||
// finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ), interval );
|
||||
// Logger.d( TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName() );
|
||||
// } else {
|
||||
|
||||
Reference in New Issue
Block a user