[graphite] Move RefCntedCallback to shared gpu file.

Bug: skia:12974
Change-Id: I15b090e2c3346d71ccf45d5f0d306da3f079821e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/523996
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2022-03-23 16:37:01 -04:00 committed by SkCQ
parent 357881bc95
commit faf520c000
54 changed files with 199 additions and 170 deletions

View File

@ -806,6 +806,7 @@ skia_shared_gpu_sources = [
"$_src/gpu/Blend.h", "$_src/gpu/Blend.h",
"$_src/gpu/BufferWriter.h", "$_src/gpu/BufferWriter.h",
"$_src/gpu/KeyBuilder.h", "$_src/gpu/KeyBuilder.h",
"$_src/gpu/RefCntedCallback.h",
"$_src/gpu/ResourceKey.cpp", "$_src/gpu/ResourceKey.cpp",
"$_src/gpu/ResourceKey.h", "$_src/gpu/ResourceKey.h",
"$_src/gpu/ShaderErrorHandler.cpp", "$_src/gpu/ShaderErrorHandler.cpp",

View File

@ -978,36 +978,6 @@ static constexpr GrColorType GrMaskFormatToColorType(GrMaskFormat format) {
SkUNREACHABLE; SkUNREACHABLE;
} }
/**
* Ref-counted object that calls a callback from its destructor.
*/
class GrRefCntedCallback : public SkNVRefCnt<GrRefCntedCallback> {
public:
using Context = void*;
using Callback = void (*)(Context);
static sk_sp<GrRefCntedCallback> Make(Callback proc, Context ctx) {
if (!proc) {
return nullptr;
}
return sk_sp<GrRefCntedCallback>(new GrRefCntedCallback(proc, ctx));
}
~GrRefCntedCallback() { fReleaseProc(fReleaseCtx); }
Context context() const { return fReleaseCtx; }
private:
GrRefCntedCallback(Callback proc, Context ctx) : fReleaseProc(proc), fReleaseCtx(ctx) {}
GrRefCntedCallback(const GrRefCntedCallback&) = delete;
GrRefCntedCallback(GrRefCntedCallback&&) = delete;
GrRefCntedCallback& operator=(const GrRefCntedCallback&) = delete;
GrRefCntedCallback& operator=(GrRefCntedCallback&&) = delete;
Callback fReleaseProc;
Context fReleaseCtx;
};
enum class GrDstSampleFlags { enum class GrDstSampleFlags {
kNone = 0, kNone = 0,
kRequiresTextureBarrier = 1 << 0, kRequiresTextureBarrier = 1 << 0,

View File

@ -69,6 +69,7 @@
#include "include/gpu/gl/GrGLTypes.h" #include "include/gpu/gl/GrGLTypes.h"
#include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/gl/GrGLDefines.h" #include "src/gpu/gl/GrGLDefines.h"
#include <webgl/webgl1.h> #include <webgl/webgl1.h>
@ -782,7 +783,7 @@ protected:
uint32_t webGLCtx = emscripten_webgl_get_current_context(); uint32_t webGLCtx = emscripten_webgl_get_current_context();
auto releaseCtx = new TextureReleaseContext{webGLCtx, glInfo.fID}; auto releaseCtx = new TextureReleaseContext{webGLCtx, glInfo.fID};
auto cleanupCallback = GrRefCntedCallback::Make(deleteJSTexture, releaseCtx); auto cleanupCallback = skgpu::RefCntedCallback::Make(deleteJSTexture, releaseCtx);
sk_sp<GrSurfaceProxy> proxy = ctx->priv().proxyProvider()->wrapBackendTexture( sk_sp<GrSurfaceProxy> proxy = ctx->priv().proxyProvider()->wrapBackendTexture(
backendTexture, backendTexture,

View File

@ -119,7 +119,7 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
auto proxyProvider = dContext->priv().proxyProvider(); auto proxyProvider = dContext->priv().proxyProvider();
fBorrowingMutex.acquire(); fBorrowingMutex.acquire();
sk_sp<GrRefCntedCallback> releaseProcHelper; sk_sp<skgpu::RefCntedCallback> releaseProcHelper;
if (fRefHelper->fBorrowingContextID.isValid()) { if (fRefHelper->fBorrowingContextID.isValid()) {
if (fRefHelper->fBorrowingContextID != dContext->directContextID()) { if (fRefHelper->fBorrowingContextID != dContext->directContextID()) {
fBorrowingMutex.release(); fBorrowingMutex.release();
@ -134,10 +134,10 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
} else { } else {
SkASSERT(!fRefHelper->fBorrowingContextReleaseProc); SkASSERT(!fRefHelper->fBorrowingContextReleaseProc);
// The ref we add to fRefHelper here will be passed into and owned by the // The ref we add to fRefHelper here will be passed into and owned by the
// GrRefCntedCallback. // skgpu::RefCntedCallback.
fRefHelper->ref(); fRefHelper->ref();
releaseProcHelper = releaseProcHelper =
GrRefCntedCallback::Make(ReleaseRefHelper_TextureReleaseProc, fRefHelper); skgpu::RefCntedCallback::Make(ReleaseRefHelper_TextureReleaseProc, fRefHelper);
fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get(); fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get();
} }
fRefHelper->fBorrowingContextID = dContext->directContextID(); fRefHelper->fBorrowingContextID = dContext->directContextID();

View File

@ -76,7 +76,7 @@ private:
// all uses of the wrapped texture are finished on the borrowing context before we open // all uses of the wrapped texture are finished on the borrowing context before we open
// this back up to other contexts. In general a ref to this release proc is owned by all // this back up to other contexts. In general a ref to this release proc is owned by all
// proxies and gpu uses of the backend texture. // proxies and gpu uses of the backend texture.
GrRefCntedCallback* fBorrowingContextReleaseProc; skgpu::RefCntedCallback* fBorrowingContextReleaseProc;
GrDirectContext::DirectContextID fBorrowingContextID; GrDirectContext::DirectContextID fBorrowingContextID;
std::unique_ptr<GrSemaphore> fSemaphore; std::unique_ptr<GrSemaphore> fSemaphore;

View File

@ -494,14 +494,15 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
return this->createBackendTexture(width, height, format, mipMapped, renderable, isProtected); return this->createBackendTexture(width, height, format, mipMapped, renderable, isProtected);
} }
static GrBackendTexture create_and_clear_backend_texture(GrDirectContext* dContext, static GrBackendTexture create_and_clear_backend_texture(
SkISize dimensions, GrDirectContext* dContext,
const GrBackendFormat& backendFormat, SkISize dimensions,
GrMipmapped mipMapped, const GrBackendFormat& backendFormat,
GrRenderable renderable, GrMipmapped mipMapped,
GrProtected isProtected, GrRenderable renderable,
sk_sp<GrRefCntedCallback> finishedCallback, GrProtected isProtected,
std::array<float, 4> color) { sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) {
GrGpu* gpu = dContext->priv().getGpu(); GrGpu* gpu = dContext->priv().getGpu();
GrBackendTexture beTex = gpu->createBackendTexture(dimensions, backendFormat, renderable, GrBackendTexture beTex = gpu->createBackendTexture(dimensions, backendFormat, renderable,
mipMapped, isProtected); mipMapped, isProtected);
@ -523,7 +524,7 @@ static bool update_texture_with_pixmaps(GrDirectContext* context,
int numLevels, int numLevels,
const GrBackendTexture& backendTexture, const GrBackendTexture& backendTexture,
GrSurfaceOrigin textureOrigin, GrSurfaceOrigin textureOrigin,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
GrColorType ct = SkColorTypeToGrColorType(src[0].colorType()); GrColorType ct = SkColorTypeToGrColorType(src[0].colorType());
const GrBackendFormat& format = backendTexture.getBackendFormat(); const GrBackendFormat& format = backendTexture.getBackendFormat();
@ -568,7 +569,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
GrProtected isProtected, GrProtected isProtected,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
TRACE_EVENT0("skia.gpu", TRACE_FUNC); TRACE_EVENT0("skia.gpu", TRACE_FUNC);
if (this->abandoned()) { if (this->abandoned()) {
@ -593,7 +594,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
GrProtected isProtected, GrProtected isProtected,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return {}; return {};
@ -626,7 +627,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(const SkPixmap srcData[],
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC); TRACE_EVENT0("skia.gpu", TRACE_FUNC);
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return {}; return {};
@ -669,7 +670,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
const SkColor4f& color, const SkColor4f& color,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -683,7 +684,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
const SkColor4f& color, const SkColor4f& color,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -710,7 +711,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
GrSurfaceOrigin textureOrigin, GrSurfaceOrigin textureOrigin,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -745,7 +746,7 @@ static GrBackendTexture create_and_update_compressed_backend_texture(
const GrBackendFormat& backendFormat, const GrBackendFormat& backendFormat,
GrMipmapped mipMapped, GrMipmapped mipMapped,
GrProtected isProtected, GrProtected isProtected,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) { size_t size) {
GrGpu* gpu = dContext->priv().getGpu(); GrGpu* gpu = dContext->priv().getGpu();
@ -773,7 +774,7 @@ GrBackendTexture GrDirectContext::createCompressedBackendTexture(
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC); TRACE_EVENT0("skia.gpu", TRACE_FUNC);
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return {}; return {};
@ -825,7 +826,7 @@ GrBackendTexture GrDirectContext::createCompressedBackendTexture(
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC); TRACE_EVENT0("skia.gpu", TRACE_FUNC);
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return {}; return {};
@ -859,7 +860,7 @@ bool GrDirectContext::updateCompressedBackendTexture(const GrBackendTexture& bac
const SkColor4f& color, const SkColor4f& color,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -891,7 +892,7 @@ bool GrDirectContext::updateCompressedBackendTexture(const GrBackendTexture& bac
size_t dataSize, size_t dataSize,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -914,7 +915,7 @@ bool GrDirectContext::setBackendTextureState(const GrBackendTexture& backendText
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto callback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto callback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;
@ -929,7 +930,7 @@ bool GrDirectContext::setBackendRenderTargetState(const GrBackendRenderTarget& b
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
GrGpuFinishedProc finishedProc, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
auto callback = GrRefCntedCallback::Make(finishedProc, finishedContext); auto callback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
if (this->abandoned()) { if (this->abandoned()) {
return false; return false;

View File

@ -843,7 +843,7 @@ GrBackendTexture GrGpu::createBackendTexture(SkISize dimensions,
} }
bool GrGpu::clearBackendTexture(const GrBackendTexture& backendTexture, bool GrGpu::clearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
if (!backendTexture.isValid()) { if (!backendTexture.isValid()) {
return false; return false;
@ -886,7 +886,7 @@ GrBackendTexture GrGpu::createCompressedBackendTexture(SkISize dimensions,
} }
bool GrGpu::updateCompressedBackendTexture(const GrBackendTexture& backendTexture, bool GrGpu::updateCompressedBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length) { size_t length) {
SkASSERT(data); SkASSERT(data);

View File

@ -19,6 +19,7 @@
#include "src/gpu/GrOpsRenderPass.h" #include "src/gpu/GrOpsRenderPass.h"
#include "src/gpu/GrPixmap.h" #include "src/gpu/GrPixmap.h"
#include "src/gpu/GrXferProcessor.h" #include "src/gpu/GrXferProcessor.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/Swizzle.h" #include "src/gpu/Swizzle.h"
class GrAttachment; class GrAttachment;
@ -534,7 +535,7 @@ public:
GrProtected); GrProtected);
bool clearBackendTexture(const GrBackendTexture&, bool clearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color); std::array<float, 4> color);
/** /**
@ -547,21 +548,21 @@ public:
GrProtected); GrProtected);
bool updateCompressedBackendTexture(const GrBackendTexture&, bool updateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length); size_t length);
virtual bool setBackendTextureState(const GrBackendTexture&, virtual bool setBackendTextureState(const GrBackendTexture&,
const GrBackendSurfaceMutableState&, const GrBackendSurfaceMutableState&,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
return false; return false;
} }
virtual bool setBackendRenderTargetState(const GrBackendRenderTarget&, virtual bool setBackendRenderTargetState(const GrBackendRenderTarget&,
const GrBackendSurfaceMutableState&, const GrBackendSurfaceMutableState&,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
return false; return false;
} }
@ -678,11 +679,11 @@ private:
SkISize dimensions, const GrBackendFormat&, GrMipmapped, GrProtected) = 0; SkISize dimensions, const GrBackendFormat&, GrMipmapped, GrProtected) = 0;
virtual bool onClearBackendTexture(const GrBackendTexture&, virtual bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) = 0; std::array<float, 4> color) = 0;
virtual bool onUpdateCompressedBackendTexture(const GrBackendTexture&, virtual bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length) = 0; size_t length) = 0;

View File

@ -8,10 +8,10 @@
#ifndef GrManagedResource_DEFINED #ifndef GrManagedResource_DEFINED
#define GrManagedResource_DEFINED #define GrManagedResource_DEFINED
#include "include/private/GrTypesPriv.h"
#include "include/private/SkMutex.h" #include "include/private/SkMutex.h"
#include "include/private/SkTHash.h" #include "include/private/SkTHash.h"
#include "include/utils/SkRandom.h" #include "include/utils/SkRandom.h"
#include "src/gpu/RefCntedCallback.h"
#include <atomic> #include <atomic>
class GrTexture; class GrTexture;
@ -221,12 +221,12 @@ public:
SkASSERT(!fReleaseHelper); SkASSERT(!fReleaseHelper);
} }
void setRelease(sk_sp<GrRefCntedCallback> releaseHelper) { void setRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
fReleaseHelper = std::move(releaseHelper); fReleaseHelper = std::move(releaseHelper);
} }
protected: protected:
mutable sk_sp<GrRefCntedCallback> fReleaseHelper; mutable sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
void invokeReleaseProc() const { void invokeReleaseProc() const {
if (fReleaseHelper) { if (fReleaseHelper) {

View File

@ -520,11 +520,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::createCompressedTextureProxy(
return proxy; return proxy;
} }
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex, sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(
GrWrapOwnership ownership, const GrBackendTexture& backendTex,
GrWrapCacheable cacheable, GrWrapOwnership ownership,
GrIOType ioType, GrWrapCacheable cacheable,
sk_sp<GrRefCntedCallback> releaseHelper) { GrIOType ioType,
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
SkASSERT(ioType != kWrite_GrIOType); SkASSERT(ioType != kWrite_GrIOType);
if (this->isAbandoned()) { if (this->isAbandoned()) {
@ -561,7 +562,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapCompressedBackendTexture(
const GrBackendTexture& beTex, const GrBackendTexture& beTex,
GrWrapOwnership ownership, GrWrapOwnership ownership,
GrWrapCacheable cacheable, GrWrapCacheable cacheable,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }
@ -597,7 +598,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
int sampleCnt, int sampleCnt,
GrWrapOwnership ownership, GrWrapOwnership ownership,
GrWrapCacheable cacheable, GrWrapCacheable cacheable,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }
@ -635,7 +636,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget( sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
const GrBackendRenderTarget& backendRT, const GrBackendRenderTarget& backendRT,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }

View File

@ -116,12 +116,12 @@ public:
GrWrapOwnership, GrWrapOwnership,
GrWrapCacheable, GrWrapCacheable,
GrIOType, GrIOType,
sk_sp<GrRefCntedCallback> = nullptr); sk_sp<skgpu::RefCntedCallback> = nullptr);
sk_sp<GrTextureProxy> wrapCompressedBackendTexture(const GrBackendTexture&, sk_sp<GrTextureProxy> wrapCompressedBackendTexture(const GrBackendTexture&,
GrWrapOwnership, GrWrapOwnership,
GrWrapCacheable, GrWrapCacheable,
sk_sp<GrRefCntedCallback> releaseHelper); sk_sp<skgpu::RefCntedCallback>);
/* /*
* Create a texture proxy that wraps a backend texture and is both texture-able and renderable * Create a texture proxy that wraps a backend texture and is both texture-able and renderable
@ -130,13 +130,13 @@ public:
int sampleCnt, int sampleCnt,
GrWrapOwnership, GrWrapOwnership,
GrWrapCacheable, GrWrapCacheable,
sk_sp<GrRefCntedCallback> releaseHelper); sk_sp<skgpu::RefCntedCallback> releaseHelper);
/* /*
* Create a render target proxy that wraps a backend render target * Create a render target proxy that wraps a backend render target
*/ */
sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&, sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&,
sk_sp<GrRefCntedCallback> releaseHelper); sk_sp<skgpu::RefCntedCallback> releaseHelper);
sk_sp<GrRenderTargetProxy> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&, sk_sp<GrRenderTargetProxy> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
const GrVkDrawableInfo&); const GrVkDrawableInfo&);

View File

@ -308,7 +308,7 @@ std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFCFromBa
const GrBackendTexture& tex, const GrBackendTexture& tex,
int sampleCount, int sampleCount,
GrSurfaceOrigin origin, GrSurfaceOrigin origin,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
#if SK_GPU_V1 #if SK_GPU_V1
SkASSERT(sampleCount > 0); SkASSERT(sampleCount > 0);

View File

@ -12,6 +12,7 @@
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/BaseDevice.h" #include "src/gpu/BaseDevice.h"
#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrImageContextPriv.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/text/GrSDFTControl.h" #include "src/gpu/text/GrSDFTControl.h"
class GrImageInfo; class GrImageInfo;
@ -201,7 +202,7 @@ public:
const GrBackendTexture&, const GrBackendTexture&,
int sampleCount, int sampleCount,
GrSurfaceOrigin, GrSurfaceOrigin,
sk_sp<GrRefCntedCallback> releaseHelper); sk_sp<skgpu::RefCntedCallback> releaseHelper);
protected: protected:
explicit GrRecordingContextPriv(GrRecordingContext* rContext) : GrImageContextPriv(rContext) {} explicit GrRecordingContextPriv(GrRecordingContext* rContext) : GrImageContextPriv(rContext) {}

View File

@ -13,6 +13,7 @@
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "src/gpu/GrGpuResource.h" #include "src/gpu/GrGpuResource.h"
#include "src/gpu/RefCntedCallback.h"
class GrRenderTarget; class GrRenderTarget;
class GrTexture; class GrTexture;
@ -41,7 +42,7 @@ public:
virtual GrBackendFormat backendFormat() const = 0; virtual GrBackendFormat backendFormat() const = 0;
void setRelease(sk_sp<GrRefCntedCallback> releaseHelper) { void setRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
this->onSetRelease(releaseHelper); this->onSetRelease(releaseHelper);
fReleaseHelper = std::move(releaseHelper); fReleaseHelper = std::move(releaseHelper);
} }
@ -51,7 +52,7 @@ public:
typedef void* ReleaseCtx; typedef void* ReleaseCtx;
typedef void (*ReleaseProc)(ReleaseCtx); typedef void (*ReleaseProc)(ReleaseCtx);
void setRelease(ReleaseProc proc, ReleaseCtx ctx) { void setRelease(ReleaseProc proc, ReleaseCtx ctx) {
this->setRelease(GrRefCntedCallback::Make(proc, ctx)); this->setRelease(skgpu::RefCntedCallback::Make(proc, ctx));
} }
/** /**
@ -141,7 +142,7 @@ private:
// Unmanaged backends (e.g. Vulkan) may want to specially handle the release proc in order to // Unmanaged backends (e.g. Vulkan) may want to specially handle the release proc in order to
// ensure it isn't called until GPU work related to the resource is completed. // ensure it isn't called until GPU work related to the resource is completed.
virtual void onSetRelease(sk_sp<GrRefCntedCallback>) {} virtual void onSetRelease(sk_sp<skgpu::RefCntedCallback>) {}
void invokeReleaseProc() { void invokeReleaseProc() {
// Depending on the ref count of fReleaseHelper this may or may not actually trigger the // Depending on the ref count of fReleaseHelper this may or may not actually trigger the
@ -152,7 +153,7 @@ private:
SkISize fDimensions; SkISize fDimensions;
GrInternalSurfaceFlags fSurfaceFlags; GrInternalSurfaceFlags fSurfaceFlags;
GrProtected fIsProtected; GrProtected fIsProtected;
sk_sp<GrRefCntedCallback> fReleaseHelper; sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
using INHERITED = GrGpuResource; using INHERITED = GrGpuResource;
}; };

View File

@ -0,0 +1,47 @@
/*
* Copyright 2022 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_RefCntedCallback_DEFINED
#define skgpu_RefCntedCallback_DEFINED
#include "include/core/SkRefCnt.h"
namespace skgpu {
/**
* Ref-counted object that calls a callback from its destructor.
*/
class RefCntedCallback : public SkNVRefCnt<RefCntedCallback> {
public:
using Context = void*;
using Callback = void (*)(Context);
static sk_sp<RefCntedCallback> Make(Callback proc, Context ctx) {
if (!proc) {
return nullptr;
}
return sk_sp<RefCntedCallback>(new RefCntedCallback(proc, ctx));
}
~RefCntedCallback() { fReleaseProc(fReleaseCtx); }
Context context() const { return fReleaseCtx; }
private:
RefCntedCallback(Callback proc, Context ctx) : fReleaseProc(proc), fReleaseCtx(ctx) {}
RefCntedCallback(const RefCntedCallback&) = delete;
RefCntedCallback(RefCntedCallback&&) = delete;
RefCntedCallback& operator=(const RefCntedCallback&) = delete;
RefCntedCallback& operator=(RefCntedCallback&&) = delete;
Callback fReleaseProc;
Context fReleaseCtx;
};
} // namespace skgpu
#endif // skgpu_RefCntedCallback_DEFINED

View File

@ -80,7 +80,7 @@ void GrD3DCommandList::releaseResources() {
this->callFinishedCallbacks(); this->callFinishedCallbacks();
} }
void GrD3DCommandList::addFinishedCallback(sk_sp<GrRefCntedCallback> callback) { void GrD3DCommandList::addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback) {
fFinishedCallbacks.push_back(std::move(callback)); fFinishedCallbacks.push_back(std::move(callback));
} }

View File

@ -110,7 +110,7 @@ public:
bool hasWork() const { return fHasWork; } bool hasWork() const { return fHasWork; }
void addFinishedCallback(sk_sp<GrRefCntedCallback> callback); void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback);
private: private:
static const int kInitialTrackedResourcesCount = 32; static const int kInitialTrackedResourcesCount = 32;
@ -149,7 +149,7 @@ private:
SkSTArray<4, D3D12_RESOURCE_BARRIER> fResourceBarriers; SkSTArray<4, D3D12_RESOURCE_BARRIER> fResourceBarriers;
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedCallbacks; SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedCallbacks;
}; };
class GrD3DDirectCommandList : public GrD3DCommandList { class GrD3DDirectCommandList : public GrD3DCommandList {

View File

@ -233,10 +233,10 @@ void GrD3DGpu::endRenderPass(GrRenderTarget* target, GrSurfaceOrigin origin,
void GrD3DGpu::addFinishedProc(GrGpuFinishedProc finishedProc, void GrD3DGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
SkASSERT(finishedProc); SkASSERT(finishedProc);
this->addFinishedCallback(GrRefCntedCallback::Make(finishedProc, finishedContext)); this->addFinishedCallback(skgpu::RefCntedCallback::Make(finishedProc, finishedContext));
} }
void GrD3DGpu::addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback) { void GrD3DGpu::addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback) {
SkASSERT(finishedCallback); SkASSERT(finishedCallback);
// Besides the current command list, we also add the finishedCallback to the newest outstanding // Besides the current command list, we also add the finishedCallback to the newest outstanding
// command list. Our contract for calling the proc is that all previous submitted command lists // command list. Our contract for calling the proc is that all previous submitted command lists
@ -1387,7 +1387,7 @@ static bool copy_color_data(const GrD3DCaps& caps,
} }
bool GrD3DGpu::onClearBackendTexture(const GrBackendTexture& backendTexture, bool GrD3DGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
GrD3DTextureResourceInfo info; GrD3DTextureResourceInfo info;
SkAssertResult(backendTexture.getD3DTextureResourceInfo(&info)); SkAssertResult(backendTexture.getD3DTextureResourceInfo(&info));
@ -1488,7 +1488,7 @@ GrBackendTexture GrD3DGpu::onCreateCompressedBackendTexture(
} }
bool GrD3DGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture, bool GrD3DGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) { size_t size) {
GrD3DTextureResourceInfo info; GrD3DTextureResourceInfo info;

View File

@ -204,7 +204,7 @@ private:
void addFinishedProc(GrGpuFinishedProc finishedProc, void addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) override; GrGpuFinishedContext finishedContext) override;
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback); void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*, GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
bool useMSAASurface, bool useMSAASurface,
@ -230,7 +230,7 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override; std::array<float, 4> color) override;
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions, GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
@ -239,7 +239,7 @@ private:
GrProtected) override; GrProtected) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) override; size_t size) override;

View File

@ -118,7 +118,7 @@ private:
// In Direct3D we call the release proc after we are finished with the underlying // In Direct3D we call the release proc after we are finished with the underlying
// GrD3DTextureResource::Resource object (which occurs after the GPU finishes all work on it). // GrD3DTextureResource::Resource object (which occurs after the GPU finishes all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc on to GrD3DTextureResource // Forward the release proc on to GrD3DTextureResource
this->setResourceRelease(std::move(releaseHelper)); this->setResourceRelease(std::move(releaseHelper));
} }

View File

@ -78,7 +78,7 @@ private:
// In D3D we call the release proc after we are finished with the underlying // In D3D we call the release proc after we are finished with the underlying
// GrSurfaceResource::Resource object (which occurs after the GPU has finished all work on it). // GrSurfaceResource::Resource object (which occurs after the GPU has finished all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc on to GrSurfaceResource // Forward the release proc on to GrSurfaceResource
this->setResourceRelease(std::move(releaseHelper)); this->setResourceRelease(std::move(releaseHelper));
} }

View File

@ -107,7 +107,7 @@ private:
// In Vulkan we call the release proc after we are finished with the underlying // In Vulkan we call the release proc after we are finished with the underlying
// GrD3DImage::Resource object (which occurs after the GPU has finished all work on it). // GrD3DImage::Resource object (which occurs after the GPU has finished all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc on to GrD3DImage // Forward the release proc on to GrD3DImage
this->setResourceRelease(std::move(releaseHelper)); this->setResourceRelease(std::move(releaseHelper));
} }

View File

@ -117,7 +117,7 @@ void GrD3DTextureResource::releaseResource(GrD3DGpu* gpu) {
fInfo.fAlloc.reset(); fInfo.fAlloc.reset();
} }
void GrD3DTextureResource::setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper) { void GrD3DTextureResource::setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
SkASSERT(fResource); SkASSERT(fResource);
// Forward the release proc on to GrD3DTextureResource::Resource // Forward the release proc on to GrD3DTextureResource::Resource
fResource->setRelease(std::move(releaseHelper)); fResource->setRelease(std::move(releaseHelper));

View File

@ -73,7 +73,7 @@ public:
GrD3DGpu* gpu, SkISize dimensions, int sampleCnt, const GrD3DTextureResourceInfo& info, GrD3DGpu* gpu, SkISize dimensions, int sampleCnt, const GrD3DTextureResourceInfo& info,
SkColor4f clearColor); SkColor4f clearColor);
void setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper); void setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper);
protected: protected:
void releaseResource(GrD3DGpu* gpu); void releaseResource(GrD3DGpu* gpu);

View File

@ -385,7 +385,7 @@ void GrDawnGpu::uploadTextureData(GrColorType srcColorType, const GrMipLevel tex
} }
bool GrDawnGpu::onClearBackendTexture(const GrBackendTexture& backendTexture, bool GrDawnGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
GrDawnTextureInfo info; GrDawnTextureInfo info;
SkAssertResult(backendTexture.getDawnTextureInfo(&info)); SkAssertResult(backendTexture.getDawnTextureInfo(&info));
@ -444,7 +444,7 @@ GrBackendTexture GrDawnGpu::onCreateCompressedBackendTexture(
} }
bool GrDawnGpu::onUpdateCompressedBackendTexture(const GrBackendTexture&, bool GrDawnGpu::onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) { size_t size) {
return false; return false;

View File

@ -146,7 +146,7 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override; std::array<float, 4> color) override;
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions, GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
@ -155,7 +155,7 @@ private:
GrProtected) override; GrProtected) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) override; size_t size) override;

View File

@ -40,7 +40,7 @@ protected:
void onAbandon() override; void onAbandon() override;
void onRelease() override; void onRelease() override;
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {} void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {}
// This accounts for the texture's memory and any MSAA renderbuffer's memory. // This accounts for the texture's memory and any MSAA renderbuffer's memory.
size_t onGpuMemorySize() const override; size_t onGpuMemorySize() const override;

View File

@ -1565,7 +1565,7 @@ GrBackendTexture GrGLGpu::onCreateCompressedBackendTexture(
} }
bool GrGLGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture, bool GrGLGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length) { size_t length) {
GrGLTextureInfo info; GrGLTextureInfo info;
@ -3704,7 +3704,7 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
} }
bool GrGLGpu::onClearBackendTexture(const GrBackendTexture& backendTexture, bool GrGLGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
this->handleDirtyContext(); this->handleDirtyContext();

View File

@ -231,11 +231,11 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override; std::array<float, 4> color) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length) override; size_t length) override;

View File

@ -179,7 +179,7 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override { std::array<float, 4> color) override {
return true; return true;
} }
@ -190,7 +190,7 @@ private:
GrProtected) override; GrProtected) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void*, const void*,
size_t) override { size_t) override {
return true; return true;

View File

@ -37,7 +37,7 @@ public:
bool commit(bool waitUntilCompleted); bool commit(bool waitUntilCompleted);
bool hasWork() { return fHasWork; } bool hasWork() { return fHasWork; }
void addFinishedCallback(sk_sp<GrRefCntedCallback> callback) { void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback) {
fFinishedCallbacks.push_back(std::move(callback)); fFinishedCallbacks.push_back(std::move(callback));
} }
@ -114,7 +114,7 @@ private:
MTLRenderPassDescriptor* fPreviousRenderPassDescriptor; MTLRenderPassDescriptor* fPreviousRenderPassDescriptor;
bool fHasWork; bool fHasWork;
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedCallbacks; SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedCallbacks;
}; };

View File

@ -142,7 +142,7 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override; std::array<float, 4> color) override;
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions, GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
@ -151,7 +151,7 @@ private:
GrProtected) override; GrProtected) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) override; size_t size) override;
@ -227,7 +227,7 @@ private:
void addFinishedProc(GrGpuFinishedProc finishedProc, void addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) override; GrGpuFinishedContext finishedContext) override;
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback); void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*, GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
bool useMSAASurface, bool useMSAASurface,

View File

@ -261,10 +261,10 @@ void GrMtlGpu::finishOutstandingGpuWork() {
void GrMtlGpu::addFinishedProc(GrGpuFinishedProc finishedProc, void GrMtlGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
SkASSERT(finishedProc); SkASSERT(finishedProc);
this->addFinishedCallback(GrRefCntedCallback::Make(finishedProc, finishedContext)); this->addFinishedCallback(skgpu::RefCntedCallback::Make(finishedProc, finishedContext));
} }
void GrMtlGpu::addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback) { void GrMtlGpu::addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback) {
SkASSERT(finishedCallback); SkASSERT(finishedCallback);
// Besides the current commandbuffer, we also add the finishedCallback to the newest outstanding // Besides the current commandbuffer, we also add the finishedCallback to the newest outstanding
// commandbuffer. Our contract for calling the proc is that all previous submitted cmdbuffers // commandbuffer. Our contract for calling the proc is that all previous submitted cmdbuffers
@ -923,7 +923,7 @@ GrBackendTexture GrMtlGpu::onCreateBackendTexture(SkISize dimensions,
} }
bool GrMtlGpu::onClearBackendTexture(const GrBackendTexture& backendTexture, bool GrMtlGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
GrMtlTextureInfo info; GrMtlTextureInfo info;
SkAssertResult(backendTexture.getMtlTextureInfo(&info)); SkAssertResult(backendTexture.getMtlTextureInfo(&info));
@ -1025,7 +1025,7 @@ GrBackendTexture GrMtlGpu::onCreateCompressedBackendTexture(
} }
bool GrMtlGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture, bool GrMtlGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) { size_t size) {
GrMtlTextureInfo info; GrMtlTextureInfo info;

View File

@ -269,7 +269,7 @@ std::unique_ptr<SurfaceDrawContext> SurfaceDrawContext::MakeFromBackendTexture(
int sampleCnt, int sampleCnt,
GrSurfaceOrigin origin, GrSurfaceOrigin origin,
const SkSurfaceProps& surfaceProps, const SkSurfaceProps& surfaceProps,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
SkASSERT(sampleCnt > 0); SkASSERT(sampleCnt > 0);
sk_sp<GrTextureProxy> proxy(rContext->priv().proxyProvider()->wrapRenderableBackendTexture( sk_sp<GrTextureProxy> proxy(rContext->priv().proxyProvider()->wrapRenderableBackendTexture(
tex, sampleCnt, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, tex, sampleCnt, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,

View File

@ -126,7 +126,7 @@ public:
int sampleCnt, int sampleCnt,
GrSurfaceOrigin, GrSurfaceOrigin,
const SkSurfaceProps&, const SkSurfaceProps&,
sk_sp<GrRefCntedCallback> releaseHelper); sk_sp<skgpu::RefCntedCallback> releaseHelper);
SurfaceDrawContext(GrRecordingContext*, SurfaceDrawContext(GrRecordingContext*,
GrSurfaceProxyView readView, GrSurfaceProxyView readView,

View File

@ -667,7 +667,7 @@ bool GrVkPrimaryCommandBuffer::finished(GrVkGpu* gpu) {
} }
} }
void GrVkPrimaryCommandBuffer::addFinishedProc(sk_sp<GrRefCntedCallback> finishedProc) { void GrVkPrimaryCommandBuffer::addFinishedProc(sk_sp<skgpu::RefCntedCallback> finishedProc) {
fFinishedProcs.push_back(std::move(finishedProc)); fFinishedProcs.push_back(std::move(finishedProc));
} }

View File

@ -312,7 +312,7 @@ public:
bool finished(GrVkGpu* gpu); bool finished(GrVkGpu* gpu);
void addFinishedProc(sk_sp<GrRefCntedCallback> finishedProc); void addFinishedProc(sk_sp<skgpu::RefCntedCallback> finishedProc);
void callFinishedProcs() { void callFinishedProcs() {
fFinishedProcs.reset(); fFinishedProcs.reset();
@ -331,7 +331,7 @@ private:
SkTArray<std::unique_ptr<GrVkSecondaryCommandBuffer>, true> fSecondaryCommandBuffers; SkTArray<std::unique_ptr<GrVkSecondaryCommandBuffer>, true> fSecondaryCommandBuffers;
VkFence fSubmitFence; VkFence fSubmitFence;
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedProcs; SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedProcs;
using INHERITED = GrVkCommandBuffer; using INHERITED = GrVkCommandBuffer;
}; };

View File

@ -1603,7 +1603,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
} }
bool GrVkGpu::onClearBackendTexture(const GrBackendTexture& backendTexture, bool GrVkGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) { std::array<float, 4> color) {
GrVkImageInfo info; GrVkImageInfo info;
SkAssertResult(backendTexture.getVkImageInfo(&info)); SkAssertResult(backendTexture.getVkImageInfo(&info));
@ -1702,7 +1702,7 @@ GrBackendTexture GrVkGpu::onCreateCompressedBackendTexture(
} }
bool GrVkGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture, bool GrVkGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t size) { size_t size) {
GrVkImageInfo info; GrVkImageInfo info;
@ -1814,7 +1814,7 @@ bool GrVkGpu::setBackendSurfaceState(GrVkImageInfo info,
SkISize dimensions, SkISize dimensions,
const GrVkSharedImageInfo& newInfo, const GrVkSharedImageInfo& newInfo,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
sk_sp<GrVkImage> texture = GrVkImage::MakeWrapped(this, sk_sp<GrVkImage> texture = GrVkImage::MakeWrapped(this,
dimensions, dimensions,
info, info,
@ -1841,7 +1841,7 @@ bool GrVkGpu::setBackendSurfaceState(GrVkImageInfo info,
bool GrVkGpu::setBackendTextureState(const GrBackendTexture& backendTeture, bool GrVkGpu::setBackendTextureState(const GrBackendTexture& backendTeture,
const GrBackendSurfaceMutableState& newState, const GrBackendSurfaceMutableState& newState,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
GrVkImageInfo info; GrVkImageInfo info;
SkAssertResult(backendTeture.getVkImageInfo(&info)); SkAssertResult(backendTeture.getVkImageInfo(&info));
sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendTeture.getMutableState(); sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendTeture.getMutableState();
@ -1855,7 +1855,7 @@ bool GrVkGpu::setBackendTextureState(const GrBackendTexture& backendTeture,
bool GrVkGpu::setBackendRenderTargetState(const GrBackendRenderTarget& backendRenderTarget, bool GrVkGpu::setBackendRenderTargetState(const GrBackendRenderTarget& backendRenderTarget,
const GrBackendSurfaceMutableState& newState, const GrBackendSurfaceMutableState& newState,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
GrVkImageInfo info; GrVkImageInfo info;
SkAssertResult(backendRenderTarget.getVkImageInfo(&info)); SkAssertResult(backendRenderTarget.getVkImageInfo(&info));
sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendRenderTarget.getMutableState(); sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendRenderTarget.getMutableState();
@ -2097,10 +2097,10 @@ void GrVkGpu::prepareSurfacesForBackendAccessAndStateUpdates(
void GrVkGpu::addFinishedProc(GrGpuFinishedProc finishedProc, void GrVkGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) { GrGpuFinishedContext finishedContext) {
SkASSERT(finishedProc); SkASSERT(finishedProc);
this->addFinishedCallback(GrRefCntedCallback::Make(finishedProc, finishedContext)); this->addFinishedCallback(skgpu::RefCntedCallback::Make(finishedProc, finishedContext));
} }
void GrVkGpu::addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback) { void GrVkGpu::addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback) {
SkASSERT(finishedCallback); SkASSERT(finishedCallback);
fResourceProvider.addFinishedProcToActiveCommandBuffers(std::move(finishedCallback)); fResourceProvider.addFinishedProcToActiveCommandBuffers(std::move(finishedCallback));
} }

View File

@ -83,12 +83,12 @@ public:
bool setBackendTextureState(const GrBackendTexture&, bool setBackendTextureState(const GrBackendTexture&,
const GrBackendSurfaceMutableState&, const GrBackendSurfaceMutableState&,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) override; sk_sp<skgpu::RefCntedCallback> finishedCallback) override;
bool setBackendRenderTargetState(const GrBackendRenderTarget&, bool setBackendRenderTargetState(const GrBackendRenderTarget&,
const GrBackendSurfaceMutableState&, const GrBackendSurfaceMutableState&,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback) override; sk_sp<skgpu::RefCntedCallback> finishedCallback) override;
void deleteBackendTexture(const GrBackendTexture&) override; void deleteBackendTexture(const GrBackendTexture&) override;
@ -222,11 +222,11 @@ private:
GrProtected) override; GrProtected) override;
bool onClearBackendTexture(const GrBackendTexture&, bool onClearBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
std::array<float, 4> color) override; std::array<float, 4> color) override;
bool onUpdateCompressedBackendTexture(const GrBackendTexture&, bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
sk_sp<GrRefCntedCallback> finishedCallback, sk_sp<skgpu::RefCntedCallback> finishedCallback,
const void* data, const void* data,
size_t length) override; size_t length) override;
@ -235,7 +235,7 @@ private:
SkISize dimensions, SkISize dimensions,
const GrVkSharedImageInfo& newInfo, const GrVkSharedImageInfo& newInfo,
GrBackendSurfaceMutableState* previousState, GrBackendSurfaceMutableState* previousState,
sk_sp<GrRefCntedCallback> finishedCallback); sk_sp<skgpu::RefCntedCallback> finishedCallback);
sk_sp<GrTexture> onCreateTexture(SkISize, sk_sp<GrTexture> onCreateTexture(SkISize,
const GrBackendFormat&, const GrBackendFormat&,
@ -307,7 +307,7 @@ private:
void addFinishedProc(GrGpuFinishedProc finishedProc, void addFinishedProc(GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) override; GrGpuFinishedContext finishedContext) override;
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback); void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*, GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
bool useMSAASurface, bool useMSAASurface,

View File

@ -590,7 +590,7 @@ void GrVkImage::onAbandon() {
GrAttachment::onAbandon(); GrAttachment::onAbandon();
} }
void GrVkImage::setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper) { void GrVkImage::setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
SkASSERT(fResource); SkASSERT(fResource);
// Forward the release proc on to GrVkImage::Resource // Forward the release proc on to GrVkImage::Resource
fResource->setRelease(std::move(releaseHelper)); fResource->setRelease(std::move(releaseHelper));

View File

@ -199,7 +199,7 @@ public:
typedef void* ReleaseCtx; typedef void* ReleaseCtx;
typedef void (*ReleaseProc)(ReleaseCtx); typedef void (*ReleaseProc)(ReleaseCtx);
void setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper); void setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper);
// Helpers to use for setting the layout of the VkImage // Helpers to use for setting the layout of the VkImage
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout); static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout);

View File

@ -160,7 +160,7 @@ private:
// In Vulkan we call the release proc after we are finished with the underlying // In Vulkan we call the release proc after we are finished with the underlying
// GrVkImage::Resource object (which occurs after the GPU has finished all work on it). // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc on to the GrVkImage of the release attachment if we have one, // Forward the release proc on to the GrVkImage of the release attachment if we have one,
// otherwise the color attachment. // otherwise the color attachment.
GrVkImage* attachment = GrVkImage* attachment =

View File

@ -466,7 +466,7 @@ void GrVkResourceProvider::forceSyncAllCommandBuffers() {
} }
void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers( void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers(
sk_sp<GrRefCntedCallback> finishedCallback) { sk_sp<skgpu::RefCntedCallback> finishedCallback) {
for (int i = 0; i < fActiveCommandPools.count(); ++i) { for (int i = 0; i < fActiveCommandPools.count(); ++i) {
GrVkCommandPool* pool = fActiveCommandPools[i]; GrVkCommandPool* pool = fActiveCommandPools[i];
GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer(); GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();

View File

@ -116,7 +116,7 @@ public:
// that the client cares about before they explicitly called flush and the GPU may reorder // that the client cares about before they explicitly called flush and the GPU may reorder
// command execution. So we make sure all previously submitted work finishes before we call the // command execution. So we make sure all previously submitted work finishes before we call the
// finishedProc. // finishedProc.
void addFinishedProcToActiveCommandBuffers(sk_sp<GrRefCntedCallback> finishedCallback); void addFinishedProcToActiveCommandBuffers(sk_sp<skgpu::RefCntedCallback> finishedCallback);
// Finds or creates a compatible GrVkDescriptorPool for the requested type and count. // Finds or creates a compatible GrVkDescriptorPool for the requested type and count.
// The refcount is incremented and a pointer returned. // The refcount is incremented and a pointer returned.

View File

@ -11,6 +11,7 @@
#include "src/gpu/GrSemaphore.h" #include "src/gpu/GrSemaphore.h"
#include "include/gpu/vk/GrVkTypes.h" #include "include/gpu/vk/GrVkTypes.h"
#include "include/private/GrTypesPriv.h"
#include "src/gpu/vk/GrVkManagedResource.h" #include "src/gpu/vk/GrVkManagedResource.h"
#include <cinttypes> #include <cinttypes>

View File

@ -75,7 +75,7 @@ protected:
// In Vulkan we call the release proc after we are finished with the underlying // In Vulkan we call the release proc after we are finished with the underlying
// GrVkImage::Resource object (which occurs after the GPU has finished all work on it). // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc onto the fTexture's GrVkImage // Forward the release proc onto the fTexture's GrVkImage
fTexture->setResourceRelease(std::move(releaseHelper)); fTexture->setResourceRelease(std::move(releaseHelper));
} }

View File

@ -83,7 +83,7 @@ private:
// In Vulkan we call the release proc after we are finished with the underlying // In Vulkan we call the release proc after we are finished with the underlying
// GrVkImage::Resource object (which occurs after the GPU has finished all work on it). // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
// Forward the release proc on to GrVkImage // Forward the release proc on to GrVkImage
GrVkTexture::onSetRelease(std::move(releaseHelper)); GrVkTexture::onSetRelease(std::move(releaseHelper));
} }

View File

@ -389,7 +389,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrRecordingContext* rContext,
SkAlphaType at, SkAlphaType at,
sk_sp<SkColorSpace> colorSpace, sk_sp<SkColorSpace> colorSpace,
GrWrapOwnership ownership, GrWrapOwnership ownership,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
if (!backendTex.isValid() || backendTex.width() <= 0 || backendTex.height() <= 0) { if (!backendTex.isValid() || backendTex.width() <= 0 || backendTex.height() <= 0) {
return nullptr; return nullptr;
} }
@ -418,7 +418,7 @@ sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrRecordingContext* rContext,
sk_sp<SkColorSpace> cs, sk_sp<SkColorSpace> cs,
TextureReleaseProc releaseP, TextureReleaseProc releaseP,
ReleaseContext releaseC) { ReleaseContext releaseC) {
auto releaseHelper = GrRefCntedCallback::Make(releaseP, releaseC); auto releaseHelper = skgpu::RefCntedCallback::Make(releaseP, releaseC);
if (!rContext) { if (!rContext) {
return nullptr; return nullptr;
@ -451,7 +451,7 @@ sk_sp<SkImage> SkImage::MakeFromTexture(GrRecordingContext* rContext,
const GrBackendTexture& tex, GrSurfaceOrigin origin, const GrBackendTexture& tex, GrSurfaceOrigin origin,
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs, SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs,
TextureReleaseProc releaseP, ReleaseContext releaseC) { TextureReleaseProc releaseP, ReleaseContext releaseC) {
auto releaseHelper = GrRefCntedCallback::Make(releaseP, releaseC); auto releaseHelper = skgpu::RefCntedCallback::Make(releaseP, releaseC);
if (!rContext) { if (!rContext) {
return nullptr; return nullptr;
@ -583,7 +583,7 @@ sk_sp<SkImage> SkImage::MakePromiseTexture(sk_sp<GrContextThreadSafeProxy> threa
// Our contract is that we will always call the release proc even on failure. // Our contract is that we will always call the release proc even on failure.
// We use the helper to convey the context, so we need to ensure make doesn't fail. // We use the helper to convey the context, so we need to ensure make doesn't fail.
textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {}; textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {};
auto releaseHelper = GrRefCntedCallback::Make(textureReleaseProc, textureContext); auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, textureContext);
SkImageInfo info = SkImageInfo::Make(dimensions, colorType, alphaType, colorSpace); SkImageInfo info = SkImageInfo::Make(dimensions, colorType, alphaType, colorSpace);
if (!SkImageInfoIsValid(info)) { if (!SkImageInfoIsValid(info)) {
return nullptr; return nullptr;
@ -727,7 +727,7 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrDirectContext* dContex
} }
SkASSERT(deleteImageProc); SkASSERT(deleteImageProc);
auto releaseHelper = GrRefCntedCallback::Make(deleteImageProc, deleteImageCtx); auto releaseHelper = skgpu::RefCntedCallback::Make(deleteImageProc, deleteImageCtx);
SkColorType colorType = SkColorType colorType =
GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format); GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);

View File

@ -200,7 +200,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
GrBackendFormat backendFormat, GrBackendFormat backendFormat,
GrMipmapped mipMapped, GrMipmapped mipMapped,
PromiseImageTextureFulfillProc fulfillProc, PromiseImageTextureFulfillProc fulfillProc,
sk_sp<GrRefCntedCallback> releaseHelper) { sk_sp<skgpu::RefCntedCallback> releaseHelper) {
SkASSERT(tsp); SkASSERT(tsp);
SkASSERT(!dimensions.isEmpty()); SkASSERT(!dimensions.isEmpty());
SkASSERT(releaseHelper); SkASSERT(releaseHelper);
@ -233,7 +233,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
class PromiseLazyInstantiateCallback { class PromiseLazyInstantiateCallback {
public: public:
PromiseLazyInstantiateCallback(PromiseImageTextureFulfillProc fulfillProc, PromiseLazyInstantiateCallback(PromiseImageTextureFulfillProc fulfillProc,
sk_sp<GrRefCntedCallback> releaseHelper) sk_sp<skgpu::RefCntedCallback> releaseHelper)
: fFulfillProc(fulfillProc), fReleaseHelper(std::move(releaseHelper)) {} : fFulfillProc(fulfillProc), fReleaseHelper(std::move(releaseHelper)) {}
PromiseLazyInstantiateCallback(PromiseLazyInstantiateCallback&&) = default; PromiseLazyInstantiateCallback(PromiseLazyInstantiateCallback&&) = default;
PromiseLazyInstantiateCallback(const PromiseLazyInstantiateCallback&) { PromiseLazyInstantiateCallback(const PromiseLazyInstantiateCallback&) {
@ -318,7 +318,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
private: private:
PromiseImageTextureFulfillProc fFulfillProc; PromiseImageTextureFulfillProc fFulfillProc;
sk_sp<GrRefCntedCallback> fReleaseHelper; sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
GrTexture* fTexture = nullptr; GrTexture* fTexture = nullptr;
GrDirectContext::DirectContextID fTextureContextID; GrDirectContext::DirectContextID fTextureContextID;
bool fFulfillProcFailed = false; bool fFulfillProcFailed = false;

View File

@ -44,12 +44,13 @@ public:
// Helper for making a lazy proxy for a promise image. // Helper for making a lazy proxy for a promise image.
// PromiseImageTextureFulfillProc must not be null. // PromiseImageTextureFulfillProc must not be null.
static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(GrContextThreadSafeProxy*, static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(
SkISize dimensions, GrContextThreadSafeProxy*,
GrBackendFormat, SkISize dimensions,
GrMipmapped, GrBackendFormat,
PromiseImageTextureFulfillProc, GrMipmapped,
sk_sp<GrRefCntedCallback> releaseHelper); PromiseImageTextureFulfillProc,
sk_sp<skgpu::RefCntedCallback> releaseHelper);
protected: protected:
SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID); SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID);

View File

@ -230,7 +230,7 @@ sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrRecordingContext* context,
sk_sp<SkColorSpace> imageColorSpace, sk_sp<SkColorSpace> imageColorSpace,
TextureReleaseProc textureReleaseProc, TextureReleaseProc textureReleaseProc,
ReleaseContext releaseContext) { ReleaseContext releaseContext) {
auto releaseHelper = GrRefCntedCallback::Make(textureReleaseProc, releaseContext); auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
int numPlanes = yuvaTextures.yuvaInfo().numPlanes(); int numPlanes = yuvaTextures.yuvaInfo().numPlanes();
@ -348,9 +348,9 @@ sk_sp<SkImage> SkImage::MakePromiseYUVATexture(sk_sp<GrContextThreadSafeProxy> t
// Our contract is that we will always call the release proc even on failure. // Our contract is that we will always call the release proc even on failure.
// We use the helper to convey the context, so we need to ensure make doesn't fail. // We use the helper to convey the context, so we need to ensure make doesn't fail.
textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {}; textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {};
sk_sp<GrRefCntedCallback> releaseHelpers[4]; sk_sp<skgpu::RefCntedCallback> releaseHelpers[4];
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
releaseHelpers[i] = GrRefCntedCallback::Make(textureReleaseProc, textureContexts[i]); releaseHelpers[i] = skgpu::RefCntedCallback::Make(textureReleaseProc, textureContexts[i]);
} }
if (!threadSafeProxy) { if (!threadSafeProxy) {

View File

@ -487,7 +487,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrRecordingContext* rContext,
const SkSurfaceProps* props, const SkSurfaceProps* props,
SkSurface::TextureReleaseProc textureReleaseProc, SkSurface::TextureReleaseProc textureReleaseProc,
SkSurface::ReleaseContext releaseContext) { SkSurface::ReleaseContext releaseContext) {
auto releaseHelper = GrRefCntedCallback::Make(textureReleaseProc, releaseContext); auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
if (!rContext) { if (!rContext) {
return nullptr; return nullptr;
@ -526,7 +526,7 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
ContentChangeMode mode, ContentChangeMode mode,
TextureReleaseProc releaseProc, TextureReleaseProc releaseProc,
ReleaseContext releaseContext) { ReleaseContext releaseContext) {
auto releaseHelper = GrRefCntedCallback::Make(releaseProc, releaseContext); auto releaseHelper = skgpu::RefCntedCallback::Make(releaseProc, releaseContext);
auto rContext = fDevice->recordingContext(); auto rContext = fDevice->recordingContext();
if (rContext->abandoned()) { if (rContext->abandoned()) {
@ -605,7 +605,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrRecordingContext* rCon
const SkSurfaceProps* props, const SkSurfaceProps* props,
SkSurface::RenderTargetReleaseProc relProc, SkSurface::RenderTargetReleaseProc relProc,
SkSurface::ReleaseContext releaseContext) { SkSurface::ReleaseContext releaseContext) {
auto releaseHelper = GrRefCntedCallback::Make(relProc, releaseContext); auto releaseHelper = skgpu::RefCntedCallback::Make(relProc, releaseContext);
if (!rContext) { if (!rContext) {
return nullptr; return nullptr;

View File

@ -11,6 +11,7 @@
#include "include/core/SkImageInfo.h" #include "include/core/SkImageInfo.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "src/core/SkMipmap.h" #include "src/core/SkMipmap.h"
#include "src/gpu/RefCntedCallback.h"
namespace { namespace {
@ -53,8 +54,8 @@ void* ManagedBackendTexture::MakeYUVAReleaseContext(
return context; return context;
} }
sk_sp<GrRefCntedCallback> ManagedBackendTexture::refCountedCallback() const { sk_sp<skgpu::RefCntedCallback> ManagedBackendTexture::refCountedCallback() const {
return GrRefCntedCallback::Make(ReleaseProc, this->releaseContext()); return skgpu::RefCntedCallback::Make(ReleaseProc, this->releaseContext());
} }
void ManagedBackendTexture::wasAdopted() { fTexture = {}; } void ManagedBackendTexture::wasAdopted() { fTexture = {}; }

View File

@ -12,7 +12,9 @@
#include "include/core/SkYUVAInfo.h" #include "include/core/SkYUVAInfo.h"
#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrDirectContext.h"
class GrRefCntedCallback; namespace skgpu {
class RefCntedCallback;
}
struct SkImageInfo; struct SkImageInfo;
namespace sk_gpu_test { namespace sk_gpu_test {
@ -69,7 +71,7 @@ public:
void* releaseContext(GrGpuFinishedProc wrappedProc = nullptr, void* releaseContext(GrGpuFinishedProc wrappedProc = nullptr,
GrGpuFinishedContext wrappedContext = nullptr) const; GrGpuFinishedContext wrappedContext = nullptr) const;
sk_sp<GrRefCntedCallback> refCountedCallback() const; sk_sp<skgpu::RefCntedCallback> refCountedCallback() const;
/** /**
* Call if the underlying GrBackendTexture was adopted by a GrContext. This clears this out the * Call if the underlying GrBackendTexture was adopted by a GrContext. This clears this out the