| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 379 } |
| 380 | 380 |
| 381 template<typename T, size_t inlineCapacity> | 381 template<typename T, size_t inlineCapacity> |
| 382 bool toVector(JSC::ExecState* exec, JSC::JSValue value, Vector<T, inlineCapacity
>& vector) | 382 bool toVector(JSC::ExecState* exec, JSC::JSValue value, Vector<T, inlineCapacity
>& vector) |
| 383 { | 383 { |
| 384 if (!value.isObject()) | 384 if (!value.isObject()) |
| 385 return false; | 385 return false; |
| 386 | 386 |
| 387 JSC::JSObject* object = asObject(value); | 387 JSC::JSObject* object = asObject(value); |
| 388 int32_t length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(
exec); | 388 int32_t length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(
exec); |
| 389 |
| 390 if (!vector.tryReserveCapacity(length)) |
| 391 return false; |
| 389 vector.resize(length); | 392 vector.resize(length); |
| 390 | 393 |
| 391 for (int32_t i = 0; i < length; ++i) { | 394 for (int32_t i = 0; i < length; ++i) { |
| 392 JSC::JSValue v = object->get(exec, i); | 395 JSC::JSValue v = object->get(exec, i); |
| 393 if (exec->hadException()) | 396 if (exec->hadException()) |
| 394 return false; | 397 return false; |
| 395 vector[i] = static_cast<T>(v.toNumber(exec)); | 398 vector[i] = static_cast<T>(v.toNumber(exec)); |
| 396 } | 399 } |
| 397 | 400 |
| 398 return true; | 401 return true; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 } | 708 } |
| 706 | 709 |
| 707 JSC::JSValue JSWebGLRenderingContext::vertexAttrib4fv(JSC::ExecState* exec) | 710 JSC::JSValue JSWebGLRenderingContext::vertexAttrib4fv(JSC::ExecState* exec) |
| 708 { | 711 { |
| 709 return dataFunctionf(f_vertexAttrib4v, exec, static_cast<WebGLRenderingConte
xt*>(impl())); | 712 return dataFunctionf(f_vertexAttrib4v, exec, static_cast<WebGLRenderingConte
xt*>(impl())); |
| 710 } | 713 } |
| 711 | 714 |
| 712 } // namespace WebCore | 715 } // namespace WebCore |
| 713 | 716 |
| 714 #endif // ENABLE(WEBGL) | 717 #endif // ENABLE(WEBGL) |
| OLD | NEW |