Loading core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +2 −2 Original line number Diff line number Diff line Loading @@ -65,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.2f; static final float BUILD = 0.3f; @NonNull ArrayList<Operation> mOperations = new ArrayList<>(); Loading Loading @@ -411,7 +411,7 @@ public class CoreDocument implements Serializable { @Override public void serialize(MapSerializer serializer) { serializer .add("type", "CoreDocument") .addType("CoreDocument") .add("width", mWidth) .add("height", mHeight) .add("operations", mOperations); Loading core/java/com/android/internal/widget/remotecompose/core/Operations.java +3 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleRowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.ColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.FitBoxLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.RowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.StateLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.TextLayout; Loading Loading @@ -231,6 +232,7 @@ public class Operations { public static final int LAYOUT_ROOT = 200; public static final int LAYOUT_CONTENT = 201; public static final int LAYOUT_BOX = 202; public static final int LAYOUT_FIT_BOX = 176; public static final int LAYOUT_ROW = 203; public static final int LAYOUT_COLLAPSIBLE_ROW = 230; public static final int LAYOUT_COLUMN = 204; Loading Loading @@ -391,6 +393,7 @@ public class Operations { map.put(LAYOUT_ROOT, RootLayoutComponent::read); map.put(LAYOUT_CONTENT, LayoutComponentContent::read); map.put(LAYOUT_BOX, BoxLayout::read); map.put(LAYOUT_FIT_BOX, FitBoxLayout::read); map.put(LAYOUT_COLUMN, ColumnLayout::read); map.put(LAYOUT_COLLAPSIBLE_COLUMN, CollapsibleColumnLayout::read); map.put(LAYOUT_ROW, RowLayout::read); Loading core/java/com/android/internal/widget/remotecompose/core/PaintOperation.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import com.android.internal.widget.remotecompose.core.serialize.Serializable; /** * PaintOperation interface, used for operations aimed at painting (while any operation _can_ paint, * this make it a little more explicit) */ public abstract class PaintOperation extends Operation { public abstract class PaintOperation extends Operation implements Serializable { @Override public void apply(@NonNull RemoteContext context) { Loading core/java/com/android/internal/widget/remotecompose/core/Platform.java +13 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,14 @@ public interface Platform { */ int getImageHeight(@NonNull Object image); /** * Returns true if the platform-specific image object has format ALPHA_8 * * @param image platform-specific image object * @return whether or not the platform-specific image object has format ALPHA_8 */ boolean isAlpha8Image(@NonNull Object image); /** * Converts a platform-specific path object into a platform-independent float buffer * Loading Loading @@ -109,6 +117,11 @@ public interface Platform { throw new UnsupportedOperationException(); } @Override public boolean isAlpha8Image(@NonNull Object image) { throw new UnsupportedOperationException(); } @Override public float[] pathToFloatArray(@NonNull Object path) { throw new UnsupportedOperationException(); Loading core/java/com/android/internal/widget/remotecompose/core/RemoteComposeBuffer.java +56 −73 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleRowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.ColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.FitBoxLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.RowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.StateLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.TextLayout; Loading Loading @@ -281,13 +282,7 @@ public class RemoteComposeBuffer { int dstRight, int dstBottom, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } int imageId = storeBitmap(image); int contentDescriptionId = 0; if (contentDescription != null) { contentDescriptionId = addText(contentDescription); Loading Loading @@ -443,16 +438,7 @@ public class RemoteComposeBuffer { float right, float bottom, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } int imageId = storeBitmap(image); addDrawBitmap(imageId, left, top, right, bottom, contentDescription); } Loading Loading @@ -523,15 +509,7 @@ public class RemoteComposeBuffer { int scaleType, float scaleFactor, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential pe } int imageId = storeBitmap(image); int contentDescriptionId = 0; if (contentDescription != null) { contentDescriptionId = addText(contentDescription); Loading Loading @@ -559,16 +537,7 @@ public class RemoteComposeBuffer { * @return id of the image useful with */ public int addBitmap(@NonNull Object image) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // tODO: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); } return imageId; return storeBitmap(image); } /** Loading @@ -578,18 +547,7 @@ public class RemoteComposeBuffer { * @return id of the image useful with */ public int addBitmap(@NonNull Object image, @NonNull String name) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); setBitmapName(imageId, name); } return imageId; return storeBitmap(image); } /** Loading Loading @@ -1393,7 +1351,7 @@ public class RemoteComposeBuffer { * @return the id of the command representing long */ public int addLong(long value) { int id = mRemoteComposeState.cacheData(value); int id = mRemoteComposeState.nextId(); LongConstant.apply(mBuffer, id, value); return id; } Loading @@ -1405,7 +1363,7 @@ public class RemoteComposeBuffer { * @return the id */ public int addBoolean(boolean value) { int id = mRemoteComposeState.cacheData(value); int id = mRemoteComposeState.nextId(); BooleanConstant.apply(mBuffer, id, value); return id; } Loading Loading @@ -1821,33 +1779,14 @@ public class RemoteComposeBuffer { } /** * This defines the name of the color given the id. * * @param id of the color * @param name Name of the color */ public void setColorName(int id, @NonNull String name) { NamedVariable.apply(mBuffer, id, NamedVariable.COLOR_TYPE, name); } /** * This defines the name of the string given the id * * @param id of the string * @param name name of the string */ public void setStringName(int id, @NonNull String name) { NamedVariable.apply(mBuffer, id, NamedVariable.STRING_TYPE, name); } /** * This defines the name of the float given the id * This defines the name of a type of given object * * @param id of the float * @param name name of the float * @param type the type of variable NamedVariable.COLOR_TYPE, STRING_TYPE, etc */ public void setFloatName(int id, String name) { NamedVariable.apply(mBuffer, id, NamedVariable.FLOAT_TYPE, name); public void setNamedVariable(int id, @NonNull String name, int type) { NamedVariable.apply(mBuffer, id, type, name); } /** Loading Loading @@ -2138,6 +2077,19 @@ public class RemoteComposeBuffer { BoxLayout.apply(mBuffer, mLastComponentId, animationId, horizontal, vertical); } /** * Add a fitbox start tag * * @param componentId component id * @param animationId animation id * @param horizontal horizontal alignment * @param vertical vertical alignment */ public void addFitBoxStart(int componentId, int animationId, int horizontal, int vertical) { mLastComponentId = getComponentId(componentId); FitBoxLayout.apply(mBuffer, mLastComponentId, animationId, horizontal, vertical); } /** * Add a row start tag * Loading Loading @@ -2439,4 +2391,35 @@ public class RemoteComposeBuffer { public void drawComponentContent() { DrawContent.apply(mBuffer); } /** * Ensures the bitmap is stored. * * @param image the bitbap to store * @return the id of the bitmap */ private int storeBitmap(Object image) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe short imageWidth = (short) mPlatform.getImageWidth(image); short imageHeight = (short) mPlatform.getImageHeight(image); if (mPlatform.isAlpha8Image(image)) { BitmapData.apply( mBuffer, imageId, BitmapData.TYPE_PNG_ALPHA_8, imageWidth, BitmapData.ENCODING_INLINE, imageHeight, data); // todo: potential npe } else { BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } } return imageId; } } Loading
core/java/com/android/internal/widget/remotecompose/core/CoreDocument.java +2 −2 Original line number Diff line number Diff line Loading @@ -65,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.2f; static final float BUILD = 0.3f; @NonNull ArrayList<Operation> mOperations = new ArrayList<>(); Loading Loading @@ -411,7 +411,7 @@ public class CoreDocument implements Serializable { @Override public void serialize(MapSerializer serializer) { serializer .add("type", "CoreDocument") .addType("CoreDocument") .add("width", mWidth) .add("height", mHeight) .add("operations", mOperations); Loading
core/java/com/android/internal/widget/remotecompose/core/Operations.java +3 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleRowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.ColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.FitBoxLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.RowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.StateLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.TextLayout; Loading Loading @@ -231,6 +232,7 @@ public class Operations { public static final int LAYOUT_ROOT = 200; public static final int LAYOUT_CONTENT = 201; public static final int LAYOUT_BOX = 202; public static final int LAYOUT_FIT_BOX = 176; public static final int LAYOUT_ROW = 203; public static final int LAYOUT_COLLAPSIBLE_ROW = 230; public static final int LAYOUT_COLUMN = 204; Loading Loading @@ -391,6 +393,7 @@ public class Operations { map.put(LAYOUT_ROOT, RootLayoutComponent::read); map.put(LAYOUT_CONTENT, LayoutComponentContent::read); map.put(LAYOUT_BOX, BoxLayout::read); map.put(LAYOUT_FIT_BOX, FitBoxLayout::read); map.put(LAYOUT_COLUMN, ColumnLayout::read); map.put(LAYOUT_COLLAPSIBLE_COLUMN, CollapsibleColumnLayout::read); map.put(LAYOUT_ROW, RowLayout::read); Loading
core/java/com/android/internal/widget/remotecompose/core/PaintOperation.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package com.android.internal.widget.remotecompose.core; import android.annotation.NonNull; import com.android.internal.widget.remotecompose.core.serialize.Serializable; /** * PaintOperation interface, used for operations aimed at painting (while any operation _can_ paint, * this make it a little more explicit) */ public abstract class PaintOperation extends Operation { public abstract class PaintOperation extends Operation implements Serializable { @Override public void apply(@NonNull RemoteContext context) { Loading
core/java/com/android/internal/widget/remotecompose/core/Platform.java +13 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,14 @@ public interface Platform { */ int getImageHeight(@NonNull Object image); /** * Returns true if the platform-specific image object has format ALPHA_8 * * @param image platform-specific image object * @return whether or not the platform-specific image object has format ALPHA_8 */ boolean isAlpha8Image(@NonNull Object image); /** * Converts a platform-specific path object into a platform-independent float buffer * Loading Loading @@ -109,6 +117,11 @@ public interface Platform { throw new UnsupportedOperationException(); } @Override public boolean isAlpha8Image(@NonNull Object image) { throw new UnsupportedOperationException(); } @Override public float[] pathToFloatArray(@NonNull Object path) { throw new UnsupportedOperationException(); Loading
core/java/com/android/internal/widget/remotecompose/core/RemoteComposeBuffer.java +56 −73 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleRowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.ColumnLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.FitBoxLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.RowLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.StateLayout; import com.android.internal.widget.remotecompose.core.operations.layout.managers.TextLayout; Loading Loading @@ -281,13 +282,7 @@ public class RemoteComposeBuffer { int dstRight, int dstBottom, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } int imageId = storeBitmap(image); int contentDescriptionId = 0; if (contentDescription != null) { contentDescriptionId = addText(contentDescription); Loading Loading @@ -443,16 +438,7 @@ public class RemoteComposeBuffer { float right, float bottom, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } int imageId = storeBitmap(image); addDrawBitmap(imageId, left, top, right, bottom, contentDescription); } Loading Loading @@ -523,15 +509,7 @@ public class RemoteComposeBuffer { int scaleType, float scaleFactor, @Nullable String contentDescription) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential pe } int imageId = storeBitmap(image); int contentDescriptionId = 0; if (contentDescription != null) { contentDescriptionId = addText(contentDescription); Loading Loading @@ -559,16 +537,7 @@ public class RemoteComposeBuffer { * @return id of the image useful with */ public int addBitmap(@NonNull Object image) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // tODO: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); } return imageId; return storeBitmap(image); } /** Loading @@ -578,18 +547,7 @@ public class RemoteComposeBuffer { * @return id of the image useful with */ public int addBitmap(@NonNull Object image, @NonNull String name) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe int imageWidth = mPlatform.getImageWidth(image); int imageHeight = mPlatform.getImageHeight(image); BitmapData.apply(mBuffer, imageId, imageWidth, imageHeight, data); setBitmapName(imageId, name); } return imageId; return storeBitmap(image); } /** Loading Loading @@ -1393,7 +1351,7 @@ public class RemoteComposeBuffer { * @return the id of the command representing long */ public int addLong(long value) { int id = mRemoteComposeState.cacheData(value); int id = mRemoteComposeState.nextId(); LongConstant.apply(mBuffer, id, value); return id; } Loading @@ -1405,7 +1363,7 @@ public class RemoteComposeBuffer { * @return the id */ public int addBoolean(boolean value) { int id = mRemoteComposeState.cacheData(value); int id = mRemoteComposeState.nextId(); BooleanConstant.apply(mBuffer, id, value); return id; } Loading Loading @@ -1821,33 +1779,14 @@ public class RemoteComposeBuffer { } /** * This defines the name of the color given the id. * * @param id of the color * @param name Name of the color */ public void setColorName(int id, @NonNull String name) { NamedVariable.apply(mBuffer, id, NamedVariable.COLOR_TYPE, name); } /** * This defines the name of the string given the id * * @param id of the string * @param name name of the string */ public void setStringName(int id, @NonNull String name) { NamedVariable.apply(mBuffer, id, NamedVariable.STRING_TYPE, name); } /** * This defines the name of the float given the id * This defines the name of a type of given object * * @param id of the float * @param name name of the float * @param type the type of variable NamedVariable.COLOR_TYPE, STRING_TYPE, etc */ public void setFloatName(int id, String name) { NamedVariable.apply(mBuffer, id, NamedVariable.FLOAT_TYPE, name); public void setNamedVariable(int id, @NonNull String name, int type) { NamedVariable.apply(mBuffer, id, type, name); } /** Loading Loading @@ -2138,6 +2077,19 @@ public class RemoteComposeBuffer { BoxLayout.apply(mBuffer, mLastComponentId, animationId, horizontal, vertical); } /** * Add a fitbox start tag * * @param componentId component id * @param animationId animation id * @param horizontal horizontal alignment * @param vertical vertical alignment */ public void addFitBoxStart(int componentId, int animationId, int horizontal, int vertical) { mLastComponentId = getComponentId(componentId); FitBoxLayout.apply(mBuffer, mLastComponentId, animationId, horizontal, vertical); } /** * Add a row start tag * Loading Loading @@ -2439,4 +2391,35 @@ public class RemoteComposeBuffer { public void drawComponentContent() { DrawContent.apply(mBuffer); } /** * Ensures the bitmap is stored. * * @param image the bitbap to store * @return the id of the bitmap */ private int storeBitmap(Object image) { int imageId = mRemoteComposeState.dataGetId(image); if (imageId == -1) { imageId = mRemoteComposeState.cacheData(image); byte[] data = mPlatform.imageToByteArray(image); // todo: potential npe short imageWidth = (short) mPlatform.getImageWidth(image); short imageHeight = (short) mPlatform.getImageHeight(image); if (mPlatform.isAlpha8Image(image)) { BitmapData.apply( mBuffer, imageId, BitmapData.TYPE_PNG_ALPHA_8, imageWidth, BitmapData.ENCODING_INLINE, imageHeight, data); // todo: potential npe } else { BitmapData.apply( mBuffer, imageId, imageWidth, imageHeight, data); // todo: potential npe } } return imageId; } }