add Color.isOpaque util

This commit is contained in:
Hannes Janetzek 2014-10-10 03:59:55 +02:00
parent 7b9301d479
commit 3f3dca30d7
3 changed files with 11 additions and 6 deletions

View File

@ -21,6 +21,8 @@ import org.oscim.utils.FastMath;
public final class Color {
private static final int OPAQUE = 0xff000000;
public static int fadePremul(int color, double alpha) {
alpha = FastMath.clamp(alpha, 0, 1);
@ -239,7 +241,10 @@ public final class Color {
return fallBackColor;
}
public static boolean isOpaque(int color) {
return (color & OPAQUE) == OPAQUE;
}
private Color() {
/* Singleton */
}
}

View File

@ -22,6 +22,7 @@ import static org.oscim.utils.FastMath.clamp;
import java.nio.ShortBuffer;
import org.oscim.backend.GL;
import org.oscim.backend.canvas.Color;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
@ -155,7 +156,6 @@ public final class PolygonBucket extends RenderBucket {
public static final class Renderer {
private static final int OPAQUE = 0xff000000;
private static final int STENCIL_BITS = 8;
public final static int CLIP_BIT = 0x80;
@ -216,7 +216,7 @@ public final class PolygonBucket extends RenderBucket {
a.blendColor, blendFill);
}
} else {
blend |= (a.color & OPAQUE) != OPAQUE;
blend |= !Color.isOpaque(a.color);
GLUtils.setColor(s.uColor, a.color, fade);
}

View File

@ -27,7 +27,7 @@ import org.oscim.utils.FastMath;
* - create distance field per tile?
*/
public class AreaStyle extends RenderStyle {
private static final int OPAQUE = 0xff000000;
private static final float FADE_START = 0.25f;
/** Drawing order level */
@ -95,7 +95,7 @@ public class AreaStyle extends RenderStyle {
}
public boolean hasAlpha(int zoom) {
if ((color & OPAQUE) != OPAQUE)
if (!Color.isOpaque(color))
return true;
if (texture != null)
@ -105,7 +105,7 @@ public class AreaStyle extends RenderStyle {
return false;
if (zoom >= blendScale) {
if ((blendColor & OPAQUE) != OPAQUE)
if (!Color.isOpaque(blendColor))
return true;
}