Bug 982464 - Disable extension functionality after a context lost happens. r=jgilbert

This commit is contained in:
Dan Glastonbury 2014-03-12 12:51:39 +10:00
Родитель 4125ef34c6
Коммит 610bb897ee
7 изменённых файлов: 47 добавлений и 0 удалений

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

@ -287,6 +287,7 @@ WebGLContext::DestroyResourcesAndContext()
if (!IsExtensionEnabled(extension) || (extension == WEBGL_lose_context))
continue;
mExtensions[extension]->MarkLost();
mExtensions[extension] = nullptr;
}

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

@ -10,6 +10,7 @@ using namespace mozilla;
WebGLExtensionBase::WebGLExtensionBase(WebGLContext* context)
: WebGLContextBoundObject(context)
, mIsLost(false)
{
SetIsDOMBinding();
}
@ -18,6 +19,12 @@ WebGLExtensionBase::~WebGLExtensionBase()
{
}
void
WebGLExtensionBase::MarkLost()
{
mIsLost = true;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLExtensionBase)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLExtensionBase, AddRef)

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

@ -26,6 +26,11 @@ void
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
nsAString& retval)
{
if (mIsLost) {
return mContext->ErrorInvalidOperation("getTranslatedShaderSource: "
"Extension is lost.");
}
mContext->GetShaderTranslatedSource(shader, retval);
if (retval.IsVoid()) {

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
@ -49,6 +50,9 @@ WebGLExtensionDrawBuffers::~WebGLExtensionDrawBuffers()
void WebGLExtensionDrawBuffers::DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("drawBuffersWEBGL: Extension is lost.");
mContext->DrawBuffers(buffers);
}

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

@ -25,6 +25,9 @@ void
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode, GLint first,
GLsizei count, GLsizei primcount)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("drawArraysInstancedANGLE: Extension is lost.");
mContext->DrawArraysInstanced(mode, first, count, primcount);
}
@ -33,12 +36,18 @@ WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode, GLsizei c
GLenum type, WebGLintptr offset,
GLsizei primcount)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("drawElementsInstancedANGLE: Extension is lost.");
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
}
void
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("vertexAttribDivisorANGLE: Extension is lost.");
mContext->VertexAttribDivisor(index, divisor);
}

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

@ -25,21 +25,37 @@ WebGLExtensionVertexArray::~WebGLExtensionVertexArray()
already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES()
{
if (mIsLost) {
mContext->ErrorInvalidOperation("createVertexArrayOES: Extension is lost. Returning NULL.");
return nullptr;
}
return mContext->CreateVertexArray();
}
void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("deleteVertexArrayOES: Extension is lost.");
mContext->DeleteVertexArray(array);
}
bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
{
if (mIsLost) {
mContext->ErrorInvalidOperation("isVertexArrayOES: Extension is lost. Returning false.");
return false;
}
return mContext->IsVertexArray(array);
}
void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
{
if (mIsLost)
return mContext->ErrorInvalidOperation("bindVertexArrayOES: Extension is lost.");
mContext->BindVertexArray(array);
}

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

@ -30,8 +30,13 @@ public:
return Context();
}
void MarkLost();
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
protected:
bool mIsLost;
};
#define DECL_WEBGL_EXTENSION_GOOP \