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

Commit a70f416c authored by Jason Sams's avatar Jason Sams
Browse files

Checkin new types for RS.

Change-Id: I3d7a1a91c45cc1c97c60f3615f32e54e98e12f91
parent c1d726c2
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -76,10 +76,30 @@ public class Allocation extends BaseObj {
        subData1D(0, mType.getElementCount(), d);
    }

    public void subData(int off, FieldPacker fp) {
        int eSize = mType.mElement.getSizeBytes();
        final byte[] data = fp.getData();

        int count = data.length / eSize;
        if ((eSize * count) != data.length) {
            throw new IllegalArgumentException("Field packer length " + data.length +
                                               " not divisible by element size " + eSize + ".");
        }
        data1DChecks(off, count, data.length, data.length);
        mRS.nAllocationSubData1D(mID, off, count, data, data.length);
    }

    private void data1DChecks(int off, int count, int len, int dataSize) {
        mRS.validate();
        if((off < 0) || (count < 1) || ((off + count) > mType.getElementCount())) {
            throw new IllegalArgumentException("Offset or Count out of bounds.");
        if(off < 0) {
            throw new IllegalArgumentException("Offset must be >= 0.");
        }
        if(count < 1) {
            throw new IllegalArgumentException("Count must be >= 1.");
        }
        if((off + count) > mType.getElementCount()) {
            throw new IllegalArgumentException("Overflow, Available count " + mType.getElementCount() +
                                               ", got " + count + " at offset " + off + ".");
        }
        if((len) < dataSize) {
            throw new IllegalArgumentException("Array too small for allocation type.");
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.renderscript;

import java.lang.Math;
import android.util.Log;


/**
 * @hide
 *
 **/
public class Byte2 {
    public Byte2() {
    }

    public byte x;
    public byte y;
}



+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.renderscript;

import java.lang.Math;
import android.util.Log;


/**
 * @hide
 *
 **/
public class Byte3 {
    public Byte3() {
    }

    public byte x;
    public byte y;
    public byte z;
}



+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.renderscript;

import java.lang.Math;
import android.util.Log;


/**
 * @hide
 *
 **/
public class Byte4 {
    public Byte4() {
    }

    public byte x;
    public byte y;
    public byte z;
    public byte w;
}


+71 −0
Original line number Diff line number Diff line
@@ -126,6 +126,77 @@ public class Element extends BaseObj {
        return rs.mElement_USER_F32;
    }

    public static Element USER_ELEMENT(RenderScript rs) {
        if(rs.mElement_USER_ELEMENT == null) {
            rs.mElement_USER_ELEMENT = createUser(rs, DataType.RS_ELEMENT);
        }
        return rs.mElement_USER_ELEMENT;
    }

    public static Element USER_TYPE(RenderScript rs) {
        if(rs.mElement_USER_TYPE == null) {
            rs.mElement_USER_TYPE = createUser(rs, DataType.RS_TYPE);
        }
        return rs.mElement_USER_TYPE;
    }

    public static Element USER_ALLOCATION(RenderScript rs) {
        if(rs.mElement_USER_ALLOCATION == null) {
            rs.mElement_USER_ALLOCATION = createUser(rs, DataType.RS_ALLOCATION);
        }
        return rs.mElement_USER_ALLOCATION;
    }

    public static Element USER_SAMPLER(RenderScript rs) {
        if(rs.mElement_USER_SAMPLER == null) {
            rs.mElement_USER_SAMPLER = createUser(rs, DataType.RS_SAMPLER);
        }
        return rs.mElement_USER_SAMPLER;
    }

    public static Element USER_SCRIPT(RenderScript rs) {
        if(rs.mElement_USER_SCRIPT == null) {
            rs.mElement_USER_SCRIPT = createUser(rs, DataType.RS_SCRIPT);
        }
        return rs.mElement_USER_SCRIPT;
    }

    public static Element USER_MESH(RenderScript rs) {
        if(rs.mElement_USER_MESH == null) {
            rs.mElement_USER_MESH = createUser(rs, DataType.RS_MESH);
        }
        return rs.mElement_USER_MESH;
    }

    public static Element USER_PROGRAM_FRAGMENT(RenderScript rs) {
        if(rs.mElement_USER_PROGRAM_FRAGMENT == null) {
            rs.mElement_USER_PROGRAM_FRAGMENT = createUser(rs, DataType.RS_PROGRAM_FRAGMENT);
        }
        return rs.mElement_USER_PROGRAM_FRAGMENT;
    }

    public static Element USER_PROGRAM_VERTEX(RenderScript rs) {
        if(rs.mElement_USER_PROGRAM_VERTEX == null) {
            rs.mElement_USER_PROGRAM_VERTEX = createUser(rs, DataType.RS_PROGRAM_VERTEX);
        }
        return rs.mElement_USER_PROGRAM_VERTEX;
    }

    public static Element USER_PROGRAM_RASTER(RenderScript rs) {
        if(rs.mElement_USER_PROGRAM_RASTER == null) {
            rs.mElement_USER_PROGRAM_RASTER = createUser(rs, DataType.RS_PROGRAM_RASTER);
        }
        return rs.mElement_USER_PROGRAM_RASTER;
    }

    public static Element USER_PROGRAM_STORE(RenderScript rs) {
        if(rs.mElement_USER_PROGRAM_STORE == null) {
            rs.mElement_USER_PROGRAM_STORE = createUser(rs, DataType.RS_PROGRAM_STORE);
        }
        return rs.mElement_USER_PROGRAM_STORE;
    }


    public static Element A_8(RenderScript rs) {
        if(rs.mElement_A_8 == null) {
            rs.mElement_A_8 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_A);
Loading