mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
b=593720; make webgl less verbose; r=bjacob
This commit is contained in:
parent
166801f966
commit
1e3c0e1230
@ -86,6 +86,7 @@ WebGLContext::WebGLContext()
|
||||
mGeneration = 0;
|
||||
mInvalidated = PR_FALSE;
|
||||
mResetLayer = PR_TRUE;
|
||||
mVerbose = PR_FALSE;
|
||||
|
||||
mActiveTexture = 0;
|
||||
mSynthesizedGLError = LOCAL_GL_NO_ERROR;
|
||||
@ -216,7 +217,9 @@ WebGLContext::DestroyResourcesAndContext()
|
||||
|
||||
// We just got rid of everything, so the context had better
|
||||
// have been going away.
|
||||
#ifdef DEBUG
|
||||
printf_stderr("--- WebGL context destroyed: %p\n", gl.get());
|
||||
#endif
|
||||
|
||||
gl = nsnull;
|
||||
}
|
||||
@ -302,7 +305,11 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
||||
nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE);
|
||||
|
||||
PRBool forceOSMesa;
|
||||
PRBool verbose = PR_FALSE;
|
||||
prefService->GetBoolPref("webgl.verbose", &verbose);
|
||||
mVerbose = verbose;
|
||||
|
||||
PRBool forceOSMesa = PR_FALSE;
|
||||
prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
|
||||
|
||||
if (!forceOSMesa) {
|
||||
@ -376,7 +383,9 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf_stderr ("--- WebGL context created: %p\n", gl.get());
|
||||
#endif
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
@ -352,6 +352,7 @@ protected:
|
||||
|
||||
PRPackedBool mInvalidated;
|
||||
PRPackedBool mResetLayer;
|
||||
PRPackedBool mVerbose;
|
||||
|
||||
WebGLuint mActiveTexture;
|
||||
WebGLenum mSynthesizedGLError;
|
||||
@ -484,8 +485,11 @@ protected:
|
||||
|
||||
public:
|
||||
// console logging helpers
|
||||
static void LogMessage (const char *fmt, ...);
|
||||
static void LogMessage(const char *fmt, ...);
|
||||
static void LogMessage(const char *fmt, va_list ap);
|
||||
// if display is false, this won't actually do anything
|
||||
static void LogMessage(bool display, const char *fmt, ...);
|
||||
void LogMessageIfVerbose(const char *fmt, ...);
|
||||
|
||||
friend class WebGLTexture;
|
||||
};
|
||||
@ -979,25 +983,29 @@ public:
|
||||
if (DoesMinFilterRequireMipmap())
|
||||
{
|
||||
if (!IsMipmapTexture2DComplete()) {
|
||||
mContext->LogMessage("%s is a 2D texture, with a minification filter requiring a mipmap, "
|
||||
"and is not mipmap complete (as defined in section 3.7.10).", msg_rendering_as_black);
|
||||
mContext->LogMessageIfVerbose
|
||||
("%s is a 2D texture, with a minification filter requiring a mipmap, "
|
||||
"and is not mipmap complete (as defined in section 3.7.10).", msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
} else if (!ImageInfoAt(0, 0).IsPowerOfTwo()) {
|
||||
mContext->LogMessage("%s is a 2D texture, with a minification filter requiring a mipmap, "
|
||||
"and either its width or height is not a power of two.", msg_rendering_as_black);
|
||||
mContext->LogMessageIfVerbose
|
||||
("%s is a 2D texture, with a minification filter requiring a mipmap, "
|
||||
"and either its width or height is not a power of two.", msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
}
|
||||
}
|
||||
else // no mipmap required
|
||||
{
|
||||
if (!ImageInfoAt(0, 0).IsPositive()) {
|
||||
mContext->LogMessage("%s is a 2D texture and its width or height is equal to zero.",
|
||||
msg_rendering_as_black);
|
||||
mContext->LogMessageIfVerbose
|
||||
("%s is a 2D texture and its width or height is equal to zero.",
|
||||
msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
} else if (!AreBothWrapModesClampToEdge() && !ImageInfoAt(0, 0).IsPowerOfTwo()) {
|
||||
mContext->LogMessage("%s is a 2D texture, with a minification filter not requiring a mipmap, "
|
||||
"with its width or height not a power of two, and with a wrap mode "
|
||||
"different from CLAMP_TO_EDGE.", msg_rendering_as_black);
|
||||
mContext->LogMessageIfVerbose
|
||||
("%s is a 2D texture, with a minification filter not requiring a mipmap, "
|
||||
"with its width or height not a power of two, and with a wrap mode "
|
||||
"different from CLAMP_TO_EDGE.", msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
}
|
||||
}
|
||||
@ -1011,12 +1019,12 @@ public:
|
||||
if (DoesMinFilterRequireMipmap())
|
||||
{
|
||||
if (!IsMipmapCubeComplete()) {
|
||||
mContext->LogMessage("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
||||
mContext->LogMessageIfVerbose("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
||||
"and is not mipmap cube complete (as defined in section 3.7.10).",
|
||||
msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
} else if (!areAllLevel0ImagesPOT) {
|
||||
mContext->LogMessage("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
||||
mContext->LogMessageIfVerbose("%s is a cube map texture, with a minification filter requiring a mipmap, "
|
||||
"and either the width or the height of some level 0 image is not a power of two.",
|
||||
msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
@ -1025,12 +1033,12 @@ public:
|
||||
else // no mipmap required
|
||||
{
|
||||
if (!IsCubeComplete()) {
|
||||
mContext->LogMessage("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
||||
mContext->LogMessageIfVerbose("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
||||
"and is not cube complete (as defined in section 3.7.10).",
|
||||
msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
} else if (!AreBothWrapModesClampToEdge() && !areAllLevel0ImagesPOT) {
|
||||
mContext->LogMessage("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
||||
mContext->LogMessageIfVerbose("%s is a cube map texture, with a minification filter not requiring a mipmap, "
|
||||
"with some level 0 image having width or height not a power of two, and with a wrap mode "
|
||||
"different from CLAMP_TO_EDGE.", msg_rendering_as_black);
|
||||
mFakeBlackStatus = DoNeedFakeBlack;
|
||||
|
@ -2467,7 +2467,7 @@ WebGLContext::ReadPixels_base(WebGLint x, WebGLint y, WebGLsizei width, WebGLsiz
|
||||
WebGLenum format, WebGLenum type, void *data, PRUint32 byteLength)
|
||||
{
|
||||
if (HTMLCanvasElement()->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
|
||||
LogMessage("ReadPixels: Not allowed");
|
||||
LogMessage(mVerbose, "ReadPixels: Not allowed");
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
|
@ -202,25 +202,53 @@ WebGLContext::SafeToCreateCanvas3DContext(nsHTMLCanvasElement *canvasElement)
|
||||
void
|
||||
WebGLContext::LogMessage(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
LogMessage(fmt, ap);
|
||||
LogMessage(fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::LogMessage(const char *fmt, va_list ap)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024];
|
||||
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (console) {
|
||||
PR_vsnprintf(buf, 1024, fmt, ap);
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(buf)).get());
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (console) {
|
||||
PR_vsnprintf(buf, 1024, fmt, ap);
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(buf)).get());
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::LogMessage(bool display, const char *fmt, ...)
|
||||
{
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
LogMessage(fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::LogMessageIfVerbose(const char *fmt, ...)
|
||||
{
|
||||
if (!mVerbose)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
LogMessage(fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -249,7 +277,7 @@ WebGLContext::SynthesizeGLError(WebGLenum err, const char *fmt, ...)
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (fmt)
|
||||
LogMessage(fmt, va);
|
||||
LogMessage(mVerbose, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return SynthesizeGLError(err);
|
||||
@ -261,7 +289,7 @@ WebGLContext::ErrorInvalidEnum(const char *fmt, ...)
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (fmt)
|
||||
LogMessage(fmt, va);
|
||||
LogMessage(mVerbose, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return SynthesizeGLError(LOCAL_GL_INVALID_ENUM);
|
||||
@ -273,7 +301,7 @@ WebGLContext::ErrorInvalidOperation(const char *fmt, ...)
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (fmt)
|
||||
LogMessage(fmt, va);
|
||||
LogMessage(mVerbose, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return SynthesizeGLError(LOCAL_GL_INVALID_OPERATION);
|
||||
@ -285,7 +313,7 @@ WebGLContext::ErrorInvalidValue(const char *fmt, ...)
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (fmt)
|
||||
LogMessage(fmt, va);
|
||||
LogMessage(mVerbose, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return SynthesizeGLError(LOCAL_GL_INVALID_VALUE);
|
||||
|
@ -111,7 +111,7 @@ WebGLContext::ValidateBuffers(PRUint32 count)
|
||||
continue;
|
||||
|
||||
if (vd.buf == nsnull) {
|
||||
LogMessage("No VBO bound to enabled attrib index %d!", i);
|
||||
LogMessage(mVerbose, "No VBO bound to enabled attrib index %d!", i);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -126,12 +126,12 @@ WebGLContext::ValidateBuffers(PRUint32 count)
|
||||
CheckedUint32(vd.componentSize()) * vd.size; // and the number of bytes needed for these components
|
||||
|
||||
if (!checked_needed.valid()) {
|
||||
LogMessage("Integer overflow computing the size of bound vertex attrib buffer at index %d", i);
|
||||
LogMessage(mVerbose, "Integer overflow computing the size of bound vertex attrib buffer at index %d", i);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (vd.buf->ByteLength() < checked_needed.value()) {
|
||||
LogMessage("VBO too small for bound attrib index %d: need at least %d bytes, but have only %d",
|
||||
LogMessage(mVerbose, "VBO too small for bound attrib index %d: need at least %d bytes, but have only %d",
|
||||
i, checked_needed.value(), vd.buf->ByteLength());
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -3172,6 +3172,7 @@ pref("webgl.shader_validator", true);
|
||||
pref("webgl.force_osmesa", false);
|
||||
pref("webgl.mochitest_native_gl", false);
|
||||
pref("webgl.osmesalib", "");
|
||||
pref("webgl.verbose", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifndef WINCE
|
||||
|
Loading…
Reference in New Issue
Block a user