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>
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 31cd5bd..312544f 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -860,24 +860,30 @@
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 cb3b47d..fa8f179 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -214,14 +214,24 @@
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 @@
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 8828d69..bca8df1 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -77,7 +77,7 @@
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 f251815..f73c138 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -65,8 +65,8 @@
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 @@
}
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,
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index a0de3d1..c92cee9 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -27,7 +27,7 @@
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();
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index f509eea..2c2623a 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -122,8 +122,8 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
-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 @@
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 98bef80..b84dac7 100644
--- a/src/image/SkImage_GpuYUVA.h
+++ b/src/image/SkImage_GpuYUVA.h
@@ -34,7 +34,7 @@
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.