Page Summary
-
BufferViewportstores information about a region's data location in the client's target, including viewport bounds, field of view, and eye type for distortion calculations. -
It is created using
GvrApiand populated viaBufferViewportList, offering methods to manage eye type, reprojection, source buffer, field of view, UV coordinates, and transform matrix. -
Constants
BUFFER_INDEX_EXTERNAL_SURFACEandEXTERNAL_SURFACE_ID_NONErepresent specific buffer and surface states. -
Developers can manipulate viewport properties like opacity and reprojection type for optimal rendering.
-
shutdown()releases resources, and the caller is responsible for not using the instance afterward.
Encapsulated information about where to find the data in the client's target for a given region (e.g., the region for a particular eye).
This includes the viewport bounds for that region, the field of view, and the type of eye that has been rendered. This latter is used to calculate what kind of distortion to apply when the region is distorted to the screen.
A BufferViewport instance can be created via GvrApi, and populated via BufferViewportList.
Nested Classes
| class | BufferViewport.EyeType | The type of eye corresponding to the BufferViewport. |
|
| class | BufferViewport.Reprojection | Types of asynchronous reprojection. | |
Constants
| int | BUFFER_INDEX_EXTERNAL_SURFACE | Source buffer index that indicates that the viewport contents should be taken directly from its external surface rather than from one of the frame's buffers. |
| int | EXTERNAL_SURFACE_ID_NONE | External surface ID that represents a nonexistent surface. |
Public Methods
| boolean | |
| int |
getExternalSurfaceId()
Gets the
GvrLayout issued Surface ID. |
| float |
getOpacity()
Gets the opacity to apply to the specified viewport.
|
| int |
getReprojection()
Gets the type of reprojection to perform on the viewport.
|
| int |
getSourceBufferIndex()
Gets the index of the source buffer that contains the viewport's pixels.
|
| void | |
| void |
getSourceUv(RectF sourceUvOut)
Gets the UV coordinates within the buffer where this viewport's pixels are located.
|
| int |
getTargetEye()
Gets the
BufferViewport.EyeType for the viewport. |
| void |
getTransform(float[] transform)
Gets the matrix that transforms a quad with vertices (-1, -1, 0), (1, -1, 0), (-1, 1, 0),
(1, 1, 0) representing the viewport contents to its desired position in eye space for the
target eye.
|
| void |
setExternalSurfaceId(int id)
Sets the ID of the externally-managed Surface texture from which this viewport reads.
|
| void |
setOpacity(float opacity)
Sets the opacity to apply to the specified viewport.
|
| void |
setReprojection(int reprojection)
Sets the type of reprojection to perform on the viewport.
|
| void |
setSourceBufferIndex(int index)
Sets the index of the source buffer that contains the viewport's pixels.
|
| void | |
| void |
setSourceLayer(int layerIndex)
Sets the layer in a multiview buffer from which the viewport should sample.
|
| void |
setSourceUv(RectF sourceUv)
Sets the UV range within the buffer where this viewport's pixels are located.
|
| void |
setTargetEye(int eye)
Sets the
BufferViewport.EyeType for the viewport. |
| void |
setTransform(float[] transform)
Sets the matrix that transforms a quad with vertices (-1, -1, 0), (1, -1, 0), (-1, 1, 0),
(1, 1, 0) that represents the viewport contents to its correct position in eye space for the
target eye.
|
| void |
shutdown()
Shuts down the BufferViewport instance, freeing associated resources.
|
Inherited Methods
Constants
public static final int BUFFER_INDEX_EXTERNAL_SURFACE
Source buffer index that indicates that the viewport contents should be taken directly from its external surface rather than from one of the frame's buffers.
public static final int EXTERNAL_SURFACE_ID_NONE
External surface ID that represents a nonexistent surface.
Public Methods
public int getExternalSurfaceId ()
Gets the GvrLayout issued Surface ID.
EXTERNAL_SURFACE_ID_NONE if no Surface is set.
Returns
- The ID of the externally-managed surface.
public float getOpacity ()
Gets the opacity to apply to the specified viewport.
Returns
- Opacity Defaults to 1.
public int getReprojection ()
Gets the type of reprojection to perform on the viewport.
Returns
- Type of reprojection (see
BufferViewport.Reprojection) that is applied to the viewport.
public int getSourceBufferIndex ()
Gets the index of the source buffer that contains the viewport's pixels.
public void getSourceFov (RectF sourceFovOut)
Gets the eye's field of view in degrees.
Parameters
| sourceFovOut | The rect to populate with the eye's field-of-view. |
|---|
public void getSourceUv (RectF sourceUvOut)
Gets the UV coordinates within the buffer where this viewport's pixels are located.
Parameters
| sourceUvOut | The rect to populate with the current source UV coordinates. |
|---|
public void getTransform (float[] transform)
Gets the matrix that transforms a quad with vertices (-1, -1, 0), (1, -1, 0), (-1, 1, 0), (1, 1, 0) representing the viewport contents to its desired position in eye space for the target eye.
Parameters
| transform | The array in which the transform matrix should be returned. |
|---|
public void setExternalSurfaceId (int id)
Sets the ID of the externally-managed Surface texture from which this viewport reads.
Parameters
| id | The ID of the external surface, as assigned by GvrLayout. A value of EXTERNAL_SURFACE_ID_NONE will disable use of the external surface.
|
|---|
public void setOpacity (float opacity)
Sets the opacity to apply to the specified viewport.
Parameters
| opacity | The opacity that will be applied to the viewport, it should be within [0,1]. |
|---|
public void setReprojection (int reprojection)
Sets the type of reprojection to perform on the viewport. Viewports that display world content should use full reprojection. Viewports that display head-locked UI should disable reprojection to avoid excessive judder. The default is to perform full reprojection.
Parameters
| reprojection | Type of reprojection (see BufferViewport.Reprojection) that will be applied to the
viewport.
|
|---|
public void setSourceBufferIndex (int index)
Sets the index of the source buffer that contains the viewport's pixels.
Parameters
| index | The new buffer index. This is either an index into the array of BufferSpec objects
passed when creating the swap chain or BUFFER_INDEX_EXTERNAL_SURFACE
when an external surface is used as the image source.
|
|---|
public void setSourceFov (RectF sourceFov)
Sets the eye's field of view in degrees.
Parameters
| sourceFov | The new field of view. |
|---|
public void setSourceLayer (int layerIndex)
Sets the layer in a multiview buffer from which the viewport should sample.
Parameters
| layerIndex | The layer in the array texture that distortion samples from. Must be non-negative. Defaults to 0. |
|---|
public void setSourceUv (RectF sourceUv)
Sets the UV range within the buffer where this viewport's pixels are located.
Parameters
| sourceUv | The rect with new source UV coordinates. The coordinates must satisfy left <= right and bottom <= top. |
|---|
public void setTransform (float[] transform)
Sets the matrix that transforms a quad with vertices (-1, -1, 0), (1, -1, 0), (-1, 1, 0),
(1, 1, 0) that represents the viewport contents to its correct position in eye space for the
target eye. This is a more general version of setSourceFov.
Parameters
| transform | The new projection matrix to set. |
|---|
public void shutdown ()
Shuts down the BufferViewport instance, freeing associated resources.
Note: The caller is responsible for ensuring that this BufferViewport
isn't used after shutdown.