Bug 1325483 - Query DRAW_BUFFER0 from GLScreenBuffer. - r=daoshengmu
MozReview-Commit-ID: KjhbQM9B8EZ
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -237,27 +237,25 @@ WebGLContext::GetParameter(JSContext* cx
return JS::Int32Value(mImplMaxColorAttachments);
} else if (pname == LOCAL_GL_MAX_DRAW_BUFFERS) {
return JS::Int32Value(mImplMaxDrawBuffers);
} else if (pname >= LOCAL_GL_DRAW_BUFFER0 &&
pname < GLenum(LOCAL_GL_DRAW_BUFFER0 + mImplMaxDrawBuffers))
{
- GLint iv = 0;
- gl->fGetIntegerv(pname, &iv);
-
- if (mBoundDrawFramebuffer)
- return JS::Int32Value(iv);
-
- const GLint index = (pname - LOCAL_GL_DRAW_BUFFER0);
- if (iv == LOCAL_GL_COLOR_ATTACHMENT0 + index)
- return JS::Int32Value(LOCAL_GL_BACK);
-
- return JS::Int32Value(LOCAL_GL_NONE);
+ GLint ret = LOCAL_GL_NONE;
+ if (!mBoundDrawFramebuffer) {
+ if (pname == LOCAL_GL_DRAW_BUFFER0) {
+ ret = gl->Screen()->GetDrawBufferMode();
+ }
+ } else {
+ gl->fGetIntegerv(pname, &ret);
+ }
+ return JS::Int32Value(ret);
}
}
if (IsWebGL2() || IsExtensionEnabled(WebGLExtensionID::OES_vertex_array_object)) {
if (pname == LOCAL_GL_VERTEX_ARRAY_BINDING) {
WebGLVertexArray* vao =
(mBoundVertexArray != mDefaultVertexArray) ? mBoundVertexArray.get() : nullptr;
return WebGLObjectAsJSValue(cx, vao, rv);
--- a/gfx/gl/GLScreenBuffer.h
+++ b/gfx/gl/GLScreenBuffer.h
@@ -236,19 +236,18 @@ public:
void BeforeReadCall();
bool CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
GLint y, GLsizei width, GLsizei height, GLint border);
void SetReadBuffer(GLenum userMode);
void SetDrawBuffer(GLenum userMode);
- GLenum GetReadBufferMode() const {
- return mUserReadBufferMode;
- }
+ GLenum GetReadBufferMode() const { return mUserReadBufferMode; }
+ GLenum GetDrawBufferMode() const { return mUserDrawBufferMode; }
/**
* Attempts to read pixels from the current bound framebuffer, if
* it is backed by a SharedSurface.
*
* Returns true if the pixel data has been read back, false
* otherwise.
*/