Add Image.isOpaque()
This commit is contained in:
1 parent
82b6374e7e
commit
e623616a50
16 files changed
+80
-18
No files matched your search
@@ -59,10 +59,10 @@ public class ImageTexture implements Texture {
|
||||
// In this 16ms, we use about 4~8 ms to upload tiles.
|
||||
private static final long UPLOAD_TILE_LIMIT = 4; // ms
|
||||
|
||||
private static Bitmap sSmallUploadBitmap;
|
||||
private static Bitmap sLargeUploadBitmap;
|
||||
private static InfiniteThreadExecutor sThreadExecutor;
|
||||
private static PVLock sPVLock;
|
||||
private static final Bitmap sSmallUploadBitmap;
|
||||
private static final Bitmap sLargeUploadBitmap;
|
||||
private static final InfiniteThreadExecutor sThreadExecutor;
|
||||
private static final PVLock sPVLock;
|
||||
|
||||
private static Tile sSmallFreeTileHead = null;
|
||||
private static Tile sLargeFreeTileHead = null;
|
||||
@@ -75,6 +75,7 @@ public class ImageTexture implements Texture {
|
||||
|
||||
private final int mWidth;
|
||||
private final int mHeight;
|
||||
private final boolean mOpaque;
|
||||
private final RectF mSrcRect = new RectF();
|
||||
private final RectF mDestRect = new RectF();
|
||||
|
||||
@@ -293,6 +294,7 @@ public class ImageTexture implements Texture {
|
||||
mImage = image;
|
||||
int width = mWidth = image.getWidth();
|
||||
int height = mHeight = image.getHeight();
|
||||
boolean opaque = mOpaque = image.isOpaque();
|
||||
ArrayList<Tile> list = new ArrayList<>();
|
||||
|
||||
for (int x = 0; x < width; x += LARGE_CONTENT_SIZE) {
|
||||
@@ -306,6 +308,7 @@ public class ImageTexture implements Texture {
|
||||
tile.offsetY = y;
|
||||
tile.image = image;
|
||||
tile.setSize(TILE_SMALL, w, Math.min(SMALL_CONTENT_SIZE, h));
|
||||
tile.setOpaque(opaque);
|
||||
list.add(tile);
|
||||
|
||||
int nextHeight = h - SMALL_CONTENT_SIZE;
|
||||
@@ -315,6 +318,7 @@ public class ImageTexture implements Texture {
|
||||
nextTile.offsetY = y + SMALL_CONTENT_SIZE;
|
||||
nextTile.image = image;
|
||||
nextTile.setSize(TILE_SMALL, w, nextHeight);
|
||||
nextTile.setOpaque(opaque);
|
||||
list.add(nextTile);
|
||||
}
|
||||
} else if (h <= SMALL_CONTENT_SIZE) {
|
||||
@@ -323,6 +327,7 @@ public class ImageTexture implements Texture {
|
||||
tile.offsetY = y;
|
||||
tile.image = image;
|
||||
tile.setSize(TILE_SMALL, Math.min(SMALL_CONTENT_SIZE, w), h);
|
||||
tile.setOpaque(opaque);
|
||||
list.add(tile);
|
||||
|
||||
int nextWidth = w - SMALL_CONTENT_SIZE;
|
||||
@@ -332,6 +337,7 @@ public class ImageTexture implements Texture {
|
||||
nextTile.offsetY = y;
|
||||
nextTile.image = image;
|
||||
nextTile.setSize(TILE_SMALL, nextWidth, h);
|
||||
nextTile.setOpaque(opaque);
|
||||
list.add(nextTile);
|
||||
}
|
||||
} else {
|
||||
@@ -340,6 +346,7 @@ public class ImageTexture implements Texture {
|
||||
tile.offsetY = y;
|
||||
tile.image = image;
|
||||
tile.setSize(TILE_LARGE, w, h);
|
||||
tile.setOpaque(opaque);
|
||||
list.add(tile);
|
||||
}
|
||||
}
|
||||
@@ -530,7 +537,7 @@ public class ImageTexture implements Texture {
|
||||
|
||||
@Override
|
||||
public boolean isOpaque() {
|
||||
return false;
|
||||
return mOpaque;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
|
||||
@@ -27,9 +27,9 @@ public class Image {
|
||||
public static final int FORMAT_GIF = 0x02;
|
||||
|
||||
private long mNativePtr;
|
||||
private int mFormat;
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
private final int mFormat;
|
||||
private final int mWidth;
|
||||
private final int mHeight;
|
||||
|
||||
private Image(long nativePtr, int format, int width, int height) {
|
||||
mNativePtr = nativePtr;
|
||||
@@ -88,6 +88,11 @@ public class Image {
|
||||
return nativeFrameCount(mNativePtr, mFormat);
|
||||
}
|
||||
|
||||
public boolean isOpaque() {
|
||||
checkRecycled();
|
||||
return nativeIsOpaque(mNativePtr, mFormat);
|
||||
}
|
||||
|
||||
public void recycle() {
|
||||
if (mNativePtr != 0) {
|
||||
nativeRecycle(mNativePtr, mFormat);
|
||||
@@ -104,9 +109,6 @@ public class Image {
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("stream");
|
||||
System.loadLibrary("jpeg-turbo");
|
||||
System.loadLibrary("gif");
|
||||
System.loadLibrary("image");
|
||||
}
|
||||
|
||||
@@ -126,5 +128,7 @@ public class Image {
|
||||
|
||||
private static native int nativeFrameCount(long nativePtr, int format);
|
||||
|
||||
private static native boolean nativeIsOpaque(long nativePtr, int format);
|
||||
|
||||
private static native void nativeRecycle(long nativePtr, int format);
|
||||
}
|
||||
Reference in new issue
Block a user