FakeXrExtensions.FakeNodeTransaction


public class FakeXrExtensions.FakeNodeTransaction implements Closeable


A fake implementation of the XR extensions Node transaction.

All modifications happen immediately and not when the transaction is applied.

Summary

Public methods

void

Submits the queued transactions to backend.

void

Closes and releases the native transaction object without applying it.

@NonNull NodeTransaction

Disables reform UX for a node.

@NonNull NodeTransaction

Enables reform UX for a node.

@NonNull NodeTransaction
setAlpha(@NonNull Node node, float value)

Sets the opacity of the node's content to a value between [0..1].

@NonNull NodeTransaction
setAnchorId(@NonNull Node node, @Nullable IBinder anchorId)

Sets the transform of the node on a per-frame basis from a previously created anchor.

@NonNull NodeTransaction
setCornerRadius(@NonNull Node node, float cornerRadius)

Sets the corner radius for 2D surfaces under this node.

@NonNull NodeTransaction

This method is deprecated.

This method is no longer supported.

@NonNull NodeTransaction
setGltfModel(@NonNull Node node, @NonNull GltfModelToken gltfModelToken)

This method is deprecated.

This method is no longer supported.

@NonNull NodeTransaction
setName(@NonNull Node node, @NonNull String name)

Sets a name for the node that is used to it in `adb dumpsys cpm` output log.

@NonNull NodeTransaction
setOrientation(@NonNull Node node, float x, float y, float z, float w)

Rotates the node by the quaternion specified by x, y, z, and w components in the local coordinate space.

@NonNull NodeTransaction
setParent(@NonNull Node node, @Nullable Node parent)

Sets the parent of this node to the given node.

@NonNull NodeTransaction
setPassthroughState(
    @NonNull Node node,
    float passthroughOpacity,
    int passthroughMode
)

Updates the passthrough state.

@NonNull NodeTransaction
setPosition(@NonNull Node node, float x, float y, float z)

Sets the position of the node in the local coordinate space (parent space).

@NonNull NodeTransaction
setReformSize(@NonNull Node node, @NonNull Vec3 reformSize)

Updates the size of the reform UX.

@NonNull NodeTransaction
setScale(@NonNull Node node, float sx, float sy, float sz)

Scales the node along the x, y, and z axis in the local coordinate space.

@NonNull NodeTransaction

Configures the node to host and control the given surface data.

@NonNull NodeTransaction
setVisibility(@NonNull Node node, boolean isVisible)

Changes the visibility of the node and its content.

@NonNull NodeTransaction
setWindowBounds(
    @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage,
    int widthPx,
    int heightPx
)

Crops the 2D buffer of the Surface hosted by this node to match the given bounds in pixels.

Inherited methods

From java.io.Closeable
abstract void

Public methods

apply

Added in 1.0.0-alpha01
public void apply()

Submits the queued transactions to backend.

This method will clear the existing transaction state so the same transaction object can be used for the next set of updates.

close

Added in 1.0.0-alpha01
public void close()

Closes and releases the native transaction object without applying it.

Note that a closed transaction cannot be used again.

disableReform

Added in 1.0.0-alpha01
public @NonNull NodeTransaction disableReform(@NonNull Node node)

Disables reform UX for a node.

Parameters
@NonNull Node node

The node to be updated.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

enableReform

Added in 1.0.0-alpha01
public @NonNull NodeTransaction enableReform(@NonNull Node node, @NonNull ReformOptions options)

Enables reform UX for a node.

Parameters
@NonNull Node node

The node to be updated.

@NonNull ReformOptions options

Configuration options for the reform UX.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setAlpha

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setAlpha(@NonNull Node node, float value)

Sets the opacity of the node's content to a value between [0..1].

Parameters
@NonNull Node node

The node to be updated.

float value

The new opacity amount in range of [0..1].

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setAnchorId

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setAnchorId(@NonNull Node node, @Nullable IBinder anchorId)

Sets the transform of the node on a per-frame basis from a previously created anchor.

The client who created the anchor and provided the ID will always remain the owner of the anchor.

Modifying the transform of the node will only be applied if or when the anchor is no longer linked to the node, or if the anchor is no longer locatable.

A node can be unlinked from an anchor by setting the ID to null. Note that this does not destroy the actual anchor.

Parameters
@NonNull Node node

The node to be updated.

@Nullable IBinder anchorId

The ID of a previously created anchor.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setCornerRadius

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setCornerRadius(@NonNull Node node, float cornerRadius)

Sets the corner radius for 2D surfaces under this node.

The corner radius is propagated to child nodes.

Parameters
@NonNull Node node

The node to be updated.

float cornerRadius

The corner radius for 2D surfaces under this node, in meters.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setEnvironment

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull NodeTransaction setEnvironment(@NonNull Node node, @Nullable EnvironmentToken token)

setGltfModel

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull NodeTransaction setGltfModel(@NonNull Node node, @NonNull GltfModelToken gltfModelToken)

setName

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setName(@NonNull Node node, @NonNull String name)

Sets a name for the node that is used to it in `adb dumpsys cpm` output log.

While the name does not have to be globally unique, it is recommended to set a unique name for each node for ease of debugging.

Parameters
@NonNull Node node

The node to be updated.

@NonNull String name

The debug name of the node.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setOrientation

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setOrientation(@NonNull Node node, float x, float y, float z, float w)

Rotates the node by the quaternion specified by x, y, z, and w components in the local coordinate space.

Parameters
@NonNull Node node

The node to be updated.

float x

The x component of the quaternion.

float y

The y component of the quaternion.

float z

The z component of the quaternion.

float w

The w component of the quaternion.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setParent

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setParent(@NonNull Node node, @Nullable Node parent)

Sets the parent of this node to the given node.

This method detaches the node from its current branch and moves into the new parent's hierarchy (if any). If parent parameter is `null`, the node will be orphaned and removed from the rendering tree until it is reattached to another node that is in the root hierarchy.

Parameters
@NonNull Node node

The node to be updated.

@Nullable Node parent

The new parent of the node or `null` if the node is to be removed from the rendering tree.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setPassthroughState

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setPassthroughState(
    @NonNull Node node,
    float passthroughOpacity,
    int passthroughMode
)

Updates the passthrough state.

Parameters
@NonNull Node node

The node to be updated.

float passthroughOpacity

The opacity of the passthrough layer where 0.0 means no passthrough and 1.0 means full passthrough.

int passthroughMode

The PassthroughState.Mode mode that the passthrough will use.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setPosition

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setPosition(@NonNull Node node, float x, float y, float z)

Sets the position of the node in the local coordinate space (parent space).

Parameters
@NonNull Node node

The node to be updated.

float x

The 'x' distance in meters from parent's origin.

float y

The 'y' distance in meters from parent's origin.

float z

The 'z' distance in meters from parent's origin.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setReformSize

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setReformSize(@NonNull Node node, @NonNull Vec3 reformSize)

Updates the size of the reform UX.

Parameters
@NonNull Node node

The node to be updated.

@NonNull Vec3 reformSize

The new size in meters that should be used to lay out the reform UX.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setScale

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setScale(@NonNull Node node, float sx, float sy, float sz)

Scales the node along the x, y, and z axis in the local coordinate space.

For 2D panels, this method scales the panel in the world, increasing its visual size without changing the buffer size. It will not trigger a relayout and will not affect its enclosing view's layout configuration.

Parameters
@NonNull Node node

The node to be updated.

float sx

The scaling factor along the x-axis.

float sy

The scaling factor along the y-axis.

float sz

The scaling factor along the z-axis.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setSurfacePackage

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setSurfacePackage(
    @Nullable Node node,
    @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage
)

Configures the node to host and control the given surface data.

This method is similar to setSurfaceControl and is provided for convenience.

Parameters
@Nullable Node node

The node to be updated.

@NonNull SurfaceControlViewHost.SurfacePackage surfacePackage

The package that contains the SurfaceControl, or 'null' to disassociate the currently hosted surface from the node.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setVisibility

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setVisibility(@NonNull Node node, boolean isVisible)

Changes the visibility of the node and its content.

Parameters
@NonNull Node node

The node to be updated.

boolean isVisible

Whether the node is visible.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.

setWindowBounds

Added in 1.0.0-alpha01
public @NonNull NodeTransaction setWindowBounds(
    @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage,
    int widthPx,
    int heightPx
)

Crops the 2D buffer of the Surface hosted by this node to match the given bounds in pixels.

This method is similar to setWindowBounds and is provided for convenience.

Parameters
@NonNull SurfaceControlViewHost.SurfacePackage surfacePackage

The package that contains the SurfaceControl.

int widthPx

The width of the surface in pixels.

int heightPx

The height of the surface in pixels.

Returns
@NonNull NodeTransaction

The reference to this NodeTransaction object that is currently being updated.