package com.rabenauge.gl;

import android.graphics.Bitmap;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

/*
 * Wrapper class for 2D texture objects.
 */
public class Texture2D extends Texture {
    public Texture2D(GL11 gl) {
        super(gl, GL10.GL_TEXTURE_2D, GL11.GL_TEXTURE_BINDING_2D);
    }

    public void setData(Bitmap bitmap, int level, boolean border) {
        makeCurrent();
        if (!isPOT(bitmap.getWidth()) || !isPOT(bitmap.getHeight())) {
            bitmap=Bitmap.createScaledBitmap(bitmap, ceilPOT(bitmap.getWidth()), ceilPOT(bitmap.getHeight()), false);
        }
        android.opengl.GLUtils.texImage2D(target, level, bitmap, border?1:0);
    }

    public void setData(Bitmap bitmap) {
        setData(bitmap, 0, false);
    }
}

@@ -426,42 +426,14 @@
     
-makeCurrent();%0A        if (!isPOT(
+int w=
 bitm
@@ -449,20 +449,12 @@
 th()
-) %7C%7C !isPOT(
+, h=
 bitm
@@ -471,140 +471,182 @@
 ht()
-)) %7B%0A            bitmap=Bitmap.createScaledBitmap(bitmap, ceilPOT(bitmap.getWidth()), ceilPOT(bitmap.getHeight()), false);%0A        %7D
+;%0A        int w2=ceilPOT(w), h2=ceilPOT(h);%0A        if (w!=w2 %7C%7C h!=h2) %7B%0A            bitmap=Bitmap.createScaledBitmap(bitmap, w2, h2, true);%0A        %7D%0A        makeCurrent();
 %0A   

Enable filtering when scaling NPOT textures; minor optimizations