# OverlayEffect

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/effect/OverlayEffect "View this page in Java")

<br />

```
@UnstableApi
class OverlayEffect : GlEffect
```

<br />

*** ** * ** ***

Applies a list of[TextureOverlay](https://developer.android.com/reference/kotlin/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-[linear](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoFrameProcessor#WORKING_COLOR_SPACE_LINEAR())working color space for SDR input and a[linear](https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultVideoFrameProcessor#WORKING_COLOR_SPACE_LINEAR())working color space or HDR input.

## Summary

|                                                                                                                                                                                                                                                                                                                      ### Public constructors                                                                                                                                                                                                                                                                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [OverlayEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/OverlayEffect#OverlayEffect(java.util.List<androidx.media3.effect.TextureOverlay>))`(textureOverlays: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[TextureOverlay](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay)`!>!)` Creates a new instance for the given list of[TextureOverlay](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay)s. |

|                                                ### Public functions                                                 |
|---------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BaseGlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/BaseGlShaderProgram)`!` | [toGlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/OverlayEffect#toGlShaderProgram(android.content.Context,boolean))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.media3.common.Effect](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect) |-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [getDurationAfterEffectApplied](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect#getDurationAfterEffectApplied(long))`(durationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` 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/kotlin/androidx/media3/effect/GlEffect) |-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isNoOp](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect#isNoOp(int,int))`(inputWidth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, inputHeight: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns whether a[GlEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect)applies no change at every timestamp. | |

## Public constructors

### OverlayEffect

```
OverlayEffect(textureOverlays: (Mutable)List<TextureOverlay!>!)
```

Creates a new instance for the given list of[TextureOverlay](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay)s.  

|                                                                                                                                                             Parameters                                                                                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textureOverlays: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[TextureOverlay](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay)`!>!` | The[TextureOverlay](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay)s to be blended into the frame. To modify the list of[TextureOverlays](https://developer.android.com/reference/kotlin/androidx/media3/effect/TextureOverlay), one must recreate a new` OverlayEffect`with the updated list. |

## Public functions

### toGlShaderProgram

```
fun toGlShaderProgram(context: Context!, useHdr: Boolean): BaseGlShaderProgram!
```

Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | A[Context](https://developer.android.com/reference/android/content/Context.html).                                                               |
| `useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException) | If an error occurs while creating the[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram). |