Bug 1170842 - Part 3: Implement GetInternalformatParameter. r=jgilbert, r=smaug

This commit is contained in:
Dan Glastonbury 2015-07-03 11:54:07 +10:00
parent 18084ad811
commit 5b4913acf0
5 changed files with 79 additions and 19 deletions

View File

@ -55,13 +55,20 @@ public:
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
void GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat, GLenum pname, JS::MutableHandleValue retval);
void FramebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture* texture, GLint level, GLint layer);
void InvalidateFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
ErrorResult& rv);
void InvalidateSubFramebuffer (GLenum target, const dom::Sequence<GLenum>& attachments, GLint x, GLint y,
GLsizei width, GLsizei height, ErrorResult& rv);
void ReadBuffer(GLenum mode);
// -------------------------------------------------------------------------
// Renderbuffer objects - WebGL2ContextRenderbuffers.cpp
void GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat,
GLenum pname, JS::MutableHandleValue retval,
ErrorResult& rv);
void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat,
GLsizei width, GLsizei height);

View File

@ -336,12 +336,6 @@ WebGL2Context::FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint
GenerateWarning("framebufferTextureLayer: Not Implemented.");
}
void
WebGL2Context::GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat, GLenum pname, JS::MutableHandleValue retval)
{
GenerateWarning("getInternalformatParameter: Not Implemented.");
}
// Map attachments intended for the default buffer, to attachments for a non-
// default buffer.
static bool
@ -536,13 +530,4 @@ WebGL2Context::ReadBuffer(GLenum mode)
gl->Screen()->SetReadBuffer(mode);
}
void
WebGL2Context::RenderbufferStorageMultisample(GLenum target, GLsizei samples,
GLenum internalFormat,
GLsizei width, GLsizei height)
{
RenderbufferStorage_base("renderbufferStorageMultisample", target, samples,
internalFormat, width, height);
}
} // namespace mozilla

View File

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
#include "WebGLContextUtils.h"
namespace mozilla {
void
WebGL2Context::GetInternalformatParameter(JSContext* cx, GLenum target,
GLenum internalformat, GLenum pname,
JS::MutableHandleValue retval,
ErrorResult& rv)
{
if (IsContextLost())
return;
if (target != LOCAL_GL_RENDERBUFFER) {
return ErrorInvalidEnumInfo("getInternalfomratParameter: target must be "
"RENDERBUFFER. Was:", target);
}
// GL_INVALID_ENUM is generated if internalformat is not color-,
// depth-, or stencil-renderable.
// TODO: When format table queries lands.
if (pname != LOCAL_GL_SAMPLES) {
return ErrorInvalidEnumInfo("getInternalformatParameter: pname must be SAMPLES. "
"Was:", pname);
}
GLint* samples = nullptr;
GLint sampleCount = 0;
gl->fGetInternalformativ(LOCAL_GL_RENDERBUFFER, internalformat,
LOCAL_GL_NUM_SAMPLE_COUNTS, 1, &sampleCount);
if (sampleCount > 0) {
samples = new GLint[sampleCount];
gl->fGetInternalformativ(LOCAL_GL_RENDERBUFFER, internalformat, LOCAL_GL_SAMPLES,
sampleCount, samples);
}
JSObject* obj = dom::Int32Array::Create(cx, this, sampleCount, samples);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
delete[] samples;
retval.setObjectOrNull(obj);
}
void
WebGL2Context::RenderbufferStorageMultisample(GLenum target, GLsizei samples,
GLenum internalFormat,
GLsizei width, GLsizei height)
{
RenderbufferStorage_base("renderbufferStorageMultisample", target, samples,
internalFormat, width, height);
}
} // namespace mozilla

View File

@ -60,6 +60,7 @@ UNIFIED_SOURCES += [
'WebGL2ContextMRTs.cpp',
'WebGL2ContextPrograms.cpp',
'WebGL2ContextQueries.cpp',
'WebGL2ContextRenderbuffers.cpp',
'WebGL2ContextSamplers.cpp',
'WebGL2ContextState.cpp',
'WebGL2ContextSync.cpp',

View File

@ -323,8 +323,7 @@ interface WebGL2RenderingContext : WebGLRenderingContext
/* Framebuffer objects */
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
void framebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
any getInternalformatParameter(GLenum target, GLenum internalformat, GLenum pname);
void framebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture? texture, GLint level, GLint layer);
[Throws]
void invalidateFramebuffer(GLenum target, sequence<GLenum> attachments);
@ -336,6 +335,8 @@ interface WebGL2RenderingContext : WebGLRenderingContext
void readBuffer(GLenum src);
/* Renderbuffer objects */
[Throws]
any getInternalformatParameter(GLenum target, GLenum internalformat, GLenum pname);
void renderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
/* Texture objects */