@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1796 -83
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -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 +57 -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 +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -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 +166 -19
- 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/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/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- 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_development.ts +160 -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 +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -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 +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- 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 +11 -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_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -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_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 +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- 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/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 +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- 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/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -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/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/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 +128 -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/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- 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 +100 -0
- 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 +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -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 +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -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_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- 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 +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -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 +126 -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 +20 -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 +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -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/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 +4 -4
- 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 +437 -81
- 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/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- 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/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 +13 -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 +224 -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/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 +46 -36
- package/src/runtime/tests.zig +1 -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 +2325 -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 +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- 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 +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -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_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -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 +163 -10
- 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 +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- 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 +166 -0
- package/tools/corewire/core_abi.zig +51 -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 +360 -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 +290 -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 +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -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 +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -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 +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -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
|
}
|
|
@@ -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.geist_regular;
|
|
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
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//! Copied paint recipes and sibling programs. Display-list storage stays native.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const widgets = @import("widgets.zig");
|
|
4
|
+
const tokens = @import("tokens.zig");
|
|
5
|
+
const widget_access = @import("widget_access.zig");
|
|
6
|
+
pub const reference = @import("widget_tree.zig");
|
|
7
|
+
pub const Policy = @import("surface_layout_policy.zig").Policy;
|
|
8
|
+
pub const Mode = enum(u8) { tree, retained };
|
|
9
|
+
pub const Status = enum(u32) { ready, hidden, depth };
|
|
10
|
+
pub const Opcode = enum(u32) { backdrop, draw, scrim, children, separators, scrollbars, reactions };
|
|
11
|
+
pub const Draw = enum(u32) {
|
|
12
|
+
container,
|
|
13
|
+
data_row,
|
|
14
|
+
tabs,
|
|
15
|
+
alert,
|
|
16
|
+
card,
|
|
17
|
+
dialog,
|
|
18
|
+
drawer,
|
|
19
|
+
sheet,
|
|
20
|
+
accordion,
|
|
21
|
+
bubble,
|
|
22
|
+
panel,
|
|
23
|
+
popover,
|
|
24
|
+
menu,
|
|
25
|
+
text,
|
|
26
|
+
code_paragraph,
|
|
27
|
+
spans,
|
|
28
|
+
icon,
|
|
29
|
+
image,
|
|
30
|
+
media,
|
|
31
|
+
terminal,
|
|
32
|
+
avatar,
|
|
33
|
+
badge,
|
|
34
|
+
button,
|
|
35
|
+
icon_button,
|
|
36
|
+
select,
|
|
37
|
+
text_field,
|
|
38
|
+
code_editor,
|
|
39
|
+
search,
|
|
40
|
+
tooltip,
|
|
41
|
+
menu_item,
|
|
42
|
+
list_item,
|
|
43
|
+
data_cell,
|
|
44
|
+
status,
|
|
45
|
+
segmented,
|
|
46
|
+
checkbox,
|
|
47
|
+
radio,
|
|
48
|
+
toggle,
|
|
49
|
+
slider,
|
|
50
|
+
progress,
|
|
51
|
+
separator,
|
|
52
|
+
split_divider,
|
|
53
|
+
skeleton,
|
|
54
|
+
spinner,
|
|
55
|
+
chart,
|
|
56
|
+
input_group,
|
|
57
|
+
};
|
|
58
|
+
pub const Command = struct { opcode: Opcode, arg: u32 };
|
|
59
|
+
fn word(bytes: []u8, at: usize, value: u32) void {
|
|
60
|
+
std.mem.writeInt(u32, bytes[at..][0..4], value, .little);
|
|
61
|
+
}
|
|
62
|
+
fn read(bytes: []const u8, at: usize) u32 {
|
|
63
|
+
return std.mem.readInt(u32, bytes[at..][0..4], .little);
|
|
64
|
+
}
|
|
65
|
+
pub const Recipe = struct {
|
|
66
|
+
status: Status,
|
|
67
|
+
count: usize,
|
|
68
|
+
commands: [6]Command,
|
|
69
|
+
pub fn init(policy: Policy, mode: Mode, widget: widgets.Widget, t: tokens.DesignTokens, depth: usize, disclosure: u8, code_paragraph: bool) Recipe {
|
|
70
|
+
var request: [32]u8 = @splat(0);
|
|
71
|
+
request[0..4].* = .{ 43, 1, @intFromEnum(mode), disclosure };
|
|
72
|
+
var flags: u32 = 0;
|
|
73
|
+
for ([_]bool{ widget.layout.clip_content, widget.layout.virtualized, widget.spans.len > 0, code_paragraph, widget.runtime_flags.code_editor, widget.runtime_flags.native_scroll, widget_access.booleanControlSelected(widget), widget.children.len > 0, widget.semantics.hidden, t.controls.button_group_style == .detached, widget.scrim }, 0..) |value, i|
|
|
74
|
+
flags |= @as(u32, @intFromBool(value)) << @intCast(i);
|
|
75
|
+
word(&request, 4, flags);
|
|
76
|
+
std.mem.writeInt(u64, request[8..16], depth, .little);
|
|
77
|
+
word(&request, 16, @bitCast(widget.layout.gap));
|
|
78
|
+
word(&request, 20, @intFromEnum(widget.kind));
|
|
79
|
+
var result: [64]u8 = @splat(0xa5);
|
|
80
|
+
if (policy(&request, &result) != 64 or read(&result, 0) != 1 or read(&result, 4) > 2 or read(&result, 8) > 6 or read(&result, 12) != 0)
|
|
81
|
+
@panic("invalid render recipe result");
|
|
82
|
+
const count = read(&result, 8);
|
|
83
|
+
if (read(&result, 4) != 0 and count != 0) @panic("invalid inactive render recipe");
|
|
84
|
+
if (!std.mem.allEqual(u8, result[16 + count * 8 ..], 0)) @panic("invalid render recipe tail");
|
|
85
|
+
var recipe: Recipe = .{ .status = @enumFromInt(read(&result, 4)), .count = count, .commands = undefined };
|
|
86
|
+
for (recipe.commands[0..count], 0..) |*command, i| {
|
|
87
|
+
const op = read(&result, 16 + i * 8);
|
|
88
|
+
const arg = read(&result, 20 + i * 8);
|
|
89
|
+
if (op > @intFromEnum(Opcode.reactions)) @panic("invalid render capability");
|
|
90
|
+
const valid = switch (@as(Opcode, @enumFromInt(op))) {
|
|
91
|
+
.draw => arg <= @intFromEnum(Draw.input_group),
|
|
92
|
+
.children => arg & ~@as(u32, 0x303) == 0,
|
|
93
|
+
.separators, .scrollbars => arg <= 1,
|
|
94
|
+
else => arg == 0,
|
|
95
|
+
};
|
|
96
|
+
if (!valid) @panic("invalid render capability arguments");
|
|
97
|
+
command.* = .{ .opcode = @enumFromInt(op), .arg = arg };
|
|
98
|
+
}
|
|
99
|
+
return recipe;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
pub const ChildPlan = struct {
|
|
103
|
+
allocator: std.mem.Allocator,
|
|
104
|
+
result: []u8,
|
|
105
|
+
count: usize,
|
|
106
|
+
pub fn init(allocator: std.mem.Allocator, policy: Policy, children: []const widgets.Widget, t: tokens.DesignTokens, stamp: bool) !ChildPlan {
|
|
107
|
+
const count = std.math.cast(u32, children.len) orelse @panic("render child count exceeds wire range");
|
|
108
|
+
const request = try allocator.alloc(u8, try std.math.add(usize, 32, try std.math.mul(usize, children.len, 12)));
|
|
109
|
+
defer allocator.free(request);
|
|
110
|
+
const result = try allocator.alloc(u8, try std.math.add(usize, 8, try std.math.mul(usize, children.len, 8)));
|
|
111
|
+
errdefer allocator.free(result);
|
|
112
|
+
@memset(request, 0);
|
|
113
|
+
request[0..4].* = .{ 44, 1, @intFromBool(stamp), 0 };
|
|
114
|
+
word(request, 4, count);
|
|
115
|
+
for ([_]i32{ t.layer.base, t.layer.modal, t.layer.overlay, t.layer.floating }, 0..) |layer, i| word(request, 8 + i * 4, @bitCast(layer));
|
|
116
|
+
for (children, 0..) |child, i| {
|
|
117
|
+
const at = 32 + i * 12;
|
|
118
|
+
word(request, at, @intFromEnum(child.kind));
|
|
119
|
+
word(request, at + 4, @as(u32, @intFromBool(child.semantics.hidden)) | (@as(u32, @intFromBool(child.layer != null)) << 1));
|
|
120
|
+
if (child.layer) |layer| word(request, at + 8, @bitCast(layer));
|
|
121
|
+
}
|
|
122
|
+
@memset(result, 0xa5);
|
|
123
|
+
if (policy(request, result) != result.len or read(result, 0) != 1 or read(result, 4) != count) @panic("invalid render child result");
|
|
124
|
+
const plan: ChildPlan = .{ .allocator = allocator, .result = result, .count = count };
|
|
125
|
+
for (0..count) |i| {
|
|
126
|
+
if (plan.index(i) >= count or read(result, 12 + i * 8) > 3) @panic("invalid render child entry");
|
|
127
|
+
for (0..i) |j| if (plan.index(i) == plan.index(j)) @panic("duplicate render child entry");
|
|
128
|
+
}
|
|
129
|
+
return plan;
|
|
130
|
+
}
|
|
131
|
+
pub fn deinit(self: ChildPlan) void {
|
|
132
|
+
self.allocator.free(self.result);
|
|
133
|
+
}
|
|
134
|
+
pub fn index(self: ChildPlan, ordinal: usize) usize {
|
|
135
|
+
return read(self.result, 8 + ordinal * 8);
|
|
136
|
+
}
|
|
137
|
+
pub fn segment(self: ChildPlan, ordinal: usize) widgets.WidgetGroupSegment {
|
|
138
|
+
return @enumFromInt(read(self.result, 12 + ordinal * 8));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/// Actual layer boundaries are copied from the portable composition owner.
|
|
143
|
+
pub const ChromePlan = struct {
|
|
144
|
+
prefix: usize,
|
|
145
|
+
suffix: usize,
|
|
146
|
+
pub fn init(policy: Policy, prefix_budget: usize, suffix_budget: usize, count: usize, before: ?usize, variable: bool) error{InvalidChromeCommandCount}!ChromePlan {
|
|
147
|
+
var request: [40]u8 = @splat(0);
|
|
148
|
+
request[0..4].* = .{ 67, 1, @as(u8, @intFromBool(before != null)) | (@as(u8, @intFromBool(variable)) << 1), 0 };
|
|
149
|
+
for ([_]usize{ prefix_budget, suffix_budget, count, before orelse 0 }, 0..) |value, i|
|
|
150
|
+
std.mem.writeInt(u64, request[8 + i * 8 ..][0..8], value, .little);
|
|
151
|
+
var result: [24]u8 = @splat(0xa5);
|
|
152
|
+
if (policy(&request, &result) != result.len or read(&result, 0) != 1 or read(&result, 4) > 1 or !std.mem.allEqual(u8, result[16..], 0))
|
|
153
|
+
@panic("invalid chrome composition result");
|
|
154
|
+
if (read(&result, 4) == 1) {
|
|
155
|
+
if (!std.mem.allEqual(u8, result[8..], 0)) @panic("invalid rejected chrome composition");
|
|
156
|
+
return error.InvalidChromeCommandCount;
|
|
157
|
+
}
|
|
158
|
+
const plan: ChromePlan = .{ .prefix = read(&result, 8), .suffix = read(&result, 12) };
|
|
159
|
+
if (plan.prefix > count or plan.suffix > count - plan.prefix or plan.prefix + plan.suffix != count)
|
|
160
|
+
@panic("invalid chrome composition span");
|
|
161
|
+
return plan;
|
|
162
|
+
}
|
|
163
|
+
};
|