Skia
2D Graphics Library
GrDirectContext Class Reference

#include <GrDirectContext.h>

Inheritance diagram for GrDirectContext:

Classes

class  DirectContextID
 

Public Member Functions

 ~GrDirectContext () override
 
void resetContext (uint32_t state=kAll_GrBackendState)
 The context normally assumes that no outsider is setting state within the underlying 3D API's context/device/whatever. More...
 
void resetGLTextureBindings ()
 If the backend is GrBackendApi::kOpenGL, then all texture unit/target combinations for which the context has modified the bound texture will have texture id 0 bound. More...
 
void abandonContext () override
 Abandons all GPU resources and assumes the underlying backend 3D API context is no longer usable. More...
 
bool abandoned () override
 Returns true if the context was abandoned or if the backend specific context has gotten into an unrecoverarble, lost state (e.g. More...
 
bool isDeviceLost ()
 Returns true if the backend specific context has gotten into an unrecoverarble, lost state (e.g. More...
 
sk_sp< GrContextThreadSafeProxythreadSafeProxy ()
 
bool oomed ()
 Checks if the underlying 3D API reported an out-of-memory error. More...
 
void releaseResourcesAndAbandonContext ()
 This is similar to abandonContext() however the underlying 3D context is not yet lost and the context will cleanup all allocated resources before returning. More...
 
void getResourceCacheLimits (int *maxResources, size_t *maxResourceBytes) const
 DEPRECATED Return the current GPU resource cache limits. More...
 
size_t getResourceCacheLimit () const
 Return the current GPU resource cache limit in bytes. More...
 
void getResourceCacheUsage (int *resourceCount, size_t *resourceBytes) const
 Gets the current GPU resource cache usage. More...
 
size_t getResourceCachePurgeableBytes () const
 Gets the number of bytes in the cache consumed by purgeable (e.g. More...
 
void setResourceCacheLimits (int maxResources, size_t maxResourceBytes)
 DEPRECATED Specify the GPU resource cache limits. More...
 
void setResourceCacheLimit (size_t maxResourceBytes)
 Specify the GPU resource cache limit. More...
 
void freeGpuResources ()
 Frees GPU created by the context. More...
 
void performDeferredCleanup (std::chrono::milliseconds msNotUsed, GrPurgeResourceOptions opts=GrPurgeResourceOptions::kAllResources)
 Purge GPU resources that haven't been used in the past 'msNotUsed' milliseconds or are otherwise marked for deletion, regardless of whether the context is under budget. More...
 
void purgeResourcesNotUsedInMs (std::chrono::milliseconds msNotUsed)
 
void purgeUnlockedResources (size_t bytesToPurge, bool preferScratchResources)
 Purge unlocked resources from the cache until the the provided byte count has been reached or we have purged all unlocked resources. More...
 
void purgeUnlockedResources (GrPurgeResourceOptions opts)
 This entry point is intended for instances where an app has been backgrounded or suspended. More...
 
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 more commands on the GPU. More...
 
void flushAndSubmit (GrSyncCpu sync=GrSyncCpu::kNo)
 Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D API. More...
 
GrSemaphoresSubmitted flush (const GrFlushInfo &info)
 Call to ensure all drawing to the context has been flushed to underlying 3D API specific objects. More...
 
void flush ()
 
GrSemaphoresSubmitted flush (const sk_sp< const SkImage > &image, const GrFlushInfo &info)
 Flushes any pending uses of texture-backed images in the GPU backend. More...
 
void flush (const sk_sp< const SkImage > &image)
 
void flushAndSubmit (const sk_sp< const SkImage > &image)
 Version of flush() that uses a default GrFlushInfo. More...
 
GrSemaphoresSubmitted flush (SkSurface *surface, SkSurfaces::BackendSurfaceAccess access, const GrFlushInfo &info)
 Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface MSAA. More...
 
GrSemaphoresSubmitted flush (SkSurface *surface, const GrFlushInfo &info, const skgpu::MutableTextureState *newState=nullptr)
 Same as above except: More...
 
void flushAndSubmit (SkSurface *surface, GrSyncCpu sync=GrSyncCpu::kNo)
 Call to ensure all reads/writes of the surface have been issued to the underlying 3D API. More...
 
void flush (SkSurface *surface)
 Flushes the given surface with the default GrFlushInfo. More...
 
bool submit (GrSyncCpu sync=GrSyncCpu::kNo)
 Submit outstanding work to the gpu from all previously un-submitted flushes. More...
 
void checkAsyncWorkCompletion ()
 Checks whether any asynchronous work is complete and if so calls related callbacks. More...
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. More...
 
bool supportsDistanceFieldText () const
 
void storeVkPipelineCacheData ()
 
GrBackendTexture createBackendTexture (int width, int height, const GrBackendFormat &, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, std::string_view label={})
 The explicitly allocated backend texture API allows clients to use Skia to create backend objects outside of Skia proper (i.e., Skia's caching system will not know about them.) More...
 
GrBackendTexture createBackendTexture (int width, int height, SkColorType, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, std::string_view label={})
 If possible, create an uninitialized backend texture. More...
 
GrBackendTexture createBackendTexture (int width, int height, const GrBackendFormat &, const SkColor4f &color, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 If possible, create a backend texture initialized to a particular color. More...
 
GrBackendTexture createBackendTexture (int width, int height, SkColorType, const SkColor4f &color, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 If possible, create a backend texture initialized to a particular color. More...
 
GrBackendTexture createBackendTexture (const SkPixmap srcData[], int numLevels, GrSurfaceOrigin, GrRenderable, GrProtected, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 If possible, create a backend texture initialized with the provided pixmap data. More...
 
GrBackendTexture createBackendTexture (const SkPixmap &srcData, GrSurfaceOrigin textureOrigin, GrRenderable renderable, GrProtected isProtected, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 Convenience version createBackendTexture() that takes just a base level pixmap. More...
 
GrBackendTexture createBackendTexture (const SkPixmap srcData[], int numLevels, GrRenderable renderable, GrProtected isProtected, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 
GrBackendTexture createBackendTexture (const SkPixmap &srcData, GrRenderable renderable, GrProtected isProtected, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr, std::string_view label={})
 
bool updateBackendTexture (const GrBackendTexture &, const SkColor4f &color, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 If possible, updates a backend texture to be filled to a particular color. More...
 
bool updateBackendTexture (const GrBackendTexture &, SkColorType skColorType, const SkColor4f &color, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 If possible, updates a backend texture to be filled to a particular color. More...
 
bool updateBackendTexture (const GrBackendTexture &, const SkPixmap srcData[], int numLevels, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 If possible, updates a backend texture filled with the provided pixmap data. More...
 
bool updateBackendTexture (const GrBackendTexture &texture, const SkPixmap &srcData, GrSurfaceOrigin textureOrigin=kTopLeft_GrSurfaceOrigin, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 Convenience version of updateBackendTexture that takes just a base level pixmap. More...
 
bool updateBackendTexture (const GrBackendTexture &texture, const SkPixmap srcData[], int numLevels, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 
GrBackendTexture createCompressedBackendTexture (int width, int height, const GrBackendFormat &, const SkColor4f &color, skgpu::Mipmapped, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 If possible, create a compressed backend texture initialized to a particular color. More...
 
GrBackendTexture createCompressedBackendTexture (int width, int height, SkTextureCompressionType, const SkColor4f &color, skgpu::Mipmapped, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 
GrBackendTexture createCompressedBackendTexture (int width, int height, const GrBackendFormat &, const void *data, size_t dataSize, skgpu::Mipmapped, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 If possible, create a backend texture initialized with the provided raw data. More...
 
GrBackendTexture createCompressedBackendTexture (int width, int height, SkTextureCompressionType, const void *data, size_t dataSize, skgpu::Mipmapped, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 
bool updateCompressedBackendTexture (const GrBackendTexture &, const SkColor4f &color, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 If possible, updates a backend texture filled with the provided color. More...
 
bool updateCompressedBackendTexture (const GrBackendTexture &, const void *data, size_t dataSize, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
 If possible, updates a backend texture filled with the provided raw data. More...
 
bool setBackendTextureState (const GrBackendTexture &, const skgpu::MutableTextureState &, skgpu::MutableTextureState *previousState=nullptr, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 Updates the state of the GrBackendTexture/RenderTarget to have the passed in skgpu::MutableTextureState. More...
 
bool setBackendRenderTargetState (const GrBackendRenderTarget &, const skgpu::MutableTextureState &, skgpu::MutableTextureState *previousState=nullptr, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
 
void deleteBackendTexture (const GrBackendTexture &)
 
bool precompileShader (const SkData &key, const SkData &data)
 
DirectContextID directContextID () const
 
GrDirectContextPriv priv ()
 
const GrDirectContextPriv priv () const
 
SK_API int maxTextureSize () const
 Gets the maximum supported texture size. More...
 
SK_API int maxRenderTargetSize () const
 Gets the maximum supported render target size. More...
 
SK_API bool colorTypeSupportedAsImage (SkColorType) const
 Can a SkImage be created with the given color type. More...
 
SK_API bool supportsProtectedContent () const
 Does this context support protected content? More...
 
SK_API bool colorTypeSupportedAsSurface (SkColorType colorType) const
 Can a SkSurface be created with the given color type. More...
 
SK_API int maxSurfaceSampleCountForColorType (SkColorType colorType) const
 Gets the maximum supported sample count for a color type. More...
 
SK_API bool colorTypeSupportedAsSurface (SkColorType colorType) const
 
SK_API int maxTextureSize () const
 Gets the maximum supported texture size. More...
 
SK_API int maxRenderTargetSize () const
 Gets the maximum supported render target size. More...
 
SK_API bool colorTypeSupportedAsImage (SkColorType) const
 Can a SkImage be created with the given color type. More...
 
SK_API bool supportsProtectedContent () const
 Does this context support protected content? More...
 
SK_API int maxSurfaceSampleCountForColorType (SkColorType colorType) const
 Gets the maximum supported sample count for a color type. More...
 
SK_API sk_sp< const SkCapabilitiesskCapabilities () const
 

Static Public Member Functions

static sk_sp< GrDirectContextMakeMock (const GrMockOptions *, const GrContextOptions &)
 
static sk_sp< GrDirectContextMakeMock (const GrMockOptions *)
 

Protected Member Functions

 GrDirectContext (GrBackendApi backend, const GrContextOptions &options)
 
bool init () override
 
GrAtlasManager * onGetAtlasManager ()
 
skgpu::ganesh::SmallPathAtlasMgr * onGetSmallPathAtlasMgr ()
 
GrDirectContextasDirectContext () override
 
GrDrawingManager * drawingManager ()
 
void destroyDrawingManager ()
 
Arenas arenas ()
 
OwnedArenas && detachArenas ()
 
GrProxyProvider * proxyProvider ()
 
const GrProxyProvider * proxyProvider () const
 
virtual void recordProgramInfo (const GrProgramInfo *)
 
virtual void detachProgramData (skia_private::TArray< ProgramData > *)
 
sktext::gpu::TextBlobRedrawCoordinator * getTextBlobRedrawCoordinator ()
 
const sktext::gpu::TextBlobRedrawCoordinator * getTextBlobRedrawCoordinator () const
 
GrThreadSafeCache * threadSafeCache ()
 
const GrThreadSafeCache * threadSafeCache () const
 
void addOnFlushCallbackObject (GrOnFlushCallbackObject *)
 Registers an object for flush-related callbacks. More...
 
GrRecordingContextasRecordingContext () override
 
Statsstats ()
 
const Statsstats () const
 
void dumpJSON (SkJSONWriter *) const
 

Protected Attributes

class GrRecordingContext::Stats fStats
 
std::unique_ptr< GrAuditTrail > fAuditTrail
 

Friends

class GrDirectContextPriv
 

Constructor & Destructor Documentation

◆ ~GrDirectContext()

GrDirectContext::~GrDirectContext ( )
override

◆ GrDirectContext()

GrDirectContext::GrDirectContext ( GrBackendApi  backend,
const GrContextOptions options 
)
protected

Member Function Documentation

◆ abandonContext()

void GrDirectContext::abandonContext ( )
override

Abandons all GPU resources and assumes the underlying backend 3D API context is no longer usable.

Call this if you have lost the associated GPU context, and thus internal texture, buffer, etc. references/IDs are now invalid. Calling this ensures that the destructors of the context and any of its created resource objects will not make backend 3D API calls. Content rendered but not previously flushed may be lost. After this function is called all subsequent calls on the context will fail or be no-ops.

The typical use case for this function is that the underlying 3D context was lost and further API calls may crash.

This call is not valid to be made inside ReleaseProcs passed into SkSurface or SkImages. The call will simply fail (and assert in debug) if it is called while inside a ReleaseProc.

For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to create the context must be kept alive even after abandoning the context. Those objects must live for the lifetime of the context object itself. The reason for this is so that we can continue to delete any outstanding GrBackendTextures/RenderTargets which must be cleaned up even in a device lost state.

◆ abandoned()

bool GrDirectContext::abandoned ( )
override

Returns true if the context was abandoned or if the backend specific context has gotten into an unrecoverarble, lost state (e.g.

in Vulkan backend if we've gotten a VK_ERROR_DEVICE_LOST). If the backend context is lost, this call will also abandon this context.

◆ addOnFlushCallbackObject()

void GrRecordingContext::addOnFlushCallbackObject ( GrOnFlushCallbackObject *  )
protectedinherited

Registers an object for flush-related callbacks.

(See GrOnFlushCallbackObject.)

NOTE: the drawing manager tracks this object as a raw pointer; it is up to the caller to ensure its lifetime is tied to that of the context.

◆ arenas()

Arenas GrRecordingContext::arenas ( )
inlineprotectedinherited

◆ asDirectContext()

GrDirectContext* GrDirectContext::asDirectContext ( )
inlineoverrideprotected

◆ asRecordingContext()

GrRecordingContext* GrRecordingContext::asRecordingContext ( )
inlineoverrideprotectedinherited

◆ checkAsyncWorkCompletion()

void GrDirectContext::checkAsyncWorkCompletion ( )

Checks whether any asynchronous work is complete and if so calls related callbacks.

◆ colorTypeSupportedAsImage() [1/2]

SK_API bool GrRecordingContext::colorTypeSupportedAsImage

Can a SkImage be created with the given color type.

◆ colorTypeSupportedAsImage() [2/2]

SK_API bool GrRecordingContext::colorTypeSupportedAsImage ( SkColorType  ) const
inherited

Can a SkImage be created with the given color type.

◆ colorTypeSupportedAsSurface() [1/2]

SK_API bool GrRecordingContext::colorTypeSupportedAsSurface
inline

Can a SkSurface be created with the given color type.

To check whether MSAA is supported use maxSurfaceSampleCountForColorType().

◆ colorTypeSupportedAsSurface() [2/2]

SK_API bool GrRecordingContext::colorTypeSupportedAsSurface ( SkColorType  colorType) const
inlineinherited

◆ createBackendTexture() [1/8]

GrBackendTexture GrDirectContext::createBackendTexture ( const SkPixmap srcData,
GrRenderable  renderable,
GrProtected  isProtected,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

◆ createBackendTexture() [2/8]

GrBackendTexture GrDirectContext::createBackendTexture ( const SkPixmap srcData,
GrSurfaceOrigin  textureOrigin,
GrRenderable  renderable,
GrProtected  isProtected,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

Convenience version createBackendTexture() that takes just a base level pixmap.

◆ createBackendTexture() [3/8]

GrBackendTexture GrDirectContext::createBackendTexture ( const SkPixmap  srcData[],
int  numLevels,
GrRenderable  renderable,
GrProtected  isProtected,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

◆ createBackendTexture() [4/8]

GrBackendTexture GrDirectContext::createBackendTexture ( const SkPixmap  srcData[],
int  numLevels,
GrSurfaceOrigin  ,
GrRenderable  ,
GrProtected  ,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

If possible, create a backend texture initialized with the provided pixmap data.

The client should ensure that the returned backend texture is valid. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. If successful, the created backend texture will be compatible with the provided pixmap(s). Compatible, in this case, means that the backend format will be the result of calling defaultBackendFormat on the base pixmap's colortype. The src data can be deleted when this call returns. If numLevels is 1 a non-mipmapped texture will result. If a mipmapped texture is desired the data for all the mipmap levels must be provided. In the mipmapped case all the colortypes of the provided pixmaps must be the same. Additionally, all the miplevels must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). The GrSurfaceOrigin controls whether the pixmap data is vertically flipped in the texture. Note: the pixmap's alphatypes and colorspaces are ignored. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ createBackendTexture() [5/8]

GrBackendTexture GrDirectContext::createBackendTexture ( int  width,
int  height,
const GrBackendFormat ,
const SkColor4f color,
skgpu::Mipmapped  ,
GrRenderable  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

If possible, create a backend texture initialized to a particular color.

The client should ensure that the returned backend texture is valid. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ createBackendTexture() [6/8]

GrBackendTexture GrDirectContext::createBackendTexture ( int  width,
int  height,
const GrBackendFormat ,
skgpu::Mipmapped  ,
GrRenderable  ,
GrProtected  = GrProtected::kNo,
std::string_view  label = {} 
)

The explicitly allocated backend texture API allows clients to use Skia to create backend objects outside of Skia proper (i.e., Skia's caching system will not know about them.)

It is the client's responsibility to delete all these objects (using deleteBackendTexture) before deleting the context used to create them. If the backend is Vulkan, the textures must be deleted before abandoning the context as well. Additionally, clients should only delete these objects on the thread for which that context is active.

The client is responsible for ensuring synchronization between different uses of the backend object (i.e., wrapping it in a surface, rendering to it, deleting the surface, rewrapping it in a image and drawing the image will require explicit synchronization on the client's part). If possible, create an uninitialized backend texture. The client should ensure that the returned backend texture is valid. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_UNDEFINED.

◆ createBackendTexture() [7/8]

GrBackendTexture GrDirectContext::createBackendTexture ( int  width,
int  height,
SkColorType  ,
const SkColor4f color,
skgpu::Mipmapped  ,
GrRenderable  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr,
std::string_view  label = {} 
)

If possible, create a backend texture initialized to a particular color.

The client should ensure that the returned backend texture is valid. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. If successful, the created backend texture will be compatible with the provided SkColorType. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ createBackendTexture() [8/8]

GrBackendTexture GrDirectContext::createBackendTexture ( int  width,
int  height,
SkColorType  ,
skgpu::Mipmapped  ,
GrRenderable  ,
GrProtected  = GrProtected::kNo,
std::string_view  label = {} 
)

If possible, create an uninitialized backend texture.

The client should ensure that the returned backend texture is valid. If successful, the created backend texture will be compatible with the provided SkColorType. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_UNDEFINED.

◆ createCompressedBackendTexture() [1/4]

GrBackendTexture GrDirectContext::createCompressedBackendTexture ( int  width,
int  height,
const GrBackendFormat ,
const SkColor4f color,
skgpu::Mipmapped  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

If possible, create a compressed backend texture initialized to a particular color.

The client should ensure that the returned backend texture is valid. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ createCompressedBackendTexture() [2/4]

GrBackendTexture GrDirectContext::createCompressedBackendTexture ( int  width,
int  height,
const GrBackendFormat ,
const void *  data,
size_t  dataSize,
skgpu::Mipmapped  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

If possible, create a backend texture initialized with the provided raw data.

The client should ensure that the returned backend texture is valid. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture If numLevels is 1 a non-mipmapped texture will result. If a mipmapped texture is desired the data for all the mipmap levels must be provided. Additionally, all the miplevels must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). For the Vulkan backend the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ createCompressedBackendTexture() [3/4]

GrBackendTexture GrDirectContext::createCompressedBackendTexture ( int  width,
int  height,
SkTextureCompressionType  ,
const SkColor4f color,
skgpu::Mipmapped  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

◆ createCompressedBackendTexture() [4/4]

GrBackendTexture GrDirectContext::createCompressedBackendTexture ( int  width,
int  height,
SkTextureCompressionType  ,
const void *  data,
size_t  dataSize,
skgpu::Mipmapped  ,
GrProtected  = GrProtected::kNo,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

◆ deleteBackendTexture()

void GrDirectContext::deleteBackendTexture ( const GrBackendTexture )

◆ destroyDrawingManager()

void GrRecordingContext::destroyDrawingManager ( )
protectedinherited

◆ detachArenas()

OwnedArenas&& GrRecordingContext::detachArenas ( )
protectedinherited

◆ detachProgramData()

virtual void GrRecordingContext::detachProgramData ( skia_private::TArray< ProgramData > *  )
inlineprotectedvirtualinherited

◆ directContextID()

DirectContextID GrDirectContext::directContextID ( ) const
inline

◆ drawingManager()

GrDrawingManager* GrRecordingContext::drawingManager ( )
protectedinherited

◆ dumpJSON()

void GrRecordingContext::dumpJSON ( SkJSONWriter *  ) const
protectedinherited

◆ dumpMemoryStatistics()

void GrDirectContext::dumpMemoryStatistics ( SkTraceMemoryDump traceMemoryDump) const

Enumerates all cached GPU resources and dumps their memory to traceMemoryDump.

◆ flush() [1/7]

void GrDirectContext::flush ( )
inline

◆ flush() [2/7]

GrSemaphoresSubmitted GrDirectContext::flush ( const GrFlushInfo info)

Call to ensure all drawing to the context has been flushed to underlying 3D API specific objects.

A call to submit is always required to ensure work is actually sent to the gpu. Some specific API details: GL: Commands are actually sent to the driver, but glFlush is never called. Thus some sync objects from the flush will not be valid until a submission occurs.

Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command buffer or encoder objects. However, these objects are not sent to the gpu until a submission occurs.

If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be submitted to the gpu during the next submit call (it is possible Skia failed to create a subset of the semaphores). The client should not wait on these semaphores until after submit has been called, and must keep them alive until then. If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the client is still responsible for deleting any initialized semaphores. Regardless of semaphore submission the context will still be flushed. It should be emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It simply means there were no semaphores submitted to the GPU. A caller should only take this as a failure if they passed in semaphores to be submitted.

◆ flush() [3/7]

void GrDirectContext::flush ( const sk_sp< const SkImage > &  image)

◆ flush() [4/7]

GrSemaphoresSubmitted GrDirectContext::flush ( const sk_sp< const SkImage > &  image,
const GrFlushInfo info 
)

Flushes any pending uses of texture-backed images in the GPU backend.

If the image is not texture-backed (including promise texture images) or if the GrDirectContext does not have the same context ID as the context backing the image then this is a no-op. If the image was not used in any non-culled draws in the current queue of work for the passed GrDirectContext then this is a no-op unless the GrFlushInfo contains semaphores or a finish proc. Those are respected even when the image has not been used.

Parameters
imagethe non-null image to flush.
infoflush options

◆ flush() [5/7]

void GrDirectContext::flush ( SkSurface surface)

Flushes the given surface with the default GrFlushInfo.

Has no effect on a CPU-backed surface.

◆ flush() [6/7]

GrSemaphoresSubmitted GrDirectContext::flush ( SkSurface surface,
const GrFlushInfo info,
const skgpu::MutableTextureState newState = nullptr 
)

Same as above except:

If a skgpu::MutableTextureState is passed in, at the end of the flush we will transition the surface to be in the state requested by the skgpu::MutableTextureState. If the surface (or SkImage or GrBackendSurface wrapping the same backend object) is used again after this flush the state may be changed and no longer match what is requested here. This is often used if the surface will be used for presenting or external use and the client wants backend object to be prepped for that use. A finishedProc or semaphore on the GrFlushInfo will also include the work for any requested state change.

If the backend API is Vulkan, the caller can set the skgpu::MutableTextureState's VkImageLayout to VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED to tell Skia to not change those respective states.

Parameters
surfaceThe GPU backed surface to be flushed. Has no effect on a CPU-backed surface.
infoflush options
newStateoptional state change request after flush

◆ flush() [7/7]

GrSemaphoresSubmitted GrDirectContext::flush ( SkSurface surface,
SkSurfaces::BackendSurfaceAccess  access,
const GrFlushInfo info 
)

Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface MSAA.

A call to GrDirectContext::submit is always required to ensure work is actually sent to the gpu. Some specific API details: GL: Commands are actually sent to the driver, but glFlush is never called. Thus some sync objects from the flush will not be valid until a submission occurs.

Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command buffer or encoder objects. However, these objects are not sent to the gpu until a submission occurs.

The work that is submitted to the GPU will be dependent on the BackendSurfaceAccess that is passed in.

If BackendSurfaceAccess::kNoAccess is passed in all commands will be issued to the GPU.

If BackendSurfaceAccess::kPresent is passed in and the backend API is not Vulkan, it is treated the same as kNoAccess. If the backend API is Vulkan, the VkImage that backs the SkSurface will be transferred back to its original queue. If the SkSurface was created by wrapping a VkImage, the queue will be set to the queue which was originally passed in on the GrVkImageInfo. Additionally, if the original queue was not external or foreign the layout of the VkImage will be set to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

The GrFlushInfo describes additional options to flush. Please see documentation at GrFlushInfo for more info.

If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be submitted to the gpu during the next submit call (it is possible Skia failed to create a subset of the semaphores). The client should not wait on these semaphores until after submit has been called, but must keep them alive until then. If a submit flag was passed in with the flush these valid semaphores can we waited on immediately. If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the client is still responsible for deleting any initialized semaphores. Regardless of semaphore submission the context will still be flushed. It should be emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It simply means there were no semaphores submitted to the GPU. A caller should only take this as a failure if they passed in semaphores to be submitted.

Pending surface commands are flushed regardless of the return result.

Parameters
surfaceThe GPU backed surface to be flushed. Has no effect on a CPU-backed surface.
accesstype of access the call will do on the backend object after flush
infoflush options

◆ flushAndSubmit() [1/3]

void GrDirectContext::flushAndSubmit ( const sk_sp< const SkImage > &  image)

Version of flush() that uses a default GrFlushInfo.

Also submits the flushed work to the GPU.

◆ flushAndSubmit() [2/3]

void GrDirectContext::flushAndSubmit ( GrSyncCpu  sync = GrSyncCpu::kNo)
inline

Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D API.

This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by GrContext::submit(sync).

◆ flushAndSubmit() [3/3]

void GrDirectContext::flushAndSubmit ( SkSurface surface,
GrSyncCpu  sync = GrSyncCpu::kNo 
)

Call to ensure all reads/writes of the surface have been issued to the underlying 3D API.

Skia will correctly order its own draws and pixel operations. This must to be used to ensure correct ordering when the surface backing store is accessed outside Skia (e.g. direct use of the 3D API or a windowing system). This is equivalent to calling ::flush with a default GrFlushInfo followed by ::submit(syncCpu).

Has no effect on a CPU-backed surface.

◆ freeGpuResources()

void GrDirectContext::freeGpuResources ( )

Frees GPU created by the context.

Can be called to reduce GPU memory pressure.

◆ getResourceCacheLimit()

size_t GrDirectContext::getResourceCacheLimit ( ) const

Return the current GPU resource cache limit in bytes.

◆ getResourceCacheLimits()

void GrDirectContext::getResourceCacheLimits ( int *  maxResources,
size_t *  maxResourceBytes 
) const

DEPRECATED Return the current GPU resource cache limits.

Parameters
maxResourcesIf non-null, will be set to -1.
maxResourceBytesIf non-null, returns maximum number of bytes of video memory that can be held in the cache.

◆ getResourceCachePurgeableBytes()

size_t GrDirectContext::getResourceCachePurgeableBytes ( ) const

Gets the number of bytes in the cache consumed by purgeable (e.g.

unlocked) resources.

◆ getResourceCacheUsage()

void GrDirectContext::getResourceCacheUsage ( int *  resourceCount,
size_t *  resourceBytes 
) const

Gets the current GPU resource cache usage.

Parameters
resourceCountIf non-null, returns the number of resources that are held in the cache.
maxResourceBytesIf non-null, returns the total number of bytes of video memory held in the cache.

◆ getTextBlobRedrawCoordinator() [1/2]

sktext::gpu::TextBlobRedrawCoordinator* GrRecordingContext::getTextBlobRedrawCoordinator ( )
protectedinherited

◆ getTextBlobRedrawCoordinator() [2/2]

const sktext::gpu::TextBlobRedrawCoordinator* GrRecordingContext::getTextBlobRedrawCoordinator ( ) const
protectedinherited

◆ init()

bool GrDirectContext::init ( )
overrideprotected

◆ isDeviceLost()

bool GrDirectContext::isDeviceLost ( )

Returns true if the backend specific context has gotten into an unrecoverarble, lost state (e.g.

in Vulkan backend if we've gotten a VK_ERROR_DEVICE_LOST). If the backend context is lost, this call will also abandon this context.

◆ MakeMock() [1/2]

static sk_sp<GrDirectContext> GrDirectContext::MakeMock ( const GrMockOptions *  )
static

◆ MakeMock() [2/2]

static sk_sp<GrDirectContext> GrDirectContext::MakeMock ( const GrMockOptions *  ,
const GrContextOptions  
)
static

◆ maxRenderTargetSize() [1/2]

SK_API int GrRecordingContext::maxRenderTargetSize

Gets the maximum supported render target size.

◆ maxRenderTargetSize() [2/2]

SK_API int GrRecordingContext::maxRenderTargetSize ( ) const
inherited

Gets the maximum supported render target size.

◆ maxSurfaceSampleCountForColorType() [1/2]

SK_API int GrRecordingContext::maxSurfaceSampleCountForColorType
inline

Gets the maximum supported sample count for a color type.

1 is returned if only non-MSAA rendering is supported for the color type. 0 is returned if rendering to this color type is not supported at all.

◆ maxSurfaceSampleCountForColorType() [2/2]

SK_API int GrRecordingContext::maxSurfaceSampleCountForColorType ( SkColorType  colorType) const
inlineinherited

Gets the maximum supported sample count for a color type.

1 is returned if only non-MSAA rendering is supported for the color type. 0 is returned if rendering to this color type is not supported at all.

◆ maxTextureSize() [1/2]

SK_API int GrRecordingContext::maxTextureSize

Gets the maximum supported texture size.

◆ maxTextureSize() [2/2]

SK_API int GrRecordingContext::maxTextureSize ( ) const
inherited

Gets the maximum supported texture size.

◆ onGetAtlasManager()

GrAtlasManager* GrDirectContext::onGetAtlasManager ( )
inlineprotected

◆ onGetSmallPathAtlasMgr()

skgpu::ganesh::SmallPathAtlasMgr* GrDirectContext::onGetSmallPathAtlasMgr ( )
protected

◆ oomed()

bool GrDirectContext::oomed ( )

Checks if the underlying 3D API reported an out-of-memory error.

If this returns true it is reset and will return false until another out-of-memory error is reported by the 3D API. If the context is abandoned then this will report false.

Currently this is implemented for:

OpenGL [ES] - Note that client calls to glGetError() may swallow GL_OUT_OF_MEMORY errors and therefore hide the error from Skia. Also, it is not advised to use this in combination with enabling GrContextOptions::fSkipGLErrorChecks. That option may prevent the context from ever checking the GL context for OOM.

Vulkan - Reports true if VK_ERROR_OUT_OF_HOST_MEMORY or VK_ERROR_OUT_OF_DEVICE_MEMORY has occurred.

◆ performDeferredCleanup()

void GrDirectContext::performDeferredCleanup ( std::chrono::milliseconds  msNotUsed,
GrPurgeResourceOptions  opts = GrPurgeResourceOptions::kAllResources 
)

Purge GPU resources that haven't been used in the past 'msNotUsed' milliseconds or are otherwise marked for deletion, regardless of whether the context is under budget.

Parameters
msNotUsedOnly unlocked resources not used in these last milliseconds will be cleaned up.
optsSpecify which resources should be cleaned up. If kScratchResourcesOnly then, all unlocked scratch resources older than 'msNotUsed' will be purged but the unlocked resources with persistent data will remain. If kAllResources

◆ precompileShader()

bool GrDirectContext::precompileShader ( const SkData key,
const SkData data 
)

◆ priv() [1/2]

GrDirectContextPriv GrDirectContext::priv ( )

◆ priv() [2/2]

const GrDirectContextPriv GrDirectContext::priv ( ) const

◆ proxyProvider() [1/2]

GrProxyProvider* GrRecordingContext::proxyProvider ( )
inlineprotectedinherited

◆ proxyProvider() [2/2]

const GrProxyProvider* GrRecordingContext::proxyProvider ( ) const
inlineprotectedinherited

◆ purgeResourcesNotUsedInMs()

void GrDirectContext::purgeResourcesNotUsedInMs ( std::chrono::milliseconds  msNotUsed)
inline

◆ purgeUnlockedResources() [1/2]

void GrDirectContext::purgeUnlockedResources ( GrPurgeResourceOptions  opts)

This entry point is intended for instances where an app has been backgrounded or suspended.

If 'scratchResourcesOnly' is true all unlocked scratch resources will be purged but the unlocked resources with persistent data will remain. If 'scratchResourcesOnly' is false then all unlocked resources will be purged. In either case, after the unlocked resources are purged a separate pass will be made to ensure that resource usage is under budget (i.e., even if 'scratchResourcesOnly' is true some resources with persistent data may be purged to be under budget).

Parameters
optsIf kScratchResourcesOnly only unlocked scratch resources will be purged prior enforcing the budget requirements.

◆ purgeUnlockedResources() [2/2]

void GrDirectContext::purgeUnlockedResources ( size_t  bytesToPurge,
bool  preferScratchResources 
)

Purge unlocked resources from the cache until the the provided byte count has been reached or we have purged all unlocked resources.

The default policy is to purge in LRU order, but can be overridden to prefer purging scratch resources (in LRU order) prior to purging other resource types.

Parameters
maxBytesToPurgethe desired number of bytes to be purged.
preferScratchResourcesIf true scratch resources will be purged prior to other resource types.

◆ recordProgramInfo()

virtual void GrRecordingContext::recordProgramInfo ( const GrProgramInfo *  )
inlineprotectedvirtualinherited

◆ releaseResourcesAndAbandonContext()

void GrDirectContext::releaseResourcesAndAbandonContext ( )

This is similar to abandonContext() however the underlying 3D context is not yet lost and the context will cleanup all allocated resources before returning.

After returning it will assume that the underlying context may no longer be valid.

The typical use case for this function is that the client is going to destroy the 3D context but can't guarantee that context will be destroyed first (perhaps because it may be ref'ed elsewhere by either the client or Skia objects).

For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to create the context must be alive before calling releaseResourcesAndAbandonContext.

◆ resetContext()

void GrDirectContext::resetContext ( uint32_t  state = kAll_GrBackendState)

The context normally assumes that no outsider is setting state within the underlying 3D API's context/device/whatever.

This call informs the context that the state was modified and it should resend. Shouldn't be called frequently for good performance. The flag bits, state, is dependent on which backend is used by the context, either GL or D3D (possible in future).

◆ resetGLTextureBindings()

void GrDirectContext::resetGLTextureBindings ( )

If the backend is GrBackendApi::kOpenGL, then all texture unit/target combinations for which the context has modified the bound texture will have texture id 0 bound.

This does not flush the context. Calling resetContext() does not change the set that will be bound to texture id 0 on the next call to resetGLTextureBindings(). After this is called all unit/target combinations are considered to have unmodified bindings until the context subsequently modifies them (meaning if this is called twice in a row with no intervening context usage then the second call is a no-op.)

◆ setBackendRenderTargetState()

bool GrDirectContext::setBackendRenderTargetState ( const GrBackendRenderTarget ,
const skgpu::MutableTextureState ,
skgpu::MutableTextureState previousState = nullptr,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

◆ setBackendTextureState()

bool GrDirectContext::setBackendTextureState ( const GrBackendTexture ,
const skgpu::MutableTextureState ,
skgpu::MutableTextureState previousState = nullptr,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

Updates the state of the GrBackendTexture/RenderTarget to have the passed in skgpu::MutableTextureState.

All objects that wrap the backend surface (i.e. SkSurfaces and SkImages) will also be aware of this state change. This call does not submit the state change to the gpu, but requires the client to call submit to send it to the GPU. The work for this call is ordered linearly with all other calls that require GrContext::submit to be called (e.g updateBackendTexture and flush). If finishedProc is not null then it will be called with finishedContext after the state transition is known to have occurred on the GPU.

See skgpu::MutableTextureState to see what state can be set via this call.

If the backend API is Vulkan, the caller can set the skgpu::MutableTextureState's VkImageLayout to VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED to tell Skia to not change those respective states.

If previousState is not null and this returns true, then Skia will have filled in previousState to have the values of the state before this call.

◆ setResourceCacheLimit()

void GrDirectContext::setResourceCacheLimit ( size_t  maxResourceBytes)

Specify the GPU resource cache limit.

If the cache currently exceeds this limit, it will be purged (LRU) to keep the cache within the limit.

Parameters
maxResourceBytesThe maximum number of bytes of video memory that can be held in the cache.

◆ setResourceCacheLimits()

void GrDirectContext::setResourceCacheLimits ( int  maxResources,
size_t  maxResourceBytes 
)

DEPRECATED Specify the GPU resource cache limits.

If the current cache exceeds the maxResourceBytes limit, it will be purged (LRU) to keep the cache within the limit.

Parameters
maxResourcesUnused.
maxResourceBytesThe maximum number of bytes of video memory that can be held in the cache.

◆ skCapabilities()

SK_API sk_sp<const SkCapabilities> GrRecordingContext::skCapabilities ( ) const
inherited

◆ stats() [1/2]

Stats* GrRecordingContext::stats ( )
inlineprotectedinherited

◆ stats() [2/2]

const Stats* GrRecordingContext::stats ( ) const
inlineprotectedinherited

◆ storeVkPipelineCacheData()

void GrDirectContext::storeVkPipelineCacheData ( )

◆ submit()

bool GrDirectContext::submit ( GrSyncCpu  sync = GrSyncCpu::kNo)

Submit outstanding work to the gpu from all previously un-submitted flushes.

The return value of the submit will indicate whether or not the submission to the GPU was successful.

If the call returns true, all previously passed in semaphores in flush calls will have been submitted to the GPU and they can safely be waited on. The caller should wait on those semaphores or perform some other global synchronization before deleting the semaphores.

If it returns false, then those same semaphores will not have been submitted and we will not try to submit them again. The caller is free to delete the semaphores at any time.

If sync flag is GrSyncCpu::kYes, this function will return once the gpu has finished with all submitted work.

◆ supportsDistanceFieldText()

bool GrDirectContext::supportsDistanceFieldText ( ) const

◆ supportsProtectedContent() [1/2]

SK_API bool GrRecordingContext::supportsProtectedContent

Does this context support protected content?

◆ supportsProtectedContent() [2/2]

SK_API bool GrRecordingContext::supportsProtectedContent ( ) const
inherited

Does this context support protected content?

◆ threadSafeCache() [1/2]

GrThreadSafeCache* GrRecordingContext::threadSafeCache ( )
protectedinherited

◆ threadSafeCache() [2/2]

const GrThreadSafeCache* GrRecordingContext::threadSafeCache ( ) const
protectedinherited

◆ threadSafeProxy()

sk_sp<GrContextThreadSafeProxy> GrDirectContext::threadSafeProxy ( )

◆ updateBackendTexture() [1/5]

bool GrDirectContext::updateBackendTexture ( const GrBackendTexture ,
const SkColor4f color,
GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

If possible, updates a backend texture to be filled to a particular color.

The client should check the return value to see if the update was successful. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to update the GrBackendTexture. For the Vulkan backend after a successful update the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ updateBackendTexture() [2/5]

bool GrDirectContext::updateBackendTexture ( const GrBackendTexture ,
const SkPixmap  srcData[],
int  numLevels,
GrSurfaceOrigin  = kTopLeft_GrSurfaceOrigin,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)

If possible, updates a backend texture filled with the provided pixmap data.

The client should check the return value to see if the update was successful. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. The backend texture must be compatible with the provided pixmap(s). Compatible, in this case, means that the backend format is compatible with the base pixmap's colortype. The src data can be deleted when this call returns. If the backend texture is mip mapped, the data for all the mipmap levels must be provided. In the mipmapped case all the colortypes of the provided pixmaps must be the same. Additionally, all the miplevels must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). The GrSurfaceOrigin controls whether the pixmap data is vertically flipped in the texture. Note: the pixmap's alphatypes and colorspaces are ignored. For the Vulkan backend after a successful update the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ updateBackendTexture() [3/5]

bool GrDirectContext::updateBackendTexture ( const GrBackendTexture ,
SkColorType  skColorType,
const SkColor4f color,
GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

If possible, updates a backend texture to be filled to a particular color.

The data in GrBackendTexture and passed in color is interpreted with respect to the passed in SkColorType. The client should check the return value to see if the update was successful. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to update the GrBackendTexture. For the Vulkan backend after a successful update the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ updateBackendTexture() [4/5]

bool GrDirectContext::updateBackendTexture ( const GrBackendTexture texture,
const SkPixmap srcData,
GrSurfaceOrigin  textureOrigin = kTopLeft_GrSurfaceOrigin,
GrGpuFinishedProc  finishedProc = nullptr,
GrGpuFinishedContext  finishedContext = nullptr 
)
inline

Convenience version of updateBackendTexture that takes just a base level pixmap.

◆ updateBackendTexture() [5/5]

bool GrDirectContext::updateBackendTexture ( const GrBackendTexture texture,
const SkPixmap  srcData[],
int  numLevels,
GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

◆ updateCompressedBackendTexture() [1/2]

bool GrDirectContext::updateCompressedBackendTexture ( const GrBackendTexture ,
const SkColor4f color,
GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

If possible, updates a backend texture filled with the provided color.

If the texture is mipmapped, all levels of the mip chain will be updated to have the supplied color. The client should check the return value to see if the update was successful. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. For the Vulkan backend after a successful update the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ updateCompressedBackendTexture() [2/2]

bool GrDirectContext::updateCompressedBackendTexture ( const GrBackendTexture ,
const void *  data,
size_t  dataSize,
GrGpuFinishedProc  finishedProc,
GrGpuFinishedContext  finishedContext 
)

If possible, updates a backend texture filled with the provided raw data.

The client should check the return value to see if the update was successful. The client can pass in a finishedProc to be notified when the data has been uploaded by the gpu and the texture can be deleted. The client is required to call submit to send the upload work to the gpu. The finishedProc will always get called even if we failed to create the GrBackendTexture. If a mipmapped texture is passed in, the data for all the mipmap levels must be provided. Additionally, all the miplevels must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount). For the Vulkan backend after a successful update the layout of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL

◆ wait()

bool GrDirectContext::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 more commands on the GPU.

We only guarantee blocking transfer and fragment shader work, but may block earlier stages as well depending on the backend.If this call returns false, then the GPU back-end will not wait on any passed in semaphores, and the client will still own the semaphores, regardless of the value of deleteSemaphoresAfterWait.

If deleteSemaphoresAfterWait is false then Skia will not delete the semaphores. In this case it is the client's responsibility to not destroy or attempt to reuse the semaphores until it knows that Skia has finished waiting on them. This can be done by using finishedProcs on flush calls.

This is not supported on the GL backend.

Friends And Related Function Documentation

◆ GrDirectContextPriv

friend class GrDirectContextPriv
friend

Member Data Documentation

◆ fAuditTrail

std::unique_ptr<GrAuditTrail> GrRecordingContext::fAuditTrail
protectedinherited

◆ fStats

class GrRecordingContext::Stats GrRecordingContext::fStats
protectedinherited

The documentation for this class was generated from the following file: