 |
Skia
2D Graphics Library
|
Go to the documentation of this file.
8 #ifndef SkSurface_DEFINED
9 #define SkSurface_DEFINED
18 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
19 #include <android/hardware_buffer.h>
23 #include "include/gpu/mtl/GrMtlTypes.h"
105 void (*releaseProc)(
void* pixels,
void* context),
149 return MakeRaster(imageInfo, 0, props);
215 TextureReleaseProc textureReleaseProc =
nullptr,
249 RenderTargetReleaseProc releaseProc =
nullptr,
252 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
273 AHardwareBuffer* hardwareBuffer,
306 GrMTLHandle* drawable)
307 SK_API_AVAILABLE_CA_METAL_LAYER;
366 bool shouldCreateWithMips =
false);
392 return MakeRenderTarget(context, budgeted, imageInfo, sampleCount,
455 int width()
const {
return fWidth; }
509 kFlushRead_BackendHandleAccess;
514 kFlushWrite_BackendHandleAccess;
519 kDiscardWrite_BackendHandleAccess;
560 TextureReleaseProc textureReleaseProc =
nullptr,
1003 bool deleteSemaphoresAfterWait =
true);
1052 uint32_t fGenerationID;
Definition: GrRecordingContext.h:34
@ kRetain_ContentChangeMode
preserves surface on change
Definition: SkSurface.h:482
void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
Similar to asyncRescaleAndReadPixels but performs an additional conversion to YUV.
int height() const
Returns pixel row count; may be zero or greater.
Definition: SkSurface.h:461
void flushAndSubmit(bool syncCpu=false)
Call to ensure all reads/writes of the surface have been issued to the underlying 3D API.
int height() const
Returns pixel row count.
Definition: SkImageInfo.h:458
GrSemaphoresSubmitted
Enum used as return value when flush with semaphores so the client knows whether the valid semaphores...
Definition: GrTypes.h:284
Definition: SkRefCnt.h:118
const SkSurfaceProps & props() const
Returns SkSurfaceProps for surface.
Definition: SkSurface.h:875
static sk_sp< SkSurface > MakeFromBackendRenderTarget(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.
@ kFlushWrite_BackendHandleAccess
back-end object is writable
Definition: SkSurface.h:502
void asyncRescaleAndReadPixels(const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
Makes surface pixel data available to caller, possibly asynchronously.
Definition: SkSurface.h:46
SkYUVColorSpace
Definition: SkImageInfo.h:148
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:198
static sk_sp< SkSurface > MakeFromBackendTexture(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.
void * writable_addr() const
Returns writable base pixel address.
Definition: SkPixmap.h:455
SkImageInfo imageInfo()
Returns an ImageInfo describing the surface.
static sk_sp< SkSurface > MakeRaster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
Allocates raster SkSurface.
@ kDiscard_ContentChangeMode
discards surface on change
Definition: SkSurface.h:481
void draw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint)
Draws SkSurface contents to canvas, with its top-left corner at (x, y).
bool peekPixels(SkPixmap *pixmap)
Copies SkSurface pixel address, row bytes, and SkImageInfo to SkPixmap, if address is available,...
void draw(SkCanvas *canvas, SkScalar x, SkScalar y)
Definition: SkSurface.h:631
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
Client-provided callback to asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420() that is ...
Definition: SkSurface.h:754
SkSurface(const SkImageInfo &imageInfo, const SkSurfaceProps *surfaceProps)
void notifyContentWillChange(ContentChangeMode mode)
Notifies that SkSurface contents will be changed by code outside of Skia.
SkSurface(int width, int height, const SkSurfaceProps *surfaceProps)
RescaleMode
Definition: SkImage.h:832
Definition: GrBackendSurface.h:61
static sk_sp< SkSurface > MakeRasterN32Premul(int width, int height, const SkSurfaceProps *surfaceProps=nullptr)
Allocates raster SkSurface.
BackendHandleAccess
Definition: SkSurface.h:500
SkCanvas * getCanvas()
Returns SkCanvas that draws into SkSurface.
void flush()
Definition: SkSurface.h:985
sk_sp< SkImage > makeImageSnapshot(const SkIRect &bounds)
Like the no-parameter version, this returns an image of the current surface contents.
@ kDiscardWrite_BackendHandleAccess
back-end object must be overwritten
Definition: SkSurface.h:503
GrSemaphoresSubmitted flush(BackendSurfaceAccess access, const GrFlushInfo &info)
Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface MSAA.
static sk_sp< SkSurface > MakeRenderTarget(GrRecordingContext *context, const SkSurfaceCharacterization &characterization, SkBudgeted budgeted)
Returns SkSurface on GPU indicated by context that is compatible with the provided characterization.
static sk_sp< SkSurface > MakeRasterDirect(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
Allocates raster SkSurface.
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:215
Definition: SkSamplingOptions.h:50
size_t rowBytes() const
Returns row bytes, the interval from one pixel row to the next.
Definition: SkPixmap.h:136
void * ReleaseContext
Caller data passed to RenderTarget/TextureReleaseProc; may be nullptr.
Definition: SkSurface.h:174
Struct to supply options to flush calls.
Definition: GrTypes.h:271
GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess backendHandleAccess)
Retrieves the back-end render target.
sk_sp< SkSurface > makeSurface(const SkImageInfo &imageInfo)
Returns a compatible SkSurface, or nullptr.
#define SK_API
Definition: SkTypes.h:181
GrSemaphoresSubmitted flush(const GrFlushInfo &info, const GrBackendSurfaceMutableState *newState=nullptr)
Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface MSAA.
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:51
static sk_sp< SkSurface > MakeRenderTarget(GrRecordingContext *context, SkBudgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false)
Returns SkSurface on GPU indicated by context.
Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
Definition: GrBackendSemaphore.h:23
Definition: SkImageInfo.h:283
sk_sp< SkSurface > makeSurface(int width, int height)
Calls makeSurface(ImageInfo) with the same ImageInfo as this surface, but with the specified width an...
void writePixels(const SkBitmap &src, int dstX, int dstY)
Copies SkRect of pixels from the src SkBitmap to the SkSurface.
Definition: SkCanvas.h:90
static sk_sp< SkSurface > MakeNull(int width, int height)
Returns SkSurface without backing pixels.
ContentChangeMode
Definition: SkSurface.h:480
static sk_sp< SkSurface > MakeRasterDirect(const SkPixmap &pm, const SkSurfaceProps *props=nullptr)
Definition: SkSurface.h:74
float SkScalar
Definition: SkScalar.h:16
void draw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkPaint *paint)
SkBudgeted
Indicates whether an allocation should count against a cache budget.
Definition: SkTypes.h:594
GrBackendTexture getBackendTexture(BackendHandleAccess backendHandleAccess)
Retrieves the back-end texture.
sk_sp< SkImage > makeImageSnapshot()
Returns SkImage capturing SkSurface contents.
int width() const
Returns pixel count in each row.
Definition: SkImageInfo.h:452
Definition: SkPixmap.h:31
RescaleGamma
Definition: SkImage.h:830
Definition: SkDeferredDisplayList.h:32
Definition: GrDirectContext.h:47
bool isCompatible(const SkSurfaceCharacterization &characterization) const
Is this surface compatible with the provided characterization?
bool draw(sk_sp< const SkDeferredDisplayList > deferredDisplayList, int xOffset=0, int yOffset=0)
Draws the deferred display list created via a SkDeferredDisplayListRecorder.
bool readPixels(const SkPixmap &dst, int srcX, int srcY)
Copies SkRect of pixels to dst.
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into dstPixels.
@ kFlushRead_BackendHandleAccess
back-end object is readable
Definition: SkSurface.h:501
The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420().
Definition: SkImage.h:806
void writePixels(const SkPixmap &src, int dstX, int dstY)
Copies SkRect of pixels from the src SkPixmap to the SkSurface.
const SkImageInfo & info() const
Returns width, height, SkAlphaType, SkColorType, and SkColorSpace.
Definition: SkPixmap.h:126
int width() const
Returns pixel count in each row; may be zero or greater.
Definition: SkSurface.h:455
BackendSurfaceAccess
Definition: SkSurface.h:887
bool characterize(SkSurfaceCharacterization *characterization) const
Initializes SkSurfaceCharacterization that can be used to perform GPU back-end processing in a separa...
void dirtyGenerationID()
Definition: SkSurface.h:1044
Definition: SkSurfaceCharacterization.h:207
static sk_sp< SkSurface > MakeRenderTarget(GrRecordingContext *context, SkBudgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, const SkSurfaceProps *surfaceProps)
Returns SkSurface on GPU indicated by context.
Definition: SkSurface.h:389
Definition: GrBackendSurface.h:54
#define SK_API_AVAILABLE(...)
Definition: SkTypes.h:426
GrRecordingContext * recordingContext()
Returns the recording context being used by the SkSurface.
bool readPixels(const SkBitmap &dst, int srcX, int srcY)
Copies SkRect of pixels from SkSurface into bitmap.
Since Skia and clients can both modify gpu textures and their connected state, Skia needs a way for c...
Definition: GrBackendSurfaceMutableState.h:27
SkColorType
Definition: SkImageInfo.h:64
bool replaceBackendTexture(const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, ContentChangeMode mode=kRetain_ContentChangeMode, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
If the surface was made via MakeFromBackendTexture then it's backing texture may be substituted with ...
bool wait(int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait=true)
Inserts a list of GPU semaphores that the current GPU-backed API must wait on before executing any mo...
uint32_t generationID()
Returns unique value identifying the content of SkSurface.
Definition: SkBitmap.h:50
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:200
static sk_sp< SkSurface > MakeRenderTarget(GrRecordingContext *context, SkBudgeted budgeted, const SkImageInfo &imageInfo)
Returns SkSurface on GPU indicated by context.
Definition: SkSurface.h:409
static sk_sp< SkSurface > MakeRasterDirectReleaseProc(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, void(*releaseProc)(void *pixels, void *context), void *context, const SkSurfaceProps *surfaceProps=nullptr)
Allocates raster SkSurface.
static sk_sp< SkSurface > MakeRaster(const SkImageInfo &imageInfo, const SkSurfaceProps *props=nullptr)
Allocates raster SkSurface.
Definition: SkSurface.h:147
void * ReadPixelsContext
Client-provided context that is passed to client-provided ReadPixelsContext.
Definition: SkSurface.h:749