SurfaceEntity
public final class SurfaceEntity extends Entity
| java.lang.Object | |||
| ↳ | androidx.xr.scenecore.BaseScenePose | ||
| ↳ | androidx.xr.scenecore.Entity | ||
| ↳ | androidx.xr.scenecore.SurfaceEntity |
SurfaceEntity is an Entity that hosts a Surface, which will be texture mapped onto the Shape. If a stereoscopic StereoMode is specified, then the User will see left and right eye content mapped to the appropriate display.
Note that it is not currently possible to synchronize Shape and StereoMode changes with application rendering or video decoding. Applications are advised to carefully hide this entity around state transitions (for example in response to video events) to manage glitchiness.
Summary
Nested types |
|---|
public abstract class SurfaceEntity.EdgeFeatheringParamsRepresents edge fading effects for a SurfaceEntity. |
public final class SurfaceEntity.EdgeFeatheringParams.NoFeathering extends SurfaceEntity.EdgeFeatheringParamsApplies no edge fading to any canvas. |
public final class SurfaceEntity.EdgeFeatheringParams.RectangleFeather extends SurfaceEntity.EdgeFeatheringParams |
public interface SurfaceEntity.ShapeRepresents the shape of the Canvas that backs a SurfaceEntity. |
public final class SurfaceEntity.Shape.Hemisphere implements SurfaceEntity.ShapeAn inwards-facing hemisphere-shaped canvas, where (0,0,0) is the center of the base of the hemisphere. |
public final class SurfaceEntity.Shape.Quad implements SurfaceEntity.ShapeA Quadrilateral-shaped canvas. |
public final class SurfaceEntity.Shape.Sphere implements SurfaceEntity.Shapecal An inwards-facing sphere-shaped mesh, centered at (0,0,0) in the local coordinate space. |
public final class SurfaceEntity.StereoModeSpecifies how the surface content will be routed for stereo viewing. |
public final class SurfaceEntity.SuperSamplingSpecifies whether super sampling should be enabled for this surface. |
public final class SurfaceEntity.SurfaceProtectionSpecifies whether the |
Public methods |
|
|---|---|
static final @NonNull SurfaceEntity |
@MainThreadPublic factory function for a SurfaceEntity. |
final @NonNull FloatSize3d |
Returns the size of the canvas in the local spatial coordinate system of the entity. |
final @NonNull SurfaceEntity.EdgeFeatheringParams |
The |
final @NonNull PerceivedResolutionResult |
getPerceivedResolution(@NonNull RenderViewpoint renderViewpoint)Gets the perceived resolution of the entity in the provided |
final @NonNull SurfaceEntity.Shape |
getShape()The shape of the canvas that backs the Entity. |
final @NonNull SurfaceEntity.StereoMode |
Controls how the surface content will be routed for stereo viewing. |
final @NonNull Surface |
Returns a surface into which the application can render stereo image content. |
final void |
The |
final void |
@MainThreadThe shape of the canvas that backs the Entity. |
final void |
Controls how the surface content will be routed for stereo viewing. |
final void |
@MainThreadSets the width and height of the |
Inherited methods |
||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||
|
Public methods
create
@MainThread
public static final @NonNull SurfaceEntity create(
@NonNull Session session,
@NonNull Pose pose,
@NonNull SurfaceEntity.Shape shape,
@NonNull SurfaceEntity.StereoMode stereoMode,
@NonNull SurfaceEntity.SuperSampling superSampling,
@NonNull SurfaceEntity.SurfaceProtection surfaceProtection,
Entity parent
)
Public factory function for a SurfaceEntity.
| Parameters | |
|---|---|
@NonNull Session session |
Session to create the SurfaceEntity in. |
@NonNull Pose pose |
Pose of this entity relative to its parent, default value is Identity. |
@NonNull SurfaceEntity.Shape shape |
The |
@NonNull SurfaceEntity.StereoMode stereoMode |
Stereo mode for the surface. |
@NonNull SurfaceEntity.SuperSampling superSampling |
The |
@NonNull SurfaceEntity.SurfaceProtection surfaceProtection |
The |
Entity parent |
Parent entity. Defaults to |
| Returns | |
|---|---|
@NonNull SurfaceEntity |
a SurfaceEntity instance |
getDimensions
public final @NonNull FloatSize3d getDimensions()
Returns the size of the canvas in the local spatial coordinate system of the entity.
This value is entirely determined by the value of shape.
getEdgeFeatheringParams
public final @NonNull SurfaceEntity.EdgeFeatheringParams getEdgeFeatheringParams()
The EdgeFeatheringParams feathering pattern to be used along the edges of the Shape. This value must only be set from the main thread.
| Throws | |
|---|---|
IllegalStateException |
when setting this value if the Entity has been disposed. |
getPerceivedResolution
public final @NonNull PerceivedResolutionResult getPerceivedResolution(@NonNull RenderViewpoint renderViewpoint)
Gets the perceived resolution of the entity in the provided RenderViewpoint.
This API is only intended for use in Full Space and will return PerceivedResolutionResult.InvalidRenderViewpoint in Home Space.
The entity's own rotation and the camera's viewing direction are disregarded; this value represents the dimensions of the entity on the camera view if its largest surface was facing the camera without changing the distance of the entity to the camera.
| Parameters | |
|---|---|
@NonNull RenderViewpoint renderViewpoint |
that provides the pose and field-of-view of the camera. |
| Returns | |
|---|---|
@NonNull PerceivedResolutionResult |
A |
| Throws | |
|---|---|
IllegalStateException |
if |
| See also | |
|---|---|
PerceivedResolutionResult |
getShape
public final @NonNull SurfaceEntity.Shape getShape()
The shape of the canvas that backs the Entity. Updating this value will alter the dimensions of the Entity.
| Throws | |
|---|---|
IllegalArgumentException |
if an invalid canvas shape is provided. |
IllegalStateException |
when setting this value if the Entity has been disposed. |
getStereoMode
public final @NonNull SurfaceEntity.StereoMode getStereoMode()
Controls how the surface content will be routed for stereo viewing. Applications must render into the surface in accordance with what is specified here in order for the compositor to correctly produce a stereoscopic view to the user.
| Throws | |
|---|---|
IllegalStateException |
when setting this value if the Entity has been disposed. |
getSurface
@MainThread
public final @NonNull Surface getSurface()
Returns a surface into which the application can render stereo image content. Note that android.graphics.Canvas Apis are not currently supported on this Canvas.
| Throws | |
|---|---|
IllegalStateException |
if the Entity has been disposed. |
setEdgeFeatheringParams
@MainThread
public final void setEdgeFeatheringParams(
@NonNull SurfaceEntity.EdgeFeatheringParams value
)
The EdgeFeatheringParams feathering pattern to be used along the edges of the Shape. This value must only be set from the main thread.
| Throws | |
|---|---|
IllegalStateException |
when setting this value if the Entity has been disposed. |
setShape
@MainThread
public final void setShape(@NonNull SurfaceEntity.Shape value)
The shape of the canvas that backs the Entity. Updating this value will alter the dimensions of the Entity.
| Throws | |
|---|---|
IllegalArgumentException |
if an invalid canvas shape is provided. |
IllegalStateException |
when setting this value if the Entity has been disposed. |
setStereoMode
@MainThread
public final void setStereoMode(@NonNull SurfaceEntity.StereoMode value)
Controls how the surface content will be routed for stereo viewing. Applications must render into the surface in accordance with what is specified here in order for the compositor to correctly produce a stereoscopic view to the user.
| Throws | |
|---|---|
IllegalStateException |
when setting this value if the Entity has been disposed. |
setSurfacePixelDimensions
@MainThread
@ExperimentalSurfaceEntityPixelDimensionsApi
public final void setSurfacePixelDimensions(@NonNull IntSize2d dimensions)
Sets the width and height of the Surface which backs this SurfaceEntity in pixels.
Before this method is called, the width and height of the underlying Surface are not guaranteed.
This is needed if the application wishes to use android.graphics.Canvas APIs to render Bitmaps into the Surface. It is not needed if the application is using MediaPlayer or ExoPlayer to decode media into the Surface, as those systems automatically manage the dimensions of the Surface.
Note that this method does not change the spatial dimensions of the SurfaceEntity, it only updates the resolution of the Surface. Unlike PanelEntity, changing this value will update the pixel density of the displayed Surface. Changing this will not change the scale.
| Throws | |
|---|---|
IllegalArgumentException |
if the dimensions are not greater than 0. |
IllegalStateException |
if the Entity has been disposed, or if |