Notify RTC when OpsTask is closed so it can drop ownership
Change-Id: I95d32ed89447995541f33bf80730876ce9c0747a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284519
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index f3f6d23..4c8ba6a 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -398,6 +398,9 @@
GrRenderTargetContext::~GrRenderTargetContext() {
ASSERT_SINGLE_OWNER
+ if (fOpsTask) {
+ fOpsTask->setClosedObserver(nullptr);
+ }
}
inline GrAAType GrRenderTargetContext::chooseAAType(GrAA aa) {
@@ -423,7 +426,7 @@
ASSERT_SINGLE_OWNER
SkDEBUGCODE(this->validate();)
- if (!fOpsTask || fOpsTask->isClosed()) {
+ if (!fOpsTask) {
sk_sp<GrOpsTask> newOpsTask =
this->drawingManager()->newOpsTask(this->writeSurfaceView(), fManagedOpsTask);
if (fOpsTask && fNumStencilSamples > 0) {
@@ -434,9 +437,10 @@
// values?
newOpsTask->setInitialStencilContent(GrOpsTask::StencilContent::kPreserved);
}
+ newOpsTask->setClosedObserver(this);
fOpsTask = std::move(newOpsTask);
}
-
+ SkASSERT(!fOpsTask->isClosed());
return fOpsTask.get();
}
@@ -2654,3 +2658,8 @@
SkRect::Make(clippedSrcRect));
return true;
}
+
+void GrRenderTargetContext::wasClosed(const GrOpsTask& task) {
+ SkASSERT(&task == fOpsTask.get());
+ fOpsTask.reset();
+}