@blakron/core 0.5.17 → 0.6.0
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/blakron/benchmark/SceneRegistry.js +13 -13
- package/dist/blakron/benchmark/SceneRegistry.js.map +1 -1
- package/dist/blakron/display/Bitmap.d.ts +4 -4
- package/dist/blakron/display/Bitmap.d.ts.map +1 -1
- package/dist/blakron/display/Bitmap.js +23 -23
- package/dist/blakron/display/Bitmap.js.map +1 -1
- package/dist/blakron/display/DisplayObject.d.ts +76 -74
- package/dist/blakron/display/DisplayObject.d.ts.map +1 -1
- package/dist/blakron/display/DisplayObject.js +297 -293
- package/dist/blakron/display/DisplayObject.js.map +1 -1
- package/dist/blakron/display/DisplayObjectContainer.d.ts +6 -8
- package/dist/blakron/display/DisplayObjectContainer.d.ts.map +1 -1
- package/dist/blakron/display/DisplayObjectContainer.js +88 -91
- package/dist/blakron/display/DisplayObjectContainer.js.map +1 -1
- package/dist/blakron/display/Graphics.d.ts +3 -3
- package/dist/blakron/display/Graphics.d.ts.map +1 -1
- package/dist/blakron/display/Graphics.js +6 -6
- package/dist/blakron/display/Graphics.js.map +1 -1
- package/dist/blakron/display/Mesh.d.ts +1 -1
- package/dist/blakron/display/Mesh.d.ts.map +1 -1
- package/dist/blakron/display/Mesh.js +4 -4
- package/dist/blakron/display/Mesh.js.map +1 -1
- package/dist/blakron/display/Shape.d.ts +3 -3
- package/dist/blakron/display/Shape.d.ts.map +1 -1
- package/dist/blakron/display/Shape.js +10 -10
- package/dist/blakron/display/Shape.js.map +1 -1
- package/dist/blakron/display/Sprite.d.ts +3 -3
- package/dist/blakron/display/Sprite.d.ts.map +1 -1
- package/dist/blakron/display/Sprite.js +10 -10
- package/dist/blakron/display/Sprite.js.map +1 -1
- package/dist/blakron/display/Stage.js +2 -2
- package/dist/blakron/display/Stage.js.map +1 -1
- package/dist/blakron/display/texture/BitmapData.js +4 -4
- package/dist/blakron/display/texture/BitmapData.js.map +1 -1
- package/dist/blakron/display/texture/RenderTexture.js +1 -1
- package/dist/blakron/display/texture/RenderTexture.js.map +1 -1
- package/dist/blakron/events/EventDispatcher.js +1 -1
- package/dist/blakron/events/EventDispatcher.js.map +1 -1
- package/dist/blakron/events/TouchEvent.js +2 -2
- package/dist/blakron/events/TouchEvent.js.map +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.d.ts +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.d.ts.map +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.js +3 -3
- package/dist/blakron/filters/ColorMatrixFilter.js.map +1 -1
- package/dist/blakron/media/Video.d.ts +1 -1
- package/dist/blakron/media/Video.d.ts.map +1 -1
- package/dist/blakron/media/Video.js +5 -5
- package/dist/blakron/media/Video.js.map +1 -1
- package/dist/blakron/player/RenderPipe.d.ts +1 -1
- package/dist/blakron/player/SystemTicker.js +2 -2
- package/dist/blakron/player/SystemTicker.js.map +1 -1
- package/dist/blakron/player/TouchHandler.js +1 -1
- package/dist/blakron/player/TouchHandler.js.map +1 -1
- package/dist/blakron/player/canvas/CanvasRenderer.js +52 -52
- package/dist/blakron/player/canvas/CanvasRenderer.js.map +1 -1
- package/dist/blakron/player/canvas/DisplayList.js +1 -1
- package/dist/blakron/player/canvas/DisplayList.js.map +1 -1
- package/dist/blakron/player/webgl/WebGLRenderer.d.ts +1 -1
- package/dist/blakron/player/webgl/WebGLRenderer.js +67 -67
- package/dist/blakron/player/webgl/WebGLRenderer.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/FilterPipe.js +7 -7
- package/dist/blakron/player/webgl/pipes/FilterPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/GraphicsPipe.js +1 -1
- package/dist/blakron/player/webgl/pipes/GraphicsPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/MaskPipe.js +12 -12
- package/dist/blakron/player/webgl/pipes/MaskPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/ParticlePipe.js +1 -1
- package/dist/blakron/player/webgl/pipes/ParticlePipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/TextPipe.d.ts +1 -1
- package/dist/blakron/player/webgl/pipes/TextPipe.js +5 -5
- package/dist/blakron/player/webgl/pipes/TextPipe.js.map +1 -1
- package/dist/blakron/system/Capabilities.d.ts +1 -1
- package/dist/blakron/system/Capabilities.d.ts.map +1 -1
- package/dist/blakron/system/Capabilities.js +1 -1
- package/dist/blakron/system/Capabilities.js.map +1 -1
- package/dist/blakron/text/BitmapText.d.ts +1 -1
- package/dist/blakron/text/BitmapText.d.ts.map +1 -1
- package/dist/blakron/text/BitmapText.js +11 -11
- package/dist/blakron/text/BitmapText.js.map +1 -1
- package/dist/blakron/text/InputController.js +1 -1
- package/dist/blakron/text/InputController.js.map +1 -1
- package/dist/blakron/text/TextField.d.ts +3 -3
- package/dist/blakron/text/TextField.d.ts.map +1 -1
- package/dist/blakron/text/TextField.js +33 -33
- package/dist/blakron/text/TextField.js.map +1 -1
- package/package.json +1 -1
|
@@ -17,14 +17,16 @@ function clampRotation(value) {
|
|
|
17
17
|
export class DisplayObject extends EventDispatcher {
|
|
18
18
|
// ── Static fields ─────────────────────────────────────────────────────────
|
|
19
19
|
static defaultTouchEnabled = false;
|
|
20
|
-
static enterFrameCallBackList = [];
|
|
21
|
-
static renderCallBackList = [];
|
|
20
|
+
static $enterFrameCallBackList = [];
|
|
21
|
+
static $renderCallBackList = [];
|
|
22
|
+
static $eventAddToStageList = [];
|
|
23
|
+
static $eventRemoveFromStageList = [];
|
|
22
24
|
/**
|
|
23
25
|
* @internal
|
|
24
|
-
* Injected by Player at startup. Called when renderMode changes (visible,
|
|
26
|
+
* Injected by Player at startup. Called when $renderMode changes (visible,
|
|
25
27
|
* filters, mask, blendMode) so the WebGLRenderer can mark its InstructionSet dirty.
|
|
26
28
|
*/
|
|
27
|
-
static
|
|
29
|
+
static $onStructureChange;
|
|
28
30
|
/**
|
|
29
31
|
* @internal
|
|
30
32
|
* Injected by Player at startup. Called when a DisplayObject's visual data
|
|
@@ -32,19 +34,19 @@ export class DisplayObject extends EventDispatcher {
|
|
|
32
34
|
* The renderer uses this to update the transform snapshot in the InstructionSet
|
|
33
35
|
* without doing a full rebuild.
|
|
34
36
|
*/
|
|
35
|
-
static
|
|
37
|
+
static $onRenderableDirty;
|
|
36
38
|
/**
|
|
37
39
|
* @internal Register a structure-change listener. Returns an unregister function.
|
|
38
40
|
* Using a registration pattern instead of a single static field supports
|
|
39
41
|
* multiple Player instances on the same page.
|
|
40
42
|
*/
|
|
41
43
|
static addStructureChangeListener(fn) {
|
|
42
|
-
const prev = DisplayObject
|
|
44
|
+
const prev = DisplayObject.$onStructureChange;
|
|
43
45
|
if (!prev) {
|
|
44
|
-
DisplayObject
|
|
46
|
+
DisplayObject.$onStructureChange = fn;
|
|
45
47
|
}
|
|
46
48
|
else {
|
|
47
|
-
DisplayObject
|
|
49
|
+
DisplayObject.$onStructureChange = () => {
|
|
48
50
|
prev();
|
|
49
51
|
fn();
|
|
50
52
|
};
|
|
@@ -52,8 +54,8 @@ export class DisplayObject extends EventDispatcher {
|
|
|
52
54
|
return () => {
|
|
53
55
|
// Simple removal: if only one listener, clear; otherwise rebuild chain.
|
|
54
56
|
// For the common single-player case this is zero overhead.
|
|
55
|
-
if (DisplayObject
|
|
56
|
-
DisplayObject
|
|
57
|
+
if (DisplayObject.$onStructureChange === fn) {
|
|
58
|
+
DisplayObject.$onStructureChange = undefined;
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
}
|
|
@@ -61,62 +63,62 @@ export class DisplayObject extends EventDispatcher {
|
|
|
61
63
|
* @internal Register a renderable-dirty listener. Returns an unregister function.
|
|
62
64
|
*/
|
|
63
65
|
static addRenderableDirtyListener(fn) {
|
|
64
|
-
const prev = DisplayObject
|
|
66
|
+
const prev = DisplayObject.$onRenderableDirty;
|
|
65
67
|
if (!prev) {
|
|
66
|
-
DisplayObject
|
|
68
|
+
DisplayObject.$onRenderableDirty = fn;
|
|
67
69
|
}
|
|
68
70
|
else {
|
|
69
|
-
DisplayObject
|
|
71
|
+
DisplayObject.$onRenderableDirty = obj => {
|
|
70
72
|
prev(obj);
|
|
71
73
|
fn(obj);
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
return () => {
|
|
75
|
-
if (DisplayObject
|
|
76
|
-
DisplayObject
|
|
77
|
+
if (DisplayObject.$onRenderableDirty === fn) {
|
|
78
|
+
DisplayObject.$onRenderableDirty = undefined;
|
|
77
79
|
}
|
|
78
80
|
};
|
|
79
81
|
}
|
|
80
82
|
// ── Instance fields ───────────────────────────────────────────────────────
|
|
81
83
|
// 场景图
|
|
82
|
-
hasAddToStage = false;
|
|
83
|
-
children;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
nestLevel = 0;
|
|
84
|
+
$hasAddToStage = false;
|
|
85
|
+
$children;
|
|
86
|
+
$parent;
|
|
87
|
+
$stage;
|
|
88
|
+
$nestLevel = 0;
|
|
87
89
|
// 变换
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
explicitWidth = NaN;
|
|
93
|
-
explicitHeight = NaN;
|
|
94
|
-
useTranslate = false;
|
|
90
|
+
$x = 0;
|
|
91
|
+
$y = 0;
|
|
92
|
+
$anchorOffsetX = 0;
|
|
93
|
+
$anchorOffsetY = 0;
|
|
94
|
+
$explicitWidth = NaN;
|
|
95
|
+
$explicitHeight = NaN;
|
|
96
|
+
$useTranslate = false;
|
|
95
97
|
// 外观
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
$visible = true;
|
|
99
|
+
$alpha = 1;
|
|
100
|
+
$blendMode = 0;
|
|
101
|
+
$filters = [];
|
|
102
|
+
$cacheAsBitmap = false;
|
|
103
|
+
$touchEnabled = DisplayObject.defaultTouchEnabled;
|
|
102
104
|
// 遮罩
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
maskedObject;
|
|
105
|
+
$mask;
|
|
106
|
+
$maskRect;
|
|
107
|
+
$scrollRect;
|
|
108
|
+
$maskedObject;
|
|
107
109
|
// 渲染状态
|
|
108
|
-
renderMode;
|
|
109
|
-
renderObjectType = 0 /* RenderObjectType.NONE */;
|
|
110
|
-
renderDirty = false;
|
|
111
|
-
cacheDirty = false;
|
|
112
|
-
displayList;
|
|
113
|
-
//
|
|
114
|
-
worldAlpha = 1;
|
|
115
|
-
worldTint = 0xffffff;
|
|
116
|
-
tintRGB = 0;
|
|
110
|
+
$renderMode;
|
|
111
|
+
$renderObjectType = 0 /* RenderObjectType.NONE */;
|
|
112
|
+
$renderDirty = false;
|
|
113
|
+
$cacheDirty = false;
|
|
114
|
+
$displayList;
|
|
115
|
+
// 世界缓存($markDirty 更新,O(1) 读取)
|
|
116
|
+
$worldAlpha = 1;
|
|
117
|
+
$worldTint = 0xffffff;
|
|
118
|
+
$tintRGB = 0;
|
|
117
119
|
// 排序
|
|
118
|
-
sortDirty = false;
|
|
119
|
-
lastSortedIndex = 0;
|
|
120
|
+
$sortDirty = false;
|
|
121
|
+
$lastSortedIndex = 0;
|
|
120
122
|
// bounds 缓存
|
|
121
123
|
_boundsDirty = true;
|
|
122
124
|
_cachedBounds = new Rectangle();
|
|
@@ -153,153 +155,153 @@ export class DisplayObject extends EventDispatcher {
|
|
|
153
155
|
this._name = value;
|
|
154
156
|
}
|
|
155
157
|
get parent() {
|
|
156
|
-
return this
|
|
158
|
+
return this.$parent;
|
|
157
159
|
}
|
|
158
160
|
get stage() {
|
|
159
|
-
return this
|
|
161
|
+
return this.$stage;
|
|
160
162
|
}
|
|
161
163
|
get matrix() {
|
|
162
|
-
return this
|
|
164
|
+
return this.$getMatrix().clone();
|
|
163
165
|
}
|
|
164
166
|
set matrix(value) {
|
|
165
|
-
this
|
|
167
|
+
this.$setMatrix(value);
|
|
166
168
|
}
|
|
167
169
|
get x() {
|
|
168
|
-
return this
|
|
170
|
+
return this.$x;
|
|
169
171
|
}
|
|
170
172
|
set x(value) {
|
|
171
|
-
this
|
|
173
|
+
this.$setX(value);
|
|
172
174
|
}
|
|
173
175
|
get y() {
|
|
174
|
-
return this
|
|
176
|
+
return this.$y;
|
|
175
177
|
}
|
|
176
178
|
set y(value) {
|
|
177
|
-
this
|
|
179
|
+
this.$setY(value);
|
|
178
180
|
}
|
|
179
181
|
get scaleX() {
|
|
180
182
|
return this._scaleX;
|
|
181
183
|
}
|
|
182
184
|
set scaleX(value) {
|
|
183
|
-
this
|
|
185
|
+
this.$setScaleX(value);
|
|
184
186
|
}
|
|
185
187
|
get scaleY() {
|
|
186
188
|
return this._scaleY;
|
|
187
189
|
}
|
|
188
190
|
set scaleY(value) {
|
|
189
|
-
this
|
|
191
|
+
this.$setScaleY(value);
|
|
190
192
|
}
|
|
191
193
|
get rotation() {
|
|
192
194
|
return this._rotation;
|
|
193
195
|
}
|
|
194
196
|
set rotation(value) {
|
|
195
|
-
this
|
|
197
|
+
this.$setRotation(value);
|
|
196
198
|
}
|
|
197
199
|
get skewX() {
|
|
198
200
|
return this._skewXdeg;
|
|
199
201
|
}
|
|
200
202
|
set skewX(value) {
|
|
201
|
-
this
|
|
203
|
+
this.$setSkewX(value);
|
|
202
204
|
}
|
|
203
205
|
get skewY() {
|
|
204
206
|
return this._skewYdeg;
|
|
205
207
|
}
|
|
206
208
|
set skewY(value) {
|
|
207
|
-
this
|
|
209
|
+
this.$setSkewY(value);
|
|
208
210
|
}
|
|
209
211
|
get width() {
|
|
210
|
-
return isNaN(this
|
|
212
|
+
return isNaN(this.$explicitWidth) ? this.$getOriginalBounds().width : this.$explicitWidth;
|
|
211
213
|
}
|
|
212
214
|
set width(value) {
|
|
213
|
-
this
|
|
215
|
+
this.$explicitWidth = isNaN(value) ? NaN : value;
|
|
214
216
|
}
|
|
215
217
|
get height() {
|
|
216
|
-
return isNaN(this
|
|
218
|
+
return isNaN(this.$explicitHeight) ? this.$getOriginalBounds().height : this.$explicitHeight;
|
|
217
219
|
}
|
|
218
220
|
set height(value) {
|
|
219
|
-
this
|
|
221
|
+
this.$explicitHeight = isNaN(value) ? NaN : value;
|
|
220
222
|
}
|
|
221
223
|
get measuredWidth() {
|
|
222
|
-
return this
|
|
224
|
+
return this.$getOriginalBounds().width;
|
|
223
225
|
}
|
|
224
226
|
get measuredHeight() {
|
|
225
|
-
return this
|
|
227
|
+
return this.$getOriginalBounds().height;
|
|
226
228
|
}
|
|
227
229
|
get anchorOffsetX() {
|
|
228
|
-
return this
|
|
230
|
+
return this.$anchorOffsetX;
|
|
229
231
|
}
|
|
230
232
|
set anchorOffsetX(value) {
|
|
231
|
-
this
|
|
233
|
+
this.$setAnchorOffsetX(value);
|
|
232
234
|
}
|
|
233
235
|
get anchorOffsetY() {
|
|
234
|
-
return this
|
|
236
|
+
return this.$anchorOffsetY;
|
|
235
237
|
}
|
|
236
238
|
set anchorOffsetY(value) {
|
|
237
|
-
this
|
|
239
|
+
this.$setAnchorOffsetY(value);
|
|
238
240
|
}
|
|
239
241
|
get visible() {
|
|
240
|
-
return this
|
|
242
|
+
return this.$visible;
|
|
241
243
|
}
|
|
242
244
|
set visible(value) {
|
|
243
|
-
this
|
|
245
|
+
this.$setVisible(value);
|
|
244
246
|
}
|
|
245
247
|
get cacheAsBitmap() {
|
|
246
|
-
return this
|
|
248
|
+
return this.$cacheAsBitmap;
|
|
247
249
|
}
|
|
248
250
|
set cacheAsBitmap(value) {
|
|
249
|
-
this
|
|
250
|
-
this
|
|
251
|
+
this.$cacheAsBitmap = value;
|
|
252
|
+
this.$setHasDisplayList(value);
|
|
251
253
|
}
|
|
252
254
|
get filters() {
|
|
253
|
-
return this
|
|
255
|
+
return this.$filters;
|
|
254
256
|
}
|
|
255
257
|
set filters(value) {
|
|
256
|
-
this
|
|
257
|
-
this
|
|
258
|
-
this
|
|
258
|
+
this.$filters = value ? [...value] : [];
|
|
259
|
+
this.$updateRenderMode();
|
|
260
|
+
this.$markDirty();
|
|
259
261
|
}
|
|
260
262
|
get alpha() {
|
|
261
|
-
return this
|
|
263
|
+
return this.$alpha;
|
|
262
264
|
}
|
|
263
265
|
set alpha(value) {
|
|
264
|
-
this
|
|
266
|
+
this.$setAlpha(value);
|
|
265
267
|
}
|
|
266
268
|
get touchEnabled() {
|
|
267
|
-
return this
|
|
269
|
+
return this.$touchEnabled;
|
|
268
270
|
}
|
|
269
271
|
set touchEnabled(value) {
|
|
270
|
-
this
|
|
272
|
+
this.$touchEnabled = !!value;
|
|
271
273
|
}
|
|
272
274
|
get scrollRect() {
|
|
273
|
-
return this
|
|
275
|
+
return this.$scrollRect;
|
|
274
276
|
}
|
|
275
277
|
set scrollRect(value) {
|
|
276
|
-
this
|
|
278
|
+
this.$setScrollRect(value);
|
|
277
279
|
}
|
|
278
280
|
get blendMode() {
|
|
279
|
-
return numberToBlendMode(this
|
|
281
|
+
return numberToBlendMode(this.$blendMode);
|
|
280
282
|
}
|
|
281
283
|
set blendMode(value) {
|
|
282
284
|
const mode = blendModeToNumber(value);
|
|
283
|
-
if (this
|
|
285
|
+
if (this.$blendMode === mode) {
|
|
284
286
|
return;
|
|
285
287
|
}
|
|
286
|
-
this
|
|
287
|
-
this
|
|
288
|
-
this
|
|
288
|
+
this.$blendMode = mode;
|
|
289
|
+
this.$updateRenderMode();
|
|
290
|
+
this.$markDirty();
|
|
289
291
|
}
|
|
290
292
|
get mask() {
|
|
291
|
-
return this
|
|
293
|
+
return this.$mask ?? this.$maskRect;
|
|
292
294
|
}
|
|
293
295
|
set mask(value) {
|
|
294
|
-
this
|
|
296
|
+
this.$setMask(value);
|
|
295
297
|
}
|
|
296
298
|
get tint() {
|
|
297
299
|
return this._tint;
|
|
298
300
|
}
|
|
299
301
|
set tint(value) {
|
|
300
302
|
this._tint = typeof value === 'number' && value >= 0 && value <= 0xffffff ? value : 0xffffff;
|
|
301
|
-
this
|
|
302
|
-
this
|
|
303
|
+
this.$tintRGB = (this._tint >> 16) + (this._tint & 0xff00) + ((this._tint & 0xff) << 16);
|
|
304
|
+
this.$markDirty();
|
|
303
305
|
}
|
|
304
306
|
get zIndex() {
|
|
305
307
|
return this._zIndex;
|
|
@@ -307,7 +309,7 @@ export class DisplayObject extends EventDispatcher {
|
|
|
307
309
|
set zIndex(value) {
|
|
308
310
|
this._zIndex = value;
|
|
309
311
|
if (this.parent) {
|
|
310
|
-
this.parent
|
|
312
|
+
this.parent.$sortDirty = true;
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
315
|
get sortableChildren() {
|
|
@@ -318,58 +320,58 @@ export class DisplayObject extends EventDispatcher {
|
|
|
318
320
|
}
|
|
319
321
|
// ── Public methods ────────────────────────────────────────────────────────
|
|
320
322
|
getBounds(resultRect, calculateAnchor = true) {
|
|
321
|
-
resultRect = this
|
|
323
|
+
resultRect = this.$getTransformedBoundsInternal(this, resultRect);
|
|
322
324
|
if (calculateAnchor) {
|
|
323
|
-
if (this
|
|
324
|
-
resultRect.x -= this
|
|
325
|
+
if (this.$anchorOffsetX !== 0) {
|
|
326
|
+
resultRect.x -= this.$anchorOffsetX;
|
|
325
327
|
}
|
|
326
|
-
if (this
|
|
327
|
-
resultRect.y -= this
|
|
328
|
+
if (this.$anchorOffsetY !== 0) {
|
|
329
|
+
resultRect.y -= this.$anchorOffsetY;
|
|
328
330
|
}
|
|
329
331
|
}
|
|
330
332
|
return resultRect;
|
|
331
333
|
}
|
|
332
334
|
getTransformedBounds(targetCoordinateSpace, resultRect) {
|
|
333
|
-
return this
|
|
335
|
+
return this.$getTransformedBoundsInternal(targetCoordinateSpace ?? this, resultRect);
|
|
334
336
|
}
|
|
335
337
|
globalToLocal(stageX = 0, stageY = 0, resultPoint) {
|
|
336
|
-
return this
|
|
338
|
+
return this.$getInvertedConcatenatedMatrix().transformPoint(stageX, stageY, resultPoint);
|
|
337
339
|
}
|
|
338
340
|
localToGlobal(localX = 0, localY = 0, resultPoint) {
|
|
339
|
-
return this
|
|
341
|
+
return this.$getConcatenatedMatrix().transformPoint(localX, localY, resultPoint);
|
|
340
342
|
}
|
|
341
343
|
hitTestPoint(x, y, shapeFlag) {
|
|
342
344
|
if (this._scaleX === 0 || this._scaleY === 0) {
|
|
343
345
|
return false;
|
|
344
346
|
}
|
|
345
|
-
const m = this
|
|
347
|
+
const m = this.$getInvertedConcatenatedMatrix();
|
|
346
348
|
const bounds = this.getBounds(undefined, false);
|
|
347
349
|
const localX = m.a * x + m.c * y + m.tx;
|
|
348
350
|
const localY = m.b * x + m.d * y + m.ty;
|
|
349
351
|
if (!bounds.contains(localX, localY)) {
|
|
350
352
|
return false;
|
|
351
353
|
}
|
|
352
|
-
const rect = this
|
|
354
|
+
const rect = this.$scrollRect ?? this.$maskRect;
|
|
353
355
|
if (rect && !rect.contains(localX, localY)) {
|
|
354
356
|
return false;
|
|
355
357
|
}
|
|
356
358
|
if (!shapeFlag) {
|
|
357
359
|
return true;
|
|
358
360
|
}
|
|
359
|
-
// Pixel-perfect: delegate to hitTest which Shape/Sprite override
|
|
360
|
-
return this
|
|
361
|
+
// Pixel-perfect: delegate to $hitTest which Shape/Sprite override
|
|
362
|
+
return this.$hitTest(x, y) !== undefined;
|
|
361
363
|
}
|
|
362
364
|
sortChildren() {
|
|
363
|
-
this
|
|
365
|
+
this.$sortDirty = false;
|
|
364
366
|
}
|
|
365
367
|
dispatchEvent(event) {
|
|
366
368
|
if (!event.bubbles) {
|
|
367
369
|
return super.dispatchEvent(event);
|
|
368
370
|
}
|
|
369
|
-
const list = this
|
|
371
|
+
const list = this.$getPropagationList(this);
|
|
370
372
|
const targetIndex = list.length * 0.5;
|
|
371
373
|
event.setDispatchContext(this, 2 /* EventPhase.AT_TARGET */);
|
|
372
|
-
this
|
|
374
|
+
this.$dispatchPropagationEvent(event, list, targetIndex);
|
|
373
375
|
return !event.isDefaultPrevented();
|
|
374
376
|
}
|
|
375
377
|
willTrigger(type) {
|
|
@@ -378,14 +380,14 @@ export class DisplayObject extends EventDispatcher {
|
|
|
378
380
|
if (node.hasEventListener(type)) {
|
|
379
381
|
return true;
|
|
380
382
|
}
|
|
381
|
-
node = node
|
|
383
|
+
node = node.$parent;
|
|
382
384
|
}
|
|
383
385
|
return false;
|
|
384
386
|
}
|
|
385
387
|
addEventListener(type, listener, useCapture, priority) {
|
|
386
388
|
super.addEventListener(type, listener, useCapture, priority);
|
|
387
389
|
if (type === Event.ENTER_FRAME || type === Event.RENDER) {
|
|
388
|
-
const list = type === Event.ENTER_FRAME ? DisplayObject
|
|
390
|
+
const list = type === Event.ENTER_FRAME ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
|
|
389
391
|
if (!list.includes(this)) {
|
|
390
392
|
list.push(this);
|
|
391
393
|
}
|
|
@@ -394,7 +396,7 @@ export class DisplayObject extends EventDispatcher {
|
|
|
394
396
|
removeEventListener(type, listener, useCapture) {
|
|
395
397
|
super.removeEventListener(type, listener, useCapture);
|
|
396
398
|
if ((type === Event.ENTER_FRAME || type === Event.RENDER) && !this.hasEventListener(type)) {
|
|
397
|
-
const list = type === Event.ENTER_FRAME ? DisplayObject
|
|
399
|
+
const list = type === Event.ENTER_FRAME ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
|
|
398
400
|
const index = list.indexOf(this);
|
|
399
401
|
if (index !== -1) {
|
|
400
402
|
list.splice(index, 1);
|
|
@@ -402,37 +404,39 @@ export class DisplayObject extends EventDispatcher {
|
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
406
|
// ── Internal methods (used by subclasses and framework) ───────────────────
|
|
405
|
-
setParent(parent) {
|
|
406
|
-
this
|
|
407
|
+
$setParent(parent) {
|
|
408
|
+
this.$parent = parent;
|
|
407
409
|
}
|
|
408
|
-
onAddToStage(stage, nestLevel) {
|
|
409
|
-
this
|
|
410
|
-
this
|
|
411
|
-
this
|
|
410
|
+
$onAddToStage(stage, $nestLevel) {
|
|
411
|
+
this.$stage = stage;
|
|
412
|
+
this.$nestLevel = $nestLevel;
|
|
413
|
+
this.$hasAddToStage = true;
|
|
414
|
+
DisplayObject.$eventAddToStageList.push(this);
|
|
412
415
|
}
|
|
413
|
-
onRemoveFromStage() {
|
|
414
|
-
this
|
|
415
|
-
this
|
|
416
|
+
$onRemoveFromStage() {
|
|
417
|
+
this.$nestLevel = 0;
|
|
418
|
+
this.$stage = undefined;
|
|
419
|
+
DisplayObject.$eventRemoveFromStageList.push(this);
|
|
416
420
|
}
|
|
417
|
-
getMatrix() {
|
|
421
|
+
$getMatrix() {
|
|
418
422
|
if (this._matrixDirty) {
|
|
419
423
|
this._matrixDirty = false;
|
|
420
424
|
this._matrix.updateScaleAndRotation(this._scaleX, this._scaleY, this._skewX, this._skewY);
|
|
421
425
|
}
|
|
422
|
-
this._matrix.tx = this
|
|
423
|
-
this._matrix.ty = this
|
|
426
|
+
this._matrix.tx = this.$x;
|
|
427
|
+
this._matrix.ty = this.$y;
|
|
424
428
|
return this._matrix;
|
|
425
429
|
}
|
|
426
|
-
setMatrix(matrix, needUpdateProperties = true) {
|
|
430
|
+
$setMatrix(matrix, needUpdateProperties = true) {
|
|
427
431
|
const m = this._matrix;
|
|
428
432
|
m.a = matrix.a;
|
|
429
433
|
m.b = matrix.b;
|
|
430
434
|
m.c = matrix.c;
|
|
431
435
|
m.d = matrix.d;
|
|
432
|
-
this
|
|
433
|
-
this
|
|
436
|
+
this.$x = matrix.tx;
|
|
437
|
+
this.$y = matrix.ty;
|
|
434
438
|
this._matrixDirty = false;
|
|
435
|
-
this
|
|
439
|
+
this.$useTranslate = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1);
|
|
436
440
|
if (needUpdateProperties) {
|
|
437
441
|
this._scaleX = m.getScaleX();
|
|
438
442
|
this._scaleY = m.getScaleY();
|
|
@@ -442,22 +446,22 @@ export class DisplayObject extends EventDispatcher {
|
|
|
442
446
|
this._skewYdeg = clampRotation((this._skewY * 180) / Math.PI);
|
|
443
447
|
this._rotation = clampRotation((this._skewY * 180) / Math.PI);
|
|
444
448
|
}
|
|
445
|
-
this
|
|
449
|
+
this.$markDirty();
|
|
446
450
|
}
|
|
447
|
-
getConcatenatedMatrix() {
|
|
451
|
+
$getConcatenatedMatrix() {
|
|
448
452
|
if (!this._concatenatedMatrix) {
|
|
449
453
|
this._concatenatedMatrix = new Matrix();
|
|
450
454
|
}
|
|
451
455
|
const matrix = this._concatenatedMatrix;
|
|
452
|
-
if (this
|
|
453
|
-
this
|
|
456
|
+
if (this.$parent) {
|
|
457
|
+
this.$parent.$getConcatenatedMatrix().preMultiplyInto(this.$getMatrix(), matrix);
|
|
454
458
|
}
|
|
455
459
|
else {
|
|
456
|
-
matrix.copyFrom(this
|
|
460
|
+
matrix.copyFrom(this.$getMatrix());
|
|
457
461
|
}
|
|
458
|
-
const ox = this
|
|
459
|
-
const oy = this
|
|
460
|
-
const rect = this
|
|
462
|
+
const ox = this.$anchorOffsetX;
|
|
463
|
+
const oy = this.$anchorOffsetY;
|
|
464
|
+
const rect = this.$scrollRect;
|
|
461
465
|
if (rect) {
|
|
462
466
|
matrix.preMultiplyInto(sharedMatrix.setTo(1, 0, 0, 1, -rect.x - ox, -rect.y - oy), matrix);
|
|
463
467
|
}
|
|
@@ -466,48 +470,48 @@ export class DisplayObject extends EventDispatcher {
|
|
|
466
470
|
}
|
|
467
471
|
return matrix;
|
|
468
472
|
}
|
|
469
|
-
getInvertedConcatenatedMatrix() {
|
|
473
|
+
$getInvertedConcatenatedMatrix() {
|
|
470
474
|
if (!this._invertedConcatenatedMatrix) {
|
|
471
475
|
this._invertedConcatenatedMatrix = new Matrix();
|
|
472
476
|
}
|
|
473
|
-
this
|
|
477
|
+
this.$getConcatenatedMatrix().invertInto(this._invertedConcatenatedMatrix);
|
|
474
478
|
return this._invertedConcatenatedMatrix;
|
|
475
479
|
}
|
|
476
|
-
setX(value) {
|
|
477
|
-
if (this
|
|
480
|
+
$setX(value) {
|
|
481
|
+
if (this.$x === value) {
|
|
478
482
|
return false;
|
|
479
483
|
}
|
|
480
|
-
this
|
|
481
|
-
this
|
|
484
|
+
this.$x = value;
|
|
485
|
+
this.$markDirty();
|
|
482
486
|
return true;
|
|
483
487
|
}
|
|
484
|
-
setY(value) {
|
|
485
|
-
if (this
|
|
488
|
+
$setY(value) {
|
|
489
|
+
if (this.$y === value) {
|
|
486
490
|
return false;
|
|
487
491
|
}
|
|
488
|
-
this
|
|
489
|
-
this
|
|
492
|
+
this.$y = value;
|
|
493
|
+
this.$markDirty();
|
|
490
494
|
return true;
|
|
491
495
|
}
|
|
492
|
-
setScaleX(value) {
|
|
496
|
+
$setScaleX(value) {
|
|
493
497
|
if (this._scaleX === value) {
|
|
494
498
|
return;
|
|
495
499
|
}
|
|
496
500
|
this._scaleX = value;
|
|
497
501
|
this._matrixDirty = true;
|
|
498
|
-
this
|
|
499
|
-
this
|
|
502
|
+
this.$updateUseTransform();
|
|
503
|
+
this.$markDirty();
|
|
500
504
|
}
|
|
501
|
-
setScaleY(value) {
|
|
505
|
+
$setScaleY(value) {
|
|
502
506
|
if (this._scaleY === value) {
|
|
503
507
|
return;
|
|
504
508
|
}
|
|
505
509
|
this._scaleY = value;
|
|
506
510
|
this._matrixDirty = true;
|
|
507
|
-
this
|
|
508
|
-
this
|
|
511
|
+
this.$updateUseTransform();
|
|
512
|
+
this.$markDirty();
|
|
509
513
|
}
|
|
510
|
-
setRotation(value) {
|
|
514
|
+
$setRotation(value) {
|
|
511
515
|
value = clampRotation(value);
|
|
512
516
|
if (value === this._rotation) {
|
|
513
517
|
return;
|
|
@@ -517,156 +521,156 @@ export class DisplayObject extends EventDispatcher {
|
|
|
517
521
|
this._skewY += delta;
|
|
518
522
|
this._rotation = value;
|
|
519
523
|
this._matrixDirty = true;
|
|
520
|
-
this
|
|
521
|
-
this
|
|
524
|
+
this.$updateUseTransform();
|
|
525
|
+
this.$markDirty();
|
|
522
526
|
}
|
|
523
|
-
setSkewX(value) {
|
|
527
|
+
$setSkewX(value) {
|
|
524
528
|
if (value === this._skewXdeg) {
|
|
525
529
|
return;
|
|
526
530
|
}
|
|
527
531
|
this._skewXdeg = value;
|
|
528
532
|
this._skewX = (clampRotation(value) / 180) * Math.PI;
|
|
529
533
|
this._matrixDirty = true;
|
|
530
|
-
this
|
|
531
|
-
this
|
|
534
|
+
this.$updateUseTransform();
|
|
535
|
+
this.$markDirty();
|
|
532
536
|
}
|
|
533
|
-
setSkewY(value) {
|
|
537
|
+
$setSkewY(value) {
|
|
534
538
|
if (value === this._skewYdeg) {
|
|
535
539
|
return;
|
|
536
540
|
}
|
|
537
541
|
this._skewYdeg = value;
|
|
538
542
|
this._skewY = ((clampRotation(value) + this._rotation) / 180) * Math.PI;
|
|
539
543
|
this._matrixDirty = true;
|
|
540
|
-
this
|
|
541
|
-
this
|
|
544
|
+
this.$updateUseTransform();
|
|
545
|
+
this.$markDirty();
|
|
542
546
|
}
|
|
543
|
-
setAnchorOffsetX(value) {
|
|
544
|
-
if (this
|
|
547
|
+
$setAnchorOffsetX(value) {
|
|
548
|
+
if (this.$anchorOffsetX === value) {
|
|
545
549
|
return;
|
|
546
550
|
}
|
|
547
|
-
this
|
|
548
|
-
this
|
|
551
|
+
this.$anchorOffsetX = value;
|
|
552
|
+
this.$markDirty();
|
|
549
553
|
}
|
|
550
|
-
setAnchorOffsetY(value) {
|
|
551
|
-
if (this
|
|
554
|
+
$setAnchorOffsetY(value) {
|
|
555
|
+
if (this.$anchorOffsetY === value) {
|
|
552
556
|
return;
|
|
553
557
|
}
|
|
554
|
-
this
|
|
555
|
-
this
|
|
558
|
+
this.$anchorOffsetY = value;
|
|
559
|
+
this.$markDirty();
|
|
556
560
|
}
|
|
557
|
-
setVisible(value) {
|
|
558
|
-
if (this
|
|
561
|
+
$setVisible(value) {
|
|
562
|
+
if (this.$visible === value) {
|
|
559
563
|
return;
|
|
560
564
|
}
|
|
561
|
-
this
|
|
562
|
-
this
|
|
563
|
-
this
|
|
565
|
+
this.$visible = value;
|
|
566
|
+
this.$updateRenderMode();
|
|
567
|
+
this.$markDirty();
|
|
564
568
|
}
|
|
565
|
-
setAlpha(value) {
|
|
566
|
-
if (this
|
|
569
|
+
$setAlpha(value) {
|
|
570
|
+
if (this.$alpha === value) {
|
|
567
571
|
return;
|
|
568
572
|
}
|
|
569
|
-
this
|
|
570
|
-
this
|
|
571
|
-
this
|
|
573
|
+
this.$alpha = value;
|
|
574
|
+
this.$updateRenderMode();
|
|
575
|
+
this.$markDirty();
|
|
572
576
|
}
|
|
573
|
-
setScrollRect(value) {
|
|
574
|
-
if (!value && !this
|
|
577
|
+
$setScrollRect(value) {
|
|
578
|
+
if (!value && !this.$scrollRect) {
|
|
575
579
|
return;
|
|
576
580
|
}
|
|
577
581
|
if (value) {
|
|
578
|
-
if (!this
|
|
579
|
-
this
|
|
582
|
+
if (!this.$scrollRect) {
|
|
583
|
+
this.$scrollRect = new Rectangle();
|
|
580
584
|
}
|
|
581
|
-
this.
|
|
585
|
+
this.$scrollRect.copyFrom(value);
|
|
582
586
|
}
|
|
583
587
|
else {
|
|
584
|
-
this
|
|
588
|
+
this.$scrollRect = undefined;
|
|
585
589
|
}
|
|
586
|
-
this
|
|
587
|
-
this
|
|
590
|
+
this.$updateRenderMode();
|
|
591
|
+
this.$markDirty();
|
|
588
592
|
}
|
|
589
|
-
setHasDisplayList(value) {
|
|
590
|
-
const hasDisplayList = !!this
|
|
593
|
+
$setHasDisplayList(value) {
|
|
594
|
+
const hasDisplayList = !!this.$displayList;
|
|
591
595
|
if (hasDisplayList === value) {
|
|
592
596
|
return;
|
|
593
597
|
}
|
|
594
598
|
if (value) {
|
|
595
599
|
const dl = DisplayList.create(this);
|
|
596
600
|
if (dl) {
|
|
597
|
-
this
|
|
598
|
-
this
|
|
601
|
+
this.$displayList = dl;
|
|
602
|
+
this.$cacheDirty = true;
|
|
599
603
|
}
|
|
600
604
|
}
|
|
601
605
|
else {
|
|
602
|
-
if (this
|
|
603
|
-
DisplayList.release(this
|
|
604
|
-
this
|
|
606
|
+
if (this.$displayList) {
|
|
607
|
+
DisplayList.release(this.$displayList);
|
|
608
|
+
this.$displayList = undefined;
|
|
605
609
|
}
|
|
606
610
|
}
|
|
607
611
|
// cacheAsBitmap toggle changes the instruction set structure:
|
|
608
612
|
// the subtree either collapses to a single displayListCache instruction
|
|
609
613
|
// or expands back to individual leaf instructions.
|
|
610
|
-
DisplayObject
|
|
611
|
-
this
|
|
614
|
+
DisplayObject.$onStructureChange?.();
|
|
615
|
+
this.$markDirty();
|
|
612
616
|
}
|
|
613
|
-
cacheDirtyUp() {
|
|
614
|
-
const p = this
|
|
615
|
-
if (p && !p
|
|
616
|
-
p
|
|
617
|
+
$cacheDirtyUp() {
|
|
618
|
+
const p = this.$parent;
|
|
619
|
+
if (p && !p.$cacheDirty) {
|
|
620
|
+
p.$cacheDirty = true;
|
|
617
621
|
p._boundsDirty = true;
|
|
618
|
-
p
|
|
622
|
+
p.$cacheDirtyUp();
|
|
619
623
|
}
|
|
620
624
|
}
|
|
621
|
-
renderDirtyUp() {
|
|
622
|
-
const p = this
|
|
623
|
-
if (p && !p
|
|
624
|
-
p
|
|
625
|
-
p
|
|
625
|
+
$renderDirtyUp() {
|
|
626
|
+
const p = this.$parent;
|
|
627
|
+
if (p && !p.$renderDirty) {
|
|
628
|
+
p.$renderDirty = true;
|
|
629
|
+
p.$renderDirtyUp();
|
|
626
630
|
}
|
|
627
631
|
}
|
|
628
|
-
updateUseTransform() {
|
|
629
|
-
this
|
|
632
|
+
$updateUseTransform() {
|
|
633
|
+
this.$useTranslate = !(this._scaleX === 1 && this._scaleY === 1 && this._skewX === 0 && this._skewY === 0);
|
|
630
634
|
}
|
|
631
|
-
updateRenderMode() {
|
|
632
|
-
if (!this
|
|
633
|
-
this
|
|
635
|
+
$updateRenderMode() {
|
|
636
|
+
if (!this.$visible || this.$alpha <= 0 || this.$maskedObject) {
|
|
637
|
+
this.$renderMode = 1 /* RenderMode.NONE */;
|
|
634
638
|
}
|
|
635
|
-
else if (this.
|
|
636
|
-
this
|
|
639
|
+
else if (this.$filters.length > 0) {
|
|
640
|
+
this.$renderMode = 2 /* RenderMode.FILTER */;
|
|
637
641
|
}
|
|
638
|
-
else if (this
|
|
639
|
-
this
|
|
642
|
+
else if (this.$blendMode !== 0 || (this.$mask && this.$mask.$stage)) {
|
|
643
|
+
this.$renderMode = 3 /* RenderMode.CLIP */;
|
|
640
644
|
}
|
|
641
|
-
else if (this
|
|
642
|
-
this
|
|
645
|
+
else if (this.$scrollRect || this.$maskRect) {
|
|
646
|
+
this.$renderMode = 4 /* RenderMode.SCROLLRECT */;
|
|
643
647
|
}
|
|
644
648
|
else {
|
|
645
|
-
this
|
|
649
|
+
this.$renderMode = undefined;
|
|
646
650
|
}
|
|
647
651
|
// RenderMode change means the instruction set structure is stale.
|
|
648
|
-
DisplayObject
|
|
652
|
+
DisplayObject.$onStructureChange?.();
|
|
649
653
|
}
|
|
650
|
-
getOriginalBounds() {
|
|
654
|
+
$getOriginalBounds() {
|
|
651
655
|
if (!this._boundsDirty) {
|
|
652
656
|
return this._cachedBounds;
|
|
653
657
|
}
|
|
654
|
-
const bounds = this
|
|
655
|
-
this
|
|
658
|
+
const bounds = this.$getContentBounds();
|
|
659
|
+
this.$measureChildBounds(bounds);
|
|
656
660
|
this._cachedBounds.copyFrom(bounds);
|
|
657
661
|
this._boundsDirty = false;
|
|
658
662
|
return this._cachedBounds;
|
|
659
663
|
}
|
|
660
|
-
measureChildBounds(_bounds) { }
|
|
661
|
-
getContentBounds() {
|
|
664
|
+
$measureChildBounds(_bounds) { }
|
|
665
|
+
$getContentBounds() {
|
|
662
666
|
const bounds = sharedRectangle;
|
|
663
667
|
bounds.setEmpty();
|
|
664
|
-
this
|
|
668
|
+
this.$measureContentBounds(bounds);
|
|
665
669
|
return bounds;
|
|
666
670
|
}
|
|
667
|
-
measureContentBounds(_bounds) { }
|
|
668
|
-
getTransformedBoundsInternal(targetCoordinateSpace, resultRect) {
|
|
669
|
-
const bounds = this
|
|
671
|
+
$measureContentBounds(_bounds) { }
|
|
672
|
+
$getTransformedBoundsInternal(targetCoordinateSpace, resultRect) {
|
|
673
|
+
const bounds = this.$getOriginalBounds();
|
|
670
674
|
if (!resultRect) {
|
|
671
675
|
resultRect = new Rectangle();
|
|
672
676
|
}
|
|
@@ -675,46 +679,46 @@ export class DisplayObject extends EventDispatcher {
|
|
|
675
679
|
return resultRect;
|
|
676
680
|
}
|
|
677
681
|
const m = sharedMatrix;
|
|
678
|
-
targetCoordinateSpace
|
|
682
|
+
targetCoordinateSpace.$getInvertedConcatenatedMatrix().preMultiplyInto(this.$getConcatenatedMatrix(), m);
|
|
679
683
|
m.transformBounds(resultRect);
|
|
680
684
|
return resultRect;
|
|
681
685
|
}
|
|
682
|
-
getConcatenatedMatrixAt(root, matrix) {
|
|
683
|
-
const invertMatrix = root
|
|
686
|
+
$getConcatenatedMatrixAt(root, matrix) {
|
|
687
|
+
const invertMatrix = root.$getInvertedConcatenatedMatrix();
|
|
684
688
|
if ((invertMatrix.a === 0 || invertMatrix.d === 0) && (invertMatrix.b === 0 || invertMatrix.c === 0)) {
|
|
685
689
|
let target = this;
|
|
686
|
-
const rootLevel = root
|
|
690
|
+
const rootLevel = root.$nestLevel;
|
|
687
691
|
matrix.identity();
|
|
688
|
-
while (target
|
|
689
|
-
const rect = target
|
|
692
|
+
while (target.$nestLevel > rootLevel) {
|
|
693
|
+
const rect = target.$scrollRect;
|
|
690
694
|
if (rect)
|
|
691
695
|
matrix.concat(sharedMatrix.setTo(1, 0, 0, 1, -rect.x, -rect.y));
|
|
692
|
-
matrix.concat(target
|
|
693
|
-
target = target
|
|
696
|
+
matrix.concat(target.$getMatrix());
|
|
697
|
+
target = target.$parent;
|
|
694
698
|
}
|
|
695
699
|
}
|
|
696
700
|
else {
|
|
697
701
|
invertMatrix.preMultiplyInto(matrix, matrix);
|
|
698
702
|
}
|
|
699
703
|
}
|
|
700
|
-
hitTest(stageX, stageY) {
|
|
701
|
-
if (!this
|
|
704
|
+
$hitTest(stageX, stageY) {
|
|
705
|
+
if (!this.$visible || this._scaleX === 0 || this._scaleY === 0) {
|
|
702
706
|
return undefined;
|
|
703
707
|
}
|
|
704
|
-
const m = this
|
|
708
|
+
const m = this.$getInvertedConcatenatedMatrix();
|
|
705
709
|
if (m.a === 0 && m.b === 0 && m.c === 0 && m.d === 0) {
|
|
706
710
|
return undefined;
|
|
707
711
|
}
|
|
708
|
-
const bounds = this
|
|
712
|
+
const bounds = this.$getContentBounds();
|
|
709
713
|
const localX = m.a * stageX + m.c * stageY + m.tx;
|
|
710
714
|
const localY = m.b * stageX + m.d * stageY + m.ty;
|
|
711
715
|
if (bounds.contains(localX, localY)) {
|
|
712
|
-
if (!this
|
|
713
|
-
const rect = this
|
|
716
|
+
if (!this.$children) {
|
|
717
|
+
const rect = this.$scrollRect ?? this.$maskRect;
|
|
714
718
|
if (rect && !rect.contains(localX, localY)) {
|
|
715
719
|
return undefined;
|
|
716
720
|
}
|
|
717
|
-
if (this
|
|
721
|
+
if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) {
|
|
718
722
|
return undefined;
|
|
719
723
|
}
|
|
720
724
|
}
|
|
@@ -722,17 +726,17 @@ export class DisplayObject extends EventDispatcher {
|
|
|
722
726
|
}
|
|
723
727
|
return undefined;
|
|
724
728
|
}
|
|
725
|
-
updateRenderNode() { }
|
|
726
|
-
getPropagationList(target) {
|
|
729
|
+
$updateRenderNode() { }
|
|
730
|
+
$getPropagationList(target) {
|
|
727
731
|
const list = [];
|
|
728
732
|
let current = target;
|
|
729
733
|
while (current) {
|
|
730
734
|
list.push(current);
|
|
731
|
-
current = current
|
|
735
|
+
current = current.$parent;
|
|
732
736
|
}
|
|
733
737
|
return [...[...list].reverse(), ...list];
|
|
734
738
|
}
|
|
735
|
-
dispatchPropagationEvent(event, list, targetIndex) {
|
|
739
|
+
$dispatchPropagationEvent(event, list, targetIndex) {
|
|
736
740
|
for (let i = 0; i < list.length; i++) {
|
|
737
741
|
const currentTarget = list[i];
|
|
738
742
|
let phase;
|
|
@@ -754,73 +758,73 @@ export class DisplayObject extends EventDispatcher {
|
|
|
754
758
|
}
|
|
755
759
|
}
|
|
756
760
|
// ── Private methods ───────────────────────────────────────────────────────
|
|
757
|
-
setMask(value) {
|
|
761
|
+
$setMask(value) {
|
|
758
762
|
if (value === this) {
|
|
759
763
|
return;
|
|
760
764
|
}
|
|
761
765
|
if (value instanceof DisplayObject) {
|
|
762
|
-
if (value === this
|
|
766
|
+
if (value === this.$mask) {
|
|
763
767
|
return;
|
|
764
768
|
}
|
|
765
|
-
if (value
|
|
766
|
-
value
|
|
769
|
+
if (value.$maskedObject) {
|
|
770
|
+
value.$maskedObject.mask = undefined;
|
|
767
771
|
}
|
|
768
|
-
value
|
|
769
|
-
this
|
|
770
|
-
this
|
|
772
|
+
value.$maskedObject = this;
|
|
773
|
+
this.$mask = value;
|
|
774
|
+
this.$maskRect = undefined;
|
|
771
775
|
}
|
|
772
776
|
else if (value instanceof Rectangle) {
|
|
773
|
-
if (!this
|
|
774
|
-
this
|
|
777
|
+
if (!this.$maskRect) {
|
|
778
|
+
this.$maskRect = new Rectangle();
|
|
775
779
|
}
|
|
776
|
-
this.
|
|
777
|
-
if (this
|
|
778
|
-
this
|
|
779
|
-
this
|
|
780
|
+
this.$maskRect.copyFrom(value);
|
|
781
|
+
if (this.$mask) {
|
|
782
|
+
this.$mask.$maskedObject = undefined;
|
|
783
|
+
this.$mask = undefined;
|
|
780
784
|
}
|
|
781
785
|
}
|
|
782
786
|
else {
|
|
783
|
-
if (this
|
|
784
|
-
this
|
|
785
|
-
this
|
|
787
|
+
if (this.$mask) {
|
|
788
|
+
this.$mask.$maskedObject = undefined;
|
|
789
|
+
this.$mask = undefined;
|
|
786
790
|
}
|
|
787
|
-
this
|
|
791
|
+
this.$maskRect = undefined;
|
|
788
792
|
}
|
|
789
|
-
this
|
|
790
|
-
this
|
|
793
|
+
this.$updateRenderMode();
|
|
794
|
+
this.$markDirty();
|
|
791
795
|
}
|
|
792
|
-
markDirty() {
|
|
793
|
-
this
|
|
796
|
+
$markDirty() {
|
|
797
|
+
this.$renderDirty = true;
|
|
794
798
|
this._boundsDirty = true;
|
|
795
799
|
// Update cached world alpha and tint so _refreshLeafTransform can read
|
|
796
800
|
// them in O(1) without walking the parent chain.
|
|
797
|
-
let alpha = this
|
|
798
|
-
let tint = this
|
|
799
|
-
let p = this
|
|
801
|
+
let alpha = this.$alpha;
|
|
802
|
+
let tint = this.$tintRGB;
|
|
803
|
+
let p = this.$parent;
|
|
800
804
|
while (p) {
|
|
801
|
-
alpha *= p
|
|
802
|
-
if (p
|
|
803
|
-
tint = p
|
|
805
|
+
alpha *= p.$alpha;
|
|
806
|
+
if (p.$tintRGB !== 0xffffff) {
|
|
807
|
+
tint = p.$tintRGB;
|
|
804
808
|
}
|
|
805
|
-
p = p
|
|
809
|
+
p = p.$parent;
|
|
806
810
|
}
|
|
807
|
-
this
|
|
808
|
-
this
|
|
811
|
+
this.$worldAlpha = alpha;
|
|
812
|
+
this.$worldTint = tint;
|
|
809
813
|
// Notify the renderer that this object's data changed.
|
|
810
|
-
DisplayObject
|
|
811
|
-
const parent = this
|
|
812
|
-
if (parent && !parent
|
|
813
|
-
parent
|
|
814
|
-
parent
|
|
815
|
-
}
|
|
816
|
-
if (parent && !parent
|
|
817
|
-
parent
|
|
818
|
-
parent
|
|
819
|
-
}
|
|
820
|
-
const masked = this
|
|
821
|
-
if (masked && !masked
|
|
822
|
-
masked
|
|
823
|
-
masked
|
|
814
|
+
DisplayObject.$onRenderableDirty?.(this);
|
|
815
|
+
const parent = this.$parent;
|
|
816
|
+
if (parent && !parent.$cacheDirty) {
|
|
817
|
+
parent.$cacheDirty = true;
|
|
818
|
+
parent.$cacheDirtyUp();
|
|
819
|
+
}
|
|
820
|
+
if (parent && !parent.$renderDirty) {
|
|
821
|
+
parent.$renderDirty = true;
|
|
822
|
+
parent.$renderDirtyUp();
|
|
823
|
+
}
|
|
824
|
+
const masked = this.$maskedObject;
|
|
825
|
+
if (masked && !masked.$cacheDirty) {
|
|
826
|
+
masked.$cacheDirty = true;
|
|
827
|
+
masked.$cacheDirtyUp();
|
|
824
828
|
}
|
|
825
829
|
}
|
|
826
830
|
}
|