46#define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(fSingleOwner)
65 int renderTargetSampleCnt,
70 std::string_view label) {
73 if (this->isAbandoned()) {
78 if (mipmapped == skgpu::Mipmapped::kYes) {
85 renderTargetSampleCnt,
91 bool hasPixels = texels[0].
fPixels;
92 auto scratch = this->getExactScratch(dimensions,
96 renderTargetSampleCnt,
105 return this->writePixels(std::move(scratch),
colorType, dimensions, texels, numMipLevels);
111 tempColorType = this->prepareLevels(
format,
colorType, dimensions, texels, numMipLevels,
112 &tmpTexels, &tmpDatas);
121 renderTargetSampleCnt,
135 int renderTargetSampleCnt,
139 std::string_view label) {
144 renderTargetSampleCnt,
149 tex->resourcePriv().makeUnbudgeted();
160 int renderTargetSampleCnt,
165 std::string_view label) {
173 if (this->isAbandoned()) {
179 renderTargetSampleCnt,
180 skgpu::Mipmapped::kNo,
189 renderTargetSampleCnt,
195 return this->writePixels(std::move(tex),
colorType, dimensions, &mipLevel, 1);
202 renderTargetSampleCnt,
204 skgpu::Mipmapped::kNo,
217 std::string_view label) {
219 if (this->isAbandoned()) {
235 int renderTargetSampleCnt,
239 std::string_view label) {
241 if (this->isAbandoned()) {
246 mipmapped, textureType)) {
256 this->getExactScratch(dimensions,
260 renderTargetSampleCnt,
273 renderTargetSampleCnt,
284 int renderTargetSampleCnt,
286 std::string_view label) {
289 if (this->isAbandoned()) {
300 renderTargetSampleCnt,
301 skgpu::Mipmapped::kNo,
312 renderTargetSampleCnt,
313 skgpu::Mipmapped::kNo,
323 renderTargetSampleCnt,
324 skgpu::Mipmapped::kNo,
331 std::string_view label) {
339 resource->
setLabel(std::move(label));
349 int renderTargetSampleCnt,
352 std::string_view label) {
359 renderTargetSampleCnt,
360 skgpu::Mipmapped::kNo,
368 renderTargetSampleCnt, mipmapped, isProtected, &
key);
380 if (this->isAbandoned()) {
390 if (this->isAbandoned()) {
403 if (this->isAbandoned()) {
426 if (this->isAbandoned() || !resource) {
434 return this->isAbandoned() ? nullptr
440 const void* staticData,
442 if (
auto buffer = this->findByUniqueKey<GrGpuBuffer>(
key)) {
455 buffer->resourcePriv().setUniqueKey(
key);
465 if (
auto buffer = this->findByUniqueKey<GrGpuBuffer>(uniqueKey)) {
481 buffer->resourcePriv().setUniqueKey(uniqueKey);
488 vertexWriter = {stagingBuffer.
reset(size), size};
491 initializeBufferFn(std::move(vertexWriter), size);
496 buffer->updateData(stagingBuffer, 0, size,
false);
503 const uint16_t* pattern,
508 size_t bufferSize = patternSize * reps *
sizeof(uint16_t);
520 temp.
reset(reps * patternSize);
523 for (
int i = 0; i < reps; ++i) {
524 int baseIdx = i * patternSize;
525 uint16_t baseVert = (uint16_t)(i * vertCount);
526 for (
int j = 0; j < patternSize; ++j) {
527 data[baseIdx+j] = baseVert + pattern[j];
531 if (!
buffer->updateData(data, 0, bufferSize,
false)) {
552 static const uint16_t kNonAAQuadIndexPattern[] = {
575 static const uint16_t kAAQuadIndexPattern[] = {
600 if (this->isAbandoned()) {
604 if (this->
caps()->buffersAreInitiallyZero()) {
614 static const size_t MIN_SIZE = 1 << 12;
615 static const size_t MIN_UNIFORM_SIZE = 1 << 7;
617 : std::max(size, MIN_SIZE);
619 size_t floorPow2 = ceilPow2 >> 1;
620 size_t mid = floorPow2 + (floorPow2 >> 1);
621 allocSize = (allocSize <= mid) ? mid : ceilPow2;
629 if (this->
caps()->buffersAreInitiallyZero()) {
649 if (!
buffer->updateData(data, 0, size,
false)) {
657 if (numSamples == 1 && useMSAASurface) {
678 if (this->
caps()->oversizedStencilSupport()) {
684 if (!stencilFormat.
isValid()) {
694 skgpu::Mipmapped::kNo,
698 auto keyedStencil = this->findByUniqueKey<GrAttachment>(sbKey);
713 return stencil !=
nullptr;
725 if (this->isAbandoned()) {
733 skgpu::Mipmapped::kNo,
744 skgpu::Mipmapped::kNo,
748 auto msaaAttachment = this->findByUniqueKey<GrAttachment>(
key);
749 if (msaaAttachment) {
750 return msaaAttachment;
754 if (msaaAttachment) {
757 return msaaAttachment;
769 if (this->isAbandoned()) {
777 skgpu::Mipmapped::kNo,
782 auto scratch = this->refScratchMSAAAttachment(dimensions,
787 "MakeMSAAAttachment");
800 std::string_view label) {
808 skgpu::Mipmapped::kNo,
817 skgpu::Mipmapped::kNo,
825 resource->
setLabel(std::move(label));
833 return this->isAbandoned() ? nullptr : fGpu->
makeSemaphore(isOwned);
850 bool rowBytesSupport,
854 std::unique_ptr<
char[]>* data) {
862 if (actualRB < minRB) {
865 if (origColorType == allowedColorType && (actualRB == minRB || rowBytesSupport)) {
872 outLevel->
fPixels = data->get();
885 TempLevels* tempLevels,
886 TempLevelDatas* tempLevelDatas)
const {
887 SkASSERT(mipLevelCount && texels && texels[0].fPixels);
889 auto allowedColorType =
895 tempLevels->reset(mipLevelCount);
896 tempLevelDatas->reset(mipLevelCount);
897 auto size = baseSize;
898 for (
int i = 0; i < mipLevelCount; ++i) {
900 &(*tempLevels)[i], &(*tempLevelDatas)[i])) {
903 size = {std::max(
size.fWidth / 2, 1), std::max(
size.fHeight / 2, 1)};
905 return allowedColorType;
912 int mipLevelCount)
const {
916 SkASSERT(mipLevelCount && texels && texels[0].fPixels);
920 auto tempColorType = this->prepareLevels(
texture->backendFormat(),
colorType, baseSize, texels,
921 mipLevelCount, &tmpTexels, &tmpDatas);
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
static const int kIndicesPerNonAAQuad
static int num_stencil_samples(const GrRenderTarget *rt, bool useMSAASurface, const GrCaps &caps)
static constexpr int kMaxNumAAQuads
static const int kVertsPerAAQuad
static constexpr int kMaxNumNonAAQuads
static const int kIndicesPerAAQuad
static bool prepare_level(const GrMipLevel &inLevel, SkISize dimensions, bool rowBytesSupport, GrColorType origColorType, GrColorType allowedColorType, GrMipLevel *outLevel, std::unique_ptr< char[]> *data)
static const int kVertsPerNonAAQuad
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
@ kDynamic_GrAccessPattern
@ kStatic_GrAccessPattern
#define SkAssertResult(cond)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static int SkNextPow2(int value)
static size_t GrNextSizePow2(size_t n)
sk_sp< T > sk_ref_sp(T *obj)
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, skgpu::ScratchKey *key)
static void ComputeSharedAttachmentUniqueKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless, skgpu::UniqueKey *key)
virtual SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const =0
bool validateSurfaceParams(const SkISize &, const GrBackendFormat &, GrRenderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped, GrTextureType) const
bool writePixelsRowBytesSupport() const
bool reuseScratchTextures() const
int internalMultisampleCount(const GrBackendFormat &format) const
static void ComputeScratchKeyForDynamicBuffer(size_t size, GrGpuBufferType, skgpu::ScratchKey *)
void setUniqueKey(const skgpu::UniqueKey &key)
bool wasDestroyed() const
void setLabel(std::string_view label)
ResourcePriv resourcePriv()
void incNumScratchTexturesReused()
void incNumScratchMSAAAttachmentsReused()
virtual std::unique_ptr< GrSemaphore > makeSemaphore(bool isOwned=true)=0
bool writePixels(GrSurface *surface, SkIRect rect, GrColorType surfaceColorType, GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount, bool prepForTexSampling=false)
const GrCaps * caps() const
virtual sk_sp< GrAttachment > makeStencilAttachment(const GrBackendFormat &colorFormat, SkISize dimensions, int numStencilSamples)=0
sk_sp< GrTexture > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType)
virtual sk_sp< GrAttachment > makeMSAAAttachment(SkISize dimensions, const GrBackendFormat &format, int numSamples, GrProtected isProtected, GrMemoryless isMemoryless)=0
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType intendedType, GrAccessPattern accessPattern)
virtual GrBackendFormat getPreferredStencilFormat(const GrBackendFormat &)=0
sk_sp< GrRenderTarget > wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo &, const GrVkDrawableInfo &)
sk_sp< GrRenderTarget > wrapBackendRenderTarget(const GrBackendRenderTarget &)
sk_sp< GrTexture > wrapCompressedBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable)
sk_sp< GrTexture > 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)
virtual std::unique_ptr< GrSemaphore > wrapBackendSemaphore(const GrBackendSemaphore &, GrSemaphoreWrapType, GrWrapOwnership)=0
sk_sp< GrTexture > createCompressedTexture(SkISize dimensions, const GrBackendFormat &format, skgpu::Budgeted budgeted, skgpu::Mipmapped mipmapped, GrProtected isProtected, const void *data, size_t dataSize)
sk_sp< GrTexture > wrapRenderableBackendTexture(const GrBackendTexture &, int sampleCnt, GrWrapOwnership, GrWrapCacheable)
void attachStencilAttachment(sk_sp< GrAttachment > stencil, bool useMSAASurface)
GrAttachment * getStencilAttachment(bool useMSAASurface) const
virtual bool canAttemptStencilAttachment(bool useMSAASurface) const =0
GrGpuResource * findAndRefScratchResource(const skgpu::ScratchKey &scratchKey)
GrGpuResource * findAndRefUniqueResource(const skgpu::UniqueKey &key)
bool attachStencilAttachment(GrRenderTarget *rt, bool useMSAASurface)
static int NumIndicesPerNonAAQuad()
sk_sp< GrRenderTarget > wrapBackendRenderTarget(const GrBackendRenderTarget &)
static int MaxNumNonAAQuads()
sk_sp< GrAttachment > getDiscardableMSAAAttachment(SkISize dimensions, const GrBackendFormat &format, int sampleCnt, skgpu::Protected isProtected, GrMemoryless memoryless)
GrResourceProvider(GrGpu *, GrResourceCache *, skgpu::SingleOwner *)
sk_sp< GrTexture > createApproxTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Protected isProtected, std::string_view label)
void assignUniqueKeyToResource(const skgpu::UniqueKey &, GrGpuResource *)
std::unique_ptr< GrSemaphore > makeSemaphore(bool isOwned=true)
void(*)(skgpu::VertexWriter, size_t bufferSize) InitializeBufferFn
static int MaxNumAAQuads()
std::unique_ptr< GrSemaphore > wrapBackendSemaphore(const GrBackendSemaphore &, GrSemaphoreWrapType, GrWrapOwnership=kBorrow_GrWrapOwnership)
sk_sp< GrTexture > wrapBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable, GrIOType)
static int NumIndicesPerAAQuad()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
sk_sp< GrTexture > findAndRefScratchTexture(const skgpu::ScratchKey &, std::string_view label)
static int NumVertsPerAAQuad()
static int NumVertsPerNonAAQuad()
sk_sp< GrTexture > 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)
sk_sp< const GrGpuBuffer > findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size, const skgpu::UniqueKey &key, InitializeBufferFn)
sk_sp< GrRenderTarget > wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo &, const GrVkDrawableInfo &)
sk_sp< GrTexture > createCompressedTexture(SkISize dimensions, const GrBackendFormat &, skgpu::Budgeted, skgpu::Mipmapped, skgpu::Protected, SkData *data, std::string_view label)
sk_sp< GrAttachment > makeMSAAAttachment(SkISize dimensions, const GrBackendFormat &format, int sampleCnt, skgpu::Protected isProtected, GrMemoryless isMemoryless)
sk_sp< GrTexture > wrapCompressedBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable)
sk_sp< GrTexture > wrapRenderableBackendTexture(const GrBackendTexture &tex, int sampleCnt, GrWrapOwnership, GrWrapCacheable)
const GrCaps * caps() const
virtual GrBackendFormat backendFormat() const =0
SkISize dimensions() const
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
static int ComputeLevelCount(int baseWidth, int baseHeight)
void reset(size_t count=0)
T * reset(size_t count=0)
static const uint8_t buffer[]
uint32_t uint32_t * format
#define ASSERT_SINGLE_OWNER
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkISize GetApproxSize(SkISize size)
static constexpr SkIRect MakeSize(const SkISize &size)
SkISize dimensions() const