From 52ca1c550bc13034c49ed30603b5b3af4510169b Mon Sep 17 00:00:00 2001 From: ienaga Date: Fri, 26 Jul 2024 09:11:44 +0900 Subject: [PATCH] =?UTF-8?q?#154=20feat:=20WebGL=E3=81=AE=E3=83=91=E3=83=83?= =?UTF-8?q?=E3=82=B1=E3=83=BC=E3=82=B8=E3=82=92=E7=A7=BB=E8=A1=8C(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/webgl/package.json | 3 - packages/webgl/src/BezierConverter.ts | 4 +- packages/webgl/src/CanvasGradientToWebGL.ts | 2 +- packages/webgl/src/CanvasToWebGLContext.ts | 67 ++-- .../webgl/src/CanvasToWebGLContextBlend.ts | 50 ++- .../webgl/src/CanvasToWebGLContextGrid.ts | 13 +- .../webgl/src/CanvasToWebGLContextMask.ts | 4 +- .../webgl/src/CanvasToWebGLContextPath.ts | 2 +- .../webgl/src/CanvasToWebGLContextStyle.ts | 9 +- packages/webgl/src/ColorBufferPool.ts | 15 +- packages/webgl/src/Const.ts | 16 - packages/webgl/src/FrameBufferManager.ts | 11 +- packages/webgl/src/StencilBufferPool.ts | 4 +- packages/webgl/src/TextureManager.ts | 2 +- .../webgl/src/VertexArrayObjectManager.ts | 4 +- packages/webgl/src/WebGLFillMeshGenerator.ts | 7 +- .../webgl/src/WebGLStrokeMeshGenerator.ts | 13 +- packages/webgl/src/WebGLUtil.ts | 310 ++++++++++++++++++ .../webgl/src/shader/CanvasToWebGLShader.ts | 6 +- .../webgl/src/shader/GradientLUTGenerator.ts | 9 +- .../webgl/src/shader/WebGLShaderInstance.ts | 1 - .../webgl/src/shader/WebGLShaderUniform.ts | 13 +- .../FragmentShaderSourceGradientLUT.ts | 6 +- .../FragmentShaderSourceConvolutionFilter.ts | 7 +- .../filter/FragmentShaderSourceFilter.ts | 5 +- .../variants/BlendShaderVariantCollection.ts | 5 +- .../variants/FilterShaderVariantCollection.ts | 10 +- .../GradientLUTShaderVariantCollection.ts | 8 +- .../GradientShapeShaderVariantCollection.ts | 3 +- .../variants/ShapeShaderVariantCollection.ts | 3 +- 30 files changed, 431 insertions(+), 181 deletions(-) delete mode 100644 packages/webgl/src/Const.ts create mode 100644 packages/webgl/src/WebGLUtil.ts diff --git a/packages/webgl/package.json b/packages/webgl/package.json index d25f75cb..ff929d6c 100644 --- a/packages/webgl/package.json +++ b/packages/webgl/package.json @@ -24,8 +24,5 @@ "repository": { "type": "git", "url": "git+https://github.com/Next2D/Player.git" - }, - "peerDependencies": { - "@next2d/share": "file:../share" } } diff --git a/packages/webgl/src/BezierConverter.ts b/packages/webgl/src/BezierConverter.ts index d3d5f38d..cc899048 100644 --- a/packages/webgl/src/BezierConverter.ts +++ b/packages/webgl/src/BezierConverter.ts @@ -1,5 +1,3 @@ -import { $Float32Array } from "@next2d/share"; - /** * @class */ @@ -13,7 +11,7 @@ export class BezierConverter */ constructor () { - this._$bezierConverterBuffer = new $Float32Array(32); + this._$bezierConverterBuffer = new Float32Array(32); } /** diff --git a/packages/webgl/src/CanvasGradientToWebGL.ts b/packages/webgl/src/CanvasGradientToWebGL.ts index 19ad0489..486e270a 100644 --- a/packages/webgl/src/CanvasGradientToWebGL.ts +++ b/packages/webgl/src/CanvasGradientToWebGL.ts @@ -7,7 +7,7 @@ import { $clamp, $poolInt32Array4, $poolFloat32Array6 -} from "@next2d/share"; +} from "./WebGLUtil"; /** * @class diff --git a/packages/webgl/src/CanvasToWebGLContext.ts b/packages/webgl/src/CanvasToWebGLContext.ts index d39e0627..8c69b8c9 100644 --- a/packages/webgl/src/CanvasToWebGLContext.ts +++ b/packages/webgl/src/CanvasToWebGLContext.ts @@ -10,7 +10,6 @@ import { CanvasToWebGLContextBlend } from "./CanvasToWebGLContextBlend"; import { CanvasPatternToWebGL } from "./CanvasPatternToWebGL"; import { CanvasGradientToWebGL } from "./CanvasGradientToWebGL"; import { WebGLFillMeshGenerator } from "./WebGLFillMeshGenerator"; -import { $setRenderSize } from "./Const"; import type { CanvasToWebGLShader } from "./shader/CanvasToWebGLShader"; import type { GradientShapeShaderVariantCollection } from "./shader/variants/GradientShapeShaderVariantCollection"; import type { ShapeShaderVariantCollection } from "./shader/variants/ShapeShaderVariantCollection"; @@ -29,16 +28,14 @@ import type { CapsStyleImpl } from "./interface/CapsStyleImpl"; import type { JointStyleImpl } from "./interface/JointStyleImpl"; import type { CachePositionImpl } from "./interface/CachePositionImpl"; import { - $Math, + $setRenderSize, $getFloat32Array9, $getArray, $clamp, $poolArray, $inverseMatrix, - $poolFloat32Array9, - $poolBoundsObject, - $getBoundsObject -} from "@next2d/share"; + $poolFloat32Array9 +} from "./WebGLUtil"; /** * @class @@ -98,7 +95,7 @@ export class CanvasToWebGLContext * @type {number} * @private */ - const samples: number = $Math.min( + const samples: number = Math.min( sample, gl.getParameter(gl.MAX_SAMPLES) ); @@ -107,7 +104,7 @@ export class CanvasToWebGLContext * @type {number} * @private */ - this._$maxTextureSize = $Math.min(8192, + this._$maxTextureSize = Math.min(8192, gl.getParameter(gl.MAX_TEXTURE_SIZE) ) - 2; @@ -121,7 +118,12 @@ export class CanvasToWebGLContext * @type {BoundsImpl} * @private */ - this._$cacheBounds = $getBoundsObject(); + this._$cacheBounds = { + "xMin": 0, + "yMin": 0, + "xMax": 0, + "yMax": 0 + }; /** * @type {Float32Array} @@ -296,7 +298,12 @@ export class CanvasToWebGLContext * @type {object} * @private */ - this._$maskBounds = $getBoundsObject(0, 0, 0, 0); + this._$maskBounds = { + "xMin": 0, + "yMin": 0, + "xMax": 0, + "yMax": 0 + }; /** * @type {object} @@ -575,7 +582,7 @@ export class CanvasToWebGLContext */ _$getTextureScale (width: number, height: number): number { - const maxSize = $Math.max(width, height); + const maxSize = Math.max(width, height); if (maxSize > this._$maxTextureSize) { return this._$maxTextureSize / maxSize; } @@ -1462,10 +1469,10 @@ export class CanvasToWebGLContext return false; } - this._$maskBounds.xMin = $Math.max(0, $Math.min(this._$maskBounds.xMin, x)); - this._$maskBounds.yMin = $Math.max(0, $Math.min(this._$maskBounds.yMin, y)); - this._$maskBounds.xMax = $Math.min(currentAttachment.width, $Math.min(this._$maskBounds.xMax, width)); - this._$maskBounds.yMax = $Math.min(currentAttachment.height, $Math.min(this._$maskBounds.yMax, height)); + this._$maskBounds.xMin = Math.max(0, Math.min(this._$maskBounds.xMin, x)); + this._$maskBounds.yMin = Math.max(0, Math.min(this._$maskBounds.yMin, y)); + this._$maskBounds.xMax = Math.min(currentAttachment.width, Math.min(this._$maskBounds.xMax, width)); + this._$maskBounds.yMax = Math.min(currentAttachment.height, Math.min(this._$maskBounds.yMax, height)); return true; } @@ -1550,9 +1557,9 @@ export class CanvasToWebGLContext const strokeStyle: Float32Array|CanvasGradientToWebGL|CanvasPatternToWebGL = this.strokeStyle; - let face: number = $Math.sign(matrix[0] * matrix[4]); + let face: number = Math.sign(matrix[0] * matrix[4]); if (face > 0 && matrix[1] !== 0 && matrix[3] !== 0) { - face = -$Math.sign(matrix[1] * matrix[3]); + face = -Math.sign(matrix[1] * matrix[3]); } let lineWidth: number = this.lineWidth * 0.5; @@ -1560,17 +1567,17 @@ export class CanvasToWebGLContext let scaleY: number; if (this._$grid.enabled) { // lineWidth *= $getSameScaleBase(); - scaleX = $Math.abs(this._$grid.ancestorMatrixA + this._$grid.ancestorMatrixD); - scaleY = $Math.abs(this._$grid.ancestorMatrixB + this._$grid.ancestorMatrixE); + scaleX = Math.abs(this._$grid.ancestorMatrixA + this._$grid.ancestorMatrixD); + scaleY = Math.abs(this._$grid.ancestorMatrixB + this._$grid.ancestorMatrixE); } else { - scaleX = $Math.abs(matrix[0] + matrix[3]); - scaleY = $Math.abs(matrix[1] + matrix[4]); + scaleX = Math.abs(matrix[0] + matrix[3]); + scaleY = Math.abs(matrix[1] + matrix[4]); } - const scaleMin: number = $Math.min(scaleX, scaleY); - const scaleMax: number = $Math.max(scaleX, scaleY); - lineWidth *= scaleMax * (1 - 0.3 * $Math.cos($Math.PI * 0.5 * (scaleMin / scaleMax))); - lineWidth = $Math.max(1, lineWidth); + const scaleMin: number = Math.min(scaleX, scaleY); + const scaleMax: number = Math.max(scaleX, scaleY); + lineWidth *= scaleMax * (1 - 0.3 * Math.cos(Math.PI * 0.5 * (scaleMin / scaleMax))); + lineWidth = Math.max(1, lineWidth); const hasGrid: boolean = this._$grid.enabled; @@ -1903,7 +1910,7 @@ export class CanvasToWebGLContext .textureManager .bind0(texture, true); - const halfBlur: number = $Math.ceil(blur * 0.5); + const halfBlur: number = Math.ceil(blur * 0.5); const fraction: number = 1 - (halfBlur - blur * 0.5); const samples: number = 1 + blur; @@ -2267,11 +2274,7 @@ export class CanvasToWebGLContext */ _$endLayer (): void { - const bounds: BoundsImpl | void = this._$positions.pop(); - if (bounds) { - $poolBoundsObject(bounds); - } - + this._$positions.pop(); this._$isLayer = !!this._$blends.pop(); } @@ -2340,7 +2343,7 @@ export class CanvasToWebGLContext */ textureScale (width: number, height: number): number { - const maxSize = $Math.max(width, height); + const maxSize = Math.max(width, height); if (maxSize > this._$maxTextureSize) { return this._$maxTextureSize / maxSize; } diff --git a/packages/webgl/src/CanvasToWebGLContextBlend.ts b/packages/webgl/src/CanvasToWebGLContextBlend.ts index bac6c241..5282ece6 100644 --- a/packages/webgl/src/CanvasToWebGLContextBlend.ts +++ b/packages/webgl/src/CanvasToWebGLContextBlend.ts @@ -7,11 +7,7 @@ import type { BlendShaderVariantCollection } from "./shader/variants/BlendShader import type { BlendModeImpl } from "./interface/BlendModeImpl"; import type { AttachmentImpl } from "./interface/AttachmentImpl"; import type { CachePositionImpl } from "./interface/CachePositionImpl"; -import { - $Math, - $Number, - $inverseMatrix -} from "@next2d/share"; +import { $inverseMatrix } from "./WebGLUtil"; /** * @class @@ -481,8 +477,8 @@ export class CanvasToWebGLContextBlend withCT, ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7 ); - const width: number = $Math.abs(x_max - x_min); - const height: number = $Math.abs(y_max - y_min); + const width: number = Math.abs(x_max - x_min); + const height: number = Math.abs(y_max - y_min); this._$gl.enable(this._$gl.SCISSOR_TEST); this._$gl.scissor(x_min, render_height - (y_min + height), width, height); @@ -578,37 +574,37 @@ export class CanvasToWebGLContextBlend const y2: number = +(left * b + bottom * d + ty); const y3: number = +(left * b + top * d + ty); - const no: number = $Number.MAX_VALUE; - const xMin: number = +$Math.min($Math.min($Math.min($Math.min( no, x0), x1), x2), x3); - const xMax: number = +$Math.max($Math.max($Math.max($Math.max(-no, x0), x1), x2), x3); - const yMin: number = +$Math.min($Math.min($Math.min($Math.min( no, y0), y1), y2), y3); - const yMax: number = +$Math.max($Math.max($Math.max($Math.max(-no, y0), y1), y2), y3); + const no: number = Number.MAX_VALUE; + const xMin: number = +Math.min(Math.min(Math.min(Math.min( no, x0), x1), x2), x3); + const xMax: number = +Math.max(Math.max(Math.max(Math.max(-no, x0), x1), x2), x3); + const yMin: number = +Math.min(Math.min(Math.min(Math.min( no, y0), y1), y2), y3); + const yMax: number = +Math.max(Math.max(Math.max(Math.max(-no, y0), y1), y2), y3); - const sx: number = $Math.max(0, xMin); - const sy: number = $Math.max(0, yMin); - const sw: number = $Math.min($Math.max(0, renderWidth - sx), $Math.ceil($Math.abs(xMax - xMin))); - const sh: number = $Math.min($Math.max(0, renderHeight - sy), $Math.ceil($Math.abs(yMax - yMin))); + const sx: number = Math.max(0, xMin); + const sy: number = Math.max(0, yMin); + const sw: number = Math.min(Math.max(0, renderWidth - sx), Math.ceil(Math.abs(xMax - xMin))); + const sh: number = Math.min(Math.max(0, renderHeight - sy), Math.ceil(Math.abs(yMax - yMin))); if (!sw || !sh) { return ; } this._$gl.enable(this._$gl.SCISSOR_TEST); - this._$gl.scissor(sx, $Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1); + this._$gl.scissor(sx, Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1); } else { - const sx: number = $Math.max(0, x + tx); - const sy: number = $Math.max(0, y + ty); - const sw: number = $Math.min($Math.max(0, renderWidth - sx), w); - const sh: number = $Math.min($Math.max(0, renderHeight - sy), h); + const sx: number = Math.max(0, x + tx); + const sy: number = Math.max(0, y + ty); + const sw: number = Math.min(Math.max(0, renderWidth - sx), w); + const sh: number = Math.min(Math.max(0, renderHeight - sy), h); if (!sw || !sh) { return ; } this._$gl.enable(this._$gl.SCISSOR_TEST); - this._$gl.scissor(sx, $Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1); + this._$gl.scissor(sx, Math.max(0, renderHeight - (sy + sh)), sw + 1, sh + 1); } this.toOperation(operation); @@ -620,10 +616,10 @@ export class CanvasToWebGLContextBlend default: { - const sx: number = $Math.max(0, x + matrix[6]); - const sy: number = $Math.max(0, y + matrix[7]); - const sw: number = $Math.min($Math.max(0, renderWidth - sx), w); - const sh: number = $Math.min($Math.max(0, renderHeight - sy), h); + const sx: number = Math.max(0, x + matrix[6]); + const sy: number = Math.max(0, y + matrix[7]); + const sw: number = Math.min(Math.max(0, renderWidth - sx), w); + const sh: number = Math.min(Math.max(0, renderHeight - sy), h); if (!sw || !sh) { return ; @@ -667,7 +663,7 @@ export class CanvasToWebGLContextBlend ); this._$gl.enable(this._$gl.SCISSOR_TEST); - this._$gl.scissor(sx, $Math.max(0, renderHeight - (sy + sh)), sw, sh); + this._$gl.scissor(sx, Math.max(0, renderHeight - (sy + sh)), sw, sh); this.toOneZero(); shader._$drawImage(); diff --git a/packages/webgl/src/CanvasToWebGLContextGrid.ts b/packages/webgl/src/CanvasToWebGLContextGrid.ts index 4ae654a1..73a3e3e7 100644 --- a/packages/webgl/src/CanvasToWebGLContextGrid.ts +++ b/packages/webgl/src/CanvasToWebGLContextGrid.ts @@ -1,6 +1,5 @@ import type { BoundsImpl } from "./interface/BoundsImpl"; import type { GridImpl } from "./interface/GridImpl"; -import { $Math } from "@next2d/share"; /** * @class @@ -301,8 +300,8 @@ export class CanvasToWebGLContextGrid const gridWidth: number = grid.w; const gridHeight: number = grid.h; - const sameWidth: number = $Math.abs($Math.ceil(boundsWidth * same_scale)); - const sameHeight: number = $Math.abs($Math.ceil(boundsHeight * same_scale)); + const sameWidth: number = Math.abs(Math.ceil(boundsWidth * same_scale)); + const sameHeight: number = Math.abs(Math.ceil(boundsHeight * same_scale)); // 等倍サイズでの正規化grid const minXST: number = gridWidth > 0 ? (grid.x - bounds.xMin) / boundsWidth : 0.00001; @@ -318,14 +317,14 @@ export class CanvasToWebGLContextGrid if (minXPQ >= maxXPQ) { const m: number = minXST / (minXST + (1 - maxXST)); - minXPQ = $Math.max(m - 0.00001, 0); - maxXPQ = $Math.min(m + 0.00001, 1); + minXPQ = Math.max(m - 0.00001, 0); + maxXPQ = Math.min(m + 0.00001, 1); } if (minYPQ >= maxYPQ) { const m: number = minYST / (minYST + (1 - maxYST)); - minYPQ = $Math.max(m - 0.00001, 0); - maxYPQ = $Math.min(m + 0.00001, 1); + minYPQ = Math.max(m - 0.00001, 0); + maxYPQ = Math.min(m + 0.00001, 1); } this.enabled = true; diff --git a/packages/webgl/src/CanvasToWebGLContextMask.ts b/packages/webgl/src/CanvasToWebGLContextMask.ts index e3cabd8f..29485e33 100644 --- a/packages/webgl/src/CanvasToWebGLContextMask.ts +++ b/packages/webgl/src/CanvasToWebGLContextMask.ts @@ -1,4 +1,3 @@ -import { WebGLFillMeshGenerator } from "./WebGLFillMeshGenerator"; import type { CanvasToWebGLContext } from "./CanvasToWebGLContext"; import type { ShapeShaderVariantCollection } from "./shader/variants/ShapeShaderVariantCollection"; import type { CanvasToWebGLShader } from "./shader/CanvasToWebGLShader"; @@ -6,7 +5,8 @@ import type { WebGLShaderUniform } from "./shader/WebGLShaderUniform"; import type { AttachmentImpl } from "./interface/AttachmentImpl"; import type { ClipObjectImpl } from "./interface/ClipObjectImpl"; import type { IndexRangeImpl } from "./interface/IndexRangeImpl"; -import { $poolArray } from "@next2d/share"; +import { WebGLFillMeshGenerator } from "./WebGLFillMeshGenerator"; +import { $poolArray } from "./WebGLUtil"; /** * @class diff --git a/packages/webgl/src/CanvasToWebGLContextPath.ts b/packages/webgl/src/CanvasToWebGLContextPath.ts index 93d034e7..f0e4703a 100644 --- a/packages/webgl/src/CanvasToWebGLContextPath.ts +++ b/packages/webgl/src/CanvasToWebGLContextPath.ts @@ -3,7 +3,7 @@ import type { VerticesImpl } from "./interface/VerticesImpl"; import { $getArray, $poolArray -} from "@next2d/share"; +} from "./WebGLUtil"; /** * @class diff --git a/packages/webgl/src/CanvasToWebGLContextStyle.ts b/packages/webgl/src/CanvasToWebGLContextStyle.ts index 2a14f3fe..f735b1c1 100644 --- a/packages/webgl/src/CanvasToWebGLContextStyle.ts +++ b/packages/webgl/src/CanvasToWebGLContextStyle.ts @@ -4,9 +4,8 @@ import type { CapsStyleImpl } from "./interface/CapsStyleImpl"; import type { JointStyleImpl } from "./interface/JointStyleImpl"; import { $getFloat32Array4, - $poolFloat32Array4, - $Float32Array -} from "@next2d/share"; + $poolFloat32Array4 +} from "./WebGLUtil"; /** * @class @@ -100,7 +99,7 @@ export class CanvasToWebGLContextStyle } set fillStyle (style: Float32Array|CanvasGradientToWebGL|CanvasPatternToWebGL) { - if (this._$fillStyle instanceof $Float32Array) { + if (this._$fillStyle instanceof Float32Array) { $poolFloat32Array4(this._$fillStyle); } this._$fillStyle = style; @@ -116,7 +115,7 @@ export class CanvasToWebGLContextStyle } set strokeStyle (style: Float32Array|CanvasGradientToWebGL|CanvasPatternToWebGL) { - if (this._$strokeStyle instanceof $Float32Array) { + if (this._$strokeStyle instanceof Float32Array) { $poolFloat32Array4(this._$strokeStyle); } this._$strokeStyle = style; diff --git a/packages/webgl/src/ColorBufferPool.ts b/packages/webgl/src/ColorBufferPool.ts index ca8d83d4..2927ef74 100644 --- a/packages/webgl/src/ColorBufferPool.ts +++ b/packages/webgl/src/ColorBufferPool.ts @@ -1,8 +1,7 @@ import { $getArray, - $Math, $upperPowerOfTwo -} from "@next2d/share"; +} from "./WebGLUtil"; /** * @class @@ -103,8 +102,8 @@ export class ColorBufferPool ): WebGLRenderbuffer { // 128以下で描画崩れが発生する場合がある?ため、256を最小サイズにする - width = $Math.max(256, $upperPowerOfTwo(width)); - height = $Math.max(256, $upperPowerOfTwo(height)); + width = Math.max(256, $upperPowerOfTwo(width)); + height = Math.max(256, $upperPowerOfTwo(height)); const colorBuffer: WebGLRenderbuffer = this._$getColorBuffer(width * height); @@ -117,8 +116,8 @@ export class ColorBufferPool || colorBuffer.samples !== samples ) { - width = $Math.max(width, colorBuffer.width); - height = $Math.max(height, colorBuffer.height); + width = Math.max(width, colorBuffer.width); + height = Math.max(height, colorBuffer.height); colorBuffer.samples = samples; colorBuffer.width = width; @@ -173,8 +172,8 @@ export class ColorBufferPool let ng: number = -1; let ok: number = this._$objectPool.length; - while ($Math.abs(ok - ng) > 1) { - const mid: number = $Math.floor((ok + ng) / 2); + while (Math.abs(ok - ng) > 1) { + const mid: number = Math.floor((ok + ng) / 2); if (area <= this._$objectPool[mid].area) { ok = mid; } else { diff --git a/packages/webgl/src/Const.ts b/packages/webgl/src/Const.ts deleted file mode 100644 index 64a7a362..00000000 --- a/packages/webgl/src/Const.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @type {number} - * @public - */ -export let $RENDER_SIZE: number = 2048; - -/** - * @param {number} size - * @return {void} - * @method - * @public - */ -export const $setRenderSize = (size: number): void => -{ - $RENDER_SIZE = Math.min(4096, size / 2); -}; \ No newline at end of file diff --git a/packages/webgl/src/FrameBufferManager.ts b/packages/webgl/src/FrameBufferManager.ts index 07bdbf4d..5f5a0816 100644 --- a/packages/webgl/src/FrameBufferManager.ts +++ b/packages/webgl/src/FrameBufferManager.ts @@ -1,8 +1,7 @@ import { TextureManager } from "./TextureManager"; import { StencilBufferPool } from "./StencilBufferPool"; import { ColorBufferPool } from "./ColorBufferPool"; -import { $Math } from "@next2d/share"; -import { $RENDER_SIZE } from "./Const"; +import { $RENDER_SIZE } from "./WebGLUtil"; import type { AttachmentImpl } from "./interface/AttachmentImpl"; import type { CachePositionImpl } from "./interface/CachePositionImpl"; @@ -506,10 +505,10 @@ export class FrameBufferManager this._$gl.TEXTURE_2D, texture, 0 ); - const x0: number = $Math.max(0, position.x - 1); - const y0: number = $Math.max(0, position.y - 1); - const x1: number = $Math.min($RENDER_SIZE, position.x + position.w + 1); - const y1: number = $Math.min($RENDER_SIZE, position.y + position.h + 1); + const x0: number = Math.max(0, position.x - 1); + const y0: number = Math.max(0, position.y - 1); + const x1: number = Math.min($RENDER_SIZE, position.x + position.w + 1); + const y1: number = Math.min($RENDER_SIZE, position.y + position.h + 1); this._$gl.blitFramebuffer( x0, y0, x1, y1, diff --git a/packages/webgl/src/StencilBufferPool.ts b/packages/webgl/src/StencilBufferPool.ts index 582b40d7..47fea134 100644 --- a/packages/webgl/src/StencilBufferPool.ts +++ b/packages/webgl/src/StencilBufferPool.ts @@ -1,5 +1,3 @@ -import { $getArray } from "@next2d/share"; - /** * @class */ @@ -27,7 +25,7 @@ export class StencilBufferPool * @type {array} * @private */ - this._$objectPool = $getArray(); + this._$objectPool = []; /** * @type {number} diff --git a/packages/webgl/src/TextureManager.ts b/packages/webgl/src/TextureManager.ts index f64f8281..0589f941 100644 --- a/packages/webgl/src/TextureManager.ts +++ b/packages/webgl/src/TextureManager.ts @@ -1,4 +1,4 @@ -import { $RENDER_SIZE } from "./Const"; +import { $RENDER_SIZE } from "./WebGLUtil"; import type { CachePositionImpl } from "./interface/CachePositionImpl"; import type { GridImpl } from "./interface/GridImpl"; diff --git a/packages/webgl/src/VertexArrayObjectManager.ts b/packages/webgl/src/VertexArrayObjectManager.ts index 8caf8a78..5ae171c0 100644 --- a/packages/webgl/src/VertexArrayObjectManager.ts +++ b/packages/webgl/src/VertexArrayObjectManager.ts @@ -5,9 +5,7 @@ import type { StrokeMethImpl } from "./interface/StrokeMethImpl"; import type { CapsStyleImpl } from "./interface/CapsStyleImpl"; import type { JointStyleImpl } from "./interface/JointStyleImpl"; import type { WebGLShaderInstance } from "./shader/WebGLShaderInstance"; -import { - $upperPowerOfTwo -} from "@next2d/share"; +import { $upperPowerOfTwo } from "./WebGLUtil"; /** * @class diff --git a/packages/webgl/src/WebGLFillMeshGenerator.ts b/packages/webgl/src/WebGLFillMeshGenerator.ts index fa00f54c..64293c89 100644 --- a/packages/webgl/src/WebGLFillMeshGenerator.ts +++ b/packages/webgl/src/WebGLFillMeshGenerator.ts @@ -1,9 +1,6 @@ import type { FillMeshImpl } from "./interface/FillMeshImpl"; import type { IndexRangeImpl } from "./interface/IndexRangeImpl"; -import { - $Float32Array, - $getArray -} from "@next2d/share"; +import { $getArray } from "./WebGLUtil"; /** * @class @@ -37,7 +34,7 @@ export class WebGLFillMeshGenerator vertexBufferLen += (vertices[idx].length / 3 - 2) * 12; } - this._$vertexBufferData = new $Float32Array(vertexBufferLen); + this._$vertexBufferData = new Float32Array(vertexBufferLen); this._$indexRanges = $getArray(); this._$currentIndex = 0; diff --git a/packages/webgl/src/WebGLStrokeMeshGenerator.ts b/packages/webgl/src/WebGLStrokeMeshGenerator.ts index 48c9286e..1508d89e 100644 --- a/packages/webgl/src/WebGLStrokeMeshGenerator.ts +++ b/packages/webgl/src/WebGLStrokeMeshGenerator.ts @@ -1,11 +1,6 @@ import type { StrokeMethImpl } from "./interface/StrokeMethImpl"; import type { JointStyleImpl } from "./interface/JointStyleImpl"; import type { CapsStyleImpl } from "./interface/CapsStyleImpl"; -import { - $Float32Array, - $Int16Array, - $Math -} from "@next2d/share"; /** * @class @@ -33,7 +28,7 @@ export class WebGLStrokeMeshGenerator line_join: JointStyleImpl ): StrokeMethImpl { - this._$vertexBufferData = this._$vertexBufferData || new $Float32Array(1024); + this._$vertexBufferData = this._$vertexBufferData || new Float32Array(1024); this._$vertexBufferPos = 0; this._$indexBufferData = this._$indexBufferData || new Int16Array(256); @@ -68,7 +63,7 @@ export class WebGLStrokeMeshGenerator static _$expandVertexBufferIfNeeded (delta_length: number): void { if (this._$vertexBufferPos + delta_length > this._$vertexBufferData.length) { - const biggerBuffer: Float32Array = new $Float32Array(this._$vertexBufferData.length * 2); + const biggerBuffer: Float32Array = new Float32Array(this._$vertexBufferData.length * 2); biggerBuffer.set(this._$vertexBufferData); this._$vertexBufferData = biggerBuffer; } @@ -84,7 +79,7 @@ export class WebGLStrokeMeshGenerator static _$expandIndexBufferIfNeeded(delta_length: number): void { if (this._$indexBufferPos + delta_length > this._$indexBufferData.length) { - const biggerBuffer: Int16Array = new $Int16Array(this._$indexBufferData.length * 2); + const biggerBuffer: Int16Array = new Int16Array(this._$indexBufferData.length * 2); biggerBuffer.set(this._$indexBufferData); this._$indexBufferData = biggerBuffer; } @@ -306,7 +301,7 @@ export class WebGLStrokeMeshGenerator const bx: number = x3 - x2; const by: number = y3 - y2; const det: number = this._$cross(ax, ay, bx, by); - if ($Math.abs(det) < 0.0001) { + if (Math.abs(det) < 0.0001) { return ; } diff --git a/packages/webgl/src/WebGLUtil.ts b/packages/webgl/src/WebGLUtil.ts new file mode 100644 index 00000000..fb9c8031 --- /dev/null +++ b/packages/webgl/src/WebGLUtil.ts @@ -0,0 +1,310 @@ +/** + * @type {number} + * @public + */ +export let $RENDER_SIZE: number = 2048; + +/** + * @param {number} size + * @return {void} + * @method + * @public + */ +export const $setRenderSize = (size: number): void => +{ + $RENDER_SIZE = Math.min(4096, size / 2); +}; + +/** + * @type {number} + */ +let programId: number = 0; + +/** + * @return {number} + * @method + * @public + */ +export const $getProgramId = (): number => +{ + return programId++; +}; + +/** + * @param {number} value + * @param {number} min + * @param {number} max + * @param {number} [default_value=null] + * @return {number} + * @method + * @public + */ +export const $clamp = ( + value: number, + min: number, max: number, + default_value: number | null = null +): number => { + + const number: number = +value; + + return isNaN(number) && default_value !== null + ? default_value + : Math.min(Math.max(min, isNaN(number) ? 0 : number), max); +}; + +/** + * @type {array} + * @private + */ +const $arrays: any[] = []; + +/** + * @param {array} args + * @return {array} + * @method + * @public + */ +export const $getArray = (...args: any[]): any[] => +{ + const array: any[] = $arrays.pop() || []; + if (args.length) { + array.push(...args); + } + return array; +}; + +/** + * @param {array} array + * @return {void} + * @method + * @public + */ +export const $poolArray = (array: any[] | null = null): void => +{ + if (!array) { + return ; + } + + if (array.length) { + array.length = 0; + } + + $arrays.push(array); +}; + +/** + * @param {number} v + * @return {number} + * @method + * @public + */ +export const $upperPowerOfTwo = (v: number): number => +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v; +}; + +/** + * @type {Float32Array[]} + * @private + */ +const $float32Array4: Float32Array[] = []; + +/** + * @param {number} [f0=0] + * @param {number} [f1=0] + * @param {number} [f2=0] + * @param {number} [f3=0] + * @return {Float32Array} + * @method + * @public + */ +export const $getFloat32Array4 = ( + f0: number = 0, f1: number = 0, + f2: number = 0, f3: number = 0 +): Float32Array => { + + const array: Float32Array = $float32Array4.pop() || new Float32Array(4); + + array[0] = f0; + array[1] = f1; + array[2] = f2; + array[3] = f3; + + return array; +}; + +/** + * @param {Float32Array} array + * @return {void} + * @method + * @public + */ +export const $poolFloat32Array4 = (array: Float32Array): void => +{ + $float32Array4.push(array); +}; + +/** + * @type {Float32Array[]} + * @private + */ +const $float32Array9: Float32Array[] = []; + +/** + * @param {number} [f0=0] + * @param {number} [f1=0] + * @param {number} [f2=0] + * @param {number} [f3=0] + * @param {number} [f4=0] + * @param {number} [f5=0] + * @param {number} [f6=0] + * @param {number} [f7=0] + * @param {number} [f8=0] + * @return {Float32Array} + * @method + * @static + */ +export const $getFloat32Array9 = ( + f0: number = 0, f1: number = 0, f2: number = 0, + f3: number = 0, f4: number = 0, f5: number = 0, + f6: number = 0, f7: number = 0, f8: number = 0 +): Float32Array => { + + const array: Float32Array = $float32Array9.pop() || new Float32Array(9); + + array[0] = f0; + array[1] = f1; + array[2] = f2; + array[3] = f3; + array[4] = f4; + array[5] = f5; + array[6] = f6; + array[7] = f7; + array[8] = f8; + + return array; +}; + +/** + * @param {Float32Array} array + * @return {void} + * @method + * @static + */ +export const $poolFloat32Array9 = (array: Float32Array): void => +{ + $float32Array9.push(array); +}; + +/** + * @param {Float32Array} m + * @returns {Float32Array} + * @method + * @static + */ +export const $inverseMatrix = (m: Float32Array): Float32Array => +{ + const rdet: number = 1 / (m[0] * m[4] - m[3] * m[1]); + const tx: number = m[3] * m[7] - m[4] * m[6]; + const ty: number = m[1] * m[6] - m[0] * m[7]; + + return $getFloat32Array9( + m[4] * rdet, 0 - m[1] * rdet, 0, + 0 - m[3] * rdet, m[0] * rdet, 0, + tx * rdet, ty * rdet, 1 + ); +}; + +/** + * @type {Float32Array[]} + * @private + */ +const $float32Array6: Float32Array[] = []; + +/** + * @param {number} [f0=0] + * @param {number} [f1=0] + * @param {number} [f2=0] + * @param {number} [f3=0] + * @param {number} [f4=0] + * @param {number} [f5=0] + * @return {Float32Array} + * @method + * @static + */ +export const $getFloat32Array6 = ( + f0: number = 0, f1: number = 0, + f2: number = 0, f3: number = 0, + f4: number = 0, f5: number = 0 +): Float32Array => { + + const array: Float32Array = $float32Array6.pop() || new Float32Array(6); + + array[0] = f0; + array[1] = f1; + array[2] = f2; + array[3] = f3; + array[4] = f4; + array[5] = f5; + + return array; +}; + +/** + * @param {Float32Array} array + * @return {void} + * @method + * @static + */ +export const $poolFloat32Array6 = (array: Float32Array): void => +{ + $float32Array6.push(array); +}; + +/** + * @type {Int32Array[]} + * @private + */ +const $int32Array4: Int32Array[] = []; + +/** + * @param {number} [f0=0] + * @param {number} [f1=0] + * @param {number} [f2=0] + * @param {number} [f3=0] + * @return {Float32Array} + * @method + * @static + */ +export const $getInt32Array4 = ( + f0: number = 0, f1: number = 0, + f2: number = 0, f3: number = 0 +): Int32Array => { + + const array: Int32Array = $int32Array4.pop() || new Int32Array(4); + + array[0] = f0; + array[1] = f1; + array[2] = f2; + array[3] = f3; + + return array; +}; + +/** + * @param {Float32Array} array + * @return {void} + * @method + * @static + */ +export const $poolInt32Array4 = (array: Int32Array): void => +{ + $int32Array4.push(array); +}; \ No newline at end of file diff --git a/packages/webgl/src/shader/CanvasToWebGLShader.ts b/packages/webgl/src/shader/CanvasToWebGLShader.ts index 3ab553a1..1383b1e8 100644 --- a/packages/webgl/src/shader/CanvasToWebGLShader.ts +++ b/packages/webgl/src/shader/CanvasToWebGLShader.ts @@ -1,9 +1,9 @@ -import { WebGLShaderUniform } from "./WebGLShaderUniform"; -import { WebGLShaderInstance } from "./WebGLShaderInstance"; import type { CanvasToWebGLContext } from "../CanvasToWebGLContext"; import type { CanvasToWebGLShaderList } from "./CanvasToWebGLShaderList"; import type { IndexRangeImpl } from "../interface/IndexRangeImpl"; -import { $getProgramId } from "@next2d/share"; +import { WebGLShaderUniform } from "./WebGLShaderUniform"; +import { WebGLShaderInstance } from "./WebGLShaderInstance"; +import { $getProgramId } from "../WebGLUtil"; /** * @class diff --git a/packages/webgl/src/shader/GradientLUTGenerator.ts b/packages/webgl/src/shader/GradientLUTGenerator.ts index 7c0ba445..504236f6 100644 --- a/packages/webgl/src/shader/GradientLUTGenerator.ts +++ b/packages/webgl/src/shader/GradientLUTGenerator.ts @@ -3,7 +3,6 @@ import type { GradientLUTShaderVariantCollection } from "./variants/GradientLUTS import type { CanvasToWebGLShader } from "./CanvasToWebGLShader"; import type { WebGLShaderUniform } from "./WebGLShaderUniform"; import type { AttachmentImpl } from "../interface/AttachmentImpl"; -import { $Math } from "@next2d/share"; /** * @class @@ -49,7 +48,7 @@ export class GradientLUTGenerator * @type {number} * @private */ - this._$maxLength = $Math.floor(gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS) * 0.75); + this._$maxLength = Math.floor(gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS) * 0.75); /** * @type {Float32Array} @@ -65,7 +64,7 @@ export class GradientLUTGenerator for (let i: number = 0; i < 256; i++) { const t: number = i / 255; - this._$rgbToLinearTable[i] = $Math.pow(t, 2.23333333); + this._$rgbToLinearTable[i] = Math.pow(t, 2.23333333); this._$rgbIdentityTable[i] = t; } } @@ -108,7 +107,7 @@ export class GradientLUTGenerator for (let begin: number = 0; begin < stopsLength; begin += this._$maxLength - 1) { - const end: number = $Math.min(begin + this._$maxLength, stopsLength); + const end: number = Math.min(begin + this._$maxLength, stopsLength); const shader: CanvasToWebGLShader = variants .getGradientLUTShader(end - begin, is_linear_space); @@ -168,7 +167,7 @@ export class GradientLUTGenerator for (let begin: number = 0; begin < stopsLength; begin += this._$maxLength - 1) { - const end: number = $Math.min(begin + this._$maxLength, stopsLength); + const end: number = Math.min(begin + this._$maxLength, stopsLength); const shader: CanvasToWebGLShader = variants .getGradientLUTShader(end - begin, false); diff --git a/packages/webgl/src/shader/WebGLShaderInstance.ts b/packages/webgl/src/shader/WebGLShaderInstance.ts index a310306c..71f3cdf6 100644 --- a/packages/webgl/src/shader/WebGLShaderInstance.ts +++ b/packages/webgl/src/shader/WebGLShaderInstance.ts @@ -7,7 +7,6 @@ export class WebGLShaderInstance private _$count: number; /** - * @param {WebGL2RenderingContext} gl * @constructor * @public */ diff --git a/packages/webgl/src/shader/WebGLShaderUniform.ts b/packages/webgl/src/shader/WebGLShaderUniform.ts index e3728ffa..c813552b 100644 --- a/packages/webgl/src/shader/WebGLShaderUniform.ts +++ b/packages/webgl/src/shader/WebGLShaderUniform.ts @@ -1,9 +1,4 @@ import type { UniformDataImpl } from "../interface/UniformDataImpl"; -import { - $getMap, - $Float32Array, - $Int32Array -} from "@next2d/share"; /** * @class @@ -38,7 +33,7 @@ export class WebGLShaderUniform * @type {Map} * @private */ - this._$map = $getMap(); + this._$map = new Map(); const activeUniforms: number = this._$gl.getProgramParameter(program, this._$gl.ACTIVE_UNIFORMS); for (let i: number = 0; i < activeUniforms; i++) { @@ -64,13 +59,13 @@ export class WebGLShaderUniform // 可能な限りFloat32Arrayに値をパックして転送するようにする case this._$gl.FLOAT_VEC4: data.method = this._$gl.uniform4fv.bind(this._$gl, location); - data.array = new $Float32Array(4 * info.size); + data.array = new Float32Array(4 * info.size); data.assign = -1; break; case this._$gl.INT_VEC4: data.method = this._$gl.uniform4iv.bind(this._$gl, location); - data.array = new $Int32Array(4 * info.size); + data.array = new Int32Array(4 * info.size); data.assign = -1; break; @@ -78,7 +73,7 @@ export class WebGLShaderUniform // sampler2Dは一度だけ設定するようにする case this._$gl.SAMPLER_2D: data.method = this._$gl.uniform1iv.bind(this._$gl, location); - data.array = new $Int32Array(info.size); + data.array = new Int32Array(info.size); data.assign = 1; break; diff --git a/packages/webgl/src/shader/fragment/FragmentShaderSourceGradientLUT.ts b/packages/webgl/src/shader/fragment/FragmentShaderSourceGradientLUT.ts index 98d93561..19209645 100644 --- a/packages/webgl/src/shader/fragment/FragmentShaderSourceGradientLUT.ts +++ b/packages/webgl/src/shader/fragment/FragmentShaderSourceGradientLUT.ts @@ -1,5 +1,3 @@ -import { $Math } from "@next2d/share"; - /** * @class */ @@ -24,8 +22,8 @@ export class FragmentShaderSourceGradientLUT const i0: number = i - 1; const i1: number = i; - const t0: string = `u_mediump[${stops_length + $Math.floor(i0 / 4)}][${i0 % 4}]`; - const t1: string = `u_mediump[${stops_length + $Math.floor(i1 / 4)}][${i1 % 4}]`; + const t0: string = `u_mediump[${stops_length + Math.floor(i0 / 4)}][${i0 % 4}]`; + const t1: string = `u_mediump[${stops_length + Math.floor(i1 / 4)}][${i1 % 4}]`; const c0: string = `u_mediump[${i0}]`; const c1: string = `u_mediump[${i1}]`; diff --git a/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.ts b/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.ts index aa1760cc..31a96da3 100644 --- a/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.ts +++ b/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.ts @@ -1,5 +1,4 @@ import { FragmentShaderLibrary } from "../FragmentShaderLibrary"; -import { $Math } from "@next2d/share"; /** * @class @@ -22,15 +21,15 @@ export class FragmentShaderSourceConvolutionFilter preserve_alpha: boolean, clamp: boolean ): string { - const halfX: number = $Math.floor(x * 0.5); - const halfY: number = $Math.floor(y * 0.5); + const halfX: number = Math.floor(x * 0.5); + const halfY: number = Math.floor(y * 0.5); const size: number = x * y; let matrixStatement: string = ""; const matrixIndex: number = clamp ? 1 : 2; for (let idx: number = 0; idx < size; ++idx) { - const index: number = matrixIndex + $Math.floor(idx / 4); + const index: number = matrixIndex + Math.floor(idx / 4); const component: number = idx % 4; diff --git a/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceFilter.ts b/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceFilter.ts index bd041fa2..2006defc 100644 --- a/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceFilter.ts +++ b/packages/webgl/src/shader/fragment/filter/FragmentShaderSourceFilter.ts @@ -1,4 +1,3 @@ -import { $Math } from "@next2d/share"; import { FragmentShaderLibrary } from "../FragmentShaderLibrary"; /** @@ -187,7 +186,7 @@ void main() { */ static STATEMENT_GLOW_STRENGTH (offset: number): string { - const index: number = $Math.floor(offset / 4); + const index: number = Math.floor(offset / 4); const component: number = offset % 4; return ` float strength = u_mediump[${index}][${component}]; @@ -294,7 +293,7 @@ void main() { */ static STATEMENT_BEVEL_STRENGTH (offset: number): string { - const index: number = $Math.floor(offset / 4); + const index: number = Math.floor(offset / 4); const component: number = offset % 4; return ` diff --git a/packages/webgl/src/shader/variants/BlendShaderVariantCollection.ts b/packages/webgl/src/shader/variants/BlendShaderVariantCollection.ts index d62ab538..a61a7cbf 100644 --- a/packages/webgl/src/shader/variants/BlendShaderVariantCollection.ts +++ b/packages/webgl/src/shader/variants/BlendShaderVariantCollection.ts @@ -5,8 +5,7 @@ import { FragmentShaderSourceBlend } from "../fragment/FragmentShaderSourceBlend import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext"; import type { WebGLShaderUniform } from "../WebGLShaderUniform"; import type { WebGLShaderInstance } from "../WebGLShaderInstance"; -import { $getMap } from "@next2d/share"; -import { $RENDER_SIZE } from "../../Const"; +import { $RENDER_SIZE } from "../../WebGLUtil"; /** * @class @@ -41,7 +40,7 @@ export class BlendShaderVariantCollection * @type {Map} * @private */ - this._$collection = $getMap(); + this._$collection = new Map(); } /** diff --git a/packages/webgl/src/shader/variants/FilterShaderVariantCollection.ts b/packages/webgl/src/shader/variants/FilterShaderVariantCollection.ts index 8fa7f292..4ad97ec0 100644 --- a/packages/webgl/src/shader/variants/FilterShaderVariantCollection.ts +++ b/packages/webgl/src/shader/variants/FilterShaderVariantCollection.ts @@ -7,10 +7,6 @@ import { FragmentShaderSourceConvolutionFilter } from "../fragment/filter/Fragme import { FragmentShaderSourceDisplacementMapFilter } from "../fragment/filter/FragmentShaderSourceDisplacementMapFilter"; import type { WebGLShaderUniform } from "../WebGLShaderUniform"; import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext"; -import { - $Math, - $getMap -} from "@next2d/share"; /** * @class @@ -45,7 +41,7 @@ export class FilterShaderVariantCollection * @type {Map} * @private */ - this._$collection = $getMap(); + this._$collection = new Map(); } /** @@ -121,7 +117,7 @@ export class FilterShaderVariantCollection mediumpLength += is_glow ? 4 : 8; } - mediumpLength = $Math.ceil(mediumpLength / 4); + mediumpLength = Math.ceil(mediumpLength / 4); const shader: CanvasToWebGLShader = new CanvasToWebGLShader( this._$gl, this._$context, @@ -193,7 +189,7 @@ export class FilterShaderVariantCollection } } - const mediumpLength: number = (clamp ? 1 : 2) + $Math.ceil(x * y / 4); + const mediumpLength: number = (clamp ? 1 : 2) + Math.ceil(x * y / 4); const shader: CanvasToWebGLShader = new CanvasToWebGLShader( this._$gl, this._$context, diff --git a/packages/webgl/src/shader/variants/GradientLUTShaderVariantCollection.ts b/packages/webgl/src/shader/variants/GradientLUTShaderVariantCollection.ts index b5d07923..5b13cc1c 100644 --- a/packages/webgl/src/shader/variants/GradientLUTShaderVariantCollection.ts +++ b/packages/webgl/src/shader/variants/GradientLUTShaderVariantCollection.ts @@ -3,10 +3,6 @@ import { FragmentShaderSourceGradientLUT } from "../fragment/FragmentShaderSourc import { CanvasToWebGLShader } from "../CanvasToWebGLShader"; import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext"; import type { WebGLShaderUniform } from "../WebGLShaderUniform"; -import { - $Math, - $getMap -} from "@next2d/share"; /** * @class @@ -41,7 +37,7 @@ export class GradientLUTShaderVariantCollection * @type {Map} * @private */ - this._$collection = $getMap(); + this._$collection = new Map(); } /** @@ -67,7 +63,7 @@ export class GradientLUTShaderVariantCollection } } - const mediumpLength: number = $Math.ceil(stops_length * 5 / 4); + const mediumpLength: number = Math.ceil(stops_length * 5 / 4); const shader: CanvasToWebGLShader = new CanvasToWebGLShader( this._$gl, this._$context, diff --git a/packages/webgl/src/shader/variants/GradientShapeShaderVariantCollection.ts b/packages/webgl/src/shader/variants/GradientShapeShaderVariantCollection.ts index 0e9da6d6..8cf4b7fa 100644 --- a/packages/webgl/src/shader/variants/GradientShapeShaderVariantCollection.ts +++ b/packages/webgl/src/shader/variants/GradientShapeShaderVariantCollection.ts @@ -5,7 +5,6 @@ import { FragmentShaderSourceGradient } from "../fragment/FragmentShaderSourceGr import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext"; import type { WebGLShaderUniform } from "../WebGLShaderUniform"; import type { CanvasToWebGLContextGrid } from "../../CanvasToWebGLContextGrid"; -import { $getMap } from "@next2d/share"; /** * @class @@ -40,7 +39,7 @@ export class GradientShapeShaderVariantCollection * @type {Map} * @private */ - this._$collection = $getMap(); + this._$collection = new Map(); } /** diff --git a/packages/webgl/src/shader/variants/ShapeShaderVariantCollection.ts b/packages/webgl/src/shader/variants/ShapeShaderVariantCollection.ts index ea8a5722..2826c797 100644 --- a/packages/webgl/src/shader/variants/ShapeShaderVariantCollection.ts +++ b/packages/webgl/src/shader/variants/ShapeShaderVariantCollection.ts @@ -5,7 +5,6 @@ import { FragmentShaderSource } from "../fragment/FragmentShaderSource"; import type { WebGLShaderUniform } from "../WebGLShaderUniform"; import type { CanvasToWebGLContext } from "../../CanvasToWebGLContext"; import type { CanvasToWebGLContextGrid } from "../../CanvasToWebGLContextGrid"; -import { $getMap } from "@next2d/share"; /** * @class @@ -40,7 +39,7 @@ export class ShapeShaderVariantCollection * @type {Map} * @private */ - this._$collection = $getMap(); + this._$collection = new Map(); } /**