diff options
author | Greg Daniel <egdaniel@google.com> | 2017-06-15 15:25:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-15 19:49:18 +0000 |
commit | 66366c697853e906d961ae691e2bc5209cdcfa62 (patch) | |
tree | f90de7fef9bd094ded9f6497c0004876694cca61 /src/gpu/gl | |
parent | 000182881a65ef4b12ca3739d47c5e21e79ca919 (diff) |
Add API for flushing surfaces with gpu semaphores
BUG=skia:
Change-Id: Ia4bfef784cd5f2516ceccafce958be18a86f91d1
Reviewed-on: https://skia-review.googlesource.com/11488
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Forrest Reiling <freiling@google.com>
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 13 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLSemaphore.h | 25 |
3 files changed, 33 insertions, 9 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index b3f8c2caa8..d40160044c 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -9,6 +9,7 @@ #include <cmath> #include "../private/GrGLSL.h" +#include "GrBackendSemaphore.h" #include "GrBackendSurface.h" #include "GrFixedClip.h" #include "GrGLBuffer.h" @@ -4288,10 +4289,16 @@ void GrGLGpu::deleteFence(GrFence fence) const { this->deleteSync((GrGLsync)fence); } -sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrGLGpu::makeSemaphore() { - return GrGLSemaphore::Make(this); +sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrGLGpu::makeSemaphore(bool isOwned) { + return GrGLSemaphore::Make(this, isOwned); } +sk_sp<GrSemaphore> GrGLGpu::wrapBackendSemaphore(const GrBackendSemaphore& semaphore, + GrWrapOwnership ownership) { + return GrGLSemaphore::MakeWrapped(this, semaphore.glSync(), ownership); +} + + void GrGLGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) { GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore.get()); @@ -4316,7 +4323,7 @@ void GrGLGpu::deleteSync(GrGLsync sync) const { sk_sp<GrSemaphore> GrGLGpu::prepareTextureForCrossContextUsage(GrTexture* texture) { // Set up a semaphore to be signaled once the data is ready, and flush GL - sk_sp<GrSemaphore> semaphore = this->makeSemaphore(); + sk_sp<GrSemaphore> semaphore = this->makeSemaphore(true); this->insertSemaphore(semaphore, true); return semaphore; diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index f121df3f01..80a12eb7cc 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -166,7 +166,9 @@ public: bool waitFence(GrFence, uint64_t timeout) override; void deleteFence(GrFence) const override; - sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() override; + sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned) override; + sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore, + GrWrapOwnership ownership) override; void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override; void waitSemaphore(sk_sp<GrSemaphore> semaphore) override; diff --git a/src/gpu/gl/GrGLSemaphore.h b/src/gpu/gl/GrGLSemaphore.h index f439ebd294..cfc3de9951 100644 --- a/src/gpu/gl/GrGLSemaphore.h +++ b/src/gpu/gl/GrGLSemaphore.h @@ -10,16 +10,26 @@ #include "GrSemaphore.h" -class GrGLGpu; +#include "GrBackendSemaphore.h" +#include "GrGLGpu.h" class GrGLSemaphore : public GrSemaphore { public: - static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu) { - return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu)); + static sk_sp<GrGLSemaphore> Make(const GrGLGpu* gpu, bool isOwned) { + return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned)); + } + + static sk_sp<GrGLSemaphore> MakeWrapped(const GrGLGpu* gpu, + GrGLsync sync, + GrWrapOwnership ownership) { + auto sema = sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, + kBorrow_GrWrapOwnership != ownership)); + sema->setSync(sync); + return sema; } ~GrGLSemaphore() override { - if (fGpu) { + if (fIsOwned && fGpu) { static_cast<const GrGLGpu*>(fGpu)->deleteSync(fSync); } } @@ -28,9 +38,14 @@ public: void setSync(const GrGLsync& sync) { fSync = sync; } private: - GrGLSemaphore(const GrGLGpu* gpu) : INHERITED(gpu), fSync(0) {} + GrGLSemaphore(const GrGLGpu* gpu, bool isOwned) : INHERITED(gpu), fSync(0), fIsOwned(isOwned) {} + + void setBackendSemaphore(GrBackendSemaphore* backendSemaphore) const override { + backendSemaphore->initGL(fSync); + } GrGLsync fSync; + bool fIsOwned; typedef GrSemaphore INHERITED; }; |