Back to Androidx

RemoteCompose Protocol Specification

compose/remote/remote-core/doc/PROTOCOL_SPEC.md

latest2.7 KB
Original Source

RemoteCompose Protocol Specification

This document defines some of the binary protocol format for RemoteCompose. Each operation consists of an OpCode followed by its specific data fields. This is not authoritative but is provided to give a feel for the protocol.

OpCode Reference

OpCodeNamePurposeFields
0HEADERDocument metadataVersion, Width, Height, Density, Profiles
38CLIP_PATHSet clip pathPath ID
39CLIP_RECTSet clip rectangleL, T, R, B
40PAINT_VALUESUpdate paint stateSerialized PaintBundle
42DRAW_RECTDraw rectangleL, T, R, B
43DRAW_TEXT_RUNDraw text runText ID, start, end, x, y, RTL
44DRAW_BITMAPDraw imageBitmap ID, L, T, R, B
46DRAW_CIRCLEDraw circlecx, cy, radius
47DRAW_LINEDraw linex1, y1, x2, y2
51DRAW_ROUND_RECTDraw rounded rectL, T, R, B, rx, ry
52DRAW_SECTORDraw pie sliceL, T, R, B, start, sweep
53DRAW_TEXT_ON_PATHText along pathText ID, Path ID, hOffset, vOffset
63THEMESet active themeTheme ID (Light/Dark/Any)
80DATA_FLOATDefine constantFloat ID, value
81ANIMATED_FLOATDynamic expressionFloat ID, RPN operations
101DATA_BITMAPSerialized imageBitmap ID, width, height, pixels
102DATA_TEXTSerialized stringText ID, string content
123DATA_PATHSerialized pathPath ID, points/commands
124DRAW_PATHDraw vector pathPath ID
126-129MATRIX_*TransformationsScale, Translate, Skew, Rotate
130-131MATRIX_SAVE/RESTOREPushes/Pops matrix-
133DRAW_TEXT_ANCHORAligned textText ID, x, y, panX, panY, flags
135TEXT_FROM_FLOATFloat to StringText ID, value ID, formatting
139DRAW_CONTENTComponent contentUsed in Canvas/Draw Content
144INTEGER_EXPRESSIONMath on IntsInt ID, mask, operations
157TOUCH_EXPRESSIONInput mappingDef, min, max, mode, easing, RPN
161PARTICLE_DEFINEParticle systemID, var IDs, count, init equations
163PARTICLE_LOOPParticle updateID, restart eq, update equations
178CONDITIONAL_OPSIf blockCondition type, a, b, children...
193PATH_EXPRESSIONAlgorithmic pathPath ID, range, X eq, Y eq
201COMPONENT_STARTUI NodeComponent ID, layout type, flags
230CONTAINER_ENDCloses block-

Data Types

  • Int: 32-bit signed (Little Endian).
  • Float: 32-bit IEEE 754.
  • Short: 16-bit signed.
  • Byte: 8-bit unsigned.
  • String: UTF-8 encoded, prefixed by length (Int).
  • Float ID: Encoded as a NaN where the significand contains the 24-bit ID.