@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const gpu_policy = @import("gpu_planning_policy.zig");
|
|
2
|
+
const render_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");
|
|
@@ -88,6 +90,9 @@ pub const CanvasFrameProfile = frame_metrics.CanvasFrameProfile;
|
|
|
88
90
|
pub const canvasFrameProfile = frame_metrics.canvasFrameProfile;
|
|
89
91
|
|
|
90
92
|
pub const CanvasRenderPass = struct {
|
|
93
|
+
/// Static compiled owner for GPU programs and portable vector coverage;
|
|
94
|
+
/// payload pointers remain borrowed from this frame.
|
|
95
|
+
gpu_plan_policy: ?gpu_policy.Policy = null,
|
|
91
96
|
frame_index: u64 = 0,
|
|
92
97
|
timestamp_ns: u64 = 0,
|
|
93
98
|
surface_size: geometry.SizeF = .{},
|
|
@@ -173,7 +178,13 @@ pub const CanvasRenderPass = struct {
|
|
|
173
178
|
return self.layer_actions.len;
|
|
174
179
|
}
|
|
175
180
|
|
|
181
|
+
pub fn encoderCounts(self: CanvasRenderPass) gpu_policy.EncoderCounts {
|
|
182
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.encoderCounts(self, owner);
|
|
183
|
+
return .{ .commands = self.encoderCommandCount(), .caches = self.encoderCacheActionCount(), .binds = self.encoderBindPipelineCount(), .draws = self.encoderDrawBatchCount() };
|
|
184
|
+
}
|
|
185
|
+
|
|
176
186
|
pub fn encoderCommandCount(self: CanvasRenderPass) usize {
|
|
187
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.encoderCounts(self, owner).commands;
|
|
177
188
|
if (!self.requiresRender()) return 0;
|
|
178
189
|
var count: usize = 2 + self.encoderCacheActionCount() + self.encoderBindPipelineCount() + self.encoderDrawBatchCount();
|
|
179
190
|
if (self.scissorBounds() != null) count += 1;
|
|
@@ -181,6 +192,7 @@ pub const CanvasRenderPass = struct {
|
|
|
181
192
|
}
|
|
182
193
|
|
|
183
194
|
pub fn encoderCacheActionCount(self: CanvasRenderPass) usize {
|
|
195
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.encoderCounts(self, owner).caches;
|
|
184
196
|
if (!self.requiresRender()) return 0;
|
|
185
197
|
return self.pipeline_actions.len +
|
|
186
198
|
self.path_geometry_actions.len +
|
|
@@ -193,6 +205,7 @@ pub const CanvasRenderPass = struct {
|
|
|
193
205
|
}
|
|
194
206
|
|
|
195
207
|
pub fn encoderBindPipelineCount(self: CanvasRenderPass) usize {
|
|
208
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.encoderCounts(self, owner).binds;
|
|
196
209
|
if (!self.requiresRender()) return 0;
|
|
197
210
|
var count: usize = 0;
|
|
198
211
|
var bound_pipeline: ?RenderPipelineKind = null;
|
|
@@ -206,6 +219,7 @@ pub const CanvasRenderPass = struct {
|
|
|
206
219
|
}
|
|
207
220
|
|
|
208
221
|
pub fn encoderDrawBatchCount(self: CanvasRenderPass) usize {
|
|
222
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.encoderCounts(self, owner).draws;
|
|
209
223
|
return if (self.requiresRender()) self.batches.len else 0;
|
|
210
224
|
}
|
|
211
225
|
|
|
@@ -253,15 +267,18 @@ pub const CanvasRenderPass = struct {
|
|
|
253
267
|
|
|
254
268
|
pub fn encoderPlan(self: CanvasRenderPass, output: []RenderEncoderCommand) Error!RenderEncoderPlan {
|
|
255
269
|
var planner = RenderEncoderPlanner.init(output);
|
|
270
|
+
if (self.gpu_plan_policy) |owner| return planner.buildCompiled(self, owner);
|
|
256
271
|
return planner.build(self);
|
|
257
272
|
}
|
|
258
273
|
|
|
259
274
|
pub fn gpuPacket(self: CanvasRenderPass, output: []CanvasGpuCommand) Error!CanvasGpuPacket {
|
|
260
275
|
var planner = CanvasGpuPacketPlanner.init(output);
|
|
276
|
+
if (self.gpu_plan_policy) |owner| return planner.buildCompiled(self, owner);
|
|
261
277
|
return planner.build(self);
|
|
262
278
|
}
|
|
263
279
|
|
|
264
280
|
pub fn gpuPacketSummary(self: CanvasRenderPass) CanvasGpuPacketSummary {
|
|
281
|
+
if (self.gpu_plan_policy) |owner| return gpu_policy.summary(self, owner);
|
|
265
282
|
if (!self.requiresRender()) return .{};
|
|
266
283
|
var summary = CanvasGpuPacketSummary{
|
|
267
284
|
.load_action = self.loadAction(),
|
|
@@ -282,6 +299,9 @@ pub const CanvasRenderPass = struct {
|
|
|
282
299
|
};
|
|
283
300
|
|
|
284
301
|
pub const CanvasFrame = struct {
|
|
302
|
+
/// Static compiled owner for GPU programs and portable vector coverage;
|
|
303
|
+
/// payload pointers remain borrowed from this frame.
|
|
304
|
+
gpu_plan_policy: ?gpu_policy.Policy = null,
|
|
285
305
|
frame_index: u64 = 0,
|
|
286
306
|
timestamp_ns: u64 = 0,
|
|
287
307
|
surface_size: geometry.SizeF = .{},
|
|
@@ -342,14 +362,23 @@ pub const CanvasFrame = struct {
|
|
|
342
362
|
fn diagnosticsWithoutBudgetStatus(self: CanvasFrame) CanvasFrameDiagnostics {
|
|
343
363
|
const render_pass = self.renderPass();
|
|
344
364
|
const gpu_packet_summary = render_pass.gpuPacketSummary();
|
|
365
|
+
const encoder_counts = render_pass.encoderCounts();
|
|
366
|
+
return self.diagnosticsFromPlanningSummaries(gpu_packet_summary, encoder_counts);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
pub fn budgetStatusFromPlanningSummaries(self: CanvasFrame, gpu_packet_summary: CanvasGpuPacketSummary, encoder_counts: gpu_policy.EncoderCounts) CanvasFrameBudgetStatus {
|
|
370
|
+
return self.budget.status(self.diagnosticsFromPlanningSummaries(gpu_packet_summary, encoder_counts));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
fn diagnosticsFromPlanningSummaries(self: CanvasFrame, gpu_packet_summary: CanvasGpuPacketSummary, encoder_counts: gpu_policy.EncoderCounts) CanvasFrameDiagnostics {
|
|
345
374
|
return .{
|
|
346
375
|
.frame_index = self.frame_index,
|
|
347
376
|
.command_count = self.render_plan.commandCount(),
|
|
348
377
|
.batch_count = self.batch_plan.batchCount(),
|
|
349
|
-
.encoder_command_count =
|
|
350
|
-
.encoder_cache_action_count =
|
|
351
|
-
.encoder_bind_pipeline_count =
|
|
352
|
-
.encoder_draw_batch_count =
|
|
378
|
+
.encoder_command_count = encoder_counts.commands,
|
|
379
|
+
.encoder_cache_action_count = encoder_counts.caches,
|
|
380
|
+
.encoder_bind_pipeline_count = encoder_counts.binds,
|
|
381
|
+
.encoder_draw_batch_count = encoder_counts.draws,
|
|
353
382
|
.pipeline_count = self.pipeline_cache_plan.entryCount(),
|
|
354
383
|
.pipeline_upload_count = self.pipeline_cache_plan.uploadCount(),
|
|
355
384
|
.pipeline_retain_count = self.pipeline_cache_plan.retainCount(),
|
|
@@ -417,6 +446,7 @@ pub const CanvasFrame = struct {
|
|
|
417
446
|
|
|
418
447
|
pub fn renderPass(self: CanvasFrame) CanvasRenderPass {
|
|
419
448
|
return .{
|
|
449
|
+
.gpu_plan_policy = self.gpu_plan_policy,
|
|
420
450
|
.frame_index = self.frame_index,
|
|
421
451
|
.timestamp_ns = self.timestamp_ns,
|
|
422
452
|
.surface_size = self.surface_size,
|
|
@@ -453,6 +483,11 @@ pub const CanvasFrame = struct {
|
|
|
453
483
|
};
|
|
454
484
|
|
|
455
485
|
pub const CanvasFrameOptions = struct {
|
|
486
|
+
text_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
487
|
+
render_cache_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
488
|
+
render_plan_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
489
|
+
render_override_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
490
|
+
render_damage_policy: ?*const fn ([]const u8, []u8) usize = null,
|
|
456
491
|
frame_index: u64 = 0,
|
|
457
492
|
timestamp_ns: u64 = 0,
|
|
458
493
|
surface_size: geometry.SizeF = .{},
|
|
@@ -512,14 +547,26 @@ pub const CanvasFrameStorage = struct {
|
|
|
512
547
|
};
|
|
513
548
|
|
|
514
549
|
pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: CanvasFrameOptions, storage: CanvasFrameStorage) Error!CanvasFrame {
|
|
515
|
-
var
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const
|
|
550
|
+
var cache_workspace = render_cache.Workspace.forFrame(options.render_cache_policy, storage, options, next.commands.len);
|
|
551
|
+
defer if (cache_workspace) |*workspace| workspace.deinit();
|
|
552
|
+
const planning_workspace: ?*render_cache.Workspace = if (cache_workspace) |*workspace| workspace else null;
|
|
553
|
+
const cache_owner: ?*render_cache.Workspace = if (options.render_cache_policy != null) planning_workspace else null;
|
|
554
|
+
var render_plan = try next.renderPlanWithWorkspace(storage.render_commands, options.render_plan_policy, planning_workspace);
|
|
555
|
+
const render_override_dirty_bounds = if (options.render_override_policy) |owner| blk: {
|
|
556
|
+
const result = @import("render_override_policy.zig").applyAndDamage(storage.render_commands[0..render_plan.commandCount()], options.previous_render_overrides, options.render_overrides, &[_]@import("render_override_policy.zig").DamageEntry{}, owner, planning_workspace.?);
|
|
557
|
+
render_plan.bounds = result.bounds;
|
|
558
|
+
break :blk result.dirty;
|
|
559
|
+
} else blk: {
|
|
560
|
+
const dirty = renderOverrideDirtyBounds(render_plan.commands, options.previous_render_overrides, options.render_overrides);
|
|
561
|
+
render_plan.bounds = applyRenderOverrides(storage.render_commands[0..render_plan.commandCount()], options.render_overrides);
|
|
562
|
+
break :blk dirty;
|
|
563
|
+
};
|
|
564
|
+
const batch_plan = try render_plan.batchPlanWithWorkspace(storage.render_batches, options.render_plan_policy, planning_workspace);
|
|
519
565
|
const pipeline_cache_plan = if (storage.pipeline_cache_entries.len == 0 and storage.pipeline_cache_actions.len == 0)
|
|
520
566
|
RenderPipelineCachePlan{}
|
|
521
567
|
else
|
|
522
|
-
try batch_plan.
|
|
568
|
+
try batch_plan.cachePlanWithWorkspace(
|
|
569
|
+
cache_owner,
|
|
523
570
|
options.previous_pipeline_cache,
|
|
524
571
|
options.frame_index,
|
|
525
572
|
storage.pipeline_cache_entries,
|
|
@@ -528,11 +575,12 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
528
575
|
const path_geometry_plan = if (storage.path_geometries.len == 0)
|
|
529
576
|
RenderPathGeometryPlan{}
|
|
530
577
|
else
|
|
531
|
-
try render_plan.
|
|
578
|
+
try render_plan.pathGeometryPlanWithPolicy(storage.path_geometries, options.render_cache_policy);
|
|
532
579
|
const path_geometry_cache_plan = if (storage.path_geometry_cache_entries.len == 0 and storage.path_geometry_cache_actions.len == 0)
|
|
533
580
|
RenderPathGeometryCachePlan{}
|
|
534
581
|
else
|
|
535
|
-
try path_geometry_plan.
|
|
582
|
+
try path_geometry_plan.cachePlanWithWorkspace(
|
|
583
|
+
cache_owner,
|
|
536
584
|
options.previous_path_geometry_cache,
|
|
537
585
|
options.frame_index,
|
|
538
586
|
storage.path_geometry_cache_entries,
|
|
@@ -541,11 +589,12 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
541
589
|
const image_plan = if (storage.images.len == 0)
|
|
542
590
|
RenderImagePlan{}
|
|
543
591
|
else
|
|
544
|
-
try render_plan.
|
|
592
|
+
try render_plan.imagePlanWithResourcesAndPolicy(options.image_resources, storage.images, options.render_cache_policy);
|
|
545
593
|
const image_cache_plan = if (storage.image_cache_entries.len == 0 and storage.image_cache_actions.len == 0)
|
|
546
594
|
RenderImageCachePlan{}
|
|
547
595
|
else
|
|
548
|
-
try image_plan.
|
|
596
|
+
try image_plan.cachePlanWithWorkspace(
|
|
597
|
+
cache_owner,
|
|
549
598
|
options.previous_image_cache,
|
|
550
599
|
options.frame_index,
|
|
551
600
|
storage.image_cache_entries,
|
|
@@ -554,18 +603,20 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
554
603
|
const layer_plan = if (storage.layers.len == 0)
|
|
555
604
|
RenderLayerPlan{}
|
|
556
605
|
else
|
|
557
|
-
try render_plan.
|
|
606
|
+
try render_plan.layerPlanWithPolicy(storage.layers, options.render_cache_policy);
|
|
558
607
|
const layer_cache_plan = if (storage.layer_cache_entries.len == 0 and storage.layer_cache_actions.len == 0)
|
|
559
608
|
RenderLayerCachePlan{}
|
|
560
609
|
else
|
|
561
|
-
try layer_plan.
|
|
610
|
+
try layer_plan.cachePlanWithWorkspace(
|
|
611
|
+
cache_owner,
|
|
562
612
|
options.previous_layer_cache,
|
|
563
613
|
options.frame_index,
|
|
564
614
|
storage.layer_cache_entries,
|
|
565
615
|
storage.layer_cache_actions,
|
|
566
616
|
);
|
|
567
|
-
const resource_plan = try next.
|
|
568
|
-
const resource_cache_plan = try resource_plan.
|
|
617
|
+
const resource_plan = try next.resourcePlanWithPolicy(storage.resources, options.render_cache_policy);
|
|
618
|
+
const resource_cache_plan = try resource_plan.cachePlanWithWorkspace(
|
|
619
|
+
cache_owner,
|
|
569
620
|
options.previous_resource_cache,
|
|
570
621
|
options.frame_index,
|
|
571
622
|
storage.resource_cache_entries,
|
|
@@ -574,18 +625,20 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
574
625
|
const visual_effect_plan = if (storage.visual_effects.len == 0)
|
|
575
626
|
VisualEffectPlan{}
|
|
576
627
|
else
|
|
577
|
-
try next.
|
|
628
|
+
try next.visualEffectPlanWithPolicy(storage.visual_effects, options.render_cache_policy);
|
|
578
629
|
const visual_effect_cache_plan = if (storage.visual_effect_cache_entries.len == 0 and storage.visual_effect_cache_actions.len == 0)
|
|
579
630
|
VisualEffectCachePlan{}
|
|
580
631
|
else
|
|
581
|
-
try visual_effect_plan.
|
|
632
|
+
try visual_effect_plan.cachePlanWithWorkspace(
|
|
633
|
+
cache_owner,
|
|
582
634
|
options.previous_visual_effect_cache,
|
|
583
635
|
options.frame_index,
|
|
584
636
|
storage.visual_effect_cache_entries,
|
|
585
637
|
storage.visual_effect_cache_actions,
|
|
586
638
|
);
|
|
587
|
-
const glyph_atlas_plan = try next.
|
|
588
|
-
const glyph_atlas_cache_plan = try glyph_atlas_plan.
|
|
639
|
+
const glyph_atlas_plan = try next.glyphAtlasPlanWithPolicy(storage.glyph_atlas_entries, options.text_cache_policy);
|
|
640
|
+
const glyph_atlas_cache_plan = try glyph_atlas_plan.cachePlanWithPolicy(
|
|
641
|
+
options.text_cache_policy,
|
|
589
642
|
options.previous_glyph_atlas_cache,
|
|
590
643
|
options.frame_index,
|
|
591
644
|
options.glyph_atlas_cache_retention_frames,
|
|
@@ -596,7 +649,8 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
596
649
|
const text_layout_cache_plan = if (storage.text_layout_cache_entries.len == 0 and storage.text_layout_cache_actions.len == 0)
|
|
597
650
|
TextLayoutCachePlan{}
|
|
598
651
|
else
|
|
599
|
-
try text_layout_plan.
|
|
652
|
+
try text_layout_plan.cachePlanWithPolicy(
|
|
653
|
+
options.text_cache_policy,
|
|
600
654
|
options.previous_text_layout_cache,
|
|
601
655
|
options.frame_index,
|
|
602
656
|
options.text_layout_cache_retention_frames,
|
|
@@ -608,7 +662,21 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
608
662
|
var changes: []const DiffChange = storage.changes[0..0];
|
|
609
663
|
var dirty_bounds: ?geometry.RectF = null;
|
|
610
664
|
|
|
611
|
-
if (
|
|
665
|
+
if (options.render_damage_policy) |owner| {
|
|
666
|
+
if (!full_repaint) changes = try DisplayList.diff(previous.?, next, storage.changes);
|
|
667
|
+
var rects: [max_canvas_frame_dirty_rects]geometry.RectF = undefined;
|
|
668
|
+
const result = @import("render_damage_policy.zig").finalize(.{
|
|
669
|
+
.full_repaint = full_repaint,
|
|
670
|
+
.surface_size = options.surface_size,
|
|
671
|
+
.scale = options.scale,
|
|
672
|
+
.render_bounds = render_plan.bounds,
|
|
673
|
+
.override_bounds = render_override_dirty_bounds,
|
|
674
|
+
.sample_extent_multiplier = options.backdrop_blur_sample_extent_multiplier,
|
|
675
|
+
}, changes, render_plan.commands, &rects, owner, planning_workspace.?);
|
|
676
|
+
full_repaint = result.full_repaint;
|
|
677
|
+
dirty_bounds = result.bounds;
|
|
678
|
+
if (full_repaint) changes = storage.changes[0..0];
|
|
679
|
+
} else if (full_repaint) {
|
|
612
680
|
dirty_bounds = fullRepaintBounds(options.surface_size, render_plan.bounds);
|
|
613
681
|
} else {
|
|
614
682
|
changes = try DisplayList.diff(previous.?, next, storage.changes);
|
|
@@ -639,6 +707,7 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
639
707
|
}
|
|
640
708
|
|
|
641
709
|
return .{
|
|
710
|
+
.gpu_plan_policy = options.render_cache_policy,
|
|
642
711
|
.frame_index = options.frame_index,
|
|
643
712
|
.timestamp_ns = options.timestamp_ns,
|
|
644
713
|
.surface_size = options.surface_size,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
pub const Policy = *const fn ([]const u8, []u8) usize;
|
|
3
|
+
pub fn word(bytes: []const u8, at: usize) u32 {
|
|
4
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
5
|
+
}
|
|
6
|
+
pub fn put(bytes: []u8, at: usize, value: usize) void {
|
|
7
|
+
std.mem.writeInt(u32, bytes[at..][0..4], std.math.cast(u32, value) orelse @panic("glyph atlas integer overflow"), .little);
|
|
8
|
+
}
|
|
9
|
+
pub fn integer(bytes: []u8, at: usize, value: u64) void {
|
|
10
|
+
std.mem.writeInt(u64, bytes[at..][0..8], value, .little);
|
|
11
|
+
}
|
|
12
|
+
pub fn float(bytes: []u8, at: usize, value: f32) void {
|
|
13
|
+
std.mem.writeInt(u32, bytes[at..][0..4], @bitCast(value), .little);
|
|
14
|
+
}
|
|
15
|
+
pub fn readFloat(bytes: []const u8, at: usize) f32 {
|
|
16
|
+
return @bitCast(word(bytes, at));
|
|
17
|
+
}
|
|
18
|
+
pub fn resultValid(bytes: []const u8, capacity: usize) bool {
|
|
19
|
+
if (bytes.len < 16) return false;
|
|
20
|
+
const count: usize = word(bytes, 0);
|
|
21
|
+
if (count > capacity or count > (bytes.len - 16) / 32 or bytes.len != 16 + count * 32 or word(bytes, 4) > 1 or word(bytes, 8) != 0 or word(bytes, 12) != 0) return false;
|
|
22
|
+
for (0..count) |i| {
|
|
23
|
+
const at = 16 + i * 32;
|
|
24
|
+
if (word(bytes, at + 16) > 3 or word(bytes, at + 20) > 3) return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
test "glyph atlas copied transport bounds counts padding and subpixel values" {
|
|
29
|
+
var bytes: [48]u8 = @splat(0);
|
|
30
|
+
put(&bytes, 0, 1);
|
|
31
|
+
try std.testing.expect(resultValid(&bytes, 1));
|
|
32
|
+
try std.testing.expect(!resultValid(&bytes, 0));
|
|
33
|
+
for ([_]usize{ 0, 4, 8, 12, 32, 36 }) |at| {
|
|
34
|
+
const saved = word(&bytes, at);
|
|
35
|
+
put(&bytes, at, 0xffffffff);
|
|
36
|
+
try std.testing.expect(!resultValid(&bytes, 1));
|
|
37
|
+
put(&bytes, at, saved);
|
|
38
|
+
}
|
|
39
|
+
for (0..48) |length| try std.testing.expect(!resultValid(bytes[0..length], 1));
|
|
40
|
+
}
|
|
@@ -240,6 +240,8 @@ pub const CanvasGpuCommand = struct {
|
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
pub const CanvasGpuPacket = struct {
|
|
243
|
+
/// Process-local portable packet preparation; never serialized or hashed.
|
|
244
|
+
preparation_policy: ?@import("gpu_packet_preparation_policy.zig").Policy = null,
|
|
243
245
|
frame_index: u64 = 0,
|
|
244
246
|
timestamp_ns: u64 = 0,
|
|
245
247
|
/// Retained-command-state generation stamped into the binary wire
|
|
@@ -382,6 +384,10 @@ pub const RenderEncoderPlanner = struct {
|
|
|
382
384
|
return .{ .commands = self.commands[0..self.len] };
|
|
383
385
|
}
|
|
384
386
|
|
|
387
|
+
pub fn buildCompiled(self: *RenderEncoderPlanner, pass: canvas.CanvasRenderPass, policy: @import("gpu_planning_policy.zig").Policy) Error!RenderEncoderPlan {
|
|
388
|
+
return @import("gpu_planning_policy.zig").encoder(self, pass, policy);
|
|
389
|
+
}
|
|
390
|
+
|
|
385
391
|
fn append(self: *RenderEncoderPlanner, command: RenderEncoderCommand) Error!void {
|
|
386
392
|
if (self.len >= self.commands.len) return error.RenderEncoderListFull;
|
|
387
393
|
self.commands[self.len] = command;
|
|
@@ -454,6 +460,10 @@ pub const CanvasGpuPacketPlanner = struct {
|
|
|
454
460
|
};
|
|
455
461
|
}
|
|
456
462
|
|
|
463
|
+
pub fn buildCompiled(self: *CanvasGpuPacketPlanner, pass: canvas.CanvasRenderPass, policy: @import("gpu_planning_policy.zig").Policy) Error!CanvasGpuPacket {
|
|
464
|
+
return @import("gpu_planning_policy.zig").packet(self, pass, policy);
|
|
465
|
+
}
|
|
466
|
+
|
|
457
467
|
fn append(self: *CanvasGpuPacketPlanner, command: CanvasGpuCommand) Error!void {
|
|
458
468
|
if (self.len >= self.commands.len) return error.CanvasGpuCommandListFull;
|
|
459
469
|
if (!command.supported()) self.unsupported_count += 1;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
//! Complete copied packet facts. Native owns allocations and retained storage;
|
|
2
|
+
//! compiled TypeScript derives identities, duplicate admission and edit flags.
|
|
3
|
+
const std = @import("std");
|
|
4
|
+
const gpu = @import("gpu.zig");
|
|
5
|
+
const canvas = @import("root.zig");
|
|
6
|
+
pub const Policy = @import("gpu_planning_policy.zig").Policy;
|
|
7
|
+
const allocator = std.heap.page_allocator;
|
|
8
|
+
const wire = @import("glyph_atlas_policy.zig");
|
|
9
|
+
const word = wire.word;
|
|
10
|
+
const put = wire.put;
|
|
11
|
+
const Facts = struct {
|
|
12
|
+
bytes: std.ArrayList(u8) = .empty,
|
|
13
|
+
fn deinit(self: *Facts) void {
|
|
14
|
+
self.bytes.deinit(allocator);
|
|
15
|
+
}
|
|
16
|
+
fn appendWord(self: *Facts, value: usize) !void {
|
|
17
|
+
const n = std.math.cast(u32, value) orelse @panic("packet fact exceeds wire range");
|
|
18
|
+
var data: [4]u8 = undefined;
|
|
19
|
+
std.mem.writeInt(u32, &data, n, .little);
|
|
20
|
+
try self.bytes.appendSlice(allocator, &data);
|
|
21
|
+
}
|
|
22
|
+
fn appendWide(self: *Facts, value: u64) !void {
|
|
23
|
+
var data: [8]u8 = undefined;
|
|
24
|
+
std.mem.writeInt(u64, &data, value, .little);
|
|
25
|
+
try self.bytes.appendSlice(allocator, &data);
|
|
26
|
+
}
|
|
27
|
+
fn scalar(self: *Facts, value: f32) !void {
|
|
28
|
+
try self.appendWord(@as(u32, @bitCast(value)));
|
|
29
|
+
}
|
|
30
|
+
fn record(self: *Facts, value: anytype) !void {
|
|
31
|
+
inline for (@typeInfo(@TypeOf(value)).@"struct".fields) |field| try self.scalar(@field(value, field.name));
|
|
32
|
+
}
|
|
33
|
+
fn optionalRect(self: *Facts, value: anytype) !void {
|
|
34
|
+
try self.appendWord(@intFromBool(value != null));
|
|
35
|
+
if (value) |r| try self.record(r);
|
|
36
|
+
}
|
|
37
|
+
fn command(self: *Facts, value: gpu.CanvasGpuCommand) !void {
|
|
38
|
+
const start = self.bytes.items.len;
|
|
39
|
+
try self.appendWord(0);
|
|
40
|
+
try self.appendWord(@intFromEnum(value.kind));
|
|
41
|
+
try self.appendWord(@intFromEnum(value.cap));
|
|
42
|
+
try self.appendWide(value.command_index);
|
|
43
|
+
try self.appendWord(@intFromBool(value.id != null));
|
|
44
|
+
if (value.id) |id| try self.appendWide(id);
|
|
45
|
+
try self.record(value.bounds);
|
|
46
|
+
try self.scalar(value.opacity);
|
|
47
|
+
try self.scalar(value.stroke_width);
|
|
48
|
+
try self.optionalRect(value.clip);
|
|
49
|
+
try self.record(value.transform);
|
|
50
|
+
try self.appendWord(@intFromEnum(std.meta.activeTag(value.shape)));
|
|
51
|
+
switch (value.shape) {
|
|
52
|
+
.none => {},
|
|
53
|
+
.rect => |r| try self.record(r),
|
|
54
|
+
.rounded_rect => |r| {
|
|
55
|
+
try self.record(r.rect);
|
|
56
|
+
try self.record(r.radius);
|
|
57
|
+
},
|
|
58
|
+
.stroke_rect => |r| {
|
|
59
|
+
try self.record(r.rect);
|
|
60
|
+
try self.record(r.radius);
|
|
61
|
+
try self.scalar(r.width);
|
|
62
|
+
},
|
|
63
|
+
.line => |r| {
|
|
64
|
+
try self.record(r.from);
|
|
65
|
+
try self.record(r.to);
|
|
66
|
+
try self.scalar(r.width);
|
|
67
|
+
},
|
|
68
|
+
.path => |elements| {
|
|
69
|
+
try self.appendWord(elements.len);
|
|
70
|
+
for (elements) |element| {
|
|
71
|
+
try self.appendWord(@intFromEnum(element.verb));
|
|
72
|
+
for (element.points) |point| try self.record(point);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
try self.appendWord(@intFromEnum(std.meta.activeTag(value.paint)));
|
|
77
|
+
switch (value.paint) {
|
|
78
|
+
.none => {},
|
|
79
|
+
.color => |c| try self.record(c),
|
|
80
|
+
.linear_gradient => |g| {
|
|
81
|
+
try self.record(g.start);
|
|
82
|
+
try self.record(g.end);
|
|
83
|
+
try self.appendWord(g.stops.len);
|
|
84
|
+
for (g.stops) |stop| {
|
|
85
|
+
try self.scalar(stop.offset);
|
|
86
|
+
try self.record(stop.color);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
try self.appendWord(@intFromBool(value.image != null));
|
|
91
|
+
if (value.image) |image| {
|
|
92
|
+
try self.appendWide(image.image_id);
|
|
93
|
+
try self.optionalRect(image.src);
|
|
94
|
+
try self.record(image.dst);
|
|
95
|
+
try self.scalar(image.opacity);
|
|
96
|
+
try self.appendWord(@intFromEnum(image.fit));
|
|
97
|
+
try self.appendWord(@intFromEnum(image.sampling));
|
|
98
|
+
try self.record(image.radius);
|
|
99
|
+
}
|
|
100
|
+
try self.appendWord(@intFromBool(value.text != null));
|
|
101
|
+
if (value.text) |text| {
|
|
102
|
+
try self.appendWide(text.font_id);
|
|
103
|
+
try self.scalar(text.size);
|
|
104
|
+
try self.record(text.origin);
|
|
105
|
+
try self.record(text.color);
|
|
106
|
+
try self.appendWord(text.text.len);
|
|
107
|
+
try self.bytes.appendSlice(allocator, text.text);
|
|
108
|
+
try self.appendWord(text.glyphs.len);
|
|
109
|
+
for (text.glyphs) |glyph| {
|
|
110
|
+
try self.appendWord(glyph.id);
|
|
111
|
+
try self.appendWide(glyph.font_id);
|
|
112
|
+
try self.scalar(glyph.x);
|
|
113
|
+
try self.scalar(glyph.y);
|
|
114
|
+
try self.scalar(glyph.advance);
|
|
115
|
+
try self.appendWide(glyph.text_start);
|
|
116
|
+
try self.appendWide(glyph.text_len);
|
|
117
|
+
}
|
|
118
|
+
try self.appendWord(@intFromBool(text.text_layout != null));
|
|
119
|
+
if (text.text_layout) |options| {
|
|
120
|
+
try self.scalar(options.max_width);
|
|
121
|
+
try self.scalar(options.line_height);
|
|
122
|
+
try self.appendWord(@intFromEnum(options.wrap));
|
|
123
|
+
try self.appendWord(@intFromEnum(options.alignment));
|
|
124
|
+
try self.appendWord(@intFromEnum(options.overflow));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
try self.appendWord(@intFromEnum(std.meta.activeTag(value.effect)));
|
|
128
|
+
switch (value.effect) {
|
|
129
|
+
.none => {},
|
|
130
|
+
.shadow => |s| {
|
|
131
|
+
try self.record(s.rect);
|
|
132
|
+
try self.record(s.radius);
|
|
133
|
+
try self.record(s.offset);
|
|
134
|
+
try self.scalar(s.blur);
|
|
135
|
+
try self.scalar(s.spread);
|
|
136
|
+
try self.record(s.color);
|
|
137
|
+
},
|
|
138
|
+
.blur => |b| {
|
|
139
|
+
try self.record(b.rect);
|
|
140
|
+
try self.scalar(b.radius);
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
put(self.bytes.items, start, self.bytes.items.len - start - 4);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
fn header(facts: *Facts, mode: u8, count: usize, baseline: usize, unique: bool) !void {
|
|
147
|
+
try facts.bytes.appendSlice(allocator, &([_]u8{0} ** 32));
|
|
148
|
+
facts.bytes.items[0..4].* = .{ 71, 1, mode, 0 };
|
|
149
|
+
put(facts.bytes.items, 4, count);
|
|
150
|
+
put(facts.bytes.items, 8, baseline);
|
|
151
|
+
put(facts.bytes.items, 12, @intFromBool(unique));
|
|
152
|
+
}
|
|
153
|
+
fn resultExtent(mode: u8, current: usize, baseline: usize) usize {
|
|
154
|
+
return std.math.add(usize, 32, if (mode == 0)
|
|
155
|
+
std.math.mul(usize, current, 16) catch @panic("packet result too large")
|
|
156
|
+
else
|
|
157
|
+
std.math.add(usize, current, baseline) catch @panic("packet result too large")) catch @panic("packet result too large");
|
|
158
|
+
}
|
|
159
|
+
/// Envelope validation only: no native hash, key lookup or semantic verdict
|
|
160
|
+
/// is used to validate the compiled result before copying caller storage.
|
|
161
|
+
pub fn resultValid(request: []const u8, result: []const u8) bool {
|
|
162
|
+
if (request.len < 32 or result.len < 32 or request[0] != 71 or request[1] != 1 or request[2] > 1 or request[3] != 0 or word(result, 0) != 1) return false;
|
|
163
|
+
const current: usize = word(request, 4);
|
|
164
|
+
const baseline: usize = word(request, 8);
|
|
165
|
+
for (request[16..32]) |byte| if (byte != 0) return false;
|
|
166
|
+
// Bound arithmetic by actual storage before computing the extent, also
|
|
167
|
+
// when usize is narrower than the count words' combined byte length.
|
|
168
|
+
if (request[2] == 0) {
|
|
169
|
+
if (current > (result.len - 32) / 16) return false;
|
|
170
|
+
} else {
|
|
171
|
+
if (current > result.len - 32 or baseline > result.len - 32 - current) return false;
|
|
172
|
+
}
|
|
173
|
+
if (result.len != resultExtent(request[2], current, baseline) or word(result, 4) != current) return false;
|
|
174
|
+
if (request[2] == 0) {
|
|
175
|
+
if (baseline != 0 or word(request, 12) > 1 or word(result, 8) > word(request, 12)) return false;
|
|
176
|
+
if (current > (request.len - 32) / 4) return false;
|
|
177
|
+
var at: usize = 32;
|
|
178
|
+
for (0..current) |_| {
|
|
179
|
+
if (request.len - at < 4) return false;
|
|
180
|
+
const length: usize = word(request, at);
|
|
181
|
+
at += 4;
|
|
182
|
+
if (length > request.len - at) return false;
|
|
183
|
+
at += length;
|
|
184
|
+
}
|
|
185
|
+
if (at != request.len) return false;
|
|
186
|
+
for (result[12..32]) |byte| if (byte != 0) return false;
|
|
187
|
+
} else {
|
|
188
|
+
if (current > (request.len - 32) / 16 or baseline > (request.len - 32) / 16 - current or request.len != 32 + (current + baseline) * 16) return false;
|
|
189
|
+
if (word(request, 12) != 0 or word(result, 8) != baseline or word(result, 12) > current or word(result, 16) > baseline) return false;
|
|
190
|
+
for (result[20..32]) |byte| if (byte != 0) return false;
|
|
191
|
+
var upserts: usize = 0;
|
|
192
|
+
var unmatched: usize = 0;
|
|
193
|
+
for (result[32..][0..current]) |flag| {
|
|
194
|
+
if (flag > 1) return false;
|
|
195
|
+
upserts += flag;
|
|
196
|
+
}
|
|
197
|
+
for (result[32 + current ..]) |flag| {
|
|
198
|
+
if (flag > 1) return false;
|
|
199
|
+
unmatched += 1 - flag;
|
|
200
|
+
}
|
|
201
|
+
if (upserts != word(result, 12) or unmatched != word(result, 16)) return false;
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
test "packet preparation copied transport rejects unbounded flags counts and reserved bytes" {
|
|
207
|
+
var request: [40]u8 = @splat(0);
|
|
208
|
+
request[0..4].* = .{ 71, 1, 0, 0 };
|
|
209
|
+
put(&request, 4, 2);
|
|
210
|
+
put(&request, 12, 1);
|
|
211
|
+
var result: [64]u8 = @splat(0);
|
|
212
|
+
put(&result, 0, 1);
|
|
213
|
+
put(&result, 4, 2);
|
|
214
|
+
try std.testing.expect(resultValid(&request, &result));
|
|
215
|
+
// Arbitrary identities are allowed: native never recomputes the policy.
|
|
216
|
+
@memset(result[32..], 0xa5);
|
|
217
|
+
put(&result, 8, 1);
|
|
218
|
+
try std.testing.expect(resultValid(&request, &result));
|
|
219
|
+
for ([_]usize{ 0, 4, 8, 12, 16, 20, 24, 28 }) |at| {
|
|
220
|
+
var bad = result;
|
|
221
|
+
put(&bad, at, 0xffffffff);
|
|
222
|
+
try std.testing.expect(!resultValid(&request, &bad));
|
|
223
|
+
}
|
|
224
|
+
for ([_]usize{ 0, 1, 2, 3, 4, 8, 12, 16, 20, 24, 28, 32, 36 }) |at| {
|
|
225
|
+
var bad = request;
|
|
226
|
+
bad[at] = 0xff;
|
|
227
|
+
try std.testing.expect(!resultValid(&bad, &result));
|
|
228
|
+
}
|
|
229
|
+
for (0..result.len) |length| try std.testing.expect(!resultValid(&request, result[0..length]));
|
|
230
|
+
var edits_request: [112]u8 = @splat(0);
|
|
231
|
+
edits_request[0..4].* = .{ 71, 1, 1, 0 };
|
|
232
|
+
put(&edits_request, 4, 3);
|
|
233
|
+
put(&edits_request, 8, 2);
|
|
234
|
+
var edits_result: [37]u8 = @splat(0);
|
|
235
|
+
put(&edits_result, 0, 1);
|
|
236
|
+
put(&edits_result, 4, 3);
|
|
237
|
+
put(&edits_result, 8, 2);
|
|
238
|
+
put(&edits_result, 12, 2);
|
|
239
|
+
put(&edits_result, 16, 1);
|
|
240
|
+
edits_result[32..].* = .{ 1, 0, 1, 0, 1 };
|
|
241
|
+
try std.testing.expect(resultValid(&edits_request, &edits_result));
|
|
242
|
+
for ([_]usize{ 0, 4, 8, 12, 16, 20, 24, 28 }) |at| {
|
|
243
|
+
var bad = edits_result;
|
|
244
|
+
put(&bad, at, 0xffffffff);
|
|
245
|
+
try std.testing.expect(!resultValid(&edits_request, &bad));
|
|
246
|
+
}
|
|
247
|
+
for (32..37) |at| {
|
|
248
|
+
var bad = edits_result;
|
|
249
|
+
bad[at] = 2;
|
|
250
|
+
try std.testing.expect(!resultValid(&edits_request, &bad));
|
|
251
|
+
bad = edits_result;
|
|
252
|
+
bad[at] ^= 1;
|
|
253
|
+
try std.testing.expect(!resultValid(&edits_request, &bad));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
fn invoke(facts: *Facts, policy: Policy) ![]u8 {
|
|
257
|
+
const request = facts.bytes.items;
|
|
258
|
+
const result = try allocator.alloc(u8, resultExtent(request[2], word(request, 4), word(request, 8)));
|
|
259
|
+
errdefer allocator.free(result);
|
|
260
|
+
@memset(result, 0xa5);
|
|
261
|
+
if (policy(request, result) != result.len or !resultValid(request, result)) @panic("invalid compiled packet preparation result");
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
pub const Identity = struct { key: u64, fingerprint: u64 };
|
|
265
|
+
pub fn identities(commands: []const gpu.CanvasGpuCommand, output: []Identity, unique: bool, policy: Policy) bool {
|
|
266
|
+
if (output.len != commands.len) @panic("packet identity storage mismatch");
|
|
267
|
+
var facts: Facts = .{};
|
|
268
|
+
defer facts.deinit();
|
|
269
|
+
header(&facts, 0, commands.len, 0, unique) catch @panic("packet fact allocation failed");
|
|
270
|
+
for (commands) |command| facts.command(command) catch @panic("packet fact allocation failed");
|
|
271
|
+
const result = invoke(&facts, policy) catch @panic("packet identity allocation failed");
|
|
272
|
+
defer allocator.free(result);
|
|
273
|
+
for (output, 0..) |*identity, i| identity.* = .{
|
|
274
|
+
.key = std.mem.readInt(u64, result[32 + i * 16 ..][0..8], .little),
|
|
275
|
+
.fingerprint = std.mem.readInt(u64, result[40 + i * 16 ..][0..8], .little),
|
|
276
|
+
};
|
|
277
|
+
return word(result, 8) == 0;
|
|
278
|
+
}
|
|
279
|
+
pub const Edits = struct { upsert_count: usize, evict_count: usize };
|
|
280
|
+
pub fn edits(current: anytype, keys: []const u64, fingerprints: []const u64, matched: []bool, upserts: []bool, policy: Policy) Edits {
|
|
281
|
+
if (keys.len != fingerprints.len or matched.len != keys.len or upserts.len != current.len) @panic("packet edit storage mismatch");
|
|
282
|
+
var facts: Facts = .{};
|
|
283
|
+
defer facts.deinit();
|
|
284
|
+
header(&facts, 1, current.len, keys.len, false) catch @panic("packet edit allocation failed");
|
|
285
|
+
for (current) |entry| {
|
|
286
|
+
facts.appendWide(entry.key) catch @panic("packet edit allocation failed");
|
|
287
|
+
facts.appendWide(entry.fingerprint) catch @panic("packet edit allocation failed");
|
|
288
|
+
}
|
|
289
|
+
for (keys, fingerprints) |key, fingerprint| {
|
|
290
|
+
facts.appendWide(key) catch @panic("packet edit allocation failed");
|
|
291
|
+
facts.appendWide(fingerprint) catch @panic("packet edit allocation failed");
|
|
292
|
+
}
|
|
293
|
+
const result = invoke(&facts, policy) catch @panic("packet edit allocation failed");
|
|
294
|
+
defer allocator.free(result);
|
|
295
|
+
for (upserts, result[32..][0..current.len]) |*slot, flag| slot.* = flag == 1;
|
|
296
|
+
for (matched, result[32 + current.len ..]) |*slot, flag| slot.* = flag == 1;
|
|
297
|
+
return .{ .upsert_count = word(result, 12), .evict_count = word(result, 16) };
|
|
298
|
+
}
|
|
299
|
+
pub fn gather(commands: []const canvas.RenderCommand, bounds: @import("geometry").RectF, current: anytype, policy: Policy) ?usize {
|
|
300
|
+
return gatherMaterialized(commands, bounds, current, null, policy);
|
|
301
|
+
}
|
|
302
|
+
/// Preserve the complete compiled payloads through serialization. Their slices
|
|
303
|
+
/// borrow the render plan; the caller owns the materialized command storage.
|
|
304
|
+
pub fn gatherMaterialized(commands: []const canvas.RenderCommand, bounds: @import("geometry").RectF, current: anytype, materialized: ?[]gpu.CanvasGpuCommand, policy: Policy) ?usize {
|
|
305
|
+
const capacity = @min(commands.len, current.len);
|
|
306
|
+
const packets = allocator.alloc(gpu.CanvasGpuCommand, capacity) catch @panic("packet gather allocation failed");
|
|
307
|
+
defer allocator.free(packets);
|
|
308
|
+
var planner = gpu.CanvasGpuPacketPlanner.init(packets);
|
|
309
|
+
const packet = planner.buildCompiled(canvas.CanvasRenderPass{ .commands = commands, .full_repaint = true, .dirty_bounds = bounds }, policy) catch return null;
|
|
310
|
+
if (packet.unsupported_command_count != 0) return null;
|
|
311
|
+
const identity = allocator.alloc(Identity, packet.commands.len) catch @panic("packet gather identity allocation failed");
|
|
312
|
+
defer allocator.free(identity);
|
|
313
|
+
if (!identities(packet.commands, identity, true, policy)) return null;
|
|
314
|
+
for (packet.commands, identity, current[0..packet.commands.len]) |command, id, *slot| slot.* = .{
|
|
315
|
+
.key = id.key,
|
|
316
|
+
.fingerprint = id.fingerprint,
|
|
317
|
+
.render_index = @intCast(command.command_index),
|
|
318
|
+
.bounds = command.bounds,
|
|
319
|
+
};
|
|
320
|
+
if (materialized) |storage| {
|
|
321
|
+
if (storage.len < packet.commands.len) @panic("retained command storage mismatch");
|
|
322
|
+
@memcpy(storage[0..packet.commands.len], packet.commands);
|
|
323
|
+
}
|
|
324
|
+
return packet.commands.len;
|
|
325
|
+
}
|