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

Side by Side Diff: ui/gl/gl_fence.cc

Issue 180723023: gpu: Mailbox emulation with EGLImage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_fence.h" 5 #include "ui/gl/gl_fence.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context.h" 9 #include "ui/gl/gl_context.h"
10 10
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 virtual bool HasCompleted() OVERRIDE { 31 virtual bool HasCompleted() OVERRIDE {
32 return !!glTestFenceNV(fence_); 32 return !!glTestFenceNV(fence_);
33 } 33 }
34 34
35 virtual void ClientWait() OVERRIDE { 35 virtual void ClientWait() OVERRIDE {
36 glFinishFenceNV(fence_); 36 glFinishFenceNV(fence_);
37 } 37 }
38 38
39 virtual void ServerWait() OVERRIDE {
40 glFinishFenceNV(fence_);
41 }
42
39 private: 43 private:
40 virtual ~GLFenceNVFence() { 44 virtual ~GLFenceNVFence() {
41 glDeleteFencesNV(1, &fence_); 45 glDeleteFencesNV(1, &fence_);
42 } 46 }
43 47
44 GLuint fence_; 48 GLuint fence_;
45 }; 49 };
46 50
47 class GLFenceARBSync: public gfx::GLFence { 51 class GLFenceARBSync: public gfx::GLFence {
48 public: 52 public:
(...skipping 10 matching lines...) Expand all
59 // We could potentially use glGetSynciv here, but it doesn't work 63 // We could potentially use glGetSynciv here, but it doesn't work
60 // on OSX 10.7 (always says the fence is not signaled yet). 64 // on OSX 10.7 (always says the fence is not signaled yet).
61 // glClientWaitSync works better, so let's use that instead. 65 // glClientWaitSync works better, so let's use that instead.
62 return glClientWaitSync(sync_, 0, 0) != GL_TIMEOUT_EXPIRED; 66 return glClientWaitSync(sync_, 0, 0) != GL_TIMEOUT_EXPIRED;
63 } 67 }
64 68
65 virtual void ClientWait() OVERRIDE { 69 virtual void ClientWait() OVERRIDE {
66 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); 70 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
67 } 71 }
68 72
73 virtual void ServerWait() OVERRIDE {
74 glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
75 }
76
69 private: 77 private:
70 virtual ~GLFenceARBSync() { 78 virtual ~GLFenceARBSync() {
71 glDeleteSync(sync_); 79 glDeleteSync(sync_);
72 } 80 }
73 81
74 GLsync sync_; 82 GLsync sync_;
75 }; 83 };
76 84
77 #if !defined(OS_MACOSX) 85 #if !defined(OS_MACOSX)
78 class EGLFenceSync : public gfx::GLFence { 86 class EGLFenceSync : public gfx::GLFence {
(...skipping 10 matching lines...) Expand all
89 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR); 97 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
90 return !value || value == EGL_SIGNALED_KHR; 98 return !value || value == EGL_SIGNALED_KHR;
91 } 99 }
92 100
93 virtual void ClientWait() OVERRIDE { 101 virtual void ClientWait() OVERRIDE {
94 EGLint flags = 0; 102 EGLint flags = 0;
95 EGLTimeKHR time = EGL_FOREVER_KHR; 103 EGLTimeKHR time = EGL_FOREVER_KHR;
96 eglClientWaitSyncKHR(display_, sync_, flags, time); 104 eglClientWaitSyncKHR(display_, sync_, flags, time);
97 } 105 }
98 106
107 virtual void ServerWait() OVERRIDE {
108 EGLint flags = 0;
109 eglWaitSyncKHR(display_, sync_, flags);
110 }
111
112
99 private: 113 private:
100 virtual ~EGLFenceSync() { 114 virtual ~EGLFenceSync() {
101 eglDestroySyncKHR(display_, sync_); 115 eglDestroySyncKHR(display_, sync_);
102 } 116 }
103 117
104 EGLSyncKHR sync_; 118 EGLSyncKHR sync_;
105 EGLDisplay display_; 119 EGLDisplay display_;
106 }; 120 };
107 #endif // !OS_MACOSX 121 #endif // !OS_MACOSX
108 122
(...skipping 14 matching lines...) Expand all
123 return new EGLFenceSync(); 137 return new EGLFenceSync();
124 #endif 138 #endif
125 if (gfx::g_driver_gl.ext.b_GL_NV_fence) 139 if (gfx::g_driver_gl.ext.b_GL_NV_fence)
126 return new GLFenceNVFence(); 140 return new GLFenceNVFence();
127 if (gfx::g_driver_gl.ext.b_GL_ARB_sync) 141 if (gfx::g_driver_gl.ext.b_GL_ARB_sync)
128 return new GLFenceARBSync(); 142 return new GLFenceARBSync();
129 return NULL; 143 return NULL;
130 } 144 }
131 145
132 } // namespace gfx 146 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698