Skia
2D Graphics Library
|
Typedefs | |
using | ReleaseContext = void * |
Caller data passed to RasterReleaseProc; may be nullptr. More... | |
using | RasterReleaseProc = void(const void *pixels, ReleaseContext) |
Function called when SkImage no longer shares pixels. More... | |
Enumerations | |
enum class | BitDepth { kU8 , kF16 } |
Functions | |
SK_API sk_sp< SkImage > | RasterFromBitmap (const SkBitmap &bitmap) |
Creates a CPU-backed SkImage from bitmap, sharing or copying bitmap pixels. More... | |
SK_API sk_sp< SkImage > | RasterFromCompressedTextureData (sk_sp< SkData > data, int width, int height, SkTextureCompressionType type) |
Creates a CPU-backed SkImage from compressed data. More... | |
SK_API sk_sp< SkImage > | 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. More... | |
SK_API sk_sp< SkImage > | DeferredFromGenerator (std::unique_ptr< SkImageGenerator > imageGenerator) |
Creates SkImage from data returned by imageGenerator. More... | |
SK_API sk_sp< SkImage > | 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. More... | |
SK_API sk_sp< SkImage > | DeferredFromPicture (sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace) |
SK_API sk_sp< SkImage > | RasterFromPixmapCopy (const SkPixmap &pixmap) |
Creates a CPU-backed SkImage from pixmap, copying the pixel data. More... | |
SK_API sk_sp< SkImage > | RasterFromPixmap (const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext) |
Creates CPU-backed SkImage from pixmap, sharing SkPixmap pixels. More... | |
SK_API sk_sp< SkImage > | RasterFromData (const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes) |
Creates CPU-backed SkImage from pixel data described by info. More... | |
SK_API sk_sp< SkImage > | 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. More... | |
using SkImages::RasterReleaseProc = typedef void(const void* pixels, ReleaseContext) |
using SkImages::ReleaseContext = typedef void* |
Caller data passed to RasterReleaseProc; may be nullptr.
|
strong |
SK_API 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.
encoded | the encoded data |
example: https://fiddle.skia.org/c/@Image_DeferredFromEncodedData
SK_API 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 |
SK_API sk_sp<SkImage> SkImages::DeferredFromPicture | ( | sk_sp< SkPicture > | picture, |
const SkISize & | dimensions, | ||
const SkMatrix * | matrix, | ||
const SkPaint * | paint, | ||
BitDepth | bitDepth, | ||
sk_sp< SkColorSpace > | colorSpace | ||
) |
SK_API 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 |
SK_API 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 |
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 |
SK_API 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 |
SK_API 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 |
SK_API 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 |
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