Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: sdk/lib/typeddata/typeddata_base.dart

Issue 12534006: Port SIMD types from dart:scalarlist to dart:typeddata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/typeddata/typeddata_base.dart
diff --git a/sdk/lib/typeddata/typeddata_base.dart b/sdk/lib/typeddata/typeddata_base.dart
index f40c403ec52a591108b4909553188515123172c5..ffe98ce875eb9bb24cd21efc8b8188341a53983f 100644
--- a/sdk/lib/typeddata/typeddata_base.dart
+++ b/sdk/lib/typeddata/typeddata_base.dart
@@ -309,6 +309,26 @@ abstract class ByteData implements TypedData {
* `byteOffset + 8` is greater than the length of this object.
*/
void setFloat64(int byteOffset, double value);
+
+ /**
+ * Returns the 4 floating point numbers represented by the sixteen bytes at
+ * the specified [byteOffset] in this object, in IEEE 754
+ * single-precision binary floating-point format (binary32).
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 16` is greater than the length of this object.
+ */
+ Float32x4 getFloat32x4(int byteOffset);
+
+ /**
+ * Sets the sixteen bytes starting at the specified [byteOffset] in this
+ * object to the 4 IEEE 754 single-precision binary floating-point
+ * (binary32) numbers of the specified [value].
+ *
+ * Throws [RangeError] if [byteOffset] is negative, or
+ * `byteOffset + 16` is greater than the length of this object.
+ */
+ void setFloat32x4(int byteOffset, Float32x4 value);
}
@@ -679,3 +699,36 @@ abstract class Float64List implements List<double>, TypedData {
static const int BYTES_PER_ELEMENT = 8;
}
+
+/**
+ * A fixed-length list of Float32x4 numbers that is viewable as a
+ * [TypedData]. For long lists, this implementation will be considerably more
+ * space- and time-efficient than the default [List] implementation.
+ */
+abstract class Float32x4List implements List<Float32x4>, TypedData {
+ /**
+ * Creates a [Float32x4List] of the specified length (in elements),
+ * all of whose elements are initially zero.
+ */
+ external factory Float32x4List(int length);
+
+ /**
+ * Creates a [Float32x4List] _view_ of the specified region in the specified
+ * byte buffer. Changes in the [Float32x4List] will be visible in the byte
+ * buffer and vice versa. If the [offsetInBytes] index of the region is not
+ * specified, it defaults to zero (the first byte in the byte buffer).
+ * If the length is not specified, it defaults to null, which indicates
+ * that the view extends to the end of the byte buffer.
+ *
+ * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
+ * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
+ * the length of [buffer].
+ *
+ * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
+ * BYTES_PER_ELEMENT.
+ */
+ external factory Float32x4List.view(ByteBuffer buffer,
+ [int offsetInBytes = 0, int length]);
+
+ static const int BYTES_PER_ELEMENT = 16;
+}

Powered by Google App Engine
This is Rietveld 408576698