# OverlayEffect

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/OverlayEffect.java+class:androidx.media3.effect.OverlayEffect)

*** ** * ** ***


```
@UnstableApi
public final class OverlayEffect implements GlEffect
```

<br />

*** ** * ** ***

Applies a list of `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`s to a frame in FIFO order (the last overlay in the list is displayed on top).

This effect assumes a non-`https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor#WORKING_COLOR_SPACE_LINEAR()` working color space for SDR input and a `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor#WORKING_COLOR_SPACE_LINEAR()` working color space or HDR input.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/effect/OverlayEffect#OverlayEffect(java.util.List<androidx.media3.effect.TextureOverlay>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/effect/TextureOverlay> textureOverlays)` Creates a new instance for the given list of `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`s. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/BaseGlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/OverlayEffect#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) |---|---| | `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) |---|---| | `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 constructors

### OverlayEffect

```
public OverlayEffect(List<TextureOverlay> textureOverlays)
```

Creates a new instance for the given list of `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`s.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/effect/TextureOverlay> textureOverlays` | The `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`s to be blended into the frame. To modify the list of `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay`, one must recreate a new ` OverlayEffect` with the updated list. |

## Public methods

### toGlShaderProgram

```
public 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`. |