Loading core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +29 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,8 @@ public class CoreDocument implements Serializable { boolean mFirstPaint = true; private boolean mIsUpdateDoc = false; private int mHostExceptionID = 0; private int mBitmapMemory = 0; private int mBitmapCount = 0; public CoreDocument() { this(new SystemClock()); Loading Loading @@ -570,6 +572,15 @@ public class CoreDocument implements Serializable { return mHostExceptionID; } /** * Get the bitmap memory used by the document * * @return the bitmap memory used by the document */ public int bitmapMemory() { return mBitmapMemory; } private interface Visitor { void visit(Operation op); } Loading Loading @@ -825,7 +836,10 @@ public class CoreDocument implements Serializable { mFloatExpressions.put(expression.mId, expression); } } mBitmapMemory = 0; mBitmapCount = 0; mOperations = inflateComponents(mOperations); mBuffer = buffer; for (Operation op : mOperations) { if (op instanceof RootLayoutComponent) { Loading Loading @@ -854,6 +868,11 @@ public class CoreDocument implements Serializable { mLastId = -1; for (Operation o : operations) { if (o instanceof BitmapData) { BitmapData bitmap = (BitmapData) o; mBitmapMemory += bitmap.getHeight() * bitmap.getWidth() * 4; mBitmapCount++; } if (o instanceof Container) { Container container = (Container) o; if (container instanceof Component) { Loading Loading @@ -1116,7 +1135,9 @@ public class CoreDocument implements Serializable { /** * Programmatically trigger the click response for the given id * * @param context the context * @param id the click area id * @param metadata the metadata of the click event */ public void performClick(@NonNull RemoteContext context, int id, @NonNull String metadata) { for (ClickAreaRepresentation clickArea : mClickAreas) { Loading Loading @@ -1166,6 +1187,7 @@ public class CoreDocument implements Serializable { /** * Support touch drag events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch */ Loading @@ -1189,6 +1211,7 @@ public class CoreDocument implements Serializable { /** * Support touch down events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch */ Loading @@ -1207,8 +1230,11 @@ public class CoreDocument implements Serializable { /** * Support touch up events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch * @param dx the x component of the drag vector * @param dy the y component of the drag vector */ public void touchUp(@NonNull RemoteContext context, float x, float y, float dx, float dy) { context.loadFloat(RemoteContext.ID_TOUCH_POS_X, x); Loading @@ -1228,8 +1254,11 @@ public class CoreDocument implements Serializable { /** * Support touch cancel events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch * @param dx the x component of the drag vector * @param dy the y component of the drag vector */ public void touchCancel(@NonNull RemoteContext context, float x, float y, float dx, float dy) { if (mRootLayoutComponent != null) { Loading core/java/com/android/internal/widget/remotecompose/core/Operations.java +11 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.internal.widget.remotecompose.core.operations.TextSubtext; import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.core.operations.TimeAttribute; import com.android.internal.widget.remotecompose.core.operations.TouchExpression; import com.android.internal.widget.remotecompose.core.operations.WakeIn; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations; import com.android.internal.widget.remotecompose.core.operations.layout.ClickModifierOperation; Loading Loading @@ -268,6 +269,7 @@ public class Operations { public static final int MATRIX_VECTOR_MATH = 188; public static final int DATA_FONT = 189; public static final int DRAW_TO_BITMAP = 190; public static final int WAKE_IN = 191; ///////////////////////////////////////// ====================== Loading Loading @@ -359,10 +361,12 @@ public class Operations { public static final int PROFILE_EXPERIMENTAL = 0x1; public static final int PROFILE_DEPRECATED = 0x2; public static final int PROFILE_OEM = 0x4; public static final int PROFILE_LOW_POWER = 0x8; // Intersected profiles public static final int PROFILE_WIDGETS = 0x100; public static final int PROFILE_ANDROIDX = 0x200; public static final int PROFILE_ANDROID_NATIVE = 0x400; /** * Returns true if the operation exists for the given api level Loading Loading @@ -435,6 +439,7 @@ public class Operations { sMapV7AndroidX.put(DATA_SHADER, ShaderData::read); sMapV7AndroidX.put(DATA_FONT, FontData::read); sMapV7AndroidX.put(DRAW_TO_BITMAP, DrawToBitmap::read); sMapV7AndroidX.put(WAKE_IN, WakeIn::read); } return sMapV7AndroidX; } Loading Loading @@ -523,6 +528,11 @@ public class Operations { if ((profiles & Operations.PROFILE_DEPRECATED) != 0) { widgets.putAll(createMapV7_Widgets_Deprecated()); } listProfiles.add(widgets); } if ((profiles & PROFILE_ANDROID_NATIVE) != 0) { throw new UnsupportedOperationException( "Android native profiles are defined externally"); } if (listProfiles.size() == 1) { Loading Loading @@ -577,7 +587,7 @@ public class Operations { return result; } static class UniqueIntMap<T> extends IntMap<T> { public static class UniqueIntMap<T> extends IntMap<T> { @Override public T put(int key, @NonNull T value) { assert null == get(key) : "Opcode " + key + " already used in Operations !"; Loading core/java/com/android/internal/widget/remotecompose/core/PaintContext.java +15 −6 Original line number Diff line number Diff line Loading @@ -216,9 +216,9 @@ public abstract class PaintContext { /** * Replace the current paint with the PaintBundle * * @param paint * @param paintBundle */ public abstract void replacePaint(@NonNull PaintBundle paint); public abstract void replacePaint(@NonNull PaintBundle paintBundle); /** * draw a round rect Loading Loading @@ -331,10 +331,10 @@ public abstract class PaintContext { * @param path2Id * @param tween 0.0 = is path1 1.0 is path2 * @param start * @param stop * @param end */ public abstract void drawTweenPath( int path1Id, int path2Id, float tween, float start, float stop); int path1Id, int path2Id, float tween, float start, float end); /** * Interpolate between two path and return the resulting path Loading Loading @@ -477,6 +477,15 @@ public abstract class PaintContext { mNeedsRepaint = true; } /** * Repaint in the given time * * @param seconds the delay in seconds to the next render loop pass */ public void wakeIn(float seconds) { mContext.mRemoteComposeState.wakeIn(seconds); } /** * Starts a graphics layer * Loading @@ -502,10 +511,10 @@ public abstract class PaintContext { /** * Returns a String from an id * * @param textId * @param id * @return the string if found */ public abstract @Nullable String getText(int textId); public abstract @Nullable String getText(int id); /** * Returns true if the document has been encoded for at least the given version MAJOR.MINOR Loading core/java/com/android/internal/widget/remotecompose/core/RemoteComposeBuffer.java +40 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.core.operations.TimeAttribute; import com.android.internal.widget.remotecompose.core.operations.TouchExpression; import com.android.internal.widget.remotecompose.core.operations.Utils; import com.android.internal.widget.remotecompose.core.operations.WakeIn; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations; import com.android.internal.widget.remotecompose.core.operations.layout.ComponentStart; Loading Loading @@ -142,6 +143,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Set; /** Provides an abstract buffer to encode/decode RemoteCompose operations */ public class RemoteComposeBuffer { Loading Loading @@ -209,6 +211,7 @@ public class RemoteComposeBuffer { * * @param width the width of the document in pixels * @param height the height of the document in pixels * @param density the density of the document in pixels per device pixel * @param capabilities bitmask indicating needed capabilities (unused for now) */ public void header(int width, int height, float density, long capabilities) { Loading Loading @@ -240,6 +243,7 @@ public class RemoteComposeBuffer { * @param dstTop top coordinate of the destination area * @param dstRight right coordinate of the destination area * @param dstBottom bottom coordinate of the destination area * @param contentDescriptionId the content description of the image */ public void drawBitmap( int imageId, Loading Loading @@ -271,6 +275,7 @@ public class RemoteComposeBuffer { /** * look up map and return the id of the object looked up * * @param id the id of the data * @param mapId the map to access * @param strId the string to lookup */ Loading Loading @@ -673,6 +678,7 @@ public class RemoteComposeBuffer { /** * Create a TextFromFloat command which creates text from a Float. * * @param id The id of the text to create * @param value The value to convert * @param digitsBefore the digits before the decimal point * @param digitsAfter the digits after the decimal point Loading Loading @@ -1087,6 +1093,7 @@ public class RemoteComposeBuffer { /** * Add a float that is a computation based on variables * * @param id the id of the float * @param value A RPN style float operation i.e. "4, 3, ADD" outputs 7 */ public void addAnimatedFloat(int id, @NonNull float ... value) { Loading @@ -1096,6 +1103,7 @@ public class RemoteComposeBuffer { /** * Add a float that is a computation based on variables. see packAnimation * * @param id the id of the float * @param value A RPN style float operation i.e. "4, 3, ADD" outputs 7 * @param animation Array of floats that represents animation */ Loading @@ -1111,6 +1119,7 @@ public class RemoteComposeBuffer { * @param min the minimum value * @param max the maximum value * @param velocityId the id for the velocity TODO support in v2 * @param touchEffects the touch effects * @param exp The Float Expression * @param touchMode the touch up handling behaviour * @param touchSpec the touch up handling parameters Loading Loading @@ -1144,6 +1153,7 @@ public class RemoteComposeBuffer { /** * measure the text and return a measure as a float * * @param id id of the measure * @param textId id of the text * @param mode the mode 0 is the width */ Loading @@ -1154,6 +1164,7 @@ public class RemoteComposeBuffer { /** * measure the text and return the length of the text as float * * @param id id of the length op * @param textId id of the text */ public void textLength(int id, int textId) { Loading Loading @@ -1185,6 +1196,7 @@ public class RemoteComposeBuffer { * * @param id int map id * @param keys * @param types * @param listId */ public void addMap( Loading @@ -1198,6 +1210,7 @@ public class RemoteComposeBuffer { * <p>TODO: do we want both a float and an int index version of this method? bbade@ TODO * for @hoford - add a unit test for this method * * @param id id of the text * @param dataSet * @param index index as a float variable */ Loading @@ -1210,6 +1223,7 @@ public class RemoteComposeBuffer { * * <p>TODO for hoford - add a unit test for this method * * @param id id of the text * @param dataSet * @param index index as an int variable */ Loading @@ -1220,6 +1234,7 @@ public class RemoteComposeBuffer { /** * Add and integer expression * * @param id the id of the expression * @param mask defines which elements are operators or variables * @param value array of values to calculate maximum 32 */ Loading Loading @@ -1412,6 +1427,7 @@ public class RemoteComposeBuffer { * Add a scroll modifier * * @param direction HORIZONTAL(0) or VERTICAL(1) * @param max max scroll amount */ public void addModifierScroll(int direction, float max) { ScrollModifierOperation.apply(mBuffer, direction, 0f, max, 0f); Loading Loading @@ -1604,6 +1620,8 @@ public class RemoteComposeBuffer { * @param componentId component id * @param animationId animation id * @param bitmapId bitmap id * @param scaleType scale type * @param alpha alpha value */ public void addImage( int componentId, int animationId, int bitmapId, int scaleType, float alpha) { Loading Loading @@ -1745,6 +1763,7 @@ public class RemoteComposeBuffer { * @param fontStyle font style (0 : Normal, 1 : Italic) * @param fontWeight font weight (1 to 1000, normal is 400) * @param fontFamilyId font family or null * @param textAlign text alignment (0 : Center, 1 : Left, 2 : Right) * @param overflow * @param maxLines */ Loading Loading @@ -2064,6 +2083,18 @@ public class RemoteComposeBuffer { mBuffer.setVersion(documentApiLevel, profiles); } /** * Set current version of the buffer (typically for writing) * * @param documentApiLevel * @param supportedOperations */ public void setVersion(int documentApiLevel, @NonNull Set<Integer> supportedOperations) { mApiLevel = documentApiLevel; mBuffer.setValidOperations(supportedOperations); } /** * Add a matrix constant * Loading Loading @@ -2108,4 +2139,13 @@ public class RemoteComposeBuffer { public void addFont(int id, int type, @NonNull byte [] data) { FontData.apply(mBuffer, id, type, data); } /** * Add a wake in command * * @param seconds time to start the render loop */ public void wakeIn(float seconds) { WakeIn.apply(mBuffer, seconds); } } core/java/com/android/internal/widget/remotecompose/core/RemoteComposeState.java +29 −4 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ public class RemoteComposeState implements CollectionsAccess { // private static final int MAX_FLOATS = 500; private static int sMaxColors = 200; /** Offset added to bitmap to cache bitmap textures */ public static final int BITMAP_TEXTURE_ID_OFFSET = 2000; private static final int MAX_DATA = 1000; private final IntMap<Object> mIntDataMap = new IntMap<>(); private final IntMap<Boolean> mIntWrittenMap = new IntMap<>(); Loading Loading @@ -474,27 +477,49 @@ public class RemoteComposeState implements CollectionsAccess { return mVarListeners.get(id) != null; } float mLastRepaint = Float.NaN; /** * List of Commands that need to be updated * * @param context The context * @param currentTime The current time * @return The number of ops to update */ public int getOpsToUpdate(@NonNull RemoteContext context, long currentTime) { if (mVarListeners.get(RemoteContext.ID_CONTINUOUS_SEC) != null) { return 1; } int repaintMs = Integer.MAX_VALUE; if (!Float.isNaN(mRepaintSeconds)) { repaintMs = (int) (mRepaintSeconds * 1000); mLastRepaint = mRepaintSeconds; } if (mVarListeners.get(RemoteContext.ID_TIME_IN_SEC) != null) { int sub = (int) (currentTime % 1000); return 2 + 1000 - sub; return Math.min(repaintMs, 2 + 1000 - sub); } if (mVarListeners.get(RemoteContext.ID_TIME_IN_MIN) != null) { int sub = (int) (currentTime % 60000); return 2 + 1000 * 60 - sub; return Math.min(repaintMs, 2 + 1000 * 60 - sub); } return -1; } float mRepaintSeconds = Float.NaN; /** * Set the amount of time to repaint the document * * @param seconds the delay in seconds to the next render loop pass */ public void wakeIn(float seconds) { if (Float.isNaN(seconds) || Float.isNaN(mLastRepaint) || mRepaintSeconds > seconds) { mRepaintSeconds = seconds; } } /** * Set the width of the overall document on screen. * Loading Loading @@ -542,8 +567,8 @@ public class RemoteComposeState implements CollectionsAccess { } @Override public int getId(int id, int index) { ArrayAccess array = mCollectionMap.get(id & 0xFFFFF); public int getId(int listId, int index) { ArrayAccess array = mCollectionMap.get(listId & 0xFFFFF); if (array != null) { return array.getId(index); } Loading Loading
core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +29 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,8 @@ public class CoreDocument implements Serializable { boolean mFirstPaint = true; private boolean mIsUpdateDoc = false; private int mHostExceptionID = 0; private int mBitmapMemory = 0; private int mBitmapCount = 0; public CoreDocument() { this(new SystemClock()); Loading Loading @@ -570,6 +572,15 @@ public class CoreDocument implements Serializable { return mHostExceptionID; } /** * Get the bitmap memory used by the document * * @return the bitmap memory used by the document */ public int bitmapMemory() { return mBitmapMemory; } private interface Visitor { void visit(Operation op); } Loading Loading @@ -825,7 +836,10 @@ public class CoreDocument implements Serializable { mFloatExpressions.put(expression.mId, expression); } } mBitmapMemory = 0; mBitmapCount = 0; mOperations = inflateComponents(mOperations); mBuffer = buffer; for (Operation op : mOperations) { if (op instanceof RootLayoutComponent) { Loading Loading @@ -854,6 +868,11 @@ public class CoreDocument implements Serializable { mLastId = -1; for (Operation o : operations) { if (o instanceof BitmapData) { BitmapData bitmap = (BitmapData) o; mBitmapMemory += bitmap.getHeight() * bitmap.getWidth() * 4; mBitmapCount++; } if (o instanceof Container) { Container container = (Container) o; if (container instanceof Component) { Loading Loading @@ -1116,7 +1135,9 @@ public class CoreDocument implements Serializable { /** * Programmatically trigger the click response for the given id * * @param context the context * @param id the click area id * @param metadata the metadata of the click event */ public void performClick(@NonNull RemoteContext context, int id, @NonNull String metadata) { for (ClickAreaRepresentation clickArea : mClickAreas) { Loading Loading @@ -1166,6 +1187,7 @@ public class CoreDocument implements Serializable { /** * Support touch drag events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch */ Loading @@ -1189,6 +1211,7 @@ public class CoreDocument implements Serializable { /** * Support touch down events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch */ Loading @@ -1207,8 +1230,11 @@ public class CoreDocument implements Serializable { /** * Support touch up events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch * @param dx the x component of the drag vector * @param dy the y component of the drag vector */ public void touchUp(@NonNull RemoteContext context, float x, float y, float dx, float dy) { context.loadFloat(RemoteContext.ID_TOUCH_POS_X, x); Loading @@ -1228,8 +1254,11 @@ public class CoreDocument implements Serializable { /** * Support touch cancel events on commands supporting touch * * @param context the context * @param x position of touch * @param y position of touch * @param dx the x component of the drag vector * @param dy the y component of the drag vector */ public void touchCancel(@NonNull RemoteContext context, float x, float y, float dx, float dy) { if (mRootLayoutComponent != null) { Loading
core/java/com/android/internal/widget/remotecompose/core/Operations.java +11 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.internal.widget.remotecompose.core.operations.TextSubtext; import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.core.operations.TimeAttribute; import com.android.internal.widget.remotecompose.core.operations.TouchExpression; import com.android.internal.widget.remotecompose.core.operations.WakeIn; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations; import com.android.internal.widget.remotecompose.core.operations.layout.ClickModifierOperation; Loading Loading @@ -268,6 +269,7 @@ public class Operations { public static final int MATRIX_VECTOR_MATH = 188; public static final int DATA_FONT = 189; public static final int DRAW_TO_BITMAP = 190; public static final int WAKE_IN = 191; ///////////////////////////////////////// ====================== Loading Loading @@ -359,10 +361,12 @@ public class Operations { public static final int PROFILE_EXPERIMENTAL = 0x1; public static final int PROFILE_DEPRECATED = 0x2; public static final int PROFILE_OEM = 0x4; public static final int PROFILE_LOW_POWER = 0x8; // Intersected profiles public static final int PROFILE_WIDGETS = 0x100; public static final int PROFILE_ANDROIDX = 0x200; public static final int PROFILE_ANDROID_NATIVE = 0x400; /** * Returns true if the operation exists for the given api level Loading Loading @@ -435,6 +439,7 @@ public class Operations { sMapV7AndroidX.put(DATA_SHADER, ShaderData::read); sMapV7AndroidX.put(DATA_FONT, FontData::read); sMapV7AndroidX.put(DRAW_TO_BITMAP, DrawToBitmap::read); sMapV7AndroidX.put(WAKE_IN, WakeIn::read); } return sMapV7AndroidX; } Loading Loading @@ -523,6 +528,11 @@ public class Operations { if ((profiles & Operations.PROFILE_DEPRECATED) != 0) { widgets.putAll(createMapV7_Widgets_Deprecated()); } listProfiles.add(widgets); } if ((profiles & PROFILE_ANDROID_NATIVE) != 0) { throw new UnsupportedOperationException( "Android native profiles are defined externally"); } if (listProfiles.size() == 1) { Loading Loading @@ -577,7 +587,7 @@ public class Operations { return result; } static class UniqueIntMap<T> extends IntMap<T> { public static class UniqueIntMap<T> extends IntMap<T> { @Override public T put(int key, @NonNull T value) { assert null == get(key) : "Opcode " + key + " already used in Operations !"; Loading
core/java/com/android/internal/widget/remotecompose/core/PaintContext.java +15 −6 Original line number Diff line number Diff line Loading @@ -216,9 +216,9 @@ public abstract class PaintContext { /** * Replace the current paint with the PaintBundle * * @param paint * @param paintBundle */ public abstract void replacePaint(@NonNull PaintBundle paint); public abstract void replacePaint(@NonNull PaintBundle paintBundle); /** * draw a round rect Loading Loading @@ -331,10 +331,10 @@ public abstract class PaintContext { * @param path2Id * @param tween 0.0 = is path1 1.0 is path2 * @param start * @param stop * @param end */ public abstract void drawTweenPath( int path1Id, int path2Id, float tween, float start, float stop); int path1Id, int path2Id, float tween, float start, float end); /** * Interpolate between two path and return the resulting path Loading Loading @@ -477,6 +477,15 @@ public abstract class PaintContext { mNeedsRepaint = true; } /** * Repaint in the given time * * @param seconds the delay in seconds to the next render loop pass */ public void wakeIn(float seconds) { mContext.mRemoteComposeState.wakeIn(seconds); } /** * Starts a graphics layer * Loading @@ -502,10 +511,10 @@ public abstract class PaintContext { /** * Returns a String from an id * * @param textId * @param id * @return the string if found */ public abstract @Nullable String getText(int textId); public abstract @Nullable String getText(int id); /** * Returns true if the document has been encoded for at least the given version MAJOR.MINOR Loading
core/java/com/android/internal/widget/remotecompose/core/RemoteComposeBuffer.java +40 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.internal.widget.remotecompose.core.operations.Theme; import com.android.internal.widget.remotecompose.core.operations.TimeAttribute; import com.android.internal.widget.remotecompose.core.operations.TouchExpression; import com.android.internal.widget.remotecompose.core.operations.Utils; import com.android.internal.widget.remotecompose.core.operations.WakeIn; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent; import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations; import com.android.internal.widget.remotecompose.core.operations.layout.ComponentStart; Loading Loading @@ -142,6 +143,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Set; /** Provides an abstract buffer to encode/decode RemoteCompose operations */ public class RemoteComposeBuffer { Loading Loading @@ -209,6 +211,7 @@ public class RemoteComposeBuffer { * * @param width the width of the document in pixels * @param height the height of the document in pixels * @param density the density of the document in pixels per device pixel * @param capabilities bitmask indicating needed capabilities (unused for now) */ public void header(int width, int height, float density, long capabilities) { Loading Loading @@ -240,6 +243,7 @@ public class RemoteComposeBuffer { * @param dstTop top coordinate of the destination area * @param dstRight right coordinate of the destination area * @param dstBottom bottom coordinate of the destination area * @param contentDescriptionId the content description of the image */ public void drawBitmap( int imageId, Loading Loading @@ -271,6 +275,7 @@ public class RemoteComposeBuffer { /** * look up map and return the id of the object looked up * * @param id the id of the data * @param mapId the map to access * @param strId the string to lookup */ Loading Loading @@ -673,6 +678,7 @@ public class RemoteComposeBuffer { /** * Create a TextFromFloat command which creates text from a Float. * * @param id The id of the text to create * @param value The value to convert * @param digitsBefore the digits before the decimal point * @param digitsAfter the digits after the decimal point Loading Loading @@ -1087,6 +1093,7 @@ public class RemoteComposeBuffer { /** * Add a float that is a computation based on variables * * @param id the id of the float * @param value A RPN style float operation i.e. "4, 3, ADD" outputs 7 */ public void addAnimatedFloat(int id, @NonNull float ... value) { Loading @@ -1096,6 +1103,7 @@ public class RemoteComposeBuffer { /** * Add a float that is a computation based on variables. see packAnimation * * @param id the id of the float * @param value A RPN style float operation i.e. "4, 3, ADD" outputs 7 * @param animation Array of floats that represents animation */ Loading @@ -1111,6 +1119,7 @@ public class RemoteComposeBuffer { * @param min the minimum value * @param max the maximum value * @param velocityId the id for the velocity TODO support in v2 * @param touchEffects the touch effects * @param exp The Float Expression * @param touchMode the touch up handling behaviour * @param touchSpec the touch up handling parameters Loading Loading @@ -1144,6 +1153,7 @@ public class RemoteComposeBuffer { /** * measure the text and return a measure as a float * * @param id id of the measure * @param textId id of the text * @param mode the mode 0 is the width */ Loading @@ -1154,6 +1164,7 @@ public class RemoteComposeBuffer { /** * measure the text and return the length of the text as float * * @param id id of the length op * @param textId id of the text */ public void textLength(int id, int textId) { Loading Loading @@ -1185,6 +1196,7 @@ public class RemoteComposeBuffer { * * @param id int map id * @param keys * @param types * @param listId */ public void addMap( Loading @@ -1198,6 +1210,7 @@ public class RemoteComposeBuffer { * <p>TODO: do we want both a float and an int index version of this method? bbade@ TODO * for @hoford - add a unit test for this method * * @param id id of the text * @param dataSet * @param index index as a float variable */ Loading @@ -1210,6 +1223,7 @@ public class RemoteComposeBuffer { * * <p>TODO for hoford - add a unit test for this method * * @param id id of the text * @param dataSet * @param index index as an int variable */ Loading @@ -1220,6 +1234,7 @@ public class RemoteComposeBuffer { /** * Add and integer expression * * @param id the id of the expression * @param mask defines which elements are operators or variables * @param value array of values to calculate maximum 32 */ Loading Loading @@ -1412,6 +1427,7 @@ public class RemoteComposeBuffer { * Add a scroll modifier * * @param direction HORIZONTAL(0) or VERTICAL(1) * @param max max scroll amount */ public void addModifierScroll(int direction, float max) { ScrollModifierOperation.apply(mBuffer, direction, 0f, max, 0f); Loading Loading @@ -1604,6 +1620,8 @@ public class RemoteComposeBuffer { * @param componentId component id * @param animationId animation id * @param bitmapId bitmap id * @param scaleType scale type * @param alpha alpha value */ public void addImage( int componentId, int animationId, int bitmapId, int scaleType, float alpha) { Loading Loading @@ -1745,6 +1763,7 @@ public class RemoteComposeBuffer { * @param fontStyle font style (0 : Normal, 1 : Italic) * @param fontWeight font weight (1 to 1000, normal is 400) * @param fontFamilyId font family or null * @param textAlign text alignment (0 : Center, 1 : Left, 2 : Right) * @param overflow * @param maxLines */ Loading Loading @@ -2064,6 +2083,18 @@ public class RemoteComposeBuffer { mBuffer.setVersion(documentApiLevel, profiles); } /** * Set current version of the buffer (typically for writing) * * @param documentApiLevel * @param supportedOperations */ public void setVersion(int documentApiLevel, @NonNull Set<Integer> supportedOperations) { mApiLevel = documentApiLevel; mBuffer.setValidOperations(supportedOperations); } /** * Add a matrix constant * Loading Loading @@ -2108,4 +2139,13 @@ public class RemoteComposeBuffer { public void addFont(int id, int type, @NonNull byte [] data) { FontData.apply(mBuffer, id, type, data); } /** * Add a wake in command * * @param seconds time to start the render loop */ public void wakeIn(float seconds) { WakeIn.apply(mBuffer, seconds); } }
core/java/com/android/internal/widget/remotecompose/core/RemoteComposeState.java +29 −4 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ public class RemoteComposeState implements CollectionsAccess { // private static final int MAX_FLOATS = 500; private static int sMaxColors = 200; /** Offset added to bitmap to cache bitmap textures */ public static final int BITMAP_TEXTURE_ID_OFFSET = 2000; private static final int MAX_DATA = 1000; private final IntMap<Object> mIntDataMap = new IntMap<>(); private final IntMap<Boolean> mIntWrittenMap = new IntMap<>(); Loading Loading @@ -474,27 +477,49 @@ public class RemoteComposeState implements CollectionsAccess { return mVarListeners.get(id) != null; } float mLastRepaint = Float.NaN; /** * List of Commands that need to be updated * * @param context The context * @param currentTime The current time * @return The number of ops to update */ public int getOpsToUpdate(@NonNull RemoteContext context, long currentTime) { if (mVarListeners.get(RemoteContext.ID_CONTINUOUS_SEC) != null) { return 1; } int repaintMs = Integer.MAX_VALUE; if (!Float.isNaN(mRepaintSeconds)) { repaintMs = (int) (mRepaintSeconds * 1000); mLastRepaint = mRepaintSeconds; } if (mVarListeners.get(RemoteContext.ID_TIME_IN_SEC) != null) { int sub = (int) (currentTime % 1000); return 2 + 1000 - sub; return Math.min(repaintMs, 2 + 1000 - sub); } if (mVarListeners.get(RemoteContext.ID_TIME_IN_MIN) != null) { int sub = (int) (currentTime % 60000); return 2 + 1000 * 60 - sub; return Math.min(repaintMs, 2 + 1000 * 60 - sub); } return -1; } float mRepaintSeconds = Float.NaN; /** * Set the amount of time to repaint the document * * @param seconds the delay in seconds to the next render loop pass */ public void wakeIn(float seconds) { if (Float.isNaN(seconds) || Float.isNaN(mLastRepaint) || mRepaintSeconds > seconds) { mRepaintSeconds = seconds; } } /** * Set the width of the overall document on screen. * Loading Loading @@ -542,8 +567,8 @@ public class RemoteComposeState implements CollectionsAccess { } @Override public int getId(int id, int index) { ArrayAccess array = mCollectionMap.get(id & 0xFFFFF); public int getId(int listId, int index) { ArrayAccess array = mCollectionMap.get(listId & 0xFFFFF); if (array != null) { return array.getId(index); } Loading