xbintsc 0.7.0 → 0.7.7
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/src/ast/common.d.ts +10 -0
- package/dist/src/binder/references.js +13 -7
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +4 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +82 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +10 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +4 -24
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.js +11 -4
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +2 -2
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +11 -5
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +3 -0
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +4 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +53 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +20 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/parser/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/tests/binder/binder.test.js +26 -4
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/checker/checker.test.js +16 -0
- package/dist/tests/checker/checker.test.js.map +1 -1
- package/dist/tests/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +13 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- package/dist/tests/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-modules.test.js +13 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +66 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-events.test.js +89 -0
- package/dist/tests/e2e/gui-events.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-anisotropy.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-anisotropy.test.js +105 -0
- package/dist/tests/e2e/gui-webgl2-anisotropy.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-sampler-array.test.d.ts +11 -0
- package/dist/tests/e2e/gui-webgl2-sampler-array.test.js +117 -0
- package/dist/tests/e2e/gui-webgl2-sampler-array.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- package/dist/tests/e2e/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +35 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/input.md +8 -0
- package/doc/gui/known-issues.md +43 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/binder.md +1 -1
- package/doc/implemented/checker.md +9 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/parser.md +2 -1
- package/doc/implemented/runtime-core.md +9 -2
- package/doc/implemented/stdlib.md +10 -2
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/zh-CN/gui/api.md +27 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/input.md +7 -0
- package/doc/zh-CN/gui/known-issues.md +30 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/binder.md +1 -1
- package/doc/zh-CN/implemented/checker.md +7 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/parser.md +2 -1
- package/doc/zh-CN/implemented/runtime-core.md +9 -2
- package/doc/zh-CN/implemented/stdlib.md +6 -2
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +11 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api.cpp +4 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_events.cpp +2 -1
- package/runtime/ext_gui/dom_api_internal.h +11 -0
- package/runtime/ext_gui/dom_api_mutation.cpp +49 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +6 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +11 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +8 -1
- package/runtime/ext_gui/gui_engine.h +20 -2
- package/runtime/ext_gui/gui_events.cpp +31 -126
- package/runtime/ext_gui/gui_input.cpp +148 -0
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/pointer_lock.cpp +137 -0
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +26 -170
- package/runtime/ext_gui/webgl_context.cpp +119 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl.h +4 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_glsl_scan.cpp +14 -0
- package/runtime/ext_gui/webgl_objects.h +18 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_shader.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +11 -83
- package/runtime/ext_gui/window_diagnostics.cpp +94 -1
- package/runtime/rt.h +27 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +52 -60
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +88 -133
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_builtins.c +3 -1
- package/runtime/xt_constructors.c +1 -0
- package/runtime/xt_containers/access.inc +96 -11
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +47 -79
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +4 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +1 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +32 -6
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_stdlib/dispatch.inc +7 -1
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/json_stringify.inc +1 -2
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/src/ast/common.ts +10 -0
- package/src/binder/references.ts +13 -7
- package/src/checker/source.ts +3 -0
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +5 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +87 -1
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +11 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/primary.ts +4 -27
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/state.ts +5 -0
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/concatenate.ts +12 -5
- package/src/driver/bundler/graph.ts +2 -2
- package/src/driver/bundler/merge.ts +11 -4
- package/src/driver/bundler/reexport-resolution.ts +2 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/frontend.ts +3 -4
- package/src/driver/runtime-objects.ts +4 -0
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +55 -1
- package/src/extensions/registry.ts +20 -0
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
|
@@ -109,6 +109,12 @@ bool WebGLContext::tex_image_format(uint32_t id, int width, int height,
|
|
|
109
109
|
set_error(GL_INVALID_VALUE);
|
|
110
110
|
return false;
|
|
111
111
|
}
|
|
112
|
+
if (record->samples > 1) {
|
|
113
|
+
/* `texImage2D` cannot redefine a multisampled texture; it is allocated by
|
|
114
|
+
* `texStorage2DMultisample` and is a render target only. */
|
|
115
|
+
set_error(GL_INVALID_OPERATION);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
112
118
|
end_pass();
|
|
113
119
|
ensure_command();
|
|
114
120
|
if (cmd_ == nullptr) return false;
|
|
@@ -126,11 +132,15 @@ bool WebGLContext::tex_image_format(uint32_t id, int width, int height,
|
|
|
126
132
|
record->target = layer >= 0 ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
|
|
127
133
|
record->compressed = false;
|
|
128
134
|
record->has_mipmaps = false;
|
|
135
|
+
record->samples = 1;
|
|
129
136
|
if (record->sampler != nullptr) {
|
|
130
137
|
SDL_ReleaseGPUSampler(guidev::g_device, record->sampler);
|
|
131
138
|
record->sampler = nullptr;
|
|
132
139
|
}
|
|
133
140
|
}
|
|
141
|
+
/* `texImage2D` always defines a single-sampled texture; a multisampled one
|
|
142
|
+
* can only be created by `texStorage2DMultisample`. */
|
|
143
|
+
record->samples = 1;
|
|
134
144
|
if (ensure_texture_gpu(record, record->as_target || record->as_depth_target) == nullptr) {
|
|
135
145
|
return false;
|
|
136
146
|
}
|
|
@@ -154,6 +164,11 @@ bool WebGLContext::tex_sub_image_format(uint32_t id, int x, int y, int width, in
|
|
|
154
164
|
set_error(GL_INVALID_OPERATION);
|
|
155
165
|
return false;
|
|
156
166
|
}
|
|
167
|
+
if (record->samples > 1) {
|
|
168
|
+
/* A multisampled texture has no uploadable levels. */
|
|
169
|
+
set_error(GL_INVALID_OPERATION);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
157
172
|
if (x < 0 || y < 0 || width <= 0 || height <= 0 || x + width > record->width ||
|
|
158
173
|
y + height > record->height) {
|
|
159
174
|
set_error(GL_INVALID_VALUE);
|
|
@@ -196,33 +211,24 @@ bool WebGLContext::generate_mipmap(uint32_t id) {
|
|
|
196
211
|
|
|
197
212
|
bool WebGLContext::read_pixels(int x, int y, int width, int height, uint8_t *out) {
|
|
198
213
|
if (out == nullptr || width <= 0 || height <= 0) return false;
|
|
199
|
-
if (
|
|
214
|
+
if (bound_framebuffer_ != 0 && framebuffer_samples(bound_framebuffer_) > 1) {
|
|
215
|
+
/* ES 3.0 §4.3.1: reading a multisampled framebuffer directly is an error.
|
|
216
|
+
* The page resolves it with `blitFramebuffer` first. The default
|
|
217
|
+
* framebuffer is exempt because its resolve target is always current. */
|
|
218
|
+
set_error(GL_INVALID_OPERATION);
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
int target_width = 0;
|
|
222
|
+
int target_height = 0;
|
|
223
|
+
int target_format = 0;
|
|
224
|
+
SDL_GPUTexture *target = read_color_texture(bound_framebuffer_, &target_width, &target_height,
|
|
225
|
+
&target_format);
|
|
226
|
+
if (target_format != (int)SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM) {
|
|
200
227
|
/* The only readback this surface offers is RGBA8; a float/half colour
|
|
201
228
|
* target is read by rendering it into an RGBA8 target instead. */
|
|
202
229
|
set_error(GL_INVALID_OPERATION);
|
|
203
230
|
return false;
|
|
204
231
|
}
|
|
205
|
-
SDL_GPUTexture *target = target_color();
|
|
206
|
-
if (bound_framebuffer_ != 0) {
|
|
207
|
-
WebGLFramebuffer *framebuffer = this->framebuffer(bound_framebuffer_);
|
|
208
|
-
if (framebuffer != nullptr) {
|
|
209
|
-
int index = read_buffer_ - GL_COLOR_ATTACHMENT0;
|
|
210
|
-
if (index < 0 || index >= kWebGLMaxDrawBuffers ||
|
|
211
|
-
framebuffer->color_textures[index] == 0) {
|
|
212
|
-
index = 0;
|
|
213
|
-
}
|
|
214
|
-
WebGLTexture *read_texture = texture(framebuffer->color_textures[index]);
|
|
215
|
-
target = read_texture != nullptr ? ensure_texture_gpu(read_texture, true) : nullptr;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
int target_width = bound_framebuffer_ == 0 ? width_ : 0;
|
|
219
|
-
int target_height = bound_framebuffer_ == 0 ? height_ : 0;
|
|
220
|
-
if (bound_framebuffer_ != 0) {
|
|
221
|
-
WebGLFramebuffer *framebuffer_ = framebuffer(bound_framebuffer_);
|
|
222
|
-
if (framebuffer_ == nullptr) return false;
|
|
223
|
-
target_width = framebuffer_->width;
|
|
224
|
-
target_height = framebuffer_->height;
|
|
225
|
-
}
|
|
226
232
|
if (target == nullptr || target_width <= 0 || target_height <= 0) return false;
|
|
227
233
|
/* Clamp to the target; pixels outside are transparent black. */
|
|
228
234
|
const int px = std::max(0, x);
|
|
@@ -249,9 +255,12 @@ bool WebGLContext::read_pixels(int x, int y, int width, int height, uint8_t *out
|
|
|
249
255
|
SDL_GPUTextureRegion region;
|
|
250
256
|
memset(®ion, 0, sizeof(region));
|
|
251
257
|
region.texture = target;
|
|
252
|
-
/*
|
|
258
|
+
/* `readPixels`' y counts from GL's bottom edge; where that lands in storage
|
|
259
|
+
* depends on the target's convention (the drawing buffer is top-down, a user
|
|
260
|
+
* framebuffer is bottom-up). */
|
|
261
|
+
const bool top_down = webgl_target_top_down(bound_framebuffer_);
|
|
253
262
|
region.x = (Uint32)px;
|
|
254
|
-
region.y = (Uint32)(target_height
|
|
263
|
+
region.y = (Uint32)webgl_target_rect_y(top_down, target_height, py, ph);
|
|
255
264
|
region.w = (Uint32)pw;
|
|
256
265
|
region.h = (Uint32)ph;
|
|
257
266
|
region.d = 1;
|
|
@@ -277,7 +286,10 @@ bool WebGLContext::read_pixels(int x, int y, int width, int height, uint8_t *out
|
|
|
277
286
|
return false;
|
|
278
287
|
}
|
|
279
288
|
for (int row = 0; row < ph; row++) {
|
|
280
|
-
|
|
289
|
+
/* A top-down target stores GL's bottom row last, so the downloaded rows are
|
|
290
|
+
* reversed; a bottom-up user framebuffer is already in GL order. */
|
|
291
|
+
const int source_row = top_down ? ph - 1 - row : row;
|
|
292
|
+
const uint8_t *source = mapped + (size_t)source_row * pw * 4;
|
|
281
293
|
uint8_t *line = out + ((size_t)(py - y + row) * width + (px - x)) * 4;
|
|
282
294
|
memcpy(line, source, (size_t)pw * 4);
|
|
283
295
|
}
|
|
@@ -310,6 +322,7 @@ bool WebGLContext::tex_storage_format(uint32_t id, int levels, int width, int he
|
|
|
310
322
|
record->target = GL_TEXTURE_2D;
|
|
311
323
|
record->compressed = false;
|
|
312
324
|
record->has_mipmaps = false;
|
|
325
|
+
record->samples = 1;
|
|
313
326
|
if (record->sampler != nullptr && guidev::g_device != nullptr) {
|
|
314
327
|
SDL_ReleaseGPUSampler(guidev::g_device, record->sampler);
|
|
315
328
|
record->sampler = nullptr;
|
|
@@ -318,6 +331,49 @@ bool WebGLContext::tex_storage_format(uint32_t id, int levels, int width, int he
|
|
|
318
331
|
return ensure_texture_gpu(record, record->as_target || record->as_depth_target) != nullptr;
|
|
319
332
|
}
|
|
320
333
|
|
|
334
|
+
bool WebGLContext::tex_storage_2d_multisample(uint32_t id, int samples,
|
|
335
|
+
SDL_GPUTextureFormat format, int width,
|
|
336
|
+
int height) {
|
|
337
|
+
WebGLTexture *record = texture(id);
|
|
338
|
+
if (record == nullptr) return false;
|
|
339
|
+
if (samples < 2 || samples > kWebGLMaxSamples) {
|
|
340
|
+
set_error(GL_INVALID_VALUE);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
int granted_samples = samples;
|
|
344
|
+
if (!multisample_supported_ ||
|
|
345
|
+
!SDL_GPUTextureSupportsSampleCount(guidev::g_device, format,
|
|
346
|
+
webgl_sample_count(samples))) {
|
|
347
|
+
/* A backend without MSAA cannot resolve a multisampled texture; allocate
|
|
348
|
+
* the single-sampled storage the page can still attach and resolve. */
|
|
349
|
+
granted_samples = 1;
|
|
350
|
+
}
|
|
351
|
+
if (width <= 0 || height <= 0) {
|
|
352
|
+
set_error(GL_INVALID_VALUE);
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
end_pass();
|
|
356
|
+
ensure_command();
|
|
357
|
+
if (record->gpu != nullptr) {
|
|
358
|
+
submit();
|
|
359
|
+
SDL_WaitForGPUIdle(guidev::g_device);
|
|
360
|
+
SDL_ReleaseGPUTexture(guidev::g_device, record->gpu);
|
|
361
|
+
record->gpu = nullptr;
|
|
362
|
+
record->usage = 0;
|
|
363
|
+
}
|
|
364
|
+
record->width = width;
|
|
365
|
+
record->height = height;
|
|
366
|
+
record->format = format;
|
|
367
|
+
record->layers = 1;
|
|
368
|
+
record->target = GL_TEXTURE_2D;
|
|
369
|
+
record->compressed = false;
|
|
370
|
+
record->has_mipmaps = false;
|
|
371
|
+
record->samples = granted_samples;
|
|
372
|
+
record->as_target = true;
|
|
373
|
+
record->defined = true;
|
|
374
|
+
return ensure_texture_gpu(record, true) != nullptr;
|
|
375
|
+
}
|
|
376
|
+
|
|
321
377
|
bool WebGLContext::tex_storage_2d(uint32_t id, int levels, int width, int height) {
|
|
322
378
|
return tex_storage_format(id, levels, width, height,
|
|
323
379
|
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM);
|
|
@@ -24,6 +24,7 @@ static xt_value g_window_proto = XT_UNDEFINED;
|
|
|
24
24
|
xt_value xt_gui_window_set_background(xt_value self, xt_value env, int32_t argc, xt_value *argv);
|
|
25
25
|
xt_value xt_gui_window_paint_list(xt_value self, xt_value env, int32_t argc, xt_value *argv);
|
|
26
26
|
xt_value xt_gui_window_paint_count(xt_value self, xt_value env, int32_t argc, xt_value *argv);
|
|
27
|
+
xt_value xt_gui_window_send_event(xt_value self, xt_value env, int32_t argc, xt_value *argv);
|
|
27
28
|
|
|
28
29
|
/* -- methods -------------------------------------------------------------- */
|
|
29
30
|
|
|
@@ -83,6 +84,7 @@ static xt_value win_load_html(xt_value self, xt_value env, int32_t argc, xt_valu
|
|
|
83
84
|
win->scroll_y = 0.0f;
|
|
84
85
|
/* Fresh document: invalidate every previously handed-out handle, and drop
|
|
85
86
|
* the decoders that belonged to the old tree. */
|
|
87
|
+
xt_gui_pointer_lock_release(win);
|
|
86
88
|
xt_gui_handles_reset(win);
|
|
87
89
|
xt_gui_media_shutdown(win);
|
|
88
90
|
xt_gui_canvas_shutdown(win);
|
|
@@ -345,6 +347,14 @@ static xt_value win_request_animation_frame(xt_value self, xt_value env, int32_t
|
|
|
345
347
|
if (!XT_IS_FUNCTION(fn)) return xt_number(0);
|
|
346
348
|
int id = win->next_animation_frame_id++;
|
|
347
349
|
win->animation_frames.push_back(XtGuiAnimationFrame{id, fn});
|
|
350
|
+
/* The pump stops once a frame leaves the queue empty, so every request has
|
|
351
|
+
* to restart it — including one made through the *window method*, which is
|
|
352
|
+
* how three.js's `setAnimationLoop` asks (`self.requestAnimationFrame`).
|
|
353
|
+
* Only the bare global did this before, so a page that booted with no frame
|
|
354
|
+
* pending when the pump drained its queue never rendered again: the last
|
|
355
|
+
* presented frame stayed on screen (the Saltline page froze on its final
|
|
356
|
+
* "准备就绪" boot image). */
|
|
357
|
+
xt_browser_schedule_frame();
|
|
348
358
|
return xt_number((double)id);
|
|
349
359
|
}
|
|
350
360
|
|
|
@@ -365,10 +375,6 @@ static xt_value win_cancel_animation_frame(xt_value self, xt_value env, int32_t
|
|
|
365
375
|
|
|
366
376
|
/* -- input diagnostics ---------------------------------------------------- */
|
|
367
377
|
|
|
368
|
-
static double xt_gui_number_or(xt_value value, double fallback) {
|
|
369
|
-
return XT_IS_NUMBER(value) ? xt_to_number(value) : fallback;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
378
|
/** Test/debug hook: CSS-like descriptor of the deepest element at (x, y). */
|
|
373
379
|
static xt_value win_hit_test(xt_value self, xt_value env, int32_t argc, xt_value *argv) {
|
|
374
380
|
(void)env;
|
|
@@ -381,84 +387,6 @@ static xt_value win_hit_test(xt_value self, xt_value env, int32_t argc, xt_value
|
|
|
381
387
|
return xt_string_from_cstr(target.c_str());
|
|
382
388
|
}
|
|
383
389
|
|
|
384
|
-
/** Test/debug hook: synthesise an input event and deliver it to handlers.
|
|
385
|
-
* `win.sendEvent("click", { x, y, button, clicks })`,
|
|
386
|
-
* `win.sendEvent("wheel", { x, y, deltaX, deltaY })` or
|
|
387
|
-
* `win.sendEvent("keydown", { key, code })`. A key event may instead name the
|
|
388
|
-
* SDL `scancode`/`keycode` plus modifiers to exercise a real-keyboard path. */
|
|
389
|
-
static xt_value win_send_event(xt_value self, xt_value env, int32_t argc, xt_value *argv) {
|
|
390
|
-
(void)env;
|
|
391
|
-
XtGuiWindow *win = xt_gui_window_from_this(self);
|
|
392
|
-
if (win == nullptr || argc < 1) return XT_FALSE;
|
|
393
|
-
const char *type = xt_string_data(xt_to_string(xt_arg(argc, argv, 0)));
|
|
394
|
-
if (type == nullptr) return XT_FALSE;
|
|
395
|
-
xt_value options = xt_arg(argc, argv, 1);
|
|
396
|
-
double x = 0;
|
|
397
|
-
double y = 0;
|
|
398
|
-
if (XT_IS_OBJECT(options)) {
|
|
399
|
-
x = xt_gui_number_or(xt_object_get_cstr(options, "x"), 0);
|
|
400
|
-
y = xt_gui_number_or(xt_object_get_cstr(options, "y"), 0);
|
|
401
|
-
}
|
|
402
|
-
std::string name(type);
|
|
403
|
-
if (name == "textInput") {
|
|
404
|
-
std::string text;
|
|
405
|
-
if (XT_IS_OBJECT(options)) {
|
|
406
|
-
xt_value value = xt_object_get_cstr(options, "text");
|
|
407
|
-
if (XT_IS_STRING(value)) text = std::string(xt_string_data(value));
|
|
408
|
-
}
|
|
409
|
-
xt_gui_text_input(win, text.c_str());
|
|
410
|
-
return XT_TRUE;
|
|
411
|
-
}
|
|
412
|
-
if (name == "compositionstart" || name == "compositionupdate" || name == "compositionend") {
|
|
413
|
-
std::string data;
|
|
414
|
-
if (XT_IS_OBJECT(options)) {
|
|
415
|
-
xt_value value = xt_object_get_cstr(options, "data");
|
|
416
|
-
if (XT_IS_STRING(value)) data = std::string(xt_string_data(value));
|
|
417
|
-
}
|
|
418
|
-
xt_gui_composition_event(win, name.c_str(), data.c_str());
|
|
419
|
-
return XT_TRUE;
|
|
420
|
-
}
|
|
421
|
-
if (name == "wheel") {
|
|
422
|
-
double delta_x = 0;
|
|
423
|
-
double delta_y = 0;
|
|
424
|
-
if (XT_IS_OBJECT(options)) {
|
|
425
|
-
delta_x = xt_gui_number_or(xt_object_get_cstr(options, "deltaX"), 0);
|
|
426
|
-
delta_y = xt_gui_number_or(xt_object_get_cstr(options, "deltaY"), 0);
|
|
427
|
-
}
|
|
428
|
-
xt_gui_dispatch_wheel(win, (float)x, (float)y, (float)delta_x, (float)delta_y);
|
|
429
|
-
return XT_TRUE;
|
|
430
|
-
}
|
|
431
|
-
if (name == "keydown" || name == "keyup") {
|
|
432
|
-
auto flag = [options](const char *key) { return xt_truthy(xt_object_get_cstr(options, key)); };
|
|
433
|
-
if (XT_IS_OBJECT(options) && XT_IS_NUMBER(xt_object_get_cstr(options, "scancode"))) {
|
|
434
|
-
int scancode = (int)xt_gui_number_or(xt_object_get_cstr(options, "scancode"), 0);
|
|
435
|
-
int keycode = (int)xt_gui_number_or(xt_object_get_cstr(options, "keycode"), 0);
|
|
436
|
-
xt_gui_dispatch_physical_key(win, type, scancode, keycode, flag("repeat"), flag("ctrl"),
|
|
437
|
-
flag("shift"), flag("alt"), flag("meta"), flag("caps"));
|
|
438
|
-
return XT_TRUE;
|
|
439
|
-
}
|
|
440
|
-
const char *key = "";
|
|
441
|
-
const char *code = "";
|
|
442
|
-
if (XT_IS_OBJECT(options)) {
|
|
443
|
-
xt_value key_value = xt_object_get_cstr(options, "key");
|
|
444
|
-
xt_value code_value = xt_object_get_cstr(options, "code");
|
|
445
|
-
if (XT_IS_STRING(key_value)) key = xt_string_data(key_value);
|
|
446
|
-
if (XT_IS_STRING(code_value)) code = xt_string_data(code_value);
|
|
447
|
-
}
|
|
448
|
-
xt_gui_dispatch_key_with_modifiers(win, type, key, code, flag("repeat"), flag("ctrl"),
|
|
449
|
-
flag("shift"), flag("alt"), flag("meta"));
|
|
450
|
-
return XT_TRUE;
|
|
451
|
-
}
|
|
452
|
-
int button = -1;
|
|
453
|
-
int clicks = 0;
|
|
454
|
-
if (XT_IS_OBJECT(options)) {
|
|
455
|
-
button = (int)xt_gui_number_or(xt_object_get_cstr(options, "button"), -1);
|
|
456
|
-
clicks = (int)xt_gui_number_or(xt_object_get_cstr(options, "clicks"), 0);
|
|
457
|
-
}
|
|
458
|
-
xt_gui_dispatch_pointer(win, type, (float)x, (float)y, button, clicks);
|
|
459
|
-
return XT_TRUE;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
390
|
/** Diagnostic/test hook: engine counters as one object. `heapBytes` and
|
|
463
391
|
* `heapAllocations` are the live runtime heap, `treeNodes`/`detachedNodes` the
|
|
464
392
|
* DOM tree and the detached pool, and `handles`/`listeners` the element-handle
|
|
@@ -580,7 +508,7 @@ xt_value xt_gui_window_proto(void) {
|
|
|
580
508
|
* `window_events.cpp`. */
|
|
581
509
|
xt_gui_install_window_events(proto);
|
|
582
510
|
define_method(proto, "hitTest", (void *)win_hit_test);
|
|
583
|
-
define_method(proto, "sendEvent", (void *)
|
|
511
|
+
define_method(proto, "sendEvent", (void *)xt_gui_window_send_event);
|
|
584
512
|
define_method(proto, "stats", (void *)win_stats);
|
|
585
513
|
/* The browser surface a page written for a real page expects (`innerWidth`,
|
|
586
514
|
* `setTimeout`, `navigator`, `matchMedia`, …) lives in `browser.cpp`. */
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* xbintsc GUI engine — window diagnostics and background painting exposed as
|
|
3
|
-
* test/debug hooks (`setBackground`, `paintList`, `paintCount`).
|
|
3
|
+
* test/debug hooks (`setBackground`, `paintList`, `paintCount`, `sendEvent`).
|
|
4
|
+
*
|
|
5
|
+
* `sendEvent` synthesises the same input payloads a real SDL event produces, so
|
|
6
|
+
* the whole hit-test/listener path is testable without a mouse. The SDL event
|
|
7
|
+
* switch lives in `gui_input.cpp`; the single-window record and its prototype
|
|
8
|
+
* stay in `window.cpp`.
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
11
|
#include "gui_internal.h"
|
|
@@ -56,3 +61,91 @@ xt_value xt_gui_window_paint_count(xt_value self, xt_value env, int32_t argc, xt
|
|
|
56
61
|
xtgui::xt_paint_build(win->document->layout().root(), list);
|
|
57
62
|
return xt_number((double)list.rects.size());
|
|
58
63
|
}
|
|
64
|
+
|
|
65
|
+
static double xt_gui_number_or(xt_value value, double fallback) {
|
|
66
|
+
return XT_IS_NUMBER(value) ? xt_to_number(value) : fallback;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Test/debug hook: synthesise an input event and deliver it to handlers.
|
|
70
|
+
* `win.sendEvent("click", { x, y, button, clicks })`,
|
|
71
|
+
* `win.sendEvent("wheel", { x, y, deltaX, deltaY })`,
|
|
72
|
+
* `win.sendEvent("mousemove", { x, y, movementX, movementY })` or
|
|
73
|
+
* `win.sendEvent("keydown", { key, code })`. A key event may instead name the
|
|
74
|
+
* SDL `scancode`/`keycode` plus modifiers to exercise a real-keyboard path. */
|
|
75
|
+
xt_value xt_gui_window_send_event(xt_value self, xt_value env, int32_t argc, xt_value *argv) {
|
|
76
|
+
(void)env;
|
|
77
|
+
XtGuiWindow *win = xt_gui_window_from_this(self);
|
|
78
|
+
if (win == nullptr || argc < 1) return XT_FALSE;
|
|
79
|
+
const char *type = xt_string_data(xt_to_string(xt_arg(argc, argv, 0)));
|
|
80
|
+
if (type == nullptr) return XT_FALSE;
|
|
81
|
+
xt_value options = xt_arg(argc, argv, 1);
|
|
82
|
+
double x = 0;
|
|
83
|
+
double y = 0;
|
|
84
|
+
double movement_x = 0;
|
|
85
|
+
double movement_y = 0;
|
|
86
|
+
if (XT_IS_OBJECT(options)) {
|
|
87
|
+
x = xt_gui_number_or(xt_object_get_cstr(options, "x"), 0);
|
|
88
|
+
y = xt_gui_number_or(xt_object_get_cstr(options, "y"), 0);
|
|
89
|
+
movement_x = xt_gui_number_or(xt_object_get_cstr(options, "movementX"), 0);
|
|
90
|
+
movement_y = xt_gui_number_or(xt_object_get_cstr(options, "movementY"), 0);
|
|
91
|
+
}
|
|
92
|
+
std::string name(type);
|
|
93
|
+
if (name == "textInput") {
|
|
94
|
+
std::string text;
|
|
95
|
+
if (XT_IS_OBJECT(options)) {
|
|
96
|
+
xt_value value = xt_object_get_cstr(options, "text");
|
|
97
|
+
if (XT_IS_STRING(value)) text = std::string(xt_string_data(value));
|
|
98
|
+
}
|
|
99
|
+
xt_gui_text_input(win, text.c_str());
|
|
100
|
+
return XT_TRUE;
|
|
101
|
+
}
|
|
102
|
+
if (name == "compositionstart" || name == "compositionupdate" || name == "compositionend") {
|
|
103
|
+
std::string data;
|
|
104
|
+
if (XT_IS_OBJECT(options)) {
|
|
105
|
+
xt_value value = xt_object_get_cstr(options, "data");
|
|
106
|
+
if (XT_IS_STRING(value)) data = std::string(xt_string_data(value));
|
|
107
|
+
}
|
|
108
|
+
xt_gui_composition_event(win, name.c_str(), data.c_str());
|
|
109
|
+
return XT_TRUE;
|
|
110
|
+
}
|
|
111
|
+
if (name == "wheel") {
|
|
112
|
+
double delta_x = 0;
|
|
113
|
+
double delta_y = 0;
|
|
114
|
+
if (XT_IS_OBJECT(options)) {
|
|
115
|
+
delta_x = xt_gui_number_or(xt_object_get_cstr(options, "deltaX"), 0);
|
|
116
|
+
delta_y = xt_gui_number_or(xt_object_get_cstr(options, "deltaY"), 0);
|
|
117
|
+
}
|
|
118
|
+
xt_gui_dispatch_wheel(win, (float)x, (float)y, (float)delta_x, (float)delta_y);
|
|
119
|
+
return XT_TRUE;
|
|
120
|
+
}
|
|
121
|
+
if (name == "keydown" || name == "keyup") {
|
|
122
|
+
auto flag = [options](const char *key) { return xt_truthy(xt_object_get_cstr(options, key)); };
|
|
123
|
+
if (XT_IS_OBJECT(options) && XT_IS_NUMBER(xt_object_get_cstr(options, "scancode"))) {
|
|
124
|
+
int scancode = (int)xt_gui_number_or(xt_object_get_cstr(options, "scancode"), 0);
|
|
125
|
+
int keycode = (int)xt_gui_number_or(xt_object_get_cstr(options, "keycode"), 0);
|
|
126
|
+
xt_gui_dispatch_physical_key(win, type, scancode, keycode, flag("repeat"), flag("ctrl"),
|
|
127
|
+
flag("shift"), flag("alt"), flag("meta"), flag("caps"));
|
|
128
|
+
return XT_TRUE;
|
|
129
|
+
}
|
|
130
|
+
const char *key = "";
|
|
131
|
+
const char *code = "";
|
|
132
|
+
if (XT_IS_OBJECT(options)) {
|
|
133
|
+
xt_value key_value = xt_object_get_cstr(options, "key");
|
|
134
|
+
xt_value code_value = xt_object_get_cstr(options, "code");
|
|
135
|
+
if (XT_IS_STRING(key_value)) key = xt_string_data(key_value);
|
|
136
|
+
if (XT_IS_STRING(code_value)) code = xt_string_data(code_value);
|
|
137
|
+
}
|
|
138
|
+
xt_gui_dispatch_key_with_modifiers(win, type, key, code, flag("repeat"), flag("ctrl"),
|
|
139
|
+
flag("shift"), flag("alt"), flag("meta"));
|
|
140
|
+
return XT_TRUE;
|
|
141
|
+
}
|
|
142
|
+
int button = -1;
|
|
143
|
+
int clicks = 0;
|
|
144
|
+
if (XT_IS_OBJECT(options)) {
|
|
145
|
+
button = (int)xt_gui_number_or(xt_object_get_cstr(options, "button"), -1);
|
|
146
|
+
clicks = (int)xt_gui_number_or(xt_object_get_cstr(options, "clicks"), 0);
|
|
147
|
+
}
|
|
148
|
+
xt_gui_dispatch_pointer(win, type, (float)x, (float)y, button, clicks, (float)movement_x,
|
|
149
|
+
(float)movement_y);
|
|
150
|
+
return XT_TRUE;
|
|
151
|
+
}
|
package/runtime/rt.h
CHANGED
|
@@ -277,6 +277,12 @@ xt_value xt_array_ctor(int32_t argc, xt_value *argv);
|
|
|
277
277
|
xt_value xt_object_ctor(int32_t argc, xt_value *argv);
|
|
278
278
|
/** Call `target[name](...)`, falling back to built-in Array/String methods. */
|
|
279
279
|
xt_value xt_call_method(xt_value target, xt_value name, int32_t argc, xt_value *argv);
|
|
280
|
+
/** `obj.name(...)` with a monomorphic method inline cache: `cache` points at
|
|
281
|
+
* three zero-initialised i64 words owned by the generated code. A hit calls the
|
|
282
|
+
* cached slot's current value with `target` as `this`; a miss runs the full
|
|
283
|
+
* dispatch and then fills the cache. */
|
|
284
|
+
xt_value xt_call_method_ic(xt_value target, xt_value name, int32_t argc, xt_value *argv,
|
|
285
|
+
int64_t *cache);
|
|
280
286
|
/** Implements `Math.<name>(...)`; the name is interned by the compiler. */
|
|
281
287
|
xt_value xt_math_call(xt_value name, int32_t argc, xt_value *argv);
|
|
282
288
|
/* The first-class `Math` object (function members as native closures). */
|
|
@@ -291,33 +297,7 @@ xt_value xt_object_static(xt_value name, int32_t argc, xt_value *argv);
|
|
|
291
297
|
/** Implements `Number.<name>(...)` / `String.<name>(...)` statics. */
|
|
292
298
|
xt_value xt_number_static(xt_value name, int32_t argc, xt_value *argv);
|
|
293
299
|
xt_value xt_string_static(xt_value name, int32_t argc, xt_value *argv);
|
|
294
|
-
|
|
295
|
-
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
296
|
-
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
297
|
-
xt_value xt_typed_array_prototype(xt_value name);
|
|
298
|
-
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
299
|
-
* store) holds, for decoders and encoders that cannot afford one property read
|
|
300
|
-
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
301
|
-
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
302
|
-
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
303
|
-
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
304
|
-
uint32_t count);
|
|
305
|
-
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
306
|
-
uint32_t count);
|
|
307
|
-
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
308
|
-
* counterpart of `new ArrayBuffer(n)`). */
|
|
309
|
-
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
310
|
-
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
311
|
-
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
312
|
-
int xt_is_typed_array(xt_value value);
|
|
313
|
-
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
314
|
-
int xt_typed_array_kind_of(xt_value value);
|
|
315
|
-
/** Read one element (coerced to a number) from a typed-array view. */
|
|
316
|
-
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
317
|
-
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
318
|
-
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
319
|
-
/** Number of elements in a typed-array view. */
|
|
320
|
-
uint32_t xt_typed_array_length(xt_value value);
|
|
300
|
+
#include "rt_binary.h"
|
|
321
301
|
/** Error-family construction and prototype lookup by constructor name. */
|
|
322
302
|
xt_value xt_error_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
323
303
|
xt_value xt_error_prototype(xt_value name);
|
|
@@ -511,6 +491,11 @@ xt_value xt_get(xt_value target, xt_value key);
|
|
|
511
491
|
* two zero-initialised i64 words owned by the generated code. */
|
|
512
492
|
xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache);
|
|
513
493
|
xt_value xt_set(xt_value target, xt_value key, xt_value value);
|
|
494
|
+
/** `obj[key]` read with an element fast path: typed arrays and plain arrays are
|
|
495
|
+
* answered without the general dispatch, everything else goes to `xt_get_ic`. */
|
|
496
|
+
xt_value xt_get_element(xt_value target, xt_value key, int64_t *cache);
|
|
497
|
+
/** `obj[key] = value` with the same element fast path. */
|
|
498
|
+
xt_value xt_set_element(xt_value target, xt_value key, xt_value value);
|
|
514
499
|
/* Materialise a first-class runtime method value (`arr.map`) as an unbound
|
|
515
500
|
* closure that expects the receiver through `this`. Returns `XT_UNDEFINED` when
|
|
516
501
|
* `name` is not a method of `target`, so it can be used as a property fallback. */
|
|
@@ -546,6 +531,10 @@ void xt_stack_push(const char *name, const char *file, int32_t line);
|
|
|
546
531
|
void xt_stack_pop(void);
|
|
547
532
|
/** Set the innermost frame's line (called just before `new Error(...)`). */
|
|
548
533
|
void xt_stack_set_line(int32_t line);
|
|
534
|
+
|
|
535
|
+
/** Milliseconds since the program's time origin — the clock behind
|
|
536
|
+
* `performance.now()` and the timestamp an animation-frame callback receives. */
|
|
537
|
+
double xt_monotonic_ms(void);
|
|
549
538
|
void xt_console_log(int32_t argc, xt_value *argv);
|
|
550
539
|
void xt_console_info(int32_t argc, xt_value *argv);
|
|
551
540
|
void xt_console_warn(int32_t argc, xt_value *argv);
|
|
@@ -561,6 +550,9 @@ xt_value xt_console_table(int32_t argc, xt_value *argv);
|
|
|
561
550
|
xt_value xt_console_time(int32_t argc, xt_value *argv);
|
|
562
551
|
xt_value xt_console_time_end(int32_t argc, xt_value *argv);
|
|
563
552
|
xt_value xt_console_time_log(int32_t argc, xt_value *argv);
|
|
553
|
+
/** The global `console` object: one cached object whose methods are closures,
|
|
554
|
+
* so `const log = console.log` / `console.error.bind(console)` work. */
|
|
555
|
+
xt_value xt_console_object(int32_t argc, xt_value *argv);
|
|
564
556
|
void xt_print(xt_value v);
|
|
565
557
|
void xt_println(xt_value v);
|
|
566
558
|
|
|
@@ -574,6 +566,11 @@ size_t xt_heap_allocations(void);
|
|
|
574
566
|
* that lives outside the heap graph. The slot may be registered before it
|
|
575
567
|
* holds a value; it is marked on every collection and registration is
|
|
576
568
|
* idempotent. `xt_gc_add_root_range` registers `count` consecutive cells.
|
|
569
|
+
*
|
|
570
|
+
* A lazily built value must be registered *before* the allocations that build
|
|
571
|
+
* it. A static cell is outside the conservative stack scan, so a collection
|
|
572
|
+
* between storing the value and registering its slot would sweep an object the
|
|
573
|
+
* program still holds.
|
|
577
574
|
*/
|
|
578
575
|
void xt_gc_add_root(xt_value *slot);
|
|
579
576
|
void xt_gc_add_root_range(xt_value *base, size_t count);
|
|
@@ -593,3 +590,6 @@ void xt_gc_mark_value(xt_value value);
|
|
|
593
590
|
#endif
|
|
594
591
|
|
|
595
592
|
#endif /* xbintsc_RUNTIME_H */
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — binary data: `ArrayBuffer`, typed arrays and `DataView`.
|
|
3
|
+
*
|
|
4
|
+
* Included by `rt.h`. An `ArrayBuffer` owns one `calloc`ed byte block (see
|
|
5
|
+
* `xt_object.buffer_bytes`), and a typed-array view caches the block plus its
|
|
6
|
+
* byte offset, so element access is a `memcpy`-sized read/write instead of a
|
|
7
|
+
* property lookup. The helpers here are what the compiler, the standard library
|
|
8
|
+
* and extensions (audio/image decoders, wasm memories) share.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef XT_RT_BINARY_H
|
|
12
|
+
#define XT_RT_BINARY_H
|
|
13
|
+
|
|
14
|
+
/** Typed-array constructor/static/prototype dispatch by constructor name. */
|
|
15
|
+
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
16
|
+
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
17
|
+
xt_value xt_typed_array_prototype(xt_value name);
|
|
18
|
+
|
|
19
|
+
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
20
|
+
* store) holds, for decoders and encoders that cannot afford one property read
|
|
21
|
+
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
22
|
+
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
23
|
+
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
24
|
+
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
25
|
+
uint32_t count);
|
|
26
|
+
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
27
|
+
uint32_t count);
|
|
28
|
+
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
29
|
+
* counterpart of `new ArrayBuffer(n)`). */
|
|
30
|
+
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
31
|
+
|
|
32
|
+
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
33
|
+
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
34
|
+
int xt_is_typed_array(xt_value value);
|
|
35
|
+
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
36
|
+
int xt_typed_array_kind_of(xt_value value);
|
|
37
|
+
/** Read one element (coerced to a number) from a typed-array view. */
|
|
38
|
+
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
39
|
+
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
40
|
+
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
41
|
+
/** Number of elements in a typed-array view. */
|
|
42
|
+
uint32_t xt_typed_array_length(xt_value value);
|
|
43
|
+
|
|
44
|
+
#endif /* XT_RT_BINARY_H */
|