@@ -53,8 +53,15 @@ export function supportsDirectArrayBuffers() {
5353 return _supportsDirectArrayBuffers ;
5454}
5555
56+ export function createArrayBufferOrNativeArray ( length : number , useInts = false ) {
57+ if ( ! supportsDirectArrayBuffers ( ) ) {
58+ return createNativeArray ( length , useInts ) ;
59+ } else {
60+ return createArrayBuffer ( length , useInts ) ;
61+ }
62+ }
5663export function createArrayBuffer ( length : number , useInts = false ) {
57- if ( global . isAndroid && ! supportsDirectArrayBuffers ( ) ) {
64+ if ( ! supportsDirectArrayBuffers ( ) ) {
5865 let bb : java . nio . ByteBuffer ;
5966 if ( useInts ) {
6067 bb = java . nio . ByteBuffer . allocateDirect ( length ) ;
@@ -67,7 +74,7 @@ export function createArrayBuffer(length: number, useInts = false) {
6774 return useInts ? new Int8Array ( length ) : new Float32Array ( length ) ;
6875}
6976export function pointsFromBuffer ( typedArray : Float32Array | Int8Array , useInts = false ) {
70- if ( global . isAndroid && ! supportsDirectArrayBuffers ( ) ) {
77+ if ( ! supportsDirectArrayBuffers ( ) ) {
7178 if ( useInts ) {
7279 const buffer = typedArray . buffer ;
7380 return ( ( buffer as any ) . nativeObject as java . nio . ByteBuffer ) . array ( ) ;
@@ -92,8 +99,8 @@ export function arrayToNativeArray(array, useInts = false) {
9299}
93100
94101// export const nativeArrayToArray = profile('nativeArrayToArray', function(array) {
95- export function nativeArrayToArray ( array ) {
96- if ( global . isAndroid && ! supportsDirectArrayBuffers ( ) ) {
102+ export function nativeArrayToArray ( array ) : number [ ] {
103+ if ( ! supportsDirectArrayBuffers ( ) ) {
97104 const result = [ ] ;
98105 for ( let index = 0 ; index < array . length ; index ++ ) {
99106 result [ index ] = array [ index ] ;
@@ -103,12 +110,12 @@ export function nativeArrayToArray(array) {
103110 }
104111 return array ;
105112}
106- export function createNativeArray ( length ) {
107- if ( global . isAndroid ) {
113+ export function createNativeArray ( length , useInts = false ) : number [ ] {
114+ if ( useInts ) {
115+ return Array . create ( 'int' , length ) ;
116+ } else {
108117 return Array . create ( 'float' , length ) ;
109118 }
110- // At least, set length to use it for iterations
111- return new Array ( length ) ;
112119}
113120
114121export function parseDashEffect ( value : string ) {
0 commit comments