Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp

Issue 2383383002: Move GPU fences into sk_gpu_test (Closed)
Patch Set: Move GPU fences into sk_gpu_test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 sk_gpu_test {
bsalomon 2016/10/03 17:54:00 Can't this still be in an anonymous namespace?
csmartdalton 2016/10/03 19:05:40 Done.
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 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 PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override;
28 bool waitFence(SkPlatformGpuFence fence) const override; 28 bool waitFence(PlatformFence fence) const override;
29 void deleteFence(SkPlatformGpuFence fence) const override; 29 void deleteFence(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 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
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 PlatformFence EGLFenceSync::insertFence() const {
305 return eglCreateSyncKHR(fDisplay, EGL_SYNC_FENCE_KHR, nullptr); 305 return reinterpret_cast<PlatformFence>(eglCreateSyncKHR(fDisplay, EGL_SYNC_F ENCE_KHR, nullptr));
306 } 306 }
307 307
308 bool EGLFenceSync::waitFence(SkPlatformGpuFence platformFence) const { 308 bool EGLFenceSync::waitFence(PlatformFence platformFence) const {
309 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); 309 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence);
310 return EGL_CONDITION_SATISFIED_KHR == 310 return EGL_CONDITION_SATISFIED_KHR ==
311 eglClientWaitSyncKHR(fDisplay, 311 eglClientWaitSyncKHR(fDisplay,
312 eglsync, 312 eglsync,
313 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 313 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
314 EGL_FOREVER_KHR); 314 EGL_FOREVER_KHR);
315 } 315 }
316 316
317 void EGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const { 317 void EGLFenceSync::deleteFence(PlatformFence platformFence) const {
318 EGLSyncKHR eglsync = static_cast<EGLSyncKHR>(platformFence); 318 EGLSyncKHR eglsync = reinterpret_cast<EGLSyncKHR>(platformFence);
319 eglDestroySyncKHR(fDisplay, eglsync); 319 eglDestroySyncKHR(fDisplay, eglsync);
320 } 320 }
321 321
322 } // anonymous namespace
323
324 namespace sk_gpu_test {
325 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, 322 GLTestContext *CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI,
326 GLTestContext *shareContext) { 323 GLTestContext *shareContext) {
327 SkASSERT(!shareContext); 324 SkASSERT(!shareContext);
328 if (shareContext) { 325 if (shareContext) {
329 return nullptr; 326 return nullptr;
330 } 327 }
331 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI); 328 EGLGLTestContext *ctx = new EGLGLTestContext(forcedGpuAPI);
332 if (!ctx->isValid()) { 329 if (!ctx->isValid()) {
333 delete ctx; 330 delete ctx;
334 return nullptr; 331 return nullptr;
335 } 332 }
336 return ctx; 333 return ctx;
337 } 334 }
338 } // namespace sk_gpu_test 335 } // namespace sk_gpu_test
339 336
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698