Bug 1324626 - Pick a MAX_CLIENT_WAIT_TIMEOUT_WEBGL. - r=lenzak800
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 19 Dec 2016 19:31:18 -0800
changeset 357449 793d4f83b98e8b68256893d830dd7bf513a47ad2
parent 357448 e53843761b603738135e2918cab284a6752ffbb5
child 357450 64eeb4a05bfecd59ae16df50058e669b5e00099a
push id17
push userfmarier@mozilla.com
push dateFri, 13 Jan 2017 22:14:57 +0000
reviewerslenzak800
bugs1324626
milestone53.0a1
Bug 1324626 - Pick a MAX_CLIENT_WAIT_TIMEOUT_WEBGL. - r=lenzak800 MozReview-Commit-ID: L4gaasXZYFb
dom/canvas/WebGL2Context.h
dom/canvas/WebGL2ContextState.cpp
dom/canvas/WebGL2ContextSync.cpp
--- a/dom/canvas/WebGL2Context.h
+++ b/dom/canvas/WebGL2Context.h
@@ -320,16 +320,18 @@ public:
     void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
     void GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLenum pname,
                              JS::MutableHandleValue retval);
 
 
     // -------------------------------------------------------------------------
     // Sync objects - WebGL2ContextSync.cpp
 
+    const GLuint64 kMaxClientWaitSyncTimeoutNS = 1000 * 1000 * 1000; // 1000ms in ns.
+
     already_AddRefed<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
     bool IsSync(const WebGLSync* sync);
     void DeleteSync(WebGLSync* sync);
     GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
     void WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout);
     void GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
                           JS::MutableHandleValue retval);
 
--- a/dom/canvas/WebGL2ContextState.cpp
+++ b/dom/canvas/WebGL2ContextState.cpp
@@ -107,17 +107,17 @@ WebGL2Context::GetParameter(JSContext* c
       // value is 4 * GL_MAX_VARYING_VECTORS
       GLint val;
       gl->fGetIntegerv(LOCAL_GL_MAX_VARYING_VECTORS, &val);
       return JS::Int32Value(4*val);
     }
 
     /* GLint64 */
     case LOCAL_GL_MAX_CLIENT_WAIT_TIMEOUT_WEBGL:
-      return JS::NumberValue(0); // TODO
+      return JS::NumberValue(kMaxClientWaitSyncTimeoutNS);
 
     case LOCAL_GL_MAX_ELEMENT_INDEX:
       // GL_MAX_ELEMENT_INDEX becomes available in GL 4.3 or via ES3
       // compatibility
       if (!gl->IsSupported(gl::GLFeature::ES3_compatibility))
         return JS::NumberValue(UINT32_MAX);
 
       /*** fall through to fGetInteger64v ***/
--- a/dom/canvas/WebGL2ContextSync.cpp
+++ b/dom/canvas/WebGL2ContextSync.cpp
@@ -62,16 +62,22 @@ WebGL2Context::ClientWaitSync(const WebG
     if (!ValidateObject(funcName, sync))
         return LOCAL_GL_WAIT_FAILED;
 
     if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
         ErrorInvalidValue("%s: `flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.", funcName);
         return LOCAL_GL_WAIT_FAILED;
     }
 
+    if (timeout > kMaxClientWaitSyncTimeoutNS) {
+        ErrorInvalidOperation("%s: `timeout` must not exceed %s nanoseconds.", funcName,
+                              "MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
+        return LOCAL_GL_WAIT_FAILED;
+    }
+
     MakeContextCurrent();
     return gl->fClientWaitSync(sync.mGLName, flags, timeout);
 }
 
 void
 WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout)
 {
     const char funcName[] = "waitSync";