Skia
2D Graphics Library
SkDeferredDisplayListRecorder Class Reference

#include <SkDeferredDisplayListRecorder.h>

Public Types

enum  PromiseImageApiVersion { PromiseImageApiVersion::kLegacy, PromiseImageApiVersion::kNew }
 
using PromiseImageTextureContext = void *
 
using PromiseImageTextureFulfillProc = sk_sp< SkPromiseImageTexture >(*)(PromiseImageTextureContext)
 
using PromiseImageTextureReleaseProc = void(*)(PromiseImageTextureContext)
 
using PromiseImageTextureDoneProc = void(*)(PromiseImageTextureContext)
 

Public Member Functions

 SkDeferredDisplayListRecorder (const SkSurfaceCharacterization &)
 
 ~SkDeferredDisplayListRecorder ()
 
const SkSurfaceCharacterizationcharacterization () const
 
SkCanvasgetCanvas ()
 
std::unique_ptr< SkDeferredDisplayListdetach ()
 
sk_sp< SkImagemakePromiseTexture (const GrBackendFormat &backendFormat, int width, int height, GrMipMapped mipMapped, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, PromiseImageTextureFulfillProc textureFulfillProc, PromiseImageTextureReleaseProc textureReleaseProc, PromiseImageTextureDoneProc textureDoneProc, PromiseImageTextureContext textureContext, PromiseImageApiVersion version=PromiseImageApiVersion::kLegacy)
 Create a new SkImage that is very similar to an SkImage created by MakeFromTexture. More...
 
sk_sp< SkImagemakeYUVAPromiseTexture (SkYUVColorSpace yuvColorSpace, const GrBackendFormat yuvaFormats[], const SkISize yuvaSizes[], const SkYUVAIndex yuvaIndices[4], int imageWidth, int imageHeight, GrSurfaceOrigin imageOrigin, sk_sp< SkColorSpace > imageColorSpace, PromiseImageTextureFulfillProc textureFulfillProc, PromiseImageTextureReleaseProc textureReleaseProc, PromiseImageTextureDoneProc textureDoneProc, PromiseImageTextureContext textureContexts[], PromiseImageApiVersion version=PromiseImageApiVersion::kLegacy)
 This entry point operates like 'makePromiseTexture' but it is used to construct a SkImage from YUV[A] data. More...
 

Member Typedef Documentation

◆ PromiseImageTextureContext

◆ PromiseImageTextureDoneProc

◆ PromiseImageTextureFulfillProc

◆ PromiseImageTextureReleaseProc

Member Enumeration Documentation

◆ PromiseImageApiVersion

Enumerator
kLegacy 
kNew 

Constructor & Destructor Documentation

◆ SkDeferredDisplayListRecorder()

SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder ( const SkSurfaceCharacterization )

◆ ~SkDeferredDisplayListRecorder()

SkDeferredDisplayListRecorder::~SkDeferredDisplayListRecorder ( )

Member Function Documentation

◆ characterization()

const SkSurfaceCharacterization& SkDeferredDisplayListRecorder::characterization ( ) const
inline

◆ detach()

std::unique_ptr<SkDeferredDisplayList> SkDeferredDisplayListRecorder::detach ( )

◆ getCanvas()

SkCanvas* SkDeferredDisplayListRecorder::getCanvas ( )

◆ makePromiseTexture()

sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture ( const GrBackendFormat backendFormat,
int  width,
int  height,
GrMipMapped  mipMapped,
GrSurfaceOrigin  origin,
SkColorType  colorType,
SkAlphaType  alphaType,
sk_sp< SkColorSpace colorSpace,
PromiseImageTextureFulfillProc  textureFulfillProc,
PromiseImageTextureReleaseProc  textureReleaseProc,
PromiseImageTextureDoneProc  textureDoneProc,
PromiseImageTextureContext  textureContext,
PromiseImageApiVersion  version = PromiseImageApiVersion::kLegacy 
)

Create a new SkImage that is very similar to an SkImage created by MakeFromTexture.

The difference is that the caller need not have created the texture nor populated it with the image pixel data. Moreover, the SkImage may be created on a thread as the creation of the image does not require access to the backend API or GrContext. Instead of passing a GrBackendTexture the client supplies a description of the texture consisting of GrBackendFormat, width, height, and GrMipMapped state. The resulting SkImage can be drawn to a SkDeferredDisplayListRecorder or directly to a GPU-backed SkSurface.

When the actual texture is required to perform a backend API draw, textureFulfillProc will be called to receive a GrBackendTexture. The properties of the GrBackendTexture must match those set during the SkImage creation, and it must refer to a valid existing texture in the backend API context/device, and be populated with the image pixel data. The texture contents cannot be modified until textureReleaseProc is called. The texture cannot be deleted until textureDoneProc is called.

When all the following are true: the promise SkImage is deleted, any SkDeferredDisplayLists that recorded draws referencing the image are deleted, and all draws referencing the texture have been flushed (via GrContext::flush or SkSurface::flush) the textureReleaseProc is called. When the following additional constraint is met the texture is safe to delete in the underlying API the textureDoneProc is called. For some APIs (e.g. GL) the two states are equivalent. However, for others (e.g. Vulkan) they are not as it is not legal to delete a texture until the GPU work referencing it has completed.

There is at most one call to each of textureFulfillProc, textureReleaseProc, and textureDoneProc. textureDoneProc is always called even if image creation fails or if the image is never fulfilled (e.g. it is never drawn or all draws are clipped out). If textureFulfillProc is called then textureReleaseProc will always be called even if textureFulfillProc failed.

If 'version' is set to kLegacy then the textureReleaseProc call is delayed until the conditions for textureDoneProc are met and then they are both called.

This call is only valid if the SkDeferredDisplayListRecorder is backed by a GPU context.

Parameters
backendFormatformat of promised gpu texture
widthwidth of promised gpu texture
heightheight of promised gpu texture
mipMappedmip mapped state of promised gpu texture
colorSpacerange of colors; may be nullptr
textureFulfillProcfunction called to get actual gpu texture
textureReleaseProcfunction called when texture can be released
textureDoneProcfunction called when we will no longer call textureFulfillProc
textureContextstate passed to textureFulfillProc and textureReleaseProc
versioncontrols when textureReleaseProc is called
Returns
created SkImage, or nullptr

◆ makeYUVAPromiseTexture()

sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture ( SkYUVColorSpace  yuvColorSpace,
const GrBackendFormat  yuvaFormats[],
const SkISize  yuvaSizes[],
const SkYUVAIndex  yuvaIndices[4],
int  imageWidth,
int  imageHeight,
GrSurfaceOrigin  imageOrigin,
sk_sp< SkColorSpace imageColorSpace,
PromiseImageTextureFulfillProc  textureFulfillProc,
PromiseImageTextureReleaseProc  textureReleaseProc,
PromiseImageTextureDoneProc  textureDoneProc,
PromiseImageTextureContext  textureContexts[],
PromiseImageApiVersion  version = PromiseImageApiVersion::kLegacy 
)

This entry point operates like 'makePromiseTexture' but it is used to construct a SkImage from YUV[A] data.

The source data may be planar (i.e. spread across multiple textures). In the extreme Y, U, V, and A are all in different planes and thus the image is specified by four textures. 'yuvaIndices' specifies the mapping from texture color channels to Y, U, V, and possibly A components. It therefore indicates how many unique textures compose the full image. Separate textureFulfillProc, textureReleaseProc, and textureDoneProc calls are made for each texture and each texture has its own PromiseImageTextureContext. 'yuvFormats', 'yuvaSizes', and 'textureContexts' have one entry for each of the up to four textures, as indicated by 'yuvaIndices'.


The documentation for this class was generated from the following file: