@native-sdk/cli 0.10.1 → 0.11.1
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/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +393 -97
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +2030 -83
- package/native-sdk.d.ts +5 -1
- package/package.json +20 -14
- package/packages/core/compile-surface/core.ts +164 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +68 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +332 -5
- package/packages/core/sdk/core.ts +371 -85
- package/packages/core/sdk/events.d.ts +252 -0
- package/packages/core/sdk/events.ts +240 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +186 -19
- package/packages/core/src/cli.ts +2 -11
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/context_menus.ts +76 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/diagnostics.ts +7 -0
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/frontend.ts +12 -10
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +98 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +92 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3954 -0
- package/packages/core/src/scalar_text.ts +82 -0
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +55 -3
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +14 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +1102 -0
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_continuity.ts +37 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +77 -18
- package/skill-data/ts-core/SKILL.md +117 -11
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +288 -144
- package/src/app_runner/root.zig +39 -12
- package/src/app_runner/ts_compiled_view.zig +1702 -0
- package/src/app_runner/ts_core_main.zig +185 -14
- package/src/app_runner/ts_core_mobile.zig +25 -13
- package/src/automation/server.zig +57 -6
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +4 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +219 -39
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/root.zig +25 -3
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/webview_inspection_test.m +106 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +130 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +15 -0
- package/src/platform/types.zig +115 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +17 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/decision_reuse.zig +133 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +131 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/markdown_tests.zig +3 -3
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +15 -11
- package/src/primitives/canvas/reference_tests.zig +58 -0
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +107 -4
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +53 -37
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +295 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +234 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +47 -0
- package/src/primitives/canvas/ui.zig +251 -83
- package/src/primitives/canvas/ui_markup.zig +207 -46
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +3026 -57
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +350 -0
- package/src/primitives/canvas/virtual_extents.zig +113 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +129 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +21 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +26 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +29 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +183 -4
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +720 -150
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +170 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +638 -33
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +419 -341
- package/src/runtime/flow_reference.zig +1427 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/global_shortcuts.zig +75 -0
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/keyboard_input.zig +86 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +16 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +231 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/staged_rebuild_policy.zig +83 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +65 -36
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2451 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1111 -45
- package/src/runtime/ui_app.zig +1381 -650
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +667 -188
- package/src/runtime/ui_app_window_tests.zig +222 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_reload.zig +226 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +46 -26
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +503 -69
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +179 -11
- package/src/security/root.zig +1 -0
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +23 -3
- package/src/tooling/ts_core.zig +97 -4
- package/src/tooling/verbs.zig +87 -1
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +188 -0
- package/tools/corewire/core_abi.zig +55 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +361 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +300 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +39 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +28 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +59 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +204 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +269 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
|
|
3
|
+
/// Native f32 extrema have target-specific signs for opposite zero operands.
|
|
4
|
+
/// Runtime probes expose only that numeric capability, never render decisions.
|
|
5
|
+
pub fn numericFlags() u8 {
|
|
6
|
+
var zeros = [_]f32{ -0.0, 0.0 };
|
|
7
|
+
std.mem.doNotOptimizeAway(&zeros);
|
|
8
|
+
const values = [_]f32{ @min(zeros[0], zeros[1]), @min(zeros[1], zeros[0]), @max(zeros[0], zeros[1]), @max(zeros[1], zeros[0]) };
|
|
9
|
+
var flags: u8 = 0;
|
|
10
|
+
for (values, 0..) |v, i| if (@as(u32, @bitCast(v)) == 0x80000000) {
|
|
11
|
+
flags |= @as(u8, 1) << @intCast(i);
|
|
12
|
+
};
|
|
13
|
+
return flags;
|
|
14
|
+
}
|
|
@@ -115,6 +115,7 @@ pub const ReferenceFont = struct {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
pub const ReferenceRenderSurface = struct {
|
|
118
|
+
vector_policy: ?@import("vector_raster_policy.zig").Policy = null,
|
|
118
119
|
width: usize,
|
|
119
120
|
height: usize,
|
|
120
121
|
pixels: []u8,
|
|
@@ -280,7 +281,9 @@ pub const ReferenceRenderSurface = struct {
|
|
|
280
281
|
.clear => self.clear(clear_color),
|
|
281
282
|
.load => if (scissor) |bounds| self.clearRect(bounds, clear_color),
|
|
282
283
|
}
|
|
283
|
-
|
|
284
|
+
var owned = self;
|
|
285
|
+
owned.vector_policy = pass.gpu_plan_policy;
|
|
286
|
+
for (pass.commands) |command| try owned.renderCommand(referenceScaleCommand(command, scale), scissor);
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
pub fn pixelRgba8(self: ReferenceRenderSurface, x: usize, y: usize) [4]u8 {
|
|
@@ -434,13 +437,14 @@ pub const ReferenceRenderSurface = struct {
|
|
|
434
437
|
.opacity = command.opacity,
|
|
435
438
|
.coverage_blend = .linear_light,
|
|
436
439
|
};
|
|
437
|
-
vector.
|
|
440
|
+
vector.fillPathWithPolicy(
|
|
438
441
|
value.elements,
|
|
439
442
|
command.transform,
|
|
440
443
|
.even_odd,
|
|
441
444
|
vector.default_tolerance,
|
|
442
445
|
referenceVectorClip(pixel_rect),
|
|
443
446
|
&sink,
|
|
447
|
+
self.vector_policy,
|
|
444
448
|
) catch return error.ReferenceRenderUnsupportedCommand;
|
|
445
449
|
}
|
|
446
450
|
|
|
@@ -462,13 +466,14 @@ pub const ReferenceRenderSurface = struct {
|
|
|
462
466
|
.opacity = command.opacity,
|
|
463
467
|
.coverage_blend = .linear_light,
|
|
464
468
|
};
|
|
465
|
-
vector.
|
|
469
|
+
vector.strokePathWithPolicy(
|
|
466
470
|
value.elements,
|
|
467
471
|
command.transform,
|
|
468
472
|
.{ .width = stroke_width, .cap = value.cap, .join = .round },
|
|
469
473
|
vector.default_tolerance,
|
|
470
474
|
referenceVectorClip(pixel_rect),
|
|
471
475
|
&sink,
|
|
476
|
+
self.vector_policy,
|
|
472
477
|
) catch return error.ReferenceRenderUnsupportedCommand;
|
|
473
478
|
}
|
|
474
479
|
|
|
@@ -893,14 +898,16 @@ pub const ReferenceRenderSurface = struct {
|
|
|
893
898
|
// fallback triggers are a clip band wider than
|
|
894
899
|
// `max_raster_width` (surface-shaped, not font-shaped) and
|
|
895
900
|
// nothing else.
|
|
896
|
-
|
|
897
|
-
|
|
901
|
+
const raster = &reference_glyph_raster_scratch.get().raster;
|
|
902
|
+
vector.fillGlyphPathWithPolicy(
|
|
903
|
+
raster,
|
|
898
904
|
builder.slice(),
|
|
899
905
|
Affine.identity(),
|
|
900
906
|
.nonzero,
|
|
901
907
|
vector.default_tolerance,
|
|
902
908
|
referenceVectorClip(pixel_rect),
|
|
903
909
|
&sink,
|
|
910
|
+
self.vector_policy,
|
|
904
911
|
) catch return false;
|
|
905
912
|
return true;
|
|
906
913
|
}
|
|
@@ -1128,7 +1135,6 @@ fn referenceScaleRect(rect: geometry.RectF, scale: f32) geometry.RectF {
|
|
|
1128
1135
|
return geometry.RectF.init(rect.x * scale, rect.y * scale, rect.width * scale, rect.height * scale);
|
|
1129
1136
|
}
|
|
1130
1137
|
|
|
1131
|
-
|
|
1132
1138
|
fn referencePixelCenter(x: usize, y: usize) geometry.PointF {
|
|
1133
1139
|
return geometry.PointF.init(@as(f32, @floatFromInt(x)) + 0.5, @as(f32, @floatFromInt(y)) + 0.5);
|
|
1134
1140
|
}
|
|
@@ -1147,9 +1153,8 @@ fn isReferenceTextSpace(byte: u8) bool {
|
|
|
1147
1153
|
/// The face a run's font id inks with: a runtime-registered face when
|
|
1148
1154
|
/// the id matches one (validated at registration, so a registered id
|
|
1149
1155
|
/// always resolves — no render-time fallback decision), otherwise the
|
|
1150
|
-
/// bundled mapping —
|
|
1151
|
-
///
|
|
1152
|
-
/// the regular outlines at their estimator advances, exactly as before).
|
|
1156
|
+
/// bundled mapping — Geist Mono for mono text, and the corresponding
|
|
1157
|
+
/// regular, medium or bold Geist face for reserved sans ids.
|
|
1153
1158
|
/// Glyphs missing from whichever face wins keep the per-glyph notdef
|
|
1154
1159
|
/// block fallback in `drawGlyphBox`; a registered face never cascades
|
|
1155
1160
|
/// into the bundled faces mid-run.
|
|
@@ -1157,8 +1162,7 @@ fn referenceFaceForFontId(fonts: []const ReferenceFont, font_id: canvas.FontId)
|
|
|
1157
1162
|
for (fonts) |font| {
|
|
1158
1163
|
if (font.id == font_id) return font.face;
|
|
1159
1164
|
}
|
|
1160
|
-
|
|
1161
|
-
return &font_ttf.geist_regular;
|
|
1165
|
+
return font_ttf.bundledFaceForFontId(font_id);
|
|
1162
1166
|
}
|
|
1163
1167
|
|
|
1164
1168
|
/// Decode the first codepoint of the cluster `text[start..start+len]`;
|
|
@@ -1415,6 +1415,64 @@ test "reference renderer blurs transparent colors without dark fringes" {
|
|
|
1415
1415
|
try expectPixelRgba8(.{ 0, 0, 0, 0 }, surface, 2, 0);
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
1418
|
+
test "bundled sans weights render matching glyph faces" {
|
|
1419
|
+
const font_ttf = canvas.font_ttf;
|
|
1420
|
+
const width = 64;
|
|
1421
|
+
const height = 48;
|
|
1422
|
+
const bounds = geometry.RectF.init(0, 0, width, height);
|
|
1423
|
+
var actual: [width * height * 4]u8 = undefined;
|
|
1424
|
+
var expected: [width * height * 4]u8 = undefined;
|
|
1425
|
+
var coverage: [3]u64 = undefined;
|
|
1426
|
+
const cases = .{
|
|
1427
|
+
.{ canvas.default_sans_font_id, &font_ttf.geist_regular },
|
|
1428
|
+
.{ canvas.default_sans_medium_font_id, &font_ttf.geist_medium },
|
|
1429
|
+
.{ canvas.default_sans_bold_font_id, &font_ttf.geist_bold },
|
|
1430
|
+
};
|
|
1431
|
+
inline for (cases, 0..) |case, index| {
|
|
1432
|
+
// Explicit glyph placement isolates face selection from measurement.
|
|
1433
|
+
// The expected pixels use the same face as an application-registered
|
|
1434
|
+
// resource, independently of the reserved-id fallback mapping.
|
|
1435
|
+
const glyphs = [_]Glyph{.{
|
|
1436
|
+
.id = case[1].glyphIndex('H'),
|
|
1437
|
+
.x = 0,
|
|
1438
|
+
.y = 0,
|
|
1439
|
+
.advance = 32 * case[1].advance(case[1].glyphIndex('H')) / case[1].units_per_em,
|
|
1440
|
+
.text_len = 1,
|
|
1441
|
+
}};
|
|
1442
|
+
var commands = [_]RenderCommand{.{
|
|
1443
|
+
.command = .{ .draw_text = .{
|
|
1444
|
+
.id = 1,
|
|
1445
|
+
.font_id = case[0],
|
|
1446
|
+
.size = 32,
|
|
1447
|
+
.origin = geometry.PointF.init(8, 36),
|
|
1448
|
+
.color = Color.rgb8(255, 255, 255),
|
|
1449
|
+
.text = "H",
|
|
1450
|
+
.glyphs = &glyphs,
|
|
1451
|
+
} },
|
|
1452
|
+
.local_bounds = bounds,
|
|
1453
|
+
.bounds = bounds,
|
|
1454
|
+
}};
|
|
1455
|
+
const pass = canvas.CanvasRenderPass{
|
|
1456
|
+
.surface_size = geometry.SizeF.init(width, height),
|
|
1457
|
+
.full_repaint = true,
|
|
1458
|
+
.commands = &commands,
|
|
1459
|
+
};
|
|
1460
|
+
const surface = try ReferenceRenderSurface.init(width, height, &actual);
|
|
1461
|
+
try surface.renderPass(pass, Color.rgba8(0, 0, 0, 0));
|
|
1462
|
+
|
|
1463
|
+
commands[0].command.draw_text.font_id = canvas.min_registered_font_id;
|
|
1464
|
+
const fonts = [_]canvas.ReferenceFont{.{ .id = canvas.min_registered_font_id, .face = case[1] }};
|
|
1465
|
+
const control = (try ReferenceRenderSurface.init(width, height, &expected)).withFonts(&fonts);
|
|
1466
|
+
try control.renderPass(pass, Color.rgba8(0, 0, 0, 0));
|
|
1467
|
+
try std.testing.expectEqualSlices(u8, &expected, &actual);
|
|
1468
|
+
coverage[index] = 0;
|
|
1469
|
+
for (0..width * height) |pixel| coverage[index] += actual[pixel * 4 + 3];
|
|
1470
|
+
}
|
|
1471
|
+
try std.testing.expect(coverage[0] > 0);
|
|
1472
|
+
try std.testing.expect(coverage[1] > coverage[0]);
|
|
1473
|
+
try std.testing.expect(coverage[2] > coverage[1]);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1418
1476
|
test "reference renderer draws proxy text runs" {
|
|
1419
1477
|
const commands = [_]CanvasCommand{.{ .draw_text = .{
|
|
1420
1478
|
.id = 1,
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//! Fixed copied font continuation. Native owns font bytes and buffers;
|
|
2
|
+
//! portable traversal and all measurement decisions belong to TypeScript.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const metrics = @import("text_metrics.zig");
|
|
5
|
+
const font_ttf = @import("font_ttf.zig");
|
|
6
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
7
|
+
pub const Mode = enum(u8) { width, advances, ink };
|
|
8
|
+
// Supply the target arithmetic fact for the reference's f32 minNum/maxNum
|
|
9
|
+
// lowering: ARM64 resolves opposite zeros canonically; x86 keeps the later
|
|
10
|
+
// operand. Bits encode negative-zero results for min(+,-), min(-,+),
|
|
11
|
+
// max(+,-), max(-,+). TypeScript still owns all extrema decisions.
|
|
12
|
+
const zero_rules: u8 = switch (@import("builtin").cpu.arch) {
|
|
13
|
+
.aarch64, .aarch64_be => 3,
|
|
14
|
+
else => 5,
|
|
15
|
+
};
|
|
16
|
+
// The 128-byte continuation contains header/font facts [0,32), traversal
|
|
17
|
+
// [32,44), native glyph replies [44,72), action/cell/pen/ink [72,104),
|
|
18
|
+
// native text window [104,112), byte emission [112,124), and admission.
|
|
19
|
+
// Native reply ranges stay bit-identical across every policy call.
|
|
20
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
21
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
22
|
+
}
|
|
23
|
+
fn float(bytes: []const u8, at: usize) f32 {
|
|
24
|
+
return @bitCast(word(bytes, at));
|
|
25
|
+
}
|
|
26
|
+
fn put(bytes: []u8, at: usize, value: u32) void {
|
|
27
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
28
|
+
}
|
|
29
|
+
fn setFloat(bytes: []u8, at: usize, value: f32) void {
|
|
30
|
+
put(bytes, at, @bitCast(value));
|
|
31
|
+
}
|
|
32
|
+
pub fn resultValid(request: []const u8, result: []const u8) bool {
|
|
33
|
+
if (request.len != 128 or result.len != 128 or !std.mem.eql(u8, request[0..3], result[0..3]) or
|
|
34
|
+
!std.mem.eql(u8, request[4..32], result[4..32]) or
|
|
35
|
+
!std.mem.eql(u8, request[44..72], result[44..72]) or
|
|
36
|
+
!std.mem.eql(u8, request[104..112], result[104..112]) or result[3] < 1 or result[3] > 2) return false;
|
|
37
|
+
const length = word(request, 8);
|
|
38
|
+
const first = word(result, 32);
|
|
39
|
+
const last = word(result, 36);
|
|
40
|
+
const cp = word(result, 40);
|
|
41
|
+
const action = word(result, 72);
|
|
42
|
+
const emit_first = word(result, 112);
|
|
43
|
+
const emit_last = word(result, 116);
|
|
44
|
+
if ((request[3] == 0 or word(request, 72) != 1) and cp != word(request, 40)) return false;
|
|
45
|
+
if (first > length or last < first or last > length or word(result, 44) > 65535 or word(result, 52) > 2 or
|
|
46
|
+
word(result, 84) > 1 or word(result, 104) > 4 or word(result, 124) > 1 or action > 4 or
|
|
47
|
+
(result[3] == 2) != (action == 0) or (cp != 0xffffffff and (cp > 0x10ffff or (cp >= 0xd800 and cp <= 0xdfff)))) return false;
|
|
48
|
+
if (emit_first > emit_last or emit_last > length or emit_last - emit_first > 4) return false;
|
|
49
|
+
if (emit_last != 0 and (request[2] != @intFromEnum(Mode.advances) or emit_first != word(request, 32) or emit_last != first)) return false;
|
|
50
|
+
if (action == 1 and first >= length) return false;
|
|
51
|
+
if ((action == 2 or action == 3) and (cp == 0xffffffff or last == first)) return false;
|
|
52
|
+
if (action == 4 and (word(result, 44) == 0 or request[2] != @intFromEnum(Mode.ink))) return false;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
pub const Result = struct { width: f32, accepted: bool, ink: metrics.TextInkMetrics };
|
|
56
|
+
pub fn measure(policy: Policy, registered_face: ?*const font_ttf.Face, font: u64, text: []const u8, size: f32, mode: Mode, advances: []f32) Result {
|
|
57
|
+
if (mode == .advances and advances.len < text.len) @panic("registered font advance buffer too short");
|
|
58
|
+
const face = registered_face orelse font_ttf.bundledFaceForFontId(font);
|
|
59
|
+
var request: [128]u8 = @splat(0);
|
|
60
|
+
var result: [128]u8 = undefined;
|
|
61
|
+
request[0..5].* = .{ 62, 1, @intFromEnum(mode), 0, @intFromBool(registered_face != null) };
|
|
62
|
+
request[5] = zero_rules;
|
|
63
|
+
put(&request, 8, std.math.cast(u32, text.len) orelse @panic("registered font text too large"));
|
|
64
|
+
std.mem.writeInt(u64, request[12..20], font, .little);
|
|
65
|
+
setFloat(&request, 20, size);
|
|
66
|
+
setFloat(&request, 24, face.units_per_em);
|
|
67
|
+
setFloat(&request, 28, face.advance(0));
|
|
68
|
+
var remaining: u64 = @as(u64, @intCast(text.len)) * 5 + 2;
|
|
69
|
+
while (true) {
|
|
70
|
+
if (remaining == 0) @panic("registered font continuation did not progress");
|
|
71
|
+
remaining -= 1;
|
|
72
|
+
@memset(&result, 0xa5);
|
|
73
|
+
if (policy(&request, &result) != result.len or !resultValid(&request, &result)) @panic("invalid registered font decision");
|
|
74
|
+
request = result;
|
|
75
|
+
const emit_first: usize = word(&request, 112);
|
|
76
|
+
const emit_last: usize = word(&request, 116);
|
|
77
|
+
if (emit_last > emit_first) {
|
|
78
|
+
advances[emit_first] = float(&request, 120);
|
|
79
|
+
@memset(advances[emit_first + 1 .. emit_last], 0);
|
|
80
|
+
}
|
|
81
|
+
switch (word(&request, 72)) {
|
|
82
|
+
0 => return .{ .width = float(&request, 80), .accepted = word(&request, 124) == 1, .ink = .{ .min_x = float(&request, 88), .max_x = float(&request, 92), .min_y = float(&request, 96), .max_y = float(&request, 100) } },
|
|
83
|
+
1 => {
|
|
84
|
+
const at: usize = word(&request, 32);
|
|
85
|
+
const count = @min(4, text.len - at);
|
|
86
|
+
put(&request, 104, @intCast(count));
|
|
87
|
+
@memset(request[108..112], 0);
|
|
88
|
+
@memcpy(request[108..][0..count], text[at..][0..count]);
|
|
89
|
+
},
|
|
90
|
+
2, 3 => {
|
|
91
|
+
const glyph = face.glyphIndex(@intCast(word(&request, 40)));
|
|
92
|
+
put(&request, 44, glyph);
|
|
93
|
+
setFloat(&request, 48, if (glyph != 0) face.advance(glyph) else 0);
|
|
94
|
+
},
|
|
95
|
+
4 => {
|
|
96
|
+
const bounds = face.glyphBounds(@intCast(word(&request, 44))) catch {
|
|
97
|
+
put(&request, 52, 2);
|
|
98
|
+
continue;
|
|
99
|
+
};
|
|
100
|
+
put(&request, 52, if (bounds != null) 1 else 0);
|
|
101
|
+
if (bounds) |value| {
|
|
102
|
+
setFloat(&request, 56, value.x);
|
|
103
|
+
setFloat(&request, 60, value.y);
|
|
104
|
+
setFloat(&request, 64, value.width);
|
|
105
|
+
setFloat(&request, 68, value.height);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
else => unreachable,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
test "registered font copied continuation bounds all capabilities and destination writes" {
|
|
114
|
+
var request: [128]u8 = @splat(0);
|
|
115
|
+
request[0..5].* = .{ 62, 1, 1, 0, 1 };
|
|
116
|
+
put(&request, 8, 8);
|
|
117
|
+
var result = request;
|
|
118
|
+
result[3] = 1;
|
|
119
|
+
put(&result, 72, 1);
|
|
120
|
+
put(&result, 124, 1);
|
|
121
|
+
try std.testing.expect(resultValid(&request, &result));
|
|
122
|
+
for ([_]usize{ 0, 1, 2, 4, 8, 12, 16, 20, 24, 28, 44, 48, 52, 56, 60, 64, 68, 104, 108 }) |at| {
|
|
123
|
+
var bad = result;
|
|
124
|
+
bad[at] ^= 1;
|
|
125
|
+
try std.testing.expect(!resultValid(&request, &bad));
|
|
126
|
+
}
|
|
127
|
+
request = result;
|
|
128
|
+
put(&result, 36, 4);
|
|
129
|
+
put(&result, 40, 65);
|
|
130
|
+
put(&result, 72, 2);
|
|
131
|
+
try std.testing.expect(resultValid(&request, &result));
|
|
132
|
+
for ([_]u32{ 0xd800, 0xdfff, 0x110000, 0xffffffff }) |cp| {
|
|
133
|
+
var bad = result;
|
|
134
|
+
put(&bad, 40, cp);
|
|
135
|
+
try std.testing.expect(!resultValid(&request, &bad));
|
|
136
|
+
}
|
|
137
|
+
request = result;
|
|
138
|
+
put(&result, 32, 4);
|
|
139
|
+
put(&result, 72, 1);
|
|
140
|
+
put(&result, 116, 4);
|
|
141
|
+
try std.testing.expect(resultValid(&request, &result));
|
|
142
|
+
for ([_]u32{ 5, 9, 0xffffffff }) |last| {
|
|
143
|
+
var bad = result;
|
|
144
|
+
put(&bad, 116, last);
|
|
145
|
+
try std.testing.expect(!resultValid(&request, &bad));
|
|
146
|
+
}
|
|
147
|
+
for ([_]usize{ 32, 36, 72, 84, 112, 124 }) |at| {
|
|
148
|
+
var bad = result;
|
|
149
|
+
put(&bad, at, 0xffffffff);
|
|
150
|
+
try std.testing.expect(!resultValid(&request, &bad));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const compiled_plan = @import("render_plan_policy.zig");
|
|
2
|
+
const compiled_cache = @import("render_cache_policy.zig");
|
|
1
3
|
const std = @import("std");
|
|
2
4
|
const geometry = @import("geometry");
|
|
3
5
|
const canvas = @import("root.zig");
|
|
@@ -383,11 +385,23 @@ pub const RenderPlan = struct {
|
|
|
383
385
|
return planner.build(self);
|
|
384
386
|
}
|
|
385
387
|
|
|
388
|
+
pub fn batchPlanWithWorkspace(self: RenderPlan, output: []RenderBatch, policy: ?compiled_cache.Policy, workspace: ?*compiled_cache.Workspace) Error!RenderBatchPlan {
|
|
389
|
+
var planner = RenderBatchPlanner.init(output);
|
|
390
|
+
if (policy) |owner| return planner.buildCompiled(self, owner, workspace orelse @panic("missing render plan workspace"));
|
|
391
|
+
return planner.build(self);
|
|
392
|
+
}
|
|
393
|
+
|
|
386
394
|
pub fn pathGeometryPlan(self: RenderPlan, output: []RenderPathGeometry) Error!RenderPathGeometryPlan {
|
|
387
395
|
var planner = RenderPathGeometryPlanner.init(output);
|
|
388
396
|
return planner.build(self);
|
|
389
397
|
}
|
|
390
398
|
|
|
399
|
+
pub fn pathGeometryPlanWithPolicy(self: RenderPlan, output: []RenderPathGeometry, policy: ?compiled_cache.Policy) Error!RenderPathGeometryPlan {
|
|
400
|
+
var planner = RenderPathGeometryPlanner.init(output);
|
|
401
|
+
if (policy) |owner| return planner.buildCompiled(self, owner);
|
|
402
|
+
return planner.build(self);
|
|
403
|
+
}
|
|
404
|
+
|
|
391
405
|
pub fn imagePlan(self: RenderPlan, output: []RenderImage) Error!RenderImagePlan {
|
|
392
406
|
return self.imagePlanWithResources(&.{}, output);
|
|
393
407
|
}
|
|
@@ -398,6 +412,19 @@ pub const RenderPlan = struct {
|
|
|
398
412
|
return planner.build(self);
|
|
399
413
|
}
|
|
400
414
|
|
|
415
|
+
pub fn imagePlanWithResourcesAndPolicy(self: RenderPlan, image_resources: []const ReferenceImage, output: []RenderImage, policy: ?compiled_cache.Policy) Error!RenderImagePlan {
|
|
416
|
+
var planner = RenderImagePlanner.init(output);
|
|
417
|
+
planner.image_resources = image_resources;
|
|
418
|
+
if (policy) |owner| return planner.buildCompiled(self, owner);
|
|
419
|
+
return planner.build(self);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
pub fn layerPlanWithPolicy(self: RenderPlan, output: []RenderLayer, policy: ?compiled_cache.Policy) Error!RenderLayerPlan {
|
|
423
|
+
var planner = RenderLayerPlanner.init(output);
|
|
424
|
+
if (policy) |owner| return planner.buildCompiled(self, owner);
|
|
425
|
+
return planner.build(self);
|
|
426
|
+
}
|
|
427
|
+
|
|
401
428
|
pub fn layerPlan(self: RenderPlan, output: []RenderLayer) Error!RenderLayerPlan {
|
|
402
429
|
var planner = RenderLayerPlanner.init(output);
|
|
403
430
|
return planner.build(self);
|
|
@@ -437,6 +464,10 @@ pub const RenderPlanner = struct {
|
|
|
437
464
|
};
|
|
438
465
|
}
|
|
439
466
|
|
|
467
|
+
pub fn buildCompiled(self: *RenderPlanner, list: DisplayList, policy: compiled_cache.Policy, workspace: *compiled_cache.Workspace) Error!RenderPlan {
|
|
468
|
+
return compiled_plan.buildRender(RenderPlan, self, list, policy, workspace);
|
|
469
|
+
}
|
|
470
|
+
|
|
440
471
|
fn consume(self: *RenderPlanner, command: CanvasCommand) Error!void {
|
|
441
472
|
switch (command) {
|
|
442
473
|
.push_clip => |clip| try self.pushClip(clip),
|
|
@@ -535,6 +566,11 @@ pub const RenderBatchPlan = struct {
|
|
|
535
566
|
var planner = RenderPipelineCachePlanner.init(entries, actions);
|
|
536
567
|
return planner.build(self, previous, frame_index);
|
|
537
568
|
}
|
|
569
|
+
pub fn cachePlanWithWorkspace(self: RenderBatchPlan, workspace: ?*compiled_cache.Workspace, previous: []const RenderPipelineCacheEntry, frame_index: u64, entries: []RenderPipelineCacheEntry, actions: []RenderPipelineCacheAction) Error!RenderPipelineCachePlan {
|
|
570
|
+
var planner = RenderPipelineCachePlanner.init(entries, actions);
|
|
571
|
+
if (workspace) |owner| return planner.buildCompiled(self, previous, frame_index, owner);
|
|
572
|
+
return planner.build(self, previous, frame_index);
|
|
573
|
+
}
|
|
538
574
|
};
|
|
539
575
|
|
|
540
576
|
pub const RenderBatchPlanner = struct {
|
|
@@ -560,6 +596,10 @@ pub const RenderBatchPlanner = struct {
|
|
|
560
596
|
};
|
|
561
597
|
}
|
|
562
598
|
|
|
599
|
+
pub fn buildCompiled(self: *RenderBatchPlanner, plan: RenderPlan, policy: compiled_cache.Policy, workspace: *compiled_cache.Workspace) Error!RenderBatchPlan {
|
|
600
|
+
return compiled_plan.buildBatch(RenderBatchPlan, self, plan, policy, workspace);
|
|
601
|
+
}
|
|
602
|
+
|
|
563
603
|
fn consume(self: *RenderBatchPlanner, command: RenderCommand, index: usize) Error!void {
|
|
564
604
|
const pipeline = renderPipelineKind(command.command);
|
|
565
605
|
if (self.len > 0 and renderBatchCanExtend(self.batches[self.len - 1], command, pipeline, index)) {
|
|
@@ -648,6 +688,10 @@ pub const RenderPipelineCachePlanner = struct {
|
|
|
648
688
|
self.action_len = 0;
|
|
649
689
|
}
|
|
650
690
|
|
|
691
|
+
pub fn buildCompiled(self: *RenderPipelineCachePlanner, plan: RenderBatchPlan, previous: []const RenderPipelineCacheEntry, frame_index: u64, workspace: *compiled_cache.Workspace) Error!RenderPipelineCachePlan {
|
|
692
|
+
return compiled_cache.build(.pipeline, RenderPipelineCachePlan, self, plan.batches, previous, frame_index, workspace, renderPipelineCacheKey, null, error.RenderPipelineCacheListFull);
|
|
693
|
+
}
|
|
694
|
+
|
|
651
695
|
pub fn build(self: *RenderPipelineCachePlanner, batch_plan: RenderBatchPlan, previous: []const RenderPipelineCacheEntry, frame_index: u64) Error!RenderPipelineCachePlan {
|
|
652
696
|
self.reset();
|
|
653
697
|
for (batch_plan.batches, 0..) |batch, batch_index| {
|
|
@@ -745,3 +789,7 @@ fn unionOptionalBounds(a: ?geometry.RectF, b: ?geometry.RectF) ?geometry.RectF {
|
|
|
745
789
|
fn affinesEqual(a: Affine, b: Affine) bool {
|
|
746
790
|
return equality_model.affinesEqual(a, b);
|
|
747
791
|
}
|
|
792
|
+
|
|
793
|
+
fn renderPipelineCacheKey(batch: RenderBatch) RenderPipelineKind {
|
|
794
|
+
return batch.pipeline;
|
|
795
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
|
|
3
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
4
|
+
pub const Family = enum(u8) { pipeline, path, image, layer, resource, effect };
|
|
5
|
+
|
|
6
|
+
/// One native-owned pair of copied buffers, reused by ordered render planning and cache
|
|
7
|
+
/// calls in a frame. Resources and committed core storage never cross the ABI.
|
|
8
|
+
pub const Workspace = struct {
|
|
9
|
+
policy: Policy,
|
|
10
|
+
request: []u8,
|
|
11
|
+
result: []u8,
|
|
12
|
+
|
|
13
|
+
pub fn init(policy: Policy, max_facts: usize, max_entries: usize, max_actions: usize) Workspace {
|
|
14
|
+
return .{
|
|
15
|
+
.policy = policy,
|
|
16
|
+
.request = std.heap.page_allocator.alloc(u8, 24 + max_facts * 56) catch @panic("render cache request allocation failed"),
|
|
17
|
+
.result = std.heap.page_allocator.alloc(u8, 16 + max_entries * 4 + max_actions * 12) catch @panic("render cache result allocation failed"),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
pub fn initPlanning(policy: Policy, command_count: usize, batch_count: usize) Workspace {
|
|
22
|
+
return initBytes(policy, 16 + command_count * 48 + 864 + command_count * 68, @max(864 + command_count * 68, 32 + batch_count * 52));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
pub fn initOverrides(policy: Policy, first: usize, second: usize, commands: usize, entries: usize, capacity: usize) Workspace {
|
|
26
|
+
return initBytes(policy, 32 + (first + second) * 40 + commands * 92 + entries * 28, @max(64 + commands * 44, 16 + @min(first + second, capacity) * 4));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pub fn initDamage(policy: Policy, changes: usize, commands: usize, baseline: usize, current: usize) Workspace {
|
|
30
|
+
const bytes = damageBytes(changes, commands, baseline, current);
|
|
31
|
+
return initBytes(policy, bytes[0], bytes[1]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fn damageBytes(changes: usize, commands: usize, baseline: usize, current: usize) [2]usize {
|
|
35
|
+
const rect_bytes = @import("frame.zig").max_canvas_frame_dirty_rects * 16;
|
|
36
|
+
return .{ @max(128 + changes * 20 + commands * 68 + rect_bytes, 128 + (baseline + current) * 32), 64 + rect_bytes + baseline * 2 + current };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fn initBytes(policy: Policy, request_bytes: usize, result_bytes: usize) Workspace {
|
|
40
|
+
return .{
|
|
41
|
+
.policy = policy,
|
|
42
|
+
.request = std.heap.page_allocator.alloc(u8, request_bytes) catch @panic("render request allocation failed"),
|
|
43
|
+
.result = std.heap.page_allocator.alloc(u8, result_bytes) catch @panic("render result allocation failed"),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn forFrame(policy: ?Policy, storage: anytype, options: anytype, command_count: usize) ?Workspace {
|
|
48
|
+
return forFrameWithOverrides(policy, storage, options, command_count, 0, 0, 0, 0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
pub fn forFrameWithOverrides(policy: ?Policy, storage: anytype, options: anytype, command_count: usize, scheduled_count: usize, dirty_count: usize, merge_capacity: usize, baseline_count: usize) ?Workspace {
|
|
52
|
+
const owner = policy orelse options.render_plan_policy orelse options.render_override_policy orelse options.render_damage_policy orelse return null;
|
|
53
|
+
var facts: usize = 0;
|
|
54
|
+
var entries: usize = 0;
|
|
55
|
+
var actions: usize = 0;
|
|
56
|
+
inline for (.{
|
|
57
|
+
.{ "render_batches", "pipeline" }, .{ "path_geometries", "path_geometry" },
|
|
58
|
+
.{ "images", "image" }, .{ "layers", "layer" },
|
|
59
|
+
.{ "resources", "resource" }, .{ "visual_effects", "visual_effect" },
|
|
60
|
+
}) |fields| {
|
|
61
|
+
const current = @field(storage, fields[0]).len;
|
|
62
|
+
const total = current + @field(options, "previous_" ++ fields[1] ++ "_cache").len;
|
|
63
|
+
facts = @max(facts, total);
|
|
64
|
+
entries = @max(entries, @min(current, @field(storage, fields[1] ++ "_cache_entries").len));
|
|
65
|
+
actions = @max(actions, @min(total, @field(storage, fields[1] ++ "_cache_actions").len));
|
|
66
|
+
}
|
|
67
|
+
var request_bytes = 24 + facts * 56;
|
|
68
|
+
var result_bytes = 16 + entries * 4 + actions * 12;
|
|
69
|
+
if (options.render_plan_policy != null) {
|
|
70
|
+
const draws = @min(command_count, storage.render_commands.len);
|
|
71
|
+
request_bytes = @max(request_bytes, 16 + command_count * 48 + 864 + draws * 68);
|
|
72
|
+
result_bytes = @max(result_bytes, @max(864 + draws * 68, 32 + @min(draws, storage.render_batches.len) * 52));
|
|
73
|
+
}
|
|
74
|
+
if (options.render_override_policy != null) {
|
|
75
|
+
const draws = @min(command_count, storage.render_commands.len);
|
|
76
|
+
const merged = scheduled_count + options.render_overrides.len;
|
|
77
|
+
request_bytes = @max(request_bytes, 32 + (options.previous_render_overrides.len + merged) * 40 + draws * 92 + dirty_count * 28);
|
|
78
|
+
result_bytes = @max(result_bytes, @max(64 + draws * 44, 16 + @min(merged, merge_capacity) * 4));
|
|
79
|
+
}
|
|
80
|
+
if (options.render_damage_policy != null) {
|
|
81
|
+
const bytes = damageBytes(storage.changes.len, @min(command_count, storage.render_commands.len), baseline_count, @min(command_count, storage.render_commands.len));
|
|
82
|
+
request_bytes = @max(request_bytes, bytes[0]);
|
|
83
|
+
result_bytes = @max(result_bytes, bytes[1]);
|
|
84
|
+
}
|
|
85
|
+
return initBytes(owner, request_bytes, result_bytes);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pub fn deinit(self: Workspace) void {
|
|
89
|
+
std.heap.page_allocator.free(self.request);
|
|
90
|
+
std.heap.page_allocator.free(self.result);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/// The native key and hash functions supply representation/resource facts.
|
|
95
|
+
/// The compiled owner decides matching, ordering and every capacity transition.
|
|
96
|
+
pub fn build(comptime family: Family, comptime Result: type, planner: anytype, current: anytype, previous: anytype, frame: u64, workspace: *Workspace, comptime keyFn: anytype, comptime hashFn: anytype, comptime full: anytype) @TypeOf(full)!Result {
|
|
97
|
+
planner.reset();
|
|
98
|
+
const total = current.len + previous.len;
|
|
99
|
+
const request_length = 24 + total * 56;
|
|
100
|
+
const result_capacity = 16 + @min(planner.entries.len, current.len) * 4 + @min(planner.actions.len, total) * 12;
|
|
101
|
+
if (request_length > workspace.request.len or result_capacity > workspace.result.len) @panic("render cache workspace too small");
|
|
102
|
+
const request = workspace.request[0..request_length];
|
|
103
|
+
@memset(request, 0);
|
|
104
|
+
request[0] = 12;
|
|
105
|
+
request[1] = @intFromEnum(family);
|
|
106
|
+
putWord(request, 4, current.len);
|
|
107
|
+
putWord(request, 8, previous.len);
|
|
108
|
+
putWord(request, 12, planner.entries.len);
|
|
109
|
+
putWord(request, 16, planner.actions.len);
|
|
110
|
+
for (current, 0..) |item, i| {
|
|
111
|
+
const key = keyFn(item);
|
|
112
|
+
fact(request[24 + i * 56 ..][0..56], key, if (comptime family == .resource) hashFn(key) else 0);
|
|
113
|
+
}
|
|
114
|
+
for (previous, 0..) |item, i| {
|
|
115
|
+
const key = if (comptime family == .pipeline) item.pipeline else item.key;
|
|
116
|
+
fact(request[24 + (current.len + i) * 56 ..][0..56], key, if (comptime family == .resource) hashFn(key) else 0);
|
|
117
|
+
}
|
|
118
|
+
const result = workspace.result[0..result_capacity];
|
|
119
|
+
const length = workspace.policy(request, result);
|
|
120
|
+
if (length < 16 or length > result.len) @panic("truncated compiled render cache result");
|
|
121
|
+
const entry_count = word(result, 0);
|
|
122
|
+
const action_count = word(result, 4);
|
|
123
|
+
const failed = word(result, 8);
|
|
124
|
+
if (failed > 1 or word(result, 12) != 0 or entry_count > @min(planner.entries.len, current.len) or action_count > @min(planner.actions.len, total) or length != 16 + @as(usize, entry_count) * 4 + @as(usize, action_count) * 12) @panic("invalid compiled render cache result");
|
|
125
|
+
for (0..entry_count) |i| {
|
|
126
|
+
const source = word(result, 16 + i * 4);
|
|
127
|
+
if (source >= current.len) @panic("invalid compiled render cache entry source");
|
|
128
|
+
const key = keyFn(current[source]);
|
|
129
|
+
planner.entries[i] = if (comptime family == .pipeline) .{ .pipeline = key, .last_used_frame = frame } else .{ .key = key, .last_used_frame = frame };
|
|
130
|
+
}
|
|
131
|
+
planner.entry_len = entry_count;
|
|
132
|
+
for (0..action_count) |i| {
|
|
133
|
+
const at = 16 + @as(usize, entry_count) * 4 + i * 12;
|
|
134
|
+
const kind = word(result, at);
|
|
135
|
+
const source = word(result, at + 4);
|
|
136
|
+
const cache = word(result, at + 8);
|
|
137
|
+
if (kind > 2 or source >= total or (cache != 0xffffffff and cache >= previous.len) or (kind == 2) != (source >= current.len) or (kind == 0) != (cache == 0xffffffff)) @panic("invalid compiled render cache action");
|
|
138
|
+
const key = if (source < current.len) keyFn(current[source]) else if (comptime family == .pipeline) previous[source - current.len].pipeline else previous[source - current.len].key;
|
|
139
|
+
var action: @TypeOf(planner.actions[0]) = undefined;
|
|
140
|
+
action.kind = @enumFromInt(kind);
|
|
141
|
+
if (comptime family == .pipeline) action.pipeline = key else action.key = key;
|
|
142
|
+
@field(action, switch (family) {
|
|
143
|
+
.pipeline => "batch_index",
|
|
144
|
+
.path => "geometry_index",
|
|
145
|
+
.image => "image_index",
|
|
146
|
+
.layer => "layer_index",
|
|
147
|
+
.resource => "resource_index",
|
|
148
|
+
.effect => "effect_index",
|
|
149
|
+
}) = if (source < current.len) source else null;
|
|
150
|
+
action.cache_index = if (cache == 0xffffffff) null else cache;
|
|
151
|
+
planner.actions[i] = action;
|
|
152
|
+
}
|
|
153
|
+
planner.action_len = action_count;
|
|
154
|
+
if (failed == 1) return full;
|
|
155
|
+
return .{ .entries = planner.entries[0..entry_count], .actions = planner.actions[0..action_count] };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
fn fact(bytes: []u8, key: anytype, hash: u64) void {
|
|
159
|
+
const T = @TypeOf(key);
|
|
160
|
+
if (comptime @typeInfo(T) == .@"enum") {
|
|
161
|
+
putWord(bytes, 0, @intFromEnum(key));
|
|
162
|
+
} else {
|
|
163
|
+
if (comptime @hasField(T, "kind")) putWord(bytes, 0, @intFromEnum(key.kind));
|
|
164
|
+
if (comptime @hasField(T, "id")) {
|
|
165
|
+
putWord(bytes, 4, @intFromBool(key.id != null));
|
|
166
|
+
putInt(bytes, 8, key.id orelse 0);
|
|
167
|
+
}
|
|
168
|
+
if (comptime @hasField(T, "command_index")) putInt(bytes, 16, key.command_index);
|
|
169
|
+
if (comptime @hasField(T, "command_start")) putInt(bytes, 16, key.command_start);
|
|
170
|
+
if (comptime @hasField(T, "image_id")) putInt(bytes, 24, key.image_id);
|
|
171
|
+
if (comptime @hasField(T, "font_id")) putInt(bytes, 32, key.font_id);
|
|
172
|
+
putInt(bytes, 40, key.fingerprint);
|
|
173
|
+
}
|
|
174
|
+
putWord(bytes, 48, @intCast(hash & 0xffffffff));
|
|
175
|
+
}
|
|
176
|
+
fn putWord(bytes: []u8, at: usize, value: usize) void {
|
|
177
|
+
std.mem.writeInt(u32, bytes[at..][0..4], std.math.cast(u32, value) orelse @panic("render cache wire integer overflow"), .little);
|
|
178
|
+
}
|
|
179
|
+
fn putInt(bytes: []u8, at: usize, value: u64) void {
|
|
180
|
+
std.mem.writeInt(u64, bytes[at..][0..8], value, .little);
|
|
181
|
+
}
|
|
182
|
+
fn word(bytes: []const u8, at: usize) u32 {
|
|
183
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
184
|
+
}
|