diff options
Diffstat (limited to 'Source/WTF/wtf/Float32Array.h')
| -rw-r--r-- | Source/WTF/wtf/Float32Array.h | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Source/WTF/wtf/Float32Array.h b/Source/WTF/wtf/Float32Array.h index 55e61e006..47204ec78 100644 --- a/Source/WTF/wtf/Float32Array.h +++ b/Source/WTF/wtf/Float32Array.h @@ -38,6 +38,10 @@ public: static inline PassRefPtr<Float32Array> create(const float* array, unsigned length); static inline PassRefPtr<Float32Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); + // Should only be used when it is known the entire array will be filled. Do + // not return these results directly to JavaScript without filling first. + static inline PassRefPtr<Float32Array> createUninitialized(unsigned length); + // Can’t use "using" here due to a bug in the RVCT compiler. bool set(TypedArrayBase<float>* array, unsigned offset) { return TypedArrayBase<float>::set(array, offset); } @@ -48,27 +52,20 @@ public: TypedArrayBase<float>::data()[index] = static_cast<float>(value); } - // Invoked by the indexed getter. Does not perform range checks; caller - // is responsible for doing so and returning undefined as necessary. - float item(unsigned index) const - { - ASSERT(index < TypedArrayBase<float>::m_length); - float result = TypedArrayBase<float>::data()[index]; - return result; - } - inline PassRefPtr<Float32Array> subarray(int start) const; inline PassRefPtr<Float32Array> subarray(int start, int end) const; + virtual ViewType getType() const + { + return TypeFloat32; + } + private: inline Float32Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); // Make constructor visible to superclass. friend class TypedArrayBase<float>; - - // Overridden from ArrayBufferView. - virtual bool isFloatArray() const { return true; } }; PassRefPtr<Float32Array> Float32Array::create(unsigned length) @@ -86,6 +83,11 @@ PassRefPtr<Float32Array> Float32Array::create(PassRefPtr<ArrayBuffer> buffer, un return TypedArrayBase<float>::create<Float32Array>(buffer, byteOffset, length); } +PassRefPtr<Float32Array> Float32Array::createUninitialized(unsigned length) +{ + return TypedArrayBase<float>::createUninitialized<Float32Array>(length); +} + Float32Array::Float32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length) : TypedArrayBase<float>(buffer, byteOffset, length) { |
