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

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

Merge "Update to ToT RemoteCompose" into main

parents 3ad341ab 8f1e6cce
Loading
Loading
Loading
Loading
+29 −5
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.LoopOper
import com.android.internal.widget.remotecompose.core.operations.layout.RootLayoutComponent;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ComponentModifiers;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.utilities.IntMap;
import com.android.internal.widget.remotecompose.core.operations.utilities.StringSerializer;
import com.android.internal.widget.remotecompose.core.serialize.MapSerializer;
import com.android.internal.widget.remotecompose.core.serialize.Serializable;
@@ -64,7 +65,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.0f;
    static final float BUILD = 0.1f;

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

@@ -99,6 +100,8 @@ public class CoreDocument implements Serializable {

    private int mLastId = 1; // last component id when inflating the file

    private IntMap<Object> mDocProperties;

    /** Returns a version number that is monotonically increasing. */
    public static int getDocumentApiLevel() {
        return DOCUMENT_API_LEVEL;
@@ -407,10 +410,31 @@ public class CoreDocument implements Serializable {

    @Override
    public void serialize(MapSerializer serializer) {
        serializer.add("type", "CoreDocument");
        serializer.add("width", mWidth);
        serializer.add("height", mHeight);
        serializer.add("operations", mOperations);
        serializer
                .add("type", "CoreDocument")
                .add("width", mWidth)
                .add("height", mHeight)
                .add("operations", mOperations);
    }

    /**
     * Set the properties of the document
     *
     * @param properties the properties to set
     */
    public void setProperties(IntMap<Object> properties) {
        mDocProperties = properties;
    }

    /**
     * @param key the key
     * @return the value associated with the key
     */
    public Object getProperty(short key) {
        if (mDocProperties == null) {
            return null;
        }
        return mDocProperties.get(key);
    }

    // ============== Haptic support ==================
+7 −0
Original line number Diff line number Diff line
@@ -206,6 +206,13 @@ public abstract class PaintContext {
    /** This restores the paint form the paint stack */
    public abstract void restorePaint();

    /**
     * Replace the current paint with the PaintBundle
     *
     * @param paint
     */
    public abstract void replacePaint(PaintBundle paint);

    /**
     * draw a round rect
     *
+27 −0
Original line number Diff line number Diff line
@@ -191,6 +191,11 @@ public class RemoteComposeBuffer {
    // Supported operations on the buffer
    ///////////////////////////////////////////////////////////////////////////////////////////////

    /** Insert a header */
    public void addHeader(short[] tags, Object[] values) {
        Header.apply(mBuffer, tags, values);
    }

    /**
     * Insert a header
     *
@@ -213,6 +218,28 @@ public class RemoteComposeBuffer {
        }
    }

    /**
     * Insert a header
     *
     * @param width the width of the document in pixels
     * @param height the height of the document in pixels
     * @param contentDescription content description of the document
     * @param capabilities bitmask indicating needed capabilities (unused for now)
     */
    public void addHeader(
            int width,
            int height,
            @Nullable String contentDescription,
            float density,
            long capabilities) {
        Header.apply(mBuffer, width, height, density, capabilities);
        int contentDescriptionId = 0;
        if (contentDescription != null) {
            contentDescriptionId = addText(contentDescription);
            RootContentDescription.apply(mBuffer, contentDescriptionId);
        }
    }

    /**
     * Insert a header
     *
+5 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.Componen
import com.android.internal.widget.remotecompose.core.operations.utilities.ArrayAccess;
import com.android.internal.widget.remotecompose.core.operations.utilities.CollectionsAccess;
import com.android.internal.widget.remotecompose.core.operations.utilities.DataMap;
import com.android.internal.widget.remotecompose.core.operations.utilities.IntMap;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
@@ -392,6 +393,7 @@ public abstract class RemoteContext {
     * @param width original width of the document when created
     * @param height original height of the document when created
     * @param capabilities bitmask of capabilities used in the document (TBD)
     * @param properties properties of the document (TBD)
     */
    public void header(
            int majorVersion,
@@ -399,13 +401,15 @@ public abstract class RemoteContext {
            int patchVersion,
            int width,
            int height,
            long capabilities) {
            long capabilities,
            IntMap<Object> properties) {
        mRemoteComposeState.setWindowWidth(width);
        mRemoteComposeState.setWindowHeight(height);
        mDocument.setVersion(majorVersion, minorVersion, patchVersion);
        mDocument.setWidth(width);
        mDocument.setHeight(height);
        mDocument.setRequiredCapabilities(capabilities);
        mDocument.setProperties(properties);
    }

    /**
+35 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import com.android.internal.widget.remotecompose.core.VariableSupport;
import com.android.internal.widget.remotecompose.core.WireBuffer;
import com.android.internal.widget.remotecompose.core.documentation.DocumentationBuilder;
import com.android.internal.widget.remotecompose.core.documentation.DocumentedOperation;
import com.android.internal.widget.remotecompose.core.serialize.MapSerializer;
import com.android.internal.widget.remotecompose.core.serialize.Serializable;

import java.util.List;

@@ -34,7 +36,7 @@ import java.util.List;
 * Operation to Colors Color modes mMode = 0 two colors and a tween mMode = 1 color1 is a colorID.
 * mMode = 2 color2 is a colorID. mMode = 3 color1 & color2 are ids mMode = 4 H S V mode
 */
public class ColorExpression extends Operation implements VariableSupport {
public class ColorExpression extends Operation implements VariableSupport, Serializable {
    private static final int OP_CODE = Operations.COLOR_EXPRESSIONS;
    private static final String CLASS_NAME = "ColorExpression";
    public int mId;
@@ -502,4 +504,36 @@ public class ColorExpression extends Operation implements VariableSupport {
    public String deepToString(@NonNull String indent) {
        return indent + toString();
    }

    @Override
    public void serialize(MapSerializer serializer) {
        serializer.add("type", CLASS_NAME).add("id", mId);
        switch (mMode) {
            case COLOR_COLOR_INTERPOLATE:
            case ID_COLOR_INTERPOLATE:
            case COLOR_ID_INTERPOLATE:
            case ID_ID_INTERPOLATE:
                serializer.add("mode", "TWEEN");
                serializer.add("startColor", mColor1, mOutColor1);
                serializer.add("endColor", mColor2, mOutColor2);
                serializer.add("startColor", mTween, mOutTween);
                break;
            case HSV_MODE:
                serializer.add("mode", "HSV");
                serializer.add("hue", mHue, mOutHue);
                serializer.add("sat", mSat, mOutSat);
                serializer.add("val", mValue, mOutValue);
                break;
            case ARGB_MODE:
            case IDARGB_MODE:
                serializer.add("mode", "ARGB");
                serializer.add("a", mArgbAlpha, mOutArgbAlpha);
                serializer.add("r", mArgbRed, mOutArgbRed);
                serializer.add("g", mArgbGreen, mOutArgbGreen);
                serializer.add("b", mArgbBlue, mOutArgbBlue);
                break;
            default:
                serializer.add("mode", "NONE");
        }
    }
}
Loading