зеркало из https://github.com/mozilla/gecko-dev.git
Bug 982464 - Disable extension functionality after a context lost happens. r=jgilbert
This commit is contained in:
Родитель
4125ef34c6
Коммит
610bb897ee
|
@ -287,6 +287,7 @@ WebGLContext::DestroyResourcesAndContext()
|
||||||
if (!IsExtensionEnabled(extension) || (extension == WEBGL_lose_context))
|
if (!IsExtensionEnabled(extension) || (extension == WEBGL_lose_context))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
mExtensions[extension]->MarkLost();
|
||||||
mExtensions[extension] = nullptr;
|
mExtensions[extension] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ using namespace mozilla;
|
||||||
|
|
||||||
WebGLExtensionBase::WebGLExtensionBase(WebGLContext* context)
|
WebGLExtensionBase::WebGLExtensionBase(WebGLContext* context)
|
||||||
: WebGLContextBoundObject(context)
|
: WebGLContextBoundObject(context)
|
||||||
|
, mIsLost(false)
|
||||||
{
|
{
|
||||||
SetIsDOMBinding();
|
SetIsDOMBinding();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +19,12 @@ WebGLExtensionBase::~WebGLExtensionBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WebGLExtensionBase::MarkLost()
|
||||||
|
{
|
||||||
|
mIsLost = true;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLExtensionBase)
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLExtensionBase)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLExtensionBase, AddRef)
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLExtensionBase, AddRef)
|
||||||
|
|
|
@ -26,6 +26,11 @@ void
|
||||||
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
|
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
|
||||||
nsAString& retval)
|
nsAString& retval)
|
||||||
{
|
{
|
||||||
|
if (mIsLost) {
|
||||||
|
return mContext->ErrorInvalidOperation("getTranslatedShaderSource: "
|
||||||
|
"Extension is lost.");
|
||||||
|
}
|
||||||
|
|
||||||
mContext->GetShaderTranslatedSource(shader, retval);
|
mContext->GetShaderTranslatedSource(shader, retval);
|
||||||
|
|
||||||
if (retval.IsVoid()) {
|
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
|
/* 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,
|
* 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/. */
|
* 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)
|
void WebGLExtensionDrawBuffers::DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("drawBuffersWEBGL: Extension is lost.");
|
||||||
|
|
||||||
mContext->DrawBuffers(buffers);
|
mContext->DrawBuffers(buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ void
|
||||||
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode, GLint first,
|
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode, GLint first,
|
||||||
GLsizei count, GLsizei primcount)
|
GLsizei count, GLsizei primcount)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("drawArraysInstancedANGLE: Extension is lost.");
|
||||||
|
|
||||||
mContext->DrawArraysInstanced(mode, first, count, primcount);
|
mContext->DrawArraysInstanced(mode, first, count, primcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +36,18 @@ WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode, GLsizei c
|
||||||
GLenum type, WebGLintptr offset,
|
GLenum type, WebGLintptr offset,
|
||||||
GLsizei primcount)
|
GLsizei primcount)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("drawElementsInstancedANGLE: Extension is lost.");
|
||||||
|
|
||||||
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
|
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
|
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("vertexAttribDivisorANGLE: Extension is lost.");
|
||||||
|
|
||||||
mContext->VertexAttribDivisor(index, divisor);
|
mContext->VertexAttribDivisor(index, divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,37 @@ WebGLExtensionVertexArray::~WebGLExtensionVertexArray()
|
||||||
|
|
||||||
already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES()
|
already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES()
|
||||||
{
|
{
|
||||||
|
if (mIsLost) {
|
||||||
|
mContext->ErrorInvalidOperation("createVertexArrayOES: Extension is lost. Returning NULL.");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return mContext->CreateVertexArray();
|
return mContext->CreateVertexArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
|
void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("deleteVertexArrayOES: Extension is lost.");
|
||||||
|
|
||||||
mContext->DeleteVertexArray(array);
|
mContext->DeleteVertexArray(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
|
bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
|
||||||
{
|
{
|
||||||
|
if (mIsLost) {
|
||||||
|
mContext->ErrorInvalidOperation("isVertexArrayOES: Extension is lost. Returning false.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return mContext->IsVertexArray(array);
|
return mContext->IsVertexArray(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
|
void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
|
||||||
{
|
{
|
||||||
|
if (mIsLost)
|
||||||
|
return mContext->ErrorInvalidOperation("bindVertexArrayOES: Extension is lost.");
|
||||||
|
|
||||||
mContext->BindVertexArray(array);
|
mContext->BindVertexArray(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,13 @@ public:
|
||||||
return Context();
|
return Context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkLost();
|
||||||
|
|
||||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase)
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase)
|
||||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool mIsLost;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DECL_WEBGL_EXTENSION_GOOP \
|
#define DECL_WEBGL_EXTENSION_GOOP \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче