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

Commit e8effee2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update to ToT RemoteCompose" into main

parents de15ce18 048715e0
Loading
Loading
Loading
Loading
+46 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.remotecompose.core.operations.ComponentValue;
import com.android.internal.widget.remotecompose.core.operations.DrawContent;
import com.android.internal.widget.remotecompose.core.operations.FloatExpression;
import com.android.internal.widget.remotecompose.core.operations.Header;
import com.android.internal.widget.remotecompose.core.operations.IntegerExpression;
@@ -28,9 +29,11 @@ import com.android.internal.widget.remotecompose.core.operations.RootContentBeha
import com.android.internal.widget.remotecompose.core.operations.ShaderData;
import com.android.internal.widget.remotecompose.core.operations.TextData;
import com.android.internal.widget.remotecompose.core.operations.Theme;
import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations;
import com.android.internal.widget.remotecompose.core.operations.layout.Component;
import com.android.internal.widget.remotecompose.core.operations.layout.Container;
import com.android.internal.widget.remotecompose.core.operations.layout.ContainerEnd;
import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponent;
import com.android.internal.widget.remotecompose.core.operations.layout.LoopOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.RootLayoutComponent;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ComponentModifiers;
@@ -65,7 +68,7 @@ public class CoreDocument implements Serializable {

    // We also keep a more fine-grained BUILD number, exposed as
    // ID_API_LEVEL = DOCUMENT_API_LEVEL + BUILD
    static final float BUILD = 0.3f;
    static final float BUILD = 0.4f;

    @NonNull ArrayList<Operation> mOperations = new ArrayList<>();

@@ -102,6 +105,8 @@ public class CoreDocument implements Serializable {

    private IntMap<Object> mDocProperties;

    boolean mFirstPaint = true;

    /** Returns a version number that is monotonically increasing. */
    public static int getDocumentApiLevel() {
        return DOCUMENT_API_LEVEL;
@@ -678,6 +683,7 @@ public class CoreDocument implements Serializable {
        ArrayList<Operation> ops = finalOperationsList;

        ArrayList<Container> containers = new ArrayList<>();
        LayoutComponent lastLayoutComponent = null;

        mLastId = -1;
        for (Operation o : operations) {
@@ -697,6 +703,9 @@ public class CoreDocument implements Serializable {
                    if (component.getComponentId() < mLastId) {
                        mLastId = component.getComponentId();
                    }
                    if (component instanceof LayoutComponent) {
                        lastLayoutComponent = (LayoutComponent) component;
                    }
                }
                containers.add(container);
                ops = container.getList();
@@ -723,7 +732,13 @@ public class CoreDocument implements Serializable {
                    }
                    ops.add((Operation) container);
                }
                if (container instanceof CanvasOperations) {
                    ((CanvasOperations) container).setComponent(lastLayoutComponent);
                }
            } else {
                if (o instanceof DrawContent) {
                    ((DrawContent) o).setComponent(lastLayoutComponent);
                }
                ops.add(o);
            }
        }
@@ -784,6 +799,7 @@ public class CoreDocument implements Serializable {

        registerVariables(context, mOperations);
        context.mMode = RemoteContext.ContextMode.UNSET;
        mFirstPaint = true;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -1092,6 +1108,28 @@ public class CoreDocument implements Serializable {
        return mRepaintNext;
    }

    /**
     * Traverse the list of operations to update the variables. TODO: this should walk the
     * dependency tree instead
     *
     * @param context
     * @param operations
     */
    private void updateVariables(
            @NonNull RemoteContext context, int theme, List<Operation> operations) {
        for (int i = 0; i < operations.size(); i++) {
            Operation op = operations.get(i);
            if (op.isDirty() && op instanceof VariableSupport) {
                ((VariableSupport) op).updateVariables(context);
                op.apply(context);
                op.markNotDirty();
            }
            if (op instanceof Container) {
                updateVariables(context, theme, ((Container) op).getList());
            }
        }
    }

    /**
     * Paint the document
     *
@@ -1110,6 +1148,13 @@ public class CoreDocument implements Serializable {
        context.mRemoteComposeState = mRemoteComposeState;
        context.mRemoteComposeState.setContext(context);

        // Update any dirty variables
        if (mFirstPaint) {
            mFirstPaint = false;
        } else {
            updateVariables(context, theme, mOperations);
        }

        // If we have a content sizing set, we are going to take the original document
        // dimension into account and apply scale+translate according to the RootContentBehavior
        // rules.
+9 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.internal.widget.remotecompose.core.operations.ClipRect;
import com.android.internal.widget.remotecompose.core.operations.ColorConstant;
import com.android.internal.widget.remotecompose.core.operations.ColorExpression;
import com.android.internal.widget.remotecompose.core.operations.ComponentValue;
import com.android.internal.widget.remotecompose.core.operations.ConditionalOperations;
import com.android.internal.widget.remotecompose.core.operations.DataListFloat;
import com.android.internal.widget.remotecompose.core.operations.DataListIds;
import com.android.internal.widget.remotecompose.core.operations.DataMapIds;
@@ -50,6 +51,7 @@ import com.android.internal.widget.remotecompose.core.operations.FloatConstant;
import com.android.internal.widget.remotecompose.core.operations.FloatExpression;
import com.android.internal.widget.remotecompose.core.operations.FloatFunctionCall;
import com.android.internal.widget.remotecompose.core.operations.FloatFunctionDefine;
import com.android.internal.widget.remotecompose.core.operations.HapticFeedback;
import com.android.internal.widget.remotecompose.core.operations.Header;
import com.android.internal.widget.remotecompose.core.operations.ImageAttribute;
import com.android.internal.widget.remotecompose.core.operations.IntegerExpression;
@@ -64,6 +66,7 @@ import com.android.internal.widget.remotecompose.core.operations.PaintData;
import com.android.internal.widget.remotecompose.core.operations.ParticlesCreate;
import com.android.internal.widget.remotecompose.core.operations.ParticlesLoop;
import com.android.internal.widget.remotecompose.core.operations.PathAppend;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
@@ -222,6 +225,9 @@ public class Operations {
    public static final int ATTRIBUTE_TIME = 172;
    public static final int CANVAS_OPERATIONS = 173;
    public static final int MODIFIER_DRAW_CONTENT = 174;
    public static final int PATH_COMBINE = 175;
    public static final int HAPTIC_FEEDBACK = 177;
    public static final int CONDITIONAL_OPERATIONS = 178;

    ///////////////////////////////////////// ======================

@@ -426,6 +432,9 @@ public class Operations {
        map.put(ATTRIBUTE_IMAGE, ImageAttribute::read);
        map.put(ATTRIBUTE_TEXT, TextAttribute::read);
        map.put(ATTRIBUTE_TIME, TimeAttribute::read);
        map.put(PATH_COMBINE, PathCombine::read);
        map.put(HAPTIC_FEEDBACK, HapticFeedback::read);
        map.put(CONDITIONAL_OPERATIONS, ConditionalOperations::read);

        //        map.put(ACCESSIBILITY_CUSTOM_ACTION, CoreSemantics::read);
    }
+11 −0
Original line number Diff line number Diff line
@@ -339,6 +339,17 @@ public abstract class PaintContext {
     */
    public abstract void tweenPath(int out, int path1, int path2, float tween);

    /**
     * Perform a between two path and return the resulting path
     *
     * @param out the interpolated path
     * @param path1 start path
     * @param path2 end path
     * @param operation 0 = difference , 1 = intersection, 2 = reverse_difference, 3 = union, 4 =
     *     xor
     */
    public abstract void combinePath(int out, int path1, int path2, byte operation);

    /**
     * This applies changes to the current paint
     *
+37 −9
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.internal.widget.remotecompose.core.operations.ClipRect;
import com.android.internal.widget.remotecompose.core.operations.ColorConstant;
import com.android.internal.widget.remotecompose.core.operations.ColorExpression;
import com.android.internal.widget.remotecompose.core.operations.ComponentValue;
import com.android.internal.widget.remotecompose.core.operations.ConditionalOperations;
import com.android.internal.widget.remotecompose.core.operations.DataListFloat;
import com.android.internal.widget.remotecompose.core.operations.DataListIds;
import com.android.internal.widget.remotecompose.core.operations.DataMapIds;
@@ -53,6 +54,7 @@ import com.android.internal.widget.remotecompose.core.operations.FloatConstant;
import com.android.internal.widget.remotecompose.core.operations.FloatExpression;
import com.android.internal.widget.remotecompose.core.operations.FloatFunctionCall;
import com.android.internal.widget.remotecompose.core.operations.FloatFunctionDefine;
import com.android.internal.widget.remotecompose.core.operations.HapticFeedback;
import com.android.internal.widget.remotecompose.core.operations.Header;
import com.android.internal.widget.remotecompose.core.operations.ImageAttribute;
import com.android.internal.widget.remotecompose.core.operations.IntegerExpression;
@@ -67,6 +69,7 @@ import com.android.internal.widget.remotecompose.core.operations.PaintData;
import com.android.internal.widget.remotecompose.core.operations.ParticlesCreate;
import com.android.internal.widget.remotecompose.core.operations.ParticlesLoop;
import com.android.internal.widget.remotecompose.core.operations.PathAppend;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
@@ -890,7 +893,7 @@ public class RemoteComposeBuffer {
     * @return new id that merges the two text
     */
    public int textMerge(int id1, int id2) {
        int textId = addText(id1 + "+" + id2);
        int textId = nextId();
        TextMerge.apply(mBuffer, textId, id1, id2);
        return textId;
    }
@@ -2273,8 +2276,6 @@ public class RemoteComposeBuffer {
        return mRemoteComposeState.nextId();
    }

    private boolean mInImpulseProcess = false;

    /**
     * add an impulse. (must be followed by impulse end)
     *
@@ -2283,22 +2284,16 @@ public class RemoteComposeBuffer {
     */
    public void addImpulse(float duration, float start) {
        ImpulseOperation.apply(mBuffer, duration, start);
        mInImpulseProcess = false;
    }

    /** add an impulse process */
    public void addImpulseProcess() {
        ImpulseProcess.apply(mBuffer);
        mInImpulseProcess = true;
    }

    /** Add an impulse end */
    public void addImpulseEnd() {
        ContainerEnd.apply(mBuffer);
        if (mInImpulseProcess) {
            ContainerEnd.apply(mBuffer);
        }
        mInImpulseProcess = false;
    }

    /**
@@ -2422,4 +2417,37 @@ public class RemoteComposeBuffer {

        return imageId;
    }

    /**
     * Combine two paths
     *
     * @param id output id
     * @param path1 first path
     * @param path2 second path
     * @param op operation to perform OP_DIFFERENCE, OP_INTERSECT, OP_REVERSE_DIFFERENCE, OP_UNION,
     *     OP_XOR
     */
    public void pathCombine(int id, int path1, int path2, byte op) {
        PathCombine.apply(mBuffer, id, path1, path2, op);
    }

    /**
     * Perform a haptic feedback
     *
     * @param feedbackConstant
     */
    public void performHaptic(int feedbackConstant) {
        HapticFeedback.apply(mBuffer, feedbackConstant);
    }

    /**
     * Add a conditional operation
     *
     * @param type type of comparison
     * @param a first value
     * @param b second value
     */
    public void addConditionalOperations(byte type, float a, float b) {
        ConditionalOperations.apply(mBuffer, type, a, b);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -551,6 +551,14 @@ public abstract class RemoteContext {
     */
    public abstract int getInteger(int id);

    /**
     * Get a Long given an id
     *
     * @param id of the long
     * @return the value
     */
    public abstract long getLong(int id);

    /**
     * Get the color given and ID
     *
@@ -629,6 +637,8 @@ public abstract class RemoteContext {
    /** The delta between current and last Frame */
    public static final int ID_ANIMATION_DELTA_TIME = 31;

    public static final int ID_EPOCH_SECOND = 32;

    public static final float FLOAT_DENSITY = Utils.asNan(ID_DENSITY);

    /** CONTINUOUS_SEC is seconds from midnight looping every hour 0-3600 */
@@ -714,6 +724,9 @@ public abstract class RemoteContext {
    /** When was this player built */
    public static final float FLOAT_API_LEVEL = Utils.asNan(ID_API_LEVEL);

    /** The time in seconds since the epoch. */
    public static final long INT_EPOCH_SECOND = ((long) ID_EPOCH_SECOND) + 0x100000000L;

    ///////////////////////////////////////////////////////////////////////////////////////////////
    // Click handling
    ///////////////////////////////////////////////////////////////////////////////////////////////
Loading