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

Commit f257e513 authored by Stephen Hines's avatar Stephen Hines
Browse files

Add isCompatible() to RS Element.

BUG=4203264

Change-Id: Id68aead685f6cbc71c2fbe461cb38382e0563f43
parent 6d99a393
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -16670,6 +16670,7 @@ package android.renderscript {
    method public static android.renderscript.Element U8_4(android.renderscript.RenderScript);
    method public static android.renderscript.Element U8_4(android.renderscript.RenderScript);
    method public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind);
    method public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind);
    method public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int);
    method public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int);
    method public boolean isCompatible(android.renderscript.Element);
    method public boolean isComplex();
    method public boolean isComplex();
  }
  }
+29 −2
Original line number Original line Diff line number Diff line
@@ -32,8 +32,8 @@ import android.util.Log;
 * <p>Complex elements contain a list of sub-elements and names that
 * <p>Complex elements contain a list of sub-elements and names that
 * represents a structure of data. The fields can be accessed by name
 * represents a structure of data. The fields can be accessed by name
 * from a script or shader. The memory layout is defined and ordered. Data
 * from a script or shader. The memory layout is defined and ordered. Data
 * alignment is determinied by the most basic primitive type. i.e. a float4
 * alignment is determined by the most basic primitive type. i.e. a float4
 * vector will be alligned to sizeof(float) and not sizeof(float4).  The
 * vector will be aligned to sizeof(float) and not sizeof(float4). The
 * ordering of elements in memory will be the order in which they were added
 * ordering of elements in memory will be the order in which they were added
 * with each component aligned as necessary. No re-ordering will be done.</p>
 * with each component aligned as necessary. No re-ordering will be done.</p>
 *
 *
@@ -583,6 +583,33 @@ public class Element extends BaseObj {
        return new Element(id, rs, dt, dk, norm, size);
        return new Element(id, rs, dt, dk, norm, size);
    }
    }


    /**
     * Check if the current Element is compatible with another Element.
     * Primitive Elements are compatible if they share the same underlying
     * size and type (i.e. U8 is compatible with A_8). User-defined Elements
     * must be equal in order to be compatible. This requires strict name
     * equivalence for all sub-Elements (in addition to structural equivalence).
     *
     * @param e The Element to check compatibility with.
     *
     * @return boolean true if the Elements are compatible, otherwise false.
     */
    public boolean isCompatible(Element e) {
        // Try strict BaseObj equality to start with.
        if (this.equals(e)) {
            return true;
        }

        // Ignore mKind because it is allowed to be different (user vs. pixel).
        // We also ignore mNormalized because it can be different. The mType
        // field must be non-null since we require name equivalence for
        // user-created Elements.
        return ((mSize == e.mSize) &&
                (mType != null) &&
                (mType == e.mType) &&
                (mVectorSize == e.mVectorSize));
    }

    /**
    /**
     * Builder class for producing complex elements with matching field and name
     * Builder class for producing complex elements with matching field and name
     * pairs.  The builder starts empty.  The order in which elements are added
     * pairs.  The builder starts empty.  The order in which elements are added