OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dart.typed_data; | 5 library dart.typed_data; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:_collection-dev'; | 8 import 'dart:_collection-dev'; |
9 import 'dart:math' show Random; | 9 import 'dart:math' show Random; |
10 | 10 |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 * BYTES_PER_ELEMENT. | 820 * BYTES_PER_ELEMENT. |
821 */ | 821 */ |
822 external factory Float32x4List.view(ByteBuffer buffer, | 822 external factory Float32x4List.view(ByteBuffer buffer, |
823 [int offsetInBytes = 0, int length]); | 823 [int offsetInBytes = 0, int length]); |
824 | 824 |
825 static const int BYTES_PER_ELEMENT = 16; | 825 static const int BYTES_PER_ELEMENT = 16; |
826 } | 826 } |
827 | 827 |
828 | 828 |
829 /** | 829 /** |
830 * A fixed-length list of Uint32x4 numbers that is viewable as a | 830 * A fixed-length list of Int32x4 numbers that is viewable as a |
831 * [TypedData]. For long lists, this implementation will be considerably more | 831 * [TypedData]. For long lists, this implementation will be considerably more |
832 * space- and time-efficient than the default [List] implementation. | 832 * space- and time-efficient than the default [List] implementation. |
833 */ | 833 */ |
834 abstract class Uint32x4List implements List<Uint32x4>, TypedData { | 834 abstract class Int32x4List implements List<Int32x4>, TypedData { |
835 /** | 835 /** |
836 * Creates a [Uint32x4List] of the specified length (in elements), | 836 * Creates a [Int32x4List] of the specified length (in elements), |
837 * all of whose elements are initially zero. | 837 * all of whose elements are initially zero. |
838 */ | 838 */ |
839 external factory Uint32x4List(int length); | 839 external factory Int32x4List(int length); |
840 | 840 |
841 /** | 841 /** |
842 * Creates a [Uint32x4List] with the same size as the [elements] list | 842 * Creates a [Int32x4List] with the same size as the [elements] list |
843 * and copies over the elements. | 843 * and copies over the elements. |
844 */ | 844 */ |
845 external factory Uint32x4List.fromList(List<Uint32x4> elements); | 845 external factory Int32x4List.fromList(List<Int32x4> elements); |
846 | 846 |
847 /** | 847 /** |
848 * Creates a [Uint32x4List] _view_ of the specified region in the specified | 848 * Creates a [Int32x4List] _view_ of the specified region in the specified |
849 * byte buffer. Changes in the [Uint32x4List] will be visible in the byte | 849 * byte buffer. Changes in the [Int32x4List] will be visible in the byte |
850 * buffer and vice versa. If the [offsetInBytes] index of the region is not | 850 * buffer and vice versa. If the [offsetInBytes] index of the region is not |
851 * specified, it defaults to zero (the first byte in the byte buffer). | 851 * specified, it defaults to zero (the first byte in the byte buffer). |
852 * If the length is not specified, it defaults to null, which indicates | 852 * If the length is not specified, it defaults to null, which indicates |
853 * that the view extends to the end of the byte buffer. | 853 * that the view extends to the end of the byte buffer. |
854 * | 854 * |
855 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 855 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
856 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 856 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
857 * the length of [buffer]. | 857 * the length of [buffer]. |
858 * | 858 * |
859 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 859 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
860 * BYTES_PER_ELEMENT. | 860 * BYTES_PER_ELEMENT. |
861 */ | 861 */ |
862 external factory Uint32x4List.view(ByteBuffer buffer, | 862 external factory Int32x4List.view(ByteBuffer buffer, |
863 [int offsetInBytes = 0, int length]); | 863 [int offsetInBytes = 0, int length]); |
864 | 864 |
865 static const int BYTES_PER_ELEMENT = 16; | 865 static const int BYTES_PER_ELEMENT = 16; |
866 } | 866 } |
867 | 867 |
868 | 868 |
869 /** | 869 /** |
870 * Interface of Dart Float32x4 immutable value type and operations. | 870 * Interface of Dart Float32x4 immutable value type and operations. |
871 * Float32x4 stores 4 32-bit floating point values in "lanes". | 871 * Float32x4 stores 4 32-bit floating point values in "lanes". |
872 * The lanes are "x", "y", "z", and "w" respectively. | 872 * The lanes are "x", "y", "z", and "w" respectively. |
873 */ | 873 */ |
874 abstract class Float32x4 { | 874 abstract class Float32x4 { |
875 external factory Float32x4(double x, double y, double z, double w); | 875 external factory Float32x4(double x, double y, double z, double w); |
876 external factory Float32x4.splat(double v); | 876 external factory Float32x4.splat(double v); |
877 external factory Float32x4.zero(); | 877 external factory Float32x4.zero(); |
878 external factory Float32x4.fromUint32x4Bits(Uint32x4 x); | 878 external factory Float32x4.fromInt32x4Bits(Int32x4 x); |
879 | 879 |
880 /// Addition operator. | 880 /// Addition operator. |
881 Float32x4 operator+(Float32x4 other); | 881 Float32x4 operator+(Float32x4 other); |
882 /// Negate operator. | 882 /// Negate operator. |
883 Float32x4 operator-(); | 883 Float32x4 operator-(); |
884 /// Subtraction operator. | 884 /// Subtraction operator. |
885 Float32x4 operator-(Float32x4 other); | 885 Float32x4 operator-(Float32x4 other); |
886 /// Multiplication operator. | 886 /// Multiplication operator. |
887 Float32x4 operator*(Float32x4 other); | 887 Float32x4 operator*(Float32x4 other); |
888 /// Division operator. | 888 /// Division operator. |
889 Float32x4 operator/(Float32x4 other); | 889 Float32x4 operator/(Float32x4 other); |
890 | 890 |
891 /// Relational less than. | 891 /// Relational less than. |
892 Uint32x4 lessThan(Float32x4 other); | 892 Int32x4 lessThan(Float32x4 other); |
893 /// Relational less than or equal. | 893 /// Relational less than or equal. |
894 Uint32x4 lessThanOrEqual(Float32x4 other); | 894 Int32x4 lessThanOrEqual(Float32x4 other); |
895 /// Relational greater than. | 895 /// Relational greater than. |
896 Uint32x4 greaterThan(Float32x4 other); | 896 Int32x4 greaterThan(Float32x4 other); |
897 /// Relational greater than or equal. | 897 /// Relational greater than or equal. |
898 Uint32x4 greaterThanOrEqual(Float32x4 other); | 898 Int32x4 greaterThanOrEqual(Float32x4 other); |
899 /// Relational equal. | 899 /// Relational equal. |
900 Uint32x4 equal(Float32x4 other); | 900 Int32x4 equal(Float32x4 other); |
901 /// Relational not-equal. | 901 /// Relational not-equal. |
902 Uint32x4 notEqual(Float32x4 other); | 902 Int32x4 notEqual(Float32x4 other); |
903 | 903 |
904 /// Returns a copy of [this] each lane being scaled by [s]. | 904 /// Returns a copy of [this] each lane being scaled by [s]. |
905 Float32x4 scale(double s); | 905 Float32x4 scale(double s); |
906 /// Returns the absolute value of this [Float32x4]. | 906 /// Returns the absolute value of this [Float32x4]. |
907 Float32x4 abs(); | 907 Float32x4 abs(); |
908 /// Clamps [this] to be in the range [lowerLimit]-[upperLimit]. | 908 /// Clamps [this] to be in the range [lowerLimit]-[upperLimit]. |
909 Float32x4 clamp(Float32x4 lowerLimit, | 909 Float32x4 clamp(Float32x4 lowerLimit, |
910 Float32x4 upperLimit); | 910 Float32x4 upperLimit); |
911 | 911 |
912 /// Extracted x value. | 912 /// Extracted x value. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1207 |
1208 /// Returns the reciprocal of [this]. | 1208 /// Returns the reciprocal of [this]. |
1209 Float32x4 reciprocal(); | 1209 Float32x4 reciprocal(); |
1210 | 1210 |
1211 /// Returns the square root of the reciprocal of [this]. | 1211 /// Returns the square root of the reciprocal of [this]. |
1212 Float32x4 reciprocalSqrt(); | 1212 Float32x4 reciprocalSqrt(); |
1213 } | 1213 } |
1214 | 1214 |
1215 | 1215 |
1216 /** | 1216 /** |
1217 * Interface of Dart Uint32x4 and operations. | 1217 * Interface of Dart Int32x4 and operations. |
1218 * Uint32x4 stores 4 32-bit bit-masks in "lanes". | 1218 * Int32x4 stores 4 32-bit bit-masks in "lanes". |
1219 * The lanes are "x", "y", "z", and "w" respectively. | 1219 * The lanes are "x", "y", "z", and "w" respectively. |
1220 */ | 1220 */ |
1221 abstract class Uint32x4 { | 1221 abstract class Int32x4 { |
1222 external factory Uint32x4(int x, int y, int z, int w); | 1222 external factory Int32x4(int x, int y, int z, int w); |
1223 external factory Uint32x4.bool(bool x, bool y, bool z, bool w); | 1223 external factory Int32x4.bool(bool x, bool y, bool z, bool w); |
1224 external factory Uint32x4.fromFloat32x4Bits(Float32x4 x); | 1224 external factory Int32x4.fromFloat32x4Bits(Float32x4 x); |
1225 | 1225 |
1226 /// The bit-wise or operator. | 1226 /// The bit-wise or operator. |
1227 Uint32x4 operator|(Uint32x4 other); | 1227 Int32x4 operator|(Int32x4 other); |
1228 /// The bit-wise and operator. | 1228 /// The bit-wise and operator. |
1229 Uint32x4 operator&(Uint32x4 other); | 1229 Int32x4 operator&(Int32x4 other); |
1230 /// The bit-wise xor operator. | 1230 /// The bit-wise xor operator. |
1231 Uint32x4 operator^(Uint32x4 other); | 1231 Int32x4 operator^(Int32x4 other); |
1232 /// Addition operator. | 1232 /// Addition operator. |
1233 Uint32x4 operator+(Uint32x4 other); | 1233 Int32x4 operator+(Int32x4 other); |
1234 /// Subtraction operator. | 1234 /// Subtraction operator. |
1235 Uint32x4 operator-(Uint32x4 other); | 1235 Int32x4 operator-(Int32x4 other); |
1236 | 1236 |
1237 /// Extract 32-bit mask from x lane. | 1237 /// Extract 32-bit mask from x lane. |
1238 int get x; | 1238 int get x; |
1239 /// Extract 32-bit mask from y lane. | 1239 /// Extract 32-bit mask from y lane. |
1240 int get y; | 1240 int get y; |
1241 /// Extract 32-bit mask from z lane. | 1241 /// Extract 32-bit mask from z lane. |
1242 int get z; | 1242 int get z; |
1243 /// Extract 32-bit mask from w lane. | 1243 /// Extract 32-bit mask from w lane. |
1244 int get w; | 1244 int get w; |
1245 | 1245 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 static const int WWZX = 0x2F; | 1498 static const int WWZX = 0x2F; |
1499 static const int WWZY = 0x6F; | 1499 static const int WWZY = 0x6F; |
1500 static const int WWZZ = 0xAF; | 1500 static const int WWZZ = 0xAF; |
1501 static const int WWZW = 0xEF; | 1501 static const int WWZW = 0xEF; |
1502 static const int WWWX = 0x3F; | 1502 static const int WWWX = 0x3F; |
1503 static const int WWWY = 0x7F; | 1503 static const int WWWY = 0x7F; |
1504 static const int WWWZ = 0xBF; | 1504 static const int WWWZ = 0xBF; |
1505 static const int WWWW = 0xFF; | 1505 static const int WWWW = 0xFF; |
1506 | 1506 |
1507 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. | 1507 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. |
1508 Uint32x4 shuffle(int mask); | 1508 Int32x4 shuffle(int mask); |
1509 | 1509 |
1510 /// Shuffle the lane values in [this] and [other]. The returned | 1510 /// Shuffle the lane values in [this] and [other]. The returned |
1511 /// Uint32x4 will have XY lanes from [this] and ZW lanes from [other]. | 1511 /// Int32x4 will have XY lanes from [this] and ZW lanes from [other]. |
1512 /// Uses the same [mask] as [shuffle]. | 1512 /// Uses the same [mask] as [shuffle]. |
1513 Uint32x4 shuffleMix(Uint32x4 other, int mask); | 1513 Int32x4 shuffleMix(Int32x4 other, int mask); |
1514 | 1514 |
1515 /// Returns a new [Uint32x4] copied from [this] with a new x value. | 1515 /// Returns a new [Int32x4] copied from [this] with a new x value. |
1516 Uint32x4 withX(int x); | 1516 Int32x4 withX(int x); |
1517 /// Returns a new [Uint32x4] copied from [this] with a new y value. | 1517 /// Returns a new [Int32x4] copied from [this] with a new y value. |
1518 Uint32x4 withY(int y); | 1518 Int32x4 withY(int y); |
1519 /// Returns a new [Uint32x4] copied from [this] with a new z value. | 1519 /// Returns a new [Int32x4] copied from [this] with a new z value. |
1520 Uint32x4 withZ(int z); | 1520 Int32x4 withZ(int z); |
1521 /// Returns a new [Uint32x4] copied from [this] with a new w value. | 1521 /// Returns a new [Int32x4] copied from [this] with a new w value. |
1522 Uint32x4 withW(int w); | 1522 Int32x4 withW(int w); |
1523 | 1523 |
1524 /// Extracted x value. Returns false for 0, true for any other value. | 1524 /// Extracted x value. Returns false for 0, true for any other value. |
1525 bool get flagX; | 1525 bool get flagX; |
1526 /// Extracted y value. Returns false for 0, true for any other value. | 1526 /// Extracted y value. Returns false for 0, true for any other value. |
1527 bool get flagY; | 1527 bool get flagY; |
1528 /// Extracted z value. Returns false for 0, true for any other value. | 1528 /// Extracted z value. Returns false for 0, true for any other value. |
1529 bool get flagZ; | 1529 bool get flagZ; |
1530 /// Extracted w value. Returns false for 0, true for any other value. | 1530 /// Extracted w value. Returns false for 0, true for any other value. |
1531 bool get flagW; | 1531 bool get flagW; |
1532 | 1532 |
1533 /// Returns a new [Uint32x4] copied from [this] with a new x value. | 1533 /// Returns a new [Int32x4] copied from [this] with a new x value. |
1534 Uint32x4 withFlagX(bool x); | 1534 Int32x4 withFlagX(bool x); |
1535 /// Returns a new [Uint32x4] copied from [this] with a new y value. | 1535 /// Returns a new [Int32x4] copied from [this] with a new y value. |
1536 Uint32x4 withFlagY(bool y); | 1536 Int32x4 withFlagY(bool y); |
1537 /// Returns a new [Uint32x4] copied from [this] with a new z value. | 1537 /// Returns a new [Int32x4] copied from [this] with a new z value. |
1538 Uint32x4 withFlagZ(bool z); | 1538 Int32x4 withFlagZ(bool z); |
1539 /// Returns a new [Uint32x4] copied from [this] with a new w value. | 1539 /// Returns a new [Int32x4] copied from [this] with a new w value. |
1540 Uint32x4 withFlagW(bool w); | 1540 Int32x4 withFlagW(bool w); |
1541 | 1541 |
1542 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: | 1542 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: |
1543 /// Select bit from [trueValue] when bit in [this] is on. | 1543 /// Select bit from [trueValue] when bit in [this] is on. |
1544 /// Select bit from [falseValue] when bit in [this] is off. | 1544 /// Select bit from [falseValue] when bit in [this] is off. |
1545 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue); | 1545 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue); |
1546 } | 1546 } |
OLD | NEW |