Skia
2D Graphics Library
SkSurfaces Namespace Reference

Typedefs

using PixelsReleaseProc = void(void *pixels, void *context)
 

Enumerations

enum class  BackendSurfaceAccess { kNoAccess , kPresent }
 

Functions

SK_API sk_sp< SkSurfaceNull (int width, int height)
 Returns SkSurface without backing pixels. More...
 
SK_API sk_sp< SkSurfaceRaster (const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
 Allocates raster SkSurface. More...
 
sk_sp< SkSurfaceRaster (const SkImageInfo &imageInfo, const SkSurfaceProps *props=nullptr)
 
SK_API sk_sp< SkSurfaceWrapPixels (const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
 Allocates raster SkSurface. More...
 
sk_sp< SkSurfaceWrapPixels (const SkPixmap &pm, const SkSurfaceProps *props=nullptr)
 
SK_API sk_sp< SkSurfaceWrapPixels (const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, PixelsReleaseProc, void *context, const SkSurfaceProps *surfaceProps=nullptr)
 Allocates raster SkSurface. More...
 

Typedef Documentation

◆ PixelsReleaseProc

using SkSurfaces::PixelsReleaseProc = typedef void(void* pixels, void* context)

Enumeration Type Documentation

◆ BackendSurfaceAccess

Enumerator
kNoAccess 

back-end surface will not be used by client

kPresent 

back-end surface will be used for presenting to screen

Function Documentation

◆ Null()

SK_API sk_sp<SkSurface> SkSurfaces::Null ( int  width,
int  height 
)

Returns SkSurface without backing pixels.

Drawing to SkCanvas returned from SkSurface has no effect. Calling makeImageSnapshot() on returned SkSurface returns nullptr.

Parameters
widthone or greater
heightone or greater
Returns
SkSurface if width and height are positive; otherwise, nullptr

example: https://fiddle.skia.org/c/@Surface_MakeNull

◆ Raster() [1/2]

sk_sp<SkSurface> SkSurfaces::Raster ( const SkImageInfo imageInfo,
const SkSurfaceProps props = nullptr 
)
inline

◆ Raster() [2/2]

SK_API 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:

  • info dimensions are greater than zero;
  • info contains SkColorType and SkAlphaType supported by raster surface.
Parameters
imageInfowidth, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero
rowBytesinterval from one SkSurface row to the next.
propsLCD striping orientation and setting for device independent fonts; may be nullptr
Returns
SkSurface if parameters are valid and memory was allocated, else nullptr.

◆ WrapPixels() [1/3]

SK_API 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().

Parameters
imageInfowidth, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero
pixelspointer to destination pixels buffer
rowBytesinterval from one SkSurface row to the next
surfacePropsLCD striping orientation and setting for device independent fonts; may be nullptr
Returns
SkSurface if all parameters are valid; otherwise, nullptr

◆ WrapPixels() [2/3]

SK_API sk_sp<SkSurface> SkSurfaces::WrapPixels ( const SkImageInfo imageInfo,
void *  pixels,
size_t  rowBytes,
PixelsReleaseProc  ,
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().

Parameters
imageInfowidth, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface; width and height must be greater than zero
pixelspointer to destination pixels buffer
rowBytesinterval from one SkSurface row to the next
releaseProccalled when SkSurface is deleted; may be nullptr
contextpassed to releaseProc; may be nullptr
surfacePropsLCD striping orientation and setting for device independent fonts; may be nullptr
Returns
SkSurface if all parameters are valid; otherwise, nullptr

◆ WrapPixels() [3/3]

sk_sp<SkSurface> SkSurfaces::WrapPixels ( const SkPixmap pm,
const SkSurfaceProps props = nullptr 
)
inline