51#ifdef SK_IN_RENDERENGINE
87 auto dContext =
surface->recordingContext()->asDirectContext();
91 if (dContext->abandoned()) {
105 dContext->priv().flushSurface(
surface->getDevice()->targetProxy());
108 return surface->getDevice()->targetProxy()->peekRenderTarget();
118 return texture->getBackendTexture();
177 "SurfaceGpu_NewImageSnapshot");
187 return sk_make_sp<SkImage_Ganesh>(
215 std::move(dstColorSpace),
252 bool deleteSemaphoresAfterWait) {
253 return fDevice->
wait(numSemaphores, waitSemaphores, deleteSemaphoresAfterWait);
268 size_t maxResourceBytes = direct->getResourceCacheLimit();
279 bool vkRTSupportsInputAttachment =
286 characterization->set(
287 direct->threadSafeProxy(),
313 if (!canvasContext) {
316 if (canvasContext->priv().contextID() != surfaceContext->priv().contextID()) {
344 if (!characterization.
isValid()) {
348 if (characterization.vulkanSecondaryCBCompatible()) {
361 size_t maxResourceBytes = direct->getResourceCacheLimit();
363 if (characterization.isTextureable()) {
384 if (!characterization.usesGLFBO0() || characterization.
sampleCount() > 1) {
395 characterization.cacheMaxResourceBytes() <= maxResourceBytes &&
396 characterization.origin() == targetView.
origin() &&
397 characterization.backendFormat() ==
format && characterization.
width() == ii.
width() &&
402 characterization.isProtected() == isProtected &&
403 characterization.surfaceProps() == fDevice->
surfaceProps();
412 if (!direct || direct->abandoned()) {
438 if (!backendFormat.
isValid()) {
451 "%s failed due to no supported rendering path for the selected "
452 "format and colorType",
459 "%s failed due to no texturing support for the selected format and "
476 if (rContext->abandoned()) {
479 if (!backendTexture.
isValid()) {
482 if (backendTexture.
width() != this->width() || backendTexture.
height() != this->height()) {
486 auto oldProxy =
sk_ref_sp(oldRTP->asTextureProxy());
490 auto* oldTexture = oldProxy->peekTexture();
494 if (!oldTexture->resourcePriv().refsWrappedObjects()) {
500 if (oldTexture->getBackendTexture().isSameTexture(backendTexture)) {
503 SkASSERT(oldTexture->asRenderTarget());
504 int sampleCnt = oldTexture->asRenderTarget()->numSamples();
507 rContext->priv().caps(), backendTexture, sampleCnt, grColorType,
true)) {
519 std::move(releaseHelper)));
545 if (stencilBits != 0 && stencilBits != 8 && stencilBits != 16) {
556 if (!rContext || !c.
isValid()) {
560 if (c.usesGLFBO0()) {
565 if (c.vulkanSecondaryCBCompatible()) {
598 bool shouldCreateWithMips,
603 sampleCount =
std::max(1, sampleCount);
623 return sk_make_sp<SkSurface_Ganesh>(std::move(
device));
658 std::move(releaseHelper)));
662#ifdef SK_IN_RENDERENGINE
666 "%s failed to wrap the texture into a renderable target "
667 "\n\tGrBackendTexture: (%i x %i) hasMipmaps: %i isProtected: %i texType: %i"
668 "\n\t\tGrGLTextureInfo: success: %i fTarget: %u fFormat: %u"
669 "\n\tmaxRenderTargetSize: %d",
676 retrievedTextureInfo,
686 std::move(colorSpace),
695 return sk_make_sp<SkSurface_Ganesh>(std::move(
device));
729 std::move(colorSpace),
737 return sk_make_sp<SkSurface_Ganesh>(std::move(
device));
745 if (!sb->isGaneshBacked()) {
756 if (!sb->isGaneshBacked()) {
767 if (!sb->isGaneshBacked()) {
781 if (
auto rContext =
surface->recordingContext(); rContext !=
nullptr) {
782 return rContext->asDirectContext()->flush(
surface, {});
791 if (
auto rContext =
surface->recordingContext(); rContext !=
nullptr) {
792 return rContext->asDirectContext()->flush(
surface.get(), {});
801 if (
auto rContext =
surface->recordingContext(); rContext !=
nullptr) {
810 if (
auto rContext =
surface->recordingContext(); rContext !=
nullptr) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kBorrow_GrWrapOwnership
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
skgpu::Protected GrProtected
@ kUnknown_SkColorType
uninitialized
static void releaseProc(const void *ptr, void *context)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static SkImage_Base * as_IB(SkImage *image)
sk_sp< T > sk_ref_sp(T *obj)
#define RENDERENGINE_ABORTF(...)
static SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps *props)
static SkSurface_Base * asSB(SkSurface *surface)
bool validate_backend_render_target(const GrCaps *caps, const GrBackendRenderTarget &rt, GrColorType grCT)
static GrRenderTarget * prepare_rt_for_external_access(SkSurface_Ganesh *surface, SkSurfaces::BackendHandleAccess access)
static bool validate_backend_texture(const GrCaps *caps, const GrBackendTexture &tex, int sampleCnt, GrColorType grCT, bool texturable)
static constexpr bool SkToBool(const T &x)
GrBackendFormat getBackendFormat() const
GrBackendFormat getBackendFormat() const
GrTextureType textureType() const
const GrCaps * caps() const
bool mipmapSupport() const
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
int maxRenderTargetSize() const
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
bool matches(GrContext_Base *candidate) const
GrContextThreadSafeProxyPriv priv()
virtual GrDirectContext * asDirectContext()
SK_API const GrSurfaceCharacterization & characterization() const
sk_sp< GrTextureProxy > wrapRenderableBackendTexture(const GrBackendTexture &, int sampleCnt, GrWrapOwnership, GrWrapCacheable, sk_sp< skgpu::RefCntedCallback > releaseHelper)
sk_sp< GrSurfaceProxy > wrapBackendRenderTarget(const GrBackendRenderTarget &, sk_sp< skgpu::RefCntedCallback > releaseHelper)
GrProxyProvider * proxyProvider()
sk_sp< skgpu::ganesh::Device > createDevice(GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &, skgpu::ganesh::Device::InitContents)
GrRecordingContextPriv priv()
SK_API sk_sp< const SkCapabilities > skCapabilities() const
bool supportsVkInputAttachment() const
bool glRTFBOIDIs0() const
bool refsWrappedObjects() const
virtual GrBackendRenderTarget getBackendRenderTarget() const =0
SkColorSpace * colorSpace() const
GrContextThreadSafeProxy * contextInfo() const
const SkImageInfo & imageInfo() const
SkColorType colorType() const
VkRTSupportsInputAttachment
VulkanSecondaryCBCompatible
skgpu::Mipmapped mipmapped() const
GrTextureProxy * asTextureProxy() const
SkISize dimensions() const
sk_sp< GrTextureProxy > asTextureProxyRef() const
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy() const
GrRenderTargetProxy * asRenderTargetProxy() const
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)
sk_sp< GrRenderTargetProxy > asRenderTargetProxyRef() const
GrProtected isProtected() const
virtual GrRenderTargetProxy * asRenderTargetProxy()
const GrBackendFormat & backendFormat() const
GrSurfaceProxyPriv priv()
skgpu::Budgeted isBudgeted() const
virtual GrTexture * asTexture()
skgpu::Mipmapped mipmapped() const
virtual GrRecordingContext * recordingContext() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
SkColorSpace * colorSpace() const
static bool Equals(const SkColorSpace *, const SkColorSpace *)
const SkImageInfo & imageInfo() const
bool writePixels(const SkPixmap &src, int x, int y)
const SkSurfaceProps & surfaceProps() const
virtual void generatingSurfaceIsDeleted()
bool surfaceMustCopyOnWrite(GrSurfaceProxy *surfaceProxy) const
static sk_sp< SkImage > MakeWithVolatileSrc(sk_sp< GrRecordingContext > rContext, GrSurfaceProxyView volatileSrc, SkColorInfo colorInfo)
SkColorSpace * colorSpace() const
sk_sp< SkImage > refCachedImage()
virtual void onDraw(SkCanvas *, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *)
bool hasCachedImage() const
SkCanvas * onNewCanvas() override
void onDraw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *paint) override
GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess)
bool onCharacterize(GrSurfaceCharacterization *) const override
void onDiscard() override
void onAsyncRescaleAndReadPixels(const SkImageInfo &info, SkIRect srcRect, RescaleGamma rescaleGamma, RescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) override
sk_sp< SkSurface > onNewSurface(const SkImageInfo &) override
bool replaceBackendTexture(const GrBackendTexture &, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc, ReleaseContext) override
GrRecordingContext * onGetRecordingContext() const override
sk_sp< SkImage > onNewImageSnapshot(const SkIRect *subset) override
~SkSurface_Ganesh() override
void onWritePixels(const SkPixmap &, int x, int y) override
GrBackendTexture getBackendTexture(BackendHandleAccess)
bool onCopyOnWrite(ContentChangeMode) override
void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, bool readAlpha, sk_sp< SkColorSpace > dstColorSpace, SkIRect srcRect, SkISize dstSize, RescaleGamma rescaleGamma, RescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) override
SkImageInfo imageInfo() const override
skgpu::ganesh::Device * getDevice()
bool draw(sk_sp< const GrDeferredDisplayList >)
bool onWait(int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait) override
sk_sp< const SkCapabilities > onCapabilities() override
SkSurface_Ganesh(sk_sp< skgpu::ganesh::Device >)
bool onIsCompatible(const GrSurfaceCharacterization &) const override
@ kDiscard_ContentChangeMode
discards surface on change
@ kRetain_ContentChangeMode
preserves surface on change
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
bool isCompatible(const GrSurfaceCharacterization &characterization) const
void(*)(ReleaseContext) TextureReleaseProc
@ kFlushRead
back-end object is readable
@ kFlushWrite
back-end object is writable
@ kDiscardWrite
back-end object must be overwritten
static sk_sp< RefCntedCallback > Make(Callback proc, Context ctx)
GrSurfaceProxyView readSurfaceView()
GrRenderTargetProxy * targetProxy()
bool wait(int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait)
void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, bool readAlpha, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, SkISize dstSize, RescaleGamma rescaleGamma, RescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
void asyncRescaleAndReadPixels(const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
bool replaceBackingProxy(SkSurface::ContentChangeMode, sk_sp< GrRenderTargetProxy >, GrColorType, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
GrRecordingContext * recordingContext() const override
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
static float max(float r, float g, float b)
SK_API bool GetGLTextureInfo(const GrBackendTexture &, GrGLTextureInfo *)
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
SkSamplingOptions sampling
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API void ResolveMSAA(SkSurface *surface)
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
void(*)(ReleaseContext) RenderTargetReleaseProc
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API GrBackendRenderTarget GetBackendRenderTarget(SkSurface *, BackendHandleAccess)
void(*)(ReleaseContext) TextureReleaseProc
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
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 mode
SK_API void FlushAndSubmit(sk_sp< SkSurface >)
SK_API GrSemaphoresSubmitted Flush(sk_sp< SkSurface >)
static constexpr SkIRect MakeSize(const SkISize &size)
const SkColorInfo & colorInfo() const
sk_sp< SkColorSpace > refColorSpace() const
SkColorType colorType() const