ScaleAndRotateTransformation


@UnstableApi
class ScaleAndRotateTransformation : MatrixTransformation


Specifies a simple rotation and/or scale to apply in the vertex shader.

All input frames' pixels will be preserved and copied into an output frame, potentially changing the width and height of the frame by scaling dimensions to fit.

The background color of the output frame will be black, with alpha = 0 if applicable.

Summary

Nested types

A builder for ScaleAndRotateTransformation instances.

Public functions

Size!
configure(inputWidth: Int, inputHeight: Int)

Configures the input and output dimensions.

Matrix!
getMatrix(presentationTimeUs: Long)

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

Boolean
isNoOp(inputWidth: Int, inputHeight: Int)

Returns whether a GlEffect applies no change at every timestamp.

Public properties

Float

The counterclockwise rotation, in degrees.

Float

The multiplier by which the frame will scale horizontally, along the x-axis.

Float

The multiplier by which the frame will scale vertically, along the y-axis.

Inherited functions

From androidx.media3.common.Effect
Long

Returns the expected duration of the output stream when the effect is applied given a input durationUs.

From androidx.media3.effect.GlEffect
abstract GlShaderProgram!
toGlShaderProgram(context: Context!, useHdr: Boolean)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.GlMatrixTransformation
BaseGlShaderProgram!
toGlShaderProgram(context: Context!, useHdr: Boolean)

Returns a GlShaderProgram that applies the effect.

From androidx.media3.effect.MatrixTransformation
FloatArray<Float>!
getGlMatrixArray(presentationTimeUs: Long)

Returns the 4x4 transformation Matrix to apply to the frame with the given timestamp.

Public functions

configure

fun configure(inputWidth: Int, inputHeight: Int): Size!

Configures the input and output dimensions.

Must be called before getGlMatrixArray.

Parameters
inputWidth: Int

The input frame width, in pixels.

inputHeight: Int

The input frame height, in pixels.

Returns
Size!

The output frame width and height, in pixels.

getMatrix

fun getMatrix(presentationTimeUs: Long): Matrix!

Returns the 3x3 transformation Matrix to apply to the frame with the given timestamp.

isNoOp

fun isNoOp(inputWidth: Int, inputHeight: Int): Boolean

Returns whether a GlEffect applies no change at every timestamp.

This can be used as a hint to skip this instance.

Parameters
inputWidth: Int

The input frame width, in pixels.

inputHeight: Int

The input frame height, in pixels.

Public properties

rotationDegrees

val rotationDegreesFloat

The counterclockwise rotation, in degrees. The value should always be between 0 (included) and 360 degrees (excluded).

scaleX

val scaleXFloat

The multiplier by which the frame will scale horizontally, along the x-axis.

scaleY

val scaleYFloat

The multiplier by which the frame will scale vertically, along the y-axis.