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

Commit 00415803 authored by Stephen Hines's avatar Stephen Hines Committed by Android (Google) Code Review
Browse files

Merge "Fix copyFrom() to use proper dimensions for copying."

parents 28586038 a9a7b374
Loading
Loading
Loading
Loading
+91 −22
Original line number Diff line number Diff line
@@ -488,8 +488,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFromUnchecked(int[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFromUnchecked(0, mCurrentCount, d);
        }
    }
    /**
     * Copy an allocation from an array.  This variant is not type
     * checked which allows an application to fill in structured
@@ -499,8 +503,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFromUnchecked(short[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFromUnchecked(0, mCurrentCount, d);
        }
    }
    /**
     * Copy an allocation from an array.  This variant is not type
     * checked which allows an application to fill in structured
@@ -510,8 +518,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFromUnchecked(byte[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFromUnchecked(0, mCurrentCount, d);
        }
    }
    /**
     * Copy an allocation from an array.  This variant is not type
     * checked which allows an application to fill in structured
@@ -521,8 +533,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFromUnchecked(float[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFromUnchecked(0, mCurrentCount, d);
        }
    }

    /**
     * Copy an allocation from an array.  This variant is type
@@ -533,8 +549,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFrom(int[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFrom(0, mCurrentCount, d);
        }
    }

    /**
     * Copy an allocation from an array.  This variant is type
@@ -545,8 +565,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFrom(short[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFrom(0, mCurrentCount, d);
        }
    }

    /**
     * Copy an allocation from an array.  This variant is type
@@ -557,8 +581,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFrom(byte[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFrom(0, mCurrentCount, d);
        }
    }

    /**
     * Copy an allocation from an array.  This variant is type
@@ -569,8 +597,12 @@ public class Allocation extends BaseObj {
     */
    public void copyFrom(float[] d) {
        mRS.validate();
        if (mCurrentDimY > 0) {
            copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
        } else {
            copy1DRangeFrom(0, mCurrentCount, d);
        }
    }

    /**
     * Copy an allocation from a bitmap.  The height, width, and
@@ -827,44 +859,81 @@ public class Allocation extends BaseObj {
        }
    }

    /**
     * Copy a rectangular region from the array into the allocation.
     * The incoming array is assumed to be tightly packed.
     *
     * @param xoff X offset of the region to update
     * @param yoff Y offset of the region to update
     * @param w Width of the incoming region to update
     * @param h Height of the incoming region to update
     * @param data to be placed into the allocation
     */
    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
    void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, byte[] data) {
        mRS.validate();
        validate2DRange(xoff, yoff, w, h);
        mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
                              w, h, data, data.length);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
    void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, short[] data) {
        mRS.validate();
        validate2DRange(xoff, yoff, w, h);
        mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
                              w, h, data, data.length * 2);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
    void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, int[] data) {
        mRS.validate();
        validate2DRange(xoff, yoff, w, h);
        mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
                              w, h, data, data.length * 4);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
    void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, float[] data) {
        mRS.validate();
        validate2DRange(xoff, yoff, w, h);
        mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
                              w, h, data, data.length * 4);
    }


    /**
     * Copy a rectangular region from the array into the allocation.
     * The incoming array is assumed to be tightly packed.
     *
     * @param xoff X offset of the region to update
     * @param yoff Y offset of the region to update
     * @param w Width of the incoming region to update
     * @param h Height of the incoming region to update
     * @param data to be placed into the allocation
     */
    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
        // We can only validate the type on API 18+, since this check was not present in
        // earlier releases.
        if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) {
            validateIsInt8();
        }
        copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
        // We can only validate the type on API 18+, since this check was not present in
        // earlier releases.
        if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) {
            validateIsInt16();
        }
        copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
        // We can only validate the type on API 18+, since this check was not present in
        // earlier releases.
        if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) {
            validateIsInt32();
        }
        copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
    }

    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
        // We can only validate the type on API 18+, since this check was not present in
        // earlier releases.
        if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 18) {
            validateIsFloat32();
        }
        copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
    }

    /**
     * Copy a rectangular region into the allocation from another
     * allocation.