MeshSpecification
  public
  
  
  
  class
  MeshSpecification
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.graphics.MeshSpecification | 
Class responsible for holding specifications for Mesh creations. This class generates a
 MeshSpecification via the
 MeshSpecification.make(Attribute[], int, Varying[], String, String) method,
 where multiple parameters to set up the mesh are supplied, including attributes, vertex stride,
 Varying, and vertex/fragment shaders. There are also additional methods to provide an
 optional ColorSpace as well as an alpha type.
 For example a vertex shader that leverages a Varying may look like the following:
 
        Varyings main(const Attributes attributes) {
             Varyings varyings;
             varyings.position = attributes.position;
             return varyings;
        }
 
      float2 main(const Varyings varyings, out float4 color) {
             color = vec4(1.0, 0.0, 0.0, 1.0);
             return varyings.position;
      }
 Paint.setBlendMode(BlendMode) used to draw the mesh.
 The position returned in the fragment shader can be consumed by any following fragment shaders in
 the shader chain.
 See https://developer.android.com/develop/ui/views/graphics/agsl for more information
 regarding Android Graphics Shader Language.
 Note that there are several limitations on various mesh specifications:
 1. The max amount of attributes allowed is 8.
 2. The offset alignment length is 4 bytes.
 2. The max stride length is 1024.
 3. The max amount of varyings is 6.
 These should be kept in mind when generating a mesh specification, as exceeding them will
 lead to errors.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | MeshSpecification.AttributeData class to represent a single attribute in a shader. | 
| 
        
        
        
        
        class | MeshSpecification.VaryingData class to represent a single varying variable. | 
| Constants | |
|---|---|
| int | ALPHA_TYPE_OPAQUEPixel is opaque. | 
| int | ALPHA_TYPE_PREMULTIPLIEDPixel components are premultiplied by alpha. | 
| int | ALPHA_TYPE_UNKNOWNuninitialized. | 
| int | ALPHA_TYPE_UNPREMULTIPLIEDPixel components are independent of alpha. | 
| int | TYPE_FLOATRepresents one float. | 
| int | TYPE_FLOAT2Represents two floats. | 
| int | TYPE_FLOAT3Represents three floats. | 
| int | TYPE_FLOAT4Represents four floats. | 
| int | TYPE_UBYTE4Represents four bytes. | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        MeshSpecification | 
      make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace, int alphaType)
      Creates a  | 
| 
        
        
        static
        
        
        MeshSpecification | 
      make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace)
      Creates a  | 
| 
        
        
        static
        
        
        MeshSpecification | 
      make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader)
      Creates a  | 
| Inherited methods | |
|---|---|
Constants
ALPHA_TYPE_OPAQUE
public static final int ALPHA_TYPE_OPAQUE
Pixel is opaque.
Constant Value: 1 (0x00000001)
ALPHA_TYPE_PREMULTIPLIED
public static final int ALPHA_TYPE_PREMULTIPLIED
Pixel components are premultiplied by alpha.
Constant Value: 2 (0x00000002)
ALPHA_TYPE_UNKNOWN
public static final int ALPHA_TYPE_UNKNOWN
uninitialized.
Constant Value: 0 (0x00000000)
ALPHA_TYPE_UNPREMULTIPLIED
public static final int ALPHA_TYPE_UNPREMULTIPLIED
Pixel components are independent of alpha.
Constant Value: 3 (0x00000003)
TYPE_FLOAT
public static final int TYPE_FLOAT
Represents one float. Its equivalent shader type is float.
Constant Value: 0 (0x00000000)
TYPE_FLOAT2
public static final int TYPE_FLOAT2
Represents two floats. Its equivalent shader type is float2.
Constant Value: 1 (0x00000001)
TYPE_FLOAT3
public static final int TYPE_FLOAT3
Represents three floats. Its equivalent shader type is float3.
Constant Value: 2 (0x00000002)
TYPE_FLOAT4
public static final int TYPE_FLOAT4
Represents four floats. Its equivalent shader type is float4.
Constant Value: 3 (0x00000003)
TYPE_UBYTE4
public static final int TYPE_UBYTE4
Represents four bytes. Its equivalent shader type is half4.
Constant Value: 4 (0x00000004)
Public methods
make
public static MeshSpecification make (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace, int alphaType)
Creates a MeshSpecification object.
| Parameters | |
|---|---|
| attributes | Attribute: list of attributes represented byAttribute. Can hold a max of
                       8.
 This value cannot benull. | 
| vertexStride | int: length of vertex stride in bytes. This should be the size of a single
                       vertex' attributes. Max of 1024 is accepted.
 Value is between 1 and 1024 inclusive | 
| varyings | Varying: List of varyings represented byVarying. Can hold a max of 6.
                       Note that `position` is provided by default, does not need to be
                       provided in the list, and does not count towards
                       the 6 varyings allowed.
 This value cannot benull. | 
| vertexShader | String: vertex shader to be supplied to the mesh. Ensure that the position
                       varying is set within the shader to get proper results.
                       SeeMeshSpecificationfor an example vertex shader
                       implementation
 This value cannot benull. | 
| fragmentShader | String: fragment shader to be supplied to the mesh.
                       SeeMeshSpecificationfor an example fragment shader
                       implementation
 This value cannot benull. | 
| colorSpace | ColorSpace:ColorSpaceto tell what color space to work in.
 This value cannot benull. | 
| alphaType | int: Describes how to interpret the alpha component for a pixel. Must be
                       one ofMeshSpecification.ALPHA_TYPE_UNKNOWN,MeshSpecification.ALPHA_TYPE_OPAQUE,MeshSpecification.ALPHA_TYPE_PREMULTIPLIED, orMeshSpecification.ALPHA_TYPE_UNPREMULTIPLIEDValue isALPHA_TYPE_UNKNOWN,ALPHA_TYPE_OPAQUE,ALPHA_TYPE_PREMULTIPLIED, orALPHA_TYPE_UNPREMULTIPLIED | 
| Returns | |
|---|---|
| MeshSpecification | MeshSpecificationobject for use when creatingMeshThis value cannot benull. | 
make
public static MeshSpecification make (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace)
Creates a MeshSpecification object.  This uses a default alphaType of
 ALPHA_TYPE_PREMULTIPLIED.
| Parameters | |
|---|---|
| attributes | Attribute: list of attributes represented byAttribute. Can hold a max of
                       8.
 This value cannot benull. | 
| vertexStride | int: length of vertex stride in bytes. This should be the size of a single
                       vertex' attributes. Max of 1024 is accepted.
 Value is between 1 and 1024 inclusive | 
| varyings | Varying: List of varyings represented byVarying. Can hold a max of 6.
                       Note that `position` is provided by default, does not need to be
                       provided in the list, and does not count towards
                       the 6 varyings allowed.
 This value cannot benull. | 
| vertexShader | String: vertex shader to be supplied to the mesh. Ensure that the position
                       varying is set within the shader to get proper results.
                       SeeMeshSpecificationfor an example vertex shader
                       implementation
 This value cannot benull. | 
| fragmentShader | String: fragment shader to be supplied to the mesh.
                       SeeMeshSpecificationfor an example fragment shader
                       implementation
 This value cannot benull. | 
| colorSpace | ColorSpace:ColorSpaceto tell what color space to work in.
 This value cannot benull. | 
| Returns | |
|---|---|
| MeshSpecification | MeshSpecificationobject for use when creatingMeshThis value cannot benull. | 
make
public static MeshSpecification make (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader)
Creates a MeshSpecification object for use within Mesh. This uses a default
 color space of ColorSpace.Named.SRGB and alphaType of
 ALPHA_TYPE_PREMULTIPLIED.
| Parameters | |
|---|---|
| attributes | Attribute: list of attributes represented byAttribute. Can hold a max of
                       8.
 This value cannot benull. | 
| vertexStride | int: length of vertex stride in bytes. This should be the size of a single
                       vertex' attributes. Max of 1024 is accepted.
 Value is between 1 and 1024 inclusive | 
| varyings | Varying: List of varyings represented byVarying. Can hold a max of 6.
                       Note that `position` is provided by default, does not need to be
                       provided in the list, and does not count towards
                       the 6 varyings allowed.
 This value cannot benull. | 
| vertexShader | String: vertex shader to be supplied to the mesh. Ensure that the position
                       varying is set within the shader to get proper results.
                       SeeMeshSpecificationfor an example vertex shader
                       implementation
 This value cannot benull. | 
| fragmentShader | String: fragment shader to be supplied to the mesh.
                       SeeMeshSpecificationfor an example fragment shader
                       implementation
 This value cannot benull. | 
| Returns | |
|---|---|
| MeshSpecification | MeshSpecificationobject for use when creatingMeshThis value cannot benull. | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
