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 sk_gpu_test::FenceSync { | 23 class EGLFenceSync : public SkGpuFenceSync { |
24 public: | 24 public: |
25 static EGLFenceSync* CreateIfSupported(EGLDisplay); | 25 static EGLFenceSync* CreateIfSupported(EGLDisplay); |
26 | 26 |
27 sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const overrid
e; | 27 SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override; |
28 bool waitFence(sk_gpu_test::PlatformFence fence) const override; | 28 bool waitFence(SkPlatformGpuFence fence) const override; |
29 void deleteFence(sk_gpu_test::PlatformFence fence) const override; | 29 void deleteFence(SkPlatformGpuFence 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 sk_gpu_test::FenceSync INHERITED; | 36 typedef SkGpuFenceSync 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 sk_gpu_test::PlatformFence EGLFenceSync::insertFence() const { | 304 SkPlatformGpuFence EGLFenceSync::insertFence() const { |
305 EGLSyncKHR eglsync = eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr)
; | 305 return eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr); |
306 return reinterpret_cast<sk_gpu_test::PlatformFence>(eglsync); | |
307 } | 306 } |
308 | 307 |
309 bool EGLFenceSync::waitFence(sk_gpu_test::PlatformFence platformFence) const { | 308 bool EGLFenceSync::waitFence(SkPlatformGpuFence platformFence) const { |
310 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); | 309 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); |
311 return EGL_CONDITION_SATISFIED_KHR == | 310 return EGL_CONDITION_SATISFIED_KHR == |
312 eglClientWaitSyncKHR(fDisplay, | 311 eglClientWaitSyncKHR(fDisplay, |
313 eglsync, | 312 eglsync, |
314 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, | 313 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, |
315 EGL_FOREVER_KHR); | 314 EGL_FOREVER_KHR); |
316 } | 315 } |
317 | 316 |
318 void EGLFenceSync::deleteFence(sk_gpu_test::PlatformFence platformFence) const { | 317 void EGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const { |
319 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence); | 318 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); |
320 eglDestroySyncKHR(fDisplay, eglsync); | 319 eglDestroySyncKHR(fDisplay, eglsync); |
321 } | 320 } |
322 | 321 |
323 } // anonymous namespace | 322 } // anonymous namespace |
324 | 323 |
325 namespace sk_gpu_test { | 324 namespace sk_gpu_test { |
326 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, | 325 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, |
327 GLTestContext *shareContext) { | 326 GLTestContext *shareContext) { |
328 SkASSERT(!shareContext); | 327 SkASSERT(!shareContext); |
329 if (shareContext) { | 328 if (shareContext) { |
330 return nullptr; | 329 return nullptr; |
331 } | 330 } |
332 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI); | 331 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI); |
333 if (!ctx->isValid()) { | 332 if (!ctx->isValid()) { |
334 delete ctx; | 333 delete ctx; |
335 return nullptr; | 334 return nullptr; |
336 } | 335 } |
337 return ctx; | 336 return ctx; |
338 } | 337 } |
339 } // namespace sk_gpu_test | 338 } // namespace sk_gpu_test |
340 | 339 |
OLD | NEW |