@@ -5,12 +5,8 @@ import { WebGLRenderingContext } from '../WebGL/WebGLRenderingContext';
55import { WebGL2RenderingContext } from '../WebGL2/WebGL2RenderingContext' ;
66import { Application , View , profile } from '@nativescript/core' ;
77
8- declare var com ;
9-
108export function createSVGMatrix ( ) : DOMMatrix {
11- return new DOMMatrix (
12- com . github . triniwiz . canvas . CanvasView . createSVGMatrix ( )
13- ) ;
9+ return new DOMMatrix ( org . nativescript . canvas . TNSCanvas . createSVGMatrix ( ) ) ;
1410}
1511
1612export * from './common' ;
@@ -30,9 +26,8 @@ export class Canvas extends CanvasBase {
3026 useCpu = arguments [ 0 ] ;
3127 }
3228 }
33- const activity =
34- Application . android . foregroundActivity || Application . android . startActivity ;
35- this . _canvas = new com . github . triniwiz . canvas . TNSCanvas ( activity , useCpu ) ;
29+ const activity = Application . android . foregroundActivity || Application . android . startActivity ;
30+ this . _canvas = new org . nativescript . canvas . TNSCanvas ( activity , useCpu ) ;
3631 ( global as any ) . __canvasLoaded = true ;
3732 }
3833
@@ -52,7 +47,7 @@ export class Canvas extends CanvasBase {
5247 // @ts -ignore
5348 get width ( ) {
5449 if ( this . getMeasuredWidth ( ) > 0 ) {
55- return this . getMeasuredWidth ( )
50+ return this . getMeasuredWidth ( ) ;
5651 }
5752 const width = this . _canvas . getWidth ( ) ;
5853 if ( width === 0 ) {
@@ -109,24 +104,24 @@ export class Canvas extends CanvasBase {
109104 super . initNativeView ( ) ;
110105 const ref = new WeakRef ( this ) ;
111106 this . __handleGestures ( ) ;
112- this . on ( View . layoutChangedEvent , args => {
107+ this . on ( View . layoutChangedEvent , ( args ) => {
113108 const parent = this . parent as any ;
114109 // TODO change DIPs once implemented
115110 if ( parent && parent . clientWidth === undefined && parent . clientHeight === undefined ) {
116111 Object . defineProperty ( parent , 'clientWidth' , {
117112 get : function ( ) {
118113 return parent . getMeasuredWidth ( ) ;
119- }
114+ } ,
120115 } ) ;
121116 Object . defineProperty ( parent , 'clientHeight' , {
122117 get : function ( ) {
123118 return parent . getMeasuredHeight ( ) ;
124- }
119+ } ,
125120 } ) ;
126121 }
127122 } ) ;
128123 this . _canvas . setListener (
129- new com . github . triniwiz . canvas . TNSCanvas . Listener ( {
124+ new org . nativescript . canvas . TNSCanvas . Listener ( {
130125 contextReady ( ) {
131126 const owner = ref . get ( ) as any ;
132127 if ( owner && ! owner . _ready ) {
@@ -180,10 +175,7 @@ export class Canvas extends CanvasBase {
180175
181176 _layoutNative ( ) {
182177 if ( ! this . parent ) {
183- if (
184- ( typeof this . width === 'string' && this . width . indexOf ( '%' ) ) ||
185- ( typeof this . height === 'string' && this . height . indexOf ( '%' ) )
186- ) {
178+ if ( ( typeof this . width === 'string' && this . width . indexOf ( '%' ) ) || ( typeof this . height === 'string' && this . height . indexOf ( '%' ) ) ) {
187179 return ;
188180 }
189181 if ( ! this . _isCustom ) {
@@ -193,11 +185,7 @@ export class Canvas extends CanvasBase {
193185 const size = this . _realSize ;
194186 let rootParams = this . _canvas . getLayoutParams ( ) ;
195187
196- if (
197- rootParams &&
198- ( size . width || 0 ) === rootParams . width &&
199- ( size . height || 0 ) === rootParams . height
200- ) {
188+ if ( rootParams && ( size . width || 0 ) === rootParams . width && ( size . height || 0 ) === rootParams . height ) {
201189 return ;
202190 }
203191
@@ -207,7 +195,7 @@ export class Canvas extends CanvasBase {
207195 }
208196 rootParams . width = size . width ;
209197 rootParams . height = size . height ;
210- let surfaceParams // = this._canvas.getSurface().getLayoutParams();
198+ let surfaceParams ; // = this._canvas.getSurface().getLayoutParams();
211199 if ( ! surfaceParams ) {
212200 surfaceParams = new android . widget . FrameLayout . LayoutParams ( 0 , 0 ) ;
213201 }
@@ -217,28 +205,15 @@ export class Canvas extends CanvasBase {
217205 this . _canvas . setLayoutParams ( rootParams ) ;
218206 //this._canvas.getSurface().setLayoutParams(surfaceParams);
219207
220- const w = android . view . View . MeasureSpec . makeMeasureSpec (
221- size . width ,
222- android . view . View . MeasureSpec . EXACTLY
223- ) ;
224- const h = android . view . View . MeasureSpec . makeMeasureSpec (
225- size . height ,
226- android . view . View . MeasureSpec . EXACTLY
227- ) ;
208+ const w = android . view . View . MeasureSpec . makeMeasureSpec ( size . width , android . view . View . MeasureSpec . EXACTLY ) ;
209+ const h = android . view . View . MeasureSpec . makeMeasureSpec ( size . height , android . view . View . MeasureSpec . EXACTLY ) ;
228210 this . _canvas . measure ( w , h ) ;
229211 this . _canvas . layout ( 0 , 0 , size . width || 0 , size . height || 0 ) ;
230212 }
231213 }
232214 }
233215
234- getContext (
235- type : string ,
236- options ?: any
237- ) :
238- | CanvasRenderingContext2D
239- | WebGLRenderingContext
240- | WebGL2RenderingContext
241- | null {
216+ getContext ( type : string , options ?: any ) : CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | null {
242217 if ( ! this . _canvas ) {
243218 return null ;
244219 }
@@ -247,7 +222,7 @@ export class Canvas extends CanvasBase {
247222 const opts = new java . util . HashMap ( ) ;
248223 Object . keys ( jsOptions ) . forEach ( ( key ) => {
249224 let val = jsOptions [ key ] ;
250- if ( typeof val === " boolean" ) {
225+ if ( typeof val === ' boolean' ) {
251226 opts . put ( key , java . lang . Boolean . valueOf ( String ( val ) ) ) ;
252227 } else {
253228 opts . put ( key , val ) ;
@@ -262,9 +237,7 @@ export class Canvas extends CanvasBase {
262237 return null ;
263238 }
264239 if ( ! this . _2dContext ) {
265- this . _2dContext = new CanvasRenderingContext2D (
266- this . _canvas . getContext ( type , getNativeOptions ( options ) )
267- ) ;
240+ this . _2dContext = new CanvasRenderingContext2D ( this . _canvas . getContext ( type , getNativeOptions ( options ) ) ) ;
268241 // @ts -ignore
269242 this . _2dContext . _canvas = this ;
270243 } else {
@@ -278,26 +251,19 @@ export class Canvas extends CanvasBase {
278251 return null ;
279252 }
280253 if ( ! this . _webglContext ) {
281- this . _webglContext = new WebGLRenderingContext (
282- this . _canvas . getContext ( 'webgl' , getNativeOptions ( options ) )
283- ) ;
254+ this . _webglContext = new WebGLRenderingContext ( this . _canvas . getContext ( 'webgl' , getNativeOptions ( options ) ) ) ;
284255 this . _webglContext . _canvas = this ;
285256 } else {
286257 this . _canvas . getContext ( 'webgl' , getNativeOptions ( options ) ) ;
287258 }
288259 this . _webglContext . _type = 'webgl' ;
289260 return this . _webglContext ;
290- } else if (
291- type &&
292- ( type === 'webgl2' || type === 'experimental-webgl2' )
293- ) {
261+ } else if ( type && ( type === 'webgl2' || type === 'experimental-webgl2' ) ) {
294262 if ( this . _2dContext || this . _webglContext ) {
295263 return null ;
296264 }
297265 if ( ! this . _webgl2Context ) {
298- this . _webgl2Context = new WebGL2RenderingContext (
299- this . android . getContext ( 'webgl2' , getNativeOptions ( options ) )
300- ) ;
266+ this . _webgl2Context = new WebGL2RenderingContext ( this . android . getContext ( 'webgl2' , getNativeOptions ( options ) ) ) ;
301267 ( this . _webgl2Context as any ) . _canvas = this ;
302268 } else {
303269 this . android . getContext ( 'webgl2' , getNativeOptions ( options ) ) ;
0 commit comments