skia /
skia /
21c6fb26c14e30f309219a4a5eb66fc1b820988e [graphite] Use scratch textures for async readback
The original motivation for this CL was to be able to connect the
copy tasks with the drawing tasks so that they could participate in
texture reuse (eventually), and to update the surface creation/flow
to use scratch resources.
It snowballed to a little broader of change:
1. Added an AsyncParams<> struct that holds the image, subset,
dst image info, and callback parameters so that it's less
verbose to pass around between the different function calls.
- It's templated to work on SkImage or TextureProxy
- It defines the validation logic and has a utility for invoking
the callbacks when things fail.
2. Split the single-plane asyncReadPixels into an Image and Texture
variant, where the Image case can perform a CopyAsDraw fallback,
but the Texture one is used for unsampleable surfaces.
- This flow avoids unwrapping an image to a texture and then
rewrapping it as an image, which would break any task linkage
for a dynamic/scratch source image.
- This allows a YUVA multiplanar image to be readback as RGBA now
by going through the generic Image function and copying it.
- Surfaces that can't be images can now be readback as long as
there's no rescaling that has to be performed.
3. Replaces the inlined copy-as-draw logic with calling the CopyAsDraw
utility function.
4. Updates the YUVA rescale+readback logic to apply the color space
transformation automatically as part of the dst image info, instead
of rendering src->dst colorspace before doing the planar split.
5. Updates the planar rendering logic in the YUVA readback to
interleave the draws to a plane and the copies.
- This will allow the planar rendering to use the same texture with
reuse once the copy and draw tasks can be scoped together.
- It makes it easier for the surface to be a scratch surface that
goes away before the recording is snapped.
6. The high-level rescale+readback function is defined as a template
that takes a bound member function as an argument so that it can
be used for either single-plane readback or yuva readback.
7. A Recorder is plumbed through all of these functions and starts
out null. If any step along the way requires a recorder it creates
it and then forwards it on so that there's at clearly at most one
recorder used during readback (before it probably couldn't happen
because a RescaleImage() call should return a readable texture
that wouldn't then go through CopyAsDraw).
- The recorder is sent all the way to finalize(), which is now
responsible for snapping a Recording and inserting it before
it adds the finish info to the queue manager.
8. Maybe(?) fixed a bug where the CPU color conversion would always
go from the original src color type to dst type and not from the
supported readback type to dst color type.
Bug: b/336779772
Change-Id: I3f400a53bff1ee7efd283982178955e0bb07cf41
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/850516
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2 files changed