Remove the unused js_CoerceArrayToCanvasImageData. rs=luke
This commit is contained in:
@@ -3205,64 +3205,6 @@ js_ArrayInfo(JSContext *cx, uintN argc, jsval *vp)
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count,
|
||||
JSUint8 *dest)
|
||||
{
|
||||
uint32 length;
|
||||
|
||||
if (!obj || !obj->isDenseArray())
|
||||
return JS_FALSE;
|
||||
|
||||
length = obj->getArrayLength();
|
||||
if (length < offset + count)
|
||||
return JS_FALSE;
|
||||
|
||||
JSUint8 *dp = dest;
|
||||
for (uintN i = offset; i < offset+count; i++) {
|
||||
const Value &v = obj->getDenseArrayElement(i);
|
||||
if (v.isInt32()) {
|
||||
jsint vi = v.toInt32();
|
||||
if (jsuint(vi) > 255)
|
||||
vi = (vi < 0) ? 0 : 255;
|
||||
*dp++ = JSUint8(vi);
|
||||
} else if (v.isDouble()) {
|
||||
jsdouble vd = v.toDouble();
|
||||
if (!(vd >= 0)) /* Not < so that NaN coerces to 0 */
|
||||
*dp++ = 0;
|
||||
else if (vd > 255)
|
||||
*dp++ = 255;
|
||||
else {
|
||||
jsdouble toTruncate = vd + 0.5;
|
||||
JSUint8 val = JSUint8(toTruncate);
|
||||
|
||||
/*
|
||||
* now val is rounded to nearest, ties rounded up. We want
|
||||
* rounded to nearest ties to even, so check whether we had a
|
||||
* tie.
|
||||
*/
|
||||
if (val == toTruncate) {
|
||||
/*
|
||||
* It was a tie (since adding 0.5 gave us the exact integer
|
||||
* we want). Since we rounded up, we either already have an
|
||||
* even number or we have an odd number but the number we
|
||||
* want is one less. So just unconditionally masking out the
|
||||
* ones bit should do the trick to get us the value we
|
||||
* want.
|
||||
*/
|
||||
*dp++ = (val & ~1);
|
||||
} else {
|
||||
*dp++ = val;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_IsDensePrimitiveArray(JSObject *obj)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user