Loading core/java/com/android/internal/widget/remotecompose/core/CompanionOperation.java +3 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import java.util.List; /** Interface for the companion operations */ Loading @@ -25,5 +27,5 @@ public interface CompanionOperation { * @param buffer data to read to create operation * @param operations command is to be added */ void read(WireBuffer buffer, List<Operation> operations); void read(@NonNull WireBuffer buffer, @NonNull List<Operation> operations); } core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +65 −22 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import com.android.internal.widget.remotecompose.core.operations.ComponentValue; import com.android.internal.widget.remotecompose.core.operations.FloatExpression; import com.android.internal.widget.remotecompose.core.operations.IntegerExpression; import com.android.internal.widget.remotecompose.core.operations.NamedVariable; import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior; Loading Loading @@ -53,15 +54,16 @@ public class CoreDocument { private static final boolean DEBUG = false; ArrayList<Operation> mOperations; @NonNull ArrayList<Operation> mOperations = new ArrayList<>(); @Nullable RootLayoutComponent mRootLayoutComponent = null; RemoteComposeState mRemoteComposeState = new RemoteComposeState(); @NonNull RemoteComposeState mRemoteComposeState = new RemoteComposeState(); @NonNull TimeVariables mTimeVariables = new TimeVariables(); // Semantic version of the document @NonNull Version mVersion = new Version(0, 1, 0); @Nullable String mContentDescription; // text description of the document (used for accessibility) long mRequiredCapabilities = 0L; // bitmask indicating needed capabilities of the player(unused) Loading @@ -74,19 +76,22 @@ public class CoreDocument { int mContentAlignment = RootContentBehavior.ALIGNMENT_CENTER; RemoteComposeBuffer mBuffer = new RemoteComposeBuffer(mRemoteComposeState); @NonNull RemoteComposeBuffer mBuffer = new RemoteComposeBuffer(mRemoteComposeState); private final HashMap<Long, IntegerExpression> mIntegerExpressions = new HashMap<>(); private final HashMap<Integer, FloatExpression> mFloatExpressions = new HashMap<>(); private HashSet<Component> mAppliedTouchOperations = new HashSet<>(); private int mLastId = 1; // last component id when inflating the file @Nullable public String getContentDescription() { return mContentDescription; } public void setContentDescription(String contentDescription) { public void setContentDescription(@Nullable String contentDescription) { this.mContentDescription = contentDescription; } Loading Loading @@ -116,19 +121,21 @@ public class CoreDocument { mRemoteComposeState.setWindowHeight(height); } @NonNull public RemoteComposeBuffer getBuffer() { return mBuffer; } public void setBuffer(RemoteComposeBuffer buffer) { public void setBuffer(@NonNull RemoteComposeBuffer buffer) { this.mBuffer = buffer; } @NonNull public RemoteComposeState getRemoteComposeState() { return mRemoteComposeState; } public void setRemoteComposeState(RemoteComposeState remoteComposeState) { public void setRemoteComposeState(@NonNull RemoteComposeState remoteComposeState) { this.mRemoteComposeState = remoteComposeState; } Loading Loading @@ -171,7 +178,7 @@ public class CoreDocument { * @param h vertical dimension of the rendering area * @param scaleOutput will contain the computed scale factor */ public void computeScale(float w, float h, float[] scaleOutput) { public void computeScale(float w, float h, @NonNull float[] scaleOutput) { float contentScaleX = 1f; float contentScaleY = 1f; if (mContentSizing == RootContentBehavior.SIZING_SCALE) { Loading Loading @@ -236,7 +243,11 @@ public class CoreDocument { * @param translateOutput will contain the computed translation */ private void computeTranslate( float w, float h, float contentScaleX, float contentScaleY, float[] translateOutput) { float w, float h, float contentScaleX, float contentScaleY, @NonNull float[] translateOutput) { int horizontalContentAlignment = mContentAlignment & 0xF0; int verticalContentAlignment = mContentAlignment & 0xF; float translateX = 0f; Loading Loading @@ -350,6 +361,22 @@ public class CoreDocument { } } /** * Execute an integer expression with the given id and put its value on the targetId * * @param expressionId the id of the integer expression * @param targetId the id of the value to update with the expression * @param context the current context */ public void evaluateFloatExpression( int expressionId, int targetId, @NonNull RemoteContext context) { FloatExpression expression = mFloatExpressions.get(expressionId); if (expression != null) { float v = expression.evaluate(context); context.overrideFloat(targetId, v); } } // ============== Haptic support ================== public interface HapticEngine { void haptic(int type); Loading @@ -375,7 +402,7 @@ public class CoreDocument { /** Callback interface for host actions */ public interface ActionCallback { void onAction(String name, Object value); void onAction(@NonNull String name, Object value); } @NonNull HashSet<ActionCallback> mActionListeners = new HashSet<ActionCallback>(); Loading @@ -386,7 +413,7 @@ public class CoreDocument { * @param name the action name * @param value a parameter to the action */ public void runNamedAction(String name, Object value) { public void runNamedAction(@NonNull String name, Object value) { // TODO: we might add an interface to group all valid parameter types for (ActionCallback callback : mActionListeners) { callback.onAction(name, value); Loading @@ -398,7 +425,7 @@ public class CoreDocument { * * @param callback */ public void addActionCallback(ActionCallback callback) { public void addActionCallback(@NonNull ActionCallback callback) { mActionListeners.add(callback); } Loading @@ -408,7 +435,7 @@ public class CoreDocument { } public interface ClickCallbacks { void click(int id, String metadata); void click(int id, @Nullable String metadata); } @NonNull HashSet<ClickCallbacks> mClickListeners = new HashSet<>(); Loading @@ -429,21 +456,21 @@ public class CoreDocument { public static class ClickAreaRepresentation { int mId; String mContentDescription; @Nullable final String mContentDescription; float mLeft; float mTop; float mRight; float mBottom; String mMetadata; @Nullable final String mMetadata; public ClickAreaRepresentation( int id, String contentDescription, @Nullable String contentDescription, float left, float top, float right, float bottom, String metadata) { @Nullable String metadata) { this.mId = id; this.mContentDescription = contentDescription; this.mLeft = left; Loading Loading @@ -484,10 +511,11 @@ public class CoreDocument { return mId; } public String getContentDescription() { public @Nullable String getContentDescription() { return mContentDescription; } @Nullable public String getMetadata() { return mMetadata; } Loading @@ -502,6 +530,10 @@ public class CoreDocument { IntegerExpression expression = (IntegerExpression) op; mIntegerExpressions.put((long) expression.mId, expression); } if (op instanceof FloatExpression) { FloatExpression expression = (FloatExpression) op; mFloatExpressions.put(expression.mId, expression); } } mOperations = inflateComponents(mOperations); mBuffer = buffer; Loading Loading @@ -605,7 +637,8 @@ public class CoreDocument { @NonNull private HashMap<Integer, Component> mComponentMap = new HashMap<Integer, Component>(); private void registerVariables(RemoteContext context, @NonNull ArrayList<Operation> list) { private void registerVariables( @NonNull RemoteContext context, @NonNull ArrayList<Operation> list) { for (Operation op : list) { if (op instanceof VariableSupport) { ((VariableSupport) op).updateVariables(context); Loading Loading @@ -701,12 +734,12 @@ public class CoreDocument { */ public void addClickArea( int id, String contentDescription, @Nullable String contentDescription, float left, float top, float right, float bottom, String metadata) { @Nullable String metadata) { mClickAreas.add( new ClickAreaRepresentation( id, contentDescription, left, top, right, bottom, metadata)); Loading @@ -726,7 +759,7 @@ public class CoreDocument { * * @param callback called when a click area has been hit, passing the click are id and metadata. */ public void addClickListener(ClickCallbacks callback) { public void addClickListener(@NonNull ClickCallbacks callback) { mClickListeners.add(callback); } Loading @@ -744,7 +777,7 @@ public class CoreDocument { * Passing a click event to the document. This will possibly result in calling the click * listeners. */ public void onClick(RemoteContext context, float x, float y) { public void onClick(@NonNull RemoteContext context, float x, float y) { for (ClickAreaRepresentation clickArea : mClickAreas) { if (clickArea.contains(x, y)) { warnClickListeners(clickArea); Loading Loading @@ -802,6 +835,14 @@ public class CoreDocument { for (TouchListener clickArea : mTouchListeners) { clickArea.touchDrag(context, x, y); } if (mRootLayoutComponent != null) { for (Component component : mAppliedTouchOperations) { component.onTouchDrag(context, this, x, y, true); } if (!mAppliedTouchOperations.isEmpty()) { return true; } } if (!mTouchListeners.isEmpty()) { return true; } Loading Loading @@ -940,6 +981,7 @@ public class CoreDocument { */ public void paint(@NonNull RemoteContext context, int theme) { context.getPaintContext().clearNeedsRepaint(); context.loadFloat(RemoteContext.ID_DENSITY, context.getDensity()); context.mMode = RemoteContext.ContextMode.UNSET; // current theme starts as UNSPECIFIED, until a Theme setter // operation gets executed and modify it. Loading Loading @@ -1097,6 +1139,7 @@ public class CoreDocument { } } @NonNull public List<Operation> getOperations() { return mOperations; } Loading core/java/com/android/internal/widget/remotecompose/core/Operation.java +5 −5 Original line number Diff line number Diff line Loading @@ -15,22 +15,22 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.Nullable; import android.annotation.NonNull; /** Base interface for RemoteCompose operations */ public interface Operation { /** add the operation to the buffer */ void write(WireBuffer buffer); void write(@NonNull WireBuffer buffer); /** * paint an operation * * @param context the paint context used to paint the operation */ void apply(RemoteContext context); void apply(@NonNull RemoteContext context); /** Debug utility to display an operation + indentation */ @Nullable String deepToString(String indent); @NonNull String deepToString(@NonNull String indent); } core/java/com/android/internal/widget/remotecompose/core/Operations.java +9 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,9 @@ import com.android.internal.widget.remotecompose.core.operations.layout.modifier import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.OffsetModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.PaddingModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RoundedClipRectModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatExpressionChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerExpressionChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueStringChangeActionOperation; Loading Loading @@ -214,6 +216,7 @@ public class Operations { public static final int MODIFIER_OFFSET = 221; public static final int MODIFIER_ZINDEX = 223; public static final int MODIFIER_GRAPHICS_LAYER = 224; public static final int MODIFIER_SCROLL = 226; public static final int LOOP_START = 215; public static final int LOOP_END = 216; Loading @@ -226,6 +229,7 @@ public class Operations { public static final int VALUE_STRING_CHANGE_ACTION = 213; public static final int VALUE_INTEGER_EXPRESSION_CHANGE_ACTION = 218; public static final int VALUE_FLOAT_CHANGE_ACTION = 222; public static final int VALUE_FLOAT_EXPRESSION_CHANGE_ACTION = 227; public static final int ANIMATION_SPEC = 14; Loading @@ -235,7 +239,7 @@ public class Operations { static class UniqueIntMap<T> extends IntMap<T> { @Override public T put(int key, T value) { public T put(int key, @NonNull T value) { assert null == get(key) : "Opcode " + key + " already used in Operations !"; return super.put(key, value); } Loading Loading @@ -316,6 +320,7 @@ public class Operations { map.put(MODIFIER_OFFSET, OffsetModifierOperation::read); map.put(MODIFIER_ZINDEX, ZIndexModifierOperation::read); map.put(MODIFIER_GRAPHICS_LAYER, GraphicsLayerModifierOperation::read); map.put(MODIFIER_SCROLL, ScrollModifierOperation::read); map.put(OPERATIONS_LIST_END, OperationsListEnd::read); Loading @@ -327,6 +332,9 @@ public class Operations { ValueIntegerExpressionChangeActionOperation::read); map.put(VALUE_STRING_CHANGE_ACTION, ValueStringChangeActionOperation::read); map.put(VALUE_FLOAT_CHANGE_ACTION, ValueFloatChangeActionOperation::read); map.put( VALUE_FLOAT_EXPRESSION_CHANGE_ACTION, ValueFloatExpressionChangeActionOperation::read); map.put(LAYOUT_ROOT, RootLayoutComponent::read); map.put(LAYOUT_CONTENT, LayoutComponentContent::read); Loading core/java/com/android/internal/widget/remotecompose/core/PaintContext.java +10 −6 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import com.android.internal.widget.remotecompose.core.operations.paint.PaintBundle; /** Specify an abstract paint context used by RemoteCompose commands to draw */ Loading @@ -22,9 +24,10 @@ public abstract class PaintContext { public static final int TEXT_MEASURE_MONOSPACE_WIDTH = 0x01; public static final int TEXT_MEASURE_FONT_HEIGHT = 0x02; protected RemoteContext mContext; protected @NonNull RemoteContext mContext; private boolean mNeedsRepaint = false; @NonNull public RemoteContext getContext() { return mContext; } Loading @@ -37,11 +40,11 @@ public abstract class PaintContext { mNeedsRepaint = false; } public PaintContext(RemoteContext context) { public PaintContext(@NonNull RemoteContext context) { this.mContext = context; } public void setContext(RemoteContext context) { public void setContext(@NonNull RemoteContext context) { this.mContext = context; } Loading Loading @@ -117,7 +120,8 @@ public abstract class PaintContext { * descent of the font (not just of the measured text) * @param bounds the bounds (left, top, right, bottom) */ public abstract void getTextBounds(int textId, int start, int end, int flags, float[] bounds); public abstract void getTextBounds( int textId, int start, int end, int flags, @NonNull float[] bounds); /** * Draw a text starting ast x,y Loading Loading @@ -158,7 +162,7 @@ public abstract class PaintContext { * * @param mPaintData the list of changes */ public abstract void applyPaint(PaintBundle mPaintData); public abstract void applyPaint(@NonNull PaintBundle mPaintData); /** * Scale the rendering by scaleX and saleY (1.0 = no scale). Scaling is done about Loading Loading @@ -264,7 +268,7 @@ public abstract class PaintContext { * * @param content the content to log */ public void log(String content) { public void log(@NonNull String content) { System.out.println("[LOG] " + content); } Loading Loading
core/java/com/android/internal/widget/remotecompose/core/CompanionOperation.java +3 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import java.util.List; /** Interface for the companion operations */ Loading @@ -25,5 +27,5 @@ public interface CompanionOperation { * @param buffer data to read to create operation * @param operations command is to be added */ void read(WireBuffer buffer, List<Operation> operations); void read(@NonNull WireBuffer buffer, @NonNull List<Operation> operations); }
core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +65 −22 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import com.android.internal.widget.remotecompose.core.operations.ComponentValue; import com.android.internal.widget.remotecompose.core.operations.FloatExpression; import com.android.internal.widget.remotecompose.core.operations.IntegerExpression; import com.android.internal.widget.remotecompose.core.operations.NamedVariable; import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior; Loading Loading @@ -53,15 +54,16 @@ public class CoreDocument { private static final boolean DEBUG = false; ArrayList<Operation> mOperations; @NonNull ArrayList<Operation> mOperations = new ArrayList<>(); @Nullable RootLayoutComponent mRootLayoutComponent = null; RemoteComposeState mRemoteComposeState = new RemoteComposeState(); @NonNull RemoteComposeState mRemoteComposeState = new RemoteComposeState(); @NonNull TimeVariables mTimeVariables = new TimeVariables(); // Semantic version of the document @NonNull Version mVersion = new Version(0, 1, 0); @Nullable String mContentDescription; // text description of the document (used for accessibility) long mRequiredCapabilities = 0L; // bitmask indicating needed capabilities of the player(unused) Loading @@ -74,19 +76,22 @@ public class CoreDocument { int mContentAlignment = RootContentBehavior.ALIGNMENT_CENTER; RemoteComposeBuffer mBuffer = new RemoteComposeBuffer(mRemoteComposeState); @NonNull RemoteComposeBuffer mBuffer = new RemoteComposeBuffer(mRemoteComposeState); private final HashMap<Long, IntegerExpression> mIntegerExpressions = new HashMap<>(); private final HashMap<Integer, FloatExpression> mFloatExpressions = new HashMap<>(); private HashSet<Component> mAppliedTouchOperations = new HashSet<>(); private int mLastId = 1; // last component id when inflating the file @Nullable public String getContentDescription() { return mContentDescription; } public void setContentDescription(String contentDescription) { public void setContentDescription(@Nullable String contentDescription) { this.mContentDescription = contentDescription; } Loading Loading @@ -116,19 +121,21 @@ public class CoreDocument { mRemoteComposeState.setWindowHeight(height); } @NonNull public RemoteComposeBuffer getBuffer() { return mBuffer; } public void setBuffer(RemoteComposeBuffer buffer) { public void setBuffer(@NonNull RemoteComposeBuffer buffer) { this.mBuffer = buffer; } @NonNull public RemoteComposeState getRemoteComposeState() { return mRemoteComposeState; } public void setRemoteComposeState(RemoteComposeState remoteComposeState) { public void setRemoteComposeState(@NonNull RemoteComposeState remoteComposeState) { this.mRemoteComposeState = remoteComposeState; } Loading Loading @@ -171,7 +178,7 @@ public class CoreDocument { * @param h vertical dimension of the rendering area * @param scaleOutput will contain the computed scale factor */ public void computeScale(float w, float h, float[] scaleOutput) { public void computeScale(float w, float h, @NonNull float[] scaleOutput) { float contentScaleX = 1f; float contentScaleY = 1f; if (mContentSizing == RootContentBehavior.SIZING_SCALE) { Loading Loading @@ -236,7 +243,11 @@ public class CoreDocument { * @param translateOutput will contain the computed translation */ private void computeTranslate( float w, float h, float contentScaleX, float contentScaleY, float[] translateOutput) { float w, float h, float contentScaleX, float contentScaleY, @NonNull float[] translateOutput) { int horizontalContentAlignment = mContentAlignment & 0xF0; int verticalContentAlignment = mContentAlignment & 0xF; float translateX = 0f; Loading Loading @@ -350,6 +361,22 @@ public class CoreDocument { } } /** * Execute an integer expression with the given id and put its value on the targetId * * @param expressionId the id of the integer expression * @param targetId the id of the value to update with the expression * @param context the current context */ public void evaluateFloatExpression( int expressionId, int targetId, @NonNull RemoteContext context) { FloatExpression expression = mFloatExpressions.get(expressionId); if (expression != null) { float v = expression.evaluate(context); context.overrideFloat(targetId, v); } } // ============== Haptic support ================== public interface HapticEngine { void haptic(int type); Loading @@ -375,7 +402,7 @@ public class CoreDocument { /** Callback interface for host actions */ public interface ActionCallback { void onAction(String name, Object value); void onAction(@NonNull String name, Object value); } @NonNull HashSet<ActionCallback> mActionListeners = new HashSet<ActionCallback>(); Loading @@ -386,7 +413,7 @@ public class CoreDocument { * @param name the action name * @param value a parameter to the action */ public void runNamedAction(String name, Object value) { public void runNamedAction(@NonNull String name, Object value) { // TODO: we might add an interface to group all valid parameter types for (ActionCallback callback : mActionListeners) { callback.onAction(name, value); Loading @@ -398,7 +425,7 @@ public class CoreDocument { * * @param callback */ public void addActionCallback(ActionCallback callback) { public void addActionCallback(@NonNull ActionCallback callback) { mActionListeners.add(callback); } Loading @@ -408,7 +435,7 @@ public class CoreDocument { } public interface ClickCallbacks { void click(int id, String metadata); void click(int id, @Nullable String metadata); } @NonNull HashSet<ClickCallbacks> mClickListeners = new HashSet<>(); Loading @@ -429,21 +456,21 @@ public class CoreDocument { public static class ClickAreaRepresentation { int mId; String mContentDescription; @Nullable final String mContentDescription; float mLeft; float mTop; float mRight; float mBottom; String mMetadata; @Nullable final String mMetadata; public ClickAreaRepresentation( int id, String contentDescription, @Nullable String contentDescription, float left, float top, float right, float bottom, String metadata) { @Nullable String metadata) { this.mId = id; this.mContentDescription = contentDescription; this.mLeft = left; Loading Loading @@ -484,10 +511,11 @@ public class CoreDocument { return mId; } public String getContentDescription() { public @Nullable String getContentDescription() { return mContentDescription; } @Nullable public String getMetadata() { return mMetadata; } Loading @@ -502,6 +530,10 @@ public class CoreDocument { IntegerExpression expression = (IntegerExpression) op; mIntegerExpressions.put((long) expression.mId, expression); } if (op instanceof FloatExpression) { FloatExpression expression = (FloatExpression) op; mFloatExpressions.put(expression.mId, expression); } } mOperations = inflateComponents(mOperations); mBuffer = buffer; Loading Loading @@ -605,7 +637,8 @@ public class CoreDocument { @NonNull private HashMap<Integer, Component> mComponentMap = new HashMap<Integer, Component>(); private void registerVariables(RemoteContext context, @NonNull ArrayList<Operation> list) { private void registerVariables( @NonNull RemoteContext context, @NonNull ArrayList<Operation> list) { for (Operation op : list) { if (op instanceof VariableSupport) { ((VariableSupport) op).updateVariables(context); Loading Loading @@ -701,12 +734,12 @@ public class CoreDocument { */ public void addClickArea( int id, String contentDescription, @Nullable String contentDescription, float left, float top, float right, float bottom, String metadata) { @Nullable String metadata) { mClickAreas.add( new ClickAreaRepresentation( id, contentDescription, left, top, right, bottom, metadata)); Loading @@ -726,7 +759,7 @@ public class CoreDocument { * * @param callback called when a click area has been hit, passing the click are id and metadata. */ public void addClickListener(ClickCallbacks callback) { public void addClickListener(@NonNull ClickCallbacks callback) { mClickListeners.add(callback); } Loading @@ -744,7 +777,7 @@ public class CoreDocument { * Passing a click event to the document. This will possibly result in calling the click * listeners. */ public void onClick(RemoteContext context, float x, float y) { public void onClick(@NonNull RemoteContext context, float x, float y) { for (ClickAreaRepresentation clickArea : mClickAreas) { if (clickArea.contains(x, y)) { warnClickListeners(clickArea); Loading Loading @@ -802,6 +835,14 @@ public class CoreDocument { for (TouchListener clickArea : mTouchListeners) { clickArea.touchDrag(context, x, y); } if (mRootLayoutComponent != null) { for (Component component : mAppliedTouchOperations) { component.onTouchDrag(context, this, x, y, true); } if (!mAppliedTouchOperations.isEmpty()) { return true; } } if (!mTouchListeners.isEmpty()) { return true; } Loading Loading @@ -940,6 +981,7 @@ public class CoreDocument { */ public void paint(@NonNull RemoteContext context, int theme) { context.getPaintContext().clearNeedsRepaint(); context.loadFloat(RemoteContext.ID_DENSITY, context.getDensity()); context.mMode = RemoteContext.ContextMode.UNSET; // current theme starts as UNSPECIFIED, until a Theme setter // operation gets executed and modify it. Loading Loading @@ -1097,6 +1139,7 @@ public class CoreDocument { } } @NonNull public List<Operation> getOperations() { return mOperations; } Loading
core/java/com/android/internal/widget/remotecompose/core/Operation.java +5 −5 Original line number Diff line number Diff line Loading @@ -15,22 +15,22 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.Nullable; import android.annotation.NonNull; /** Base interface for RemoteCompose operations */ public interface Operation { /** add the operation to the buffer */ void write(WireBuffer buffer); void write(@NonNull WireBuffer buffer); /** * paint an operation * * @param context the paint context used to paint the operation */ void apply(RemoteContext context); void apply(@NonNull RemoteContext context); /** Debug utility to display an operation + indentation */ @Nullable String deepToString(String indent); @NonNull String deepToString(@NonNull String indent); }
core/java/com/android/internal/widget/remotecompose/core/Operations.java +9 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,9 @@ import com.android.internal.widget.remotecompose.core.operations.layout.modifier import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.OffsetModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.PaddingModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RoundedClipRectModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatExpressionChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerExpressionChangeActionOperation; import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueStringChangeActionOperation; Loading Loading @@ -214,6 +216,7 @@ public class Operations { public static final int MODIFIER_OFFSET = 221; public static final int MODIFIER_ZINDEX = 223; public static final int MODIFIER_GRAPHICS_LAYER = 224; public static final int MODIFIER_SCROLL = 226; public static final int LOOP_START = 215; public static final int LOOP_END = 216; Loading @@ -226,6 +229,7 @@ public class Operations { public static final int VALUE_STRING_CHANGE_ACTION = 213; public static final int VALUE_INTEGER_EXPRESSION_CHANGE_ACTION = 218; public static final int VALUE_FLOAT_CHANGE_ACTION = 222; public static final int VALUE_FLOAT_EXPRESSION_CHANGE_ACTION = 227; public static final int ANIMATION_SPEC = 14; Loading @@ -235,7 +239,7 @@ public class Operations { static class UniqueIntMap<T> extends IntMap<T> { @Override public T put(int key, T value) { public T put(int key, @NonNull T value) { assert null == get(key) : "Opcode " + key + " already used in Operations !"; return super.put(key, value); } Loading Loading @@ -316,6 +320,7 @@ public class Operations { map.put(MODIFIER_OFFSET, OffsetModifierOperation::read); map.put(MODIFIER_ZINDEX, ZIndexModifierOperation::read); map.put(MODIFIER_GRAPHICS_LAYER, GraphicsLayerModifierOperation::read); map.put(MODIFIER_SCROLL, ScrollModifierOperation::read); map.put(OPERATIONS_LIST_END, OperationsListEnd::read); Loading @@ -327,6 +332,9 @@ public class Operations { ValueIntegerExpressionChangeActionOperation::read); map.put(VALUE_STRING_CHANGE_ACTION, ValueStringChangeActionOperation::read); map.put(VALUE_FLOAT_CHANGE_ACTION, ValueFloatChangeActionOperation::read); map.put( VALUE_FLOAT_EXPRESSION_CHANGE_ACTION, ValueFloatExpressionChangeActionOperation::read); map.put(LAYOUT_ROOT, RootLayoutComponent::read); map.put(LAYOUT_CONTENT, LayoutComponentContent::read); Loading
core/java/com/android/internal/widget/remotecompose/core/PaintContext.java +10 −6 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import com.android.internal.widget.remotecompose.core.operations.paint.PaintBundle; /** Specify an abstract paint context used by RemoteCompose commands to draw */ Loading @@ -22,9 +24,10 @@ public abstract class PaintContext { public static final int TEXT_MEASURE_MONOSPACE_WIDTH = 0x01; public static final int TEXT_MEASURE_FONT_HEIGHT = 0x02; protected RemoteContext mContext; protected @NonNull RemoteContext mContext; private boolean mNeedsRepaint = false; @NonNull public RemoteContext getContext() { return mContext; } Loading @@ -37,11 +40,11 @@ public abstract class PaintContext { mNeedsRepaint = false; } public PaintContext(RemoteContext context) { public PaintContext(@NonNull RemoteContext context) { this.mContext = context; } public void setContext(RemoteContext context) { public void setContext(@NonNull RemoteContext context) { this.mContext = context; } Loading Loading @@ -117,7 +120,8 @@ public abstract class PaintContext { * descent of the font (not just of the measured text) * @param bounds the bounds (left, top, right, bottom) */ public abstract void getTextBounds(int textId, int start, int end, int flags, float[] bounds); public abstract void getTextBounds( int textId, int start, int end, int flags, @NonNull float[] bounds); /** * Draw a text starting ast x,y Loading Loading @@ -158,7 +162,7 @@ public abstract class PaintContext { * * @param mPaintData the list of changes */ public abstract void applyPaint(PaintBundle mPaintData); public abstract void applyPaint(@NonNull PaintBundle mPaintData); /** * Scale the rendering by scaleX and saleY (1.0 = no scale). Scaling is done about Loading Loading @@ -264,7 +268,7 @@ public abstract class PaintContext { * * @param content the content to log */ public void log(String content) { public void log(@NonNull String content) { System.out.println("[LOG] " + content); } Loading