Baulk at creating wait semaphores if we can't always delete them
Change-Id: I4ddc988972b90ed182a1f11a83e2858c2ba4ae9f
Reviewed-on: https://skia-review.googlesource.com/c/192400
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index b66d0ad..427ab9a 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1666,7 +1666,7 @@
}
bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
- const GrBackendSemaphore* waitSemaphores) {
+ const GrBackendSemaphore waitSemaphores[]) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
@@ -1678,14 +1678,19 @@
return false;
}
- auto resourceProvider = fContext->priv().resourceProvider();
+ auto direct = fContext->priv().asDirectContext();
+ if (!direct) {
+ return false;
+ }
+
+ auto resourceProvider = direct->priv().resourceProvider();
SkTArray<sk_sp<GrSemaphore>> semaphores(numSemaphores);
for (int i = 0; i < numSemaphores; ++i) {
sk_sp<GrSemaphore> sema = resourceProvider->wrapBackendSemaphore(
waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait,
kAdopt_GrWrapOwnership);
- std::unique_ptr<GrOp> waitOp(GrSemaphoreOp::MakeWait(fContext, sema,
+ std::unique_ptr<GrOp> waitOp(GrSemaphoreOp::MakeWait(fContext, std::move(sema),
fRenderTargetProxy.get()));
this->getRTOpList()->addOp(std::move(waitOp), *this->caps());
}
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 7854ab0..bf2f210 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -373,7 +373,7 @@
* The next time this GrRenderTargetContext is flushed, the gpu will wait on the passed in
* semaphores before executing any commands.
*/
- bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
+ bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore waitSemaphores[]);
void insertEventMarker(const SkString&);
diff --git a/src/gpu/ops/GrSemaphoreOp.h b/src/gpu/ops/GrSemaphoreOp.h
index 8576156..648749d 100644
--- a/src/gpu/ops/GrSemaphoreOp.h
+++ b/src/gpu/ops/GrSemaphoreOp.h
@@ -24,7 +24,8 @@
protected:
GrSemaphoreOp(uint32_t classId, sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
- : INHERITED(classId), fSemaphore(std::move(semaphore)) {
+ : INHERITED(classId)
+ , fSemaphore(std::move(semaphore)) {
this->makeFullScreen(proxy);
}