b=569236; better WebGL messages; r=vladimir

This commit is contained in:
Benoit Jacob 2010-06-14 14:44:12 -04:00
Родитель 873505206a
Коммит 4fa51050ec
4 изменённых файлов: 49 добавлений и 48 удалений

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

@ -168,61 +168,23 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
}
LogMessage("Canvas 3D: creating PBuffer...");
GLContextProvider::ContextFormat format(GLContextProvider::ContextFormat::BasicRGBA32);
format.depth = 16;
format.minDepth = 1;
gl = gl::sGLContextProvider.CreatePBuffer(gfxIntSize(width, height), format);
if (!gl) {
LogMessage("Canvas 3D: can't get a native PBuffer, trying OSMesa...");
if (!InitAndValidateGL()) {
gl = gl::GLContextProviderOSMesa::CreatePBuffer(gfxIntSize(width, height), format);
if (!gl) {
LogMessage("Canvas 3D: can't create a OSMesa pseudo-PBuffer.");
if (!InitAndValidateGL()) {
LogMessage("WebGL: Can't get a usable OpenGL context.");
return NS_ERROR_FAILURE;
}
else {
LogMessage("WebGL: Using software rendering via OSMesa");
}
}
// We just blew away all the resources by creating a new context; reset everything,
// and let ValidateGL set up the correct dimensions again.
mActiveTexture = 0;
mSynthesizedGLError = LOCAL_GL_NO_ERROR;
mAttribBuffers.Clear();
mUniformTextures.Clear();
mBound2DTextures.Clear();
mBoundCubeMapTextures.Clear();
mBoundArrayBuffer = nsnull;
mBoundElementArrayBuffer = nsnull;
mCurrentProgram = nsnull;
mFramebufferColorAttachments.Clear();
mFramebufferDepthAttachment = nsnull;
mFramebufferStencilAttachment = nsnull;
mBoundFramebuffer = nsnull;
mBoundRenderbuffer = nsnull;
mMapTextures.Clear();
mMapBuffers.Clear();
mMapPrograms.Clear();
mMapShaders.Clear();
mMapFramebuffers.Clear();
mMapRenderbuffers.Clear();
// Now check the GL implementation, checking limits along the way
if (!ValidateGL()) {
LogMessage("Canvas 3D: Couldn't validate OpenGL implementation; is everything needed present?");
return NS_ERROR_FAILURE;
}
LogMessage("Canvas 3D: ready");
mWidth = width;
mHeight = height;

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

@ -304,7 +304,7 @@ protected:
WebGLenum mSynthesizedGLError;
PRBool SafeToCreateCanvas3DContext(nsHTMLCanvasElement *canvasElement);
PRBool ValidateGL();
PRBool InitAndValidateGL();
PRBool ValidateBuffers(PRUint32 count);
static PRBool ValidateCapabilityEnum(WebGLenum cap);

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

@ -144,8 +144,37 @@ PRBool WebGLContext::ValidateCapabilityEnum(WebGLenum cap)
}
PRBool
WebGLContext::ValidateGL()
WebGLContext::InitAndValidateGL()
{
if (!gl) return PR_FALSE;
mActiveTexture = 0;
mSynthesizedGLError = LOCAL_GL_NO_ERROR;
mAttribBuffers.Clear();
mUniformTextures.Clear();
mBound2DTextures.Clear();
mBoundCubeMapTextures.Clear();
mBoundArrayBuffer = nsnull;
mBoundElementArrayBuffer = nsnull;
mCurrentProgram = nsnull;
mFramebufferColorAttachments.Clear();
mFramebufferDepthAttachment = nsnull;
mFramebufferStencilAttachment = nsnull;
mBoundFramebuffer = nsnull;
mBoundRenderbuffer = nsnull;
mMapTextures.Clear();
mMapBuffers.Clear();
mMapPrograms.Clear();
mMapShaders.Clear();
mMapFramebuffers.Clear();
mMapRenderbuffers.Clear();
// make sure that the opengl stuff that we need is supported
GLint val = 0;

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

@ -42,6 +42,7 @@
#include "nsIWidget.h"
#include "nsDirectoryServiceUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIConsoleService.h"
#include "nsIPrefService.h"
#include "gfxASurface.h"
#include "gfxImageSurface.h"
@ -58,6 +59,15 @@
namespace mozilla {
namespace gl {
static void LogMessage(const char *msg)
{
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(msg)).get());
fprintf(stderr, "%s\n", msg);
}
}
typedef void* PrivateOSMesaContext;
class OSMesaLibrary
@ -116,7 +126,7 @@ OSMesaLibrary::EnsureInitialized()
mOSMesaLibrary = PR_LoadLibrary(osmesalib.get());
if (!mOSMesaLibrary) {
NS_WARNING("Canvas 3D: Couldn't open OSMesa lib -- webgl.osmesalib path is incorrect, or not a valid shared library");
LogMessage("Couldn't open OSMesa lib for software rendering -- webgl.osmesalib path is incorrect, or not a valid shared library");
return PR_FALSE;
}
@ -132,7 +142,7 @@ OSMesaLibrary::EnsureInitialized()
};
if (!LibrarySymbolLoader::LoadSymbols(mOSMesaLibrary, &symbols[0])) {
NS_WARNING("Couldn't find required entry points in OSMesa libary");
LogMessage("Couldn't find required entry points in OSMesa libary");
return PR_FALSE;
}