@@ -37,23 +37,23 @@ function getSDK() {
3737 return SDK_INT ;
3838}
3939
40- function createArrayBuffer ( length : number , useInts = false ) {
40+ export function createArrayBuffer ( length : number , useInts = false ) {
4141 let bb : java . nio . ByteBuffer ;
4242 if ( useInts ) {
4343 bb = java . nio . ByteBuffer . allocateDirect ( length ) ;
4444 } else {
4545 bb = java . nio . ByteBuffer . allocateDirect ( length * 4 ) . order ( java . nio . ByteOrder . LITTLE_ENDIAN ) ;
4646 }
47- // var bb = java.nio.ByteBuffer.allocateDirect(length * 4).order(java.nio.ByteOrder.LITTLE_ENDIAN);
4847 const result = ( ArrayBuffer as any ) . from ( bb ) ;
49- // result.bb = bb;
50- return result ;
48+ return useInts ? new Int8Array ( result ) : new Float32Array ( result ) ;
5149}
52- function pointsFromBuffer ( buffer : ArrayBuffer , useInts = false ) {
50+ export function pointsFromBuffer ( typedArray : Float32Array | Int8Array , useInts = false ) {
5351 if ( useInts ) {
52+ const buffer = typedArray . buffer ;
5453 return ( ( buffer as any ) . nativeObject as java . nio . ByteBuffer ) . array ( ) ;
5554 }
56- const length = buffer . byteLength / 4 ;
55+ const buffer = typedArray . buffer ;
56+ const length = typedArray . length ;
5757 const testArray = Array . create ( 'float' , length ) ;
5858 ( ( buffer as any ) . nativeObject as java . nio . ByteBuffer ) . asFloatBuffer ( ) . get ( testArray , 0 , length ) ;
5959 return testArray as number [ ] ;
@@ -64,11 +64,9 @@ export function arrayToNativeArray(array, useInts = false) {
6464 return array ;
6565 }
6666 const length = array . length ;
67- const buffer = createArrayBuffer ( length , useInts ) ;
68- const arrayBuffer = useInts ? new Int8Array ( buffer ) : new Float32Array ( buffer ) ;
69- arrayBuffer . set ( array ) ;
67+ const typedArray = createArrayBuffer ( length , useInts ) ;
7068
71- return pointsFromBuffer ( buffer , useInts ) ;
69+ return pointsFromBuffer ( typedArray , useInts ) ;
7270}
7371
7472export function parseDashEffect ( value : string ) {
@@ -226,7 +224,7 @@ export class Paint {
226224 native . setLinearText ( true ) ; // ensure we are drawing fonts correctly
227225 return new Proxy ( this , {
228226 get ( target , name , receiver ) {
229- if ( native [ name ] ) {
227+ if ( native && native [ name ] ) {
230228 return function ( ...args ) {
231229 const methodName = name ;
232230 for ( let index = 0 ; index < args . length ; index ++ ) {
@@ -372,7 +370,7 @@ export class DashPathEffect {
372370 }
373371 get ( target , name , receiver ) {
374372 const native = this . _native ;
375- if ( native [ name ] ) {
373+ if ( native && native [ name ] ) {
376374 return function ( ...args ) {
377375 const methodName = name ;
378376 return native [ methodName ] ( ...args ) ;
@@ -394,7 +392,7 @@ export class Path {
394392 }
395393 get ( target , name , receiver ) {
396394 const native = this . _native ;
397- if ( native [ name ] ) {
395+ if ( native && native [ name ] ) {
398396 return function ( ...args ) {
399397 const methodName = name ;
400398 for ( let index = 0 ; index < args . length ; index ++ ) {
@@ -423,7 +421,7 @@ export class RadialGradient {
423421 }
424422 get ( target , name , receiver ) {
425423 const native = this . _native ;
426- if ( native [ name ] ) {
424+ if ( native && native [ name ] ) {
427425 return function ( ...args ) {
428426 const methodName = name ;
429427 return native [ methodName ] ( ...args ) ;
@@ -463,7 +461,7 @@ export class LinearGradient {
463461 }
464462 get ( target , name , receiver ) {
465463 const native = this . _native ;
466- if ( native [ name ] ) {
464+ if ( native && native [ name ] ) {
467465 return function ( ...args ) {
468466 const methodName = name ;
469467 return native [ methodName ] ( ...args ) ;
@@ -488,7 +486,7 @@ export class BitmapShader {
488486 }
489487 get ( target , name , receiver ) {
490488 const native = this . _native ;
491- if ( native [ name ] ) {
489+ if ( native && native [ name ] ) {
492490 return function ( ...args ) {
493491 const methodName = name ;
494492 return native [ methodName ] ( ...args ) ;
@@ -517,7 +515,7 @@ export class StaticLayout {
517515 }
518516 get ( target , name , receiver ) {
519517 const native = this . _native ;
520- if ( native [ name ] ) {
518+ if ( native && native [ name ] ) {
521519 return function ( ...args ) {
522520 const methodName = name ;
523521 for ( let index = 0 ; index < args . length ; index ++ ) {
0 commit comments