check size > 0 before deleting texture IDs

- formatting...
This commit is contained in:
Hannes Janetzek 2013-06-25 07:24:32 +02:00
parent 52b2fadd7d
commit 0b4aff79c9

View File

@ -13,6 +13,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.renderer.sublayers;
import java.util.ArrayList;
import org.oscim.backend.CanvasAdapter;
@ -76,8 +77,8 @@ public class TextureItem extends Inlist<TextureItem> {
}
/**
* Retrieve a TextureItem from pool with default Bitmap
* with dimension TextureRenderer.TEXTURE_WIDTH/HEIGHT.
* Retrieve a TextureItem from pool with default Bitmap with dimension
* TextureRenderer.TEXTURE_WIDTH/HEIGHT.
*/
public synchronized static TextureItem get(boolean initBitmap) {
TextureItem ti = pool.get();
@ -162,13 +163,15 @@ public class TextureItem extends Inlist<TextureItem> {
/**
* This function may only be used in GLRenderer Thread.
*
* @param to the TextureObjet to compile and upload
* @param to
* the TextureObjet to compile and upload
*/
public static void uploadTexture(TextureItem to) {
// free unused textures, find a better place for this TODO
synchronized (mTextures) {
int size = mTextures.size();
if (size > 0) {
int[] tmp = new int[size];
for (int i = 0; i < size; i++)
tmp[i] = mTextures.get(i).intValue();
@ -178,6 +181,7 @@ public class TextureItem extends Inlist<TextureItem> {
mTexCnt -= size;
}
}
if (to.id < 0) {
mTexCnt++;
@ -216,11 +220,13 @@ public class TextureItem extends Inlist<TextureItem> {
} else if (to.width == w && to.height == h) {
bitmap.uploadToTexture(true);
//GLUtils.texSubImage2D(GL20.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
// GLUtils.texSubImage2D(GL20.GL_TEXTURE_2D, 0, 0, 0, bitmap,
// format, type);
} else {
bitmap.uploadToTexture(false);
//GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, format, bitmap, type, 0);
// GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, format, bitmap, type,
// 0);
to.width = w;
to.height = h;
}
@ -273,7 +279,8 @@ public class TextureItem extends Inlist<TextureItem> {
//
// if (TextureRenderer.debug)
// Log.d(TAG, "alloc bitmap: " +
// android.os.Debug.getNativeHeapAllocatedSize() / (1024 * 1024));
// android.os.Debug.getNativeHeapAllocatedSize() / (1024 *
// 1024));
return CanvasAdapter.g.getBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, 0);
}