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

Commit 1bada8cd authored by Jason Sams's avatar Jason Sams
Browse files

Begin implementing SimpleMesh and fix some bugs with refcounting and java...

Begin implementing SimpleMesh and fix some bugs with refcounting and java object destruction tracking.
parent 467f3df1
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -43,8 +43,11 @@ public class Allocation extends BaseObj {
    }

    public void destroy() {
        if(mDestroyed) {
            throw new IllegalStateException("Object already destroyed.");
        }
        mDestroyed = true;
        mRS.nAllocationDestroy(mID);
        mID = 0;
    }

    public void data(int[] d) {
@@ -160,17 +163,27 @@ public class Allocation extends BaseObj {
        mBitmapOptions.inScaled = false;
    }

    static public Allocation createTyped(RenderScript rs, Type type) {
    static public Allocation createTyped(RenderScript rs, Type type)
        throws IllegalArgumentException {

        if(type.mID == 0) {
            throw new IllegalStateException("Bad Type");
        }
        int id = rs.nAllocationCreateTyped(type.mID);
        return new Allocation(id, rs);
    }

    static public Allocation createSized(RenderScript rs, Element e, int count) {
    static public Allocation createSized(RenderScript rs, Element e, int count)
        throws IllegalArgumentException {

        int id;
        if(e.mIsPredefined) {
            id = rs.nAllocationCreatePredefSized(e.mPredefinedID, count);
        } else {
            id = rs.nAllocationCreateSized(e.mID, count);
            if(id == 0) {
                throw new IllegalStateException("Bad element.");
            }
        }
        return new Allocation(id, rs);
    }
+3 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ class BaseObj {
    BaseObj(RenderScript rs) {
        mRS = rs;
        mID = 0;
        mDestroyed = false;
    }

    public int getID() {
@@ -34,6 +35,7 @@ class BaseObj {
    }

    int mID;
    boolean mDestroyed;
    String mName;
    RenderScript mRS;

@@ -57,7 +59,7 @@ class BaseObj {

    protected void finalize() throws Throwable
    {
        if (mID != 0) {
        if (!mDestroyed) {
            Log.v(RenderScript.LOG_TAG,
                  "Element finalized without having released the RS reference.");
        }
+5 −2
Original line number Diff line number Diff line
@@ -137,8 +137,11 @@ public class Element extends BaseObj {
        if(mIsPredefined) {
            throw new IllegalStateException("Attempting to destroy a predefined Element.");
        }
        if(mDestroyed) {
            throw new IllegalStateException("Object already destroyed.");
        }
        mDestroyed = true;
        mRS.nElementDestroy(mID);
        mID = 0;
    }


@@ -206,7 +209,7 @@ public class Element extends BaseObj {
                    if (en.mIsNormalized) {
                        norm = 1;
                    }
                    rs.nElementAdd(en.mType.mID, en.mKind.mID, norm, en.mBits);
                    rs.nElementAdd(en.mKind.mID, en.mType.mID, norm, en.mBits);
                }
            }
            int id = rs.nElementCreate();
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 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;

/**
 * @hide
 **/
public enum Primitive {
    POINT (0),
    LINE (1),
    LINE_STRIP (2),
    TRIANGLE (3),
    TRIANGLE_STRIP (4),
    TRIANGLE_FAN (5);

    int mID;
    Primitive(int id) {
        mID = id;
    }
}


+4 −1
Original line number Diff line number Diff line
@@ -46,8 +46,11 @@ public class ProgramFragment extends BaseObj {
    }

    public void destroy() {
        if(mDestroyed) {
            throw new IllegalStateException("Object already destroyed.");
        }
        mDestroyed = true;
        mRS.nProgramFragmentStoreDestroy(mID);
        mID = 0;
    }

    public void bindTexture(Allocation va, int slot)
Loading