import android.graphics.RectF;
import android.support.v4.util.LongSparseArray;
import android.util.DisplayMetrics;
-import android.util.FloatMath;
import android.view.WindowManager;
import com.android.gallery3d.app.GalleryContext;
-import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.DecodeUtils;
+import com.android.photos.data.GalleryBitmapPool;
import com.android.gallery3d.glrenderer.GLCanvas;
import com.android.gallery3d.glrenderer.UploadedTexture;
import com.android.gallery3d.util.Future;
// TILE_SIZE must be 2^N
private static int sTileSize;
- private static BitmapPool sTilePool;
-
/*
* This is the tile state in the CPU side.
* Life of a Tile:
// still refers to the coordinate on the original image.
//
// The method would be called in another thread.
- public Bitmap getTile(int level, int x, int y, int tileSize,
- BitmapPool pool);
+ public Bitmap getTile(int level, int x, int y, int tileSize);
}
public static boolean isHighResolution(Context context) {
} else {
sTileSize = 256;
}
- sTilePool =
- ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER
- ? new BitmapPool(sTileSize, sTileSize, 128)
- : null;
}
}
int height = (int) Math.ceil(Math.max(
Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h)));
- int left = (int) FloatMath.floor(cX - width / (2f * scale));
- int top = (int) FloatMath.floor(cY - height / (2f * scale));
- int right = (int) FloatMath.ceil(left + width / scale);
- int bottom = (int) FloatMath.ceil(top + height / scale);
+ int left = (int) Math.floor(cX - width / (2f * scale));
+ int top = (int) Math.floor(cY - height / (2f * scale));
+ int right = (int) Math.ceil(left + width / scale);
+ int bottom = (int) Math.ceil(top + height / scale);
// align the rectangle to tile boundary
int size = sTileSize << level;
}
}
setScreenNail(null);
- if (sTilePool != null) sTilePool.clear();
}
public void prepareTextures() {
if (tile.mTileState == STATE_RECYCLING) {
tile.mTileState = STATE_RECYCLED;
if (tile.mDecodedTile != null) {
- if (sTilePool != null) sTilePool.recycle(tile.mDecodedTile);
+ GalleryBitmapPool.getInstance().put(tile.mDecodedTile);
tile.mDecodedTile = null;
}
mRecycledQueue.push(tile);
}
tile.mTileState = STATE_RECYCLED;
if (tile.mDecodedTile != null) {
- if (sTilePool != null) sTilePool.recycle(tile.mDecodedTile);
+ GalleryBitmapPool.getInstance().put(tile.mDecodedTile);
tile.mDecodedTile = null;
}
mRecycledQueue.push(tile);
@Override
protected void onFreeBitmap(Bitmap bitmap) {
- if (sTilePool != null) sTilePool.recycle(bitmap);
+ GalleryBitmapPool.getInstance().put(bitmap);
}
boolean decode() {
// by (1 << mTilelevel) from a region in the original image.
try {
mDecodedTile = DecodeUtils.ensureGLCompatibleBitmap(mModel.getTile(
- mTileLevel, mX, mY, sTileSize, sTilePool));
+ mTileLevel, mX, mY, sTileSize));
} catch (Throwable t) {
Log.w(TAG, "fail to decode tile", t);
}