Added in API level 31

RenderEffect


class RenderEffect
kotlin.Any
   ↳ android.graphics.RenderEffect

Intermediate rendering step used to render drawing commands with a corresponding visual effect. A RenderEffect can be configured on a RenderNode through RenderNode#setRenderEffect(RenderEffect) and will be applied when drawn through Canvas#drawRenderNode(RenderNode). Additionally a RenderEffect can be applied to a View's backing RenderNode through android.view.View#setRenderEffect(RenderEffect)

Summary

Public methods
static RenderEffect

Create a RenderEffect that renders the contents of the input Bitmap.

static RenderEffect
createBitmapEffect(bitmap: Bitmap, src: Rect?, dst: Rect)

Create a RenderEffect that renders the contents of the input Bitmap.

static RenderEffect

Create a RenderEffect that is a composition of 2 other RenderEffect instances combined by the specified BlendMode

static RenderEffect
createBlurEffect(radiusX: Float, radiusY: Float, inputEffect: RenderEffect, edgeTreatment: Shader.TileMode)

Create a RenderEffect that blurs the contents of the optional input RenderEffect with the specified radius along the x and y axis.

static RenderEffect
createBlurEffect(radiusX: Float, radiusY: Float, edgeTreatment: Shader.TileMode)

Create a RenderEffect that blurs the contents of the android.graphics.RenderNode that this RenderEffect is installed on with the specified radius along the x and y axis.

static RenderEffect

Create a RenderEffect that composes 'inner' with 'outer', such that the results of 'inner' are treated as the source bitmap passed to 'outer', i.

static RenderEffect
createColorFilterEffect(colorFilter: ColorFilter, renderEffect: RenderEffect)

Create a RenderEffect that applies the color filter to the provided RenderEffect

static RenderEffect

Create a RenderEffect that applies the color filter to the contents of the android.graphics.RenderNode that this RenderEffect is installed on

static RenderEffect
createOffsetEffect(offsetX: Float, offsetY: Float)

Create a RenderEffect instance that will offset the drawing content by the provided x and y offset.

static RenderEffect
createOffsetEffect(offsetX: Float, offsetY: Float, input: RenderEffect)

Create a RenderEffect instance with the provided x and y offset

static RenderEffect
createRuntimeShaderEffect(shader: RuntimeShader, uniformShaderName: String)

Create a RenderEffect that executes the provided RuntimeShader and passes the contents of the android.graphics.RenderNode that this RenderEffect is installed on as an input to the shader.

static RenderEffect

Create a RenderEffect that renders the contents of the input Shader.

Public methods

createBitmapEffect

Added in API level 31
static fun createBitmapEffect(bitmap: Bitmap): RenderEffect

Create a RenderEffect that renders the contents of the input Bitmap. This is useful to create an input for other RenderEffect types such as RenderEffect#createBlurEffect(float, float, RenderEffect, TileMode) or RenderEffect#createColorFilterEffect(ColorFilter, RenderEffect)

Parameters
bitmap Bitmap: The source bitmap to be rendered by the created RenderEffect This value cannot be null.
Return
RenderEffect This value cannot be null.

createBitmapEffect

Added in API level 31
static fun createBitmapEffect(
    bitmap: Bitmap,
    src: Rect?,
    dst: Rect
): RenderEffect

Create a RenderEffect that renders the contents of the input Bitmap. This is useful to create an input for other RenderEffect types such as RenderEffect#createBlurEffect(float, float, RenderEffect, TileMode) or RenderEffect#createColorFilterEffect(ColorFilter, RenderEffect)

Parameters
bitmap Bitmap: The source bitmap to be rendered by the created RenderEffect This value cannot be null.
src Rect?: Optional subset of the bitmap to be part of the rendered output. If null is provided, the entire bitmap bounds are used.
dst Rect: Bounds of the destination which the bitmap is translated and scaled to be drawn into within the bounds of the RenderNode this RenderEffect is installed on This value cannot be null.
Return
RenderEffect This value cannot be null.

createBlendModeEffect

Added in API level 31
static fun createBlendModeEffect(
    dst: RenderEffect,
    src: RenderEffect,
    blendMode: BlendMode
): RenderEffect

Create a RenderEffect that is a composition of 2 other RenderEffect instances combined by the specified BlendMode

Parameters
dst RenderEffect: The Dst pixels used in blending This value cannot be null.
src RenderEffect: The Src pixels used in blending This value cannot be null.
blendMode BlendMode: The BlendMode to be used to combine colors from the two RenderEffects This value cannot be null.
Return
RenderEffect This value cannot be null.

createBlurEffect

Added in API level 31
static fun createBlurEffect(
    radiusX: Float,
    radiusY: Float,
    inputEffect: RenderEffect,
    edgeTreatment: Shader.TileMode
): RenderEffect

Create a RenderEffect that blurs the contents of the optional input RenderEffect with the specified radius along the x and y axis. If no input RenderEffect is provided then all drawing commands issued with a android.graphics.RenderNode that this RenderEffect is installed in will be blurred

Parameters
radiusX Float: Radius of blur along the X axis
radiusY Float: Radius of blur along the Y axis
inputEffect RenderEffect: Input RenderEffect that provides the content to be blurred, can be null to indicate that the drawing commands on the RenderNode are to be blurred instead of the input RenderEffect
edgeTreatment Shader.TileMode: Policy for how to blur content near edges of the blur kernel This value cannot be null.
Return
RenderEffect This value cannot be null.

createBlurEffect

Added in API level 31
static fun createBlurEffect(
    radiusX: Float,
    radiusY: Float,
    edgeTreatment: Shader.TileMode
): RenderEffect

Create a RenderEffect that blurs the contents of the android.graphics.RenderNode that this RenderEffect is installed on with the specified radius along the x and y axis.

Parameters
radiusX Float: Radius of blur along the X axis
radiusY Float: Radius of blur along the Y axis
edgeTreatment Shader.TileMode: Policy for how to blur content near edges of the blur kernel This value cannot be null.
Return
RenderEffect This value cannot be null.

createChainEffect

Added in API level 31
static fun createChainEffect(
    outer: RenderEffect,
    inner: RenderEffect
): RenderEffect

Create a RenderEffect that composes 'inner' with 'outer', such that the results of 'inner' are treated as the source bitmap passed to 'outer', i.e.

<code>result = outer(inner(source))
  </code>
Consumers should favor explicit chaining of RenderEffect instances at creation time rather than using chain effect. Chain effects are useful for situations where the input or output are provided from elsewhere and the input or output RenderEffect need to be changed.

Parameters
outer RenderEffect: RenderEffect that consumes the output of {@param inner} as its input This value cannot be null.
inner RenderEffect: RenderEffect that is consumed as input by {@param outer} This value cannot be null.
Return
RenderEffect This value cannot be null.

createColorFilterEffect

Added in API level 31
static fun createColorFilterEffect(
    colorFilter: ColorFilter,
    renderEffect: RenderEffect
): RenderEffect

Create a RenderEffect that applies the color filter to the provided RenderEffect

Parameters
colorFilter ColorFilter: ColorFilter applied to the content in the input RenderEffect This value cannot be null.
renderEffect RenderEffect: Source to be transformed by the specified ColorFilter This value cannot be null.
Return
RenderEffect This value cannot be null.

createColorFilterEffect

Added in API level 31
static fun createColorFilterEffect(colorFilter: ColorFilter): RenderEffect

Create a RenderEffect that applies the color filter to the contents of the android.graphics.RenderNode that this RenderEffect is installed on

Parameters
colorFilter ColorFilter: ColorFilter applied to the content in the input RenderEffect This value cannot be null.
Return
RenderEffect This value cannot be null.

createOffsetEffect

Added in API level 31
static fun createOffsetEffect(
    offsetX: Float,
    offsetY: Float
): RenderEffect

Create a RenderEffect instance that will offset the drawing content by the provided x and y offset.

Parameters
offsetX Float: offset along the x axis in pixels
offsetY Float: offset along the y axis in pixels
Return
RenderEffect This value cannot be null.

createOffsetEffect

Added in API level 31
static fun createOffsetEffect(
    offsetX: Float,
    offsetY: Float,
    input: RenderEffect
): RenderEffect

Create a RenderEffect instance with the provided x and y offset

Parameters
offsetX Float: offset along the x axis in pixels
offsetY Float: offset along the y axis in pixels
input RenderEffect: target RenderEffect used to render in the offset coordinates. This value cannot be null.
Return
RenderEffect This value cannot be null.

createRuntimeShaderEffect

Added in API level 33
static fun createRuntimeShaderEffect(
    shader: RuntimeShader,
    uniformShaderName: String
): RenderEffect

Create a RenderEffect that executes the provided RuntimeShader and passes the contents of the android.graphics.RenderNode that this RenderEffect is installed on as an input to the shader.

Parameters
shader RuntimeShader: the runtime shader that will bind the inputShaderName to the RenderEffect input This value cannot be null.
uniformShaderName String: the uniform name defined in the RuntimeShader's program to which the contents of the RenderNode will be bound This value cannot be null.
Return
RenderEffect This value cannot be null.

createShaderEffect

Added in API level 31
static fun createShaderEffect(shader: Shader): RenderEffect

Create a RenderEffect that renders the contents of the input Shader. This is useful to create an input for other RenderEffect types such as RenderEffect#createBlurEffect(float, float, RenderEffect, TileMode) RenderEffect#createBlurEffect(float, float, RenderEffect, TileMode) or RenderEffect#createColorFilterEffect(ColorFilter, RenderEffect).

Parameters
shader Shader: This value cannot be null.
Return
RenderEffect This value cannot be null.