[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:
parent
357881bc95
commit
faf520c000
@ -806,6 +806,7 @@ skia_shared_gpu_sources = [
|
||||
"$_src/gpu/Blend.h",
|
||||
"$_src/gpu/BufferWriter.h",
|
||||
"$_src/gpu/KeyBuilder.h",
|
||||
"$_src/gpu/RefCntedCallback.h",
|
||||
"$_src/gpu/ResourceKey.cpp",
|
||||
"$_src/gpu/ResourceKey.h",
|
||||
"$_src/gpu/ShaderErrorHandler.cpp",
|
||||
|
@ -978,36 +978,6 @@ static constexpr GrColorType GrMaskFormatToColorType(GrMaskFormat format) {
|
||||
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 {
|
||||
kNone = 0,
|
||||
kRequiresTextureBarrier = 1 << 0,
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "include/gpu/gl/GrGLTypes.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
#include "src/gpu/gl/GrGLDefines.h"
|
||||
|
||||
#include <webgl/webgl1.h>
|
||||
@ -782,7 +783,7 @@ protected:
|
||||
|
||||
uint32_t webGLCtx = emscripten_webgl_get_current_context();
|
||||
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(
|
||||
backendTexture,
|
||||
|
@ -119,7 +119,7 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
auto proxyProvider = dContext->priv().proxyProvider();
|
||||
|
||||
fBorrowingMutex.acquire();
|
||||
sk_sp<GrRefCntedCallback> releaseProcHelper;
|
||||
sk_sp<skgpu::RefCntedCallback> releaseProcHelper;
|
||||
if (fRefHelper->fBorrowingContextID.isValid()) {
|
||||
if (fRefHelper->fBorrowingContextID != dContext->directContextID()) {
|
||||
fBorrowingMutex.release();
|
||||
@ -134,10 +134,10 @@ GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
} else {
|
||||
SkASSERT(!fRefHelper->fBorrowingContextReleaseProc);
|
||||
// The ref we add to fRefHelper here will be passed into and owned by the
|
||||
// GrRefCntedCallback.
|
||||
// skgpu::RefCntedCallback.
|
||||
fRefHelper->ref();
|
||||
releaseProcHelper =
|
||||
GrRefCntedCallback::Make(ReleaseRefHelper_TextureReleaseProc, fRefHelper);
|
||||
skgpu::RefCntedCallback::Make(ReleaseRefHelper_TextureReleaseProc, fRefHelper);
|
||||
fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get();
|
||||
}
|
||||
fRefHelper->fBorrowingContextID = dContext->directContextID();
|
||||
|
@ -76,7 +76,7 @@ private:
|
||||
// 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
|
||||
// proxies and gpu uses of the backend texture.
|
||||
GrRefCntedCallback* fBorrowingContextReleaseProc;
|
||||
skgpu::RefCntedCallback* fBorrowingContextReleaseProc;
|
||||
GrDirectContext::DirectContextID fBorrowingContextID;
|
||||
|
||||
std::unique_ptr<GrSemaphore> fSemaphore;
|
||||
|
@ -494,14 +494,15 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
|
||||
return this->createBackendTexture(width, height, format, mipMapped, renderable, isProtected);
|
||||
}
|
||||
|
||||
static GrBackendTexture create_and_clear_backend_texture(GrDirectContext* dContext,
|
||||
SkISize dimensions,
|
||||
const GrBackendFormat& backendFormat,
|
||||
GrMipmapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
static GrBackendTexture create_and_clear_backend_texture(
|
||||
GrDirectContext* dContext,
|
||||
SkISize dimensions,
|
||||
const GrBackendFormat& backendFormat,
|
||||
GrMipmapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
GrGpu* gpu = dContext->priv().getGpu();
|
||||
GrBackendTexture beTex = gpu->createBackendTexture(dimensions, backendFormat, renderable,
|
||||
mipMapped, isProtected);
|
||||
@ -523,7 +524,7 @@ static bool update_texture_with_pixmaps(GrDirectContext* context,
|
||||
int numLevels,
|
||||
const GrBackendTexture& backendTexture,
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
GrColorType ct = SkColorTypeToGrColorType(src[0].colorType());
|
||||
const GrBackendFormat& format = backendTexture.getBackendFormat();
|
||||
|
||||
@ -568,7 +569,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (this->abandoned()) {
|
||||
@ -593,7 +594,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(int width, int height,
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return {};
|
||||
@ -626,7 +627,7 @@ GrBackendTexture GrDirectContext::createBackendTexture(const SkPixmap srcData[],
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return {};
|
||||
@ -669,7 +670,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
|
||||
const SkColor4f& color,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -683,7 +684,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
|
||||
const SkColor4f& color,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -710,7 +711,7 @@ bool GrDirectContext::updateBackendTexture(const GrBackendTexture& backendTextur
|
||||
GrSurfaceOrigin textureOrigin,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -745,7 +746,7 @@ static GrBackendTexture create_and_update_compressed_backend_texture(
|
||||
const GrBackendFormat& backendFormat,
|
||||
GrMipmapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
GrGpu* gpu = dContext->priv().getGpu();
|
||||
@ -773,7 +774,7 @@ GrBackendTexture GrDirectContext::createCompressedBackendTexture(
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return {};
|
||||
@ -825,7 +826,7 @@ GrBackendTexture GrDirectContext::createCompressedBackendTexture(
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return {};
|
||||
@ -859,7 +860,7 @@ bool GrDirectContext::updateCompressedBackendTexture(const GrBackendTexture& bac
|
||||
const SkColor4f& color,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -891,7 +892,7 @@ bool GrDirectContext::updateCompressedBackendTexture(const GrBackendTexture& bac
|
||||
size_t dataSize,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto finishedCallback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto finishedCallback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -914,7 +915,7 @@ bool GrDirectContext::setBackendTextureState(const GrBackendTexture& backendText
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto callback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto callback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
@ -929,7 +930,7 @@ bool GrDirectContext::setBackendRenderTargetState(const GrBackendRenderTarget& b
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
auto callback = GrRefCntedCallback::Make(finishedProc, finishedContext);
|
||||
auto callback = skgpu::RefCntedCallback::Make(finishedProc, finishedContext);
|
||||
|
||||
if (this->abandoned()) {
|
||||
return false;
|
||||
|
@ -843,7 +843,7 @@ GrBackendTexture GrGpu::createBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
bool GrGpu::clearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
if (!backendTexture.isValid()) {
|
||||
return false;
|
||||
@ -886,7 +886,7 @@ GrBackendTexture GrGpu::createCompressedBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
bool GrGpu::updateCompressedBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length) {
|
||||
SkASSERT(data);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "src/gpu/GrOpsRenderPass.h"
|
||||
#include "src/gpu/GrPixmap.h"
|
||||
#include "src/gpu/GrXferProcessor.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
#include "src/gpu/Swizzle.h"
|
||||
|
||||
class GrAttachment;
|
||||
@ -534,7 +535,7 @@ public:
|
||||
GrProtected);
|
||||
|
||||
bool clearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color);
|
||||
|
||||
/**
|
||||
@ -547,21 +548,21 @@ public:
|
||||
GrProtected);
|
||||
|
||||
bool updateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length);
|
||||
|
||||
virtual bool setBackendTextureState(const GrBackendTexture&,
|
||||
const GrBackendSurfaceMutableState&,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool setBackendRenderTargetState(const GrBackendRenderTarget&,
|
||||
const GrBackendSurfaceMutableState&,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -678,11 +679,11 @@ private:
|
||||
SkISize dimensions, const GrBackendFormat&, GrMipmapped, GrProtected) = 0;
|
||||
|
||||
virtual bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) = 0;
|
||||
|
||||
virtual bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length) = 0;
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef GrManagedResource_DEFINED
|
||||
#define GrManagedResource_DEFINED
|
||||
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "include/private/SkMutex.h"
|
||||
#include "include/private/SkTHash.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
#include <atomic>
|
||||
|
||||
class GrTexture;
|
||||
@ -221,12 +221,12 @@ public:
|
||||
SkASSERT(!fReleaseHelper);
|
||||
}
|
||||
|
||||
void setRelease(sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
void setRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
fReleaseHelper = std::move(releaseHelper);
|
||||
}
|
||||
|
||||
protected:
|
||||
mutable sk_sp<GrRefCntedCallback> fReleaseHelper;
|
||||
mutable sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
|
||||
|
||||
void invokeReleaseProc() const {
|
||||
if (fReleaseHelper) {
|
||||
|
@ -520,11 +520,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::createCompressedTextureProxy(
|
||||
return proxy;
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType ioType,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(
|
||||
const GrBackendTexture& backendTex,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType ioType,
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
SkASSERT(ioType != kWrite_GrIOType);
|
||||
|
||||
if (this->isAbandoned()) {
|
||||
@ -561,7 +562,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapCompressedBackendTexture(
|
||||
const GrBackendTexture& beTex,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -597,7 +598,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -635,7 +636,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
|
||||
|
||||
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
|
||||
const GrBackendRenderTarget& backendRT,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -116,12 +116,12 @@ public:
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable,
|
||||
GrIOType,
|
||||
sk_sp<GrRefCntedCallback> = nullptr);
|
||||
sk_sp<skgpu::RefCntedCallback> = nullptr);
|
||||
|
||||
sk_sp<GrTextureProxy> wrapCompressedBackendTexture(const GrBackendTexture&,
|
||||
GrWrapOwnership,
|
||||
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
|
||||
@ -130,13 +130,13 @@ public:
|
||||
int sampleCnt,
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
/*
|
||||
* Create a render target proxy that wraps a backend render target
|
||||
*/
|
||||
sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
sk_sp<GrRenderTargetProxy> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
|
||||
const GrVkDrawableInfo&);
|
||||
|
@ -308,7 +308,7 @@ std::unique_ptr<skgpu::SurfaceFillContext> GrRecordingContextPriv::makeSFCFromBa
|
||||
const GrBackendTexture& tex,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin origin,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
|
||||
#if SK_GPU_V1
|
||||
SkASSERT(sampleCount > 0);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/gpu/BaseDevice.h"
|
||||
#include "src/gpu/GrImageContextPriv.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
#include "src/gpu/text/GrSDFTControl.h"
|
||||
|
||||
class GrImageInfo;
|
||||
@ -201,7 +202,7 @@ public:
|
||||
const GrBackendTexture&,
|
||||
int sampleCount,
|
||||
GrSurfaceOrigin,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
protected:
|
||||
explicit GrRecordingContextPriv(GrRecordingContext* rContext) : GrImageContextPriv(rContext) {}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#include "src/gpu/GrGpuResource.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
|
||||
class GrRenderTarget;
|
||||
class GrTexture;
|
||||
@ -41,7 +42,7 @@ public:
|
||||
|
||||
virtual GrBackendFormat backendFormat() const = 0;
|
||||
|
||||
void setRelease(sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
void setRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
this->onSetRelease(releaseHelper);
|
||||
fReleaseHelper = std::move(releaseHelper);
|
||||
}
|
||||
@ -51,7 +52,7 @@ public:
|
||||
typedef void* ReleaseCtx;
|
||||
typedef void (*ReleaseProc)(ReleaseCtx);
|
||||
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
|
||||
// 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() {
|
||||
// Depending on the ref count of fReleaseHelper this may or may not actually trigger the
|
||||
@ -152,7 +153,7 @@ private:
|
||||
SkISize fDimensions;
|
||||
GrInternalSurfaceFlags fSurfaceFlags;
|
||||
GrProtected fIsProtected;
|
||||
sk_sp<GrRefCntedCallback> fReleaseHelper;
|
||||
sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
|
||||
|
||||
using INHERITED = GrGpuResource;
|
||||
};
|
||||
|
47
src/gpu/RefCntedCallback.h
Normal file
47
src/gpu/RefCntedCallback.h
Normal 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
|
||||
|
@ -80,7 +80,7 @@ void GrD3DCommandList::releaseResources() {
|
||||
this->callFinishedCallbacks();
|
||||
}
|
||||
|
||||
void GrD3DCommandList::addFinishedCallback(sk_sp<GrRefCntedCallback> callback) {
|
||||
void GrD3DCommandList::addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback) {
|
||||
fFinishedCallbacks.push_back(std::move(callback));
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
|
||||
bool hasWork() const { return fHasWork; }
|
||||
|
||||
void addFinishedCallback(sk_sp<GrRefCntedCallback> callback);
|
||||
void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback);
|
||||
|
||||
private:
|
||||
static const int kInitialTrackedResourcesCount = 32;
|
||||
@ -149,7 +149,7 @@ private:
|
||||
|
||||
SkSTArray<4, D3D12_RESOURCE_BARRIER> fResourceBarriers;
|
||||
|
||||
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedCallbacks;
|
||||
SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedCallbacks;
|
||||
};
|
||||
|
||||
class GrD3DDirectCommandList : public GrD3DCommandList {
|
||||
|
@ -233,10 +233,10 @@ void GrD3DGpu::endRenderPass(GrRenderTarget* target, GrSurfaceOrigin origin,
|
||||
void GrD3DGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
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);
|
||||
// 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
|
||||
@ -1387,7 +1387,7 @@ static bool copy_color_data(const GrD3DCaps& caps,
|
||||
}
|
||||
|
||||
bool GrD3DGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
GrD3DTextureResourceInfo info;
|
||||
SkAssertResult(backendTexture.getD3DTextureResourceInfo(&info));
|
||||
@ -1488,7 +1488,7 @@ GrBackendTexture GrD3DGpu::onCreateCompressedBackendTexture(
|
||||
}
|
||||
|
||||
bool GrD3DGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
GrD3DTextureResourceInfo info;
|
||||
|
@ -204,7 +204,7 @@ private:
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback);
|
||||
void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
|
||||
|
||||
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
|
||||
bool useMSAASurface,
|
||||
@ -230,7 +230,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override;
|
||||
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
@ -239,7 +239,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) override;
|
||||
|
||||
|
@ -118,7 +118,7 @@ private:
|
||||
|
||||
// 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).
|
||||
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
|
||||
void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
|
||||
// Forward the release proc on to GrD3DTextureResource
|
||||
this->setResourceRelease(std::move(releaseHelper));
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
|
||||
// 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).
|
||||
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
|
||||
void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
|
||||
// Forward the release proc on to GrSurfaceResource
|
||||
this->setResourceRelease(std::move(releaseHelper));
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ private:
|
||||
|
||||
// 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).
|
||||
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
|
||||
void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
|
||||
// Forward the release proc on to GrD3DImage
|
||||
this->setResourceRelease(std::move(releaseHelper));
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void GrD3DTextureResource::releaseResource(GrD3DGpu* gpu) {
|
||||
fInfo.fAlloc.reset();
|
||||
}
|
||||
|
||||
void GrD3DTextureResource::setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
void GrD3DTextureResource::setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
SkASSERT(fResource);
|
||||
// Forward the release proc on to GrD3DTextureResource::Resource
|
||||
fResource->setRelease(std::move(releaseHelper));
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
GrD3DGpu* gpu, SkISize dimensions, int sampleCnt, const GrD3DTextureResourceInfo& info,
|
||||
SkColor4f clearColor);
|
||||
|
||||
void setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
void setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
protected:
|
||||
void releaseResource(GrD3DGpu* gpu);
|
||||
|
@ -385,7 +385,7 @@ void GrDawnGpu::uploadTextureData(GrColorType srcColorType, const GrMipLevel tex
|
||||
}
|
||||
|
||||
bool GrDawnGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
GrDawnTextureInfo info;
|
||||
SkAssertResult(backendTexture.getDawnTextureInfo(&info));
|
||||
@ -444,7 +444,7 @@ GrBackendTexture GrDawnGpu::onCreateCompressedBackendTexture(
|
||||
}
|
||||
|
||||
bool GrDawnGpu::onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
return false;
|
||||
|
@ -146,7 +146,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override;
|
||||
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
@ -155,7 +155,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) override;
|
||||
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
|
||||
void onAbandon() 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.
|
||||
size_t onGpuMemorySize() const override;
|
||||
|
@ -1565,7 +1565,7 @@ GrBackendTexture GrGLGpu::onCreateCompressedBackendTexture(
|
||||
}
|
||||
|
||||
bool GrGLGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length) {
|
||||
GrGLTextureInfo info;
|
||||
@ -3704,7 +3704,7 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
bool GrGLGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
|
@ -231,11 +231,11 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length) override;
|
||||
|
||||
|
@ -179,7 +179,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override {
|
||||
return true;
|
||||
}
|
||||
@ -190,7 +190,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void*,
|
||||
size_t) override {
|
||||
return true;
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
bool commit(bool waitUntilCompleted);
|
||||
bool hasWork() { return fHasWork; }
|
||||
|
||||
void addFinishedCallback(sk_sp<GrRefCntedCallback> callback) {
|
||||
void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> callback) {
|
||||
fFinishedCallbacks.push_back(std::move(callback));
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ private:
|
||||
MTLRenderPassDescriptor* fPreviousRenderPassDescriptor;
|
||||
bool fHasWork;
|
||||
|
||||
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedCallbacks;
|
||||
SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedCallbacks;
|
||||
|
||||
};
|
||||
|
||||
|
@ -142,7 +142,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override;
|
||||
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
@ -151,7 +151,7 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) override;
|
||||
|
||||
@ -227,7 +227,7 @@ private:
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback);
|
||||
void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
|
||||
|
||||
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
|
||||
bool useMSAASurface,
|
||||
|
@ -261,10 +261,10 @@ void GrMtlGpu::finishOutstandingGpuWork() {
|
||||
void GrMtlGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
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);
|
||||
// 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
|
||||
@ -923,7 +923,7 @@ GrBackendTexture GrMtlGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
bool GrMtlGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
GrMtlTextureInfo info;
|
||||
SkAssertResult(backendTexture.getMtlTextureInfo(&info));
|
||||
@ -1025,7 +1025,7 @@ GrBackendTexture GrMtlGpu::onCreateCompressedBackendTexture(
|
||||
}
|
||||
|
||||
bool GrMtlGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
GrMtlTextureInfo info;
|
||||
|
@ -269,7 +269,7 @@ std::unique_ptr<SurfaceDrawContext> SurfaceDrawContext::MakeFromBackendTexture(
|
||||
int sampleCnt,
|
||||
GrSurfaceOrigin origin,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
SkASSERT(sampleCnt > 0);
|
||||
sk_sp<GrTextureProxy> proxy(rContext->priv().proxyProvider()->wrapRenderableBackendTexture(
|
||||
tex, sampleCnt, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
int sampleCnt,
|
||||
GrSurfaceOrigin,
|
||||
const SkSurfaceProps&,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
SurfaceDrawContext(GrRecordingContext*,
|
||||
GrSurfaceProxyView readView,
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ public:
|
||||
|
||||
bool finished(GrVkGpu* gpu);
|
||||
|
||||
void addFinishedProc(sk_sp<GrRefCntedCallback> finishedProc);
|
||||
void addFinishedProc(sk_sp<skgpu::RefCntedCallback> finishedProc);
|
||||
|
||||
void callFinishedProcs() {
|
||||
fFinishedProcs.reset();
|
||||
@ -331,7 +331,7 @@ private:
|
||||
|
||||
SkTArray<std::unique_ptr<GrVkSecondaryCommandBuffer>, true> fSecondaryCommandBuffers;
|
||||
VkFence fSubmitFence;
|
||||
SkTArray<sk_sp<GrRefCntedCallback>> fFinishedProcs;
|
||||
SkTArray<sk_sp<skgpu::RefCntedCallback>> fFinishedProcs;
|
||||
|
||||
using INHERITED = GrVkCommandBuffer;
|
||||
};
|
||||
|
@ -1603,7 +1603,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
|
||||
}
|
||||
|
||||
bool GrVkGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) {
|
||||
GrVkImageInfo info;
|
||||
SkAssertResult(backendTexture.getVkImageInfo(&info));
|
||||
@ -1702,7 +1702,7 @@ GrBackendTexture GrVkGpu::onCreateCompressedBackendTexture(
|
||||
}
|
||||
|
||||
bool GrVkGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendTexture,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
GrVkImageInfo info;
|
||||
@ -1814,7 +1814,7 @@ bool GrVkGpu::setBackendSurfaceState(GrVkImageInfo info,
|
||||
SkISize dimensions,
|
||||
const GrVkSharedImageInfo& newInfo,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
sk_sp<GrVkImage> texture = GrVkImage::MakeWrapped(this,
|
||||
dimensions,
|
||||
info,
|
||||
@ -1841,7 +1841,7 @@ bool GrVkGpu::setBackendSurfaceState(GrVkImageInfo info,
|
||||
bool GrVkGpu::setBackendTextureState(const GrBackendTexture& backendTeture,
|
||||
const GrBackendSurfaceMutableState& newState,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
GrVkImageInfo info;
|
||||
SkAssertResult(backendTeture.getVkImageInfo(&info));
|
||||
sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendTeture.getMutableState();
|
||||
@ -1855,7 +1855,7 @@ bool GrVkGpu::setBackendTextureState(const GrBackendTexture& backendTeture,
|
||||
bool GrVkGpu::setBackendRenderTargetState(const GrBackendRenderTarget& backendRenderTarget,
|
||||
const GrBackendSurfaceMutableState& newState,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
GrVkImageInfo info;
|
||||
SkAssertResult(backendRenderTarget.getVkImageInfo(&info));
|
||||
sk_sp<GrBackendSurfaceMutableStateImpl> currentState = backendRenderTarget.getMutableState();
|
||||
@ -2097,10 +2097,10 @@ void GrVkGpu::prepareSurfacesForBackendAccessAndStateUpdates(
|
||||
void GrVkGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
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);
|
||||
fResourceProvider.addFinishedProcToActiveCommandBuffers(std::move(finishedCallback));
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ public:
|
||||
bool setBackendTextureState(const GrBackendTexture&,
|
||||
const GrBackendSurfaceMutableState&,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) override;
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) override;
|
||||
|
||||
bool setBackendRenderTargetState(const GrBackendRenderTarget&,
|
||||
const GrBackendSurfaceMutableState&,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) override;
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) override;
|
||||
|
||||
void deleteBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
@ -222,11 +222,11 @@ private:
|
||||
GrProtected) override;
|
||||
|
||||
bool onClearBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
std::array<float, 4> color) override;
|
||||
|
||||
bool onUpdateCompressedBackendTexture(const GrBackendTexture&,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback,
|
||||
const void* data,
|
||||
size_t length) override;
|
||||
|
||||
@ -235,7 +235,7 @@ private:
|
||||
SkISize dimensions,
|
||||
const GrVkSharedImageInfo& newInfo,
|
||||
GrBackendSurfaceMutableState* previousState,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback);
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback);
|
||||
|
||||
sk_sp<GrTexture> onCreateTexture(SkISize,
|
||||
const GrBackendFormat&,
|
||||
@ -307,7 +307,7 @@ private:
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
|
||||
void addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback);
|
||||
void addFinishedCallback(sk_sp<skgpu::RefCntedCallback> finishedCallback);
|
||||
|
||||
GrOpsRenderPass* onGetOpsRenderPass(GrRenderTarget*,
|
||||
bool useMSAASurface,
|
||||
|
@ -590,7 +590,7 @@ void GrVkImage::onAbandon() {
|
||||
GrAttachment::onAbandon();
|
||||
}
|
||||
|
||||
void GrVkImage::setResourceRelease(sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
void GrVkImage::setResourceRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
SkASSERT(fResource);
|
||||
// Forward the release proc on to GrVkImage::Resource
|
||||
fResource->setRelease(std::move(releaseHelper));
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
typedef void* 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
|
||||
static VkPipelineStageFlags LayoutToPipelineSrcStageFlags(const VkImageLayout layout);
|
||||
|
@ -160,7 +160,7 @@ private:
|
||||
|
||||
// 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).
|
||||
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,
|
||||
// otherwise the color attachment.
|
||||
GrVkImage* attachment =
|
||||
|
@ -466,7 +466,7 @@ void GrVkResourceProvider::forceSyncAllCommandBuffers() {
|
||||
}
|
||||
|
||||
void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers(
|
||||
sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
sk_sp<skgpu::RefCntedCallback> finishedCallback) {
|
||||
for (int i = 0; i < fActiveCommandPools.count(); ++i) {
|
||||
GrVkCommandPool* pool = fActiveCommandPools[i];
|
||||
GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
// 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
|
||||
// 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.
|
||||
// The refcount is incremented and a pointer returned.
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "src/gpu/GrSemaphore.h"
|
||||
|
||||
#include "include/gpu/vk/GrVkTypes.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "src/gpu/vk/GrVkManagedResource.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
@ -75,7 +75,7 @@ protected:
|
||||
|
||||
// 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).
|
||||
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
|
||||
void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
|
||||
// Forward the release proc onto the fTexture's GrVkImage
|
||||
fTexture->setResourceRelease(std::move(releaseHelper));
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
|
||||
// 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).
|
||||
void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
|
||||
void onSetRelease(sk_sp<skgpu::RefCntedCallback> releaseHelper) override {
|
||||
// Forward the release proc on to GrVkImage
|
||||
GrVkTexture::onSetRelease(std::move(releaseHelper));
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrRecordingContext* rContext,
|
||||
SkAlphaType at,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrWrapOwnership ownership,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
if (!backendTex.isValid() || backendTex.width() <= 0 || backendTex.height() <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -418,7 +418,7 @@ sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrRecordingContext* rContext,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
TextureReleaseProc releaseP,
|
||||
ReleaseContext releaseC) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(releaseP, releaseC);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(releaseP, releaseC);
|
||||
|
||||
if (!rContext) {
|
||||
return nullptr;
|
||||
@ -451,7 +451,7 @@ sk_sp<SkImage> SkImage::MakeFromTexture(GrRecordingContext* rContext,
|
||||
const GrBackendTexture& tex, GrSurfaceOrigin origin,
|
||||
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs,
|
||||
TextureReleaseProc releaseP, ReleaseContext releaseC) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(releaseP, releaseC);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(releaseP, releaseC);
|
||||
|
||||
if (!rContext) {
|
||||
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.
|
||||
// We use the helper to convey the context, so we need to ensure make doesn't fail.
|
||||
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);
|
||||
if (!SkImageInfoIsValid(info)) {
|
||||
return nullptr;
|
||||
@ -727,7 +727,7 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrDirectContext* dContex
|
||||
}
|
||||
SkASSERT(deleteImageProc);
|
||||
|
||||
auto releaseHelper = GrRefCntedCallback::Make(deleteImageProc, deleteImageCtx);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(deleteImageProc, deleteImageCtx);
|
||||
|
||||
SkColorType colorType =
|
||||
GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
|
||||
|
@ -200,7 +200,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
GrBackendFormat backendFormat,
|
||||
GrMipmapped mipMapped,
|
||||
PromiseImageTextureFulfillProc fulfillProc,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper) {
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper) {
|
||||
SkASSERT(tsp);
|
||||
SkASSERT(!dimensions.isEmpty());
|
||||
SkASSERT(releaseHelper);
|
||||
@ -233,7 +233,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
class PromiseLazyInstantiateCallback {
|
||||
public:
|
||||
PromiseLazyInstantiateCallback(PromiseImageTextureFulfillProc fulfillProc,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper)
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper)
|
||||
: fFulfillProc(fulfillProc), fReleaseHelper(std::move(releaseHelper)) {}
|
||||
PromiseLazyInstantiateCallback(PromiseLazyInstantiateCallback&&) = default;
|
||||
PromiseLazyInstantiateCallback(const PromiseLazyInstantiateCallback&) {
|
||||
@ -318,7 +318,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
|
||||
private:
|
||||
PromiseImageTextureFulfillProc fFulfillProc;
|
||||
sk_sp<GrRefCntedCallback> fReleaseHelper;
|
||||
sk_sp<skgpu::RefCntedCallback> fReleaseHelper;
|
||||
GrTexture* fTexture = nullptr;
|
||||
GrDirectContext::DirectContextID fTextureContextID;
|
||||
bool fFulfillProcFailed = false;
|
||||
|
@ -44,12 +44,13 @@ public:
|
||||
|
||||
// Helper for making a lazy proxy for a promise image.
|
||||
// PromiseImageTextureFulfillProc must not be null.
|
||||
static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(GrContextThreadSafeProxy*,
|
||||
SkISize dimensions,
|
||||
GrBackendFormat,
|
||||
GrMipmapped,
|
||||
PromiseImageTextureFulfillProc,
|
||||
sk_sp<GrRefCntedCallback> releaseHelper);
|
||||
static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(
|
||||
GrContextThreadSafeProxy*,
|
||||
SkISize dimensions,
|
||||
GrBackendFormat,
|
||||
GrMipmapped,
|
||||
PromiseImageTextureFulfillProc,
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelper);
|
||||
|
||||
protected:
|
||||
SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID);
|
||||
|
@ -230,7 +230,7 @@ sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrRecordingContext* context,
|
||||
sk_sp<SkColorSpace> imageColorSpace,
|
||||
TextureReleaseProc textureReleaseProc,
|
||||
ReleaseContext releaseContext) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(textureReleaseProc, releaseContext);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
|
||||
|
||||
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
||||
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.
|
||||
// We use the helper to convey the context, so we need to ensure make doesn't fail.
|
||||
textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](void*) {};
|
||||
sk_sp<GrRefCntedCallback> releaseHelpers[4];
|
||||
sk_sp<skgpu::RefCntedCallback> releaseHelpers[4];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
releaseHelpers[i] = GrRefCntedCallback::Make(textureReleaseProc, textureContexts[i]);
|
||||
releaseHelpers[i] = skgpu::RefCntedCallback::Make(textureReleaseProc, textureContexts[i]);
|
||||
}
|
||||
|
||||
if (!threadSafeProxy) {
|
||||
|
@ -487,7 +487,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrRecordingContext* rContext,
|
||||
const SkSurfaceProps* props,
|
||||
SkSurface::TextureReleaseProc textureReleaseProc,
|
||||
SkSurface::ReleaseContext releaseContext) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(textureReleaseProc, releaseContext);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
|
||||
|
||||
if (!rContext) {
|
||||
return nullptr;
|
||||
@ -526,7 +526,7 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
|
||||
ContentChangeMode mode,
|
||||
TextureReleaseProc releaseProc,
|
||||
ReleaseContext releaseContext) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(releaseProc, releaseContext);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(releaseProc, releaseContext);
|
||||
|
||||
auto rContext = fDevice->recordingContext();
|
||||
if (rContext->abandoned()) {
|
||||
@ -605,7 +605,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrRecordingContext* rCon
|
||||
const SkSurfaceProps* props,
|
||||
SkSurface::RenderTargetReleaseProc relProc,
|
||||
SkSurface::ReleaseContext releaseContext) {
|
||||
auto releaseHelper = GrRefCntedCallback::Make(relProc, releaseContext);
|
||||
auto releaseHelper = skgpu::RefCntedCallback::Make(relProc, releaseContext);
|
||||
|
||||
if (!rContext) {
|
||||
return nullptr;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "src/core/SkMipmap.h"
|
||||
#include "src/gpu/RefCntedCallback.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -53,8 +54,8 @@ void* ManagedBackendTexture::MakeYUVAReleaseContext(
|
||||
return context;
|
||||
}
|
||||
|
||||
sk_sp<GrRefCntedCallback> ManagedBackendTexture::refCountedCallback() const {
|
||||
return GrRefCntedCallback::Make(ReleaseProc, this->releaseContext());
|
||||
sk_sp<skgpu::RefCntedCallback> ManagedBackendTexture::refCountedCallback() const {
|
||||
return skgpu::RefCntedCallback::Make(ReleaseProc, this->releaseContext());
|
||||
}
|
||||
|
||||
void ManagedBackendTexture::wasAdopted() { fTexture = {}; }
|
||||
|
@ -12,7 +12,9 @@
|
||||
#include "include/core/SkYUVAInfo.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
|
||||
class GrRefCntedCallback;
|
||||
namespace skgpu {
|
||||
class RefCntedCallback;
|
||||
}
|
||||
struct SkImageInfo;
|
||||
|
||||
namespace sk_gpu_test {
|
||||
@ -69,7 +71,7 @@ public:
|
||||
void* releaseContext(GrGpuFinishedProc wrappedProc = nullptr,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user