From f739bcc07c32789738c0c8402cea75cab5045196 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 3 May 2012 16:54:14 -0400 Subject: [PATCH] backout b13c1d8d2cda / bug 747619 for build failure (-Werror) --- content/canvas/src/WebGLContextGL.cpp | 59 ++++++++++++++------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 6ee0ca0e9b1d..1f0e2e45ea21 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -4164,7 +4164,7 @@ GetFloat32Array(JSContext* aCx, const JS::Value& aValue) return ErrorInvalidOperation("%s: This uniform location is obsolete since the program has been relinked", info); \ GLint location = location_object->Location(); -#define SIMPLE_ARRAY_METHOD_UNIFORM(name, expectedElemSize, arrayType, ptrType) \ +#define SIMPLE_ARRAY_METHOD_UNIFORM(name, cnt, arrayType, ptrType) \ NS_IMETHODIMP \ WebGLContext::name(nsIWebGLUniformLocation *aLocation, const JS::Value& aValue, \ JSContext* aCx) \ @@ -4180,39 +4180,40 @@ WebGLContext::name(nsIWebGLUniformLocation *aLocation, const JS::Value& aValue, \ nsIWebGLUniformLocation* ploc = aLocation; \ OBTAIN_UNIFORM_LOCATION(#name ": location") \ - int uniformElemSize = location_object->ElementSize(); \ - if (expectedElemSize != uniformElemSize) { \ + int elementSize = location_object->ElementSize(); \ + if (cnt != elementSize) { \ return ErrorInvalidOperation( \ #name ": this function expected a uniform of element size %d," \ " got a uniform of element size %d", \ - expectedElemSize, \ - uniformElemSize); \ + cnt, \ + elementSize); \ } \ PRUint32 arrayLength = JS_GetTypedArrayLength(wa, aCx); \ const WebGLUniformInfo& info = location_object->Info(); \ - if (arrayLength == 0 || \ - arrayLength % expectedElemSize) \ + PRUint32 expectedArrayLength = cnt * info.arraySize; \ + if (arrayLength < expectedArrayLength || \ + (arrayLength % cnt)) \ { \ return ErrorInvalidValue("%s: expected an array of length a multiple of" \ - " %d, got an array of length %d", \ + " %d and at least %d, got an array of length %d", \ #name, \ - expectedElemSize, \ + cnt, \ + expectedArrayLength, \ arrayLength); \ } \ if (!info.isArray && \ - arrayLength != expectedElemSize) { \ + arrayLength > expectedArrayLength) { \ return ErrorInvalidOperation("%s: expected an array of length exactly %d" \ " (since this uniform is not an array uniform)," \ - " got an array of length %d", \ + " got an array of length %d", \ #name, \ - expectedElemSize, \ + expectedArrayLength, \ arrayLength); \ } \ \ MakeContextCurrent(); \ - PRUint32 numElementsToUpload = NS_MIN(info.arraySize, arrayLength/expectedElemSize); \ - gl->f##name(location, numElementsToUpload, \ - static_cast(JS_GetArrayBufferViewData(wa, aCx))); \ + gl->f##name(location, info.arraySize, \ + static_cast(JS_GetArrayBufferViewData(wa, aCx))); \ return NS_OK; \ } @@ -4221,7 +4222,6 @@ NS_IMETHODIMP WebGLContext::name(nsIWebGLUniformLocation* aLocation, bool aTranspose, \ const JS::Value& aValue, JSContext* aCx) \ { \ - int expectedElemSize = (dim)*(dim); \ JSObject* wa = GetFloat32Array(aCx, aValue); \ if (!wa) { \ return NS_ERROR_FAILURE; \ @@ -4236,32 +4236,34 @@ WebGLContext::name(nsIWebGLUniformLocation* aLocation, bool aTranspose, if (!wa || !JS_IsFloat32Array(wa, aCx)) { \ return ErrorInvalidValue(#name ": array must be of Float32 type"); \ } \ - int uniformElemSize = location_object->ElementSize(); \ - if (expectedElemSize != uniformElemSize) { \ + int elementSize = location_object->ElementSize(); \ + if (dim*dim != elementSize) { \ return ErrorInvalidOperation( \ #name ": this function expected a uniform of element size %d," \ " got a uniform of element size %d", \ - expectedElemSize, \ - uniformElemSize); \ + dim*dim, \ + elementSize); \ } \ PRUint32 arrayLength = JS_GetTypedArrayLength(wa, aCx); \ const WebGLUniformInfo& info = location_object->Info(); \ - if (arrayLength == 0 || \ - arrayLength % expectedElemSize) \ + PRUint32 expectedArrayLength = dim * dim * info.arraySize; \ + if (arrayLength < expectedArrayLength || \ + (arrayLength % (dim*dim))) \ { \ return ErrorInvalidValue("%s: expected an array of length a multiple of" \ - " %d, got an array of length %d", \ + " %d and at least %d, got an array of length %d", \ #name, \ - expectedElemSize, \ + dim*dim, \ + expectedArrayLength, \ arrayLength); \ } \ - if (!info.isArray && \ - arrayLength != expectedElemSize) { \ + if (!info.isArray && \ + arrayLength > expectedArrayLength) { \ return ErrorInvalidOperation("%s: expected an array of length exactly %d" \ " (since this uniform is not an array uniform)," \ " got an array of length %d", \ #name, \ - expectedElemSize, \ + expectedArrayLength, \ arrayLength); \ } \ if (aTranspose) { \ @@ -4270,8 +4272,7 @@ WebGLContext::name(nsIWebGLUniformLocation* aLocation, bool aTranspose, } \ \ MakeContextCurrent(); \ - PRUint32 numElementsToUpload = NS_MIN(info.arraySize, arrayLength/(expectedElemSize)); \ - gl->f##name(location, numElementsToUpload, false, \ + gl->f##name(location, info.arraySize, false, \ static_cast(JS_GetArrayBufferViewData(wa, aCx))); \ return NS_OK; \ }