// (c) Tuomas J. Lukka package gzz.gfx.gl; import gzz.mem.*; /** A memory consumer which is a texture; what's in the texture * is not specified. * Quality = dots per measwidth unit. */ abstract public class TextureMemoryConsumer implements MemoryConsumer { public boolean getScalable() { return true; } int width, height; int curWidth, curHeight; int bitsPerTexel; protected int getBytes(int w, int h) { return w*h*bitsPerTexel / 8; } /** The width measured in resolution units (e.g.inches). */ float measwidth; public int getMaxBytes(float quality) { float fact = measwidth * quality; // round up int w; for(w = 1; w < fact; w*=2); if(w > width) w = width; int h = w*height/width; if(h == 0) h = 1; return getBytes(w, h); } public int getReservation() { return getBytes(curWidth, curHeight); } public float getQuality() { return curWidth / (float)measwidth; } }