mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 924188 - Use MOZ_ASSERT where appropriate in WebGL code - r=jgilbert
This commit is contained in:
parent
de3c7b5255
commit
8adc0f724a
@ -1042,7 +1042,7 @@ CanvasRenderingContext2D::Render(gfxContext *ctx, GraphicsFilter aFilter, uint32
|
||||
if (!(aFlags & RenderFlagPremultAlpha)) {
|
||||
nsRefPtr<gfxASurface> curSurface = ctx->CurrentSurface();
|
||||
nsRefPtr<gfxImageSurface> gis = curSurface->GetAsImageSurface();
|
||||
NS_ABORT_IF_FALSE(gis, "If non-premult alpha, must be able to get image surface!");
|
||||
MOZ_ASSERT(gis, "If non-premult alpha, must be able to get image surface!");
|
||||
|
||||
gfxUtils::UnpremultiplyImageSurface(gis);
|
||||
}
|
||||
@ -3584,7 +3584,7 @@ CanvasRenderingContext2D::EnsureErrorTarget()
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), FORMAT_B8G8R8A8);
|
||||
NS_ABORT_IF_FALSE(errorTarget, "Failed to allocate the error target!");
|
||||
MOZ_ASSERT(errorTarget, "Failed to allocate the error target!");
|
||||
|
||||
sErrorTarget = errorTarget;
|
||||
NS_ADDREF(sErrorTarget);
|
||||
|
@ -481,7 +481,7 @@ WebGLContext::CheckedBufferData(GLenum target,
|
||||
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
|
||||
boundBuffer = mBoundVertexArray->mBoundElementArrayBuffer;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(boundBuffer != nullptr, "no buffer bound for this target");
|
||||
MOZ_ASSERT(boundBuffer != nullptr, "no buffer bound for this target");
|
||||
|
||||
bool sizeChanges = uint32_t(size) != boundBuffer->ByteLength();
|
||||
if (sizeChanges) {
|
||||
|
@ -2157,7 +2157,7 @@ WebGLContext::LinkProgram(WebGLProgram *program)
|
||||
shaderTypeName = "fragment";
|
||||
} else {
|
||||
// should have been validated earlier
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false);
|
||||
shaderTypeName = "<unknown>";
|
||||
}
|
||||
|
||||
@ -3666,7 +3666,7 @@ GLenum WebGLContext::CheckedTexImage2D(GLenum target,
|
||||
const GLvoid *data)
|
||||
{
|
||||
WebGLTexture *tex = activeBoundTextureForTarget(target);
|
||||
NS_ABORT_IF_FALSE(tex != nullptr, "no texture bound");
|
||||
MOZ_ASSERT(tex != nullptr, "no texture bound");
|
||||
|
||||
bool sizeMayChange = true;
|
||||
|
||||
@ -4162,7 +4162,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type)
|
||||
case LOCAL_GL_LUMINANCE_ALPHA:
|
||||
return WebGLTexelConversions::RA8;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "Coding mistake?! Should never reach this point.");
|
||||
MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
|
||||
return WebGLTexelConversions::BadFormat;
|
||||
}
|
||||
} else if (type == LOCAL_GL_FLOAT) {
|
||||
@ -4179,7 +4179,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type)
|
||||
case LOCAL_GL_LUMINANCE_ALPHA:
|
||||
return WebGLTexelConversions::RA32F;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "Coding mistake?! Should never reach this point.");
|
||||
MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
|
||||
return WebGLTexelConversions::BadFormat;
|
||||
}
|
||||
} else {
|
||||
@ -4191,7 +4191,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type)
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
|
||||
return WebGLTexelConversions::RGB565;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "Coding mistake?! Should never reach this point.");
|
||||
MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
|
||||
return WebGLTexelConversions::BadFormat;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ WebGLContext::ErrorName(GLenum error)
|
||||
case LOCAL_GL_NO_ERROR:
|
||||
return "NO_ERROR";
|
||||
default:
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false);
|
||||
return "[unknown WebGL error!]";
|
||||
}
|
||||
}
|
||||
@ -221,8 +221,7 @@ WebGLContext::IsTextureFormatCompressed(GLenum format)
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_NOTREACHED("Invalid WebGL texture format?");
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false, "Invalid WebGL texture format?");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ WebGLProgram::UpdateInfo()
|
||||
mContext->gl->fGetActiveAttrib(mGLName, i, mAttribMaxNameLength, &attrnamelen, &attrsize, &attrtype, nameBuf);
|
||||
if (attrnamelen > 0) {
|
||||
GLint loc = mContext->gl->fGetAttribLocation(mGLName, nameBuf);
|
||||
NS_ABORT_IF_FALSE(loc >= 0, "major oops in managing the attributes of a WebGL program");
|
||||
MOZ_ASSERT(loc >= 0, "major oops in managing the attributes of a WebGL program");
|
||||
if (loc < mContext->mGLMaxVertexAttribs) {
|
||||
mAttribsInUse[loc] = true;
|
||||
} else {
|
||||
@ -491,7 +491,7 @@ uint32_t WebGLContext::GetBitsPerTexel(GLenum format, GLenum type)
|
||||
return 16;
|
||||
}
|
||||
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ WebGLFramebuffer::Attachment::IsComplete() const {
|
||||
MOZ_CRASH("Invalid WebGL attachment poin?");
|
||||
}
|
||||
|
||||
NS_ABORT(); // should never get there
|
||||
MOZ_ASSERT(false); // should never get there
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -330,14 +330,14 @@ WebGLFramebuffer::GetAttachment(GLenum attachment) const {
|
||||
return mStencilAttachment;
|
||||
|
||||
if (!CheckColorAttachementNumber(attachment, "getAttachment")) {
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false);
|
||||
return mColorAttachments[0];
|
||||
}
|
||||
|
||||
uint32_t colorAttachmentId = uint32_t(attachment - LOCAL_GL_COLOR_ATTACHMENT0);
|
||||
|
||||
if (colorAttachmentId >= mColorAttachments.Length()) {
|
||||
NS_ABORT();
|
||||
MOZ_ASSERT(false);
|
||||
return mColorAttachments[0];
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,8 @@ public:
|
||||
{ }
|
||||
|
||||
~WebGLRefCountedObject() {
|
||||
NS_ABORT_IF_FALSE(mWebGLRefCnt == 0, "destroying WebGL object still referenced by other WebGL objects");
|
||||
NS_ABORT_IF_FALSE(mDeletionStatus == Deleted, "Derived class destructor must call DeleteOnce()");
|
||||
MOZ_ASSERT(mWebGLRefCnt == 0, "destroying WebGL object still referenced by other WebGL objects");
|
||||
MOZ_ASSERT(mDeletionStatus == Deleted, "Derived class destructor must call DeleteOnce()");
|
||||
}
|
||||
|
||||
// called by WebGLRefPtr
|
||||
@ -113,7 +113,7 @@ public:
|
||||
|
||||
// called by WebGLRefPtr
|
||||
void WebGLRelease() {
|
||||
NS_ABORT_IF_FALSE(mWebGLRefCnt > 0, "releasing WebGL object with WebGL refcnt already zero");
|
||||
MOZ_ASSERT(mWebGLRefCnt > 0, "releasing WebGL object with WebGL refcnt already zero");
|
||||
--mWebGLRefCnt;
|
||||
MaybeDelete();
|
||||
}
|
||||
@ -215,12 +215,12 @@ public:
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
NS_ABORT_IF_FALSE(mRawPtr != 0, "You can't dereference a nullptr WebGLRefPtr with operator->()!");
|
||||
MOZ_ASSERT(mRawPtr != 0, "You can't dereference a nullptr WebGLRefPtr with operator->()!");
|
||||
return get();
|
||||
}
|
||||
|
||||
T& operator*() const {
|
||||
NS_ABORT_IF_FALSE(mRawPtr != 0, "You can't dereference a nullptr WebGLRefPtr with operator*()!");
|
||||
MOZ_ASSERT(mRawPtr != 0, "You can't dereference a nullptr WebGLRefPtr with operator*()!");
|
||||
return *get();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class WebGLImageConverter
|
||||
case RGBA32F:
|
||||
return 4;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "Unknown texel format. Coding mistake?");
|
||||
MOZ_ASSERT(false, "Unknown texel format. Coding mistake?");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ class WebGLImageConverter
|
||||
|
||||
// end of early return cases.
|
||||
|
||||
NS_ABORT_IF_FALSE(!mAlreadyRun, "converter should be run only once!");
|
||||
MOZ_ASSERT(!mAlreadyRun, "converter should be run only once!");
|
||||
mAlreadyRun = true;
|
||||
|
||||
// gather some compile-time meta-data about the formats at hand.
|
||||
@ -160,8 +160,8 @@ class WebGLImageConverter
|
||||
const size_t NumElementsPerSrcTexel = NumElementsPerTexelForFormat<SrcFormat>();
|
||||
const size_t NumElementsPerDstTexel = NumElementsPerTexelForFormat<DstFormat>();
|
||||
const size_t MaxElementsPerTexel = 4;
|
||||
NS_ABORT_IF_FALSE(NumElementsPerSrcTexel <= MaxElementsPerTexel, "unhandled format");
|
||||
NS_ABORT_IF_FALSE(NumElementsPerDstTexel <= MaxElementsPerTexel, "unhandled format");
|
||||
MOZ_ASSERT(NumElementsPerSrcTexel <= MaxElementsPerTexel, "unhandled format");
|
||||
MOZ_ASSERT(NumElementsPerDstTexel <= MaxElementsPerTexel, "unhandled format");
|
||||
|
||||
// we assume that the strides are multiples of the sizeof of respective types.
|
||||
// this assumption will allow us to iterate over src and dst images using typed
|
||||
@ -169,9 +169,9 @@ class WebGLImageConverter
|
||||
// So this assumption allows us to write cleaner and safer code, but it might
|
||||
// not be true forever and if it eventually becomes wrong, we'll have to revert
|
||||
// to always iterating using uint8_t* pointers regardless of the types at hand.
|
||||
NS_ABORT_IF_FALSE(mSrcStride % sizeof(SrcType) == 0 &&
|
||||
mDstStride % sizeof(DstType) == 0,
|
||||
"Unsupported: texture stride is not a multiple of sizeof(type)");
|
||||
MOZ_ASSERT(mSrcStride % sizeof(SrcType) == 0 &&
|
||||
mDstStride % sizeof(DstType) == 0,
|
||||
"Unsupported: texture stride is not a multiple of sizeof(type)");
|
||||
const ptrdiff_t srcStrideInElements = mSrcStride / sizeof(SrcType);
|
||||
const ptrdiff_t dstStrideInElements = mDstStride / sizeof(DstType);
|
||||
|
||||
@ -225,7 +225,7 @@ class WebGLImageConverter
|
||||
WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(Premultiply)
|
||||
WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(Unpremultiply)
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "unhandled case. Coding mistake?");
|
||||
MOZ_ASSERT(false, "unhandled case. Coding mistake?");
|
||||
}
|
||||
|
||||
#undef WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP
|
||||
@ -254,7 +254,7 @@ class WebGLImageConverter
|
||||
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA4444)
|
||||
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA32F)
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "unhandled case. Coding mistake?");
|
||||
MOZ_ASSERT(false, "unhandled case. Coding mistake?");
|
||||
}
|
||||
|
||||
#undef WEBGLIMAGECONVERTER_CASE_DSTFORMAT
|
||||
@ -287,7 +287,7 @@ public:
|
||||
WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA4444)
|
||||
WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA32F)
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "unhandled case. Coding mistake?");
|
||||
MOZ_ASSERT(false, "unhandled case. Coding mistake?");
|
||||
}
|
||||
|
||||
#undef WEBGLIMAGECONVERTER_CASE_SRCFORMAT
|
||||
@ -335,7 +335,7 @@ WebGLContext::ConvertImage(size_t width, size_t height, size_t srcStride, size_t
|
||||
// So the case we're handling here is when even though no format conversion is needed,
|
||||
// we still might have to flip vertically and/or to adjust to a different stride.
|
||||
|
||||
NS_ABORT_IF_FALSE(mPixelStoreFlipY || srcStride != dstStride, "Performance trap -- should handle this case earlier, to avoid memcpy");
|
||||
MOZ_ASSERT(mPixelStoreFlipY || srcStride != dstStride, "Performance trap -- should handle this case earlier, to avoid memcpy");
|
||||
|
||||
size_t row_size = width * dstTexelSize; // doesn't matter, src and dst formats agree
|
||||
const uint8_t* ptr = src;
|
||||
|
@ -128,7 +128,7 @@ inline size_t TexelBytesForFormat(int format) {
|
||||
case WebGLTexelConversions::RGBA32F:
|
||||
return 16;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(false, "Unknown texel format. Coding mistake?");
|
||||
MOZ_ASSERT(false, "Unknown texel format. Coding mistake?");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ FORCE_INLINE void
|
||||
unpack(const SrcType* __restrict src,
|
||||
DstType* __restrict dst)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(false, "Unimplemented texture format conversion");
|
||||
MOZ_ASSERT(false, "Unimplemented texture format conversion");
|
||||
}
|
||||
|
||||
template<> FORCE_INLINE void
|
||||
@ -335,7 +335,7 @@ FORCE_INLINE void
|
||||
pack(const SrcType* __restrict src,
|
||||
DstType* __restrict dst)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(false, "Unimplemented texture format conversion");
|
||||
MOZ_ASSERT(false, "Unimplemented texture format conversion");
|
||||
}
|
||||
|
||||
template<> FORCE_INLINE void
|
||||
@ -658,7 +658,7 @@ pack<RA32F, Premultiply, float, float>(const float* __restrict src, float* __res
|
||||
template<typename SrcType, typename DstType> FORCE_INLINE void
|
||||
convertType(const SrcType* __restrict src, DstType* __restrict dst)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(false, "Unimplemented texture format conversion");
|
||||
MOZ_ASSERT(false, "Unimplemented texture format conversion");
|
||||
}
|
||||
|
||||
template<> FORCE_INLINE void
|
||||
|
@ -44,7 +44,7 @@ struct WebGLUniformInfo {
|
||||
case SH_FLOAT_MAT4:
|
||||
return 16;
|
||||
default:
|
||||
NS_ABORT(); // should never get here
|
||||
MOZ_ASSERT(false); // should never get here
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user