Bug 1320030 - Handle program and shader object deletion differently. - r=ethlin
MozReview-Commit-ID: 4wSZ81lFP6e
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1641,31 +1641,57 @@ public:
" generation of this one) passed as argument.",
funcName);
return false;
}
return true;
}
- bool ValidateObject(const char* funcName, const WebGLDeletableObject& object) {
+ bool ValidateObject(const char* funcName, const WebGLDeletableObject& object,
+ bool isShaderOrProgram = false)
+ {
if (!ValidateObjectAllowDeleted(funcName, object))
return false;
- if (object.IsDeleteRequested()) {
- ErrorInvalidOperation("%s: Object argument cannot be marked for deletion.",
+ if (isShaderOrProgram) {
+ /* GLES 3.0.5 p45:
+ * "Commands that accept shader or program object names will generate the
+ * error INVALID_VALUE if the provided name is not the name of either a
+ * shader or program object[.]"
+ * Further, shaders and programs appear to be different from other objects,
+ * in that their lifetimes are better defined. However, they also appear to
+ * allow use of objects marked for deletion, and only reject
+ * actually-destroyed objects.
+ */
+ if (object.IsDeleted()) {
+ ErrorInvalidValue("%s: Shader or program object argument cannot have been"
+ " deleted.",
funcName);
- return false;
+ return false;
+ }
+ } else {
+ if (object.IsDeleteRequested()) {
+ ErrorInvalidOperation("%s: Object argument cannot have been marked for"
+ " deletion.",
+ funcName);
+ return false;
+ }
}
return true;
}
////
+ bool ValidateObject(const char* funcName, const WebGLProgram& object);
+ bool ValidateObject(const char* funcName, const WebGLShader& object);
+
+ ////
+
bool ValidateIsObject(const char* funcName,
const WebGLDeletableObject* object) const
{
if (IsContextLost())
return false;
if (!object)
return false;
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -52,16 +52,28 @@
#include "mozilla/dom/ImageData.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/EndianUtils.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h"
namespace mozilla {
+inline bool
+WebGLContext::ValidateObject(const char* funcName, const WebGLProgram& object)
+{
+ return ValidateObject(funcName, object, true);
+}
+
+inline bool
+WebGLContext::ValidateObject(const char* funcName, const WebGLShader& object)
+{
+ return ValidateObject(funcName, object, true);
+}
+
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::gl;
//
// WebGL API
//