# GlMatrixTransformation

Artifact: [androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/effect/GlMatrixTransformation.java+class:androidx.media3.effect.GlMatrixTransformation)

*** ** * ** ***


```
@UnstableApi
public interface GlMatrixTransformation extends GlEffect
```

<br />

Known direct subclasses [MatrixTransformation](https://developer.android.com/reference/androidx/media3/effect/MatrixTransformation)

|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/MatrixTransformation` | Specifies a 3x3 transformation `https://developer.android.com/reference/android/graphics/Matrix.html` to apply in the vertex shader for each frame. |

Known indirect subclasses [Crop](https://developer.android.com/reference/androidx/media3/effect/Crop), [Presentation](https://developer.android.com/reference/androidx/media3/effect/Presentation), [ScaleAndRotateTransformation](https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation)

|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/Crop` | Specifies a crop to apply in the vertex shader. |
| `https://developer.android.com/reference/androidx/media3/effect/Presentation` | Controls how a frame is presented with options to set the output resolution and choose how to map the input pixels onto the output frame geometry (for example, by stretching the input frame to match the specified output frame, or fitting the input frame using letterboxing). |
| `https://developer.android.com/reference/androidx/media3/effect/ScaleAndRotateTransformation` | Specifies a simple rotation and/or scale to apply in the vertex shader. |

*** ** * ** ***

Specifies a 4x4 transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply in the vertex shader for each input frame.

The matrix is applied to points given in normalized device coordinates (-1 to 1 on x, y, and z axes). Transformed pixels that are moved outside of the normal device coordinate range are clipped.

Output frame pixels outside of the transformed input frame will be black, with alpha = 0 if applicable.

## Summary

| ### Public methods |
|---|---|
| `default https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#configure(int,int)(int inputWidth, int inputHeight)` Configures the input and output dimensions. |
| `abstract float[]` | `https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#getGlMatrixArray(long)(long presentationTimeUs)` Returns the 4x4 transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the frame with the given timestamp. |
| `default int` | `@https://developer.android.com/reference/androidx/media3/common/C.TextureMinFilter https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#getGlTextureMinFilter()()` Returns the `https://developer.android.com/reference/androidx/media3/common/C.TextureMinFilter` to use for sampling the input texture when applying this matrix transformation. |
| `default https://developer.android.com/reference/androidx/media3/effect/BaseGlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#toGlShaderProgram(android.content.Context,boolean)(https://developer.android.com/reference/android/content/Context.html context, boolean useHdr)` Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect. |

| ### Inherited methods |
|---|
| From [androidx.media3.common.Effect](https://developer.android.com/reference/androidx/media3/common/Effect) |---|---| | `default long` | `https://developer.android.com/reference/androidx/media3/common/Effect#getDurationAfterEffectApplied(long)(long durationUs)` Returns the expected duration of the output stream when the effect is applied given a input `durationUs`. | |
| From [androidx.media3.effect.GlEffect](https://developer.android.com/reference/androidx/media3/effect/GlEffect) |---|---| | `default boolean` | `https://developer.android.com/reference/androidx/media3/effect/GlEffect#isNoOp(int,int)(int inputWidth, int inputHeight)` Returns whether a `https://developer.android.com/reference/androidx/media3/effect/GlEffect` applies no change at every timestamp. | |

## Public methods

### configure

```
default Size configure(int inputWidth, int inputHeight)
```

Configures the input and output dimensions.

Must be called before `https://developer.android.com/reference/androidx/media3/effect/GlMatrixTransformation#getGlMatrixArray(long)`.

| Parameters |
|---|---|
| `int inputWidth` | The input frame width, in pixels. |
| `int inputHeight` | The input frame height, in pixels. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/Size` | The output frame width and height, in pixels. |

### getGlMatrixArray

```
abstract float[] getGlMatrixArray(long presentationTimeUs)
```

Returns the 4x4 transformation `https://developer.android.com/reference/android/opengl/Matrix.html` to apply to the frame with the given timestamp.

### getGlTextureMinFilter

```
@C.TextureMinFilter
default int getGlTextureMinFilter()
```

Returns the `https://developer.android.com/reference/androidx/media3/common/C.TextureMinFilter` to use for sampling the input texture when applying this matrix transformation.

### toGlShaderProgram

```
default BaseGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
```

Returns a `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` that applies the effect.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A `https://developer.android.com/reference/android/content/Context.html`. |
| `boolean useHdr` | Whether input textures come from an HDR source. If `true`, colors will be in linear RGB BT.2020. If `false`, colors will be in linear RGB BT.709. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while creating the `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram`. |