r?jrmuizel - Use existing can-I-read-from-this helper.
draft
r?jrmuizel - Use existing can-I-read-from-this helper.
From de1398f53d90e508367de67e5f4e024a1e41134f Mon Sep 17 00:00:00 2001
---
dom/canvas/WebGLContextState.cpp | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
MozReview-Commit-ID: Lrfvga5VJqW
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -375,47 +375,37 @@ WebGLContext::GetParameter(JSContext* cx
case LOCAL_GL_BLEND_EQUATION_RGB:
case LOCAL_GL_BLEND_EQUATION_ALPHA:
case LOCAL_GL_GENERATE_MIPMAP_HINT: {
GLint i = 0;
gl->fGetIntegerv(pname, &i);
return JS::NumberValue(uint32_t(i));
}
case LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE: {
- if (mBoundReadFramebuffer) {
- nsCString fbStatusInfoIgnored;
- const auto status = mBoundReadFramebuffer->CheckFramebufferStatus(&fbStatusInfoIgnored);
- if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
- ErrorInvalidOperation("getParameter: Read framebuffer must be"
- " complete before querying"
- " IMPLEMENTATION_COLOR_READ_TYPE.");
- return JS::NullValue();
- }
- }
+ const webgl::FormatUsageInfo* usage;
+ uint32_t width, height;
+ GLenum mode;
+ if (!ValidateCurFBForRead(funcName, &usage, &width, &height, &mode))
+ return JS::NullValue();
GLint i = 0;
if (gl->IsSupported(gl::GLFeature::ES2_compatibility)) {
gl->fGetIntegerv(pname, &i);
} else {
i = LOCAL_GL_UNSIGNED_BYTE;
}
return JS::NumberValue(uint32_t(i));
}
case LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT: {
- if (mBoundReadFramebuffer) {
- nsCString fbStatusInfoIgnored;
- const auto status = mBoundReadFramebuffer->CheckFramebufferStatus(&fbStatusInfoIgnored);
- if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
- ErrorInvalidOperation("getParameter: Read framebuffer must be"
- " complete before querying"
- " IMPLEMENTATION_COLOR_READ_FORMAT.");
- return JS::NullValue();
- }
- }
+ const webgl::FormatUsageInfo* usage;
+ uint32_t width, height;
+ GLenum mode;
+ if (!ValidateCurFBForRead(funcName, &usage, &width, &height, &mode))
+ return JS::NullValue();
GLint i = 0;
if (gl->IsSupported(gl::GLFeature::ES2_compatibility)) {
gl->fGetIntegerv(pname, &i);
} else {
i = LOCAL_GL_RGBA;
}