Flutter Engine
The Flutter Engine
|
#include <GrResourceProvider.h>
Public Types | |
enum class | ZeroInit : bool { kNo = false , kYes = true } |
using | InitializeBufferFn = void(*)(skgpu::VertexWriter, size_t bufferSize) |
Static Public Member Functions | |
static int | MaxNumNonAAQuads () |
static int | NumVertsPerNonAAQuad () |
static int | NumIndicesPerNonAAQuad () |
static int | MaxNumAAQuads () |
static int | NumVertsPerAAQuad () |
static int | NumIndicesPerAAQuad () |
Friends | |
class | GrResourceProviderPriv |
A factory for arbitrary resource types.
Definition at line 59 of file GrResourceProvider.h.
using GrResourceProvider::InitializeBufferFn = void(*)(skgpu::VertexWriter, size_t bufferSize) |
Either finds and refs a buffer with the given unique key, or creates a new new, fills its contents with the InitializeBufferDataFn() callback, and assigns it the unique key.
intendedType | hint to the graphics subsystem about how the buffer will be used. |
size | minimum size of buffer to return. |
key | Key to be assigned to the buffer. |
InitializeBufferFn | callback with which to initialize the buffer. |
Definition at line 220 of file GrResourceProvider.h.
|
strong |
Enumerator | |
---|---|
kNo | |
kYes |
Definition at line 301 of file GrResourceProvider.h.
GrResourceProvider::GrResourceProvider | ( | GrGpu * | gpu, |
GrResourceCache * | cache, | ||
skgpu::SingleOwner * | owner | ||
) |
Definition at line 48 of file GrResourceProvider.cpp.
|
inline |
Definition at line 357 of file GrResourceProvider.h.
void GrResourceProvider::assignUniqueKeyToResource | ( | const skgpu::UniqueKey & | key, |
GrGpuResource * | resource | ||
) |
Assigns a unique key to a resource. If the key is associated with another resource that association is removed and replaced by this resource.
Definition at line 423 of file GrResourceProvider.cpp.
bool GrResourceProvider::attachStencilAttachment | ( | GrRenderTarget * | rt, |
bool | useMSAASurface | ||
) |
If passed in render target already has a stencil buffer on the specified surface, return true. Otherwise attempt to attach one and return true on success.
Definition at line 664 of file GrResourceProvider.cpp.
|
inline |
Definition at line 363 of file GrResourceProvider.h.
|
inline |
Definition at line 362 of file GrResourceProvider.h.
sk_sp< GrTexture > GrResourceProvider::createApproxTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
skgpu::Renderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Protected | isProtected, | ||
std::string_view | label | ||
) |
Finds a texture that approximately matches the descriptor. Will be at least as large in width and height as desc specifies. If renderable is kYes then the GrTexture will also be a GrRenderTarget. The texture's format and sample count will always match the request. The contents of the texture are undefined.
Definition at line 280 of file GrResourceProvider.cpp.
sk_sp< GrGpuBuffer > GrResourceProvider::createBuffer | ( | const void * | data, |
size_t | size, | ||
GrGpuBufferType | type, | ||
GrAccessPattern | pattern | ||
) |
Same as above but also fills the buffer from data.
Definition at line 640 of file GrResourceProvider.cpp.
sk_sp< GrGpuBuffer > GrResourceProvider::createBuffer | ( | size_t | size, |
GrGpuBufferType | intendedType, | ||
GrAccessPattern | accessPattern, | ||
ZeroInit | zeroInit | ||
) |
Returns a buffer.
size | minimum size of buffer to return. |
GrGpuBufferType | hint to the graphics subsystem about what the buffer will be used for. |
GrAccessPattern | hint to the graphics subsystem about how the data will be accessed. |
ZeroInit | if kYes zero-initialize the buffer. Otherwise, contents are undefined. |
Definition at line 596 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::createCompressedTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
skgpu::Budgeted | budgeted, | ||
skgpu::Mipmapped | mipmapped, | ||
skgpu::Protected | isProtected, | ||
SkData * | data, | ||
std::string_view | label | ||
) |
Creates a compressed texture. The GrGpu must support the SkImageImage::Compression type. It will not be renderable.
Definition at line 211 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::createTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
GrColorType | srcColorType, | ||
skgpu::Renderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Budgeted | budgeted, | ||
SkBackingFit | fit, | ||
skgpu::Protected | isProtected, | ||
const GrMipLevel & | mipLevel, | ||
std::string_view | label | ||
) |
Create a potentially loose fit texture with the provided data. The color type must be valid for the format and also describe the texel data. This will ensure any conversions that need to get applied to the data before upload are applied.
Definition at line 155 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::createTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
GrColorType | colorType, | ||
skgpu::Renderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Budgeted | budgeted, | ||
skgpu::Mipmapped | mipmapped, | ||
skgpu::Protected | isProtected, | ||
const GrMipLevel | texels[], | ||
std::string_view | label | ||
) |
Create an exact fit texture with initial data to upload. The color type must be valid for the format and also describe the texel data. This will ensure any conversions that need to get applied to the data before upload are applied.
Definition at line 60 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::createTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
skgpu::Renderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Mipmapped | mipmapped, | ||
skgpu::Budgeted | budgeted, | ||
skgpu::Protected | isProtected, | ||
std::string_view | label | ||
) |
Create an exact fit texture with no initial data to upload.
Definition at line 231 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::findAndRefScratchTexture | ( | const skgpu::ScratchKey & | key, |
std::string_view | label | ||
) |
Search the cache for a scratch texture matching the provided arguments. Failing that it returns null. If non-null, the resulting texture is always budgeted.
Definition at line 330 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::findAndRefScratchTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
skgpu::Renderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Mipmapped | mipmapped, | ||
skgpu::Protected | isProtected, | ||
std::string_view | label | ||
) |
Definition at line 345 of file GrResourceProvider.cpp.
|
inline |
Finds a resource in the cache, based on the specified key. Prior to calling this, the caller must be sure that if a resource of exists in the cache with the given unique key then it is of type T.
Definition at line 70 of file GrResourceProvider.h.
|
inline |
Either finds and refs, or creates an index buffer with a repeating pattern for drawing contiguous vertices of a repeated mesh. If the return is non-null, the caller owns a ref on the returned GrBuffer.
pattern | the pattern of indices to repeat |
patternSize | size in bytes of the pattern |
reps | number of times to repeat the pattern |
vertCount | number of vertices the pattern references |
key | Key to be assigned to the index buffer. |
Definition at line 254 of file GrResourceProvider.h.
sk_sp< const GrGpuBuffer > GrResourceProvider::findOrMakeStaticBuffer | ( | GrGpuBufferType | intendedType, |
size_t | size, | ||
const skgpu::UniqueKey & | key, | ||
InitializeBufferFn | initializeBufferFn | ||
) |
Definition at line 460 of file GrResourceProvider.cpp.
sk_sp< const GrGpuBuffer > GrResourceProvider::findOrMakeStaticBuffer | ( | GrGpuBufferType | intendedType, |
size_t | size, | ||
const void * | staticData, | ||
const skgpu::UniqueKey & | key | ||
) |
Either finds and refs, or creates a static buffer with the given parameters and contents.
intendedType | hint to the graphics subsystem about what the buffer will be used for. |
size | minimum size of buffer to return. |
data | optional data with which to initialize the buffer. |
key | Key to be assigned to the buffer. |
Definition at line 438 of file GrResourceProvider.cpp.
sk_sp< GrAttachment > GrResourceProvider::getDiscardableMSAAAttachment | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
int | sampleCnt, | ||
skgpu::Protected | isProtected, | ||
GrMemoryless | memoryless | ||
) |
Gets a GrAttachment that can be used for MSAA rendering. This attachment may be shared by other users. Thus any renderpass that uses the attachment should not assume any specific data at the start and should not try to save written data at the end. Ideally the render pass should discard the data at the end.
Definition at line 716 of file GrResourceProvider.cpp.
sk_sp< GrAttachment > GrResourceProvider::makeMSAAAttachment | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
int | sampleCnt, | ||
skgpu::Protected | isProtected, | ||
GrMemoryless | isMemoryless | ||
) |
Definition at line 760 of file GrResourceProvider.cpp.
std::unique_ptr< GrSemaphore > GrResourceProvider::makeSemaphore | ( | bool | isOwned = true | ) |
Definition at line 832 of file GrResourceProvider.cpp.
|
static |
Definition at line 590 of file GrResourceProvider.cpp.
|
static |
Definition at line 562 of file GrResourceProvider.cpp.
|
static |
Definition at line 592 of file GrResourceProvider.cpp.
|
static |
Definition at line 564 of file GrResourceProvider.cpp.
|
static |
Definition at line 591 of file GrResourceProvider.cpp.
|
static |
Definition at line 563 of file GrResourceProvider.cpp.
|
inline |
Definition at line 364 of file GrResourceProvider.h.
|
inline |
Definition at line 32 of file GrResourceProviderPriv.h.
|
inline |
Definition at line 34 of file GrResourceProviderPriv.h.
|
inline |
Returns an index buffer that can be used to render antialiased quads. Each quad consumes 30 indices and 8 vertices. Call MaxNumAAQuads to get the max allowed number of AA quads. Draw with GrPrimitiveType::kTriangles @ return the AA quad index buffer
Definition at line 290 of file GrResourceProvider.h.
|
inline |
Returns an index buffer that can be used to render non-antialiased quads. Each quad consumes 6 indices (0, 1, 2, 2, 1, 3) and 4 vertices. Call MaxNumNonAAQuads to get the max allowed number of non-AA quads. Draw with GrPrimitiveType::kTriangles @ return the non-AA quad index buffer
Definition at line 272 of file GrResourceProvider.h.
sk_sp< GrRenderTarget > GrResourceProvider::wrapBackendRenderTarget | ( | const GrBackendRenderTarget & | backendRT | ) |
Wraps an existing render target with a GrRenderTarget object. It is similar to wrapBackendTexture but can be used to draw into surfaces that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that the client will resolve to a texture). Currently wrapped render targets always use the kBorrow_GrWrapOwnership and GrWrapCacheable::kNo semantics.
Definition at line 409 of file GrResourceProvider.cpp.
std::unique_ptr< GrSemaphore > GrResourceProvider::wrapBackendSemaphore | ( | const GrBackendSemaphore & | semaphore, |
GrSemaphoreWrapType | wrapType, | ||
GrWrapOwnership | ownership = kBorrow_GrWrapOwnership |
||
) |
Definition at line 836 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::wrapBackendTexture | ( | const GrBackendTexture & | tex, |
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable, | ||
GrIOType | ioType | ||
) |
Wraps an existing texture with a GrTexture object.
GrIOType must either be kRead or kRW. kRead blocks any operations that would modify the pixels (e.g. dst for a copy, regenerating MIP levels, write pixels).
OpenGL: if the object is a texture Gr may change its GL texture params when it is drawn.
Definition at line 375 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::wrapCompressedBackendTexture | ( | const GrBackendTexture & | tex, |
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable | ||
) |
Definition at line 386 of file GrResourceProvider.cpp.
sk_sp< GrTexture > GrResourceProvider::wrapRenderableBackendTexture | ( | const GrBackendTexture & | tex, |
int | sampleCnt, | ||
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable | ||
) |
This makes the backend texture be renderable. If sampleCnt is > 1 and the underlying API uses separate MSAA render buffers then a MSAA render buffer is created that resolves to the texture.
Definition at line 398 of file GrResourceProvider.cpp.
sk_sp< GrRenderTarget > GrResourceProvider::wrapVulkanSecondaryCBAsRenderTarget | ( | const SkImageInfo & | imageInfo, |
const GrVkDrawableInfo & | vkInfo | ||
) |
Definition at line 415 of file GrResourceProvider.cpp.
|
friend |
Definition at line 421 of file GrResourceProvider.h.