Skip to content

ImageShader Additional Constructors #31338

@cmkweber

Description

@cmkweber

Currently, the ImageShader constructor only takes an Image (or SkImage).
This is problematic when the shader source will be on the GPU.

For instance, to create an image shader using the canvas as a source, one must go:

Canvas(PictureRecorder) -> Picture -> Image -> ImageShader

This causes the image to have to be swapped from GPU to CPU and then back to GPU.
This really slows down at Picture.toImage(), and not suitable for per frame updates.

Skia supports creating a canvas that draws to an SkBitmap:

SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);

It also supports creating an image shader from an SkBitmap:

SkBitmap::makeShader(SkTileMode tmx, SkTileMode tmy, const SkMatrix* localMatrix = nullptr)

Can these be added to allow for paint shaders to draw dynamic imagery effectively?

A skia fiddle can be found here:
https://fiddle.skia.org/c/31a0d78a243b94166338e59b5346d726

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityengineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions