Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

SurfaceControl.Builder

public static class SurfaceControl.Builder
extends Object

java.lang.Object
   ↳ android.view.SurfaceControl.Builder


Builder class for SurfaceControl objects.

Summary

Public constructors

SurfaceControl.Builder()

Begin building a SurfaceControl.

Public methods

SurfaceControl build()

Construct a new SurfaceControl with the set parameters.

SurfaceControl.Builder setBufferSize(int width, int height)

Set the initial size of the controlled surface's buffers in pixels.

SurfaceControl.Builder setFormat(int format)

Set the pixel format of the controlled surface's buffers, using constants from PixelFormat.

SurfaceControl.Builder setName(String name)

Set a debugging-name for the SurfaceControl.

SurfaceControl.Builder setOpaque(boolean opaque)

Indicates whether the surface must be considered opaque, even if its pixel format is set to translucent.

SurfaceControl.Builder setParent(SurfaceControl parent)

Set a parent surface for our new SurfaceControl.

Inherited methods

Public constructors

SurfaceControl.Builder

public SurfaceControl.Builder ()

Begin building a SurfaceControl.

Public methods

build

public SurfaceControl build ()

Construct a new SurfaceControl with the set parameters. The builder remains valid.

Returns
SurfaceControl

setBufferSize

public SurfaceControl.Builder setBufferSize (int width, 
                int height)

Set the initial size of the controlled surface's buffers in pixels.

Parameters
width int: The buffer width in pixels. Value is 0 or greater

height int: The buffer height in pixels. Value is 0 or greater

Returns
SurfaceControl.Builder

setFormat

public SurfaceControl.Builder setFormat (int format)

Set the pixel format of the controlled surface's buffers, using constants from PixelFormat.

Parameters
format int: Value is PixelFormat.RGBA_8888, PixelFormat.RGBX_8888, PixelFormat.RGBA_F16, PixelFormat.RGBA_1010102, PixelFormat.RGB_888, or PixelFormat.RGB_565

Returns
SurfaceControl.Builder This value will never be null.

setName

public SurfaceControl.Builder setName (String name)

Set a debugging-name for the SurfaceControl.

Parameters
name String: A name to identify the Surface in debugging.

Returns
SurfaceControl.Builder

setOpaque

public SurfaceControl.Builder setOpaque (boolean opaque)

Indicates whether the surface must be considered opaque, even if its pixel format is set to translucent. This can be useful if an application needs full RGBA 8888 support for instance but will still draw every pixel opaque.

This flag only determines whether opacity will be sampled from the alpha channel. Plane-alpha from calls to setAlpha() can still result in blended composition regardless of the opaque setting. Combined effects are (assuming a buffer format with an alpha channel):

  • OPAQUE + alpha(1.0) == opaque composition
  • OPAQUE + alpha(0.x) == blended composition
  • OPAQUE + alpha(0.0) == no composition
  • !OPAQUE + alpha(1.0) == blended composition
  • !OPAQUE + alpha(0.x) == blended composition
  • !OPAQUE + alpha(0.0) == no composition
If the underlying buffer lacks an alpha channel, it is as if setOpaque(true) were set automatically.

Parameters
opaque boolean: Whether the Surface is OPAQUE.

Returns
SurfaceControl.Builder This value will never be null.

setParent

public SurfaceControl.Builder setParent (SurfaceControl parent)

Set a parent surface for our new SurfaceControl. Child surfaces are constrained to the onscreen region of their parent. Furthermore they stack relatively in Z order, and inherit the transformation of the parent.

Parameters
parent SurfaceControl: The parent control. This value may be null.

Returns
SurfaceControl.Builder This value will never be null.