36#define ASSERT_SINGLE_OWNER SKGPU_ASSERT_SINGLE_OWNER(fImageContext->priv().singleOwner())
76 fUniquelyKeyedProxies.
add(proxy);
86 fUniquelyKeyedProxies.
add(proxy);
117#if defined(GR_TEST_UTILS)
122 int renderTargetSampleCnt,
135 if (this->
caps()->isFormatCompressed(
format)) {
150 renderTargetSampleCnt,
152 "InstantiatedProxyViaApproxTexture_Test");
158 renderTargetSampleCnt,
159 skgpu::Mipmapped::kNo,
162 "InstantiatedProxyViaTexture_Test");
168 return this->createWrapped(std::move(tex), UseAllocator::kYes);
175 int renderTargetSampleCnt,
184 return this->testingOnly_createInstantiatedProxy(dimensions,
187 renderTargetSampleCnt,
194 return this->createWrapped(std::move(tex), UseAllocator::kYes);
199 UseAllocator useAllocator) {
201 if (tex->getUniqueKey().isValid()) {
206 if (tex->asRenderTarget()) {
243 result = this->createWrapped(std::move(
texture), useAllocator);
262 if (proxy->asRenderTargetProxy()) {
265 SkASSERT(expectedFormat == proxy->backendFormat());
268 return {std::move(proxy), origin, swizzle};
287 skgpu::Mipmapped::kYes == mipmapped ?
"MipMap " :
"",
296 copyBitmap.allocPixels();
297 if (!
bitmap.readPixels(copyBitmap.pixmap())) {
300 if (mipmapped == skgpu::Mipmapped::kYes &&
bitmap.fMips) {
304 if (copyBitmap.fMips) {
305 for (
int i = 0; i < copyBitmap.fMips->countLevels(); ++i) {
307 bitmap.fMips->getLevel(i, &src);
308 copyBitmap.fMips->getLevel(i, &dst);
309 src.fPixmap.readPixels(dst.fPixmap);
313 copyBitmap.setImmutable();
317 if (mipmapped == skgpu::Mipmapped::kNo ||
319 proxy = this->createNonMippedProxyFromBitmap(copyBitmap, fit, budgeted);
321 proxy = this->createMippedProxyFromBitmap(copyBitmap, budgeted);
344 auto dims =
bitmap.dimensions();
371 skgpu::Mipmapped::kNo,
378 "ProxyProvider_CreateNonMippedProxyFromBitmap");
405 auto dims =
bitmap.dimensions();
409 const int mipLevelCount = mipmaps->countLevels() + 1;
410 std::unique_ptr<GrMipLevel[]> texels(
new GrMipLevel[mipLevelCount]);
413 texels[0].fPixels =
bitmap.getPixels();
414 texels[0].fRowBytes =
bitmap.rowBytes();
416 for (
int i = 1; i < mipLevelCount; ++i) {
418 mipmaps->getLevel(i - 1, &generatedMipLevel);
419 texels[i].fPixels = generatedMipLevel.
fPixmap.
addr();
431 skgpu::Mipmapped::kYes,
438 skgpu::Mipmapped::kYes,
445 "ProxyProvider_CreateMippedProxyFromBitmap");
459 int renderTargetSampleCnt,
464 std::string_view label,
479 if (skgpu::Mipmapped::kYes == mipmapped) {
483 mipmapped = skgpu::Mipmapped::kNo;
490 renderTargetSampleCnt,
495 GrMipmapStatus mipmapStatus = (skgpu::Mipmapped::kYes == mipmapped)
498 if (renderable == GrRenderable::kYes) {
507 renderTargetSampleCnt,
513 surfaceFlags | extraFlags,
550 GrMipmapStatus mipmapStatus = (skgpu::Mipmapped::kYes == mipmapped)
574 "ProxyProvider_CreateCompressedTextureProxy");
619 tex->setRelease(std::move(releaseHelper));
654 tex->setRelease(std::move(releaseHelper));
689 backendTex, sampleCnt, ownership, cacheable);
695 tex->setRelease(std::move(releaseHelper));
736 rt->setRelease(std::move(releaseHelper));
740 SkASSERT(!rt->getUniqueKey().isValid());
768 GrMipmapStatus mipmapStatus = (skgpu::Mipmapped::kYes == mipmapped)
786 proxy->priv().setIsPromiseProxy();
800 std::string_view label) {
812 if (dimensions.
fWidth > this->caps()->maxTextureSize() ||
813 dimensions.
fHeight > this->caps()->maxTextureSize()) {
842 bool wrapsVkSecondaryCB,
851 if (dimensions.
fWidth > this->caps()->maxRenderTargetSize() ||
852 dimensions.
fHeight > this->caps()->maxRenderTargetSize()) {
873 this->isDDLProvider(),
874 "TextureRenderTarget_LazyRenderTargetProxy"));
892 "RenderTargetProxy_LazyRenderTargetProxy"));
898 int renderTargetSampleCnt,
906 SkASSERT(renderTargetSampleCnt == 1 || renderable == GrRenderable::kYes);
914 static constexpr SkISize kLazyDims = {-1, -1};
915 if (GrRenderable::kYes == renderable) {
921 renderTargetSampleCnt,
922 skgpu::Mipmapped::kNo,
930 "TextureRenderTarget_FullyLazyProxy"));
935 skgpu::Mipmapped::kNo,
943 "Texture_FullyLazyProxy"));
950 this->processInvalidUniqueKeyImpl(
key, proxy, invalidateGPUResource, RemoveTableEntry::kYes);
955 InvalidateGPUResource invalidateGPUResource,
956 RemoveTableEntry removeTableEntry) {
960 proxy = fUniquelyKeyedProxies.
find(
key);
973 SkASSERT(!invalidGpuResource || invalidGpuResource->getUniqueKey() ==
key);
979 if (removeTableEntry == RemoveTableEntry::kYes) {
985 if (invalidGpuResource) {
986 invalidGpuResource->resourcePriv().removeUniqueKey();
999 return fImageContext->
priv().
caps();
1012 proxy->fProxyProvider =
nullptr;
1020 this->processInvalidUniqueKeyImpl(proxy->
getUniqueKey(), proxy,
1022 RemoveTableEntry::kNo);
1025 fUniquelyKeyedProxies.
reset();
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool SkImageInfoIsValid(const SkImageInfo &info)
sk_sp< T > sk_ref_sp(T *obj)
#define ATRACE_ANDROID_FRAMEWORK(fmt,...)
GrBackendFormat getBackendFormat() const
sk_sp< const GrCaps > refCaps() const
uint32_t contextID() const
const GrCaps * caps() const
std::tuple< GrColorType, GrBackendFormat > getFallbackColorTypeAndFormat(GrColorType, int sampleCount) const
virtual GrInternalSurfaceFlags getExtraSurfaceFlagsForDeferredRT() const
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
int maxTextureSize() const
virtual GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const =0
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
bool isFormatCompressed(const GrBackendFormat &format) const
bool validateSurfaceParams(const SkISize &, const GrBackendFormat &, GrRenderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped, GrTextureType) const
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
const GrCaps * caps() const
GrContextThreadSafeProxyPriv priv()
virtual GrDirectContext * asDirectContext()
SK_API GrBackendApi backend() const
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
const skgpu::UniqueKey & getUniqueKey() const
GrImageContextPriv priv()
void orphanAllUniqueKeys()
uint32_t contextID() const
void removeUniqueKeyFromProxy(GrTextureProxy *)
sk_sp< GrRenderTargetProxy > createLazyRenderTargetProxy(LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, int renderTargetSampleCnt, GrInternalSurfaceFlags, const TextureInfo *, GrMipmapStatus, SkBackingFit, skgpu::Budgeted, GrProtected, bool wrapsVkSecondaryCB, UseAllocator useAllocator)
GrSurfaceProxyView findCachedProxyWithColorTypeFallback(const skgpu::UniqueKey &, GrSurfaceOrigin, GrColorType, int sampleCnt)
GrResourceProvider * resourceProvider() const
sk_sp< const GrCaps > refCaps() const
GrProxyProvider(GrImageContext *)
sk_sp< GrTextureProxy > findProxyByUniqueKey(const skgpu::UniqueKey &)
sk_sp< GrTextureProxy > createLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, skgpu::Mipmapped, GrMipmapStatus, GrInternalSurfaceFlags, SkBackingFit, skgpu::Budgeted, GrProtected, UseAllocator, std::string_view label)
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
GrSurfaceProxy::LazyCallbackResult LazyCallbackResult
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrDDLProvider isDDLProvider() const
sk_sp< GrTextureProxy > wrapCompressedBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, sk_sp< skgpu::RefCntedCallback >)
static sk_sp< GrTextureProxy > CreatePromiseProxy(GrContextThreadSafeProxy *, LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, skgpu::Mipmapped)
bool assignUniqueKeyToProxy(const skgpu::UniqueKey &, GrTextureProxy *)
sk_sp< GrTextureProxy > findOrCreateProxyByUniqueKey(const skgpu::UniqueKey &, UseAllocator=UseAllocator::kYes)
void processInvalidUniqueKey(const skgpu::UniqueKey &, GrTextureProxy *, InvalidateGPUResource)
sk_sp< GrTextureProxy > wrapRenderableBackendTexture(const GrBackendTexture &, int sampleCnt, GrWrapOwnership, GrWrapCacheable, sk_sp< skgpu::RefCntedCallback > releaseHelper)
void adoptUniqueKeyFromSurface(GrTextureProxy *proxy, const GrSurface *)
sk_sp< GrSurfaceProxy > wrapBackendRenderTarget(const GrBackendRenderTarget &, sk_sp< skgpu::RefCntedCallback > releaseHelper)
static sk_sp< GrTextureProxy > MakeFullyLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, GrRenderable, int renderTargetSampleCnt, GrProtected, const GrCaps &, UseAllocator)
void removeAllUniqueKeys()
bool renderingDirectly() const
sk_sp< GrTextureProxy > createProxyFromBitmap(const SkBitmap &, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted)
GrSurfaceProxy::LazySurfaceDesc LazySurfaceDesc
GrSurfaceProxy::LazyInstantiateCallback LazyInstantiateCallback
sk_sp< GrTextureProxy > createCompressedTextureProxy(SkISize dimensions, skgpu::Budgeted, skgpu::Mipmapped, GrProtected, SkTextureCompressionType, sk_sp< SkData > data)
const GrCaps * caps() const
GrGpuResource * findAndRefUniqueResource(const skgpu::UniqueKey &key)
sk_sp< GrRenderTarget > wrapBackendRenderTarget(const GrBackendRenderTarget &)
std::enable_if< std::is_base_of< GrGpuResource, T >::value, sk_sp< T > >::type findByUniqueKey(const skgpu::UniqueKey &key)
sk_sp< GrTexture > createApproxTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Protected isProtected, std::string_view label)
sk_sp< GrTexture > wrapBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable, GrIOType)
GrResourceProviderPriv priv()
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< GrTexture > createCompressedTexture(SkISize dimensions, const GrBackendFormat &, skgpu::Budgeted, skgpu::Mipmapped, skgpu::Protected, SkData *data, std::string_view label)
sk_sp< GrTexture > wrapCompressedBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable)
sk_sp< GrTexture > wrapRenderableBackendTexture(const GrBackendTexture &tex, int sampleCnt, GrWrapOwnership, GrWrapCacheable)
const skgpu::UniqueKey & getUniqueKey() const override
CacheAccess cacheAccess()
const SkImageInfo & info() const
static SkMipmap * Build(const SkPixmap &src, SkDiscardableFactoryProc, bool computeContents=true)
static int ComputeLevelCount(int baseWidth, int baseHeight)
SkColorType colorType() const
const void * addr() const
T * find(const Key &key) const
void remove(const Key &key)
void reset(T *ptr=nullptr)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
#define ASSERT_SINGLE_OWNER
skgpu::Mipmapped fMipmapped