skia2/include/gpu/GrBackendSemaphore.h
Greg Daniel 66366c6978 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>
2017-06-15 19:49:18 +00:00

70 lines
1.6 KiB
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrBackendSemaphore_DEFINED
#define GrBackendSemaphore_DEFINED
#include "GrTypes.h"
#include "gl/GrGLTypes.h"
#ifdef SK_VULKAN
#include "vk/GrVkTypes.h"
#endif
/**
* Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
*/
class GrBackendSemaphore {
public:
// For convenience we just set the backend here to OpenGL. The GrBackendSemaphore cannot be used
// until either initGL or initVulkan are called which will set the appropriate GrBackend.
GrBackendSemaphore() : fBackend(kOpenGL_GrBackend), fGLSync(0), fIsInitialized(false) {}
void initGL(GrGLsync sync) {
fBackend = kOpenGL_GrBackend;
fGLSync = sync;
fIsInitialized = true;
}
#ifdef SK_VULKAN
void initVulkan(VkSemaphore semaphore) {
fBackend = kVulkan_GrBackend;
fVkSemaphore = semaphore;
fIsInitialized = true;
}
#endif
GrGLsync glSync() const {
if (!fIsInitialized || kOpenGL_GrBackend != fBackend) {
return 0;
}
return fGLSync;
}
#ifdef SK_VULKAN
VkSemaphore vkSemaphore() const {
if (!fIsInitialized || kVulkan_GrBackend != fBackend) {
return VK_NULL_HANDLE;
}
return fVkSemaphore;
}
#endif
private:
GrBackend fBackend;
union {
GrGLsync fGLSync;
#ifdef SK_VULKAN
VkSemaphore fVkSemaphore;
#endif
};
bool fIsInitialized;
};
#endif