fixed thread safety problem in Viewport (#438)
recycled variables were accessed non synchronized (and therefore non thread safe) causing errors once multiple threads were used interacting with the Viewport
This commit is contained in:
parent
d23bca9c7f
commit
f94c665b27
@ -118,7 +118,7 @@ public class ViewController extends Viewport {
|
|||||||
mPos.y = mMinY;
|
mPos.y = mMinY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point applyRotation(double mx, double my) {
|
private synchronized Point applyRotation(double mx, double my) {
|
||||||
if (mPos.bearing == 0) {
|
if (mPos.bearing == 0) {
|
||||||
mMovePoint.x = mx;
|
mMovePoint.x = mx;
|
||||||
mMovePoint.y = my;
|
mMovePoint.y = my;
|
||||||
|
@ -210,7 +210,7 @@ public class Viewport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void unproject(float x, float y, float[] coords, int position) {
|
protected synchronized void unproject(float x, float y, float[] coords, int position) {
|
||||||
mv[0] = x;
|
mv[0] = x;
|
||||||
mv[1] = y;
|
mv[1] = y;
|
||||||
mv[2] = -1;
|
mv[2] = -1;
|
||||||
@ -242,7 +242,7 @@ public class Viewport {
|
|||||||
* the visible part of the map. Sets box to map coordinates:
|
* the visible part of the map. Sets box to map coordinates:
|
||||||
* xmin,ymin,xmax,ymax
|
* xmin,ymin,xmax,ymax
|
||||||
*/
|
*/
|
||||||
public Box getBBox(Box box, int expand) {
|
public synchronized Box getBBox(Box box, int expand) {
|
||||||
if (box == null)
|
if (box == null)
|
||||||
box = new Box();
|
box = new Box();
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ public class Viewport {
|
|||||||
* @param y screen coordinate
|
* @param y screen coordinate
|
||||||
* @return the corresponding GeoPoint
|
* @return the corresponding GeoPoint
|
||||||
*/
|
*/
|
||||||
public GeoPoint fromScreenPoint(float x, float y) {
|
public synchronized GeoPoint fromScreenPoint(float x, float y) {
|
||||||
fromScreenPoint(x, y, mMovePoint);
|
fromScreenPoint(x, y, mMovePoint);
|
||||||
return new GeoPoint(
|
return new GeoPoint(
|
||||||
MercatorProjection.toLatitude(mMovePoint.y),
|
MercatorProjection.toLatitude(mMovePoint.y),
|
||||||
@ -301,7 +301,7 @@ public class Viewport {
|
|||||||
* @param x screen coordinate
|
* @param x screen coordinate
|
||||||
* @param y screen coordinate
|
* @param y screen coordinate
|
||||||
*/
|
*/
|
||||||
public void fromScreenPoint(double x, double y, Point out) {
|
public synchronized void fromScreenPoint(double x, double y, Point out) {
|
||||||
unprojectScreen(x, y, mu);
|
unprojectScreen(x, y, mu);
|
||||||
|
|
||||||
double cs = mPos.scale * Tile.SIZE;
|
double cs = mPos.scale * Tile.SIZE;
|
||||||
@ -363,7 +363,7 @@ public class Viewport {
|
|||||||
*
|
*
|
||||||
* @param out Point projected to screen coordinate
|
* @param out Point projected to screen coordinate
|
||||||
*/
|
*/
|
||||||
public void toScreenPoint(double x, double y, boolean relativeToCenter, Point out) {
|
public synchronized void toScreenPoint(double x, double y, boolean relativeToCenter, Point out) {
|
||||||
|
|
||||||
double cs = mPos.scale * Tile.SIZE;
|
double cs = mPos.scale * Tile.SIZE;
|
||||||
double cx = mPos.x * cs;
|
double cx = mPos.x * cs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user