-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
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