@next2d/player 1.14.9 → 1.14.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/player/index.js +5 -3
- package/dist/player/next2d/display/GraphicsGradientFill.d.ts +1 -1
- package/dist/player/next2d/display/GraphicsGradientFill.js +6 -2
- package/dist/player/next2d/display/Loader.d.ts +1 -1
- package/dist/player/player/Next2D.d.ts +1 -2
- package/dist/player/player/Next2D.js +7 -11
- package/package.json +1 -1
- package/dist/interface/ClassNameMap.d.ts +0 -4
- package/dist/interface/ClassNameMap.js +0 -1
- package/dist/interface/RenderDisplayObjectImpl.d.ts +0 -2
- package/dist/interface/RenderDisplayObjectImpl.js +0 -1
- package/dist/interface/TextFormatImpl.d.ts +0 -16
- package/dist/interface/TextFormatImpl.js +0 -1
- package/dist/interface/TextModeImpl.d.ts +0 -1
- package/dist/interface/TextModeImpl.js +0 -1
- package/dist/renderer/RenderDisplayObject.d.ts +0 -129
- package/dist/renderer/RenderDisplayObject.js +0 -567
- package/dist/renderer/RenderDisplayObjectContainer.d.ts +0 -70
- package/dist/renderer/RenderDisplayObjectContainer.js +0 -670
- package/dist/renderer/RenderGlobal.d.ts +0 -76
- package/dist/renderer/RenderGlobal.js +0 -88
- package/dist/renderer/RenderGraphics.d.ts +0 -90
- package/dist/renderer/RenderGraphics.js +0 -597
- package/dist/renderer/RenderPlayer.d.ts +0 -164
- package/dist/renderer/RenderPlayer.js +0 -421
- package/dist/renderer/RenderShape.d.ts +0 -32
- package/dist/renderer/RenderShape.js +0 -104
- package/dist/renderer/RenderTextField.d.ts +0 -119
- package/dist/renderer/RenderTextField.js +0 -709
- package/dist/renderer/RenderVideo.d.ts +0 -59
- package/dist/renderer/RenderVideo.js +0 -272
|
@@ -1,597 +0,0 @@
|
|
|
1
|
-
import { RenderDisplayObject } from "./RenderDisplayObject";
|
|
2
|
-
import { Rectangle } from "../player/next2d/geom/Rectangle";
|
|
3
|
-
import { $renderPlayer } from "./RenderGlobal";
|
|
4
|
-
import { $clamp, $getBoundsObject, $boundsMatrix, $Math, $poolBoundsObject, $Infinity, $Number, $getArray, $poolArray, $getFloat32Array6, $multiplicationMatrix, $poolFloat32Array6, $getFloat32Array4, $linearGradientXY, $getFloat32Array8 } from "../player/util/RenderUtil";
|
|
5
|
-
/**
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
export class RenderGraphics extends RenderDisplayObject {
|
|
9
|
-
_$recodes;
|
|
10
|
-
_$maxAlpha;
|
|
11
|
-
_$canDraw;
|
|
12
|
-
/**
|
|
13
|
-
* @constructor
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
/**
|
|
19
|
-
* @type {Float32Array}
|
|
20
|
-
* @default null
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
this._$recodes = null;
|
|
24
|
-
/**
|
|
25
|
-
* @type {number}
|
|
26
|
-
* @default 0
|
|
27
|
-
* @private
|
|
28
|
-
*/
|
|
29
|
-
this._$maxAlpha = 0;
|
|
30
|
-
/**
|
|
31
|
-
* @type {boolean}
|
|
32
|
-
* @default false
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
this._$canDraw = false;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @param {CanvasToWebGLContext} context
|
|
39
|
-
* @param {Float32Array} matrix
|
|
40
|
-
* @return {void}
|
|
41
|
-
* @method
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
_$clip(context, matrix) {
|
|
45
|
-
if (!this._$recodes) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
49
|
-
this._$runCommand(context, this._$recodes, null, true);
|
|
50
|
-
context.clip();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @param {CanvasToWebGLContext} context
|
|
54
|
-
* @param {Float32Array} matrix
|
|
55
|
-
* @param {Float32Array} color_transform
|
|
56
|
-
* @param {string} [blend_mode=BlendMode.NORMAL]
|
|
57
|
-
* @param {array} [filters=null]
|
|
58
|
-
* @return {void}
|
|
59
|
-
* @method
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
_$draw(context, matrix, color_transform, blend_mode = "normal", filters = null) {
|
|
63
|
-
if (!this._$visible
|
|
64
|
-
|| !this._$recodes
|
|
65
|
-
|| !this._$maxAlpha
|
|
66
|
-
|| !this._$canDraw) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const alpha = $clamp(color_transform[3] + color_transform[7] / 255, 0, 1, 0);
|
|
70
|
-
if (!alpha) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const rawMatrix = this._$matrix;
|
|
74
|
-
// set grid data
|
|
75
|
-
let hasGrid = this._$scale9Grid !== null;
|
|
76
|
-
// 9スライスを有効にしたオブジェクトが回転・傾斜成分を含む場合は
|
|
77
|
-
// 9スライスは無効になる
|
|
78
|
-
if (hasGrid) {
|
|
79
|
-
hasGrid = hasGrid
|
|
80
|
-
&& $Math.abs(rawMatrix[1]) < 0.001
|
|
81
|
-
&& $Math.abs(rawMatrix[2]) < 0.0001;
|
|
82
|
-
}
|
|
83
|
-
// size
|
|
84
|
-
const baseBounds = $getBoundsObject(this._$xMin, this._$xMax, this._$yMin, this._$yMax);
|
|
85
|
-
const bounds = $boundsMatrix(baseBounds, matrix);
|
|
86
|
-
const xMax = bounds.xMax;
|
|
87
|
-
const xMin = bounds.xMin;
|
|
88
|
-
const yMax = bounds.yMax;
|
|
89
|
-
const yMin = bounds.yMin;
|
|
90
|
-
$poolBoundsObject(bounds);
|
|
91
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
92
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
93
|
-
switch (true) {
|
|
94
|
-
case width === 0:
|
|
95
|
-
case height === 0:
|
|
96
|
-
case width === 0 - $Infinity:
|
|
97
|
-
case height === 0 - $Infinity:
|
|
98
|
-
case width === $Infinity:
|
|
99
|
-
case height === $Infinity:
|
|
100
|
-
return;
|
|
101
|
-
default:
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
// cache current buffer
|
|
105
|
-
const manager = context.frameBuffer;
|
|
106
|
-
const currentAttachment = manager.currentAttachment;
|
|
107
|
-
if (!currentAttachment
|
|
108
|
-
|| xMin > currentAttachment.width
|
|
109
|
-
|| yMin > currentAttachment.height) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
let xScale = +$Math.sqrt(matrix[0] * matrix[0]
|
|
113
|
-
+ matrix[1] * matrix[1]);
|
|
114
|
-
if (!$Number.isInteger(xScale)) {
|
|
115
|
-
const value = xScale.toString();
|
|
116
|
-
const index = value.indexOf("e");
|
|
117
|
-
if (index !== -1) {
|
|
118
|
-
xScale = +value.slice(0, index);
|
|
119
|
-
}
|
|
120
|
-
xScale = +xScale.toFixed(4);
|
|
121
|
-
}
|
|
122
|
-
let yScale = +$Math.sqrt(matrix[2] * matrix[2]
|
|
123
|
-
+ matrix[3] * matrix[3]);
|
|
124
|
-
if (!$Number.isInteger(yScale)) {
|
|
125
|
-
const value = yScale.toString();
|
|
126
|
-
const index = value.indexOf("e");
|
|
127
|
-
if (index !== -1) {
|
|
128
|
-
yScale = +value.slice(0, index);
|
|
129
|
-
}
|
|
130
|
-
yScale = +yScale.toFixed(4);
|
|
131
|
-
}
|
|
132
|
-
if (0 > xMin + width || 0 > yMin + height) {
|
|
133
|
-
if (filters && filters.length && this._$canApply(filters)) {
|
|
134
|
-
let rect = new Rectangle(0, 0, width, height);
|
|
135
|
-
for (let idx = 0; idx < filters.length; ++idx) {
|
|
136
|
-
rect = filters[idx]
|
|
137
|
-
._$generateFilterRect(rect, xScale, yScale);
|
|
138
|
-
}
|
|
139
|
-
if (0 > rect.x + rect.width || 0 > rect.y + rect.height) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// get cache
|
|
148
|
-
const keys = $getArray(xScale, yScale);
|
|
149
|
-
let uniqueId = `${this._$instanceId}`;
|
|
150
|
-
if (!hasGrid
|
|
151
|
-
&& this._$loaderInfoId > -1
|
|
152
|
-
&& this._$characterId > -1) {
|
|
153
|
-
uniqueId = `${this._$loaderInfoId}@${this._$characterId}`;
|
|
154
|
-
}
|
|
155
|
-
const cacheStore = $renderPlayer.cacheStore;
|
|
156
|
-
const cacheKeys = cacheStore.generateKeys(uniqueId, keys, color_transform);
|
|
157
|
-
$poolArray(keys);
|
|
158
|
-
let texture = cacheStore.get(cacheKeys);
|
|
159
|
-
if (!texture) {
|
|
160
|
-
// resize
|
|
161
|
-
let width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
|
|
162
|
-
let height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
|
|
163
|
-
const textureScale = context._$getTextureScale(width, height);
|
|
164
|
-
if (textureScale < 1) {
|
|
165
|
-
width *= textureScale;
|
|
166
|
-
height *= textureScale;
|
|
167
|
-
}
|
|
168
|
-
// create cache buffer
|
|
169
|
-
const attachment = manager
|
|
170
|
-
.createCacheAttachment(width, height, true);
|
|
171
|
-
context._$bind(attachment);
|
|
172
|
-
// reset
|
|
173
|
-
context.reset();
|
|
174
|
-
context.setTransform(xScale, 0, 0, yScale, 0 - baseBounds.xMin * xScale, 0 - baseBounds.yMin * yScale);
|
|
175
|
-
if (hasGrid) {
|
|
176
|
-
const mScale = $renderPlayer.scaleX;
|
|
177
|
-
const baseMatrix = $getFloat32Array6(mScale, 0, 0, mScale, 0, 0);
|
|
178
|
-
const pMatrix = $multiplicationMatrix(baseMatrix, rawMatrix);
|
|
179
|
-
$poolFloat32Array6(baseMatrix);
|
|
180
|
-
const aMatrixBase = this._$matrixBase;
|
|
181
|
-
const aMatrix = $getFloat32Array6(aMatrixBase[0], aMatrixBase[1], aMatrixBase[2], aMatrixBase[3], aMatrixBase[4] * mScale - xMin, aMatrixBase[5] * mScale - yMin);
|
|
182
|
-
const apMatrix = $multiplicationMatrix(aMatrix, pMatrix);
|
|
183
|
-
const aOffsetX = apMatrix[4] - (matrix[4] - xMin);
|
|
184
|
-
const aOffsetY = apMatrix[5] - (matrix[5] - yMin);
|
|
185
|
-
$poolFloat32Array6(apMatrix);
|
|
186
|
-
const parentBounds = $boundsMatrix(baseBounds, pMatrix);
|
|
187
|
-
const parentXMax = +parentBounds.xMax;
|
|
188
|
-
const parentXMin = +parentBounds.xMin;
|
|
189
|
-
const parentYMax = +parentBounds.yMax;
|
|
190
|
-
const parentYMin = +parentBounds.yMin;
|
|
191
|
-
const parentWidth = $Math.ceil($Math.abs(parentXMax - parentXMin));
|
|
192
|
-
const parentHeight = $Math.ceil($Math.abs(parentYMax - parentYMin));
|
|
193
|
-
$poolBoundsObject(parentBounds);
|
|
194
|
-
context.grid.enable(parentXMin, parentYMin, parentWidth, parentHeight, baseBounds, this._$scale9Grid, mScale, pMatrix[0], pMatrix[1], pMatrix[2], pMatrix[3], pMatrix[4], pMatrix[5], aMatrix[0], aMatrix[1], aMatrix[2], aMatrix[3], aMatrix[4] - aOffsetX, aMatrix[5] - aOffsetY);
|
|
195
|
-
$poolFloat32Array6(pMatrix);
|
|
196
|
-
$poolFloat32Array6(aMatrix);
|
|
197
|
-
}
|
|
198
|
-
// plain alpha
|
|
199
|
-
color_transform[3] = 1;
|
|
200
|
-
this._$runCommand(context, this._$recodes, color_transform, false);
|
|
201
|
-
if (hasGrid) {
|
|
202
|
-
context.grid.disable();
|
|
203
|
-
}
|
|
204
|
-
texture = manager.getTextureFromCurrentAttachment();
|
|
205
|
-
// set cache
|
|
206
|
-
cacheStore.set(cacheKeys, texture);
|
|
207
|
-
// release buffer
|
|
208
|
-
manager.releaseAttachment(attachment, false);
|
|
209
|
-
// end draw and reset current buffer
|
|
210
|
-
context._$bind(currentAttachment);
|
|
211
|
-
}
|
|
212
|
-
let drawFilter = false;
|
|
213
|
-
let offsetX = 0;
|
|
214
|
-
let offsetY = 0;
|
|
215
|
-
if (filters && filters.length
|
|
216
|
-
&& this._$canApply(filters)) {
|
|
217
|
-
drawFilter = true;
|
|
218
|
-
texture = this._$drawFilter(context, texture, matrix, filters, width, height);
|
|
219
|
-
offsetX = texture._$offsetX;
|
|
220
|
-
offsetY = texture._$offsetY;
|
|
221
|
-
}
|
|
222
|
-
const radianX = $Math.atan2(matrix[1], matrix[0]);
|
|
223
|
-
const radianY = $Math.atan2(0 - matrix[2], matrix[3]);
|
|
224
|
-
if (!drawFilter && (radianX || radianY)) {
|
|
225
|
-
const tx = baseBounds.xMin * xScale;
|
|
226
|
-
const ty = baseBounds.yMin * yScale;
|
|
227
|
-
const cosX = $Math.cos(radianX);
|
|
228
|
-
const sinX = $Math.sin(radianX);
|
|
229
|
-
const cosY = $Math.cos(radianY);
|
|
230
|
-
const sinY = $Math.sin(radianY);
|
|
231
|
-
context.setTransform(cosX, sinX, 0 - sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
|
|
235
|
-
}
|
|
236
|
-
// draw
|
|
237
|
-
context.reset();
|
|
238
|
-
context.globalAlpha = alpha;
|
|
239
|
-
context.imageSmoothingEnabled = true;
|
|
240
|
-
context.globalCompositeOperation = blend_mode;
|
|
241
|
-
context.drawImage(texture, 0, 0, texture.width, texture.height, color_transform);
|
|
242
|
-
// pool
|
|
243
|
-
$poolArray(cacheKeys);
|
|
244
|
-
$poolBoundsObject(baseBounds);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* @description strokeのセットアップ
|
|
248
|
-
*
|
|
249
|
-
* @param {CanvasToWebGLContext} context
|
|
250
|
-
* @param {number} line_width
|
|
251
|
-
* @param {number} line_cap
|
|
252
|
-
* @param {number} line_join
|
|
253
|
-
* @param {number} miter_limit
|
|
254
|
-
* @return {void}
|
|
255
|
-
* @method
|
|
256
|
-
* @public
|
|
257
|
-
*/
|
|
258
|
-
setupStroke(context, line_width, line_cap, line_join, miter_limit) {
|
|
259
|
-
context.lineWidth = line_width;
|
|
260
|
-
switch (line_cap) {
|
|
261
|
-
case 0:
|
|
262
|
-
context.lineCap = "none";
|
|
263
|
-
break;
|
|
264
|
-
case 1:
|
|
265
|
-
context.lineCap = "round";
|
|
266
|
-
break;
|
|
267
|
-
case 2:
|
|
268
|
-
context.lineCap = "square";
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
switch (line_join) {
|
|
272
|
-
case 0:
|
|
273
|
-
context.lineJoin = "bevel";
|
|
274
|
-
break;
|
|
275
|
-
case 1:
|
|
276
|
-
context.lineJoin = "miter";
|
|
277
|
-
break;
|
|
278
|
-
case 2:
|
|
279
|
-
context.lineJoin = "round";
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
context.miterLimit = miter_limit;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @description CanvasGradientToWebGLオブジェクトを生成
|
|
286
|
-
*
|
|
287
|
-
* @param {CanvasToWebGLContext} context
|
|
288
|
-
* @param {number} type
|
|
289
|
-
* @param {array} stops
|
|
290
|
-
* @param {Float32Array} matrix
|
|
291
|
-
* @param {number} spread
|
|
292
|
-
* @param {number} interpolation
|
|
293
|
-
* @param {number} focal
|
|
294
|
-
* @param {Float32Array} [color_transform=null]
|
|
295
|
-
* @return {CanvasGradientToWebGL}
|
|
296
|
-
* @method
|
|
297
|
-
* @public
|
|
298
|
-
*/
|
|
299
|
-
createGradientStyle(context, type, stops, matrix, spread, interpolation, focal, color_transform = null) {
|
|
300
|
-
let spreadMethod = "pad";
|
|
301
|
-
switch (spread) {
|
|
302
|
-
case 0: // REFLECT
|
|
303
|
-
spreadMethod = "reflect";
|
|
304
|
-
break;
|
|
305
|
-
case 1: // REPEAT
|
|
306
|
-
spreadMethod = "repeat";
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
let css;
|
|
310
|
-
if (type === 0) {
|
|
311
|
-
// LINEAR
|
|
312
|
-
const xy = $linearGradientXY(matrix);
|
|
313
|
-
css = context.createLinearGradient(xy[0], xy[1], xy[2], xy[3], interpolation ? "rgb" : "linearRGB", spreadMethod);
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
// RADIAL
|
|
317
|
-
context.save();
|
|
318
|
-
context.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
319
|
-
css = context.createRadialGradient(0, 0, 0, 0, 0, 819.2, interpolation ? "rgb" : "linearRGB", spreadMethod, focal);
|
|
320
|
-
}
|
|
321
|
-
for (let idx = 0; idx < stops.length; ++idx) {
|
|
322
|
-
const color = stops[idx];
|
|
323
|
-
let alpha = color.A;
|
|
324
|
-
if (color_transform) {
|
|
325
|
-
if (color_transform[3] !== 1 || color_transform[7] !== 0) {
|
|
326
|
-
alpha = $Math.max(0, $Math.min(color.A * color_transform[3] + color_transform[7], 255)) | 0;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
css.addColorStop(color.ratio, $getFloat32Array4(color.R, color.G, color.B, alpha));
|
|
330
|
-
}
|
|
331
|
-
return css;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* @description Graphicsクラスの描画を実行
|
|
335
|
-
* Execute drawing in the Graphics class
|
|
336
|
-
*
|
|
337
|
-
* @param {CanvasToWebGLContext} context
|
|
338
|
-
* @param {Float32Array} recodes
|
|
339
|
-
* @param {Float32Array} [color_transform=null]
|
|
340
|
-
* @param {boolean} [is_clip=false]
|
|
341
|
-
* @return {void}
|
|
342
|
-
* @method
|
|
343
|
-
* @public
|
|
344
|
-
*/
|
|
345
|
-
_$runCommand(context, recodes, color_transform = null, is_clip = false) {
|
|
346
|
-
// reset
|
|
347
|
-
context.reset();
|
|
348
|
-
context.beginPath();
|
|
349
|
-
const length = recodes.length;
|
|
350
|
-
for (let idx = 0; idx < length;) {
|
|
351
|
-
switch (recodes[idx++]) {
|
|
352
|
-
case 9: // BEGIN_PATH
|
|
353
|
-
context.beginPath();
|
|
354
|
-
break;
|
|
355
|
-
case 0: // MOVE_TO
|
|
356
|
-
context.moveTo(recodes[idx++], recodes[idx++]);
|
|
357
|
-
break;
|
|
358
|
-
case 2: // LINE_TO
|
|
359
|
-
context.lineTo(recodes[idx++], recodes[idx++]);
|
|
360
|
-
break;
|
|
361
|
-
case 1: // CURVE_TO
|
|
362
|
-
context.quadraticCurveTo(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
363
|
-
break;
|
|
364
|
-
case 5: // FILL_STYLE
|
|
365
|
-
{
|
|
366
|
-
if (is_clip) {
|
|
367
|
-
idx += 4;
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
const color = $getFloat32Array4();
|
|
371
|
-
color[0] = recodes[idx++] / 255;
|
|
372
|
-
color[1] = recodes[idx++] / 255;
|
|
373
|
-
color[2] = recodes[idx++] / 255;
|
|
374
|
-
color[3] = recodes[idx++] / 255;
|
|
375
|
-
if (color_transform !== null) {
|
|
376
|
-
if (color_transform[3] !== 1 || color_transform[7] !== 0) {
|
|
377
|
-
color[3] = $Math.max(0, $Math.min(color[3] * color_transform[3] + color_transform[7], 255)) / 255;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
context.fillStyle = color;
|
|
381
|
-
}
|
|
382
|
-
break;
|
|
383
|
-
case 7: // END_FILL
|
|
384
|
-
if (!is_clip) {
|
|
385
|
-
context.fill();
|
|
386
|
-
}
|
|
387
|
-
break;
|
|
388
|
-
case 6: // STROKE_STYLE
|
|
389
|
-
{
|
|
390
|
-
if (is_clip) {
|
|
391
|
-
idx += 8;
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
this.setupStroke(context, recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
395
|
-
const color = $getFloat32Array4();
|
|
396
|
-
color[0] = recodes[idx++] / 255;
|
|
397
|
-
color[1] = recodes[idx++] / 255;
|
|
398
|
-
color[2] = recodes[idx++] / 255;
|
|
399
|
-
color[3] = recodes[idx++] / 255;
|
|
400
|
-
if (color_transform !== null) {
|
|
401
|
-
if (color_transform[3] !== 1 || color_transform[7] !== 0) {
|
|
402
|
-
color[3] = $Math.max(0, $Math.min(color[3] * color_transform[3] + color_transform[7], 255)) / 255;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
context.strokeStyle = color;
|
|
406
|
-
}
|
|
407
|
-
break;
|
|
408
|
-
case 8: // END_STROKE
|
|
409
|
-
if (!is_clip) {
|
|
410
|
-
context.stroke();
|
|
411
|
-
}
|
|
412
|
-
break;
|
|
413
|
-
case 12: // CLOSE_PATH
|
|
414
|
-
context.closePath();
|
|
415
|
-
break;
|
|
416
|
-
case 3: // CUBIC
|
|
417
|
-
context.bezierCurveTo(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
418
|
-
break;
|
|
419
|
-
case 4: // ARC
|
|
420
|
-
context.arc(recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
421
|
-
break;
|
|
422
|
-
case 10: // GRADIENT_FILL
|
|
423
|
-
{
|
|
424
|
-
if (is_clip) {
|
|
425
|
-
idx += 1;
|
|
426
|
-
const length = recodes[idx++];
|
|
427
|
-
idx += length * 5;
|
|
428
|
-
idx += 9;
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
const type = recodes[idx++];
|
|
432
|
-
let stopLength = recodes[idx++];
|
|
433
|
-
const stops = $getArray();
|
|
434
|
-
while (stopLength) {
|
|
435
|
-
stops.push({
|
|
436
|
-
"ratio": recodes[idx++],
|
|
437
|
-
"R": recodes[idx++],
|
|
438
|
-
"G": recodes[idx++],
|
|
439
|
-
"B": recodes[idx++],
|
|
440
|
-
"A": recodes[idx++]
|
|
441
|
-
});
|
|
442
|
-
stopLength--;
|
|
443
|
-
}
|
|
444
|
-
const matrix = $getFloat32Array6(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
445
|
-
context.fillStyle = this.createGradientStyle(context, type, stops, matrix, recodes[idx++], recodes[idx++], recodes[idx++], color_transform);
|
|
446
|
-
context.fill();
|
|
447
|
-
// if RADIAL
|
|
448
|
-
if (type === 1) {
|
|
449
|
-
context.restore();
|
|
450
|
-
}
|
|
451
|
-
$poolFloat32Array6(matrix);
|
|
452
|
-
$poolArray(stops);
|
|
453
|
-
}
|
|
454
|
-
break;
|
|
455
|
-
case 11: // GRADIENT_STROKE
|
|
456
|
-
{
|
|
457
|
-
if (is_clip) {
|
|
458
|
-
idx += 5;
|
|
459
|
-
const length = recodes[idx++];
|
|
460
|
-
idx += length * 5;
|
|
461
|
-
idx += 9;
|
|
462
|
-
continue;
|
|
463
|
-
}
|
|
464
|
-
this.setupStroke(context, recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
465
|
-
const type = recodes[idx++];
|
|
466
|
-
let stopLength = recodes[idx++];
|
|
467
|
-
const stops = $getArray();
|
|
468
|
-
while (stopLength) {
|
|
469
|
-
stops.push({
|
|
470
|
-
"ratio": recodes[idx++],
|
|
471
|
-
"R": recodes[idx++],
|
|
472
|
-
"G": recodes[idx++],
|
|
473
|
-
"B": recodes[idx++],
|
|
474
|
-
"A": recodes[idx++]
|
|
475
|
-
});
|
|
476
|
-
stopLength--;
|
|
477
|
-
}
|
|
478
|
-
const matrix = $getFloat32Array6(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
479
|
-
context.strokeStyle = this.createGradientStyle(context, type, stops, matrix, recodes[idx++], recodes[idx++], recodes[idx++], color_transform);
|
|
480
|
-
context.stroke();
|
|
481
|
-
// if RADIAL
|
|
482
|
-
if (type === 1) {
|
|
483
|
-
context.restore();
|
|
484
|
-
}
|
|
485
|
-
$poolFloat32Array6(matrix);
|
|
486
|
-
$poolArray(stops);
|
|
487
|
-
}
|
|
488
|
-
break;
|
|
489
|
-
case 13: // BITMAP_FILL
|
|
490
|
-
{
|
|
491
|
-
const width = recodes[idx++];
|
|
492
|
-
const height = recodes[idx++];
|
|
493
|
-
const graphicsWidth = recodes[idx++];
|
|
494
|
-
const graphicsHeight = recodes[idx++];
|
|
495
|
-
const bitmapLength = recodes[idx++];
|
|
496
|
-
if (is_clip) {
|
|
497
|
-
idx += bitmapLength;
|
|
498
|
-
idx += 8;
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
const buffer = new Uint8Array(recodes.subarray(idx, bitmapLength + idx));
|
|
502
|
-
idx += bitmapLength;
|
|
503
|
-
const matrix = $getFloat32Array6(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
504
|
-
const repeat = !!recodes[idx++];
|
|
505
|
-
const smooth = !!recodes[idx++];
|
|
506
|
-
context.save();
|
|
507
|
-
if (matrix[0] !== 1 || matrix[1] !== 0
|
|
508
|
-
|| matrix[2] !== 0 || matrix[3] !== 1
|
|
509
|
-
|| matrix[4] !== 0 || matrix[5] !== 0) {
|
|
510
|
-
context.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
511
|
-
}
|
|
512
|
-
$poolFloat32Array6(matrix);
|
|
513
|
-
const manager = context.frameBuffer;
|
|
514
|
-
const texture = manager.createTextureFromPixels(width, height, buffer, true);
|
|
515
|
-
if (!repeat
|
|
516
|
-
&& width === graphicsWidth
|
|
517
|
-
&& height === graphicsHeight) {
|
|
518
|
-
context.drawImage(texture, 0, 0, width, height);
|
|
519
|
-
manager.releaseTexture(texture);
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
context.fillStyle = context.createPattern(texture, repeat, color_transform || $getFloat32Array8());
|
|
523
|
-
context.imageSmoothingEnabled = smooth;
|
|
524
|
-
context.fill();
|
|
525
|
-
}
|
|
526
|
-
// restore
|
|
527
|
-
context.restore();
|
|
528
|
-
context.imageSmoothingEnabled = false;
|
|
529
|
-
}
|
|
530
|
-
break;
|
|
531
|
-
case 14: // BITMAP_STROKE
|
|
532
|
-
{
|
|
533
|
-
if (is_clip) {
|
|
534
|
-
idx += 4;
|
|
535
|
-
const bitmapLength = recodes[idx++];
|
|
536
|
-
idx += bitmapLength;
|
|
537
|
-
idx += 8;
|
|
538
|
-
continue;
|
|
539
|
-
}
|
|
540
|
-
context.save();
|
|
541
|
-
this.setupStroke(context, recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
542
|
-
const width = recodes[idx++];
|
|
543
|
-
const height = recodes[idx++];
|
|
544
|
-
const bitmapLength = recodes[idx++];
|
|
545
|
-
const buffer = new Uint8Array(recodes.subarray(idx, bitmapLength + idx));
|
|
546
|
-
idx += bitmapLength;
|
|
547
|
-
const matrix = $getFloat32Array6(recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++], recodes[idx++]);
|
|
548
|
-
if (matrix[0] !== 1 || matrix[1] !== 0
|
|
549
|
-
|| matrix[2] !== 0 || matrix[3] !== 1
|
|
550
|
-
|| matrix[4] !== 0 || matrix[5] !== 0) {
|
|
551
|
-
context.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
552
|
-
}
|
|
553
|
-
$poolFloat32Array6(matrix);
|
|
554
|
-
const repeat = !!recodes[idx++];
|
|
555
|
-
const smooth = !!recodes[idx++];
|
|
556
|
-
const manager = context.frameBuffer;
|
|
557
|
-
const texture = manager.createTextureFromPixels(width, height, buffer, true);
|
|
558
|
-
context.strokeStyle = context.createPattern(texture, repeat, color_transform || $getFloat32Array8());
|
|
559
|
-
context.imageSmoothingEnabled = smooth;
|
|
560
|
-
context.stroke();
|
|
561
|
-
// restore
|
|
562
|
-
context.restore();
|
|
563
|
-
context.imageSmoothingEnabled = false;
|
|
564
|
-
}
|
|
565
|
-
break;
|
|
566
|
-
default:
|
|
567
|
-
break;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* @description 描画情報を更新
|
|
573
|
-
*
|
|
574
|
-
* @param {object} object
|
|
575
|
-
* @return {void}
|
|
576
|
-
* @method
|
|
577
|
-
* @private
|
|
578
|
-
*/
|
|
579
|
-
_$update(object) {
|
|
580
|
-
super._$update(object);
|
|
581
|
-
if (object.recodes) {
|
|
582
|
-
this._$recodes = object.recodes;
|
|
583
|
-
this._$xMin = object.xMin;
|
|
584
|
-
this._$yMin = object.yMin;
|
|
585
|
-
this._$xMax = object.xMax;
|
|
586
|
-
this._$yMax = object.yMax;
|
|
587
|
-
this._$maxAlpha = object.maxAlpha;
|
|
588
|
-
this._$canDraw = object.canDraw;
|
|
589
|
-
const cacheStore = $renderPlayer.cacheStore;
|
|
590
|
-
cacheStore.removeCache(this._$instanceId);
|
|
591
|
-
if (this._$loaderInfoId > -1
|
|
592
|
-
&& this._$characterId > -1) {
|
|
593
|
-
cacheStore.removeCache(`${this._$loaderInfoId}@${this._$characterId}`);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|