Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/graphics/MeshSpecification#nestedclasses) \| [Constants](https://developer.android.com/reference/android/graphics/MeshSpecification#constants) \| [Methods](https://developer.android.com/reference/android/graphics/MeshSpecification#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/MeshSpecification#inhmethods)

# MeshSpecification

*** ** * ** ***

` public class MeshSpecification `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.MeshSpecification |

<br />

*** ** * ** ***

Class responsible for holding specifications for `https://developer.android.com/reference/android/graphics/Mesh` creations. This class generates a `https://developer.android.com/reference/android/graphics/MeshSpecification` via the `https://developer.android.com/reference/android/graphics/MeshSpecification#make(android.graphics.MeshSpecification.Attribute[],%20int,%20android.graphics.MeshSpecification.Varying[],%20java.lang.String,%20java.lang.String)` method, where multiple parameters to set up the mesh are supplied, including attributes, vertex stride, `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying`, and vertex/fragment shaders. There are also additional methods to provide an optional `https://developer.android.com/reference/android/graphics/ColorSpace` as well as an alpha type. For example a vertex shader that leverages a `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying` may look like the following:

```
       Varyings main(const Attributes attributes) {
            Varyings varyings;
            varyings.position = attributes.position;
            return varyings;
       }
```
The corresponding fragment shader that may consume the varying look like the following:

```
     float2 main(const Varyings varyings, out float4 color) {
            color = vec4(1.0, 0.0, 0.0, 1.0);
            return varyings.position;
     }
```
The color returned from this fragment shader is blended with the other parameters that are configured on the Paint object (ex. `https://developer.android.com/reference/android/graphics/Paint#setBlendMode(android.graphics.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.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute` Data class to represent a single attribute in a shader. |
| ` class` | `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying` Data class to represent a single varying variable. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_OPAQUE` Pixel is opaque. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_PREMULTIPLIED` Pixel components are premultiplied by alpha. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNKNOWN` uninitialized. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNPREMULTIPLIED` Pixel components are independent of alpha. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#TYPE_FLOAT` Represents one float. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#TYPE_FLOAT2` Represents two floats. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#TYPE_FLOAT3` Represents three floats. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#TYPE_FLOAT4` Represents four floats. |
| `int` | `https://developer.android.com/reference/android/graphics/MeshSpecification#TYPE_UBYTE4` Represents four bytes. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/graphics/MeshSpecification` | ` https://developer.android.com/reference/android/graphics/MeshSpecification#make(android.graphics.MeshSpecification.Attribute[],%20int,%20android.graphics.MeshSpecification.Varying[],%20java.lang.String,%20java.lang.String,%20android.graphics.ColorSpace,%20int)(https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute attributes, int vertexStride, https://developer.android.com/reference/android/graphics/MeshSpecification.Varying varyings, https://developer.android.com/reference/java/lang/String vertexShader, https://developer.android.com/reference/java/lang/String fragmentShader, https://developer.android.com/reference/android/graphics/ColorSpace colorSpace, int alphaType) ` Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object. |
| ` static https://developer.android.com/reference/android/graphics/MeshSpecification` | ` https://developer.android.com/reference/android/graphics/MeshSpecification#make(android.graphics.MeshSpecification.Attribute[],%20int,%20android.graphics.MeshSpecification.Varying[],%20java.lang.String,%20java.lang.String,%20android.graphics.ColorSpace)(https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute attributes, int vertexStride, https://developer.android.com/reference/android/graphics/MeshSpecification.Varying varyings, https://developer.android.com/reference/java/lang/String vertexShader, https://developer.android.com/reference/java/lang/String fragmentShader, https://developer.android.com/reference/android/graphics/ColorSpace colorSpace) ` Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object. |
| ` static https://developer.android.com/reference/android/graphics/MeshSpecification` | ` https://developer.android.com/reference/android/graphics/MeshSpecification#make(android.graphics.MeshSpecification.Attribute[],%20int,%20android.graphics.MeshSpecification.Varying[],%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute attributes, int vertexStride, https://developer.android.com/reference/android/graphics/MeshSpecification.Varying varyings, https://developer.android.com/reference/java/lang/String vertexShader, https://developer.android.com/reference/java/lang/String fragmentShader) ` Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object for use within `https://developer.android.com/reference/android/graphics/Mesh`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### ALPHA_TYPE_OPAQUE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ALPHA_TYPE_OPAQUE
```

Pixel is opaque.

<br />

Constant Value: 1 (0x00000001)

### ALPHA_TYPE_PREMULTIPLIED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ALPHA_TYPE_PREMULTIPLIED
```

Pixel components are premultiplied by alpha.

<br />

Constant Value: 2 (0x00000002)

### ALPHA_TYPE_UNKNOWN

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ALPHA_TYPE_UNKNOWN
```

uninitialized.

<br />

Constant Value: 0 (0x00000000)

### ALPHA_TYPE_UNPREMULTIPLIED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ALPHA_TYPE_UNPREMULTIPLIED
```

Pixel components are independent of alpha.

<br />

Constant Value: 3 (0x00000003)

### TYPE_FLOAT

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_FLOAT
```

Represents one float. Its equivalent shader type is float.

<br />

Constant Value: 0 (0x00000000)

### TYPE_FLOAT2

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_FLOAT2
```

Represents two floats. Its equivalent shader type is float2.

<br />

Constant Value: 1 (0x00000001)

### TYPE_FLOAT3

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_FLOAT3
```

Represents three floats. Its equivalent shader type is float3.

<br />

Constant Value: 2 (0x00000002)

### TYPE_FLOAT4

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_FLOAT4
```

Represents four floats. Its equivalent shader type is float4.

<br />

Constant Value: 3 (0x00000003)

### TYPE_UBYTE4

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_UBYTE4
```

Represents four bytes. Its equivalent shader type is half4.

<br />

Constant Value: 4 (0x00000004)

## Public methods

### make

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MeshSpecification make (Attribute[] attributes, 
                int vertexStride, 
                Varying[] varyings, 
                String vertexShader, 
                String fragmentShader, 
                ColorSpace colorSpace, 
                int alphaType)
```

Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object.

<br />

| Parameters ||
|---|---|
| `attributes` | `Attribute`: list of attributes represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute`. Can hold a max of 8. This value cannot be `null`. <br /> |
| `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 <br /> |
| `varyings` | `Varying`: List of varyings represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying`. 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 be `null`. <br /> |
| `vertexShader` | `String`: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example vertex shader implementation. This value cannot be `null`. <br /> |
| `fragmentShader` | `String`: fragment shader to be supplied to the mesh. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example fragment shader implementation. This value cannot be `null`. <br /> |
| `colorSpace` | `ColorSpace`: `https://developer.android.com/reference/android/graphics/ColorSpace` to tell what color space to work in. This value cannot be `null`. <br /> |
| `alphaType` | `int`: Describes how to interpret the alpha component for a pixel. Must be one of `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNKNOWN`, `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_OPAQUE`, `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_PREMULTIPLIED`, or `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNPREMULTIPLIED` Value is one of the following: - `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNKNOWN` - `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_OPAQUE` - `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_PREMULTIPLIED` - `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_UNPREMULTIPLIED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/MeshSpecification` | `https://developer.android.com/reference/android/graphics/MeshSpecification` object for use when creating `https://developer.android.com/reference/android/graphics/Mesh` This value cannot be `null`. <br /> |

### make

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MeshSpecification make (Attribute[] attributes, 
                int vertexStride, 
                Varying[] varyings, 
                String vertexShader, 
                String fragmentShader, 
                ColorSpace colorSpace)
```

Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object. This uses a default alphaType of `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_PREMULTIPLIED`.

<br />

| Parameters ||
|---|---|
| `attributes` | `Attribute`: list of attributes represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute`. Can hold a max of 8. This value cannot be `null`. <br /> |
| `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 <br /> |
| `varyings` | `Varying`: List of varyings represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying`. 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 be `null`. <br /> |
| `vertexShader` | `String`: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example vertex shader implementation. This value cannot be `null`. <br /> |
| `fragmentShader` | `String`: fragment shader to be supplied to the mesh. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example fragment shader implementation. This value cannot be `null`. <br /> |
| `colorSpace` | `ColorSpace`: `https://developer.android.com/reference/android/graphics/ColorSpace` to tell what color space to work in. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/MeshSpecification` | `https://developer.android.com/reference/android/graphics/MeshSpecification` object for use when creating `https://developer.android.com/reference/android/graphics/Mesh` This value cannot be `null`. <br /> |

### make

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MeshSpecification make (Attribute[] attributes, 
                int vertexStride, 
                Varying[] varyings, 
                String vertexShader, 
                String fragmentShader)
```

Creates a `https://developer.android.com/reference/android/graphics/MeshSpecification` object for use within `https://developer.android.com/reference/android/graphics/Mesh`. This uses a default color space of `https://developer.android.com/reference/android/graphics/ColorSpace.Named#SRGB` and alphaType of `https://developer.android.com/reference/android/graphics/MeshSpecification#ALPHA_TYPE_PREMULTIPLIED`.

<br />

| Parameters ||
|---|---|
| `attributes` | `Attribute`: list of attributes represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Attribute`. Can hold a max of 8. This value cannot be `null`. <br /> |
| `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 <br /> |
| `varyings` | `Varying`: List of varyings represented by `https://developer.android.com/reference/android/graphics/MeshSpecification.Varying`. 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 be `null`. <br /> |
| `vertexShader` | `String`: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example vertex shader implementation. This value cannot be `null`. <br /> |
| `fragmentShader` | `String`: fragment shader to be supplied to the mesh. See `https://developer.android.com/reference/android/graphics/MeshSpecification` for an example fragment shader implementation. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/MeshSpecification` | `https://developer.android.com/reference/android/graphics/MeshSpecification` object for use when creating `https://developer.android.com/reference/android/graphics/Mesh` This value cannot be `null`. <br /> |