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

Commit 2afa2200 authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Update fountain to use boolean rather than ints for true/false."

parents 391a3e02 61d10a4e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ int root() {
    return 1;
}

void addParticles(int rate, float x, float y, int newColor)
void addParticles(int rate, float x, float y, bool newColor)
{
    if (newColor) {
        partColor.x = rsRand(0.5f, 1.0f);
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public class FountainRS {
    boolean holdingColor = false;
    public void newTouchPosition(int x, int y, int rate) {
        if (rate > 0) {
            mScript.invoke_addParticles(rate, x, y, !holdingColor ? 1 : 0);
            mScript.invoke_addParticles(rate, x, y, !holdingColor);
            holdingColor = true;
        } else {
            holdingColor = false;
+3 −2
Original line number Diff line number Diff line
@@ -50,12 +50,13 @@ public class ScriptC_Fountain extends ScriptC {
    }

    private final static int mExportFuncIdx_addParticles = 0;
    public void invoke_addParticles(int rate, float x, float y, int newColor) {
    public void invoke_addParticles(int rate, float x, float y, boolean newColor) {
        FieldPacker addParticles_fp = new FieldPacker(16);
        addParticles_fp.addI32(rate);
        addParticles_fp.addF32(x);
        addParticles_fp.addF32(y);
        addParticles_fp.addI32(newColor);
        addParticles_fp.addBoolean(newColor);
        addParticles_fp.skip(3);
        invoke(mExportFuncIdx_addParticles, addParticles_fp);
    }

+10 −9
Original line number Diff line number Diff line
@@ -38,17 +38,18 @@ public class ScriptField_Point extends android.renderscript.Script.FieldBase {

    private Item mItemArray[];
    private FieldPacker mIOBuffer;
    public  ScriptField_Point(RenderScript rs, int count) {
        mItemArray = null;
        mIOBuffer = null;
        {
    public static Element createElement(RenderScript rs) {
        Element.Builder eb = new Element.Builder(rs);
        eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "delta");
        eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "position");
        eb.add(Element.createVector(rs, Element.DataType.UNSIGNED_8, 4), "color");
            mElement = eb.create();
        return eb.create();
    }

    public  ScriptField_Point(RenderScript rs, int count) {
        mItemArray = null;
        mIOBuffer = null;
        mElement = createElement(rs);
        init(rs, count);
    }

@@ -65,7 +66,7 @@ public class ScriptField_Point extends android.renderscript.Script.FieldBase {
        mItemArray[index] = i;
        if (copyNow)  {
            copyToArray(i, index);
            mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
            mAllocation.subData1D(index, 1, mIOBuffer.getData());
        }

    }