![]() |
Flutter Engine
The Flutter Engine
|
#include <GrGpu.h>
Classes | |
class | Stats |
Public Types | |
enum class | DisconnectType { kAbandon , kCleanup } |
Protected Member Functions | |
void | didWriteToSurface (GrSurface *surface, GrSurfaceOrigin origin, const SkIRect *bounds, uint32_t mipLevels=1) const |
void | setOOMed () |
void | initCaps (sk_sp< const GrCaps > caps) |
Static Protected Member Functions | |
static bool | CompressedDataIsCorrect (SkISize dimensions, SkTextureCompressionType, skgpu::Mipmapped, const void *data, size_t length) |
Protected Attributes | |
Stats | fStats |
|
strong |
Enumerator | |
---|---|
kAbandon | |
kCleanup |
Definition at line 80 of file GrGpu.h.
GrGpu::GrGpu | ( | GrDirectContext * | direct | ) |
Definition at line 41 of file GrGpu.cpp.
|
virtual |
|
pure virtual |
|
inline |
bool GrGpu::checkAndResetOOMed | ( | ) |
|
pure virtual |
bool GrGpu::clearBackendTexture | ( | const GrBackendTexture & | backendTexture, |
sk_sp< skgpu::RefCntedCallback > | finishedCallback, | ||
std::array< float, 4 > | color | ||
) |
|
pure virtual |
|
staticprotected |
Definition at line 858 of file GrGpu.cpp.
bool GrGpu::copySurface | ( | GrSurface * | dst, |
const SkIRect & | dstRect, | ||
GrSurface * | src, | ||
const SkIRect & | srcRect, | ||
GrSamplerState::Filter | filter | ||
) |
Definition at line 410 of file GrGpu.cpp.
GrBackendTexture GrGpu::createBackendTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrRenderable | renderable, | ||
skgpu::Mipmapped | mipmapped, | ||
GrProtected | isProtected, | ||
std::string_view | label | ||
) |
Creates a texture directly in the backend API without wrapping it in a GrTexture. Must be matched with a call to deleteBackendTexture().
If data is null the texture is uninitialized.
If data represents a color then all texture levels are cleared to that color.
If data represents pixmaps then it must have a either one pixmap or, if mipmapping is specified, a complete MIP hierarchy of pixmaps. Additionally, if provided, the mip levels must be sized correctly according to the MIP sizes implied by dimensions. They must all have the same color type and that color type must be compatible with the texture format.
Definition at line 868 of file GrGpu.cpp.
sk_sp< GrGpuBuffer > GrGpu::createBuffer | ( | size_t | size, |
GrGpuBufferType | intendedType, | ||
GrAccessPattern | accessPattern | ||
) |
Creates a buffer in GPU memory. For a client-side buffer use GrBuffer::CreateCPUBacked.
size | size of buffer to create. |
intendedType | hint to the graphics subsystem about what the buffer will be used for. |
accessPattern | hint to the graphics subsystem about how the data will be accessed. |
Definition at line 393 of file GrGpu.cpp.
GrBackendTexture GrGpu::createCompressedBackendTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
skgpu::Mipmapped | mipmapped, | ||
GrProtected | isProtected | ||
) |
Same as the createBackendTexture case except compressed backend textures can never be renderable.
Definition at line 912 of file GrGpu.cpp.
sk_sp< GrTexture > GrGpu::createCompressedTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
skgpu::Budgeted | budgeted, | ||
skgpu::Mipmapped | mipmapped, | ||
GrProtected | isProtected, | ||
const void * | data, | ||
size_t | dataSize | ||
) |
Definition at line 260 of file GrGpu.cpp.
sk_sp< GrTexture > GrGpu::createTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
GrRenderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Budgeted | budgeted, | ||
GrProtected | isProtected, | ||
GrColorType | textureColorType, | ||
GrColorType | srcColorType, | ||
const GrMipLevel | texels[], | ||
int | texelLevelCount, | ||
std::string_view | label | ||
) |
Creates a texture object. If renderable is kYes then the returned texture can be used as a render target by calling GrTexture::asRenderTarget(). Not all pixel configs can be used as render targets. Support for configs as textures or render targets can be checked using GrCaps.
dimensions | dimensions of the texture to be created. |
format | the format for the texture (not currently used). |
renderable | should the resulting texture be renderable |
renderTargetSampleCnt | The number of samples to use for rendering if renderable is kYes. If renderable is kNo then this must be 1. |
budgeted | does this texture count against the resource cache budget? |
isProtected | should the texture be created as protected. |
texels | array of mipmap levels containing texel data to load. If level i has pixels then it is assumed that its dimensions are max(1, floor(dimensions.fWidth / 2)) by max(1, floor(dimensions.fHeight / 2)). If texels[i].fPixels == nullptr for all i <= mipLevelCount or mipLevelCount is 0 then the texture's contents are uninitialized. If a level has non-null pixels, its row bytes must be a multiple of the config's bytes-per-pixel. The row bytes must be tight to the level width if !caps->writePixelsRowBytesSupport(). If mipLevelCount > 1 and texels[i].fPixels != nullptr for any i > 0 then all levels must have non-null pixels. All levels must have non-null pixels if GrCaps::createTextureMustSpecifyAllLevels() is true. |
textureColorType | The color type interpretation of the texture for the purpose of of uploading texel data. |
srcColorType | The color type of data in texels[]. |
texelLevelCount | the number of levels in 'texels'. May be 0, 1, or floor(max((log2(dimensions.fWidth), log2(dimensions.fHeight)))). It must be the latter if GrCaps::createTextureMustSpecifyAllLevels() is true. |
Definition at line 189 of file GrGpu.cpp.
sk_sp< GrTexture > GrGpu::createTexture | ( | SkISize | dimensions, |
const GrBackendFormat & | format, | ||
GrTextureType | textureType, | ||
GrRenderable | renderable, | ||
int | renderTargetSampleCnt, | ||
skgpu::Mipmapped | mipmapped, | ||
skgpu::Budgeted | budgeted, | ||
GrProtected | isProtected, | ||
std::string_view | label | ||
) |
Simplified createTexture() interface for when there is no initial texel data to upload.
Definition at line 156 of file GrGpu.cpp.
|
pure virtual |
Frees a texture created by createBackendTexture(). If ownership of the backend texture has been transferred to a context using adopt semantics this should not be called.
|
protected |
Definition at line 665 of file GrGpu.cpp.
|
virtual |
void GrGpu::dumpJSON | ( | SkJSONWriter * | writer | ) | const |
void GrGpu::executeFlushInfo | ( | SkSpan< GrSurfaceProxy * > | proxies, |
SkSurfaces::BackendSurfaceAccess | access, | ||
const GrFlushInfo & | info, | ||
const skgpu::MutableTextureState * | newState | ||
) |
Definition at line 682 of file GrGpu.cpp.
|
pure virtual |
|
inline |
|
inline |
GrOpsRenderPass * GrGpu::getOpsRenderPass | ( | GrRenderTarget * | renderTarget, |
bool | useMSAASurface, | ||
GrAttachment * | stencil, | ||
GrSurfaceOrigin | origin, | ||
const SkIRect & | bounds, | ||
const GrOpsRenderPass::LoadAndStoreInfo & | colorInfo, | ||
const GrOpsRenderPass::StencilLoadAndStoreInfo & | stencilInfo, | ||
const skia_private::TArray< GrSurfaceProxy *, true > & | sampledProxies, | ||
GrXferBarrierFlags | renderPassXferBarriers | ||
) |
Definition at line 730 of file GrGpu.cpp.
|
pure virtual |
|
inline |
|
pure virtual |
|
inlinevirtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
inline |
|
privatepure virtual |
|
privatepure virtual |
Implemented in GrMtlGpu.
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
Implemented in GrVkGpu.
|
inlineprivatevirtual |
|
inlineprivatevirtual |
|
inlineprivatevirtual |
|
privatepure virtual |
Implemented in GrVkGpu.
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatepure virtual |
|
privatevirtual |
|
privatepure virtual |
|
pure virtual |
|
inlineprivatevirtual |
|
pure virtual |
bool GrGpu::readPixels | ( | GrSurface * | surface, |
SkIRect | rect, | ||
GrColorType | surfaceColorType, | ||
GrColorType | dstColorType, | ||
void * | buffer, | ||
size_t | rowBytes | ||
) |
Reads a rectangle of pixels from a render target. No sRGB/linear conversions are performed.
surface | the surface to read from |
rect | the rectangle of pixels to read |
surfaceColorType | the color type for this use of the surface. |
dstColorType | the color type of the destination buffer. |
buffer | memory to read the rectangle into. |
rowBytes | the number of bytes between consecutive rows. Must be a multiple of dstColorType's bytes-per-pixel. Must be tight to width if !caps->readPixelsRowBytesSupport(). |
Definition at line 426 of file GrGpu.cpp.
|
pure virtual |
bool GrGpu::regenerateMipMapLevels | ( | GrTexture * | texture | ) |
Uses the base of the texture to recompute the contents of the other levels.
Definition at line 632 of file GrGpu.cpp.
|
inlinevirtual |
Frees any backend specific objects that are not currently in use by the GPU. This is called when the client is trying to free up as much GPU memory as possible. We will not release resources connected to programs/pipelines since the cost to recreate those is significantly higher that other resources.
Reimplemented in GrVkGpu.
Definition at line 453 of file GrGpu.h.
void GrGpu::resetTextureBindings | ( | ) |
If the backend API has stateful texture bindings, this resets them back to defaults.
void GrGpu::resolveRenderTarget | ( | GrRenderTarget * | target, |
const SkIRect & | resolveRect | ||
) |
Resolves MSAA. The resolveRect must already be in the native destination space.
Definition at line 659 of file GrGpu.cpp.
|
inlinevirtual |
|
inlinevirtual |
|
inlineprotected |
|
inlinevirtual |
|
inlinevirtual |
|
pure virtual |
bool GrGpu::submitToGpu | ( | GrSyncCpu | sync | ) |
Definition at line 748 of file GrGpu.cpp.
|
inlinevirtual |
bool GrGpu::transferFromBufferToBuffer | ( | sk_sp< GrGpuBuffer > | src, |
size_t | srcOffset, | ||
sk_sp< GrGpuBuffer > | dst, | ||
size_t | dstOffset, | ||
size_t | size | ||
) |
Transfer bytes from one GPU buffer to another. The src buffer must have type kXferCpuToGpu and the dst buffer must not. Neither buffer may currently be mapped. The offsets and size must be aligned to GrCaps::transferFromBufferToBufferAlignment.
src | the buffer to read from |
srcOffset | the aligned offset at the src at which the transfer begins. |
dst | the buffer to write to |
dstOffset | the aligned offset in the dst at which the transfer begins |
size | the aligned number of bytes to transfer; |
Definition at line 511 of file GrGpu.cpp.
bool GrGpu::transferPixelsFrom | ( | GrSurface * | surface, |
SkIRect | rect, | ||
GrColorType | surfaceColorType, | ||
GrColorType | bufferColorType, | ||
sk_sp< GrGpuBuffer > | transferBuffer, | ||
size_t | offset | ||
) |
Reads the pixels from a rectangle of a surface into a buffer. Use GrCaps::SupportedRead::fOffsetAlignmentForTransferBuffer to determine the requirements for the buffer offset alignment. If the surface is a MIP mapped texture, the base level is read.
If successful the row bytes in the buffer is always: GrColorTypeBytesPerPixel(bufferColorType) * rect.width()
Asserts that the caller has passed a properly aligned offset and that the buffer is large enough to hold the result
surface | the surface to read from. |
rect | the rectangle of pixels to read |
surfaceColorType | the color type for this use of the surface. |
bufferColorType | the color type of the transfer buffer's pixel data |
transferBuffer | GrBuffer to write pixels to (type must be "kXferGpuToCpu") |
offset | offset from the start of the buffer |
Definition at line 592 of file GrGpu.cpp.
bool GrGpu::transferPixelsTo | ( | GrTexture * | texture, |
SkIRect | rect, | ||
GrColorType | textureColorType, | ||
GrColorType | bufferColorType, | ||
sk_sp< GrGpuBuffer > | transferBuffer, | ||
size_t | offset, | ||
size_t | rowBytes | ||
) |
Updates the pixels in a rectangle of a texture using a buffer. If the texture is MIP mapped, the base level is written to.
texture | the texture to write to. |
rect | the rectangle of pixels in the texture to overwrite |
textureColorType | the color type for this use of the surface. |
bufferColorType | the color type of the transfer buffer's pixel data |
transferBuffer | GrBuffer to read pixels from (type must be "kXferCpuToGpu") |
offset | offset from the start of the buffer |
rowBytes | number of bytes between consecutive rows in the buffer. Must be a multiple of bufferColorType's bytes-per-pixel. Must be tight to rect.width() if !caps->writePixelsRowBytesSupport(). |
Definition at line 540 of file GrGpu.cpp.
|
inlinevirtual |
bool GrGpu::updateCompressedBackendTexture | ( | const GrBackendTexture & | backendTexture, |
sk_sp< skgpu::RefCntedCallback > | finishedCallback, | ||
const void * | data, | ||
size_t | length | ||
) |
Definition at line 941 of file GrGpu.cpp.
|
pure virtual |
|
inlinevirtual |
sk_sp< GrRenderTarget > GrGpu::wrapBackendRenderTarget | ( | const GrBackendRenderTarget & | backendRT | ) |
Implements GrResourceProvider::wrapBackendRenderTarget
Definition at line 366 of file GrGpu.cpp.
|
pure virtual |
sk_sp< GrTexture > GrGpu::wrapBackendTexture | ( | const GrBackendTexture & | backendTex, |
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable, | ||
GrIOType | ioType | ||
) |
Implements GrResourceProvider::wrapBackendTexture
Definition at line 297 of file GrGpu.cpp.
sk_sp< GrTexture > GrGpu::wrapCompressedBackendTexture | ( | const GrBackendTexture & | backendTex, |
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable | ||
) |
Definition at line 318 of file GrGpu.cpp.
sk_sp< GrTexture > GrGpu::wrapRenderableBackendTexture | ( | const GrBackendTexture & | backendTex, |
int | sampleCnt, | ||
GrWrapOwnership | ownership, | ||
GrWrapCacheable | cacheable | ||
) |
Implements GrResourceProvider::wrapRenderableBackendTexture
Definition at line 337 of file GrGpu.cpp.
sk_sp< GrRenderTarget > GrGpu::wrapVulkanSecondaryCBAsRenderTarget | ( | const SkImageInfo & | imageInfo, |
const GrVkDrawableInfo & | vkInfo | ||
) |
Implements GrResourceProvider::wrapVulkanSecondaryCBAsRenderTarget
Definition at line 382 of file GrGpu.cpp.
bool GrGpu::writePixels | ( | GrSurface * | surface, |
SkIRect | rect, | ||
GrColorType | surfaceColorType, | ||
GrColorType | srcColorType, | ||
const GrMipLevel | texels[], | ||
int | mipLevelCount, | ||
bool | prepForTexSampling = false |
||
) |
Updates the pixels in a rectangle of a surface. No sRGB/linear conversions are performed.
surface | the surface to write to. |
rect | the rectangle of pixels to overwrite |
surfaceColorType | the color type for this use of the surface. |
srcColorType | the color type of the source buffer. |
texels | array of mipmap levels containing texture data. Row bytes must be a multiple of srcColorType's bytes-per-pixel. Must be tight to level width if !caps->writePixelsRowBytesSupport(). |
mipLevelCount | number of levels in 'texels' |
prepForTexSampling | After doing write pixels should the surface be prepared for texture sampling. This is currently only used by Vulkan for inline uploads to set that layout back to sampled after doing the upload. Inline uploads currently can happen between draws in a single op so it is not trivial to break up the OpsTask into two tasks when we see an inline upload. However, once we are able to support doing that we can remove this parameter. |
Definition at line 461 of file GrGpu.cpp.
|
inline |
Helper for the case of a single level.
Definition at line 293 of file GrGpu.h.
|
pure virtual |