Flutter Engine
The Flutter Engine
|
Typedefs | |
using | ReleaseContext = void * |
using | BufferReleaseProc = void(*)(ReleaseContext) |
using | PixelsReleaseProc = void(void *pixels, void *context) |
using | RenderTargetReleaseProc = void(*)(ReleaseContext) |
using | TextureReleaseProc = void(*)(ReleaseContext) |
using | BackendHandleAccess = SkSurface::BackendHandleAccess |
Enumerations | |
enum class | BackendSurfaceAccess { kNoAccess , kPresent } |
using SkSurfaces::BackendHandleAccess = typedef SkSurface::BackendHandleAccess |
Definition at line 167 of file SkSurfaceGanesh.h.
using SkSurfaces::BufferReleaseProc = typedef void (*)(ReleaseContext) |
Definition at line 25 of file SurfaceAndroid.h.
using SkSurfaces::PixelsReleaseProc = typedef void(void* pixels, void* context) |
Definition at line 116 of file SkSurface.h.
typedef void * SkSurfaces::ReleaseContext |
Caller data passed to RenderTarget/TextureReleaseProc; may be nullptr.
Definition at line 24 of file SurfaceAndroid.h.
using SkSurfaces::RenderTargetReleaseProc = typedef void (*)(ReleaseContext) |
User function called when supplied render target may be deleted.
Definition at line 34 of file SkSurfaceGanesh.h.
typedef void(* SkSurfaces::TextureReleaseProc)(ReleaseContext) |
User function called when supplied texture may be deleted.
Definition at line 37 of file SkSurfaceGanesh.h.
|
strong |
Enumerator | |
---|---|
kNoAccess | back-end surface will not be used by client |
kPresent | back-end surface will be used for presenting to screen |
Definition at line 44 of file SkSurface.h.
The 'AsImage' and 'AsImageCopy' API/entry points are currently only available for Graphite.
In this API, SkSurface no longer supports copy-on-write behavior. Instead, when creating an image for a surface, the client must explicitly indicate if a copy should be made. In both of the below calls the resource backing the surface will never change.
The 'AsImage' entry point has some major ramifications for the mutability of the returned SkImage. Since the originating surface and the returned image share the same backing, care must be taken by the client to ensure that the contents of the image reflect the desired contents when it is consumed by the gpu. Note: if the backing GPU buffer isn't textureable this method will return null. Graphite will not attempt to make a copy. Note: For 'AsImage', the mipmapping of the image will match that of the source surface.
The 'AsImageCopy' entry point allows subsetting and the addition of mipmaps (since a copy is already being made).
In Graphite, the legacy API call (i.e., makeImageSnapshot) will just always make a copy.
Definition at line 186 of file Surface_Graphite.cpp.
sk_sp< SkImage > SkSurfaces::AsImageCopy | ( | sk_sp< const SkSurface > | surface, |
const SkIRect * | subset = nullptr , |
||
skgpu::Mipmapped | mipmapped = skgpu::Mipmapped::kNo |
||
) |
Definition at line 198 of file Surface_Graphite.cpp.
GrBackendRenderTarget SkSurfaces::GetBackendRenderTarget | ( | SkSurface * | surface, |
BackendHandleAccess | access | ||
) |
Retrieves the back-end render target. If SkSurface has no back-end render target, an invalid object is returned. Call GrBackendRenderTarget::isValid to determine if the result is valid.
The returned GrBackendRenderTarget should be discarded if the SkSurface is drawn to or deleted.
Definition at line 751 of file SkSurface_Ganesh.cpp.
GrBackendTexture SkSurfaces::GetBackendTexture | ( | SkSurface * | surface, |
BackendHandleAccess | access | ||
) |
Retrieves the back-end texture. If SkSurface has no back-end texture, an invalid object is returned. Call GrBackendTexture::isValid to determine if the result is valid.
The returned GrBackendTexture should be discarded if the SkSurface is drawn to or deleted.
Definition at line 740 of file SkSurface_Ganesh.cpp.
Returns SkSurface without backing pixels. Drawing to SkCanvas returned from SkSurface has no effect. Calling makeImageSnapshot() on returned SkSurface returns nullptr.
width | one or greater |
height | one or greater |
example: https://fiddle.skia.org/c/@Surface_MakeNull
Definition at line 52 of file SkSurface_Null.cpp.
|
inline |
Definition at line 80 of file SkSurface.h.
sk_sp< SkSurface > SkSurfaces::Raster | ( | const SkImageInfo & | imageInfo, |
size_t | rowBytes, | ||
const SkSurfaceProps * | surfaceProps | ||
) |
Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into those allocated pixels, which are zeroed before use. Pixel memory size is imageInfo.height() times imageInfo.minRowBytes() or rowBytes, if provided and non-zero.
Pixel memory is deleted when SkSurface is deleted.
Validity constraints include:
imageInfo | width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero |
rowBytes | interval from one SkSurface row to the next. |
props | LCD striping orientation and setting for device independent fonts; may be nullptr |
Definition at line 186 of file SkSurface_Raster.cpp.
sk_sp< SkSurface > SkSurfaces::RenderTarget | ( | GrRecordingContext * | context, |
const GrSurfaceCharacterization & | characterization, | ||
skgpu::Budgeted | budgeted | ||
) |
Returns SkSurface on GPU indicated by context that is compatible with the provided characterization. budgeted selects whether allocation for pixels is tracked by context.
context | GPU context |
characterization | description of the desired SkSurface |
Definition at line 553 of file SkSurface_Ganesh.cpp.
|
inline |
Definition at line 80 of file SkSurfaceGanesh.h.
|
inline |
Definition at line 72 of file SkSurfaceGanesh.h.
sk_sp< SkSurface > SkSurfaces::RenderTarget | ( | GrRecordingContext * | context, |
skgpu::Budgeted | budgeted, | ||
const SkImageInfo & | imageInfo, | ||
int | sampleCount, | ||
GrSurfaceOrigin | surfaceOrigin, | ||
const SkSurfaceProps * | surfaceProps, | ||
bool | shouldCreateWithMips = false , |
||
bool | isProtected = false |
||
) |
Returns SkSurface on GPU indicated by context. Allocates memory for pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted selects whether allocation for pixels is tracked by context. imageInfo describes the pixel format in SkColorType, and transparency in SkAlphaType, and color matching in SkColorSpace.
sampleCount requests the number of samples per pixel. Pass zero to disable multi-sample anti-aliasing. The request is rounded up to the next supported count, or rounded down if it is larger than the maximum supported count.
surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
context | GPU context |
imageInfo | width, height, SkColorType, SkAlphaType, SkColorSpace; width, or height, or both, may be zero |
sampleCount | samples per pixel, or 0 to disable full scene anti-aliasing |
surfaceOrigin | How to align the pixel data. |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
shouldCreateWithMips | hint that SkSurface will host mip map images |
Definition at line 592 of file SkSurface_Ganesh.cpp.
sk_sp< SkSurface > SkSurfaces::RenderTarget | ( | skgpu::graphite::Recorder * | recorder, |
const SkImageInfo & | imageInfo, | ||
skgpu::Mipmapped | mipmapped = skgpu::Mipmapped::kNo , |
||
const SkSurfaceProps * | surfaceProps = nullptr , |
||
std::string_view | label = {} |
||
) |
In Graphite, while clients hold a ref on an SkSurface, the backing gpu object does not count against the budget. Once an SkSurface is freed, the backing gpu object may or may not become a scratch (i.e., reusable) resource but, if it does, it will be counted against the budget.
Definition at line 212 of file Surface_Graphite.cpp.
Definition at line 202 of file SkSurfaceGanesh.h.
void SkSurfaces::ResolveMSAA | ( | SkSurface * | surface | ) |
If a surface is a Ganesh-backed surface, is being drawn with MSAA, and there is a resolve texture, this call will insert a resolve command into the stream of gpu commands. In order for the resolve to actually have an effect, the work still needs to be flushed and submitted to the GPU after recording the resolve command. If a resolve is not supported or the SkSurface has no dirty work to resolve, then this call is a no-op.
This call is most useful when the SkSurface is created by wrapping a single sampled gpu texture, but asking Skia to render with MSAA. If the client wants to use the wrapped texture outside of Skia, the only way to trigger a resolve is either to call this command or use GrDirectContext::flush.
Definition at line 762 of file SkSurface_Ganesh.cpp.
SK_API sk_sp< SkSurface > SkSurfaces::WrapAndroidHardwareBuffer | ( | GrDirectContext * | context, |
AHardwareBuffer * | hardwareBuffer, | ||
GrSurfaceOrigin | origin, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps, | ||
bool | fromWindow = false |
||
) |
Private; only to be used by Android Framework. Creates SkSurface from Android hardware buffer. Returned SkSurface takes a reference on the buffer. The ref on the buffer will be released when the SkSurface is destroyed and there is no pending work on the GPU involving the buffer.
Currently this is only supported for buffers that can be textured as well as rendered to. In other words that must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
context | GPU context |
hardwareBuffer | AHardwareBuffer Android hardware buffer |
colorSpace | range of colors; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
fromWindow | Whether or not the AHardwareBuffer is part of an Android Window. Currently only used with Vulkan backend. |
SK_API sk_sp< SkSurface > SkSurfaces::WrapAndroidHardwareBuffer | ( | skgpu::graphite::Recorder * | recorder, |
AHardwareBuffer * | hardwareBuffer, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps, | ||
BufferReleaseProc | = nullptr , |
||
ReleaseContext | = nullptr , |
||
bool | fromWindow = false |
||
) |
Private; only to be used by Android Framework. Creates an SkSurface from an Android hardware buffer.
Upon success bufferReleaseProc is called when it is safe to delete the buffer in the backend API (accounting only for use of the buffer by this surface). If SkSurface creation fails bufferReleaseProc is called before this function returns.
Currently this is only supported for buffers that can be textured as well as rendered to. In other words the buffer must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
recorder | the applicable Graphite recorder |
hardwareBuffer | an Android hardware buffer |
colorSpace | range of colors; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
bufferReleaseProc | function called when the buffer can be released |
ReleaseContext | state passed to bufferReleaseProc |
fromWindow | Whether or not the AHardwareBuffer is part of an Android Window. Currently only used with Vulkan backend. |
sk_sp< SkSurface > SkSurfaces::WrapBackendRenderTarget | ( | GrRecordingContext * | context, |
const GrBackendRenderTarget & | backendRenderTarget, | ||
GrSurfaceOrigin | origin, | ||
SkColorType | colorType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps, | ||
RenderTargetReleaseProc | releaseProc = nullptr , |
||
ReleaseContext | releaseContext = nullptr |
||
) |
Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget is valid for the lifetime of returned SkSurface.
SkSurface is returned if all parameters are valid. backendRenderTarget is valid if its pixel configuration agrees with colorSpace and context; for instance, if backendRenderTarget has an sRGB configuration, then context must support sRGB, and colorSpace must be present. Further, backendRenderTarget width and height must not exceed context capabilities, and the context must be able to support back-end render targets.
Upon success releaseProc is called when it is safe to delete the render target in the backend API (accounting only for use of the render target by this surface). If SkSurface creation fails releaseProc is called before this function returns.
context | GPU context |
backendRenderTarget | GPU intermediate memory buffer |
colorSpace | range of colors |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
releaseProc | function called when backendRenderTarget can be released |
releaseContext | state passed to releaseProc |
Definition at line 698 of file SkSurface_Ganesh.cpp.
sk_sp< SkSurface > SkSurfaces::WrapBackendTexture | ( | GrRecordingContext * | context, |
const GrBackendTexture & | backendTexture, | ||
GrSurfaceOrigin | origin, | ||
int | sampleCnt, | ||
SkColorType | colorType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps, | ||
TextureReleaseProc | textureReleaseProc = nullptr , |
||
ReleaseContext | releaseContext = nullptr |
||
) |
Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is valid for the lifetime of returned SkSurface. If sampleCnt greater than zero, creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
SkSurface is returned if all parameters are valid. backendTexture is valid if its pixel configuration agrees with colorSpace and context; for instance, if backendTexture has an sRGB configuration, then context must support sRGB, and colorSpace must be present. Further, backendTexture width and height must not exceed context capabilities, and the context must be able to support back-end textures.
Upon success textureReleaseProc is called when it is safe to delete the texture in the backend API (accounting only for use of the texture by this surface). If SkSurface creation fails textureReleaseProc is called before this function returns.
context | GPU context |
backendTexture | texture residing on GPU |
sampleCnt | samples per pixel, or 0 to disable full scene anti-aliasing |
colorSpace | range of colors; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
textureReleaseProc | function called when texture can be released |
releaseContext | state passed to textureReleaseProc |
Definition at line 626 of file SkSurface_Ganesh.cpp.
sk_sp< SkSurface > SkSurfaces::WrapBackendTexture | ( | skgpu::graphite::Recorder * | recorder, |
const skgpu::graphite::BackendTexture & | backendTex, | ||
SkColorType | colorType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | props, | ||
TextureReleaseProc | releaseP = nullptr , |
||
ReleaseContext | releaseC = nullptr , |
||
std::string_view | label = {} |
||
) |
Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may be required to ensure the texture is valid for the lifetime of the returned SkSurface. The required lifetimes for the specific apis are: Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once this call returns.
SkSurface is returned if all the parameters are valid. The backendTexture is valid if its format agrees with colorSpace and recorder; for instance, if backendTexture has an sRGB configuration, then the recorder must support sRGB, and colorSpace must be present. Further, backendTexture's width and height must not exceed the recorder's capabilities, and the recorder must be able to support the back-end texture.
Definition at line 225 of file Surface_Graphite.cpp.
sk_sp< SkSurface > SkSurfaces::WrapCAMetalLayer | ( | GrRecordingContext * | context, |
GrMTLHandle | layer, | ||
GrSurfaceOrigin | origin, | ||
int | sampleCnt, | ||
SkColorType | colorType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps, | ||
GrMTLHandle * | drawable | ||
) |
Creates SkSurface from CAMetalLayer. Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be released when the SkSurface is destroyed.
Only available when Metal API is enabled.
Will grab the current drawable from the layer and use its texture as a backendRT to create a renderable surface.
context | GPU context |
layer | GrMTLHandle (expected to be a CAMetalLayer*) |
sampleCnt | samples per pixel, or 0 to disable full scene anti-aliasing |
colorSpace | range of colors; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
drawable | Pointer to drawable to be filled in when this surface is instantiated; may not be nullptr |
Definition at line 31 of file SkSurface_GaneshMtl.mm.
sk_sp< SkSurface > SkSurfaces::WrapMTKView | ( | GrRecordingContext * | context, |
GrMTLHandle | mtkView, | ||
GrSurfaceOrigin | origin, | ||
int | sampleCnt, | ||
SkColorType | colorType, | ||
sk_sp< SkColorSpace > | colorSpace, | ||
const SkSurfaceProps * | surfaceProps | ||
) |
Creates SkSurface from MTKView. Returned SkSurface takes a reference on the MTKView. The ref on the layer will be released when the SkSurface is destroyed.
Only available when Metal API is enabled.
Will grab the current drawable from the layer and use its texture as a backendRT to create a renderable surface.
context | GPU context |
layer | GrMTLHandle (expected to be a MTKView*) |
sampleCnt | samples per pixel, or 0 to disable full scene anti-aliasing |
colorSpace | range of colors; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
Definition at line 104 of file SkSurface_GaneshMtl.mm.
sk_sp< SkSurface > SkSurfaces::WrapPixels | ( | const SkImageInfo & | imageInfo, |
void * | pixels, | ||
size_t | rowBytes, | ||
const SkSurfaceProps * | surfaceProps = nullptr |
||
) |
Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into the provided pixels.
SkSurface is returned if all parameters are valid. Valid parameters include: info dimensions are greater than zero; info contains SkColorType and SkAlphaType supported by raster surface; pixels is not nullptr; rowBytes is large enough to contain info width pixels of SkColorType.
Pixel buffer size should be info height times computed rowBytes. Pixels are not initialized. To access pixels after drawing, peekPixels() or readPixels().
imageInfo | width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero |
pixels | pointer to destination pixels buffer |
rowBytes | interval from one SkSurface row to the next |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
Definition at line 179 of file SkSurface_Raster.cpp.
sk_sp< SkSurface > SkSurfaces::WrapPixels | ( | const SkImageInfo & | imageInfo, |
void * | pixels, | ||
size_t | rowBytes, | ||
PixelsReleaseProc | releaseProc, | ||
void * | context, | ||
const SkSurfaceProps * | surfaceProps = nullptr |
||
) |
Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into the provided pixels. releaseProc is called with pixels and context when SkSurface is deleted.
SkSurface is returned if all parameters are valid. Valid parameters include: info dimensions are greater than zero; info contains SkColorType and SkAlphaType supported by raster surface; pixels is not nullptr; rowBytes is large enough to contain info width pixels of SkColorType.
Pixel buffer size should be info height times computed rowBytes. Pixels are not initialized. To access pixels after drawing, call flush() or peekPixels().
imageInfo | width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero |
pixels | pointer to destination pixels buffer |
rowBytes | interval from one SkSurface row to the next |
releaseProc | called when SkSurface is deleted; may be nullptr |
context | passed to releaseProc; may be nullptr |
surfaceProps | LCD striping orientation and setting for device independent fonts; may be nullptr |
Definition at line 160 of file SkSurface_Raster.cpp.
|
inline |
Definition at line 112 of file SkSurface.h.