OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gl/GLTestContext.h" | 8 #include "gl/GLTestContext.h" |
9 | 9 |
10 #define GL_GLEXT_PROTOTYPES | 10 #define GL_GLEXT_PROTOTYPES |
11 #include <GLES2/gl2.h> | 11 #include <GLES2/gl2.h> |
12 | 12 |
13 #define EGL_EGLEXT_PROTOTYPES | 13 #define EGL_EGLEXT_PROTOTYPES |
14 #include <EGL/egl.h> | 14 #include <EGL/egl.h> |
15 #include <EGL/eglext.h> | 15 #include <EGL/eglext.h> |
16 | 16 |
17 #include "gl/GrGLDefines.h" | 17 #include "gl/GrGLDefines.h" |
18 #include "gl/GrGLUtil.h" | 18 #include "gl/GrGLUtil.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_s
ync. | 22 // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_s
ync. |
23 class EGLFenceSync : public SkGpuFenceSync { | 23 class EGLFenceSync : public sk_gpu_test::FenceSync { |
24 public: | 24 public: |
25 static EGLFenceSync* CreateIfSupported(EGLDisplay); | 25 static EGLFenceSync* CreateIfSupported(EGLDisplay); |
26 | 26 |
27 SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override; | 27 sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const overrid
e; |
28 bool waitFence(SkPlatformGpuFence fence) const override; | 28 bool waitFence(sk_gpu_test::PlatformFence fence) const override; |
29 void deleteFence(SkPlatformGpuFence fence) const override; | 29 void deleteFence(sk_gpu_test::PlatformFence fence) const override; |
30 | 30 |
31 private: | 31 private: |
32 EGLFenceSync(EGLDisplay display) : fDisplay(display) {} | 32 EGLFenceSync(EGLDisplay display) : fDisplay(display) {} |
33 | 33 |
34 EGLDisplay fDisplay; | 34 EGLDisplay fDisplay; |
35 | 35 |
36 typedef SkGpuFenceSync INHERITED; | 36 typedef sk_gpu_test::FenceSync INHERITED; |
37 }; | 37 }; |
38 | 38 |
39 class EGLGLTestContext : public sk_gpu_test::GLTestContext { | 39 class EGLGLTestContext : public sk_gpu_test::GLTestContext { |
40 public: | 40 public: |
41 EGLGLTestContext(GrGLStandard forcedGpuAPI); | 41 EGLGLTestContext(GrGLStandard forcedGpuAPI); |
42 ~EGLGLTestContext() override; | 42 ~EGLGLTestContext() override; |
43 | 43 |
44 GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; | 44 GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; |
45 void destroyEGLImage(GrEGLImage) const override; | 45 void destroyEGLImage(GrEGLImage) const override; |
46 GrGLuint eglImageToExternalTexture(GrEGLImage) const override; | 46 GrGLuint eglImageToExternalTexture(GrEGLImage) const override; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 return false; | 294 return false; |
295 } | 295 } |
296 | 296 |
297 EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) { | 297 EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) { |
298 if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) { | 298 if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) { |
299 return nullptr; | 299 return nullptr; |
300 } | 300 } |
301 return new EGLFenceSync(display); | 301 return new EGLFenceSync(display); |
302 } | 302 } |
303 | 303 |
304 SkPlatformGpuFence EGLFenceSync::insertFence() const { | 304 sk_gpu_test::PlatformFence EGLFenceSync::insertFence() const { |
305 return eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr); | 305 EGLSyncKHR eglsync = eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr)
; |
| 306 return reinterpret_cast<sk_gpu_test::PlatformFence>(eglsync); |
306 } | 307 } |
307 | 308 |
308 bool EGLFenceSync::waitFence(SkPlatformGpuFence platformFence) const { | 309 bool EGLFenceSync::waitFence(sk_gpu_test::PlatformFence platformFence) const { |
309 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); | 310 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); |
310 return EGL_CONDITION_SATISFIED_KHR == | 311 return EGL_CONDITION_SATISFIED_KHR == |
311 eglClientWaitSyncKHR(fDisplay, | 312 eglClientWaitSyncKHR(fDisplay, |
312 eglsync, | 313 eglsync, |
313 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, | 314 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, |
314 EGL_FOREVER_KHR); | 315 EGL_FOREVER_KHR); |
315 } | 316 } |
316 | 317 |
317 void EGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const { | 318 void EGLFenceSync::deleteFence(sk_gpu_test::PlatformFence platformFence) const { |
318 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); | 319 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); |
319 eglDestroySyncKHR(fDisplay, eglsync); | 320 eglDestroySyncKHR(fDisplay, eglsync); |
320 } | 321 } |
321 | 322 |
322 } // anonymous namespace | 323 } // anonymous namespace |
323 | 324 |
324 namespace sk_gpu_test { | 325 namespace sk_gpu_test { |
325 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, | 326 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
326 GLTestContext *shareContext) { | 327 GLTestContext *shareContext) { |
327 SkASSERT(!shareContext); | 328 SkASSERT(!shareContext); |
328 if (shareContext) { | 329 if (shareContext) { |
329 return nullptr; | 330 return nullptr; |
330 } | 331 } |
331 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI); | 332 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI); |
332 if (!ctx->isValid()) { | 333 if (!ctx->isValid()) { |
333 delete ctx; | 334 delete ctx; |
334 return nullptr; | 335 return nullptr; |
335 } | 336 } |
336 return ctx; | 337 return ctx; |
337 } | 338 } |
338 } // namespace sk_gpu_test | 339 } // namespace sk_gpu_test |
339 | 340 |
OLD | NEW |