GrGLSemaphore.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef GrGLSemaphore_DEFINED
  8. #define GrGLSemaphore_DEFINED
  9. #include "include/gpu/GrBackendSemaphore.h"
  10. #include "include/private/GrTypesPriv.h"
  11. #include "src/gpu/GrSemaphore.h"
  12. class GrGLGpu;
  13. class GrGLSemaphore : public GrSemaphore {
  14. public:
  15. static sk_sp<GrGLSemaphore> Make(GrGLGpu* gpu, bool isOwned) {
  16. return sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu, isOwned));
  17. }
  18. static sk_sp<GrGLSemaphore> MakeWrapped(GrGLGpu* gpu,
  19. GrGLsync sync,
  20. GrWrapOwnership ownership) {
  21. auto sema = sk_sp<GrGLSemaphore>(new GrGLSemaphore(gpu,
  22. kBorrow_GrWrapOwnership != ownership));
  23. sema->setSync(sync);
  24. return sema;
  25. }
  26. GrGLsync sync() const { return fSync; }
  27. void setSync(const GrGLsync& sync) { fSync = sync; }
  28. GrBackendSemaphore backendSemaphore() const override {
  29. GrBackendSemaphore backendSemaphore;
  30. backendSemaphore.initGL(fSync);
  31. return backendSemaphore;
  32. }
  33. private:
  34. GrGLSemaphore(GrGLGpu* gpu, bool isOwned);
  35. void onRelease() override;
  36. void onAbandon() override;
  37. GrGLsync fSync;
  38. bool fIsOwned;
  39. typedef GrSemaphore INHERITED;
  40. };
  41. #endif