Add a isDDLTarget flag to GrSurfaceProxy
With repositionable DDLs the surface proxies they target need
special handling (i.e., their backing resource size cannot
be known ahead of time).
I'll follow this up with a CL that removes the DDLTarget system from
the GrDrawingManager. AFAICT it is not longer needed.
Change-Id: I0d9189b94726fdf356d54c16de32d7e52e0d1451
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352116
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkDeferredDisplayList.cpp b/src/core/SkDeferredDisplayList.cpp
index 23a3324..c073567 100644
--- a/src/core/SkDeferredDisplayList.cpp
+++ b/src/core/SkDeferredDisplayList.cpp
@@ -28,6 +28,9 @@
, fLazyProxyData(std::move(lazyProxyData))
#endif
{
+#if SK_SUPPORT_GPU
+ SkASSERT(fTargetProxy->isDDLTarget());
+#endif
}
SkDeferredDisplayList::~SkDeferredDisplayList() {
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 43db56f..433ef40 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -162,7 +162,7 @@
fTargetProxy = proxyProvider->createLazyRenderTargetProxy(
[lazyProxyData = fLazyProxyData](GrResourceProvider* resourceProvider,
- const GrSurfaceProxy::LazySurfaceDesc&) {
+ const GrSurfaceProxy::LazySurfaceDesc&) {
// The proxy backing the destination surface had better have been instantiated
// prior to the this one (i.e., the proxy backing the DLL's surface).
// Fulfill this lazy proxy with the destination surface's GrRenderTarget.
@@ -185,6 +185,7 @@
if (!fTargetProxy) {
return false;
}
+ fTargetProxy->priv().setIsDDLTarget();
GrSwizzle writeSwizzle = caps->getWriteSwizzle(fCharacterization.backendFormat(), grColorType);
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index d6eee6c..49c63e4 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -104,6 +104,8 @@
access == SkSurface::BackendSurfaceAccess::kNoAccess && !newState) {
bool allUnused = std::all_of(proxies.begin(), proxies.end(), [&](GrSurfaceProxy* proxy) {
bool used = std::any_of(fDAG.begin(), fDAG.end(), [&](auto& task) {
+ // TODO: the DDLTask should now just return true here instead of
+ // needing GrDrawingManager::isDDLTarget.
return task && task->isUsed(proxy);
});
return !used && !this->isDDLTarget(proxy);
@@ -686,6 +688,11 @@
}
#endif
+void GrDrawingManager::addDDLTarget(GrSurfaceProxy* newTarget, GrRenderTargetProxy* ddlTarget) {
+ SkASSERT(ddlTarget->isDDLTarget());
+ fDDLTargets.set(newTarget->uniqueID().asUInt(), ddlTarget);
+}
+
void GrDrawingManager::closeActiveOpsTask() {
if (fActiveOpsTask) {
// This is a temporary fix for the partial-MDB world. In that world we're not
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 72c6c15..b226569 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -184,16 +184,12 @@
SkTArray<GrOnFlushCallbackObject*> fOnFlushCBObjects;
- void addDDLTarget(GrSurfaceProxy* newTarget, GrRenderTargetProxy* ddlTarget) {
- fDDLTargets.set(newTarget->uniqueID().asUInt(), ddlTarget);
- }
+ // TODO: this should be removed. The DDLTask has a ref on 'newTarget' and should
+ // just use that pointer.
+ void addDDLTarget(GrSurfaceProxy* newTarget, GrRenderTargetProxy* ddlTarget);
bool isDDLTarget(GrSurfaceProxy* newTarget) {
return SkToBool(fDDLTargets.find(newTarget->uniqueID().asUInt()));
}
- GrRenderTargetProxy* getDDLTarget(GrSurfaceProxy* newTarget) {
- auto entry = fDDLTargets.find(newTarget->uniqueID().asUInt());
- return entry ? *entry : nullptr;
- }
void clearDDLTargets() { fDDLTargets.reset(); }
// We play a trick with lazy proxies to retarget the base target of a DDL to the SkSurface
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index 1ac26a1..f162cc3 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -327,6 +327,8 @@
inline GrSurfaceProxyPriv priv();
inline const GrSurfaceProxyPriv priv() const; // NOLINT(readability-const-return-type)
+ bool isDDLTarget() const { return fIsDDLTarget; }
+
GrProtected isProtected() const { return fIsProtected; }
protected:
@@ -424,6 +426,7 @@
virtual LazySurfaceDesc callbackDesc() const = 0;
bool fIgnoredByResourceAllocator = false;
+ bool fIsDDLTarget = false;
GrProtected fIsProtected;
// This entry is lazily evaluated so, when the proxy wraps a resource, the resource
diff --git a/src/gpu/GrSurfaceProxyPriv.h b/src/gpu/GrSurfaceProxyPriv.h
index 0ed82ed..aa98f96 100644
--- a/src/gpu/GrSurfaceProxyPriv.h
+++ b/src/gpu/GrSurfaceProxyPriv.h
@@ -40,6 +40,8 @@
bool doLazyInstantiation(GrResourceProvider*);
+ void setIsDDLTarget() { fProxy->fIsDDLTarget = true; }
+
private:
explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) = delete;