Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrGLSemaphore.h" |
| 9 | |
| 10 | #include "GrGLGpu.h" |
| 11 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame^] | 12 | GrGLSemaphore::GrGLSemaphore(GrGLGpu* gpu, bool isOwned) |
| 13 | : INHERITED(gpu), fSync(0), fIsOwned(isOwned) { |
| 14 | isOwned ? this->registerWithCache(SkBudgeted::kNo) : this->registerWithCacheWrapped(); |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 15 | } |
| 16 | |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame^] | 17 | void GrGLSemaphore::onRelease() { |
| 18 | if (fSync && fIsOwned) { |
| 19 | static_cast<const GrGLGpu*>(this->getGpu())->deleteSync(fSync); |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 20 | } |
Brian Salomon | 62db8d5 | 2018-08-30 10:37:47 -0400 | [diff] [blame^] | 21 | fSync = 0; |
| 22 | INHERITED::onRelease(); |
| 23 | } |
| 24 | |
| 25 | void GrGLSemaphore::onAbandon() { |
| 26 | fSync = 0; |
| 27 | INHERITED::onAbandon(); |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 28 | } |