Bug 911856 - Remove the custom concept of "stable context" in favor of the standard concept of "lost context" - r=jgilbert

This commit is contained in:
Benoit Jacob 2013-09-04 08:14:44 -04:00
Родитель 7e265eab98
Коммит 2a253a692e
12 изменённых файлов: 159 добавлений и 158 удалений

Просмотреть файл

@ -184,7 +184,7 @@ WebGLContext::WebGLContext()
mContextLossTimerRunning = false;
mDrawSinceContextLossTimerSet = false;
mContextRestorer = do_CreateInstance("@mozilla.org/timer;1");
mContextStatus = ContextStable;
mContextStatus = ContextNotLost;
mContextLostErrorSet = false;
mLoseContextOnHeapMinimize = false;
mCanLoseContextInForeground = true;
@ -844,7 +844,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (!mResetLayer && aOldLayer &&
@ -899,7 +899,7 @@ void
WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializer> &retval)
{
retval.SetNull();
if (!IsContextStable())
if (IsContextLost())
return;
dom::WebGLContextAttributes& result = retval.SetValue();
@ -918,7 +918,7 @@ WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializ
NS_IMETHODIMP
WebGLContext::MozGetUnderlyingParamString(uint32_t pname, nsAString& retval)
{
if (!IsContextStable())
if (IsContextLost())
return NS_OK;
retval.SetIsVoid(true);
@ -1220,7 +1220,7 @@ WebGLContext::RobustnessTimerCallback(nsITimer* timer)
SetupContextLossTimer();
return;
}
mContextStatus = ContextStable;
mContextStatus = ContextNotLost;
nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
NS_LITERAL_STRING("webglcontextrestored"),
@ -1240,7 +1240,7 @@ void
WebGLContext::MaybeRestoreContext()
{
// Don't try to handle it if we already know it's busted.
if (mContextStatus != ContextStable || gl == nullptr)
if (mContextStatus != ContextNotLost || gl == nullptr)
return;
bool isEGL = gl->GetContextType() == GLContext::ContextTypeEGL,

Просмотреть файл

@ -297,18 +297,18 @@ public:
return mCanvasElement;
}
GLsizei DrawingBufferWidth() const {
if (!IsContextStable())
if (IsContextLost())
return 0;
return mWidth;
}
GLsizei DrawingBufferHeight() const {
if (!IsContextStable())
if (IsContextLost())
return 0;
return mHeight;
}
void GetContextAttributes(dom::Nullable<dom::WebGLContextAttributesInitializer>& retval);
bool IsContextLost() const { return !IsContextStable(); }
bool IsContextLost() const { return mContextStatus != ContextNotLost; }
void GetSupportedExtensions(JSContext *cx, dom::Nullable< nsTArray<nsString> > &retval);
JSObject* GetExtension(JSContext* cx, const nsAString& aName, ErrorResult& rv);
void ActiveTexture(GLenum texture);
@ -320,7 +320,7 @@ public:
void BindTexture(GLenum target, WebGLTexture *tex);
void BindVertexArray(WebGLVertexArray *vao);
void BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fBlendColor(r, g, b, a);
@ -371,13 +371,13 @@ public:
void DetachShader(WebGLProgram *program, WebGLShader *shader);
void DrawBuffers(const dom::Sequence<GLenum>& buffers);
void Flush() {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fFlush();
}
void Finish() {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fFinish();
@ -446,7 +446,7 @@ public:
bool IsTexture(WebGLTexture *tex);
bool IsVertexArray(WebGLVertexArray *vao);
void LineWidth(GLfloat width) {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fLineWidth(width);
@ -454,7 +454,7 @@ public:
void LinkProgram(WebGLProgram *program);
void PixelStorei(GLenum pname, GLint param);
void PolygonOffset(GLfloat factor, GLfloat units) {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fPolygonOffset(factor, units);
@ -466,7 +466,7 @@ public:
void RenderbufferStorage(GLenum target, GLenum internalformat,
GLsizei width, GLsizei height);
void SampleCoverage(GLclampf value, WebGLboolean invert) {
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
gl->fSampleCoverage(value, invert);
@ -497,7 +497,7 @@ public:
GLenum internalformat, GLenum format, GLenum type,
ElementType& elt, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
nsRefPtr<gfxImageSurface> isurf;
WebGLTexelFormat srcFormat;
@ -536,7 +536,7 @@ public:
GLint xoffset, GLint yoffset, GLenum format,
GLenum type, ElementType& elt, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
nsRefPtr<gfxImageSurface> isurf;
WebGLTexelFormat srcFormat;
@ -943,13 +943,14 @@ protected:
int32_t mGLMaxDrawBuffers;
uint32_t mGLMaxTransformFeedbackSeparateAttribs;
// Represents current status, or state, of the context. That is, is it lost
// or stable and what part of the context lost process are we currently at.
// Represents current status of the context with respect to context loss.
// That is, whether the context is lost, and what part of the context loss
// process we currently are at.
// This is used to support the WebGL spec's asyncronous nature in handling
// context loss.
enum ContextStatus {
// The context is stable; there either are none or we don't know of any.
ContextStable,
ContextNotLost,
// The context has been lost, but we have not yet sent an event to the
// script informing it of this.
ContextLostAwaitingEvent,
@ -1139,9 +1140,6 @@ protected:
const GLvoid *data);
void MaybeRestoreContext();
bool IsContextStable() const {
return mContextStatus == ContextStable;
}
void ForceLoseContext();
void ForceRestoreContext();

Просмотреть файл

@ -56,7 +56,7 @@ SimulateOcclusionQueryTarget(const gl::GLContext* gl, GLenum target)
already_AddRefed<WebGLQuery>
WebGLContext::CreateQuery()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (mActiveOcclusionQuery && !gl->IsGLES2()) {
@ -81,7 +81,7 @@ WebGLContext::CreateQuery()
void
WebGLContext::DeleteQuery(WebGLQuery *query)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!query)
@ -110,7 +110,7 @@ WebGLContext::DeleteQuery(WebGLQuery *query)
void
WebGLContext::BeginQuery(GLenum target, WebGLQuery *query)
{
if (!IsContextStable())
if (IsContextLost())
return;
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "beginQuery");
@ -180,7 +180,7 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery *query)
void
WebGLContext::EndQuery(GLenum target)
{
if (!IsContextStable())
if (IsContextLost())
return;
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "endQuery");
@ -222,7 +222,7 @@ WebGLContext::EndQuery(GLenum target)
bool
WebGLContext::IsQuery(WebGLQuery *query)
{
if (!IsContextStable())
if (IsContextLost())
return false;
if (!query)
@ -236,7 +236,7 @@ WebGLContext::IsQuery(WebGLQuery *query)
already_AddRefed<WebGLQuery>
WebGLContext::GetQuery(GLenum target, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "getQuery");
@ -259,7 +259,7 @@ WebGLContext::GetQuery(GLenum target, GLenum pname)
JS::Value
WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (!query) {

Просмотреть файл

@ -13,7 +13,7 @@ using namespace mozilla::dom;
void
WebGLContext::BindBuffer(GLenum target, WebGLBuffer *buffer)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindBuffer", buffer))
@ -48,7 +48,7 @@ WebGLContext::BindBuffer(GLenum target, WebGLBuffer *buffer)
void
WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindBufferBase", buffer))
@ -90,7 +90,7 @@ void
WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
WebGLintptr offset, WebGLsizeiptr size)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindBufferRange", buffer))
@ -137,7 +137,7 @@ void
WebGLContext::BufferData(GLenum target, WebGLsizeiptr size,
GLenum usage)
{
if (!IsContextStable())
if (IsContextLost())
return;
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferData");
@ -187,7 +187,7 @@ WebGLContext::BufferData(GLenum target,
const Nullable<ArrayBuffer> &maybeData,
GLenum usage)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (maybeData.IsNull()) {
@ -235,7 +235,7 @@ void
WebGLContext::BufferData(GLenum target, const ArrayBufferView& data,
GLenum usage)
{
if (!IsContextStable())
if (IsContextLost())
return;
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
@ -275,7 +275,7 @@ void
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
const Nullable<ArrayBuffer> &maybeData)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (maybeData.IsNull()) {
@ -318,7 +318,7 @@ void
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
const ArrayBufferView& data)
{
if (!IsContextStable())
if (IsContextLost())
return;
WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
@ -352,7 +352,7 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
already_AddRefed<WebGLBuffer>
WebGLContext::CreateBuffer()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLBuffer> globj = new WebGLBuffer(this);
@ -362,7 +362,7 @@ WebGLContext::CreateBuffer()
void
WebGLContext::DeleteBuffer(WebGLBuffer *buffer)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteBuffer", buffer))
@ -392,7 +392,7 @@ WebGLContext::DeleteBuffer(WebGLBuffer *buffer)
bool
WebGLContext::IsBuffer(WebGLBuffer *buffer)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isBuffer", buffer) &&

Просмотреть файл

@ -136,7 +136,7 @@ CompareWebGLExtensionName(const nsACString& name, const char *other)
JSObject*
WebGLContext::GetExtension(JSContext *cx, const nsAString& aName, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
NS_LossyConvertUTF16toASCII name(aName);
@ -257,7 +257,7 @@ void
WebGLContext::GetSupportedExtensions(JSContext *cx, Nullable< nsTArray<nsString> > &retval)
{
retval.SetNull();
if (!IsContextStable())
if (IsContextLost())
return;
nsTArray<nsString>& arr = retval.SetValue();

Просмотреть файл

@ -13,7 +13,7 @@ using namespace mozilla;
void
WebGLContext::Clear(GLbitfield mask)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -92,7 +92,7 @@ void
WebGLContext::ClearColor(GLclampf r, GLclampf g,
GLclampf b, GLclampf a)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -106,7 +106,7 @@ WebGLContext::ClearColor(GLclampf r, GLclampf g,
void
WebGLContext::ClearDepth(GLclampf v)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -117,7 +117,7 @@ WebGLContext::ClearDepth(GLclampf v)
void
WebGLContext::ClearStencil(GLint v)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -128,7 +128,7 @@ WebGLContext::ClearStencil(GLint v)
void
WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -142,7 +142,7 @@ WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboo
void
WebGLContext::DepthMask(WebGLboolean b)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -229,7 +229,7 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
void
WebGLContext::StencilMask(GLuint mask)
{
if (!IsContextStable())
if (IsContextLost())
return;
mStencilWriteMaskFront = mask;
@ -242,7 +242,7 @@ WebGLContext::StencilMask(GLuint mask)
void
WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateFaceEnum(face, "stencilMaskSeparate: face"))

Просмотреть файл

@ -63,7 +63,7 @@ inline const WebGLRectangleObject *WebGLContext::FramebufferRectangleObject() co
void
WebGLContext::ActiveTexture(GLenum texture)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (texture < LOCAL_GL_TEXTURE0 ||
@ -84,7 +84,7 @@ WebGLContext::ActiveTexture(GLenum texture)
void
WebGLContext::AttachShader(WebGLProgram *program, WebGLShader *shader)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("attachShader: program", program) ||
@ -106,7 +106,7 @@ void
WebGLContext::BindAttribLocation(WebGLProgram *prog, GLuint location,
const nsAString& name)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("bindAttribLocation: program", prog))
@ -131,7 +131,7 @@ WebGLContext::BindAttribLocation(WebGLProgram *prog, GLuint location,
void
WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (target != LOCAL_GL_FRAMEBUFFER)
@ -160,7 +160,7 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb)
void
WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer *wrb)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (target != LOCAL_GL_RENDERBUFFER)
@ -187,7 +187,7 @@ WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer *wrb)
void
WebGLContext::BindTexture(GLenum target, WebGLTexture *tex)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindTexture", tex))
@ -216,7 +216,7 @@ WebGLContext::BindTexture(GLenum target, WebGLTexture *tex)
void WebGLContext::BlendEquation(GLenum mode)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateBlendEquationEnum(mode, "blendEquation: mode"))
@ -228,7 +228,7 @@ void WebGLContext::BlendEquation(GLenum mode)
void WebGLContext::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateBlendEquationEnum(modeRGB, "blendEquationSeparate: modeRGB") ||
@ -241,7 +241,7 @@ void WebGLContext::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
void WebGLContext::BlendFunc(GLenum sfactor, GLenum dfactor)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateBlendFuncSrcEnum(sfactor, "blendFunc: sfactor") ||
@ -259,7 +259,7 @@ void
WebGLContext::BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateBlendFuncSrcEnum(srcRGB, "blendFuncSeparate: srcRGB") ||
@ -315,7 +315,7 @@ GLenum WebGLContext::CheckedBufferData(GLenum target,
GLenum
WebGLContext::CheckFramebufferStatus(GLenum target)
{
if (!IsContextStable())
if (IsContextLost())
{
return LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;
}
@ -472,7 +472,7 @@ WebGLContext::CopyTexImage2D(GLenum target,
GLsizei height,
GLint border)
{
if (!IsContextStable())
if (IsContextLost())
return;
switch (target) {
@ -581,7 +581,7 @@ WebGLContext::CopyTexSubImage2D(GLenum target,
GLsizei width,
GLsizei height)
{
if (!IsContextStable())
if (IsContextLost())
return;
switch (target) {
@ -654,7 +654,7 @@ WebGLContext::CopyTexSubImage2D(GLenum target,
already_AddRefed<WebGLProgram>
WebGLContext::CreateProgram()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLProgram> globj = new WebGLProgram(this);
return globj.forget();
@ -663,7 +663,7 @@ WebGLContext::CreateProgram()
already_AddRefed<WebGLShader>
WebGLContext::CreateShader(GLenum type)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (type != LOCAL_GL_VERTEX_SHADER &&
@ -680,7 +680,7 @@ WebGLContext::CreateShader(GLenum type)
void
WebGLContext::CullFace(GLenum face)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateFaceEnum(face, "cullFace"))
@ -693,7 +693,7 @@ WebGLContext::CullFace(GLenum face)
void
WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteFramebuffer", fbuf))
@ -712,7 +712,7 @@ WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
void
WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer *rbuf)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteRenderbuffer", rbuf))
@ -734,7 +734,7 @@ WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer *rbuf)
void
WebGLContext::DeleteTexture(WebGLTexture *tex)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteTexture", tex))
@ -763,7 +763,7 @@ WebGLContext::DeleteTexture(WebGLTexture *tex)
void
WebGLContext::DeleteProgram(WebGLProgram *prog)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteProgram", prog))
@ -778,7 +778,7 @@ WebGLContext::DeleteProgram(WebGLProgram *prog)
void
WebGLContext::DeleteShader(WebGLShader *shader)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteShader", shader))
@ -793,7 +793,7 @@ WebGLContext::DeleteShader(WebGLShader *shader)
void
WebGLContext::DetachShader(WebGLProgram *program, WebGLShader *shader)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("detachShader: program", program) ||
@ -809,7 +809,7 @@ WebGLContext::DetachShader(WebGLProgram *program, WebGLShader *shader)
void
WebGLContext::DepthFunc(GLenum func)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateComparisonEnum(func, "depthFunc"))
@ -822,7 +822,7 @@ WebGLContext::DepthFunc(GLenum func)
void
WebGLContext::DepthRange(GLfloat zNear, GLfloat zFar)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (zNear > zFar)
@ -1053,7 +1053,7 @@ WebGLContext::UnbindFakeBlackTextures()
void
WebGLContext::FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum rbtarget, WebGLRenderbuffer *wrb)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!mBoundFramebuffer)
@ -1069,7 +1069,7 @@ WebGLContext::FramebufferTexture2D(GLenum target,
WebGLTexture *tobj,
GLint level)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!mBoundFramebuffer)
@ -1081,7 +1081,7 @@ WebGLContext::FramebufferTexture2D(GLenum target,
void
WebGLContext::FrontFace(GLenum mode)
{
if (!IsContextStable())
if (IsContextLost())
return;
switch (mode) {
@ -1099,7 +1099,7 @@ WebGLContext::FrontFace(GLenum mode)
already_AddRefed<WebGLActiveInfo>
WebGLContext::GetActiveAttrib(WebGLProgram *prog, uint32_t index)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (!ValidateObject("getActiveAttrib: program", prog))
@ -1133,7 +1133,7 @@ WebGLContext::GetActiveAttrib(WebGLProgram *prog, uint32_t index)
void
WebGLContext::GenerateMipmap(GLenum target)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateTextureTargetEnum(target, "generateMipmap"))
@ -1184,7 +1184,7 @@ WebGLContext::GenerateMipmap(GLenum target)
already_AddRefed<WebGLActiveInfo>
WebGLContext::GetActiveUniform(WebGLProgram *prog, uint32_t index)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (!ValidateObject("getActiveUniform: program", prog))
@ -1237,7 +1237,7 @@ WebGLContext::GetAttachedShaders(WebGLProgram *prog,
Nullable< nsTArray<WebGLShader*> > &retval)
{
retval.SetNull();
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowNull("getAttachedShaders", prog))
@ -1258,7 +1258,7 @@ WebGLContext::GetAttachedShaders(WebGLProgram *prog,
GLint
WebGLContext::GetAttribLocation(WebGLProgram *prog, const nsAString& name)
{
if (!IsContextStable())
if (IsContextLost())
return -1;
if (!ValidateObject("getAttribLocation: program", prog))
@ -1280,7 +1280,7 @@ WebGLContext::GetAttribLocation(WebGLProgram *prog, const nsAString& name)
JS::Value
WebGLContext::GetBufferParameter(GLenum target, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (target != LOCAL_GL_ARRAY_BUFFER && target != LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
@ -1319,7 +1319,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
GLenum pname,
ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (target != LOCAL_GL_FRAMEBUFFER) {
@ -1409,7 +1409,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
JS::Value
WebGLContext::GetRenderbufferParameter(GLenum target, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (target != LOCAL_GL_RENDERBUFFER) {
@ -1452,7 +1452,7 @@ WebGLContext::GetRenderbufferParameter(GLenum target, GLenum pname)
already_AddRefed<WebGLTexture>
WebGLContext::CreateTexture()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLTexture> globj = new WebGLTexture(this);
return globj.forget();
@ -1461,7 +1461,7 @@ WebGLContext::CreateTexture()
GLenum
WebGLContext::GetError()
{
if (mContextStatus == ContextStable) {
if (mContextStatus == ContextNotLost) {
MakeContextCurrent();
UpdateWebGLErrorAndClearGLError();
} else if (!mContextLostErrorSet) {
@ -1477,7 +1477,7 @@ WebGLContext::GetError()
JS::Value
WebGLContext::GetProgramParameter(WebGLProgram *prog, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectAllowDeleted("getProgramParameter: program", prog))
@ -1539,7 +1539,7 @@ WebGLContext::GetProgramInfoLog(WebGLProgram *prog, nsAString& retval)
void
WebGLContext::GetProgramInfoLog(WebGLProgram *prog, nsACString& retval)
{
if (!IsContextStable())
if (IsContextLost())
{
retval.SetIsVoid(true);
return;
@ -1583,7 +1583,7 @@ void WebGLContext::TexParameter_base(GLenum target, GLenum pname,
{
MOZ_ASSERT(intParamPtr || floatParamPtr);
if (!IsContextStable())
if (IsContextLost())
return;
GLint intParam = intParamPtr ? *intParamPtr : GLint(*floatParamPtr);
@ -1686,7 +1686,7 @@ void WebGLContext::TexParameter_base(GLenum target, GLenum pname,
JS::Value
WebGLContext::GetTexParameter(GLenum target, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
MakeContextCurrent();
@ -1730,7 +1730,7 @@ JS::Value
WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (!ValidateObject("getUniform: program", prog))
@ -1862,7 +1862,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
already_AddRefed<WebGLUniformLocation>
WebGLContext::GetUniformLocation(WebGLProgram *prog, const nsAString& name)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
if (!ValidateObject("getUniformLocation: program", prog))
@ -1893,7 +1893,7 @@ WebGLContext::GetUniformLocation(WebGLProgram *prog, const nsAString& name)
void
WebGLContext::Hint(GLenum target, GLenum mode)
{
if (!IsContextStable())
if (IsContextLost())
return;
bool isValid = false;
@ -1917,7 +1917,7 @@ WebGLContext::Hint(GLenum target, GLenum mode)
bool
WebGLContext::IsFramebuffer(WebGLFramebuffer *fb)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isFramebuffer", fb) &&
@ -1928,7 +1928,7 @@ WebGLContext::IsFramebuffer(WebGLFramebuffer *fb)
bool
WebGLContext::IsProgram(WebGLProgram *prog)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isProgram", prog) && !prog->IsDeleted();
@ -1937,7 +1937,7 @@ WebGLContext::IsProgram(WebGLProgram *prog)
bool
WebGLContext::IsRenderbuffer(WebGLRenderbuffer *rb)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isRenderBuffer", rb) &&
@ -1948,7 +1948,7 @@ WebGLContext::IsRenderbuffer(WebGLRenderbuffer *rb)
bool
WebGLContext::IsShader(WebGLShader *shader)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isShader", shader) &&
@ -1958,7 +1958,7 @@ WebGLContext::IsShader(WebGLShader *shader)
bool
WebGLContext::IsTexture(WebGLTexture *tex)
{
if (!IsContextStable())
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isTexture", tex) &&
@ -1999,7 +1999,7 @@ bool WebGLContext::BindArrayAttribToLocation0(WebGLProgram *program)
void
WebGLContext::LinkProgram(WebGLProgram *program)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("linkProgram", program))
@ -2129,7 +2129,7 @@ WebGLContext::LinkProgram(WebGLProgram *program)
void
WebGLContext::PixelStorei(GLenum pname, GLint param)
{
if (!IsContextStable())
if (IsContextLost())
return;
switch (pname) {
@ -2170,7 +2170,7 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
GLenum type, const Nullable<ArrayBufferView> &pixels,
ErrorResult& rv)
{
if (!IsContextStable()) {
if (IsContextLost()) {
return;
}
@ -2393,7 +2393,7 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
void
WebGLContext::RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!mBoundRenderbuffer || !mBoundRenderbuffer->GLName())
@ -2470,7 +2470,7 @@ WebGLContext::RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei
void
WebGLContext::Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (width < 0 || height < 0)
@ -2483,7 +2483,7 @@ WebGLContext::Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
void
WebGLContext::StencilFunc(GLenum func, GLint ref, GLuint mask)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateComparisonEnum(func, "stencilFunc: func"))
@ -2501,7 +2501,7 @@ WebGLContext::StencilFunc(GLenum func, GLint ref, GLuint mask)
void
WebGLContext::StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateFaceEnum(face, "stencilFuncSeparate: face") ||
@ -2532,7 +2532,7 @@ WebGLContext::StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint ma
void
WebGLContext::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateStencilOpEnum(sfail, "stencilOp: sfail") ||
@ -2547,7 +2547,7 @@ WebGLContext::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
void
WebGLContext::StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateFaceEnum(face, "stencilOpSeparate: face") ||
@ -2936,7 +2936,7 @@ WebGLContext::UniformMatrix4fv_base(WebGLUniformLocation* location_object,
void
WebGLContext::UseProgram(WebGLProgram *prog)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowNull("useProgram", prog))
@ -2959,7 +2959,7 @@ WebGLContext::UseProgram(WebGLProgram *prog)
void
WebGLContext::ValidateProgram(WebGLProgram *prog)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("validateProgram", prog))
@ -2982,7 +2982,7 @@ WebGLContext::ValidateProgram(WebGLProgram *prog)
already_AddRefed<WebGLFramebuffer>
WebGLContext::CreateFramebuffer()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLFramebuffer> globj = new WebGLFramebuffer(this);
return globj.forget();
@ -2991,7 +2991,7 @@ WebGLContext::CreateFramebuffer()
already_AddRefed<WebGLRenderbuffer>
WebGLContext::CreateRenderbuffer()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLRenderbuffer> globj = new WebGLRenderbuffer(this);
return globj.forget();
@ -3000,7 +3000,7 @@ WebGLContext::CreateRenderbuffer()
void
WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (width < 0 || height < 0)
@ -3013,7 +3013,7 @@ WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
void
WebGLContext::CompileShader(WebGLShader *shader)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("compileShader", shader))
@ -3283,7 +3283,7 @@ WebGLContext::CompressedTexImage2D(GLenum target, GLint level, GLenum internalfo
GLsizei width, GLsizei height, GLint border,
const ArrayBufferView& view)
{
if (!IsContextStable()) {
if (IsContextLost()) {
return;
}
@ -3323,7 +3323,7 @@ WebGLContext::CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLsizei width, GLsizei height,
GLenum format, const ArrayBufferView& view)
{
if (!IsContextStable()) {
if (IsContextLost()) {
return;
}
@ -3421,7 +3421,7 @@ WebGLContext::CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
JS::Value
WebGLContext::GetShaderParameter(WebGLShader *shader, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (!ValidateObject("getShaderParameter: shader", shader))
@ -3470,7 +3470,7 @@ WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval)
void
WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsACString& retval)
{
if (!IsContextStable())
if (IsContextLost())
{
retval.SetIsVoid(true);
return;
@ -3507,7 +3507,7 @@ WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsACString& retval)
already_AddRefed<WebGLShaderPrecisionFormat>
WebGLContext::GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype)
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
switch (shadertype) {
@ -3555,7 +3555,7 @@ WebGLContext::GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype)
void
WebGLContext::GetShaderSource(WebGLShader *shader, nsAString& retval)
{
if (!IsContextStable())
if (IsContextLost())
{
retval.SetIsVoid(true);
return;
@ -3570,7 +3570,7 @@ WebGLContext::GetShaderSource(WebGLShader *shader, nsAString& retval)
void
WebGLContext::ShaderSource(WebGLShader *shader, const nsAString& source)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObject("shaderSource: shader", shader))
@ -3776,7 +3776,7 @@ WebGLContext::TexImage2D(GLenum target, GLint level,
GLsizei height, GLint border, GLenum format,
GLenum type, const Nullable<ArrayBufferView> &pixels, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type,
@ -3791,7 +3791,7 @@ WebGLContext::TexImage2D(GLenum target, GLint level,
GLenum internalformat, GLenum format,
GLenum type, ImageData* pixels, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!pixels) {
@ -3927,7 +3927,7 @@ WebGLContext::TexSubImage2D(GLenum target, GLint level,
const Nullable<ArrayBufferView> &pixels,
ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (pixels.IsNull())
@ -3946,7 +3946,7 @@ WebGLContext::TexSubImage2D(GLenum target, GLint level,
GLenum format, GLenum type, ImageData* pixels,
ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!pixels)
@ -3964,7 +3964,7 @@ WebGLContext::TexSubImage2D(GLenum target, GLint level,
bool
WebGLContext::LoseContext()
{
if (!IsContextStable())
if (IsContextLost())
return false;
ForceLoseContext();
@ -3975,7 +3975,7 @@ WebGLContext::LoseContext()
bool
WebGLContext::RestoreContext()
{
if (IsContextStable() || !mAllowRestore) {
if (!IsContextLost() || !mAllowRestore) {
return false;
}

Просмотреть файл

@ -19,7 +19,7 @@ using namespace dom;
void
WebGLContext::Disable(GLenum cap)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateCapabilityEnum(cap, "disable"))
@ -39,7 +39,7 @@ WebGLContext::Disable(GLenum cap)
void
WebGLContext::Enable(GLenum cap)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateCapabilityEnum(cap, "enable"))
@ -71,7 +71,7 @@ StringValue(JSContext* cx, const char* chars, ErrorResult& rv)
JS::Value
WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
MakeContextCurrent();
@ -486,7 +486,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
JS::Value
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
MakeContextCurrent();
@ -512,7 +512,7 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
bool
WebGLContext::IsEnabled(GLenum cap)
{
if (!IsContextStable())
if (IsContextLost())
return false;
if (!ValidateCapabilityEnum(cap, "isEnabled"))

Просмотреть файл

@ -654,7 +654,7 @@ WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocatio
bool
WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t cnt, uint32_t arrayLength)
{
if (!IsContextStable()) {
if (IsContextLost()) {
return false;
}
if (arrayLength < cnt) {
@ -668,7 +668,7 @@ bool
WebGLContext::ValidateUniformArraySetter(const char* name, uint32_t expectedElemSize, WebGLUniformLocation *location_object,
GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength)
{
if (!IsContextStable())
if (IsContextLost())
return false;
if (!ValidateUniformLocation(name, location_object))
return false;
@ -711,7 +711,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLU
WebGLboolean aTranspose)
{
uint32_t expectedElemSize = (dim)*(dim);
if (!IsContextStable())
if (IsContextLost())
return false;
if (!ValidateUniformLocation(name, location_object))
return false;
@ -756,7 +756,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLU
bool
WebGLContext::ValidateUniformSetter(const char* name, WebGLUniformLocation *location_object, GLint& location)
{
if (!IsContextStable())
if (IsContextLost())
return false;
if (!ValidateUniformLocation(name, location_object))
return false;

Просмотреть файл

@ -13,7 +13,7 @@ using namespace mozilla;
void
WebGLContext::BindVertexArray(WebGLVertexArray *array)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array))
@ -48,7 +48,7 @@ WebGLContext::BindVertexArray(WebGLVertexArray *array)
already_AddRefed<WebGLVertexArray>
WebGLContext::CreateVertexArray()
{
if (!IsContextStable())
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLVertexArray> globj = new WebGLVertexArray(this);
@ -64,7 +64,7 @@ WebGLContext::CreateVertexArray()
void
WebGLContext::DeleteVertexArray(WebGLVertexArray *array)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (array == nullptr)
@ -82,7 +82,7 @@ WebGLContext::DeleteVertexArray(WebGLVertexArray *array)
bool
WebGLContext::IsVertexArray(WebGLVertexArray *array)
{
if (!IsContextStable())
if (IsContextLost())
return false;
if (!array)

Просмотреть файл

@ -23,7 +23,7 @@ static const int MAX_DRAW_CALLS_SINCE_FLUSH = 100;
void
WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -43,7 +43,7 @@ WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
void
WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -63,7 +63,7 @@ WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
void
WebGLContext::VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -84,7 +84,7 @@ void
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1,
GLfloat x2, GLfloat x3)
{
if (!IsContextStable())
if (IsContextLost())
return;
MakeContextCurrent();
@ -185,7 +185,7 @@ WebGLContext::VertexAttrib4fv_base(GLuint idx, uint32_t arrayLength,
void
WebGLContext::EnableVertexAttribArray(GLuint index)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
@ -201,7 +201,7 @@ WebGLContext::EnableVertexAttribArray(GLuint index)
void
WebGLContext::DisableVertexAttribArray(GLuint index)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
@ -221,7 +221,7 @@ JS::Value
WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
ErrorResult& rv)
{
if (!IsContextStable())
if (IsContextLost())
return JS::NullValue();
if (!mBoundVertexArray->EnsureAttribIndex(index, "getVertexAttrib"))
@ -309,7 +309,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
WebGLsizeiptr
WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
{
if (!IsContextStable())
if (IsContextLost())
return 0;
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
@ -328,7 +328,7 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
WebGLboolean normalized, GLsizei stride,
WebGLintptr byteOffset)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (mBoundArrayBuffer == nullptr)
@ -405,7 +405,7 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
void
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
{
if (!IsContextStable())
if (IsContextLost())
return;
if ( !mBoundVertexArray->EnsureAttribIndex(index, "vertexAttribDivisor") ) {
@ -500,7 +500,7 @@ bool WebGLContext::DrawArrays_check(GLint first, GLsizei count, GLsizei primcoun
void
WebGLContext::DrawArrays(GLenum mode, GLint first, GLsizei count)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateDrawModeEnum(mode, "drawArrays: mode"))
@ -518,7 +518,7 @@ WebGLContext::DrawArrays(GLenum mode, GLint first, GLsizei count)
void
WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateDrawModeEnum(mode, "drawArraysInstanced: mode"))
@ -665,7 +665,7 @@ void
WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type,
WebGLintptr byteOffset)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateDrawModeEnum(mode, "drawElements: mode"))
@ -684,7 +684,7 @@ void
WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
WebGLintptr byteOffset, GLsizei primcount)
{
if (!IsContextStable())
if (IsContextLost())
return;
if (!ValidateDrawModeEnum(mode, "drawElementsInstanced: mode"))

Просмотреть файл

@ -6,8 +6,11 @@
#ifndef WEBGLTYPES_H_
#define WEBGLTYPES_H_
// Manual reflection of WebIDL typedefs that are different from the
// corresponding OpenGL typedefs.
// Most WebIDL typedefs are identical to their OpenGL counterparts.
#include "GLTypes.h"
// Manual reflection of WebIDL typedefs that are different from their
// OpenGL counterparts.
typedef int64_t WebGLsizeiptr;
typedef int64_t WebGLintptr;
typedef bool WebGLboolean;