Make GrSemaphore a GrGpuResource
This makes semaphores get handled correctly when GrContext is abandoned or
asked to free all its resources.
Change-Id: I0b935bb95cf99b9acf647472bcd0231bb2759db6
Reviewed-on: https://skia-review.googlesource.com/150364
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLSemaphore.cpp b/src/gpu/gl/GrGLSemaphore.cpp
index c26b74e..b557efb 100644
--- a/src/gpu/gl/GrGLSemaphore.cpp
+++ b/src/gpu/gl/GrGLSemaphore.cpp
@@ -9,12 +9,20 @@
#include "GrGLGpu.h"
-GrGLSemaphore::GrGLSemaphore(const GrGLGpu* gpu, bool isOwned)
- : INHERITED(gpu), fSync(0), fIsOwned(isOwned) {
+GrGLSemaphore::GrGLSemaphore(GrGLGpu* gpu, bool isOwned)
+ : INHERITED(gpu), fSync(0), fIsOwned(isOwned) {
+ isOwned ? this->registerWithCache(SkBudgeted::kNo) : this->registerWithCacheWrapped();
}
-GrGLSemaphore::~GrGLSemaphore() {
- if (fIsOwned && fGpu) {
- static_cast<const GrGLGpu*>(fGpu)->deleteSync(fSync);
+void GrGLSemaphore::onRelease() {
+ if (fSync && fIsOwned) {
+ static_cast<const GrGLGpu*>(this->getGpu())->deleteSync(fSync);
}
+ fSync = 0;
+ INHERITED::onRelease();
+}
+
+void GrGLSemaphore::onAbandon() {
+ fSync = 0;
+ INHERITED::onAbandon();
}