Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2abc1350 authored by Pin Ting's avatar Pin Ting Committed by Android (Google) Code Review
Browse files

Merge "Accelerate PNG image rendering." into gb-ub-photos-arches

parents accef756 8c377351
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.DecodeUtils;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.ThreadPool;
import com.android.gallery3d.util.ThreadPool.CancelListener;
import com.android.gallery3d.util.ThreadPool.JobContext;
@@ -43,15 +44,12 @@ public class TileImageView extends GLView {

    // TILE_SIZE must be 2^N - 2. We put one pixel border in each side of the
    // texture to avoid seams between tiles.
    private static final int TILE_SIZE = 254;
    private static int TILE_SIZE;
    private static final int TILE_BORDER = 1;
    private static final int BITMAP_SIZE = TILE_SIZE + TILE_BORDER * 2;
    private static int BITMAP_SIZE;
    private static final int UPLOAD_LIMIT = 1;

    private static final BitmapPool sTilePool =
            ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER
            ? new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128)
            : null;
    private static BitmapPool sTilePool;

    /*
     *  This is the tile state in the CPU side.
@@ -152,6 +150,18 @@ public class TileImageView extends GLView {
    public TileImageView(GalleryContext context) {
        mThreadPool = context.getThreadPool();
        mTileDecoder = mThreadPool.submit(new TileDecoder());
        if (TILE_SIZE == 0) {
            if (GalleryUtils.isHighResolution(context.getAndroidContext())) {
                TILE_SIZE = 510 ;
            } else {
                TILE_SIZE = 254;
            }
            BITMAP_SIZE = TILE_SIZE + TILE_BORDER * 2;
            sTilePool =
                    ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER
                    ? new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128)
                    : null;
        }
    }

    public void setModel(Model model) {
+0 −1
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ public class TileImageViewAdapter implements TileImageView.Model {
    @Override
    public Bitmap getTile(int level, int x, int y, int tileSize,
            int borderSize, BitmapPool pool) {

        if (!ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER) {
            return getTileWithoutReusingBitmap(level, x, y, tileSize, borderSize);
        }
+8 −0
Original line number Diff line number Diff line
@@ -87,6 +87,14 @@ public class GalleryUtils {
                R.color.bitmap_screennail_placeholder));
    }

    public static boolean isHighResolution(Context context) {
        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager wm = (WindowManager)
                context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(metrics);
        return metrics.heightPixels > 2048 ||  metrics.widthPixels > 2048;
    }

    public static float[] intColorToFloatARGBArray(int from) {
        return new float[] {
            Color.alpha(from) / 255f,