get() for GL instance and other fixes for gwt compilation
This commit is contained in:
parent
970c0b6f0b
commit
1f8739023c
@ -85,7 +85,7 @@ public interface GL20 {
|
|||||||
public static final int GL_POLYGON_OFFSET_FILL = 0x8037;
|
public static final int GL_POLYGON_OFFSET_FILL = 0x8037;
|
||||||
public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
|
public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
|
||||||
public static final int GL_SAMPLE_COVERAGE = 0x80A0;
|
public static final int GL_SAMPLE_COVERAGE = 0x80A0;
|
||||||
public static final int GL_NO_ERROR = 0;
|
//public static final int GL_NO_ERROR = 0;
|
||||||
public static final int GL_INVALID_ENUM = 0x0500;
|
public static final int GL_INVALID_ENUM = 0x0500;
|
||||||
public static final int GL_INVALID_VALUE = 0x0501;
|
public static final int GL_INVALID_VALUE = 0x0501;
|
||||||
public static final int GL_INVALID_OPERATION = 0x0502;
|
public static final int GL_INVALID_OPERATION = 0x0502;
|
||||||
|
|||||||
@ -18,4 +18,8 @@ package org.oscim.backend;
|
|||||||
|
|
||||||
public class GLAdapter {
|
public class GLAdapter {
|
||||||
public static GL20 INSTANCE; //= new AndroidGL20();
|
public static GL20 INSTANCE; //= new AndroidGL20();
|
||||||
|
|
||||||
|
public static GL20 get(){
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ import org.oscim.view.MapViewPosition;
|
|||||||
|
|
||||||
class TextRenderLayer extends BasicRenderLayer {
|
class TextRenderLayer extends BasicRenderLayer {
|
||||||
private final static String TAG = TextRenderLayer.class.getName();
|
private final static String TAG = TextRenderLayer.class.getName();
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private final static float MIN_CAPTION_DIST = 5;
|
private final static float MIN_CAPTION_DIST = 5;
|
||||||
private final static float MIN_WAY_DIST = 3;
|
private final static float MIN_WAY_DIST = 3;
|
||||||
|
|||||||
@ -77,17 +77,17 @@ public abstract class TileLayer<T extends TileLoader> extends Layer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
for (T tileWorker : mTileLoader) {
|
for (T loader : mTileLoader) {
|
||||||
tileWorker.pause();
|
loader.pause();
|
||||||
tileWorker.interrupt();
|
loader.interrupt();
|
||||||
tileWorker.cleanup();
|
loader.cleanup();
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
tileWorker.join(10000);
|
// tileWorker.join(10000);
|
||||||
} catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
// restore the interrupted status
|
// // restore the interrupted status
|
||||||
Thread.currentThread().interrupt();
|
// Thread.currentThread().interrupt();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
mTileManager.destroy();
|
mTileManager.destroy();
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ public abstract class TileLayer<T extends TileLoader> extends Layer {
|
|||||||
for (int i = 0; i < mNumTileLoader; i++) {
|
for (int i = 0; i < mNumTileLoader; i++) {
|
||||||
T m = mTileLoader.get(i);
|
T m = mTileLoader.get(i);
|
||||||
synchronized (m) {
|
synchronized (m) {
|
||||||
m.notify();
|
m.go();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,9 @@ public abstract class TileLoader extends PausableThread {
|
|||||||
|
|
||||||
protected abstract boolean executeJob(MapTile tile);
|
protected abstract boolean executeJob(MapTile tile);
|
||||||
|
|
||||||
|
public void go(){
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doWork() {
|
protected void doWork() {
|
||||||
|
|||||||
@ -34,15 +34,13 @@ import org.oscim.view.MapView;
|
|||||||
import org.oscim.view.MapViewPosition;
|
import org.oscim.view.MapViewPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @TODO
|
* @TODO - prefetching to cache file - this class should probably not be in
|
||||||
* - prefetching to cache file
|
* 'renderer' -> tilemap? - make it general for reuse in tile-overlays
|
||||||
* - this class should probably not be in 'renderer' -> tilemap?
|
|
||||||
* - make it general for reuse in tile-overlays
|
|
||||||
*/
|
*/
|
||||||
public class TileManager {
|
public class TileManager {
|
||||||
private static final int CACHE_TILES_MAX = 250;
|
private static final int CACHE_TILES_MAX = 250;
|
||||||
|
|
||||||
static final String TAG = TileManager.class.getSimpleName();
|
static final String TAG = TileManager.class.getName();
|
||||||
private final static int MIN_ZOOMLEVEL = 2;
|
private final static int MIN_ZOOMLEVEL = 2;
|
||||||
|
|
||||||
private final int mMaxZoom;
|
private final int mMaxZoom;
|
||||||
@ -56,7 +54,6 @@ public class TileManager {
|
|||||||
private final MapView mMapView;
|
private final MapView mMapView;
|
||||||
private final MapViewPosition mMapViewPosition;
|
private final MapViewPosition mMapViewPosition;
|
||||||
|
|
||||||
|
|
||||||
// cache for all tiles
|
// cache for all tiles
|
||||||
private MapTile[] mTiles;
|
private MapTile[] mTiles;
|
||||||
|
|
||||||
@ -80,7 +77,7 @@ public class TileManager {
|
|||||||
private final Object mTilelock = new Object();
|
private final Object mTilelock = new Object();
|
||||||
|
|
||||||
// need to keep track of TileSets to clear on reset.
|
// need to keep track of TileSets to clear on reset.
|
||||||
//private final ArrayList<TileSet> mTileSets = new ArrayList<TileSet>(4);
|
// private final ArrayList<TileSet> mTileSets = new ArrayList<TileSet>(4);
|
||||||
|
|
||||||
private TileSet mCurrentTiles;
|
private TileSet mCurrentTiles;
|
||||||
/* package */TileSet mNewTiles;
|
/* package */TileSet mNewTiles;
|
||||||
@ -148,7 +145,7 @@ public class TileManager {
|
|||||||
|
|
||||||
// sync with GLRender thread
|
// sync with GLRender thread
|
||||||
// ... and labeling thread?
|
// ... and labeling thread?
|
||||||
GLRenderer.drawlock.lock();
|
synchronized (GLRenderer.drawlock) {
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
// pass VBOs and VertexItems back to pools
|
// pass VBOs and VertexItems back to pools
|
||||||
@ -177,13 +174,12 @@ public class TileManager {
|
|||||||
mCurrentTiles = new TileSet(numTiles);
|
mCurrentTiles = new TileSet(numTiles);
|
||||||
Log.d(TAG, "max tiles: " + numTiles);
|
Log.d(TAG, "max tiles: " + numTiles);
|
||||||
|
|
||||||
GLRenderer.drawlock.unlock();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Update mCurrentTiles TileSet of currently visible tiles.
|
* 1. Update mCurrentTiles TileSet of currently visible tiles. 2. Add not
|
||||||
* 2. Add not yet loaded (or loading) tiles to JobQueue.
|
* yet loaded (or loading) tiles to JobQueue. 3. Manage cache
|
||||||
* 3. Manage cache
|
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
* current MapPosition
|
* current MapPosition
|
||||||
@ -202,9 +198,9 @@ public class TileManager {
|
|||||||
|
|
||||||
int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, mMaxZoom);
|
int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, mMaxZoom);
|
||||||
|
|
||||||
if (mZoomTable != null){
|
if (mZoomTable != null) {
|
||||||
int match = 0;
|
int match = 0;
|
||||||
for (int z : mZoomTable){
|
for (int z : mZoomTable) {
|
||||||
if (z <= tileZoom && z > match)
|
if (z <= tileZoom && z > match)
|
||||||
match = z;
|
match = z;
|
||||||
}
|
}
|
||||||
@ -260,7 +256,7 @@ public class TileManager {
|
|||||||
|
|
||||||
mUpdateSerial++;
|
mUpdateSerial++;
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, newCnt + " << " + Arrays.deepToString(mCurrentTiles.tiles));
|
||||||
// request rendering as tiles changed
|
// request rendering as tiles changed
|
||||||
mMapView.render();
|
mMapView.render();
|
||||||
}
|
}
|
||||||
@ -294,12 +290,12 @@ public class TileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrive a TileSet of current tiles.
|
* Retrive a TileSet of current tiles. Tiles remain locked in cache until
|
||||||
* Tiles remain locked in cache until the set is unlocked by either passing
|
* the set is unlocked by either passing it again to this function or to
|
||||||
* it again to this function or to releaseTiles. If passed TileSet is null
|
* releaseTiles. If passed TileSet is null it will be allocated.
|
||||||
* it will be allocated.
|
|
||||||
*
|
*
|
||||||
* @param tileSet to be updated
|
* @param tileSet
|
||||||
|
* to be updated
|
||||||
* @return true if TileSet has changed
|
* @return true if TileSet has changed
|
||||||
*/
|
*/
|
||||||
public boolean getActiveTiles(TileSet tileSet) {
|
public boolean getActiveTiles(TileSet tileSet) {
|
||||||
@ -352,7 +348,7 @@ public class TileManager {
|
|||||||
/* package */MapTile addTile(int x, int y, int zoomLevel) {
|
/* package */MapTile addTile(int x, int y, int zoomLevel) {
|
||||||
MapTile tile;
|
MapTile tile;
|
||||||
|
|
||||||
//tile = QuadTree.getTile(x, y, zoomLevel);
|
// tile = QuadTree.getTile(x, y, zoomLevel);
|
||||||
tile = mIndex.getTile(x, y, zoomLevel);
|
tile = mIndex.getTile(x, y, zoomLevel);
|
||||||
|
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
@ -432,7 +428,7 @@ public class TileManager {
|
|||||||
|
|
||||||
mIndex.remove(t);
|
mIndex.remove(t);
|
||||||
|
|
||||||
//QuadTree.remove(t);
|
// QuadTree.remove(t);
|
||||||
t.state = STATE_NONE;
|
t.state = STATE_NONE;
|
||||||
|
|
||||||
mTilesCount--;
|
mTilesCount--;
|
||||||
@ -509,8 +505,8 @@ public class TileManager {
|
|||||||
// so end of mTiles is at mTilesCount now
|
// so end of mTiles is at mTilesCount now
|
||||||
size = mTilesSize = mTilesCount;
|
size = mTilesSize = mTilesCount;
|
||||||
|
|
||||||
//Log.d(TAG, "remove:" + remove + " new:" + newTileCnt);
|
// Log.d(TAG, "remove:" + remove + " new:" + newTileCnt);
|
||||||
//Log.d(TAG, "cur: " + mapPosition);
|
// Log.d(TAG, "cur: " + mapPosition);
|
||||||
|
|
||||||
for (int i = size - 1; i >= 0 && remove > 0; i--) {
|
for (int i = size - 1; i >= 0 && remove > 0; i--) {
|
||||||
MapTile t = tiles[i];
|
MapTile t = tiles[i];
|
||||||
@ -533,7 +529,7 @@ public class TileManager {
|
|||||||
// clear unused tile
|
// clear unused tile
|
||||||
|
|
||||||
if (t.state == STATE_NEW_DATA) {
|
if (t.state == STATE_NEW_DATA) {
|
||||||
//Log.d(TAG, "limitCache: clear unused " + t
|
// Log.d(TAG, "limitCache: clear unused " + t
|
||||||
// + " " + t.distance);
|
// + " " + t.distance);
|
||||||
newTileCnt--;
|
newTileCnt--;
|
||||||
}
|
}
|
||||||
@ -545,7 +541,7 @@ public class TileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove = (newTileCnt - MAX_TILES_IN_QUEUE) + 10;
|
remove = (newTileCnt - MAX_TILES_IN_QUEUE) + 10;
|
||||||
//int r = remove;
|
// int r = remove;
|
||||||
for (int i = size - 1; i >= 0 && remove > 0; i--) {
|
for (int i = size - 1; i >= 0 && remove > 0; i--) {
|
||||||
MapTile t = tiles[i];
|
MapTile t = tiles[i];
|
||||||
if (t != null && t.state == STATE_NEW_DATA) {
|
if (t != null && t.state == STATE_NEW_DATA) {
|
||||||
@ -559,7 +555,8 @@ public class TileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mTilesForUpload += newTileCnt;
|
mTilesForUpload += newTileCnt;
|
||||||
//Log.d(TAG, "cleanup load queue " + tilesForUpload + "/" + r + " - " + remove);
|
// Log.d(TAG, "cleanup load queue " + tilesForUpload + "/" + r +
|
||||||
|
// " - " + remove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +573,7 @@ public class TileManager {
|
|||||||
// - should rather be STATE_FAILED
|
// - should rather be STATE_FAILED
|
||||||
// no one should be able to use this tile now, MapTileLoader passed
|
// no one should be able to use this tile now, MapTileLoader passed
|
||||||
// it, GL-Thread does nothing until newdata is set.
|
// it, GL-Thread does nothing until newdata is set.
|
||||||
//Log.d(TAG, "passTile: failed loading " + tile);
|
// Log.d(TAG, "passTile: failed loading " + tile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,15 +17,16 @@ package org.oscim.layers.tile;
|
|||||||
import static org.oscim.layers.tile.MapTile.STATE_NEW_DATA;
|
import static org.oscim.layers.tile.MapTile.STATE_NEW_DATA;
|
||||||
import static org.oscim.layers.tile.MapTile.STATE_READY;
|
import static org.oscim.layers.tile.MapTile.STATE_READY;
|
||||||
|
|
||||||
import org.oscim.view.MapView;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.oscim.backend.Log;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.renderer.BufferObject;
|
import org.oscim.renderer.BufferObject;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
import org.oscim.renderer.RenderLayer;
|
import org.oscim.renderer.RenderLayer;
|
||||||
import org.oscim.utils.ScanBox;
|
import org.oscim.utils.ScanBox;
|
||||||
|
import org.oscim.view.MapView;
|
||||||
import org.oscim.backend.Log;
|
|
||||||
|
|
||||||
public class TileRenderLayer extends RenderLayer {
|
public class TileRenderLayer extends RenderLayer {
|
||||||
private final static String TAG = TileRenderLayer.class.getName();
|
private final static String TAG = TileRenderLayer.class.getName();
|
||||||
@ -62,13 +63,15 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
int tileCnt = mDrawTiles.cnt;
|
int tileCnt = mDrawTiles.cnt;
|
||||||
MapTile[] tiles = mDrawTiles.tiles;
|
MapTile[] tiles = mDrawTiles.tiles;
|
||||||
|
|
||||||
if (tilesChanged || positionChanged)
|
if (tilesChanged || positionChanged){
|
||||||
updateTileVisibility(m.mapPlane);
|
updateTileVisibility(m.mapPlane);
|
||||||
|
Log.d(TAG, tileCnt + " >> " + Arrays.deepToString(tiles));
|
||||||
|
|
||||||
|
}
|
||||||
tileCnt += mNumTileHolder;
|
tileCnt += mNumTileHolder;
|
||||||
|
|
||||||
/* prepare tile for rendering */
|
/* prepare tile for rendering */
|
||||||
if (compileTileLayers(tiles, tileCnt) > 0){
|
if (compileTileLayers(tiles, tileCnt) > 0) {
|
||||||
mUploadSerial++;
|
mUploadSerial++;
|
||||||
BufferObject.checkBufferUsage(false);
|
BufferObject.checkBufferUsage(false);
|
||||||
}
|
}
|
||||||
@ -89,9 +92,9 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
public void clearTiles() {
|
public void clearTiles() {
|
||||||
// Clear all references to MapTiles as all current
|
// Clear all references to MapTiles as all current
|
||||||
// tiles will also be removed from TileManager.
|
// tiles will also be removed from TileManager.
|
||||||
GLRenderer.drawlock.lock();
|
synchronized (GLRenderer.drawlock) {
|
||||||
mDrawTiles = new TileSet();
|
mDrawTiles = new TileSet();
|
||||||
GLRenderer.drawlock.unlock();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** compile tile layer data and upload to VBOs */
|
/** compile tile layer data and upload to VBOs */
|
||||||
@ -192,8 +195,8 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update tileSet with currently visible tiles
|
* Update tileSet with currently visible tiles get a TileSet of currently
|
||||||
* get a TileSet of currently visible tiles
|
* visible tiles
|
||||||
*/
|
*/
|
||||||
public boolean getVisibleTiles(TileSet tileSet) {
|
public boolean getVisibleTiles(TileSet tileSet) {
|
||||||
if (tileSet == null)
|
if (tileSet == null)
|
||||||
@ -205,8 +208,8 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// same tiles as before
|
// same tiles as before
|
||||||
//if (tileSet.serial == mDrawTiles.serial)
|
// if (tileSet.serial == mDrawTiles.serial)
|
||||||
//return false;
|
// return false;
|
||||||
|
|
||||||
int prevSerial = tileSet.serial;
|
int prevSerial = tileSet.serial;
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ import org.oscim.utils.quadtree.QuadTree;
|
|||||||
public class TileRenderer {
|
public class TileRenderer {
|
||||||
//private final static String TAG = TileRenderer.class.getName();
|
//private final static String TAG = TileRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
// Counter increases polygon-offset for each tile drawn.
|
// Counter increases polygon-offset for each tile drawn.
|
||||||
private static int mOffsetCnt;
|
private static int mOffsetCnt;
|
||||||
@ -153,7 +153,7 @@ public class TileRenderer {
|
|||||||
|
|
||||||
// simple line shader does not take forward shortening into
|
// simple line shader does not take forward shortening into
|
||||||
// account. only used when tilt is 0.
|
// account. only used when tilt is 0.
|
||||||
int simpleShader = (pos.tilt < 1 ? 1 : 0);
|
int simpleShader = 1; //(pos.tilt < 1 ? 1 : 0);
|
||||||
|
|
||||||
boolean clipped = false;
|
boolean clipped = false;
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import org.oscim.utils.GlUtils;
|
|||||||
public final class BufferObject {
|
public final class BufferObject {
|
||||||
private final static String TAG = BufferObject.class.getName();
|
private final static String TAG = BufferObject.class.getName();
|
||||||
|
|
||||||
private final static GL20 GL = GLAdapter.INSTANCE;
|
private final static GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private static final int MB = 1024 * 1024;
|
private static final int MB = 1024 * 1024;
|
||||||
private static final int LIMIT_BUFFERS = 16 * MB;
|
private static final int LIMIT_BUFFERS = 16 * MB;
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import java.nio.ByteOrder;
|
|||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.oscim.backend.GL20;
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
@ -39,7 +38,7 @@ import org.oscim.view.MapViewPosition;
|
|||||||
public class GLRenderer {
|
public class GLRenderer {
|
||||||
private static final String TAG = GLRenderer.class.getName();
|
private static final String TAG = GLRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private static final int SHORT_BYTES = 2;
|
private static final int SHORT_BYTES = 2;
|
||||||
private static final int CACHE_TILES_MAX = 250;
|
private static final int CACHE_TILES_MAX = 250;
|
||||||
@ -97,7 +96,7 @@ public class GLRenderer {
|
|||||||
|
|
||||||
// drawlock to synchronize Main- and GL-Thread
|
// drawlock to synchronize Main- and GL-Thread
|
||||||
// static ReentrantLock tilelock = new ReentrantLock();
|
// static ReentrantLock tilelock = new ReentrantLock();
|
||||||
public static ReentrantLock drawlock = new ReentrantLock();
|
public static Object drawlock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mapView
|
* @param mapView
|
||||||
@ -252,11 +251,8 @@ public class GLRenderer {
|
|||||||
|
|
||||||
// prevent main thread recreating all tiles (updateMap)
|
// prevent main thread recreating all tiles (updateMap)
|
||||||
// while rendering is going on.
|
// while rendering is going on.
|
||||||
drawlock.lock();
|
synchronized(drawlock){
|
||||||
try {
|
|
||||||
draw();
|
draw();
|
||||||
} finally {
|
|
||||||
drawlock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mBufferPool.releaseBuffers();
|
mBufferPool.releaseBuffers();
|
||||||
@ -348,7 +344,7 @@ public class GLRenderer {
|
|||||||
mMatrices.mvp.setScale(0.5f, 0.5f, 1);
|
mMatrices.mvp.setScale(0.5f, 0.5f, 1);
|
||||||
mMatrices.proj.multiplyLhs(mMatrices.mvp);
|
mMatrices.proj.multiplyLhs(mMatrices.mvp);
|
||||||
}
|
}
|
||||||
|
GL = GLAdapter.get();
|
||||||
GL.glViewport(0, 0, width, height);
|
GL.glViewport(0, 0, width, height);
|
||||||
GL.glScissor(0, 0, width, height);
|
GL.glScissor(0, 0, width, height);
|
||||||
GL.glEnable(GL20.GL_SCISSOR_TEST);
|
GL.glEnable(GL20.GL_SCISSOR_TEST);
|
||||||
@ -399,6 +395,9 @@ public class GLRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceCreated() {
|
public void onSurfaceCreated() {
|
||||||
|
|
||||||
|
Log.d(TAG, "surface created");
|
||||||
|
|
||||||
// Log.d(TAG, GL.glGetString(GL20.GL_EXTENSIONS));
|
// Log.d(TAG, GL.glGetString(GL20.GL_EXTENSIONS));
|
||||||
|
|
||||||
// classes that require GL context for initialization
|
// classes that require GL context for initialization
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import org.oscim.backend.GLAdapter;
|
|||||||
import org.oscim.backend.Log;
|
import org.oscim.backend.Log;
|
||||||
|
|
||||||
public class GLState {
|
public class GLState {
|
||||||
private final static GL20 GL = GLAdapter.INSTANCE;
|
private final static GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private final static String TAG = GLState.class.getName();
|
private final static String TAG = GLState.class.getName();
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import org.oscim.view.MapView;
|
|||||||
*/
|
*/
|
||||||
public abstract class BasicRenderLayer extends RenderLayer {
|
public abstract class BasicRenderLayer extends RenderLayer {
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
public final Layers layers;
|
public final Layers layers;
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import org.oscim.view.MapView;
|
|||||||
|
|
||||||
public class CustomRenderLayer extends RenderLayer {
|
public class CustomRenderLayer extends RenderLayer {
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private int mProgramObject;
|
private int mProgramObject;
|
||||||
private int hVertexPosition;
|
private int hVertexPosition;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ import org.oscim.view.MapView;
|
|||||||
|
|
||||||
public class CustomRenderLayer2 extends RenderLayer {
|
public class CustomRenderLayer2 extends RenderLayer {
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private int mProgramObject;
|
private int mProgramObject;
|
||||||
private int hVertexPosition;
|
private int hVertexPosition;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import org.oscim.view.MapView;
|
|||||||
public class ExtrusionRenderLayer extends RenderLayer {
|
public class ExtrusionRenderLayer extends RenderLayer {
|
||||||
private final static String TAG = ExtrusionRenderLayer.class.getName();
|
private final static String TAG = ExtrusionRenderLayer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private final TileRenderLayer mTileLayer;
|
private final TileRenderLayer mTileLayer;
|
||||||
|
|
||||||
@ -421,14 +421,14 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
|||||||
+ "}}}";
|
+ "}}}";
|
||||||
|
|
||||||
final static String extrusionFragmentShader = ""
|
final static String extrusionFragmentShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "varying vec4 color;"
|
+ "varying vec4 color;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
+ " gl_FragColor = color;"
|
+ " gl_FragColor = color;"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final static String extrusionFragmentShaderZ = ""
|
final static String extrusionFragmentShaderZ = ""
|
||||||
// + "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "varying float depth;"
|
+ "varying float depth;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
+ "float d = depth * 0.2;"
|
+ "float d = depth * 0.2;"
|
||||||
|
|||||||
@ -14,9 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.renderer.layers;
|
package org.oscim.renderer.layers;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.oscim.view.MapView;
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.backend.canvas.Paint.Cap;
|
import org.oscim.backend.canvas.Paint.Cap;
|
||||||
import org.oscim.core.GeometryBuffer;
|
import org.oscim.core.GeometryBuffer;
|
||||||
@ -24,15 +21,13 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
import org.oscim.renderer.sublayers.LineLayer;
|
import org.oscim.renderer.sublayers.LineLayer;
|
||||||
import org.oscim.renderer.sublayers.TextItem;
|
|
||||||
import org.oscim.renderer.sublayers.TextLayer;
|
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.renderinstruction.Line;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.view.MapView;
|
||||||
|
|
||||||
public class GridRenderLayer extends BasicRenderLayer {
|
public class GridRenderLayer extends BasicRenderLayer {
|
||||||
private final static String TILE_FORMAT = "%d/%d/%d";
|
private final static String TILE_FORMAT = "%d/%d/%d";
|
||||||
private final TextLayer mTextLayer;
|
// private final TextLayer mTextLayer;
|
||||||
private final Text mText;
|
// private final Text mText;
|
||||||
|
|
||||||
private final LineLayer mLineLayer;
|
private final LineLayer mLineLayer;
|
||||||
|
|
||||||
@ -67,44 +62,44 @@ public class GridRenderLayer extends BasicRenderLayer {
|
|||||||
mLines.addPoint(pos + size * 8, y);
|
mLines.addPoint(pos + size * 8, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
mText = Text.createText(22, 0, Color.RED, 0, false);
|
// mText = Text.createText(22, 0, Color.RED, 0, false);
|
||||||
|
|
||||||
mTextLayer = layers.addTextLayer(new TextLayer());
|
// mTextLayer = layers.addTextLayer(new TextLayer());
|
||||||
mLineLayer = layers.addLineLayer(0,
|
mLineLayer = layers.addLineLayer(0,
|
||||||
new Line(Color.BLUE, 1.5f, Cap.BUTT));
|
new Line(Color.BLUE, 1.5f, Cap.BUTT));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLabels(int x, int y, int z) {
|
// private void addLabels(int x, int y, int z) {
|
||||||
int s = Tile.SIZE;
|
// int s = Tile.SIZE;
|
||||||
|
//
|
||||||
TextLayer tl = mTextLayer;
|
// TextLayer tl = mTextLayer;
|
||||||
tl.clear();
|
// tl.clear();
|
||||||
|
//
|
||||||
for (int yy = -2; yy < 2; yy++) {
|
// for (int yy = -2; yy < 2; yy++) {
|
||||||
for (int xx = -2; xx < 2; xx++) {
|
// for (int xx = -2; xx < 2; xx++) {
|
||||||
|
//
|
||||||
// String label = String.format(
|
// // String label = String.format(
|
||||||
// Locale.ROOT, TILE_FORMAT,
|
// // Locale.ROOT, TILE_FORMAT,
|
||||||
// Integer.valueOf(x + xx),
|
// // Integer.valueOf(x + xx),
|
||||||
// Integer.valueOf(y + yy),
|
// // Integer.valueOf(y + yy),
|
||||||
// Integer.valueOf(z));
|
// // Integer.valueOf(z));
|
||||||
String label = Integer.valueOf(x + xx) + "/" +
|
// String label = Integer.valueOf(x + xx) + "/" +
|
||||||
Integer.valueOf(y + yy) + "/" +
|
// Integer.valueOf(y + yy) + "/" +
|
||||||
Integer.valueOf(z);
|
// Integer.valueOf(z);
|
||||||
|
//
|
||||||
TextItem ti = TextItem.pool.get();
|
// TextItem ti = TextItem.pool.get();
|
||||||
ti.set(s * xx + s / 2, s * yy + s / 2, label, mText);
|
// ti.set(s * xx + s / 2, s * yy + s / 2, label, mText);
|
||||||
|
//
|
||||||
tl.addText(ti);
|
// tl.addText(ti);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// render TextItems to a bitmap and prepare vertex buffer data.
|
// // render TextItems to a bitmap and prepare vertex buffer data.
|
||||||
tl.prepare();
|
// tl.prepare();
|
||||||
|
//
|
||||||
// release TextItems
|
// // release TextItems
|
||||||
tl.clearLabels();
|
// tl.clearLabels();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(MapPosition pos, boolean changed, Matrices m) {
|
public void update(MapPosition pos, boolean changed, Matrices m) {
|
||||||
@ -129,7 +124,7 @@ public class GridRenderLayer extends BasicRenderLayer {
|
|||||||
layerPos.y = (double) y / z;
|
layerPos.y = (double) y / z;
|
||||||
layerPos.scale = z;
|
layerPos.scale = z;
|
||||||
|
|
||||||
addLabels(x, y, pos.zoomLevel);
|
// addLabels(x, y, pos.zoomLevel);
|
||||||
|
|
||||||
mLineLayer.clear();
|
mLineLayer.clear();
|
||||||
mLineLayer.addLine(mLines);
|
mLineLayer.addLine(mLines);
|
||||||
|
|||||||
@ -57,7 +57,7 @@ import org.oscim.view.MapViewPosition;
|
|||||||
|
|
||||||
public class TextRenderLayer extends BasicRenderLayer {
|
public class TextRenderLayer extends BasicRenderLayer {
|
||||||
private final static String TAG = TextRenderLayer.class.getName();
|
private final static String TAG = TextRenderLayer.class.getName();
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private final static float MIN_CAPTION_DIST = 5;
|
private final static float MIN_CAPTION_DIST = 5;
|
||||||
private final static float MIN_WAY_DIST = 3;
|
private final static float MIN_WAY_DIST = 3;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import org.oscim.utils.GlUtils;
|
|||||||
public final class BitmapRenderer {
|
public final class BitmapRenderer {
|
||||||
|
|
||||||
//private final static String TAG = BitmapRenderer.class.getName();
|
//private final static String TAG = BitmapRenderer.class.getName();
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
public final static boolean debug = true;
|
public final static boolean debug = true;
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import org.oscim.utils.LineClipper;
|
|||||||
public class ExtrusionLayer extends Layer {
|
public class ExtrusionLayer extends Layer {
|
||||||
private final static String TAG = ExtrusionLayer.class.getName();
|
private final static String TAG = ExtrusionLayer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private static final float S = GLRenderer.COORD_SCALE;
|
private static final float S = GLRenderer.COORD_SCALE;
|
||||||
private VertexItem mVertices;
|
private VertexItem mVertices;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import org.oscim.utils.GlUtils;
|
|||||||
public final class LineRenderer {
|
public final class LineRenderer {
|
||||||
private final static String TAG = LineRenderer.class.getName();
|
private final static String TAG = LineRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static GL20 GL;
|
||||||
|
|
||||||
private static final int LINE_VERTICES_DATA_POS_OFFSET = 0;
|
private static final int LINE_VERTICES_DATA_POS_OFFSET = 0;
|
||||||
|
|
||||||
@ -46,6 +46,8 @@ public final class LineRenderer {
|
|||||||
private static int mTexID;
|
private static int mTexID;
|
||||||
|
|
||||||
static boolean init() {
|
static boolean init() {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
lineProgram[0] = GlUtils.createProgram(lineVertexShader,
|
lineProgram[0] = GlUtils.createProgram(lineVertexShader,
|
||||||
lineFragmentShader);
|
lineFragmentShader);
|
||||||
if (lineProgram[0] == 0) {
|
if (lineProgram[0] == 0) {
|
||||||
@ -93,11 +95,11 @@ public final class LineRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void beginLines() {
|
public static void beginLines() {
|
||||||
//GL.glBindTexture(GL20.GL_TEXTURE_2D, mTexID);
|
GL.glBindTexture(GL20.GL_TEXTURE_2D, mTexID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void endLines() {
|
public static void endLines() {
|
||||||
//GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Layer draw(Layers layers, Layer curLayer, MapPosition pos,
|
public static Layer draw(Layers layers, Layer curLayer, MapPosition pos,
|
||||||
@ -249,7 +251,7 @@ public final class LineRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String lineVertexShader = ""
|
private final static String lineVertexShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform mat4 u_mvp;"
|
+ "uniform mat4 u_mvp;"
|
||||||
// factor to increase line width relative to scale
|
// factor to increase line width relative to scale
|
||||||
+ "uniform float u_width;"
|
+ "uniform float u_width;"
|
||||||
@ -268,7 +270,7 @@ public final class LineRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String lineSimpleFragmentShader = ""
|
private final static String lineSimpleFragmentShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform sampler2D tex;"
|
+ "uniform sampler2D tex;"
|
||||||
+ "uniform float u_wscale;"
|
+ "uniform float u_wscale;"
|
||||||
+ "uniform float u_mode;"
|
+ "uniform float u_mode;"
|
||||||
@ -283,8 +285,8 @@ public final class LineRenderer {
|
|||||||
//+ " len = texture2D(tex, v_st).a;"
|
//+ " len = texture2D(tex, v_st).a;"
|
||||||
//+ " len = u_mode * length(v_st);"
|
//+ " len = u_mode * length(v_st);"
|
||||||
// this avoids branching, need to check performance
|
// this avoids branching, need to check performance
|
||||||
//+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * texture2D(tex, v_st).a);"
|
+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * texture2D(tex, v_st).a);"
|
||||||
+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * length(v_st));"
|
//+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * length(v_st));"
|
||||||
// interpolate alpha between: 0.0 < 1.0 - len < u_wscale
|
// interpolate alpha between: 0.0 < 1.0 - len < u_wscale
|
||||||
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
|
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
|
||||||
//+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);"
|
//+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);"
|
||||||
@ -294,7 +296,7 @@ public final class LineRenderer {
|
|||||||
|
|
||||||
private final static String lineFragmentShader = ""
|
private final static String lineFragmentShader = ""
|
||||||
+ "#extension GL_OES_standard_derivatives : enable\n"
|
+ "#extension GL_OES_standard_derivatives : enable\n"
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform sampler2D tex;"
|
+ "uniform sampler2D tex;"
|
||||||
+ "uniform float u_mode;"
|
+ "uniform float u_mode;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
@ -307,8 +309,8 @@ public final class LineRenderer {
|
|||||||
+ " len = abs(v_st.s);"
|
+ " len = abs(v_st.s);"
|
||||||
+ " fuzz = fwidth(v_st.s);"
|
+ " fuzz = fwidth(v_st.s);"
|
||||||
+ " } else {"
|
+ " } else {"
|
||||||
//+ " len = texture2D(tex, v_st).a;"
|
+ " len = texture2D(tex, v_st).a;"
|
||||||
+ " len = length(v_st);"
|
//+ " len = length(v_st);"
|
||||||
+ " vec2 st_width = fwidth(v_st);"
|
+ " vec2 st_width = fwidth(v_st);"
|
||||||
+ " fuzz = max(st_width.s, st_width.t);"
|
+ " fuzz = max(st_width.s, st_width.t);"
|
||||||
+ " }"
|
+ " }"
|
||||||
|
|||||||
@ -14,8 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.renderer.sublayers;
|
package org.oscim.renderer.sublayers;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ShortBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
|
|
||||||
import org.oscim.backend.GL20;
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
@ -30,7 +29,7 @@ import org.oscim.utils.GlUtils;
|
|||||||
public class LineTexRenderer {
|
public class LineTexRenderer {
|
||||||
private final static String TAG = LineTexRenderer.class.getName();
|
private final static String TAG = LineTexRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
// factor to normalize extrusion vector and scale to coord scale
|
// factor to normalize extrusion vector and scale to coord scale
|
||||||
private final static float COORD_SCALE_BY_DIR_SCALE =
|
private final static float COORD_SCALE_BY_DIR_SCALE =
|
||||||
@ -76,18 +75,17 @@ public class LineTexRenderer {
|
|||||||
int[] vboIds = GlUtils.glGenBuffers(1);
|
int[] vboIds = GlUtils.glGenBuffers(1);
|
||||||
mVertexFlipID = vboIds[0];
|
mVertexFlipID = vboIds[0];
|
||||||
|
|
||||||
// 0, 1, 0, 1, 0, ...
|
// bytes: 0, 1, 0, 1, 0, ...
|
||||||
byte[] flip = new byte[GLRenderer.maxQuads * 4];
|
short[] flip = new short[GLRenderer.maxQuads * 2];
|
||||||
for (int i = 0; i < flip.length; i++)
|
for (int i = 0; i < flip.length; i++)
|
||||||
flip[i] = (byte) (i % 2);
|
flip[i] = 1;
|
||||||
|
|
||||||
ByteBuffer buf = ByteBuffer.allocateDirect(flip.length)
|
ShortBuffer buf = GLRenderer.getShortBuffer(flip.length);
|
||||||
.order(ByteOrder.nativeOrder());
|
|
||||||
|
|
||||||
buf.put(flip);
|
buf.put(flip);
|
||||||
buf.flip();
|
buf.flip();
|
||||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, mVertexFlipID);
|
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, mVertexFlipID);
|
||||||
GL.glBufferData(GL20.GL_ARRAY_BUFFER, flip.length, buf,
|
GL.glBufferData(GL20.GL_ARRAY_BUFFER, flip.length * 2, buf,
|
||||||
GL20.GL_STATIC_DRAW);
|
GL20.GL_STATIC_DRAW);
|
||||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
@ -230,7 +228,7 @@ public class LineTexRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final static String vertexShader = ""
|
final static String vertexShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform mat4 u_mvp;"
|
+ "uniform mat4 u_mvp;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "uniform float u_pscale;"
|
+ "uniform float u_pscale;"
|
||||||
@ -258,7 +256,7 @@ public class LineTexRenderer {
|
|||||||
//*
|
//*
|
||||||
final static String fragmentShader = ""
|
final static String fragmentShader = ""
|
||||||
+ "#extension GL_OES_standard_derivatives : enable\n"
|
+ "#extension GL_OES_standard_derivatives : enable\n"
|
||||||
//+ " precision mediump float;"
|
+ " precision mediump float;"
|
||||||
+ " uniform vec4 u_color;"
|
+ " uniform vec4 u_color;"
|
||||||
+ " uniform vec4 u_bgcolor;"
|
+ " uniform vec4 u_bgcolor;"
|
||||||
+ " uniform float u_pwidth;"
|
+ " uniform float u_pwidth;"
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import java.nio.FloatBuffer;
|
|||||||
|
|
||||||
import org.oscim.backend.GL20;
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
|
import org.oscim.backend.Log;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
@ -35,7 +36,7 @@ import org.oscim.utils.Matrix4;
|
|||||||
public final class PolygonRenderer {
|
public final class PolygonRenderer {
|
||||||
private static final String TAG = PolygonRenderer.class.getName();
|
private static final String TAG = PolygonRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static GL20 GL;
|
||||||
|
|
||||||
private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0;
|
private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0;
|
||||||
private static final int STENCIL_BITS = 8;
|
private static final int STENCIL_BITS = 8;
|
||||||
@ -63,6 +64,8 @@ public final class PolygonRenderer {
|
|||||||
private static int mTexGrass;
|
private static int mTexGrass;
|
||||||
|
|
||||||
static boolean init() {
|
static boolean init() {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
for (int i = 0; i < numShaders; i++) {
|
for (int i = 0; i < numShaders; i++) {
|
||||||
|
|
||||||
// Set up the program for rendering polygons
|
// Set up the program for rendering polygons
|
||||||
@ -80,7 +83,7 @@ public final class PolygonRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (polygonProgram[i] == 0) {
|
if (polygonProgram[i] == 0) {
|
||||||
// Log.e(TAG, "Could not create polygon program.");
|
Log.e(TAG, "Could not create polygon program.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hPolygonMatrix[i] = GL.glGetUniformLocation(polygonProgram[i], "u_mvp");
|
hPolygonMatrix[i] = GL.glGetUniformLocation(polygonProgram[i], "u_mvp");
|
||||||
@ -427,7 +430,7 @@ public final class PolygonRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String polygonVertexShader = ""
|
private final static String polygonVertexShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform mat4 u_mvp;"
|
+ "uniform mat4 u_mvp;"
|
||||||
+ "attribute vec4 a_pos;"
|
+ "attribute vec4 a_pos;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
@ -435,14 +438,14 @@ public final class PolygonRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String polygonFragmentShader = ""
|
private final static String polygonFragmentShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
+ " gl_FragColor = u_color;"
|
+ " gl_FragColor = u_color;"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String polygonVertexShaderZ = ""
|
private final static String polygonVertexShaderZ = ""
|
||||||
//+ "precision highp float;"
|
+ "precision highp float;"
|
||||||
+ "uniform mat4 u_mvp;"
|
+ "uniform mat4 u_mvp;"
|
||||||
+ "attribute vec4 a_pos;"
|
+ "attribute vec4 a_pos;"
|
||||||
+ "varying float z;"
|
+ "varying float z;"
|
||||||
@ -451,7 +454,7 @@ public final class PolygonRenderer {
|
|||||||
+ " z = gl_Position.z;"
|
+ " z = gl_Position.z;"
|
||||||
+ "}";
|
+ "}";
|
||||||
private final static String polygonFragmentShaderZ = ""
|
private final static String polygonFragmentShaderZ = ""
|
||||||
//+ "precision highp float;"
|
+ "precision highp float;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "varying float z;"
|
+ "varying float z;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
@ -466,7 +469,7 @@ public final class PolygonRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String textureVertexShader = ""
|
private final static String textureVertexShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform mat4 u_mvp;"
|
+ "uniform mat4 u_mvp;"
|
||||||
+ "uniform vec2 u_scale;"
|
+ "uniform vec2 u_scale;"
|
||||||
+ "attribute vec4 a_pos;"
|
+ "attribute vec4 a_pos;"
|
||||||
@ -479,7 +482,7 @@ public final class PolygonRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String textureFragmentShader = ""
|
private final static String textureFragmentShader = ""
|
||||||
//+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "uniform sampler2D tex;"
|
+ "uniform sampler2D tex;"
|
||||||
+ "uniform vec2 u_scale;"
|
+ "uniform vec2 u_scale;"
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import org.oscim.utils.pool.SyncPool;
|
|||||||
|
|
||||||
public class TextureItem extends Inlist<TextureItem> {
|
public class TextureItem extends Inlist<TextureItem> {
|
||||||
private final static String TAG = TextureItem.class.getName();
|
private final static String TAG = TextureItem.class.getName();
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
// texture ID
|
// texture ID
|
||||||
public int id;
|
public int id;
|
||||||
@ -254,13 +254,14 @@ public class TextureItem extends Inlist<TextureItem> {
|
|||||||
mBitmaps.clear();
|
mBitmaps.clear();
|
||||||
mTextures.clear();
|
mTextures.clear();
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
// for (int i = 0; i < 4; i++) {
|
||||||
Bitmap bitmap = CanvasAdapter.g.getBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, 0);
|
// Bitmap bitmap = CanvasAdapter.g.getBitmap(TEXTURE_WIDTH,
|
||||||
// Bitmap bitmap = Bitmap.createBitmap(
|
// TEXTURE_HEIGHT, 0);
|
||||||
// TEXTURE_WIDTH, TEXTURE_HEIGHT,
|
// // Bitmap bitmap = Bitmap.createBitmap(
|
||||||
// Bitmap.Config.ARGB_8888);
|
// // TEXTURE_WIDTH, TEXTURE_HEIGHT,
|
||||||
mBitmaps.add(bitmap);
|
// // Bitmap.Config.ARGB_8888);
|
||||||
}
|
// mBitmaps.add(bitmap);
|
||||||
|
// }
|
||||||
|
|
||||||
// mBitmapFormat = GLUtils.getInternalFormat(mBitmaps.get(0));
|
// mBitmapFormat = GLUtils.getInternalFormat(mBitmaps.get(0));
|
||||||
// mBitmapType = GLUtils.getType(mBitmaps.get(0));
|
// mBitmapType = GLUtils.getType(mBitmaps.get(0));
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import org.oscim.utils.GlUtils;
|
|||||||
public final class TextureRenderer {
|
public final class TextureRenderer {
|
||||||
//private final static String TAG = TextureRenderer.class.getName();
|
//private final static String TAG = TextureRenderer.class.getName();
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
public final static boolean debug = false;
|
public final static boolean debug = false;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public final class TextureRenderer {
|
|||||||
private final static double COORD_DIV = 1.0 / GLRenderer.COORD_SCALE;
|
private final static double COORD_DIV = 1.0 / GLRenderer.COORD_SCALE;
|
||||||
|
|
||||||
private final static String textVertexShader = ""
|
private final static String textVertexShader = ""
|
||||||
// + "precision mediump float; "
|
+ "precision mediump float; "
|
||||||
+ "attribute vec4 vertex;"
|
+ "attribute vec4 vertex;"
|
||||||
+ "attribute vec2 tex_coord;"
|
+ "attribute vec2 tex_coord;"
|
||||||
+ "uniform mat4 u_mv;"
|
+ "uniform mat4 u_mv;"
|
||||||
@ -143,7 +143,7 @@ public final class TextureRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String textFragmentShader = ""
|
private final static String textFragmentShader = ""
|
||||||
// + "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform sampler2D tex;"
|
+ "uniform sampler2D tex;"
|
||||||
+ "varying vec2 tex_c;"
|
+ "varying vec2 tex_c;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
|
|||||||
@ -28,13 +28,14 @@ import org.oscim.renderer.GLRenderer;
|
|||||||
* Utility functions
|
* Utility functions
|
||||||
*/
|
*/
|
||||||
public class GlUtils {
|
public class GlUtils {
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
// public static native void setColor(int location, int color, float alpha);
|
// public static native void setColor(int location, int color, float alpha);
|
||||||
// public static native void setColorBlend(int location, int color1, int
|
// public static native void setColorBlend(int location, int color1, int
|
||||||
// color2, float mix);
|
// color2, float mix);
|
||||||
|
|
||||||
public static void setColor(int location, int color, float alpha) {
|
public static void setColor(int location, int color, float alpha) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
if (alpha >= 1)
|
if (alpha >= 1)
|
||||||
alpha = ((color >>> 24) & 0xff) / 255f;
|
alpha = ((color >>> 24) & 0xff) / 255f;
|
||||||
else if (alpha < 0)
|
else if (alpha < 0)
|
||||||
@ -60,7 +61,7 @@ public class GlUtils {
|
|||||||
public static void setColorBlend(int location, int color1, int color2, float mix) {
|
public static void setColorBlend(int location, int color1, int color2, float mix) {
|
||||||
float a1 = (((color1 >>> 24) & 0xff) / 255f) * (1 - mix);
|
float a1 = (((color1 >>> 24) & 0xff) / 255f) * (1 - mix);
|
||||||
float a2 = (((color2 >>> 24) & 0xff) / 255f) * mix;
|
float a2 = (((color2 >>> 24) & 0xff) / 255f) * mix;
|
||||||
|
GL = GLAdapter.get();
|
||||||
GL.glUniform4f
|
GL.glUniform4f
|
||||||
(location,
|
(location,
|
||||||
((((color1 >>> 16) & 0xff) / 255f) * a1 + (((color2 >>> 16) & 0xff) / 255f) * a2),
|
((((color1 >>> 16) & 0xff) / 255f) * a1 + (((color2 >>> 16) & 0xff) / 255f) * a2),
|
||||||
@ -72,6 +73,7 @@ public class GlUtils {
|
|||||||
private static String TAG = "GlUtils";
|
private static String TAG = "GlUtils";
|
||||||
|
|
||||||
public static void setTextureParameter(int min_filter, int mag_filter, int wrap_s, int wrap_t) {
|
public static void setTextureParameter(int min_filter, int mag_filter, int wrap_s, int wrap_t) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
GL.glTexParameterf(GL20.GL_TEXTURE_2D,
|
GL.glTexParameterf(GL20.GL_TEXTURE_2D,
|
||||||
GL20.GL_TEXTURE_MIN_FILTER,
|
GL20.GL_TEXTURE_MIN_FILTER,
|
||||||
min_filter);
|
min_filter);
|
||||||
@ -111,7 +113,7 @@ public class GlUtils {
|
|||||||
public static int loadTexture(byte[] pixel, int width, int height, int format,
|
public static int loadTexture(byte[] pixel, int width, int height, int format,
|
||||||
int min_filter, int mag_filter, int wrap_s, int wrap_t) {
|
int min_filter, int mag_filter, int wrap_s, int wrap_t) {
|
||||||
int[] textureIds = GlUtils.glGenTextures(1);
|
int[] textureIds = GlUtils.glGenTextures(1);
|
||||||
|
GL = GLAdapter.get();
|
||||||
GL.glBindTexture(GL20.GL_TEXTURE_2D, textureIds[0]);
|
GL.glBindTexture(GL20.GL_TEXTURE_2D, textureIds[0]);
|
||||||
|
|
||||||
setTextureParameter(min_filter, mag_filter, wrap_s, wrap_t);
|
setTextureParameter(min_filter, mag_filter, wrap_s, wrap_t);
|
||||||
@ -119,15 +121,17 @@ public class GlUtils {
|
|||||||
ByteBuffer buf = ByteBuffer.allocateDirect(width * height).order(ByteOrder.nativeOrder());
|
ByteBuffer buf = ByteBuffer.allocateDirect(width * height).order(ByteOrder.nativeOrder());
|
||||||
buf.put(pixel);
|
buf.put(pixel);
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
|
IntBuffer intBuf = buf.asIntBuffer();
|
||||||
GL.glTexImage2D(GL20.GL_TEXTURE_2D, 0, format, width, height, 0, format,
|
GL.glTexImage2D(GL20.GL_TEXTURE_2D, 0, format, width, height, 0, format,
|
||||||
GL20.GL_UNSIGNED_BYTE, buf);
|
GL20.GL_UNSIGNED_BYTE, intBuf);
|
||||||
|
|
||||||
GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||||
return textureIds[0];
|
return textureIds[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int loadStippleTexture(byte[] stipple) {
|
public static int loadStippleTexture(byte[] stipple) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (byte flip : stipple)
|
for (byte flip : stipple)
|
||||||
sum += flip;
|
sum += flip;
|
||||||
@ -166,6 +170,7 @@ public class GlUtils {
|
|||||||
* @return gl identifier
|
* @return gl identifier
|
||||||
*/
|
*/
|
||||||
public static int loadShader(int shaderType, String source) {
|
public static int loadShader(int shaderType, String source) {
|
||||||
|
|
||||||
int shader = GL.glCreateShader(shaderType);
|
int shader = GL.glCreateShader(shaderType);
|
||||||
if (shader != 0) {
|
if (shader != 0) {
|
||||||
GL.glShaderSource(shader, source);
|
GL.glShaderSource(shader, source);
|
||||||
@ -173,6 +178,7 @@ public class GlUtils {
|
|||||||
IntBuffer compiled = GLRenderer.getIntBuffer(1);
|
IntBuffer compiled = GLRenderer.getIntBuffer(1);
|
||||||
|
|
||||||
GL.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, compiled);
|
GL.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, compiled);
|
||||||
|
compiled.position(0);
|
||||||
if (compiled.get() == 0) {
|
if (compiled.get() == 0) {
|
||||||
Log.e(TAG, "Could not compile shader " + shaderType + ":");
|
Log.e(TAG, "Could not compile shader " + shaderType + ":");
|
||||||
Log.e(TAG, GL.glGetShaderInfoLog(shader));
|
Log.e(TAG, GL.glGetShaderInfoLog(shader));
|
||||||
@ -191,6 +197,8 @@ public class GlUtils {
|
|||||||
* @return gl identifier
|
* @return gl identifier
|
||||||
*/
|
*/
|
||||||
public static int createProgram(String vertexSource, String fragmentSource) {
|
public static int createProgram(String vertexSource, String fragmentSource) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
int vertexShader = loadShader(GL20.GL_VERTEX_SHADER, vertexSource);
|
int vertexShader = loadShader(GL20.GL_VERTEX_SHADER, vertexSource);
|
||||||
if (vertexShader == 0) {
|
if (vertexShader == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -211,6 +219,7 @@ public class GlUtils {
|
|||||||
GL.glLinkProgram(program);
|
GL.glLinkProgram(program);
|
||||||
IntBuffer linkStatus = GLRenderer.getIntBuffer(1);
|
IntBuffer linkStatus = GLRenderer.getIntBuffer(1);
|
||||||
GL.glGetProgramiv(program, GL20.GL_LINK_STATUS, linkStatus);
|
GL.glGetProgramiv(program, GL20.GL_LINK_STATUS, linkStatus);
|
||||||
|
linkStatus.position(0);
|
||||||
if (linkStatus.get() != GL20.GL_TRUE) {
|
if (linkStatus.get() != GL20.GL_TRUE) {
|
||||||
Log.e(TAG, "Could not link program: ");
|
Log.e(TAG, "Could not link program: ");
|
||||||
Log.e(TAG, GL.glGetProgramInfoLog(program));
|
Log.e(TAG, GL.glGetProgramInfoLog(program));
|
||||||
@ -226,17 +235,21 @@ public class GlUtils {
|
|||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
public static void checkGlError(String op) {
|
public static void checkGlError(String op) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
while ((error = GL.glGetError()) != GL20.GL_NO_ERROR) {
|
while ((error = GL.glGetError()) != 0) { //GL20.GL_NO_ERROR) {
|
||||||
Log.e(TAG, op + ": glError " + error);
|
Log.e(TAG, op + ": glError " + error);
|
||||||
// throw new RuntimeException(op + ": glError " + error);
|
// throw new RuntimeException(op + ": glError " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkGlOutOfMemory(String op) {
|
public static boolean checkGlOutOfMemory(String op) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
boolean oom = false;
|
boolean oom = false;
|
||||||
while ((error = GL.glGetError()) != GL20.GL_NO_ERROR) {
|
while ((error = GL.glGetError()) != 0) {// GL20.GL_NO_ERROR) {
|
||||||
Log.e(TAG, op + ": glError " + error);
|
Log.e(TAG, op + ": glError " + error);
|
||||||
// throw new RuntimeException(op + ": glError " + error);
|
// throw new RuntimeException(op + ": glError " + error);
|
||||||
if (error == 1285)
|
if (error == 1285)
|
||||||
@ -261,6 +274,8 @@ public class GlUtils {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
public static void setColor(int handle, float[] c, float alpha) {
|
public static void setColor(int handle, float[] c, float alpha) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
if (alpha >= 1) {
|
if (alpha >= 1) {
|
||||||
GL.glUniform4f(handle, c[0], c[1], c[2], c[3]);
|
GL.glUniform4f(handle, c[0], c[1], c[2], c[3]);
|
||||||
} else {
|
} else {
|
||||||
@ -318,6 +333,8 @@ public class GlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void glUniform4fv(int location, int count, float[] val) {
|
public static void glUniform4fv(int location, int count, float[] val) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
FloatBuffer buf = GLRenderer.getFloatBuffer(count * 4);
|
FloatBuffer buf = GLRenderer.getFloatBuffer(count * 4);
|
||||||
buf.put(val);
|
buf.put(val);
|
||||||
buf.flip();
|
buf.flip();
|
||||||
@ -325,6 +342,8 @@ public class GlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int[] glGenBuffers(int num) {
|
public static int[] glGenBuffers(int num) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
buf.limit(num);
|
buf.limit(num);
|
||||||
@ -337,6 +356,8 @@ public class GlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void glDeleteBuffers(int num, int[] ids) {
|
public static void glDeleteBuffers(int num, int[] ids) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
||||||
buf.put(ids, 0, num);
|
buf.put(ids, 0, num);
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
@ -344,6 +365,8 @@ public class GlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int[] glGenTextures(int num) {
|
public static int[] glGenTextures(int num) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
buf.limit(num);
|
buf.limit(num);
|
||||||
@ -356,6 +379,8 @@ public class GlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void glDeleteTextures(int num, int[] ids) {
|
public static void glDeleteTextures(int num, int[] ids) {
|
||||||
|
GL = GLAdapter.get();
|
||||||
|
|
||||||
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
IntBuffer buf = GLRenderer.getIntBuffer(num);
|
||||||
buf.put(ids, 0, num);
|
buf.put(ids, 0, num);
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import org.oscim.backend.GLAdapter;
|
|||||||
|
|
||||||
public class Matrix4 {
|
public class Matrix4 {
|
||||||
|
|
||||||
private static final GL20 GL = GLAdapter.INSTANCE;
|
private static final GL20 GL = GLAdapter.get();
|
||||||
|
|
||||||
private final static String TAG = Matrix4.class.getName();
|
private final static String TAG = Matrix4.class.getName();
|
||||||
private final static boolean dbg = false;
|
private final static boolean dbg = false;
|
||||||
|
|||||||
@ -43,6 +43,13 @@ public abstract class PausableThread extends Thread {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
super.interrupt();
|
super.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.join(10000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// restore the interrupted status
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user