@next2d/display 3.15.1 → 3.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/display",
3
- "version": "3.15.1",
3
+ "version": "3.17.0",
4
4
  "description": "Next2D Display Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/ui": "3.15.1",
28
- "@next2d/text": "3.15.1",
29
- "@next2d/geom": "3.15.1",
30
- "@next2d/media": "3.15.1",
31
- "@next2d/net": "3.15.1",
32
- "@next2d/events": "3.15.1",
33
- "@next2d/filters": "3.15.1",
34
- "@next2d/render-queue": "3.15.1"
27
+ "@next2d/ui": "3.17.0",
28
+ "@next2d/text": "3.17.0",
29
+ "@next2d/geom": "3.17.0",
30
+ "@next2d/media": "3.17.0",
31
+ "@next2d/net": "3.17.0",
32
+ "@next2d/events": "3.17.0",
33
+ "@next2d/filters": "3.17.0",
34
+ "@next2d/render-queue": "3.17.0"
35
35
  }
36
36
  }
package/src/BitmapData.js CHANGED
@@ -20,44 +20,6 @@ export class BitmapData {
20
20
  * @public
21
21
  */
22
22
  constructor(width = 0, height = 0) {
23
- /**
24
- * @description ビットマップイメージの幅(ピクセル単位)です。
25
- * The width of the bitmap image in pixels.
26
- *
27
- * @return {number}
28
- * @readonly
29
- * @public
30
- */
31
- Object.defineProperty(this, "width", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- /**
38
- * @description ビットマップイメージの高さ(ピクセル単位)です。
39
- * The height of the bitmap image in pixels.
40
- *
41
- * @return {number}
42
- * @readonly
43
- * @public
44
- */
45
- Object.defineProperty(this, "height", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: void 0
50
- });
51
- /**
52
- * @type {Uint8Array | null}
53
- * @public
54
- */
55
- Object.defineProperty(this, "buffer", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: void 0
60
- });
61
23
  this.width = width | 0;
62
24
  this.height = height | 0;
63
25
  this.buffer = null;
@@ -2,6 +2,19 @@
2
2
  * @description 描画で利用するFloat32Arrayからハッシュ値を生成します。
3
3
  * Generates a hash value from the Float32Array used for drawing.
4
4
  *
5
+ * 図形を初めて描くときに、その描画データ全体に対して呼ばれる。1 バイトごとに乗算する
6
+ * FNV-1a では 1 要素につき 4 回の乗算になり、画面を切り替えた直後のフレームで目立つ
7
+ * 時間を取っていた。1 要素 (32bit) につき乗算 1 回にし、乗算では上位ビットの違いが
8
+ * 下位へ伝わらないので、毎回上位ビットを下位へ折り返して混ぜる。
9
+ * (折り返しが無いと、符号ビットだけが 2 か所で異なるデータ = 反転した図形 が同じ値になる)
10
+ *
11
+ * Called over the whole drawing data the first time a shape is drawn. Byte-wise FNV-1a
12
+ * costs four multiplications per element, which took a noticeable share of the frame
13
+ * right after a screen change. This uses one multiplication per 32-bit element and
14
+ * folds the high bits down after each one, because a multiplication never carries
15
+ * differences in high bits downwards (without the fold, data differing only in the sign
16
+ * bit at two places, i.e. mirrored shapes, would produce the same value).
17
+ *
5
18
  * @param {Float32Array} buffer
6
19
  * @return {number}
7
20
  * @method
@@ -2,6 +2,19 @@
2
2
  * @description 描画で利用するFloat32Arrayからハッシュ値を生成します。
3
3
  * Generates a hash value from the Float32Array used for drawing.
4
4
  *
5
+ * 図形を初めて描くときに、その描画データ全体に対して呼ばれる。1 バイトごとに乗算する
6
+ * FNV-1a では 1 要素につき 4 回の乗算になり、画面を切り替えた直後のフレームで目立つ
7
+ * 時間を取っていた。1 要素 (32bit) につき乗算 1 回にし、乗算では上位ビットの違いが
8
+ * 下位へ伝わらないので、毎回上位ビットを下位へ折り返して混ぜる。
9
+ * (折り返しが無いと、符号ビットだけが 2 か所で異なるデータ = 反転した図形 が同じ値になる)
10
+ *
11
+ * Called over the whole drawing data the first time a shape is drawn. Byte-wise FNV-1a
12
+ * costs four multiplications per element, which took a noticeable share of the frame
13
+ * right after a screen change. This uses one multiplication per 32-bit element and
14
+ * folds the high bits down after each one, because a multiplication never carries
15
+ * differences in high bits downwards (without the fold, data differing only in the sign
16
+ * bit at two places, i.e. mirrored shapes, would produce the same value).
17
+ *
5
18
  * @param {Float32Array} buffer
6
19
  * @return {number}
7
20
  * @method
@@ -11,60 +24,30 @@ export const execute = (buffer) => {
11
24
  // Float32ArrayのバッファをUint32Arrayとして直接参照(DataView不要)
12
25
  const bits = new Uint32Array(buffer.buffer, buffer.byteOffset, buffer.length);
13
26
  const len = bits.length;
14
- let hash = 2166136261; // FNV-1aオフセット basis
27
+ // 長さも混ぜる (末尾に 0 が続くデータを区別する)
28
+ let hash = 2166136261 ^ len;
15
29
  let idx = 0;
16
- // 8要素ずつ処理(ループアンローリング)
17
- const unrolledEnd = len & ~7; // len - (len % 8)
30
+ // 4要素ずつ処理(ループアンローリング)
31
+ const unrolledEnd = len & ~3;
18
32
  while (idx < unrolledEnd) {
19
- let b = bits[idx++];
20
- hash = Math.imul(hash ^ b & 0xff, 16777619);
21
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
22
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
23
- hash = Math.imul(hash ^ b >>> 24, 16777619);
24
- b = bits[idx++];
25
- hash = Math.imul(hash ^ b & 0xff, 16777619);
26
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
27
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
28
- hash = Math.imul(hash ^ b >>> 24, 16777619);
29
- b = bits[idx++];
30
- hash = Math.imul(hash ^ b & 0xff, 16777619);
31
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
32
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
33
- hash = Math.imul(hash ^ b >>> 24, 16777619);
34
- b = bits[idx++];
35
- hash = Math.imul(hash ^ b & 0xff, 16777619);
36
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
37
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
38
- hash = Math.imul(hash ^ b >>> 24, 16777619);
39
- b = bits[idx++];
40
- hash = Math.imul(hash ^ b & 0xff, 16777619);
41
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
42
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
43
- hash = Math.imul(hash ^ b >>> 24, 16777619);
44
- b = bits[idx++];
45
- hash = Math.imul(hash ^ b & 0xff, 16777619);
46
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
47
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
48
- hash = Math.imul(hash ^ b >>> 24, 16777619);
49
- b = bits[idx++];
50
- hash = Math.imul(hash ^ b & 0xff, 16777619);
51
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
52
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
53
- hash = Math.imul(hash ^ b >>> 24, 16777619);
54
- b = bits[idx++];
55
- hash = Math.imul(hash ^ b & 0xff, 16777619);
56
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
57
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
58
- hash = Math.imul(hash ^ b >>> 24, 16777619);
33
+ hash = Math.imul(hash ^ bits[idx], 0x9E3779B1);
34
+ hash ^= hash >>> 15;
35
+ hash = Math.imul(hash ^ bits[idx + 1], 0x9E3779B1);
36
+ hash ^= hash >>> 15;
37
+ hash = Math.imul(hash ^ bits[idx + 2], 0x9E3779B1);
38
+ hash ^= hash >>> 15;
39
+ hash = Math.imul(hash ^ bits[idx + 3], 0x9E3779B1);
40
+ hash ^= hash >>> 15;
41
+ idx += 4;
59
42
  }
60
- // 残り (0〜7要素)
43
+ // 残り (0〜3要素)
61
44
  while (idx < len) {
62
- const b = bits[idx++];
63
- hash = Math.imul(hash ^ b & 0xff, 16777619);
64
- hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
65
- hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
66
- hash = Math.imul(hash ^ b >>> 24, 16777619);
45
+ hash = Math.imul(hash ^ bits[idx++], 0x9E3779B1);
46
+ hash ^= hash >>> 15;
67
47
  }
48
+ // 仕上げの攪拌
49
+ hash = Math.imul(hash ^ hash >>> 16, 0x85EBCA6B);
50
+ hash ^= hash >>> 13;
68
51
  // 32bitハッシュ値を24bitに圧縮
69
- return hash >>> 8 ^ hash & 0xff & 0xffffff;
52
+ return (hash >>> 8 ^ hash & 0xff) & 0xffffff;
70
53
  };