Flutter Engine
The Flutter Engine
|
Typedefs | |
using | ReleaseContext = void * |
using | RasterReleaseProc = void(const void *pixels, ReleaseContext) |
using | BackendTextureReleaseProc = std::function< void(GrBackendTexture)> |
using | TextureReleaseProc = void(*)(ReleaseContext) |
using | GraphitePromiseImageContext = void * |
using | GraphitePromiseTextureFulfillContext = void * |
using | GraphitePromiseTextureReleaseContext = void * |
using | GraphitePromiseTextureFulfillProc = std::tuple< skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext >(*)(GraphitePromiseTextureFulfillContext) |
using | GraphitePromiseImageReleaseProc = void(*)(GraphitePromiseImageContext) |
using | GraphitePromiseTextureReleaseProc = void(*)(GraphitePromiseTextureReleaseContext) |
using | PromiseImageTextureContext = void * |
using | PromiseImageTextureFulfillProc = sk_sp< GrPromiseImageTexture >(*)(PromiseImageTextureContext) |
using | PromiseImageTextureReleaseProc = void(*)(PromiseImageTextureContext) |
Enumerations | |
enum class | BitDepth { kU8 , kF16 } |
enum class | GenerateMipmapsFromBase : bool { kNo , kYes } |
All factories in this file refer to the Ganesh GPU backend when they say GPU.
These functions expose features that are only for external use in Chromium.
using SkImages::BackendTextureReleaseProc = typedef std::function<void(GrBackendTexture)> |
Defines a callback function, taking one parameter of type GrBackendTexture with no return value. Function is called when backend texture is to be released.
Definition at line 43 of file SkImageGanesh.h.
using SkImages::GraphitePromiseImageContext = typedef void* |
using SkImages::GraphitePromiseImageReleaseProc = typedef void (*)(GraphitePromiseImageContext) |
using SkImages::GraphitePromiseTextureFulfillContext = typedef void* |
using SkImages::GraphitePromiseTextureFulfillProc = typedef std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext> (*)( GraphitePromiseTextureFulfillContext) |
using SkImages::GraphitePromiseTextureReleaseContext = typedef void* |
using SkImages::GraphitePromiseTextureReleaseProc = typedef void (*)(GraphitePromiseTextureReleaseContext) |
using SkImages::PromiseImageTextureContext = typedef void* |
Definition at line 35 of file SkImageChromium.h.
using SkImages::PromiseImageTextureFulfillProc = typedef sk_sp<GrPromiseImageTexture> (*)(PromiseImageTextureContext) |
Definition at line 36 of file SkImageChromium.h.
using SkImages::PromiseImageTextureReleaseProc = typedef void (*)(PromiseImageTextureContext) |
Definition at line 37 of file SkImageChromium.h.
using SkImages::RasterReleaseProc = typedef void(const void* pixels, ReleaseContext) |
using SkImages::ReleaseContext = typedef void* |
typedef void(* SkImages::TextureReleaseProc)(ReleaseContext) |
User function called when supplied texture may be deleted.
Definition at line 45 of file SkImageGanesh.h.
|
strong |
|
strong |
sk_sp< SkImage > SkImages::AdoptTextureFrom | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | textureOrigin, | ||
SkColorType | colorType | ||
) |
Creates GPU-backed SkImage from backendTexture associated with context. Skia will assume ownership of the resource and will release it when no longer needed. A non-null SkImage is returned if format of backendTexture is recognized and supported. Recognized formats vary by GPU backend.
context | GPU context |
backendTexture | texture residing on GPU |
textureOrigin | origin of backendTexture |
colorType | color type of the resulting image |
alphaType | alpha type of the resulting image |
colorSpace | range of colors; may be nullptr |
Definition at line 230 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::AdoptTextureFrom | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | textureOrigin, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType | ||
) |
Definition at line 238 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::AdoptTextureFrom | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | textureOrigin, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace | ||
) |
Definition at line 246 of file SkImage_GaneshFactories.cpp.
|
inline |
Definition at line 107 of file Image.h.
|
inline |
sk_sp< SkImage > SkImages::BorrowTextureFrom | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | origin, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
TextureReleaseProc | textureReleaseProc = nullptr , |
||
ReleaseContext | releaseContext = nullptr |
||
) |
Creates GPU-backed SkImage from the provided GPU texture associated with context. GPU texture must stay valid and unchanged until textureReleaseProc is called by Skia. Skia will call textureReleaseProc with the passed-in releaseContext when SkImage is deleted or no longer refers to the texture. A non-null SkImage is returned if format of backendTexture is recognized and supported. Recognized formats vary by GPU backend.
context | GPU context |
backendTexture | texture residing on GPU |
colorSpace | This describes the color space of this image's contents, as seen after sampling. In general, if the format of the backend texture is SRGB, some linear colorSpace should be supplied (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the backend texture is linear, then the colorSpace should include a description of the transfer function as well (e.g., SkColorSpace::MakeSRGB()). |
textureReleaseProc | function called when texture can be released |
releaseContext | state passed to textureReleaseProc |
Definition at line 194 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::CrossContextTextureFromPixmap | ( | GrDirectContext * | context, |
const SkPixmap & | pixmap, | ||
bool | buildMips, | ||
bool | limitToMaxTextureSize = false |
||
) |
Creates a GPU-backed SkImage from pixmap. It is uploaded to GPU backend using context. Created SkImage is available to other GPU contexts, and is available across thread boundaries. All contexts must be in the same GPU share group, or otherwise share resources. When SkImage is no longer referenced, context releases texture memory asynchronously. SkColorSpace of SkImage is determined by pixmap.colorSpace(). SkImage is returned referring to GPU backend if context is not nullptr, format of data is recognized and supported, and if context supports moving resources between contexts. Otherwise, pixmap pixel data is copied and SkImage as returned in raster format if possible; nullptr may be returned. Recognized GPU formats vary by platform and GPU backend.
context | GPU context |
pixmap | SkImageInfo, pixel address, and row bytes |
buildMips | create SkImage as mip map if true |
limitToMaxTextureSize | downscale image to GPU maximum texture size, if necessary |
Definition at line 373 of file SkImage_GaneshFactories.cpp.
SK_API sk_sp< SkImage > SkImages::DeferredFromAHardwareBuffer | ( | AHardwareBuffer * | hardwareBuffer, |
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
GrSurfaceOrigin | surfaceOrigin = kTopLeft_GrSurfaceOrigin |
||
) |
SK_API sk_sp< SkImage > SkImages::DeferredFromAHardwareBuffer | ( | AHardwareBuffer * | hardwareBuffer, |
SkAlphaType | alphaType = kPremul_SkAlphaType |
||
) |
(See Skia bug 7447) Creates SkImage from Android hardware buffer. Returned SkImage takes a reference on the buffer. Only available on Android, when ANDROID_API is defined to be 26 or greater.
hardwareBuffer | AHardwareBuffer Android hardware buffer |
colorSpace | range of colors; may be nullptr |
sk_sp< SkImage > SkImages::DeferredFromEncodedData | ( | sk_sp< SkData > | encoded, |
std::optional< SkAlphaType > | alphaType = std::nullopt |
||
) |
Return a SkImage using the encoded data, but attempts to defer decoding until the image is actually used/drawn. This deferral allows the system to cache the result, either on the CPU or on the GPU, depending on where the image is drawn. If memory is low, the cache may be purged, causing the next draw of the image to have to re-decode.
If alphaType is nullopt, the image's alpha type will be chosen automatically based on the image format. Transparent images will default to kPremul_SkAlphaType. If alphaType contains kPremul_SkAlphaType or kUnpremul_SkAlphaType, that alpha type will be used. Forcing opaque (passing kOpaque_SkAlphaType) is not allowed, and will return nullptr.
If the encoded format is not supported, nullptr is returned.
If possible, clients should use SkCodecs::DeferredImage instead.
encoded | the encoded data |
example: https://fiddle.skia.org/c/@Image_DeferredFromEncodedData
Definition at line 52 of file SkImageGenerator_FromEncoded.cpp.
sk_sp< SkImage > SkImages::DeferredFromGenerator | ( | std::unique_ptr< SkImageGenerator > | imageGenerator | ) |
Creates SkImage from data returned by imageGenerator. The image data will not be created (on either the CPU or GPU) until the image is actually drawn. Generated data is owned by SkImage and may not be shared or accessed.
SkImage is returned if generator data is valid. Valid data parameters vary by type of data and platform.
imageGenerator may wrap SkPicture data, codec data, or custom data.
imageGenerator | stock or custom routines to retrieve SkImage |
Definition at line 282 of file SkImage_Lazy.cpp.
sk_sp< SkImage > SkImages::DeferredFromPicture | ( | sk_sp< SkPicture > | picture, |
const SkISize & | dimensions, | ||
const SkMatrix * | matrix, | ||
const SkPaint * | paint, | ||
BitDepth | bitDepth, | ||
sk_sp< SkColorSpace > | colorSpace | ||
) |
Definition at line 23 of file SkImage_LazyFactories.cpp.
sk_sp< SkImage > SkImages::DeferredFromPicture | ( | sk_sp< SkPicture > | picture, |
const SkISize & | dimensions, | ||
const SkMatrix * | matrix, | ||
const SkPaint * | paint, | ||
BitDepth | bitDepth, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
SkSurfaceProps | props | ||
) |
Creates SkImage from picture. Returned SkImage width and height are set by dimensions. SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
The Picture data is not turned into an image (CPU or GPU) until it is drawn.
If matrix is nullptr, draws with identity SkMatrix. If paint is nullptr, draws with default SkPaint. colorSpace may be nullptr.
picture | stream of drawing commands |
dimensions | width and height |
matrix | SkMatrix to rotate, scale, translate, and so on; may be nullptr |
paint | SkPaint to apply transparency, filtering, and so on; may be nullptr |
bitDepth | 8-bit integer or 16-bit float: per component |
colorSpace | range of colors; may be nullptr |
props | props to use when rasterizing the picture |
Definition at line 33 of file SkImage_LazyFactories.cpp.
sk_sp< SkImage > SkImages::DeferredFromTextureGenerator | ( | std::unique_ptr< GrTextureGenerator > | gen | ) |
Like SkImages::DeferredFromGenerator except allows for the use of GrTextureGenerator.
gen | producer of textures |
Definition at line 62 of file SkImage_LazyTexture.cpp.
|
static |
Definition at line 318 of file ImageFactories.cpp.
|
inline |
Definition at line 279 of file SkImageGanesh.h.
bool SkImages::GetBackendTextureFromImage | ( | const SkImage * | img, |
GrBackendTexture * | outTexture, | ||
bool | flushPendingGrContextIO, | ||
GrSurfaceOrigin * | origin = nullptr |
||
) |
Retrieves the existing backend texture. If SkImage is not a Ganesh-backend texture image or otherwise does not have such a texture, false is returned. Otherwise, outTexture will be set to the image's texture.
If flushPendingGrContextIO is true, completes deferred I/O operations. If origin in not nullptr, copies location of content drawn into SkImage.
outTexture | Will be set to the underlying texture of the image if non-null. |
flushPendingGrContextIO | flag to flush outstanding requests |
origin | Will be set to the origin orientation of the image if non-null. |
Definition at line 112 of file SkImage_GaneshFactories.cpp.
|
inline |
Definition at line 303 of file SkImageGanesh.h.
|
inline |
Definition at line 111 of file SkImageChromium.h.
GrDirectContext * SkImages::GetContext | ( | const SkImage * | src | ) |
Returns the GPU context associated with this image or nullptr if the image is not Ganesh-backed. We expose this only to help transition certain API calls and do not intend for this to stick around forever.
Definition at line 448 of file SkImage_GaneshBase.cpp.
|
static |
Definition at line 350 of file ImageFactories.cpp.
bool SkImages::MakeBackendTextureFromImage | ( | GrDirectContext * | context, |
sk_sp< SkImage > | image, | ||
GrBackendTexture * | backendTexture, | ||
BackendTextureReleaseProc * | backendTextureReleaseProc | ||
) |
Extracts the backendTexture from an existing SkImage. If the image is not already GPU-backed, the raster data will be uploaded as a texture and returned. If this is the only reference to the image, the old image's texture will be moved out of the passed in image. If the image is shared (has a refcount > 1), the texture will be copied and then returned.
context | GPU context |
image | image, either CPU-backed or GPU-backed |
backendTexture | Will be set to the underlying texture of the image. |
backendTextureReleaseProc | Called when the texture is released |
Definition at line 67 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::MakeWithFilter | ( | GrRecordingContext * | context, |
sk_sp< SkImage > | src, | ||
const SkImageFilter * | filter, | ||
const SkIRect & | subset, | ||
const SkIRect & | clipBounds, | ||
SkIRect * | outSubset, | ||
SkIPoint * | offset | ||
) |
Creates a filtered SkImage on the GPU. filter processes the src image, potentially changing color, position, and size. subset is the bounds of src that are processed by filter. clipBounds is the expected bounds of the filtered SkImage. outSubset is required storage for the actual bounds of the filtered SkImage. offset is required storage for translation of returned SkImage.
Returns nullptr if SkImage could not be created or if the recording context provided doesn't match the GPU context in which the image was created. If nullptr is returned, outSubset and offset are undefined.
Useful for animation of SkImageFilter that varies size from frame to frame. Returned SkImage is created larger than required by filter so that GPU texture can be reused with different sized effects. outSubset describes the valid bounds of GPU texture returned. offset translates the returned SkImage to keep subsequent animation frames aligned with respect to each other.
context | the GrRecordingContext in play - if it exists |
filter | how SkImage is sampled when transformed |
subset | bounds of SkImage processed by filter |
clipBounds | expected bounds of filtered SkImage |
outSubset | storage for returned SkImage bounds |
offset | storage for returned SkImage translation |
Definition at line 421 of file SkImage_GaneshBase.cpp.
sk_sp< SkImage > SkImages::MakeWithFilter | ( | sk_sp< SkImage > | src, |
const SkImageFilter * | filter, | ||
const SkIRect & | subset, | ||
const SkIRect & | clipBounds, | ||
SkIRect * | outSubset, | ||
SkIPoint * | offset | ||
) |
Creates a filtered SkImage on the CPU. filter processes the src image, potentially changing the color, position, and size. subset is the bounds of src that are processed by filter. clipBounds is the expected bounds of the filtered SkImage. outSubset is required storage for the actual bounds of the filtered SkImage. offset is required storage for translation of returned SkImage.
Returns nullptr a filtered result could not be created. If nullptr is returned, outSubset and offset are undefined.
Useful for animation of SkImageFilter that varies size from frame to frame. outSubset describes the valid bounds of returned image. offset translates the returned SkImage to keep subsequent animation frames aligned with respect to each other.
src | the image to be filtered |
filter | the image filter to be applied |
subset | bounds of SkImage processed by filter |
clipBounds | expected bounds of filtered SkImage |
outSubset | storage for returned SkImage bounds |
offset | storage for returned SkImage translation |
Definition at line 100 of file SkImage_RasterFactories.cpp.
sk_sp< SkImage > SkImages::MakeWithFilter | ( | skgpu::graphite::Recorder * | recorder, |
sk_sp< SkImage > | src, | ||
const SkImageFilter * | filter, | ||
const SkIRect & | subset, | ||
const SkIRect & | clipBounds, | ||
SkIRect * | outSubset, | ||
SkIPoint * | offset | ||
) |
Creates a filtered SkImage on the GPU. filter processes the src image, potentially changing color, position, and size. subset is the bounds of src that are processed by filter. clipBounds is the expected bounds of the filtered SkImage. outSubset is required storage for the actual bounds of the filtered SkImage. offset is required storage for translation of returned SkImage.
Returns nullptr if SkImage could not be created. If nullptr is returned, outSubset and offset are undefined.
Useful for animation of SkImageFilter that varies size from frame to frame. Returned SkImage is created larger than required by filter so that GPU texture can be reused with different sized effects. outSubset describes the valid bounds of GPU texture returned. offset translates the returned SkImage to keep subsequent animation frames aligned with respect to each other.
recorder | the recorder in which the filtering operation is to be performed |
filter | how SkImage is sampled when transformed |
subset | bounds of SkImage processed by filter |
clipBounds | expected bounds of filtered SkImage |
outSubset | storage for returned SkImage bounds |
offset | storage for returned SkImage translation |
Definition at line 298 of file ImageFactories.cpp.
|
static |
Definition at line 167 of file SkImage_GaneshFactories.cpp.
Like SkImagePriv::SkMakeImageFromRasterBitmap, except this can be pinned using skgpu::ganesh::PinAsTexture and CopyPixelMode is never.
Definition at line 54 of file SkImage_RasterPinnable.cpp.
sk_sp< SkImage > SkImages::PromiseTextureFrom | ( | sk_sp< GrContextThreadSafeProxy > | gpuContextProxy, |
const GrBackendFormat & | backendFormat, | ||
SkISize | dimensions, | ||
skgpu::Mipmapped | mipmapped, | ||
GrSurfaceOrigin | origin, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
PromiseImageTextureFulfillProc | textureFulfillProc, | ||
PromiseImageTextureReleaseProc | textureReleaseProc, | ||
PromiseImageTextureContext | textureContext | ||
) |
Create a new GPU-backed SkImage that is very similar to an SkImage created by BorrowTextureFrom. 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 GrDirectContext. Instead of passing a GrBackendTexture the client supplies a description of the texture consisting of GrBackendFormat, width, height, and skgpu::Mipmapped state. The resulting SkImage can be drawn to a GrDeferredDisplayListRecorder 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 cannot be deleted until textureReleaseProc is called. There is at most one call to each of textureFulfillProc and textureReleaseProc. textureReleaseProc 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)
gpuContextProxy | the thread-safe proxy of the gpu context. required. |
backendFormat | format of promised gpu texture |
dimensions | width & height of promised gpu texture |
mipmapped | mip mapped state of promised gpu texture |
origin | surface origin of promised gpu texture |
colorType | color type of promised gpu texture |
alphaType | alpha type of promised gpu texture |
colorSpace | range of colors; may be nullptr |
textureFulfillProc | function called to get actual gpu texture |
textureReleaseProc | function called when texture can be deleted |
textureContext | state passed to textureFulfillProc and textureReleaseProc |
Definition at line 316 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::PromiseTextureFrom | ( | skgpu::graphite::Recorder * | recorder, |
SkISize | dimensions, | ||
const skgpu::graphite::TextureInfo & | textureInfo, | ||
const SkColorInfo & | colorInfo, | ||
skgpu::graphite::Volatile | isVolatile, | ||
GraphitePromiseTextureFulfillProc | fulfillProc, | ||
GraphitePromiseImageReleaseProc | imageReleaseProc, | ||
GraphitePromiseTextureReleaseProc | textureReleaseProc, | ||
GraphitePromiseImageContext | imageContext | ||
) |
Definition at line 218 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::PromiseTextureFrom | ( | skgpu::graphite::Recorder * | recorder, |
SkISize | dimensions, | ||
const skgpu::graphite::TextureInfo & | textureInfo, | ||
const SkColorInfo & | colorInfo, | ||
skgpu::Origin | origin, | ||
skgpu::graphite::Volatile | isVolatile, | ||
GraphitePromiseTextureFulfillProc | fulfillProc, | ||
GraphitePromiseImageReleaseProc | imageReleaseProc, | ||
GraphitePromiseTextureReleaseProc | textureReleaseProc, | ||
GraphitePromiseImageContext | imageContext, | ||
std::string_view | label = {} |
||
) |
Create a new SkImage that is very similar to an SkImage created by WrapTexture. The difference is that the caller need not have created the backend texture nor populated it with data when creating the image. Instead of passing a BackendTexture to the factory the client supplies a description of the texture consisting of dimensions, TextureInfo, SkColorInfo and Volatility.
In general, 'fulfill' must return a BackendTexture that matches the properties provided at SkImage creation time. The BackendTexture must refer to a valid existing texture in the backend API context/device, and already be populated with data. The texture cannot be deleted until 'textureRelease' is called. 'textureRelease' will be called with the textureReleaseContext returned by 'fulfill'.
Wrt when and how often the fulfill, imageRelease, and textureRelease callbacks will be called:
For non-volatile promise images, 'fulfill' will be called at Context::insertRecording time. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease' will always be called only once - when Skia will no longer try calling 'fulfill' to get a backend texture. If 'fulfill' failed (i.e., it didn't return a valid backend texture) then 'textureRelease' will never be called. If 'fulfill' was successful then 'textureRelease' will be called only once when the GPU is done with the contents of the promise image. This will usually occur during a Context::submit call but it could occur earlier due to error conditions. 'fulfill' can be called multiple times if the promise image is used in multiple recordings. If 'fulfill' fails, the insertRecording itself will fail. Subsequent insertRecording calls (with Recordings that use the promise image) will keep calling 'fulfill' until it succeeds.
For volatile promise images, 'fulfill' will be called each time the Recording is inserted into a Context. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease' will always be called only once just like the non-volatile case. If 'fulfill' fails at insertRecording-time, 'textureRelease' will never be called. If 'fulfill' was successful then a 'textureRelease' matching that 'fulfill' will be called when the GPU is done with the contents of the promise image. This will usually occur during a Context::submit call but it could occur earlier due to error conditions.
recorder | the recorder that will capture the commands creating the image |
dimensions | width & height of promised gpu texture |
textureInfo | structural information for the promised gpu texture |
colorInfo | color type, alpha type and colorSpace information for the image |
origin | Whether the Texture logically treats the origin as TopLeft or BottomLeft |
isVolatile | volatility of the promise image |
fulfill | function called to get the actual backend texture, and the instance for the GraphitePromiseTextureReleaseProc |
imageRelease | function called when any image-centric data can be deleted |
textureRelease | function called when the backend texture can be deleted |
imageContext | state passed to fulfill and imageRelease |
Definition at line 165 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::PromiseTextureFromYUVA | ( | sk_sp< GrContextThreadSafeProxy > | gpuContextProxy, |
const GrYUVABackendTextureInfo & | backendTextureInfo, | ||
sk_sp< SkColorSpace > | imageColorSpace, | ||
PromiseImageTextureFulfillProc | textureFulfillProc, | ||
PromiseImageTextureReleaseProc | textureReleaseProc, | ||
PromiseImageTextureContext | textureContexts[] | ||
) |
This is similar to 'PromiseTextureFrom' but it creates a GPU-backed 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. 'backendTextureInfo' describes the planar arrangement, texture formats, conversion to RGB, and origin of the textures. Separate 'textureFulfillProc' and 'textureReleaseProc' calls are made for each texture. Each texture has its own PromiseImageTextureContext. If 'backendTextureInfo' is not valid then no release proc calls are made. Otherwise, the calls will be made even on failure. 'textureContexts' has one entry for each of the up to four textures, as indicated by 'backendTextureInfo'. Currently the mip mapped property of 'backendTextureInfo' is ignored. However, in the near future it will be required that if it is kYes then textureFulfillProc must return a mip mapped texture for each plane in order to successfully draw the image.
gpuContextProxy | the thread-safe proxy of the gpu context. required. |
backendTextureInfo | info about the promised yuva gpu texture |
imageColorSpace | range of colors; may be nullptr |
textureFulfillProc | function called to get actual gpu texture |
textureReleaseProc | function called when texture can be deleted |
textureContexts | state passed to textureFulfillProc and textureReleaseProc |
Definition at line 395 of file SkImage_GaneshYUVA.cpp.
sk_sp< SkImage > SkImages::PromiseTextureFromYUVA | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::YUVABackendTextureInfo & | backendTextureInfo, | ||
sk_sp< SkColorSpace > | imageColorSpace, | ||
skgpu::graphite::Volatile | isVolatile, | ||
GraphitePromiseTextureFulfillProc | fulfillProc, | ||
GraphitePromiseImageReleaseProc | imageReleaseProc, | ||
GraphitePromiseTextureReleaseProc | textureReleaseProc, | ||
GraphitePromiseImageContext | imageContext, | ||
GraphitePromiseTextureFulfillContext | planeContexts[], | ||
std::string_view | label = {} |
||
) |
This is similar to 'PromiseTextureFrom' but it creates a GPU-backed 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. 'backendTextureInfo' describes the planar arrangement, texture formats, and conversion to RGB. Separate 'fulfill' and 'textureRelease' calls are made for each texture. Each texture has its own GraphitePromiseFulfillContext. The GraphitePromiseImageReleaseProc will be made even on failure. 'planeContexts' has one entry for each of the up to four textures, as indicated by 'backendTextureInfo'. Currently the mipmapped property of 'backendTextureInfo' is ignored. However, in the near future it will be required that if it is kYes then the fulfillProc must return a mip mapped texture for each plane in order to successfully draw the image.
recorder | the recorder that will capture the commands creating the image |
backendTextureInfo | info about the promised yuva gpu texture(s) |
imageColorSpace | range of colors; may be nullptr |
isVolatile | volatility of the promise image |
fulfill | function called to get the actual backend texture for a given GraphitePromiseTextureContext, and the instance for the GraphitePromiseTextureReleaseProc |
imageRelease | function called when any image-centric data can be deleted |
textureRelease | function called when the backend texture can be deleted |
imageContext | state passed to imageRelease |
planeContexts | states passed to fulfill for each plane |
Definition at line 239 of file ImageFactories.cpp.
Creates a CPU-backed SkImage from bitmap, sharing or copying bitmap pixels. If the bitmap is marked immutable, and its pixel memory is shareable, it may be shared instead of copied.
SkImage is returned if bitmap is valid. Valid SkBitmap parameters include: dimensions are greater than zero; each dimension fits in 29 bits; SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType; row bytes are large enough to hold one row of pixels; pixel address is not nullptr.
bitmap | SkImageInfo, row bytes, and pixels |
Definition at line 74 of file SkImage_RasterFactories.cpp.
sk_sp< SkImage > SkImages::RasterFromCompressedTextureData | ( | sk_sp< SkData > | data, |
int | width, | ||
int | height, | ||
SkTextureCompressionType | type | ||
) |
Creates a CPU-backed SkImage from compressed data.
This method will decompress the compressed data and create an image wrapping it. Any mipmap levels present in the compressed data are discarded.
data | compressed data to store in SkImage |
width | width of full SkImage |
height | height of full SkImage |
type | type of compression used |
Definition at line 122 of file SkImage_RasterFactories.cpp.
sk_sp< SkImage > SkImages::RasterFromData | ( | const SkImageInfo & | info, |
sk_sp< SkData > | pixels, | ||
size_t | rowBytes | ||
) |
Creates CPU-backed SkImage from pixel data described by info. The pixels data will not be copied.
SkImage is returned if SkImageInfo is valid. Valid SkImageInfo parameters include: dimensions are greater than zero; each dimension fits in 29 bits; SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType; rowBytes are large enough to hold one row of pixels; pixels is not nullptr, and contains enough data for SkImage.
info | contains width, height, SkAlphaType, SkColorType, SkColorSpace |
pixels | address or pixel storage |
rowBytes | size of pixel row or larger |
Definition at line 86 of file SkImage_RasterFactories.cpp.
sk_sp< SkImage > SkImages::RasterFromPixmap | ( | const SkPixmap & | pixmap, |
RasterReleaseProc | rasterReleaseProc, | ||
ReleaseContext | releaseContext | ||
) |
Creates CPU-backed SkImage from pixmap, sharing SkPixmap pixels. Pixels must remain valid and unchanged until rasterReleaseProc is called. rasterReleaseProc is passed releaseContext when SkImage is deleted or no longer refers to pixmap pixels.
Pass nullptr for rasterReleaseProc to share SkPixmap without requiring a callback when SkImage is released. Pass nullptr for releaseContext if rasterReleaseProc does not require state.
SkImage is returned if pixmap is valid. Valid SkPixmap parameters include: dimensions are greater than zero; each dimension fits in 29 bits; SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType; row bytes are large enough to hold one row of pixels; pixel address is not nullptr.
pixmap | SkImageInfo, pixel address, and row bytes |
rasterReleaseProc | function called when pixels can be released; or nullptr |
releaseContext | state passed to rasterReleaseProc; or nullptr |
Definition at line 153 of file SkImage_RasterFactories.cpp.
Creates a CPU-backed SkImage from pixmap, copying the pixel data. As a result, pixmap pixels may be modified or deleted without affecting SkImage.
SkImage is returned if SkPixmap is valid. Valid SkPixmap parameters include: dimensions are greater than zero; each dimension fits in 29 bits; SkColorType and SkAlphaType are valid, and SkColorType is not kUnknown_SkColorType; row bytes are large enough to hold one row of pixels; pixel address is not nullptr.
pixmap | SkImageInfo, pixel address, and row bytes |
example: https://fiddle.skia.org/c/@Image_RasterFromPixmapCopy
Definition at line 82 of file SkImage_RasterFactories.cpp.
sk_sp< SkImage > SkImages::SubsetTextureFrom | ( | GrDirectContext * | context, |
const SkImage * | img, | ||
const SkIRect & | subset | ||
) |
Returns subset of this image as a texture-backed image.
Returns nullptr if any of the following are true:
context | the non-null GrDirectContext to which the subset should be uploaded. |
subset | bounds of returned SkImage |
Definition at line 411 of file SkImage_GaneshBase.cpp.
sk_sp< SkImage > SkImages::SubsetTextureFrom | ( | skgpu::graphite::Recorder * | recorder, |
const SkImage * | img, | ||
const SkIRect & | subset, | ||
SkImage::RequiredProperties | props = {} |
||
) |
Returns subset of this image as a texture-backed image.
Returns nullptr if any of the following are true:
recorder | the non-null recorder in which to create the new image. |
img | Source image |
subset | bounds of returned SkImage |
props | properties the returned SkImage must possess (e.g. mipmaps) |
Definition at line 287 of file ImageFactories.cpp.
SK_API sk_sp< SkImage > SkImages::TextureFromAHardwareBufferWithData | ( | GrDirectContext * | context, |
const SkPixmap & | pixmap, | ||
AHardwareBuffer * | hardwareBuffer, | ||
GrSurfaceOrigin | surfaceOrigin = kTopLeft_GrSurfaceOrigin |
||
) |
Creates SkImage from Android hardware buffer and uploads the data from the SkPixmap to it. Returned SkImage takes a reference on the buffer. Only available on Android, when ANDROID_API is defined to be 26 or greater.
context | GPU context |
pixmap | SkPixmap that contains data to be uploaded to the AHardwareBuffer |
hardwareBuffer | AHardwareBuffer Android hardware buffer |
surfaceOrigin | surface origin for resulting image |
sk_sp< SkImage > SkImages::TextureFromCompressedTexture | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | origin, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
TextureReleaseProc | textureReleaseProc = nullptr , |
||
ReleaseContext | releaseContext = nullptr |
||
) |
Creates a GPU-backed SkImage from a GPU backend texture. The backend texture must stay valid and unchanged until textureReleaseProc is called. The textureReleaseProc is called when the SkImage is deleted or no longer refers to the texture and will be passed the releaseContext. An SkImage is returned if the format of backendTexture is recognized and supported. Recognized formats vary by GPU backend.
context | the GPU context |
backendTexture | a texture already allocated by the GPU |
alphaType | This characterizes the nature of the alpha values in the backend texture. For opaque compressed formats (e.g., ETC1) this should usually be set to kOpaq ue_SkAlphaType. |
colorSpace | This describes the color space of this image's contents, as seen after sampling. In general, if the format of the backend texture is SRGB, some linear colorSpace should be supplied (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the backend texture is linear, then the colorSpace should include a description of the transfer function as well (e.g., SkColorSpace::MakeSRGB()). |
textureReleaseProc | function called when the backend texture can be released |
releaseContext | state passed to textureReleaseProc |
Definition at line 127 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::TextureFromCompressedTextureData | ( | GrDirectContext * | direct, |
sk_sp< SkData > | data, | ||
int | width, | ||
int | height, | ||
SkTextureCompressionType | type, | ||
skgpu::Mipmapped | mipmapped = skgpu::Mipmapped::kNo , |
||
GrProtected | isProtected = GrProtected::kNo |
||
) |
Creates a GPU-backed SkImage from compressed data. This method will return an SkImage representing the compressed data. If the GPU doesn't support the specified compression method, the data will be decompressed and then wrapped in a GPU-backed image. Note: one can query the supported compression formats via GrRecordingContext::compressedBackendFormat.
context | GPU context |
data | compressed data to store in SkImage |
width | width of full SkImage |
height | height of full SkImage |
type | type of compression used |
mipmapped | does 'data' contain data for all the mipmap levels? |
isProtected | do the contents of 'data' require DRM protection (on Vulkan)? |
Definition at line 280 of file SkImage_GaneshFactories.cpp.
sk_sp< SkImage > SkImages::TextureFromImage | ( | GrDirectContext * | dContext, |
const SkImage * | img, | ||
skgpu::Mipmapped | mipmapped = skgpu::Mipmapped::kNo , |
||
skgpu::Budgeted | budgeted = skgpu::Budgeted::kYes |
||
) |
Returns SkImage backed by GPU texture associated with context. Returned SkImage is compatible with SkSurface created with dstColorSpace. The returned SkImage respects mipmapped setting; if mipmapped equals skgpu::Mipmapped::kYes, the backing texture allocates mip map levels. The mipmapped parameter is effectively treated as kNo if MIP maps are not supported by the GPU. Returns original SkImage if the image is already texture-backed, the context matches, and mipmapped is compatible with the backing GPU texture. skgpu::Budgeted is ignored in this case. Returns nullptr if context is nullptr, or if SkImage was created with another GrDirectContext.
GrDirectContext | the GrDirectContext in play, if it exists |
SkImage | a non-null pointer to an SkImage. |
skgpu::Mipmapped | Whether created SkImage texture must allocate mip map levels. Defaults to no. |
skgpu::Budgeted | Whether to count a newly created texture for the returned image counts against the context's budget. Defaults to yes. |
Definition at line 429 of file SkImage_GaneshFactories.cpp.
|
inline |
Definition at line 208 of file SkImageGanesh.h.
sk_sp< SkImage > SkImages::TextureFromImage | ( | skgpu::graphite::Recorder * | recorder, |
const SkImage * | image, | ||
SkImage::RequiredProperties | requiredProps = {} |
||
) |
Returns an SkImage backed by a Graphite texture, using the provided Recorder for creation and uploads if necessary. The returned SkImage respects the required image properties' mipmap setting for non-Graphite SkImages; i.e., if mipmapping is required, the backing Graphite texture will have allocated mip map levels.
It is assumed that MIP maps are always supported by the GPU.
Returns original SkImage if the image is already Graphite-backed and the required mipmapping is compatible with the backing Graphite texture. If the required mipmapping is not compatible, nullptr will be returned.
Returns nullptr if no Recorder is provided, or if SkImage was created with another Recorder and work on that Recorder has not been submitted.
Recorder | the Recorder to use for storing commands |
RequiredProperties | properties the returned SkImage must possess (e.g. mipmaps) |
Definition at line 387 of file ImageFactories.cpp.
|
inline |
Definition at line 254 of file Image.h.
sk_sp< SkImage > SkImages::TextureFromYUVAImages | ( | skgpu::graphite::Recorder * | recorder, |
const SkYUVAInfo & | yuvaInfo, | ||
SkSpan< const sk_sp< SkImage > > | images, | ||
sk_sp< SkColorSpace > | imageColorSpace | ||
) |
Creates an SkImage from YUV[A] planar SkImages associated with the recorder.
The images should have kGraphite type, and the result will be nullptr if any are not. The resulting SkImage will not take a ref on the given SkImages but will take a ref on the underlying TextureProxies. The releaseProcs, if any, for those Textures will be the ones set when the given SkImages were created.
recorder | The recorder. |
yuvaInfo | Structure describing the YUVA format |
images | A set of SkImages containing YUVA data |
imageColorSpace | Range of colors of the resulting image after conversion to RGB; may be nullptr |
Definition at line 513 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVAPixmaps | ( | GrRecordingContext * | context, |
const SkYUVAPixmaps & | pixmaps, | ||
skgpu::Mipmapped | buildMips, | ||
bool | limitToMaxTextureSize, | ||
sk_sp< SkColorSpace > | imageColorSpace | ||
) |
Creates a GPU-backed SkImage from SkYUVAPixmaps. The image will remain planar with each plane converted to a texture using the passed GrRecordingContext. SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB. The SkColorSpace of the resulting RGB values is specified by imageColorSpace. This will be the SkColorSpace reported by the image and when drawn the RGB values will be converted from this space into the destination space (if the destination is tagged). Currently, this is only supported using the GPU backend and will fail if context is nullptr. SkYUVAPixmaps does not need to remain valid after this returns.
context | GPU context |
pixmaps | The planes as pixmaps with supported SkYUVAInfo that specifies conversion to RGB. |
buildMips | create internal YUVA textures as mip map if kYes. This is silently ignored if the context does not support mip maps. |
limitToMaxTextureSize | downscale image to GPU maximum texture size, if necessary |
imageColorSpace | range of colors of the resulting image; may be nullptr |
Definition at line 325 of file SkImage_GaneshYUVA.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVAPixmaps | ( | GrRecordingContext * | context, |
const SkYUVAPixmaps & | pixmaps, | ||
skgpu::Mipmapped | buildMips = skgpu::Mipmapped::kNo , |
||
bool | limitToMaxTextureSize = false |
||
) |
Definition at line 318 of file SkImage_GaneshYUVA.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVAPixmaps | ( | skgpu::graphite::Recorder * | recorder, |
const SkYUVAPixmaps & | pixmaps, | ||
SkImage::RequiredProperties | requiredProps = {} , |
||
bool | limitToMaxTextureSize = false , |
||
sk_sp< SkColorSpace > | imgColorSpace = nullptr , |
||
std::string_view | label = {} |
||
) |
Creates SkImage from SkYUVAPixmaps.
The image will remain planar with each plane converted to a texture using the passed Recorder.
SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB. The SkColorSpace of the resulting RGB values is specified by imgColorSpace. This will be the SkColorSpace reported by the image and when drawn the RGB values will be converted from this space into the destination space (if the destination is tagged).
This is only supported using the GPU backend and will fail if recorder is nullptr.
SkYUVAPixmaps does not need to remain valid after this returns.
Recorder | The Recorder to use for storing commands |
pixmaps | The planes as pixmaps with supported SkYUVAInfo that specifies conversion to RGB. |
RequiredProperties | Properties the returned SkImage must possess (e.g. mipmaps) |
limitToMaxTextureSize | Downscale image to GPU maximum texture size, if necessary |
imgColorSpace | Range of colors of the resulting image; may be nullptr |
Definition at line 418 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVATextures | ( | GrRecordingContext * | context, |
const GrYUVABackendTextures & | yuvaTextures | ||
) |
Definition at line 282 of file SkImage_GaneshYUVA.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVATextures | ( | GrRecordingContext * | context, |
const GrYUVABackendTextures & | yuvaTextures, | ||
sk_sp< SkColorSpace > | imageColorSpace, | ||
TextureReleaseProc | textureReleaseProc = nullptr , |
||
ReleaseContext | releaseContext = nullptr |
||
) |
Creates a GPU-backed SkImage from YUV[A] planar textures. This requires that the textures stay valid for the lifetime of the image. The ReleaseContext can be used to know when it is safe to either delete or overwrite the textures. If ReleaseProc is provided it is also called before return on failure.
context | GPU context |
yuvaTextures | A set of textures containing YUVA data and a description of the data and transformation to RGBA. |
imageColorSpace | range of colors of the resulting image after conversion to RGB; may be nullptr |
textureReleaseProc | called when the backend textures can be released |
releaseContext | state passed to textureReleaseProc |
Definition at line 287 of file SkImage_GaneshYUVA.cpp.
sk_sp< SkImage > SkImages::TextureFromYUVATextures | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::YUVABackendTextures & | yuvaBackendTextures, | ||
sk_sp< SkColorSpace > | imageColorSpace, | ||
TextureReleaseProc | releaseP = nullptr , |
||
ReleaseContext | releaseC = nullptr , |
||
std::string_view | label = {} |
||
) |
Creates an SkImage from YUV[A] planar textures associated with the recorder.
recorder | The recorder. |
yuvaBackendTextures | A set of textures containing YUVA data and a description of the data and transformation to RGBA. |
imageColorSpace | range of colors of the resulting image after conversion to RGB; may be nullptr |
TextureReleaseProc | called when the backend textures can be released |
ReleaseContext | state passed to TextureReleaseProc |
Definition at line 479 of file ImageFactories.cpp.
|
static |
Definition at line 48 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::WrapTexture | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::BackendTexture & | backendTex, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
skgpu::Origin | origin, | ||
GenerateMipmapsFromBase | generateMipmapsFromBase, | ||
TextureReleaseProc | releaseP = nullptr , |
||
ReleaseContext | releaseC = nullptr , |
||
std::string_view | label = {} |
||
) |
Creates an SkImage from a GPU texture associated with the recorder. The client is still responsible for managing the backend texture's lifetime.
SkImage is returned if the format of backendTexture is recognized and supported. Recognized formats vary by GPU back-end.
recorder | The recorder |
backendTexture | texture residing on GPU |
colorSpace | This describes the color space of this image's contents, as seen after sampling. In general, if the format of the backend texture is SRGB, some linear colorSpace should be supplied (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the backend texture is linear, then the colorSpace should include a description of the transfer function as well (e.g., SkColorSpace::MakeSRGB()). |
origin | Whether the Texture logically treats the origin as TopLeft or BottomLeft |
generateMipmapsFromBase | If kYes then the pixel contents of the textures upper mipmap levels are generated by successive downsampling of the base level. If the texture is not mipmapped or isn't renderable then image creation will fail. If kNo and the texture is mipmapped then the contents of upper levels are assumed to already be valid. |
Definition at line 67 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::WrapTexture | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::BackendTexture & | backendTex, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
skgpu::Origin | origin, | ||
TextureReleaseProc | releaseP = nullptr , |
||
ReleaseContext | releaseC = nullptr , |
||
std::string_view | label = {} |
||
) |
Definition at line 124 of file ImageFactories.cpp.
sk_sp< SkImage > SkImages::WrapTexture | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::BackendTexture & | backendTex, | ||
SkColorType | colorType, | ||
SkAlphaType | alphaType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
TextureReleaseProc | releaseP = nullptr , |
||
ReleaseContext | releaseC = nullptr , |
||
std::string_view | label = {} |
||
) |
Definition at line 145 of file ImageFactories.cpp.