Index: tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp |
diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp |
index edbc63200bba04fcaa14460a4870bb0575c1145d..684b3be9dd7531ba9ef4b23a0fa62b0a20c17172 100644 |
--- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp |
+++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp |
@@ -17,25 +17,69 @@ |
#include "gl/GrGLDefines.h" |
#include "gl/GrGLUtil.h" |
+namespace sk_gpu_test { |
+ |
namespace { |
bsalomon
2016/10/03 19:16:20
why nested? AFAIK we only ever use top level anony
|
// TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_sync. |
-class EGLFenceSync : public SkGpuFenceSync { |
+class EGLFenceSync : public FenceSync { |
public: |
static EGLFenceSync* CreateIfSupported(EGLDisplay); |
- SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override; |
- bool waitFence(SkPlatformGpuFence fence) const override; |
- void deleteFence(SkPlatformGpuFence fence) const override; |
+ PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override; |
+ bool waitFence(PlatformFence fence) const override; |
+ void deleteFence(PlatformFence fence) const override; |
private: |
EGLFenceSync(EGLDisplay display) : fDisplay(display) {} |
EGLDisplay fDisplay; |
- typedef SkGpuFenceSync INHERITED; |
+ typedef FenceSync INHERITED; |
}; |
+bool supports_egl_extension(EGLDisplay display, const char* extension) { |
+ size_t extensionLength = strlen(extension); |
+ const char* extensionsStr = eglQueryString(display, EGL_EXTENSIONS); |
+ while (const char* match = strstr(extensionsStr, extension)) { |
+ // Ensure the string we found is its own extension, not a substring of a larger extension |
+ // (e.g. GL_ARB_occlusion_query / GL_ARB_occlusion_query2). |
+ if ((match == extensionsStr || match[-1] == ' ') && |
+ (match[extensionLength] == ' ' || match[extensionLength] == '\0')) { |
+ return true; |
+ } |
+ extensionsStr = match + extensionLength; |
+ } |
+ return false; |
+} |
+ |
+EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) { |
+ if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) { |
+ return nullptr; |
+ } |
+ return new EGLFenceSync(display); |
+} |
+ |
+PlatformFence EGLFenceSync::insertFence() const { |
+ return reinterpret_cast<PlatformFence>(eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr)); |
+} |
+ |
+bool EGLFenceSync::waitFence(PlatformFence platformFence) const { |
+ EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); |
+ return EGL_CONDITION_SATISFIED_KHR == |
+ eglClientWaitSyncKHR(fDisplay, |
+ eglsync, |
+ EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, |
+ EGL_FOREVER_KHR); |
+} |
+ |
+void EGLFenceSync::deleteFence(PlatformFence platformFence) const { |
+ EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); |
+ eglDestroySyncKHR(fDisplay, eglsync); |
+} |
+ |
+} // anonymous namespace |
+ |
class EGLGLTestContext : public sk_gpu_test::GLTestContext { |
public: |
EGLGLTestContext(GrGLStandard forcedGpuAPI); |
@@ -279,49 +323,6 @@ GrGLFuncPtr EGLGLTestContext::onPlatformGetProcAddress(const char* procName) con |
return eglGetProcAddress(procName); |
} |
-static bool supports_egl_extension(EGLDisplay display, const char* extension) { |
- size_t extensionLength = strlen(extension); |
- const char* extensionsStr = eglQueryString(display, EGL_EXTENSIONS); |
- while (const char* match = strstr(extensionsStr, extension)) { |
- // Ensure the string we found is its own extension, not a substring of a larger extension |
- // (e.g. GL_ARB_occlusion_query / GL_ARB_occlusion_query2). |
- if ((match == extensionsStr || match[-1] == ' ') && |
- (match[extensionLength] == ' ' || match[extensionLength] == '\0')) { |
- return true; |
- } |
- extensionsStr = match + extensionLength; |
- } |
- return false; |
-} |
- |
-EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) { |
- if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) { |
- return nullptr; |
- } |
- return new EGLFenceSync(display); |
-} |
- |
-SkPlatformGpuFence EGLFenceSync::insertFence() const { |
- return eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr); |
-} |
- |
-bool EGLFenceSync::waitFence(SkPlatformGpuFence platformFence) const { |
- EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); |
- return EGL_CONDITION_SATISFIED_KHR == |
- eglClientWaitSyncKHR(fDisplay, |
- eglsync, |
- EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, |
- EGL_FOREVER_KHR); |
-} |
- |
-void EGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const { |
- EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); |
- eglDestroySyncKHR(fDisplay, eglsync); |
-} |
- |
-} // anonymous namespace |
- |
-namespace sk_gpu_test { |
GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
GLTestContext *shareContext) { |
SkASSERT(!shareContext); |