@@ -3,7 +3,7 @@ import { DOMMatrix } from '../Canvas2D';
33import { CanvasRenderingContext2D } from '../Canvas2D/CanvasRenderingContext2D' ;
44import { WebGLRenderingContext } from '../WebGL/WebGLRenderingContext' ;
55import { WebGL2RenderingContext } from '../WebGL2/WebGL2RenderingContext' ;
6- import { Utils , profile } from " @nativescript/core" ;
6+ import { Utils , profile } from ' @nativescript/core' ;
77
88declare var TNSCanvas , TNSCanvasListener ;
99
@@ -22,30 +22,29 @@ export class Canvas extends CanvasBase {
2222
2323 constructor ( useCpu = false ) {
2424 super ( ) ;
25- this . _canvas = TNSCanvas . alloc ( ) . initWithFrameUseCpu (
26- CGRectZero ,
27- useCpu
28- ) ;
29- console . dir ( this . _canvas ) ;
25+ this . _canvas = TNSCanvas . alloc ( ) . initWithFrameUseCpu ( CGRectZero , useCpu ) ;
3026 const ref = new WeakRef ( this ) ;
31- const listener = ( NSObject as any ) . extend ( {
32- contextReady ( ) {
33- if ( ! this . _isReady ) {
34- const owner = ref . get ( ) ;
35- if ( owner ) {
36- owner . _readyEvent ( ) ;
37- this . _isReady = true ;
27+ const listener = ( NSObject as any ) . extend (
28+ {
29+ contextReady ( ) {
30+ if ( ! this . _isReady ) {
31+ const owner = ref . get ( ) ;
32+ if ( owner ) {
33+ owner . _readyEvent ( ) ;
34+ this . _isReady = true ;
35+ }
3836 }
39- }
37+ } ,
38+ } ,
39+ {
40+ protocols : [ TNSCanvasListener ] ,
4041 }
41- } , {
42- protocols : [ TNSCanvasListener ]
43- } ) ;
42+ ) ;
4443 this . _readyListener = listener . new ( ) ;
4544 this . _canvas . setListener ( this . _readyListener ) ;
4645 }
4746
48- [ ignorePixelScalingProperty . setNative ] ( value : boolean ) {
47+ [ ignorePixelScalingProperty . setNative ] ( value : boolean ) {
4948 this . _canvas . ignorePixelScaling = value ;
5049 }
5150
@@ -128,12 +127,12 @@ export class Canvas extends CanvasBase {
128127 Object . defineProperty ( parent , 'clientWidth' , {
129128 get : function ( ) {
130129 return parent . getMeasuredWidth ( ) ;
131- }
130+ } ,
132131 } ) ;
133132 Object . defineProperty ( parent , 'clientHeight' , {
134133 get : function ( ) {
135134 return parent . getMeasuredHeight ( ) ;
136- }
135+ } ,
137136 } ) ;
138137 }
139138 }
@@ -178,10 +177,7 @@ export class Canvas extends CanvasBase {
178177
179178 _layoutNative ( ) {
180179 if ( ! this . parent ) {
181- if (
182- ( typeof this . style . width === 'string' && this . style . width . indexOf ( '%' ) ) ||
183- ( typeof this . style . height === 'string' && this . style . height . indexOf ( '%' ) )
184- ) {
180+ if ( ( typeof this . style . width === 'string' && this . style . width . indexOf ( '%' ) ) || ( typeof this . style . height === 'string' && this . style . height . indexOf ( '%' ) ) ) {
185181 return ;
186182 }
187183 if ( ! this . _isCustom ) {
@@ -201,27 +197,14 @@ export class Canvas extends CanvasBase {
201197 }
202198
203199 const frame_origin = this . _canvas . frame . origin ;
204- const frame = CGRectMake (
205- frame_origin . x ,
206- frame_origin . y ,
207- width ,
208- height
209- ) ;
200+ const frame = CGRectMake ( frame_origin . x , frame_origin . y , width , height ) ;
210201 this . _canvas . frame = frame ;
211202 this . _canvas . setNeedsLayout ( ) ;
212203 this . _canvas . layoutIfNeeded ( ) ;
213204 }
214205 }
215206
216-
217- getContext (
218- type : string ,
219- options ?: any
220- ) :
221- | CanvasRenderingContext2D
222- | WebGLRenderingContext
223- | WebGL2RenderingContext
224- | null {
207+ getContext ( type : string , options ?: any ) : CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | null {
225208 if ( ! this . _canvas ) {
226209 return null ;
227210 }
@@ -230,9 +213,7 @@ export class Canvas extends CanvasBase {
230213 return null ;
231214 }
232215 if ( ! this . _2dContext ) {
233- this . _2dContext = new CanvasRenderingContext2D (
234- this . _canvas . getContextContextAttributes ( type , this . _handleContextOptions ( type , options ) )
235- ) ;
216+ this . _2dContext = new CanvasRenderingContext2D ( this . _canvas . getContextContextAttributes ( type , this . _handleContextOptions ( type , options ) ) ) ;
236217 this . _2dContext . _canvas = this ;
237218 } else {
238219 this . _canvas . getContextContextAttributes ( type , this . _handleContextOptions ( type , options ) ) ;
@@ -244,9 +225,7 @@ export class Canvas extends CanvasBase {
244225 return null ;
245226 }
246227 if ( ! this . _webglContext ) {
247- this . _webglContext = new WebGLRenderingContext (
248- this . _canvas . getContextContextAttributes ( 'webgl' , this . _handleContextOptions ( type , options ) )
249- ) ;
228+ this . _webglContext = new WebGLRenderingContext ( this . _canvas . getContextContextAttributes ( 'webgl' , this . _handleContextOptions ( type , options ) ) ) ;
250229 this . _webglContext . _canvas = this ;
251230 } else {
252231 this . _canvas . getContextContextAttributes ( 'webgl' , this . _handleContextOptions ( type , options ) ) ;
@@ -258,9 +237,7 @@ export class Canvas extends CanvasBase {
258237 return null ;
259238 }
260239 if ( ! this . _webgl2Context ) {
261- this . _webgl2Context = new WebGL2RenderingContext (
262- this . _canvas . getContextContextAttributes ( 'webgl2' , this . _handleContextOptions ( type , options ) )
263- ) ;
240+ this . _webgl2Context = new WebGL2RenderingContext ( this . _canvas . getContextContextAttributes ( 'webgl2' , this . _handleContextOptions ( type , options ) ) ) ;
264241 ( this . _webgl2Context as any ) . _canvas = this ;
265242 } else {
266243 this . _canvas . getContextContextAttributes ( 'webgl2' , this . _handleContextOptions ( type , options ) ) ;
0 commit comments