@swf2es/player-hosts 0.1.4 → 0.1.6

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.
Files changed (43) hide show
  1. package/dist/thread/format/bitmap.js +13 -14
  2. package/dist/thread/format/index.js +1 -1
  3. package/dist/thread/format/swf.js +11 -1
  4. package/dist/thread/player/avm1/globals/BitmapData.js +2 -1
  5. package/dist/thread/player/bitmap/composite.js +767 -0
  6. package/dist/thread/player/bitmap/draw.js +3 -3
  7. package/dist/thread/player/bitmap/filters.js +32 -32
  8. package/dist/thread/player/bitmap/ops.js +2 -766
  9. package/dist/thread/player/bitmap/pixel-bender.js +4 -1
  10. package/dist/thread/player/display/bounds.js +105 -0
  11. package/dist/thread/player/display/displayobject.js +1 -1
  12. package/dist/thread/player/display/drawing.js +25 -10
  13. package/dist/thread/player/display/instantiate.js +28 -29
  14. package/dist/thread/player/display/shapes.js +72 -54
  15. package/dist/thread/player/display/textobjects.js +34 -1
  16. package/dist/thread/player/player.js +4 -3
  17. package/dist/thread/player/playerglobal/flash/desktop/NativeApplication.js +1 -1
  18. package/dist/thread/player/playerglobal/flash/display/BitmapData.js +3 -2
  19. package/dist/thread/player/playerglobal/flash/display/DisplayObject.js +2 -2
  20. package/dist/thread/player/playerglobal/flash/display/SimpleButton.js +12 -11
  21. package/dist/thread/player/playerglobal/flash/display/Stage.js +2 -8
  22. package/dist/thread/player/playerglobal/flash/display/shaders.js +1 -1
  23. package/dist/thread/player/playerglobal/flash/filesystem/paths.js +1 -1
  24. package/dist/thread/player/playerglobal/flash/filesystem/writes.js +1 -1
  25. package/dist/thread/player/playerglobal/flash/globalization/locale.js +1 -1
  26. package/dist/thread/player/scripting/events.js +2 -2
  27. package/dist/thread/player/scripting/lifecycle.js +39 -19
  28. package/dist/thread/player/scripting/symbols.js +24 -30
  29. package/dist/thread/player/scripting.js +5 -9
  30. package/dist/thread/runtime/avm1/errors.js +1 -1
  31. package/dist/thread/runtime/avm1/numbers.js +7 -8
  32. package/dist/thread/runtime/avm2/amf.js +2 -1
  33. package/dist/thread/runtime/avm2/names.js +0 -4
  34. package/dist/thread/runtime/avm2/natives/bytearray.js +6 -166
  35. package/dist/thread/runtime/avm2/natives/regexp.js +68 -64
  36. package/dist/thread/runtime/avm2/natives/shell-workers.js +1 -1
  37. package/dist/thread/runtime/avm2/natives/shell.js +2 -1
  38. package/dist/thread/runtime/avm2/natives/xml/parser.js +2 -2
  39. package/dist/thread/runtime/avm2/numbers.js +1 -1
  40. package/dist/thread/runtime/avm2/runtime.js +10 -8
  41. package/dist/thread/runtime/avm2/traits.js +1 -1
  42. package/dist/thread/runtime/avm2/utf8.js +167 -0
  43. package/package.json +2 -2
@@ -1,12 +1,12 @@
1
1
  // A display object drawn into a bitmap: rendered by the host's renderer
2
- // over its own bounds alone, then composited as a bitmap is (ops.ts
3
- // drawBitmap). AS3's BitmapData.draw and AVM1's share it.
2
+ // over its own bounds alone, then composited as a bitmap is
3
+ // (composite.ts). AS3's BitmapData.draw and AVM1's share it.
4
4
  import { bounds } from "../display/bounds.js";
5
5
  import { pickWork } from "../display/display.js";
6
6
  import { transformRect } from "../display/geometry.js";
7
7
  import { drawnAsStage } from "../display/perspective.js";
8
8
  import { BitmapStore } from "./bitmap.js";
9
- import { drawBitmap } from "./ops.js";
9
+ import { drawBitmap } from "./composite.js";
10
10
  /** `d` drawn into `store` through `m`, as drawInto draws a display object. */
11
11
  function drawObject(drawer, store, d, m, c, blend, r, samples) {
12
12
  // Only the part the object can reach: its bounds through the matrix, a
@@ -52,17 +52,16 @@ function spreadOf(blur, quality, kind) {
52
52
  }
53
53
  /** How far a filter's rect reaches past what it filters, each way, before any offset: [x, y], whole pixels. */
54
54
  function reach(f) {
55
- if (f.kind === "convolution") {
56
- return [f.matrixX >> 1, f.matrixY >> 1];
57
- }
58
- if (f.kind === "colorMatrix") {
59
- return [0, 0];
60
- }
61
- // A displacement map's reach, by its scale, as adl reckons it: a quarter of it, whole; none with no map.
62
- if (f.kind === "displacementMap") {
63
- return f.mapBitmap
64
- ? [Math.floor(Math.abs(f.scaleX) / 4) || 0, Math.floor(Math.abs(f.scaleY) / 4) || 0]
65
- : [0, 0];
55
+ switch (f.kind) {
56
+ case "convolution":
57
+ return [f.matrixX >> 1, f.matrixY >> 1];
58
+ case "colorMatrix":
59
+ return [0, 0];
60
+ // A displacement map's reach, by its scale, as adl reckons it: a quarter of it, whole; none with no map.
61
+ case "displacementMap":
62
+ return f.mapBitmap
63
+ ? [Math.floor(Math.abs(f.scaleX) / 4) || 0, Math.floor(Math.abs(f.scaleY) / 4) || 0]
64
+ : [0, 0];
66
65
  }
67
66
  return [spreadOf(f.blurX, f.quality, f.kind), spreadOf(f.blurY, f.quality, f.kind)];
68
67
  }
@@ -291,29 +290,30 @@ export function applyFilter(dest, source, rect, dx, dy, given, map = null) {
291
290
  write(dest, displace(source, rect, shown, f, map), shown, shown, mx, my);
292
291
  return true;
293
292
  }
294
- if (f.kind === "convolution" && (f.matrixX === 0 || f.matrixY === 0)) {
295
- copyEmpty(dest, source, rect, out, shown, mx, my);
296
- return true;
297
- }
298
- if (f.kind === "convolution") {
299
- const pixels = convolve(source, shown, f, dest.transparent);
300
- if (pixels) {
301
- write(dest, pixels, shown, shown, mx, my);
293
+ switch (f.kind) {
294
+ case "convolution": {
295
+ if (f.matrixX === 0 || f.matrixY === 0) {
296
+ copyEmpty(dest, source, rect, out, shown, mx, my);
297
+ return true;
298
+ }
299
+ const pixels = convolve(source, shown, f, dest.transparent);
300
+ if (pixels) {
301
+ write(dest, pixels, shown, shown, mx, my);
302
+ }
303
+ return true;
302
304
  }
303
- return true;
304
- }
305
- if (f.kind === "colorMatrix") {
306
- colorMatrix(dest, source, rect, dx, dy, f.matrix);
307
- return true;
308
- }
309
- if (f.kind === "blur") {
310
- // What is shown, blurred as far round it as the blur reaches into it, which may be past the
311
- // rect, whose edge cuts what is written alone.
312
- const pixels = bitmapKernel()?.blur(source, shown, f.blurX, f.blurY, f.quality);
313
- if (pixels) {
314
- write(dest, pixels, shown, shown, mx, my);
305
+ case "colorMatrix":
306
+ colorMatrix(dest, source, rect, dx, dy, f.matrix);
307
+ return true;
308
+ case "blur": {
309
+ // What is shown, blurred as far round it as the blur reaches into it, which may be past the
310
+ // rect, whose edge cuts what is written alone.
311
+ const pixels = bitmapKernel()?.blur(source, shown, f.blurX, f.blurY, f.quality);
312
+ if (pixels) {
313
+ write(dest, pixels, shown, shown, mx, my);
314
+ }
315
+ return true;
315
316
  }
316
- return true;
317
317
  }
318
318
  // The source's pixels where they are shown, and its alpha blurred and read
319
319
  // from the offset, each over what is shown alone: however far the offset