diff --git a/include/core/SkImage.h b/include/core/SkImage.h index 31cd5bd290..312544f660 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -860,24 +860,30 @@ public: bool isValid(GrRecordingContext* context) const; /** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not - texture-backed (including promise texture images) or if the the GrContext does not + texture-backed (including promise texture images) or if the GrDirectContext does not have the same context ID as the context backing the image then this is a no-op. - If the image was not used in any non-culled draws recorded on the passed GrContext then - this is a no-op unless the GrFlushInfo contains semaphores or a finish proc. Those are - respected even when the image has not been used. + If the image was not used in any non-culled draws in the current queue of work for the + passed GrDirectContext then this is a no-op unless the GrFlushInfo contains semaphores or + a finish proc. Those are respected even when the image has not been used. @param context the context on which to flush pending usages of the image. @param info flush options */ - GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo); + GrSemaphoresSubmitted flush(GrDirectContext* context, const GrFlushInfo& flushInfo); - void flush(GrContext* context) { this->flush(context, {}); } + void flush(GrDirectContext* context) { this->flush(context, {}); } /** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the GPU. */ + void flushAndSubmit(GrDirectContext*); + +#ifdef SK_IMAGE_FLUSH_LEGACY_API + GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo); + void flush(GrContext* context) { this->flush(context, {}); } void flushAndSubmit(GrContext*); +#endif /** Retrieves the back-end texture. If SkImage has no back-end texture, an invalid object is returned. Call GrBackendTexture::isValid to determine if the result diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index cb3b47dfe5..fa8f179116 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -214,14 +214,24 @@ bool SkImage::isValid(GrRecordingContext* rContext) const { return as_IB(this)->onIsValid(rContext); } +GrSemaphoresSubmitted SkImage::flush(GrDirectContext* dContext, const GrFlushInfo& flushInfo) { + return as_IB(this)->onFlush(dContext, flushInfo); +} + +void SkImage::flushAndSubmit(GrDirectContext* dContext) { + this->flush(dContext, {}); + dContext->submit(); +} + +#ifdef SK_IMAGE_FLUSH_LEGACY_API GrSemaphoresSubmitted SkImage::flush(GrContext* context, const GrFlushInfo& flushInfo) { - return as_IB(this)->onFlush(context, flushInfo); + return this->flush(GrAsDirectContext(context), flushInfo); } void SkImage::flushAndSubmit(GrContext* context) { - this->flush(context, {}); - context->submit(); + this->flushAndSubmit(GrAsDirectContext(context)); } +#endif #else @@ -239,11 +249,19 @@ bool SkImage::isValid(GrRecordingContext* rContext) const { return as_IB(this)->onIsValid(nullptr); } +GrSemaphoresSubmitted SkImage::flush(GrDirectContext*, const GrFlushInfo&) { + return GrSemaphoresSubmitted::kNo; +} + +void SkImage::flushAndSubmit(GrDirectContext*) {} + +#ifdef SK_IMAGE_FLUSH_LEGACY_API GrSemaphoresSubmitted SkImage::flush(GrContext*, const GrFlushInfo&) { return GrSemaphoresSubmitted::kNo; } void SkImage::flushAndSubmit(GrContext*) {} +#endif #endif diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 8828d69fc8..bca8df1b28 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -77,7 +77,7 @@ public: virtual GrContext* context() const { return nullptr; } #if SK_SUPPORT_GPU - virtual GrSemaphoresSubmitted onFlush(GrContext* context, const GrFlushInfo&) { + virtual GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) { return GrSemaphoresSubmitted::kNo; } diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index f251815c37..f73c13892b 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -65,8 +65,8 @@ SkImage_Gpu::SkImage_Gpu(sk_sp context, uint32_t uniqueID, GrSurfaceP SkImage_Gpu::~SkImage_Gpu() {} -GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrContext* context, const GrFlushInfo& info) { - if (!context || !fContext->priv().matches(context) || fContext->abandoned()) { +GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrDirectContext* dContext, const GrFlushInfo& info) { + if (!fContext->priv().matches(dContext) || dContext->abandoned()) { if (info.fSubmittedProc) { info.fSubmittedProc(info.fSubmittedContext, false); } @@ -77,7 +77,7 @@ GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrContext* context, const GrFlushInfo } GrSurfaceProxy* p[1] = {fView.proxy()}; - return context->priv().flushSurfaces(p, 1, info); + return dContext->priv().flushSurfaces(p, 1, info); } sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT, diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index a0de3d1b6e..c92cee91ef 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -27,7 +27,7 @@ public: sk_sp); ~SkImage_Gpu() override; - GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override; + GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override; GrTextureProxy* peekProxy() const override { return fView.asTextureProxy(); diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index f509eeac33..2c2623ac19 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -122,8 +122,8 @@ bool SkImage_GpuYUVA::setupMipmapsForPlanes(GrRecordingContext* context) const { ////////////////////////////////////////////////////////////////////////////////////////////////// -GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrContext* context, const GrFlushInfo& info) { - if (!context || !fContext->priv().matches(context) || fContext->abandoned()) { +GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrDirectContext* dContext, const GrFlushInfo& info) { + if (!fContext->priv().matches(dContext) || dContext->abandoned()) { if (info.fSubmittedProc) { info.fSubmittedProc(info.fSubmittedContext, false); } @@ -143,7 +143,7 @@ GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrContext* context, const GrFlush proxies[0] = fRGBView.proxy(); numProxies = 1; } - return context->priv().flushSurfaces(proxies, numProxies, info); + return dContext->priv().flushSurfaces(proxies, numProxies, info); } GrTextureProxy* SkImage_GpuYUVA::peekProxy() const { return fRGBView.asTextureProxy(); } diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h index 98bef80f85..b84dac70e0 100644 --- a/src/image/SkImage_GpuYUVA.h +++ b/src/image/SkImage_GpuYUVA.h @@ -34,7 +34,7 @@ public: GrSurfaceOrigin, sk_sp); - GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override; + GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override; // This returns the single backing proxy if the YUV channels have already been flattened but // nullptr if they have not.