Migrate SkImage::flush methods to GrDirectContext

Flag landed in Chrome CL 2310889.

Bug: skia:104662
Change-Id: I616c7e6cd16104132bb0764c6d786a5cbeb4dd47
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304797
Commit-Queue: Adlai Holler <adlai@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2020-07-22 10:22:12 -04:00 committed by Skia Commit-Bot
parent e40ced7d9a
commit 40ad5fd50a
7 changed files with 42 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -65,8 +65,8 @@ SkImage_Gpu::SkImage_Gpu(sk_sp<GrContext> 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> SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT,

View File

@ -27,7 +27,7 @@ public:
sk_sp<SkColorSpace>);
~SkImage_Gpu() override;
GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override;
GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override;
GrTextureProxy* peekProxy() const override {
return fView.asTextureProxy();

View File

@ -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(); }

View File

@ -34,7 +34,7 @@ public:
GrSurfaceOrigin,
sk_sp<SkColorSpace>);
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.