diff --git a/src/org/oscim/renderer/sublayers/SpriteManager.java b/src/org/oscim/renderer/atlas/SpriteManager.java
similarity index 94%
rename from src/org/oscim/renderer/sublayers/SpriteManager.java
rename to src/org/oscim/renderer/atlas/SpriteManager.java
index baa7646b..94723c9d 100644
--- a/src/org/oscim/renderer/sublayers/SpriteManager.java
+++ b/src/org/oscim/renderer/atlas/SpriteManager.java
@@ -12,9 +12,10 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see .
*/
-package org.oscim.renderer.sublayers;
+package org.oscim.renderer.atlas;
-import org.oscim.renderer.sublayers.TextureAtlas.Rect;
+import org.oscim.renderer.atlas.TextureAtlas.Rect;
+import org.oscim.renderer.sublayers.TextureItem;
import org.oscim.utils.pool.Inlist;
import android.graphics.Canvas;
diff --git a/src/org/oscim/renderer/sublayers/TextureAtlas.java b/src/org/oscim/renderer/atlas/TextureAtlas.java
similarity index 82%
rename from src/org/oscim/renderer/sublayers/TextureAtlas.java
rename to src/org/oscim/renderer/atlas/TextureAtlas.java
index a0eea2bd..2ac0567a 100644
--- a/src/org/oscim/renderer/sublayers/TextureAtlas.java
+++ b/src/org/oscim/renderer/atlas/TextureAtlas.java
@@ -57,15 +57,18 @@
*
* ============================================================================
*/
-package org.oscim.renderer.sublayers;
+package org.oscim.renderer.atlas;
+import java.util.HashMap;
+
+import org.oscim.renderer.sublayers.TextureItem;
import org.oscim.utils.pool.Inlist;
import android.graphics.Bitmap;
+import android.util.Log;
public class TextureAtlas extends Inlist {
-
-
+ private final static String TAG = TextureAtlas.class.getName();
/** Allocated slots */
public Slot mSlots;
@@ -83,11 +86,23 @@ public class TextureAtlas extends Inlist {
/** Allocated surface size */
int mUsed;
- /** Texture identity (OpenGL) */
- int id;
- /** Atlas data */
- Bitmap mData;
+ public TextureItem texture;
+
+ /**
+ * only call in GL-Thread
+ */
+ public TextureItem compileTexture() {
+ if (texture != null) {
+ if (texture.id < 1) {
+ TextureItem.uploadTexture(texture);
+ }
+ return texture;
+ }
+
+ Log.wtf(TAG, "Missing atlas texture");
+ return null;
+ }
public static class Slot extends Inlist {
public int x, y, w;
@@ -100,6 +115,13 @@ public class TextureAtlas extends Inlist {
}
public static class Rect extends Inlist {
+ public Rect(int x, int y, int w, int h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+
public int x, y, w, h;
}
@@ -110,12 +132,31 @@ public class TextureAtlas extends Inlist {
mSlots = new Slot(1, 1, width - 2);
}
+ public TextureAtlas(Bitmap bitmap) {
+ mDepth = 0;
+ texture = new TextureItem(bitmap);
+ mWidth = texture.width;
+ mHeight = texture.height;
+
+ mRegions = new HashMap