Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Feb 17, 2024
1 parent c0c09e5 commit 5b3672d
Show file tree
Hide file tree
Showing 60 changed files with 4,857 additions and 4,905 deletions.
2 changes: 1 addition & 1 deletion packages/canvas-babylon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-babylon",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-media/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-media",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Canvas media",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-phaser-ce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser-ce",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Tools for using Phaser-ce to build native 2D games in NativeScript 👾",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-phaser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Build awesome 2D games with Phaser.js and NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-pixi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-pixi",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Plugin for using pixi.js in NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-polyfill/DOM/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Node {

addEventListener(eventName, listener, thisArg) {
this._checkEmitter();
thisArg = thisArg || this;
thisArg = typeof thisArg === 'object' ? thisArg : this;
if (this.emitter.on) {
this.emitter.on(eventName, listener, thisArg);
} else if (this.emitter.addEventListener) {
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-polyfill/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-polyfill",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js, babylon.js, etc....",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-three/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-three",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "Utilities for using THREE.js on NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions packages/canvas/Canvas/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class Canvas extends CanvasBase {
_didLayout = false;

static useSurface = false;
_renderer;

constructor(nativeInstance?) {
super();
Expand Down Expand Up @@ -286,7 +287,7 @@ export class Canvas extends CanvasBase {
}

if (this._canvas === undefined || this._canvas === null) {
return 0;
return;
}

const size = this._realSize;
Expand Down Expand Up @@ -317,7 +318,7 @@ export class Canvas extends CanvasBase {
}

if (!this._2dContext) {
this._layoutNative();
this._layoutNative(true);
const opts = { ...defaultOpts, ...this._handleContextOptions(type, options), fontColor: this.parent?.style?.color?.android || -16777216 };

const ctx = this._canvas.create2DContext(opts.alpha, opts.antialias, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible, opts.fontColor);
Expand All @@ -339,7 +340,7 @@ export class Canvas extends CanvasBase {
return null;
}
if (!this._webglContext) {
this._layoutNative();
this._layoutNative(true);
const opts = { version: 'v1', ...defaultOpts, ...this._handleContextOptions(type, options) };

this._canvas.initContext(type, opts.alpha, false, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible);
Expand All @@ -356,7 +357,7 @@ export class Canvas extends CanvasBase {
}

if (!this._webgl2Context) {
this._layoutNative();
this._layoutNative(true);
const opts = { version: 'v2', ...defaultOpts, ...this._handleContextOptions(type, options) };

this._canvas.initContext(type, opts.alpha, false, opts.depth, opts.failIfMajorPerformanceCaveat, opts.powerPreference, opts.premultipliedAlpha, opts.preserveDrawingBuffer, opts.stencil, opts.desynchronized, opts.xrCompatible);
Expand Down
37 changes: 35 additions & 2 deletions packages/canvas/WebGL/WebGLRenderingContext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ import { ImageBitmap } from '../../ImageBitmap';

import { Helpers } from '../../helpers';

enum ContextType {
None,
Canvas,
WebGL,
WebGL2,
}

let ctor;

export class WebGLRenderingContextBase extends WebGLRenderingCommon {
Expand Down Expand Up @@ -834,6 +841,20 @@ export class WebGLRenderingContextBase extends WebGLRenderingCommon {
this.native.texImage2D(target, level, internalformat, width, height, border.native);
} else if (border instanceof Canvas) {
this.native.texImage2D(target, level, internalformat, width, height, border.native);

if (global.isAndroid) {
this.native.texImage2D(target, level, internalformat, width, height, border.native);
} else {
if ((border as any)._contextType === ContextType.Canvas) {
if (!(border as any)._renderer) {
(border as any)._renderer = Utils.setupRender();
(border as any)._renderer.createSurface();
}
(border as any)._renderer.texImage2D(target, level, internalformat, width, height, (border as any)._canvas, this.canvas._canvas, this.native.__flipY);
} else {
this.native.texImage2D(target, level, internalformat, width, height, border.native);
}
}
} else if (global.isAndroid && border instanceof android.graphics.Bitmap) {
// todo ios
this.native.texImage2D(target, level, internalformat, width, height, border);
Expand All @@ -855,7 +876,19 @@ export class WebGLRenderingContextBase extends WebGLRenderingCommon {
}
}
} else if (border && typeof border.tagName === 'string' && border.tagName === 'CANVAS' && border._canvas instanceof Canvas) {
this.native.texImage2D(target, level, internalformat, width, height, border._canvas.native);
if (global.isAndroid) {
this.native.texImage2D(target, level, internalformat, width, height, border._canvas.native);
} else {
if (border._canvas._contextType === ContextType.Canvas) {
if (!border._canvas._renderer) {
border._canvas._renderer = Utils.setupRender();
border._canvas._renderer.createSurface();
}
border._canvas._renderer.texImage2D(target, level, internalformat, width, height, border._canvas._canvas, this.canvas._canvas, this.native.__flipY);
} else {
this.native.texImage2D(target, level, internalformat, width, height, border._canvas.native);
}
}
}
}
}
Expand Down Expand Up @@ -1116,4 +1149,4 @@ export class WebGLRenderingContextBase extends WebGLRenderingCommon {
}
}

export class WebGLRenderingContext extends WebGLRenderingContextBase {}
export class WebGLRenderingContext extends WebGLRenderingContextBase {}
2 changes: 1 addition & 1 deletion packages/canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.11",
"description": "DOM Canvas API for NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
Binary file modified packages/canvas/platforms/android/canvas-release.aar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,10 @@ long long canvas_native_context_init_context_with_custom_surface(float width,
float ppi,
int direction);

int64_t canvas_native_context_get_texture_from_2d(int64_t context);

uint32_t canvas_native_context_backend_texture_get_id(int64_t texture);

void canvas_native_context_backend_texture_destroy(int64_t texture);

#endif /* CANVAS_IOS_H */
Binary file not shown.
Loading

0 comments on commit 5b3672d

Please sign in to comment.