@next2d/builder 0.1.8 → 0.1.11

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 (67) hide show
  1. package/dist/cli.d.ts +59 -0
  2. package/dist/cli.js +141 -0
  3. package/dist/constants.d.ts +53 -0
  4. package/dist/constants.js +64 -0
  5. package/dist/context.d.ts +29 -0
  6. package/dist/context.js +19 -0
  7. package/dist/electron.d.ts +10 -0
  8. package/dist/electron.js +142 -0
  9. package/dist/index.js +18 -790
  10. package/dist/native.d.ts +27 -0
  11. package/dist/native.js +123 -0
  12. package/dist/utils.d.ts +27 -0
  13. package/dist/utils.js +40 -0
  14. package/dist/web.d.ts +18 -0
  15. package/dist/web.js +70 -0
  16. package/dist/xbox.d.ts +62 -0
  17. package/dist/xbox.js +426 -0
  18. package/package.json +11 -9
  19. package/templates/xbox/CMakeLists.txt +47 -11
  20. package/templates/xbox/README.md +18 -0
  21. package/templates/xbox/js/bootstrap.js +120 -0
  22. package/templates/xbox/src/AssetLoader.cpp +115 -12
  23. package/templates/xbox/src/AssetLoader.h +4 -0
  24. package/templates/xbox/src/EmbeddedAssets.cpp +149 -0
  25. package/templates/xbox/src/EmbeddedAssets.h +60 -0
  26. package/templates/xbox/src/EventLoop.cpp +0 -15
  27. package/templates/xbox/src/bindings/Audio.cpp +118 -22
  28. package/templates/xbox/src/bindings/Canvas.cpp +32 -2
  29. package/templates/xbox/src/bindings/Canvas2D.cpp +495 -39
  30. package/templates/xbox/src/bindings/Console.cpp +6 -1
  31. package/templates/xbox/src/bindings/DomShims.cpp +18 -2
  32. package/templates/xbox/src/bindings/EventTarget.cpp +9 -0
  33. package/templates/xbox/src/bindings/Image.cpp +83 -57
  34. package/templates/xbox/src/bindings/Polyfills.cpp +671 -236
  35. package/templates/xbox/src/bindings/RasterCore.h +105 -1
  36. package/templates/xbox/src/bindings/Video.cpp +57 -3
  37. package/templates/xbox/src/bindings/webgpu/WebGPU.cpp +29 -3
  38. package/templates/xbox/src/bindings/webgpu/WebGPUCommon.h +4 -1
  39. package/templates/xbox/src/bindings/webgpu/WebGPUEnums.h +32 -0
  40. package/templates/xbox/src/gpu/DawnContext.cpp +167 -16
  41. package/templates/xbox/src/main.cpp +385 -16
  42. package/templates/xbox/src/platform/AudioDecoder.cpp +121 -0
  43. package/templates/xbox/src/platform/AudioDecoder.h +18 -0
  44. package/templates/xbox/src/platform/AudioEngine.cpp +28 -3
  45. package/templates/xbox/src/platform/DecodeQueue.cpp +136 -0
  46. package/templates/xbox/src/platform/DecodeQueue.h +27 -0
  47. package/templates/xbox/src/platform/ImageDecoder.cpp +44 -0
  48. package/templates/xbox/src/platform/ImageDecoder.h +18 -0
  49. package/templates/xbox/src/platform/StbTextRasterizer.cpp +324 -0
  50. package/templates/xbox/src/platform/StbTextRasterizer.h +37 -0
  51. package/templates/xbox/src/platform/TextRasterizer.cpp +32 -0
  52. package/templates/xbox/src/platform/WicDecoder.cpp +19 -0
  53. package/templates/xbox/src/v8/CodeCache.h +223 -0
  54. package/templates/xbox/src/v8/V8Runtime.cpp +34 -33
  55. package/templates/xbox/src/v8/V8Util.h +54 -4
  56. package/templates/xbox/src/worker/WorkerRuntime.cpp +165 -65
  57. package/templates/xbox/src/worker/WorkerRuntime.h +23 -3
  58. package/templates/xbox/tests/check_local.sh +5 -1
  59. package/templates/xbox/tests/gamecore_api_probe.cpp +172 -0
  60. package/templates/xbox/tests/raster_test.cpp +50 -0
  61. package/templates/xbox/tests/windows_platform_test.cpp +75 -3
  62. package/templates/xbox/third_party/LICENSES.md +14 -0
  63. package/templates/xbox/third_party/dr_mp3.h +5412 -0
  64. package/templates/xbox/third_party/dr_wav.h +9131 -0
  65. package/templates/xbox/third_party/stb_image.h +7988 -0
  66. package/templates/xbox/third_party/stb_truetype.h +5079 -0
  67. package/templates/xbox/third_party/stb_vorbis.c +5584 -0
@@ -257,6 +257,55 @@ static void TestTransformedFill()
257
257
  CHECK(Px(s, 33, 25).a == 0);
258
258
  }
259
259
 
260
+ // 任意形状クリップ (ピクセルマスク)。矩形は外接矩形、非矩形はマスクで厳密クリップ。
261
+ static void TestClipMask()
262
+ {
263
+ // 矩形パスは mask を作らない (IsAxisAlignedRect が true)。
264
+ std::vector<SubPath> rect = { MakeRectPath(2, 2, 5, 5) };
265
+ CHECK(IsAxisAlignedRect(rect));
266
+
267
+ // 左上三角 (0,0),(10,0),(0,10) — 内側は x+y<10。
268
+ std::vector<SubPath> tri(1);
269
+ tri[0].pts = { {0,0}, {10,0}, {0,10} };
270
+ tri[0].closed = true;
271
+ CHECK(!IsAxisAlignedRect(tri));
272
+
273
+ ClipRect clip;
274
+ IntersectClipMask(clip, tri, 10, 10);
275
+ CHECK(clip.mask != nullptr);
276
+ CHECK(clip.mask_w == 10 && clip.mask_h == 10);
277
+
278
+ // 全面塗りが三角形にクリップされる。
279
+ Surface s(10, 10);
280
+ std::vector<SubPath> full = { MakeRectPath(0, 0, 10, 10) };
281
+ FillPath(s, clip, full, {255, 0, 0, 255}, 1.0);
282
+ CHECK(Px(s, 1, 1).r == 255); // 深く内側
283
+ CHECK(Px(s, 1, 2).r == 255);
284
+ CHECK(Px(s, 9, 9).a == 0); // 深く外側 (x+y=18)
285
+ CHECK(Px(s, 8, 8).a == 0); // 外側 (x+y=16)
286
+
287
+ // Blend も直接マスクに従う。
288
+ Surface s2(10, 10);
289
+ Blend(s2, clip, 1, 1, {0, 255, 0, 255}, 1.0); // 内側 → 描かれる
290
+ Blend(s2, clip, 9, 9, {0, 255, 0, 255}, 1.0); // 外側 → 描かれない
291
+ CHECK(Px(s2, 1, 1).g == 255);
292
+ CHECK(Px(s2, 9, 9).a == 0);
293
+
294
+ // マスク同士の積集合: 左上三角 ∩ 右下三角 は (1,1) を除外する。
295
+ ClipRect clip2;
296
+ IntersectClipMask(clip2, tri, 10, 10);
297
+ std::vector<SubPath> tri2(1);
298
+ tri2[0].pts = { {10,0}, {10,10}, {0,10} }; // 右下三角 (内側 x+y>10)
299
+ tri2[0].closed = true;
300
+ IntersectClipMask(clip2, tri2, 10, 10);
301
+ Surface s3(10, 10);
302
+ FillPath(s3, clip2, full, {0, 0, 255, 255}, 1.0);
303
+ CHECK(Px(s3, 1, 1).a == 0); // 左上三角内だが右下三角外 → 積集合で除外
304
+
305
+ // 非矩形クリップでも外接矩形 (高速リジェクト) は反映される。
306
+ CHECK(clip.active);
307
+ }
308
+
260
309
  int main()
261
310
  {
262
311
  TestParseColor();
@@ -272,6 +321,7 @@ int main()
272
321
  TestFlattenCurves();
273
322
  TestPathBounds();
274
323
  TestTransformedFill();
324
+ TestClipMask();
275
325
 
276
326
  std::printf("%s: %d checks, %d failures\n",
277
327
  failures ? "FAILED" : "ok", checks, failures);
@@ -3,9 +3,10 @@
3
3
  // windows-latest ランナーで実行して「Windows 上で実際に動く」ことを検証する。
4
4
  //
5
5
  // ビルド (Developer Command Prompt / CI):
6
- // cl /std:c++17 /EHsc /Isrc tests\windows_platform_test.cpp ^
6
+ // cl /std:c++17 /EHsc /Isrc /I. tests\windows_platform_test.cpp ^
7
7
  // src\platform\WicDecoder.cpp src\platform\TextRasterizer.cpp ^
8
8
  // src\platform\AudioEngine.cpp ^
9
+ // src\platform\ImageDecoder.cpp src\platform\AudioDecoder.cpp ^
9
10
  // ole32.lib windowscodecs.lib d2d1.lib dwrite.lib ^
10
11
  // mfplat.lib mfreadwrite.lib mfuuid.lib xaudio2.lib shlwapi.lib
11
12
  //
@@ -16,9 +17,14 @@
16
17
  #endif
17
18
 
18
19
  #include "../src/platform/WicDecoder.h"
20
+ #include "../src/platform/ImageDecoder.h"
21
+ #include "../src/platform/AudioDecoder.h"
19
22
  #include "../src/platform/TextRasterizer.h"
23
+ #include "../src/platform/StbTextRasterizer.h"
20
24
  #include "../src/platform/AudioEngine.h"
21
25
 
26
+ #include <fstream>
27
+
22
28
  #include <Windows.h>
23
29
  #include <mfapi.h>
24
30
 
@@ -89,6 +95,24 @@ static void TestWicDecode()
89
95
  CHECK(!next2d::DecodeImageWithWIC(garbage, bad));
90
96
  }
91
97
 
98
+ // --- ImageDecoder: 本番の第一経路 (stb_image。コンソールでも同一コード) --------
99
+ static void TestImageDecoder()
100
+ {
101
+ std::vector<uint8_t> png(kTestPng, kTestPng + sizeof(kTestPng));
102
+ next2d::DecodedImage img;
103
+ CHECK(next2d::DecodeImage(png, img));
104
+ CHECK(img.width == 2 && img.height == 2);
105
+ CHECK(img.rgba.size() == 16);
106
+ CHECK(img.rgba[0] == 255 && img.rgba[1] == 0 && img.rgba[2] == 0 && img.rgba[3] == 255);
107
+ CHECK(img.rgba[4] == 0 && img.rgba[5] == 255 && img.rgba[6] == 0);
108
+ CHECK(img.rgba[8] == 0 && img.rgba[9] == 0 && img.rgba[10] == 255);
109
+ CHECK(img.rgba[15] == 128);
110
+
111
+ std::vector<uint8_t> garbage(32, 0xAB);
112
+ next2d::DecodedImage bad;
113
+ CHECK(!next2d::DecodeImage(garbage, bad));
114
+ }
115
+
92
116
  // --- DirectWrite: メトリクスとグリフラスタライズ (fillText の実体) ----------
93
117
  static void TestTextRasterizer()
94
118
  {
@@ -131,7 +155,43 @@ static void TestTextRasterizer()
131
155
  CHECK(!next2d::RasterizeTextWithDWrite("24px Segoe UI", L"", 0, 0, 0, empty));
132
156
  }
133
157
 
134
- // --- Media Foundation: 音声デコード (decodeAudioData の実体) -----------------
158
+ // --- stb_truetype: コンソールのテキスト経路 (TextRasterizer の #else 分岐実体) --
159
+ // コンソールでは DirectWrite が無く StbTextRasterizer が fillText/measureText を
160
+ // 担う。Windows の実フォント (arial.ttf) で同一コードを検証する。
161
+ static void TestStbText()
162
+ {
163
+ // フォント未登録では false
164
+ next2d::TextMetricsInfo none;
165
+ CHECK(!next2d::stbtext::MeasureText("24px Arial", L"Hi", none));
166
+
167
+ wchar_t windir[MAX_PATH] = {};
168
+ GetEnvironmentVariableW(L"WINDIR", windir, MAX_PATH);
169
+ std::wstring font_path = std::wstring(windir) + L"\\Fonts\\arial.ttf";
170
+ std::ifstream ifs(font_path.c_str(), std::ios::binary);
171
+ std::vector<uint8_t> font((std::istreambuf_iterator<char>(ifs)),
172
+ std::istreambuf_iterator<char>());
173
+ CHECK(!font.empty());
174
+ CHECK(next2d::stbtext::RegisterFont("Arial", std::move(font)));
175
+
176
+ next2d::TextMetricsInfo m;
177
+ CHECK(next2d::stbtext::MeasureText("24px Arial", L"Hello", m));
178
+ CHECK(m.width > 10.0 && m.width < 200.0);
179
+ CHECK(m.ascent > 5.0 && m.ascent < 40.0);
180
+
181
+ next2d::TextBitmap bmp;
182
+ CHECK(next2d::stbtext::RasterizeText("24px Arial", L"A", 255, 0, 0, bmp));
183
+ CHECK(bmp.width > 0 && bmp.height > 0 && bmp.baseline > 0);
184
+ int opaque = 0;
185
+ for (size_t i = 3; i < bmp.rgba.size(); i += 4) if (bmp.rgba[i] > 200) ++opaque;
186
+ CHECK(opaque > 5);
187
+
188
+ next2d::TextBitmap empty;
189
+ CHECK(!next2d::stbtext::RasterizeText("24px Arial", L"", 0, 0, 0, empty));
190
+ }
191
+
192
+ // --- 音声デコード (decodeAudioData の実体) -----------------------------------
193
+ // AudioEngine::Decode は第一経路 dr_wav/dr_mp3/stb_vorbis (コンソールでも同一)、
194
+ // フォールバックが Media Foundation。両経路を検証する。
135
195
  static void TestAudioDecode()
136
196
  {
137
197
  std::vector<uint8_t> wav(kTestWav, kTestWav + sizeof(kTestWav));
@@ -139,11 +199,21 @@ static void TestAudioDecode()
139
199
  CHECK(next2d::AudioEngine::Decode(wav, pcm));
140
200
  CHECK(pcm.sample_rate == 48000);
141
201
  CHECK(pcm.channels == 1);
142
- CHECK(pcm.samples.size() >= 40); // 48 サンプル前後 (MF は端数調整あり)
202
+ CHECK(pcm.samples.size() >= 40); // 48 サンプル前後
143
203
  // 振幅 0.5 の矩形波 → ピーク絶対値が 0.4〜0.6
144
204
  float peak = 0;
145
205
  for (float s : pcm.samples) peak = std::max(peak, std::fabs(s));
146
206
  CHECK(peak > 0.4f && peak < 0.6f);
207
+
208
+ // ポータブルデコーダ単体 (本番の第一経路) も直接検証
209
+ next2d::PcmBuffer pcm2;
210
+ CHECK(next2d::DecodeAudio(wav, pcm2));
211
+ CHECK(pcm2.sample_rate == 48000 && pcm2.channels == 1);
212
+ CHECK(pcm2.samples.size() >= 40);
213
+
214
+ std::vector<uint8_t> garbage(32, 0xAB);
215
+ next2d::PcmBuffer bad;
216
+ CHECK(!next2d::DecodeAudio(garbage, bad));
147
217
  }
148
218
 
149
219
  // --- XAudio2: 初期化 (ヘッドレス CI では音声デバイスが無く失敗し得る → warn) --
@@ -175,7 +245,9 @@ int main()
175
245
  MFStartup(MF_VERSION);
176
246
 
177
247
  TestWicDecode();
248
+ TestImageDecoder();
178
249
  TestTextRasterizer();
250
+ TestStbText();
179
251
  TestAudioDecode();
180
252
  TestAudioEngineInit();
181
253
 
@@ -0,0 +1,14 @@
1
+ # third_party ライセンス
2
+
3
+ コンソール (Game Core OS) には WIC / Media Foundation / DirectWrite が存在しないため、
4
+ 画像・音声デコードはヘッダオンリーのポータブルデコーダを第一経路として使用する。
5
+
6
+ | ファイル | 提供元 | ライセンス |
7
+ |---|---|---|
8
+ | stb_image.h | https://github.com/nothings/stb | public domain (Unlicense) / MIT のデュアル |
9
+ | stb_truetype.h | https://github.com/nothings/stb | public domain (Unlicense) / MIT のデュアル |
10
+ | stb_vorbis.c | https://github.com/nothings/stb | public domain (Unlicense) / MIT のデュアル |
11
+ | dr_mp3.h | https://github.com/mackron/dr_libs | public domain (Unlicense) / MIT-0 のデュアル |
12
+ | dr_wav.h | https://github.com/mackron/dr_libs | public domain (Unlicense) / MIT-0 のデュアル |
13
+
14
+ いずれも各ファイル末尾に原文のライセンス条文が含まれる。