@native-sdk/cli 0.0.0 → 0.4.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/LICENSE +176 -0
- package/README.md +50 -1
- package/app.zon +30 -0
- package/bin/native.js +156 -0
- package/build/app.zig +716 -0
- package/build.zig +2593 -0
- package/build.zig.zon +24 -0
- package/native-sdk.d.ts +615 -0
- package/package.json +44 -8
- package/skill-data/automation/SKILL.md +248 -0
- package/skill-data/core/SKILL.md +249 -0
- package/skill-data/core/references/app-model-runtime.md +141 -0
- package/skill-data/core/references/bridge-security-native-capabilities.md +230 -0
- package/skill-data/core/references/frontend-assets.md +124 -0
- package/skill-data/core/references/project-anatomy.md +108 -0
- package/skill-data/core/references/web-engines-packaging-debugging.md +199 -0
- package/skill-data/native-ui/SKILL.md +1080 -0
- package/skills/native-sdk/SKILL.md +33 -0
- package/src/app_runner/root.zig +740 -0
- package/src/assets/root.zig +20 -0
- package/src/automation/protocol.zig +285 -0
- package/src/automation/root.zig +13 -0
- package/src/automation/server.zig +506 -0
- package/src/automation/snapshot.zig +1202 -0
- package/src/automation/watcher.zig +165 -0
- package/src/bridge/root.zig +507 -0
- package/src/debug/root.zig +246 -0
- package/src/embed/app_exports.zig +11 -0
- package/src/embed/c_api.zig +793 -0
- package/src/embed/c_exports.zig +10 -0
- package/src/embed/chrome.zig +168 -0
- package/src/embed/conversions.zig +359 -0
- package/src/embed/host.zig +960 -0
- package/src/embed/root.zig +81 -0
- package/src/embed/tests.zig +2552 -0
- package/src/embed/types.zig +382 -0
- package/src/embed/ui_host.zig +289 -0
- package/src/extensions/root.zig +197 -0
- package/src/frontend/root.zig +48 -0
- package/src/js/root.zig +65 -0
- package/src/platform/android/NativeSdkActivity.java +1370 -0
- package/src/platform/android/android_host.c +696 -0
- package/src/platform/android/files.zig +9 -0
- package/src/platform/android/native_sdk_app.h +237 -0
- package/src/platform/ios/files.zig +8 -0
- package/src/platform/ios/native_sdk_app.h +289 -0
- package/src/platform/ios/uikit_host.m +2739 -0
- package/src/platform/linux/cef_host.cpp +599 -0
- package/src/platform/linux/gtk_host.c +5362 -0
- package/src/platform/linux/gtk_host.h +265 -0
- package/src/platform/linux/root.zig +1519 -0
- package/src/platform/macos/appkit_host.h +604 -0
- package/src/platform/macos/appkit_host.m +10392 -0
- package/src/platform/macos/automation_host.h +14 -0
- package/src/platform/macos/automation_host.m +12 -0
- package/src/platform/macos/cef_host.mm +3028 -0
- package/src/platform/macos/root.zig +2260 -0
- package/src/platform/null_platform.zig +2232 -0
- package/src/platform/null_platform_tests.zig +670 -0
- package/src/platform/policy_values.zig +14 -0
- package/src/platform/root.zig +181 -0
- package/src/platform/types.zig +2681 -0
- package/src/platform/windows/cef_host.cpp +3 -0
- package/src/platform/windows/root.zig +1521 -0
- package/src/platform/windows/webview2_host.cpp +6230 -0
- package/src/primitives/app_dirs/root.zig +440 -0
- package/src/primitives/app_manifest/root.zig +109 -0
- package/src/primitives/app_manifest/tests.zig +758 -0
- package/src/primitives/app_manifest/types.zig +587 -0
- package/src/primitives/app_manifest/validation.zig +828 -0
- package/src/primitives/assets/root.zig +520 -0
- package/src/primitives/canvas/a11y_audit.zig +390 -0
- package/src/primitives/canvas/a11y_audit_tests.zig +225 -0
- package/src/primitives/canvas/app_icon.zig +1590 -0
- package/src/primitives/canvas/chart.zig +392 -0
- package/src/primitives/canvas/chart_tests.zig +751 -0
- package/src/primitives/canvas/commands.zig +446 -0
- package/src/primitives/canvas/drawing.zig +309 -0
- package/src/primitives/canvas/equality.zig +316 -0
- package/src/primitives/canvas/events.zig +696 -0
- package/src/primitives/canvas/font_coverage.zig +118 -0
- package/src/primitives/canvas/font_ttf.zig +510 -0
- package/src/primitives/canvas/font_ttf_tests.zig +280 -0
- package/src/primitives/canvas/fonts/Geist-Regular.ttf +0 -0
- package/src/primitives/canvas/fonts/GeistMono-Regular.ttf +0 -0
- package/src/primitives/canvas/frame.zig +679 -0
- package/src/primitives/canvas/frame_metrics.zig +462 -0
- package/src/primitives/canvas/gpu.zig +639 -0
- package/src/primitives/canvas/hash.zig +112 -0
- package/src/primitives/canvas/icons/alert.svg +1 -0
- package/src/primitives/canvas/icons/archive.svg +1 -0
- package/src/primitives/canvas/icons/arrow-down.svg +1 -0
- package/src/primitives/canvas/icons/arrow-right.svg +1 -0
- package/src/primitives/canvas/icons/arrow-up.svg +1 -0
- package/src/primitives/canvas/icons/check-circle.svg +1 -0
- package/src/primitives/canvas/icons/check.svg +1 -0
- package/src/primitives/canvas/icons/chevron-down.svg +1 -0
- package/src/primitives/canvas/icons/chevron-left.svg +1 -0
- package/src/primitives/canvas/icons/chevron-right.svg +1 -0
- package/src/primitives/canvas/icons/chevron-up.svg +1 -0
- package/src/primitives/canvas/icons/circle-dot.svg +1 -0
- package/src/primitives/canvas/icons/clock.svg +1 -0
- package/src/primitives/canvas/icons/copy.svg +1 -0
- package/src/primitives/canvas/icons/download.svg +1 -0
- package/src/primitives/canvas/icons/edit.svg +1 -0
- package/src/primitives/canvas/icons/ellipsis.svg +1 -0
- package/src/primitives/canvas/icons/external-link.svg +1 -0
- package/src/primitives/canvas/icons/eye.svg +1 -0
- package/src/primitives/canvas/icons/file-text.svg +1 -0
- package/src/primitives/canvas/icons/folder-open.svg +1 -0
- package/src/primitives/canvas/icons/folder.svg +1 -0
- package/src/primitives/canvas/icons/git-branch.svg +1 -0
- package/src/primitives/canvas/icons/git-merge.svg +1 -0
- package/src/primitives/canvas/icons/git-pull-request.svg +1 -0
- package/src/primitives/canvas/icons/info.svg +1 -0
- package/src/primitives/canvas/icons/menu.svg +1 -0
- package/src/primitives/canvas/icons/missing.svg +1 -0
- package/src/primitives/canvas/icons/moon.svg +1 -0
- package/src/primitives/canvas/icons/music.svg +1 -0
- package/src/primitives/canvas/icons/panel-left.svg +1 -0
- package/src/primitives/canvas/icons/panel-right.svg +1 -0
- package/src/primitives/canvas/icons/pause.svg +1 -0
- package/src/primitives/canvas/icons/play.svg +1 -0
- package/src/primitives/canvas/icons/plus.svg +1 -0
- package/src/primitives/canvas/icons/refresh-cw.svg +1 -0
- package/src/primitives/canvas/icons/repeat.svg +1 -0
- package/src/primitives/canvas/icons/save.svg +1 -0
- package/src/primitives/canvas/icons/search.svg +1 -0
- package/src/primitives/canvas/icons/send.svg +1 -0
- package/src/primitives/canvas/icons/settings.svg +1 -0
- package/src/primitives/canvas/icons/shuffle.svg +1 -0
- package/src/primitives/canvas/icons/skip-back.svg +1 -0
- package/src/primitives/canvas/icons/skip-forward.svg +1 -0
- package/src/primitives/canvas/icons/sun.svg +1 -0
- package/src/primitives/canvas/icons/terminal.svg +1 -0
- package/src/primitives/canvas/icons/trash.svg +1 -0
- package/src/primitives/canvas/icons/volume.svg +1 -0
- package/src/primitives/canvas/icons/wrench.svg +1 -0
- package/src/primitives/canvas/icons/x-circle.svg +1 -0
- package/src/primitives/canvas/icons/x.svg +1 -0
- package/src/primitives/canvas/icons.zig +249 -0
- package/src/primitives/canvas/layout_audit.zig +744 -0
- package/src/primitives/canvas/layout_audit_tests.zig +426 -0
- package/src/primitives/canvas/markdown.zig +1031 -0
- package/src/primitives/canvas/markdown_hostile_tests.zig +471 -0
- package/src/primitives/canvas/markdown_tests.zig +538 -0
- package/src/primitives/canvas/plan_key_index.zig +120 -0
- package/src/primitives/canvas/png.zig +355 -0
- package/src/primitives/canvas/reference.zig +1457 -0
- package/src/primitives/canvas/reference_blur.zig +104 -0
- package/src/primitives/canvas/reference_memo.zig +322 -0
- package/src/primitives/canvas/reference_paths.zig +184 -0
- package/src/primitives/canvas/reference_tests.zig +1650 -0
- package/src/primitives/canvas/render.zig +747 -0
- package/src/primitives/canvas/render_effects.zig +255 -0
- package/src/primitives/canvas/render_fingerprints.zig +256 -0
- package/src/primitives/canvas/render_generic_resources.zig +376 -0
- package/src/primitives/canvas/render_images.zig +247 -0
- package/src/primitives/canvas/render_layers.zig +260 -0
- package/src/primitives/canvas/render_paths.zig +347 -0
- package/src/primitives/canvas/render_resources.zig +51 -0
- package/src/primitives/canvas/render_tests.zig +3186 -0
- package/src/primitives/canvas/root.zig +744 -0
- package/src/primitives/canvas/serialization.zig +1528 -0
- package/src/primitives/canvas/svg_icon.zig +636 -0
- package/src/primitives/canvas/svg_icon_tests.zig +312 -0
- package/src/primitives/canvas/test_support.zig +422 -0
- package/src/primitives/canvas/testdata/markdown_document.md +83 -0
- package/src/primitives/canvas/tests.zig +30 -0
- package/src/primitives/canvas/text.zig +82 -0
- package/src/primitives/canvas/text_atlas.zig +408 -0
- package/src/primitives/canvas/text_batch_tests.zig +431 -0
- package/src/primitives/canvas/text_interaction.zig +615 -0
- package/src/primitives/canvas/text_layout.zig +1069 -0
- package/src/primitives/canvas/text_layout_cache.zig +281 -0
- package/src/primitives/canvas/text_layout_hash.zig +113 -0
- package/src/primitives/canvas/text_layout_types.zig +128 -0
- package/src/primitives/canvas/text_measure_cache.zig +279 -0
- package/src/primitives/canvas/text_metrics.zig +309 -0
- package/src/primitives/canvas/text_metrics_tests.zig +262 -0
- package/src/primitives/canvas/text_span_tests.zig +608 -0
- package/src/primitives/canvas/text_spans.zig +1010 -0
- package/src/primitives/canvas/text_tests.zig +1949 -0
- package/src/primitives/canvas/themes/geist.zig +470 -0
- package/src/primitives/canvas/tokens.zig +1522 -0
- package/src/primitives/canvas/ui.zig +2686 -0
- package/src/primitives/canvas/ui_markup.zig +3791 -0
- package/src/primitives/canvas/ui_markup_binary.zig +522 -0
- package/src/primitives/canvas/ui_markup_binary_tests.zig +591 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +2565 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1669 -0
- package/src/primitives/canvas/ui_markup_contract.zig +1620 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +953 -0
- package/src/primitives/canvas/ui_markup_edit.zig +416 -0
- package/src/primitives/canvas/ui_markup_edit_tests.zig +341 -0
- package/src/primitives/canvas/ui_markup_expr.zig +1152 -0
- package/src/primitives/canvas/ui_markup_expr_tests.zig +779 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +505 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +1545 -0
- package/src/primitives/canvas/ui_markup_view.zig +2352 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +3709 -0
- package/src/primitives/canvas/ui_provenance.zig +96 -0
- package/src/primitives/canvas/ui_provenance_tests.zig +186 -0
- package/src/primitives/canvas/ui_schema.zig +825 -0
- package/src/primitives/canvas/ui_schema_tests.zig +128 -0
- package/src/primitives/canvas/ui_tests.zig +1432 -0
- package/src/primitives/canvas/vector.zig +919 -0
- package/src/primitives/canvas/vector_tests.zig +547 -0
- package/src/primitives/canvas/virtual_extent_tests.zig +317 -0
- package/src/primitives/canvas/virtual_extents.zig +540 -0
- package/src/primitives/canvas/widget_access.zig +208 -0
- package/src/primitives/canvas/widget_anchored_tests.zig +264 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +3160 -0
- package/src/primitives/canvas/widget_invalidation.zig +748 -0
- package/src/primitives/canvas/widget_layout.zig +2055 -0
- package/src/primitives/canvas/widget_layout_tests.zig +2691 -0
- package/src/primitives/canvas/widget_metrics.zig +228 -0
- package/src/primitives/canvas/widget_render.zig +2534 -0
- package/src/primitives/canvas/widget_render_controls.zig +1563 -0
- package/src/primitives/canvas/widget_render_scroll.zig +136 -0
- package/src/primitives/canvas/widget_render_style.zig +626 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +794 -0
- package/src/primitives/canvas/widget_routing.zig +475 -0
- package/src/primitives/canvas/widget_runtime.zig +307 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +3015 -0
- package/src/primitives/canvas/widget_semantics.zig +480 -0
- package/src/primitives/canvas/widget_semantics_tests.zig +2129 -0
- package/src/primitives/canvas/widget_tests.zig +8 -0
- package/src/primitives/canvas/widget_text_input.zig +351 -0
- package/src/primitives/canvas/widget_text_select.zig +147 -0
- package/src/primitives/canvas/widget_tree.zig +232 -0
- package/src/primitives/canvas/widgets.zig +1319 -0
- package/src/primitives/diagnostics/root.zig +445 -0
- package/src/primitives/geometry/root.zig +889 -0
- package/src/primitives/json/root.zig +272 -0
- package/src/primitives/platform_info/root.zig +450 -0
- package/src/primitives/trace/root.zig +569 -0
- package/src/root.zig +165 -0
- package/src/runtime/api.zig +431 -0
- package/src/runtime/async_bridge.zig +49 -0
- package/src/runtime/automation_commands.zig +686 -0
- package/src/runtime/automation_liveness_tests.zig +140 -0
- package/src/runtime/automation_snapshot.zig +246 -0
- package/src/runtime/automation_widget_dispatch.zig +617 -0
- package/src/runtime/bridge_dispatch_tests.zig +202 -0
- package/src/runtime/bridge_payload.zig +194 -0
- package/src/runtime/bridge_permission_tests.zig +551 -0
- package/src/runtime/bridge_responses.zig +414 -0
- package/src/runtime/builtin_bridge.zig +554 -0
- package/src/runtime/canvas_budget_edge_tests.zig +415 -0
- package/src/runtime/canvas_font_tests.zig +410 -0
- package/src/runtime/canvas_fonts.zig +229 -0
- package/src/runtime/canvas_frame.zig +1734 -0
- package/src/runtime/canvas_frame_animation_tests.zig +609 -0
- package/src/runtime/canvas_frame_cache_tests.zig +333 -0
- package/src/runtime/canvas_frame_helpers.zig +414 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +544 -0
- package/src/runtime/canvas_frame_packet_tests.zig +1353 -0
- package/src/runtime/canvas_frame_patch_tests.zig +1051 -0
- package/src/runtime/canvas_frame_retained_tests.zig +753 -0
- package/src/runtime/canvas_frame_tests.zig +9 -0
- package/src/runtime/canvas_frame_text_layout_budget_tests.zig +149 -0
- package/src/runtime/canvas_image_tests.zig +362 -0
- package/src/runtime/canvas_images.zig +224 -0
- package/src/runtime/canvas_limits.zig +317 -0
- package/src/runtime/canvas_screenshot_tests.zig +289 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +1494 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +678 -0
- package/src/runtime/canvas_widget_chart_tests.zig +249 -0
- package/src/runtime/canvas_widget_clipboard_tests.zig +399 -0
- package/src/runtime/canvas_widget_context_menu.zig +318 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +462 -0
- package/src/runtime/canvas_widget_control_tests.zig +2164 -0
- package/src/runtime/canvas_widget_disclosure_tests.zig +440 -0
- package/src/runtime/canvas_widget_display.zig +677 -0
- package/src/runtime/canvas_widget_event_tests.zig +1779 -0
- package/src/runtime/canvas_widget_events.zig +1098 -0
- package/src/runtime/canvas_widget_floating_tests.zig +695 -0
- package/src/runtime/canvas_widget_layout_tests.zig +26 -0
- package/src/runtime/canvas_widget_runtime.zig +1335 -0
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +582 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +202 -0
- package/src/runtime/canvas_widget_scroll_tests.zig +1549 -0
- package/src/runtime/canvas_widget_semantics_tests.zig +810 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +1031 -0
- package/src/runtime/canvas_widget_state.zig +798 -0
- package/src/runtime/canvas_widget_text_tests.zig +2104 -0
- package/src/runtime/canvas_widget_window_drag_tests.zig +284 -0
- package/src/runtime/clock.zig +231 -0
- package/src/runtime/core.zig +927 -0
- package/src/runtime/effects.zig +4197 -0
- package/src/runtime/effects_audio_tests.zig +690 -0
- package/src/runtime/effects_clipboard_tests.zig +317 -0
- package/src/runtime/effects_fetch_tests.zig +1031 -0
- package/src/runtime/effects_file_tests.zig +407 -0
- package/src/runtime/effects_tests.zig +1251 -0
- package/src/runtime/flow.zig +1175 -0
- package/src/runtime/frame_profile.zig +221 -0
- package/src/runtime/gpu_surface_events.zig +639 -0
- package/src/runtime/launch_timing.zig +59 -0
- package/src/runtime/markdown_app_tests.zig +224 -0
- package/src/runtime/native_command_event_tests.zig +431 -0
- package/src/runtime/platform_bridge_tests.zig +8 -0
- package/src/runtime/platform_config_tests.zig +392 -0
- package/src/runtime/root.zig +150 -0
- package/src/runtime/runtime_event_tests.zig +1079 -0
- package/src/runtime/session_journal.zig +1522 -0
- package/src/runtime/session_record.zig +332 -0
- package/src/runtime/session_replay.zig +274 -0
- package/src/runtime/session_state.zig +30 -0
- package/src/runtime/session_tests.zig +399 -0
- package/src/runtime/shell_layout.zig +472 -0
- package/src/runtime/shell_layout_tests.zig +1246 -0
- package/src/runtime/shell_view_tests.zig +604 -0
- package/src/runtime/state.zig +110 -0
- package/src/runtime/system_services.zig +392 -0
- package/src/runtime/test_support.zig +79 -0
- package/src/runtime/tests.zig +30 -0
- package/src/runtime/ui_app.zig +3290 -0
- package/src/runtime/ui_app_huge_model_tests.zig +351 -0
- package/src/runtime/ui_app_provenance.zig +370 -0
- package/src/runtime/ui_app_tests.zig +3254 -0
- package/src/runtime/ui_app_virtual_variable_tests.zig +485 -0
- package/src/runtime/ui_app_window_tests.zig +442 -0
- package/src/runtime/validation.zig +206 -0
- package/src/runtime/view.zig +908 -0
- package/src/runtime/view_canvas.zig +850 -0
- package/src/runtime/view_widget_control.zig +433 -0
- package/src/runtime/view_widget_scroll.zig +360 -0
- package/src/runtime/view_widget_text.zig +275 -0
- package/src/runtime/view_widget_tree.zig +843 -0
- package/src/runtime/webview_view_bridge_tests.zig +664 -0
- package/src/runtime/widget_bridge.zig +231 -0
- package/src/runtime/window_command_bridge_tests.zig +403 -0
- package/src/runtime/window_storage.zig +255 -0
- package/src/runtime/window_view_runtime.zig +727 -0
- package/src/runtime/window_views.zig +334 -0
- package/src/security/root.zig +118 -0
- package/src/tooling/android.zig +1172 -0
- package/src/tooling/assets.zig +128 -0
- package/src/tooling/buildgraph.zig +379 -0
- package/src/tooling/cef.zig +671 -0
- package/src/tooling/codesign.zig +172 -0
- package/src/tooling/components/identity_tests.zig +185 -0
- package/src/tooling/components/stepper.zig +113 -0
- package/src/tooling/components/timeline.native +27 -0
- package/src/tooling/components/timeline_item.zig +131 -0
- package/src/tooling/default_icon.icns +0 -0
- package/src/tooling/default_icon.png +0 -0
- package/src/tooling/dev.zig +172 -0
- package/src/tooling/doctor.zig +349 -0
- package/src/tooling/eject_components.zig +170 -0
- package/src/tooling/embedlib.zig +290 -0
- package/src/tooling/ios.zig +528 -0
- package/src/tooling/manifest.zig +1939 -0
- package/src/tooling/package.zig +2388 -0
- package/src/tooling/process_tree.zig +114 -0
- package/src/tooling/raw_manifest.zig +193 -0
- package/src/tooling/root.zig +22 -0
- package/src/tooling/templates.zig +3191 -0
- package/src/tooling/toolchain.zig +371 -0
- package/src/tooling/verbs.zig +204 -0
- package/src/tooling/web_engine.zig +135 -0
- package/src/tooling/xcodeproj.zig +462 -0
- package/src/window_state/root.zig +507 -0
- package/index.js +0 -2
|
@@ -0,0 +1,1650 @@
|
|
|
1
|
+
const support = @import("test_support.zig");
|
|
2
|
+
const std = support.std;
|
|
3
|
+
const geometry = support.geometry;
|
|
4
|
+
const canvas = support.canvas;
|
|
5
|
+
const drawing_model = support.drawing_model;
|
|
6
|
+
const text_model = support.text_model;
|
|
7
|
+
const render_model = support.render_model;
|
|
8
|
+
const event_model = support.event_model;
|
|
9
|
+
const equality_model = support.equality_model;
|
|
10
|
+
const widget_runtime = support.widget_runtime;
|
|
11
|
+
const Error = support.Error;
|
|
12
|
+
const ObjectId = support.ObjectId;
|
|
13
|
+
const ImageId = support.ImageId;
|
|
14
|
+
const FontId = support.FontId;
|
|
15
|
+
const default_sans_font_id = support.default_sans_font_id;
|
|
16
|
+
const default_mono_font_id = support.default_mono_font_id;
|
|
17
|
+
const default_sans_font_family = support.default_sans_font_family;
|
|
18
|
+
const default_mono_font_family = support.default_mono_font_family;
|
|
19
|
+
const default_glyph_atlas_cache_retention_frames = support.default_glyph_atlas_cache_retention_frames;
|
|
20
|
+
const default_text_layout_cache_retention_frames = support.default_text_layout_cache_retention_frames;
|
|
21
|
+
const Color = support.Color;
|
|
22
|
+
const Affine = support.Affine;
|
|
23
|
+
const Radius = support.Radius;
|
|
24
|
+
const GradientStop = support.GradientStop;
|
|
25
|
+
const LinearGradient = support.LinearGradient;
|
|
26
|
+
const Fill = support.Fill;
|
|
27
|
+
const Stroke = support.Stroke;
|
|
28
|
+
const Clip = support.Clip;
|
|
29
|
+
const FillRect = support.FillRect;
|
|
30
|
+
const StrokeRect = support.StrokeRect;
|
|
31
|
+
const FillRoundedRect = support.FillRoundedRect;
|
|
32
|
+
const Line = support.Line;
|
|
33
|
+
const PathVerb = support.PathVerb;
|
|
34
|
+
const PathElement = support.PathElement;
|
|
35
|
+
const FillPath = support.FillPath;
|
|
36
|
+
const StrokePath = support.StrokePath;
|
|
37
|
+
const ImageFit = support.ImageFit;
|
|
38
|
+
const ImageSampling = support.ImageSampling;
|
|
39
|
+
const DrawImage = support.DrawImage;
|
|
40
|
+
const Shadow = support.Shadow;
|
|
41
|
+
const Blur = support.Blur;
|
|
42
|
+
const Glyph = support.Glyph;
|
|
43
|
+
const GlyphAtlasKey = support.GlyphAtlasKey;
|
|
44
|
+
const GlyphAtlasEntry = support.GlyphAtlasEntry;
|
|
45
|
+
const GlyphAtlasPlan = support.GlyphAtlasPlan;
|
|
46
|
+
const GlyphAtlasPlanner = support.GlyphAtlasPlanner;
|
|
47
|
+
const GlyphAtlasCacheEntry = support.GlyphAtlasCacheEntry;
|
|
48
|
+
const GlyphAtlasCacheActionKind = support.GlyphAtlasCacheActionKind;
|
|
49
|
+
const GlyphAtlasCacheAction = support.GlyphAtlasCacheAction;
|
|
50
|
+
const GlyphAtlasCachePlan = support.GlyphAtlasCachePlan;
|
|
51
|
+
const GlyphAtlasCachePlanner = support.GlyphAtlasCachePlanner;
|
|
52
|
+
const DrawText = support.DrawText;
|
|
53
|
+
const TextWrap = support.TextWrap;
|
|
54
|
+
const TextAlign = support.TextAlign;
|
|
55
|
+
const TextLayoutOptions = support.TextLayoutOptions;
|
|
56
|
+
const TextLine = support.TextLine;
|
|
57
|
+
const TextLayout = support.TextLayout;
|
|
58
|
+
const TextLayoutKey = support.TextLayoutKey;
|
|
59
|
+
const TextLayoutPlan = support.TextLayoutPlan;
|
|
60
|
+
const TextLayoutPlanSet = support.TextLayoutPlanSet;
|
|
61
|
+
const TextLayoutPlanner = support.TextLayoutPlanner;
|
|
62
|
+
const TextLayoutCacheEntry = support.TextLayoutCacheEntry;
|
|
63
|
+
const TextLayoutCacheActionKind = support.TextLayoutCacheActionKind;
|
|
64
|
+
const TextLayoutCacheAction = support.TextLayoutCacheAction;
|
|
65
|
+
const TextLayoutCachePlan = support.TextLayoutCachePlan;
|
|
66
|
+
const TextLayoutCachePlanner = support.TextLayoutCachePlanner;
|
|
67
|
+
const TextRange = support.TextRange;
|
|
68
|
+
const TextSelectionRect = support.TextSelectionRect;
|
|
69
|
+
const TextSelection = support.TextSelection;
|
|
70
|
+
const TextCaretDirection = support.TextCaretDirection;
|
|
71
|
+
const TextCaretMove = support.TextCaretMove;
|
|
72
|
+
const TextCompositionUpdate = support.TextCompositionUpdate;
|
|
73
|
+
const TextInputEvent = support.TextInputEvent;
|
|
74
|
+
const TextEditState = support.TextEditState;
|
|
75
|
+
const CanvasCommand = support.CanvasCommand;
|
|
76
|
+
const CommandRef = support.CommandRef;
|
|
77
|
+
const DiffKind = support.DiffKind;
|
|
78
|
+
const DiffChange = support.DiffChange;
|
|
79
|
+
const Builder = support.Builder;
|
|
80
|
+
const max_render_state_stack = support.max_render_state_stack;
|
|
81
|
+
const RenderState = support.RenderState;
|
|
82
|
+
const RenderCommand = support.RenderCommand;
|
|
83
|
+
const CanvasRenderOverride = support.CanvasRenderOverride;
|
|
84
|
+
const CanvasRenderAnimation = support.CanvasRenderAnimation;
|
|
85
|
+
const applyRenderOverrides = support.applyRenderOverrides;
|
|
86
|
+
const renderOverrideDirtyBounds = support.renderOverrideDirtyBounds;
|
|
87
|
+
const RenderPlan = support.RenderPlan;
|
|
88
|
+
const RenderPlanner = support.RenderPlanner;
|
|
89
|
+
const RenderPipelineKind = support.RenderPipelineKind;
|
|
90
|
+
const RenderBatch = support.RenderBatch;
|
|
91
|
+
const RenderBatchPlanner = support.RenderBatchPlanner;
|
|
92
|
+
const RenderBatchPlan = support.RenderBatchPlan;
|
|
93
|
+
const RenderPipelineCacheEntry = support.RenderPipelineCacheEntry;
|
|
94
|
+
const RenderPipelineCacheActionKind = support.RenderPipelineCacheActionKind;
|
|
95
|
+
const RenderPipelineCacheAction = support.RenderPipelineCacheAction;
|
|
96
|
+
const RenderPipelineCachePlanner = support.RenderPipelineCachePlanner;
|
|
97
|
+
const RenderPipelineCachePlan = support.RenderPipelineCachePlan;
|
|
98
|
+
const RenderPathGeometryKind = support.RenderPathGeometryKind;
|
|
99
|
+
const RenderPathGeometry = support.RenderPathGeometry;
|
|
100
|
+
const RenderPathGeometryPlan = support.RenderPathGeometryPlan;
|
|
101
|
+
const RenderPathGeometryPlanner = support.RenderPathGeometryPlanner;
|
|
102
|
+
const RenderPathGeometryKey = support.RenderPathGeometryKey;
|
|
103
|
+
const RenderPathGeometryCacheEntry = support.RenderPathGeometryCacheEntry;
|
|
104
|
+
const RenderPathGeometryCacheActionKind = support.RenderPathGeometryCacheActionKind;
|
|
105
|
+
const RenderPathGeometryCacheAction = support.RenderPathGeometryCacheAction;
|
|
106
|
+
const RenderPathGeometryCachePlan = support.RenderPathGeometryCachePlan;
|
|
107
|
+
const RenderPathGeometryCachePlanner = support.RenderPathGeometryCachePlanner;
|
|
108
|
+
const RenderImage = support.RenderImage;
|
|
109
|
+
const RenderImagePlan = support.RenderImagePlan;
|
|
110
|
+
const RenderImagePlanner = support.RenderImagePlanner;
|
|
111
|
+
const RenderImageKey = support.RenderImageKey;
|
|
112
|
+
const RenderImageCacheEntry = support.RenderImageCacheEntry;
|
|
113
|
+
const RenderImageCacheActionKind = support.RenderImageCacheActionKind;
|
|
114
|
+
const RenderImageCacheAction = support.RenderImageCacheAction;
|
|
115
|
+
const RenderImageCachePlan = support.RenderImageCachePlan;
|
|
116
|
+
const RenderImageCachePlanner = support.RenderImageCachePlanner;
|
|
117
|
+
const RenderResourceKind = support.RenderResourceKind;
|
|
118
|
+
const RenderResource = support.RenderResource;
|
|
119
|
+
const RenderResourcePlan = support.RenderResourcePlan;
|
|
120
|
+
const RenderResourcePlanner = support.RenderResourcePlanner;
|
|
121
|
+
const RenderResourceKey = support.RenderResourceKey;
|
|
122
|
+
const RenderResourceCacheEntry = support.RenderResourceCacheEntry;
|
|
123
|
+
const RenderResourceCacheActionKind = support.RenderResourceCacheActionKind;
|
|
124
|
+
const RenderResourceCacheAction = support.RenderResourceCacheAction;
|
|
125
|
+
const RenderResourceCachePlan = support.RenderResourceCachePlan;
|
|
126
|
+
const RenderResourceCachePlanner = support.RenderResourceCachePlanner;
|
|
127
|
+
const RenderLayer = support.RenderLayer;
|
|
128
|
+
const RenderLayerPlan = support.RenderLayerPlan;
|
|
129
|
+
const RenderLayerPlanner = support.RenderLayerPlanner;
|
|
130
|
+
const RenderLayerKey = support.RenderLayerKey;
|
|
131
|
+
const RenderLayerCacheEntry = support.RenderLayerCacheEntry;
|
|
132
|
+
const RenderLayerCacheActionKind = support.RenderLayerCacheActionKind;
|
|
133
|
+
const RenderLayerCacheAction = support.RenderLayerCacheAction;
|
|
134
|
+
const RenderLayerCachePlan = support.RenderLayerCachePlan;
|
|
135
|
+
const RenderLayerCachePlanner = support.RenderLayerCachePlanner;
|
|
136
|
+
const VisualEffectKind = support.VisualEffectKind;
|
|
137
|
+
const VisualEffect = support.VisualEffect;
|
|
138
|
+
const VisualEffectPlan = support.VisualEffectPlan;
|
|
139
|
+
const VisualEffectPlanner = support.VisualEffectPlanner;
|
|
140
|
+
const VisualEffectKey = support.VisualEffectKey;
|
|
141
|
+
const VisualEffectCacheEntry = support.VisualEffectCacheEntry;
|
|
142
|
+
const VisualEffectCacheActionKind = support.VisualEffectCacheActionKind;
|
|
143
|
+
const VisualEffectCacheAction = support.VisualEffectCacheAction;
|
|
144
|
+
const VisualEffectCachePlan = support.VisualEffectCachePlan;
|
|
145
|
+
const VisualEffectCachePlanner = support.VisualEffectCachePlanner;
|
|
146
|
+
const CanvasFrameOptions = support.CanvasFrameOptions;
|
|
147
|
+
const CanvasFrameStorage = support.CanvasFrameStorage;
|
|
148
|
+
const CanvasFrameBudget = support.CanvasFrameBudget;
|
|
149
|
+
const CanvasFrameBudgetStatus = support.CanvasFrameBudgetStatus;
|
|
150
|
+
const CanvasFrameDiagnostics = support.CanvasFrameDiagnostics;
|
|
151
|
+
const CanvasFrameProfileRisk = support.CanvasFrameProfileRisk;
|
|
152
|
+
const CanvasFrameProfile = support.CanvasFrameProfile;
|
|
153
|
+
const CanvasRenderPass = support.CanvasRenderPass;
|
|
154
|
+
const CanvasFrame = support.CanvasFrame;
|
|
155
|
+
const buildCanvasFrame = support.buildCanvasFrame;
|
|
156
|
+
const CanvasRenderPassLoadAction = support.CanvasRenderPassLoadAction;
|
|
157
|
+
const RenderEncoderBeginPass = support.RenderEncoderBeginPass;
|
|
158
|
+
const RenderEncoderCommand = support.RenderEncoderCommand;
|
|
159
|
+
const RenderEncoderPlan = support.RenderEncoderPlan;
|
|
160
|
+
const RenderEncoderPlanner = support.RenderEncoderPlanner;
|
|
161
|
+
const CanvasGpuCommandKind = support.CanvasGpuCommandKind;
|
|
162
|
+
const CanvasGpuRoundedRect = support.CanvasGpuRoundedRect;
|
|
163
|
+
const CanvasGpuStrokeRect = support.CanvasGpuStrokeRect;
|
|
164
|
+
const CanvasGpuLine = support.CanvasGpuLine;
|
|
165
|
+
const CanvasGpuShape = support.CanvasGpuShape;
|
|
166
|
+
const CanvasGpuPaint = support.CanvasGpuPaint;
|
|
167
|
+
const CanvasGpuImage = support.CanvasGpuImage;
|
|
168
|
+
const CanvasGpuText = support.CanvasGpuText;
|
|
169
|
+
const CanvasGpuShadow = support.CanvasGpuShadow;
|
|
170
|
+
const CanvasGpuBlur = support.CanvasGpuBlur;
|
|
171
|
+
const CanvasGpuEffect = support.CanvasGpuEffect;
|
|
172
|
+
const CanvasGpuCommand = support.CanvasGpuCommand;
|
|
173
|
+
const CanvasGpuPacket = support.CanvasGpuPacket;
|
|
174
|
+
const CanvasGpuPacketSummary = support.CanvasGpuPacketSummary;
|
|
175
|
+
const CanvasGpuPacketPlanner = support.CanvasGpuPacketPlanner;
|
|
176
|
+
const ReferenceImage = support.ReferenceImage;
|
|
177
|
+
const ReferenceRenderSurface = support.ReferenceRenderSurface;
|
|
178
|
+
const Density = support.Density;
|
|
179
|
+
const Easing = support.Easing;
|
|
180
|
+
const ColorScheme = support.ColorScheme;
|
|
181
|
+
const ColorContrast = support.ColorContrast;
|
|
182
|
+
const ThemeOptions = support.ThemeOptions;
|
|
183
|
+
const ColorTokens = support.ColorTokens;
|
|
184
|
+
const FontFamily = support.FontFamily;
|
|
185
|
+
const TypographyTokens = support.TypographyTokens;
|
|
186
|
+
const SpacingTokens = support.SpacingTokens;
|
|
187
|
+
const RadiusTokens = support.RadiusTokens;
|
|
188
|
+
const StrokeTokens = support.StrokeTokens;
|
|
189
|
+
const ShadowToken = support.ShadowToken;
|
|
190
|
+
const ShadowTokens = support.ShadowTokens;
|
|
191
|
+
const BlurTokens = support.BlurTokens;
|
|
192
|
+
const MotionDuration = support.MotionDuration;
|
|
193
|
+
const MotionAnimationOptions = support.MotionAnimationOptions;
|
|
194
|
+
const MotionTokens = support.MotionTokens;
|
|
195
|
+
const SpringToken = support.SpringToken;
|
|
196
|
+
const BlurTokenRef = support.BlurTokenRef;
|
|
197
|
+
const ScrollPhysics = support.ScrollPhysics;
|
|
198
|
+
const ScrollState = support.ScrollState;
|
|
199
|
+
const VirtualListOptions = support.VirtualListOptions;
|
|
200
|
+
const VirtualListRange = support.VirtualListRange;
|
|
201
|
+
const virtualListRange = support.virtualListRange;
|
|
202
|
+
const LayerTokens = support.LayerTokens;
|
|
203
|
+
const PixelSnapTokens = support.PixelSnapTokens;
|
|
204
|
+
const ControlVisualTokens = support.ControlVisualTokens;
|
|
205
|
+
const ControlTokens = support.ControlTokens;
|
|
206
|
+
const ColorTokenOverrides = support.ColorTokenOverrides;
|
|
207
|
+
const TypographyTokenOverrides = support.TypographyTokenOverrides;
|
|
208
|
+
const SpacingTokenOverrides = support.SpacingTokenOverrides;
|
|
209
|
+
const RadiusTokenOverrides = support.RadiusTokenOverrides;
|
|
210
|
+
const StrokeTokenOverrides = support.StrokeTokenOverrides;
|
|
211
|
+
const ShadowTokenOverrides = support.ShadowTokenOverrides;
|
|
212
|
+
const ShadowTokensOverrides = support.ShadowTokensOverrides;
|
|
213
|
+
const BlurTokenOverrides = support.BlurTokenOverrides;
|
|
214
|
+
const SpringTokenOverrides = support.SpringTokenOverrides;
|
|
215
|
+
const MotionTokenOverrides = support.MotionTokenOverrides;
|
|
216
|
+
const ScrollPhysicsOverrides = support.ScrollPhysicsOverrides;
|
|
217
|
+
const LayerTokenOverrides = support.LayerTokenOverrides;
|
|
218
|
+
const PixelSnapTokenOverrides = support.PixelSnapTokenOverrides;
|
|
219
|
+
const ControlVisualTokenOverrides = support.ControlVisualTokenOverrides;
|
|
220
|
+
const ControlTokenOverrides = support.ControlTokenOverrides;
|
|
221
|
+
const DesignTokenOverrides = support.DesignTokenOverrides;
|
|
222
|
+
const DesignTokens = support.DesignTokens;
|
|
223
|
+
const WidgetKind = support.WidgetKind;
|
|
224
|
+
const WidgetCursor = support.WidgetCursor;
|
|
225
|
+
const WidgetState = support.WidgetState;
|
|
226
|
+
const WidgetRenderState = support.WidgetRenderState;
|
|
227
|
+
const WidgetMainAlignment = support.WidgetMainAlignment;
|
|
228
|
+
const WidgetCrossAlignment = support.WidgetCrossAlignment;
|
|
229
|
+
const WidgetLayoutStyle = support.WidgetLayoutStyle;
|
|
230
|
+
const WidgetStyle = support.WidgetStyle;
|
|
231
|
+
const WidgetVariant = support.WidgetVariant;
|
|
232
|
+
const WidgetSize = support.WidgetSize;
|
|
233
|
+
const WidgetRole = support.WidgetRole;
|
|
234
|
+
const BuiltinComponentStyle = support.BuiltinComponentStyle;
|
|
235
|
+
const BuiltinComponentKind = support.BuiltinComponentKind;
|
|
236
|
+
const builtin_component_kinds = support.builtin_component_kinds;
|
|
237
|
+
const builtin_component_names = support.builtin_component_names;
|
|
238
|
+
const BuiltinComponentDescriptor = support.BuiltinComponentDescriptor;
|
|
239
|
+
const builtinComponentCount = support.builtinComponentCount;
|
|
240
|
+
const builtinComponentName = support.builtinComponentName;
|
|
241
|
+
const builtinComponentDescriptor = support.builtinComponentDescriptor;
|
|
242
|
+
const WidgetActions = support.WidgetActions;
|
|
243
|
+
const WidgetSemantics = support.WidgetSemantics;
|
|
244
|
+
const Widget = support.Widget;
|
|
245
|
+
const BuiltinComponentOptions = support.BuiltinComponentOptions;
|
|
246
|
+
const WidgetCommandPart = support.WidgetCommandPart;
|
|
247
|
+
const BuiltinSurfacePlacementOptions = support.BuiltinSurfacePlacementOptions;
|
|
248
|
+
const BuiltinSurfaceBackdropOptions = support.BuiltinSurfaceBackdropOptions;
|
|
249
|
+
const BuiltinStatusBarOptions = support.BuiltinStatusBarOptions;
|
|
250
|
+
const BuiltinSurfaceEnterAnimationOptions = support.BuiltinSurfaceEnterAnimationOptions;
|
|
251
|
+
const builtinComponentWidget = support.builtinComponentWidget;
|
|
252
|
+
const widgetCommandPartId = support.widgetCommandPartId;
|
|
253
|
+
const builtinSurfaceBackdropWidget = support.builtinSurfaceBackdropWidget;
|
|
254
|
+
const builtinStatusBarWidget = support.builtinStatusBarWidget;
|
|
255
|
+
const builtinSurfaceFrame = support.builtinSurfaceFrame;
|
|
256
|
+
const appendBuiltinSurfaceEnterAnimations = support.appendBuiltinSurfaceEnterAnimations;
|
|
257
|
+
const builtinSurfaceEnterOffset = support.builtinSurfaceEnterOffset;
|
|
258
|
+
const max_widget_depth = support.max_widget_depth;
|
|
259
|
+
const max_widget_text_range_rects = support.max_widget_text_range_rects;
|
|
260
|
+
const WidgetLayoutNode = support.WidgetLayoutNode;
|
|
261
|
+
const WidgetHit = support.WidgetHit;
|
|
262
|
+
const WidgetPointerPhase = support.WidgetPointerPhase;
|
|
263
|
+
const WidgetPointerEvent = support.WidgetPointerEvent;
|
|
264
|
+
const WidgetKeyboardPhase = support.WidgetKeyboardPhase;
|
|
265
|
+
const WidgetKeyboardModifiers = support.WidgetKeyboardModifiers;
|
|
266
|
+
const WidgetKeyboardEvent = support.WidgetKeyboardEvent;
|
|
267
|
+
const WidgetControlIntentKind = support.WidgetControlIntentKind;
|
|
268
|
+
const WidgetControlIntent = support.WidgetControlIntent;
|
|
269
|
+
const WidgetSemanticAction = support.WidgetSemanticAction;
|
|
270
|
+
const WidgetFileDropEvent = support.WidgetFileDropEvent;
|
|
271
|
+
const WidgetDragEvent = support.WidgetDragEvent;
|
|
272
|
+
const WidgetEventPhase = support.WidgetEventPhase;
|
|
273
|
+
const WidgetEventRouteEntry = support.WidgetEventRouteEntry;
|
|
274
|
+
const WidgetEventRoute = support.WidgetEventRoute;
|
|
275
|
+
const WidgetKeyboardRoute = support.WidgetKeyboardRoute;
|
|
276
|
+
const WidgetFocusDirection = support.WidgetFocusDirection;
|
|
277
|
+
const WidgetFocusTarget = support.WidgetFocusTarget;
|
|
278
|
+
const WidgetScrollMetrics = support.WidgetScrollMetrics;
|
|
279
|
+
const WidgetListMetrics = support.WidgetListMetrics;
|
|
280
|
+
const WidgetSemanticsNode = support.WidgetSemanticsNode;
|
|
281
|
+
const WidgetInvalidationKind = support.WidgetInvalidationKind;
|
|
282
|
+
const WidgetInvalidation = support.WidgetInvalidation;
|
|
283
|
+
const widgetKeyboardControlIntent = support.widgetKeyboardControlIntent;
|
|
284
|
+
const widgetSemanticControlIntent = support.widgetSemanticControlIntent;
|
|
285
|
+
const widgetSemanticControlIntentWithActions = support.widgetSemanticControlIntentWithActions;
|
|
286
|
+
const isWidgetActivationKey = support.isWidgetActivationKey;
|
|
287
|
+
const widgetSliderKeyboardValue = support.widgetSliderKeyboardValue;
|
|
288
|
+
const widgetScrollKeyboardIntent = support.widgetScrollKeyboardIntent;
|
|
289
|
+
const widgetScrollKeyboardDelta = support.widgetScrollKeyboardDelta;
|
|
290
|
+
const WidgetLayoutTree = support.WidgetLayoutTree;
|
|
291
|
+
const DisplayList = support.DisplayList;
|
|
292
|
+
const emitWidgetTree = support.emitWidgetTree;
|
|
293
|
+
const layoutWidgetTree = support.layoutWidgetTree;
|
|
294
|
+
const layoutWidgetTreeWithTokens = support.layoutWidgetTreeWithTokens;
|
|
295
|
+
const layoutTextRun = support.layoutTextRun;
|
|
296
|
+
const layoutTextRunPlan = support.layoutTextRunPlan;
|
|
297
|
+
const layoutTextCaretRect = support.layoutTextCaretRect;
|
|
298
|
+
const textCaretRectForLayout = support.textCaretRectForLayout;
|
|
299
|
+
const layoutTextSelectionRects = support.layoutTextSelectionRects;
|
|
300
|
+
const textSelectionRectsForLayout = support.textSelectionRectsForLayout;
|
|
301
|
+
const layoutTextOffsetForPoint = support.layoutTextOffsetForPoint;
|
|
302
|
+
const textOffsetForLayoutPoint = support.textOffsetForLayoutPoint;
|
|
303
|
+
const applyTextInputEvent = support.applyTextInputEvent;
|
|
304
|
+
const sampleCanvasRenderAnimations = support.sampleCanvasRenderAnimations;
|
|
305
|
+
const emitWidgetLayout = support.emitWidgetLayout;
|
|
306
|
+
const toggleWidgetKnobCommandId = support.toggleWidgetKnobCommandId;
|
|
307
|
+
const toggleWidgetKnobTravel = support.toggleWidgetKnobTravel;
|
|
308
|
+
const textSelectionForWidgetPoint = support.textSelectionForWidgetPoint;
|
|
309
|
+
const textOffsetForWidgetPoint = support.textOffsetForWidgetPoint;
|
|
310
|
+
const textInputViewportForWidget = support.textInputViewportForWidget;
|
|
311
|
+
const textInputContentExtentForWidget = support.textInputContentExtentForWidget;
|
|
312
|
+
const textInputMaxScrollOffsetForWidget = support.textInputMaxScrollOffsetForWidget;
|
|
313
|
+
const clampedTextInputScrollOffsetForWidget = support.clampedTextInputScrollOffsetForWidget;
|
|
314
|
+
const intrinsicWidgetSize = support.intrinsicWidgetSize;
|
|
315
|
+
const cursorForWidgetHit = support.cursorForWidgetHit;
|
|
316
|
+
const cursorForWidgetTarget = support.cursorForWidgetTarget;
|
|
317
|
+
const WidgetTextGeometry = support.WidgetTextGeometry;
|
|
318
|
+
const textGeometryForWidget = support.textGeometryForWidget;
|
|
319
|
+
const virtualWidgetScrollContentExtent = support.virtualWidgetScrollContentExtent;
|
|
320
|
+
const virtualWidgetScrollContentExtentWithTokens = support.virtualWidgetScrollContentExtentWithTokens;
|
|
321
|
+
const writeCanvasGpuPacketJson = support.writeCanvasGpuPacketJson;
|
|
322
|
+
const strokeBounds = support.strokeBounds;
|
|
323
|
+
const shadowBounds = support.shadowBounds;
|
|
324
|
+
const semanticActions = support.semanticActions;
|
|
325
|
+
const defaultSemanticActions = support.defaultSemanticActions;
|
|
326
|
+
const defaultFocusable = support.defaultFocusable;
|
|
327
|
+
const textLineBounds = support.textLineBounds;
|
|
328
|
+
const textBounds = support.textBounds;
|
|
329
|
+
const estimateTextWidth = support.estimateTextWidth;
|
|
330
|
+
const estimateTextWidthForFont = support.estimateTextWidthForFont;
|
|
331
|
+
const estimateTextAdvanceForBytes = support.estimateTextAdvanceForBytes;
|
|
332
|
+
const estimatedGlyphAdvance = support.estimatedGlyphAdvance;
|
|
333
|
+
const snapTextSelection = support.snapTextSelection;
|
|
334
|
+
const snapTextRange = support.snapTextRange;
|
|
335
|
+
const nextTextOffset = support.nextTextOffset;
|
|
336
|
+
const nextTextLineEnd = support.nextTextLineEnd;
|
|
337
|
+
const isTextBreakByte = support.isTextBreakByte;
|
|
338
|
+
const textLineRange = support.textLineRange;
|
|
339
|
+
const textLineCaretX = support.textLineCaretX;
|
|
340
|
+
const motionProgress = support.motionProgress;
|
|
341
|
+
const renderImageFingerprint = support.renderImageFingerprint;
|
|
342
|
+
const renderImageFingerprintForResource = support.renderImageFingerprintForResource;
|
|
343
|
+
const commandsEqual = support.commandsEqual;
|
|
344
|
+
const rectsEqual = support.rectsEqual;
|
|
345
|
+
const optionalRectsEqual = support.optionalRectsEqual;
|
|
346
|
+
const sizesEqual = support.sizesEqual;
|
|
347
|
+
const insetsEqual = support.insetsEqual;
|
|
348
|
+
const optionalColorsEqual = support.optionalColorsEqual;
|
|
349
|
+
const radiiEqual = support.radiiEqual;
|
|
350
|
+
const affinesEqual = support.affinesEqual;
|
|
351
|
+
const optionalF32Equal = support.optionalF32Equal;
|
|
352
|
+
const optionalTextSelectionsEqual = support.optionalTextSelectionsEqual;
|
|
353
|
+
const optionalTextRangesEqual = support.optionalTextRangesEqual;
|
|
354
|
+
const widgetPartId = support.widgetPartId;
|
|
355
|
+
const colorWithAlpha = support.colorWithAlpha;
|
|
356
|
+
const widgetControlHeight = support.widgetControlHeight;
|
|
357
|
+
const textSelectionFillColor = support.textSelectionFillColor;
|
|
358
|
+
const transparentColor = support.transparentColor;
|
|
359
|
+
const expectRect = support.expectRect;
|
|
360
|
+
const expectRectApprox = support.expectRectApprox;
|
|
361
|
+
const expectPixelRgba8 = support.expectPixelRgba8;
|
|
362
|
+
const expectVisiblePixel = support.expectVisiblePixel;
|
|
363
|
+
const referenceSurfaceSignature = support.referenceSurfaceSignature;
|
|
364
|
+
const expectLayoutFrame = support.expectLayoutFrame;
|
|
365
|
+
const expectRouteEntry = support.expectRouteEntry;
|
|
366
|
+
const expectFillColor = support.expectFillColor;
|
|
367
|
+
const expectGpuPaintColor = support.expectGpuPaintColor;
|
|
368
|
+
|
|
369
|
+
test "reference renderer clears and fills solid rect render pass" {
|
|
370
|
+
const commands = [_]CanvasCommand{.{ .fill_rect = .{
|
|
371
|
+
.id = 1,
|
|
372
|
+
.rect = geometry.RectF.init(1, 1, 2, 2),
|
|
373
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
374
|
+
} }};
|
|
375
|
+
|
|
376
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
377
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
378
|
+
var resources: [0]RenderResource = .{};
|
|
379
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
380
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
381
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
382
|
+
var changes: [0]DiffChange = .{};
|
|
383
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
384
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
385
|
+
}, .{
|
|
386
|
+
.render_commands = &render_commands,
|
|
387
|
+
.render_batches = &render_batches,
|
|
388
|
+
.resources = &resources,
|
|
389
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
390
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
391
|
+
.glyph_atlas_entries = &glyphs,
|
|
392
|
+
.changes = &changes,
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
396
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
397
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
398
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 0, 0);
|
|
399
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
400
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 2, 2);
|
|
401
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 3);
|
|
402
|
+
|
|
403
|
+
try surface.renderPass(.{}, Color.rgb8(255, 255, 255));
|
|
404
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
test "reference renderer applies render pass scale" {
|
|
408
|
+
const commands = [_]CanvasCommand{.{ .fill_rect = .{
|
|
409
|
+
.id = 1,
|
|
410
|
+
.rect = geometry.RectF.init(1, 1, 1, 1),
|
|
411
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
412
|
+
} }};
|
|
413
|
+
|
|
414
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
415
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
416
|
+
var resources: [0]RenderResource = .{};
|
|
417
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
418
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
419
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
420
|
+
var changes: [0]DiffChange = .{};
|
|
421
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
422
|
+
.surface_size = geometry.SizeF.init(2, 2),
|
|
423
|
+
.scale = 2,
|
|
424
|
+
}, .{
|
|
425
|
+
.render_commands = &render_commands,
|
|
426
|
+
.render_batches = &render_batches,
|
|
427
|
+
.resources = &resources,
|
|
428
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
429
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
430
|
+
.glyph_atlas_entries = &glyphs,
|
|
431
|
+
.changes = &changes,
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
435
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
436
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
437
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 1);
|
|
438
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 2, 2);
|
|
439
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 3, 3);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
test "reference renderer applies render pass scissor on load" {
|
|
443
|
+
const commands = [_]RenderCommand{.{
|
|
444
|
+
.command = .{ .fill_rect = .{
|
|
445
|
+
.id = 1,
|
|
446
|
+
.rect = geometry.RectF.init(0, 0, 4, 4),
|
|
447
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
448
|
+
} },
|
|
449
|
+
.local_bounds = geometry.RectF.init(0, 0, 4, 4),
|
|
450
|
+
.bounds = geometry.RectF.init(0, 0, 4, 4),
|
|
451
|
+
}};
|
|
452
|
+
|
|
453
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
454
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
455
|
+
surface.clear(Color.rgb8(0, 0, 255));
|
|
456
|
+
try surface.renderPass(.{
|
|
457
|
+
.dirty_bounds = geometry.RectF.init(1, 1, 2, 2),
|
|
458
|
+
.commands = &commands,
|
|
459
|
+
}, Color.rgb8(0, 0, 0));
|
|
460
|
+
|
|
461
|
+
try expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 0, 0);
|
|
462
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
463
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 2, 2);
|
|
464
|
+
try expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 3, 3);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
test "reference renderer clears dirty rect on retained load" {
|
|
468
|
+
const commands = [_]RenderCommand{.{
|
|
469
|
+
.command = .{ .fill_rect = .{
|
|
470
|
+
.id = 1,
|
|
471
|
+
.rect = geometry.RectF.init(1, 1, 1, 1),
|
|
472
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
473
|
+
} },
|
|
474
|
+
.local_bounds = geometry.RectF.init(1, 1, 1, 1),
|
|
475
|
+
.bounds = geometry.RectF.init(1, 1, 1, 1),
|
|
476
|
+
}};
|
|
477
|
+
|
|
478
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
479
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
480
|
+
surface.clear(Color.rgb8(0, 0, 255));
|
|
481
|
+
try surface.renderPass(.{
|
|
482
|
+
.dirty_bounds = geometry.RectF.init(1, 1, 2, 2),
|
|
483
|
+
.commands = &commands,
|
|
484
|
+
}, Color.rgb8(0, 0, 0));
|
|
485
|
+
|
|
486
|
+
try expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 0, 0);
|
|
487
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
488
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 2, 2);
|
|
489
|
+
try expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 3, 3);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
test "reference renderer captures Phase 2 primitive signature" {
|
|
493
|
+
const stops = [_]GradientStop{
|
|
494
|
+
.{ .offset = 0, .color = Color.rgb8(248, 250, 252) },
|
|
495
|
+
.{ .offset = 1, .color = Color.rgb8(48, 111, 237) },
|
|
496
|
+
};
|
|
497
|
+
const glyphs = [_]Glyph{
|
|
498
|
+
.{ .id = 1, .x = 0, .y = 0, .advance = 4 },
|
|
499
|
+
.{ .id = 2, .x = 5, .y = 0, .advance = 4 },
|
|
500
|
+
};
|
|
501
|
+
const image_pixels = [_]u8{
|
|
502
|
+
16, 185, 129, 255,
|
|
503
|
+
255, 255, 255, 255,
|
|
504
|
+
15, 23, 42, 255,
|
|
505
|
+
48, 111, 237, 255,
|
|
506
|
+
};
|
|
507
|
+
const images = [_]ReferenceImage{.{
|
|
508
|
+
.id = 7,
|
|
509
|
+
.width = 2,
|
|
510
|
+
.height = 2,
|
|
511
|
+
.pixels = &image_pixels,
|
|
512
|
+
}};
|
|
513
|
+
const commands = [_]CanvasCommand{
|
|
514
|
+
.{ .fill_rect = .{
|
|
515
|
+
.id = 1,
|
|
516
|
+
.rect = geometry.RectF.init(0, 0, 32, 24),
|
|
517
|
+
.fill = .{ .linear_gradient = .{ .start = geometry.PointF.init(0, 0), .end = geometry.PointF.init(32, 24), .stops = &stops } },
|
|
518
|
+
} },
|
|
519
|
+
.{ .shadow = .{
|
|
520
|
+
.id = 2,
|
|
521
|
+
.rect = geometry.RectF.init(4, 4, 18, 10),
|
|
522
|
+
.radius = Radius.all(3),
|
|
523
|
+
.offset = .{ .dx = 0, .dy = 2 },
|
|
524
|
+
.blur = 2,
|
|
525
|
+
.spread = 0,
|
|
526
|
+
.color = Color.rgba8(15, 23, 42, 64),
|
|
527
|
+
} },
|
|
528
|
+
.{ .push_clip = .{ .id = 3, .rect = geometry.RectF.init(2, 2, 28, 20), .radius = Radius.all(2) } },
|
|
529
|
+
.{ .push_opacity = 0.84 },
|
|
530
|
+
.{ .transform = Affine.translate(1, 1) },
|
|
531
|
+
.{ .fill_rounded_rect = .{
|
|
532
|
+
.id = 4,
|
|
533
|
+
.rect = geometry.RectF.init(4, 4, 18, 10),
|
|
534
|
+
.radius = Radius.all(3),
|
|
535
|
+
.fill = .{ .color = Color.rgb8(255, 255, 255) },
|
|
536
|
+
} },
|
|
537
|
+
.{ .stroke_rect = .{
|
|
538
|
+
.id = 5,
|
|
539
|
+
.rect = geometry.RectF.init(4, 4, 18, 10),
|
|
540
|
+
.radius = Radius.all(3),
|
|
541
|
+
.stroke = .{ .fill = .{ .color = Color.rgb8(15, 23, 42) }, .width = 1 },
|
|
542
|
+
} },
|
|
543
|
+
.{ .draw_image = .{
|
|
544
|
+
.id = 6,
|
|
545
|
+
.image_id = 7,
|
|
546
|
+
.dst = geometry.RectF.init(18, 5, 8, 8),
|
|
547
|
+
.fit = .cover,
|
|
548
|
+
.sampling = .nearest,
|
|
549
|
+
} },
|
|
550
|
+
.{ .draw_text = .{
|
|
551
|
+
.id = 7,
|
|
552
|
+
.font_id = 1,
|
|
553
|
+
.size = 4,
|
|
554
|
+
.origin = geometry.PointF.init(6, 18),
|
|
555
|
+
.color = Color.rgb8(15, 23, 42),
|
|
556
|
+
.text = "UI",
|
|
557
|
+
.glyphs = &glyphs,
|
|
558
|
+
} },
|
|
559
|
+
.pop_opacity,
|
|
560
|
+
.pop_clip,
|
|
561
|
+
.{ .blur = .{
|
|
562
|
+
.id = 8,
|
|
563
|
+
.rect = geometry.RectF.init(24, 2, 6, 6),
|
|
564
|
+
.radius = 1,
|
|
565
|
+
} },
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
var render_commands: [commands.len]RenderCommand = undefined;
|
|
569
|
+
var render_batches: [commands.len]RenderBatch = undefined;
|
|
570
|
+
var pipeline_cache_entries: [8]RenderPipelineCacheEntry = undefined;
|
|
571
|
+
var pipeline_cache_actions: [16]RenderPipelineCacheAction = undefined;
|
|
572
|
+
var layers: [commands.len]RenderLayer = undefined;
|
|
573
|
+
var layer_cache_entries: [commands.len]RenderLayerCacheEntry = undefined;
|
|
574
|
+
var layer_cache_actions: [commands.len * 2]RenderLayerCacheAction = undefined;
|
|
575
|
+
var resources: [8]RenderResource = undefined;
|
|
576
|
+
var resource_cache_entries: [8]RenderResourceCacheEntry = undefined;
|
|
577
|
+
var resource_cache_actions: [16]RenderResourceCacheAction = undefined;
|
|
578
|
+
var visual_effects: [4]VisualEffect = undefined;
|
|
579
|
+
var visual_effect_cache_entries: [4]VisualEffectCacheEntry = undefined;
|
|
580
|
+
var visual_effect_cache_actions: [8]VisualEffectCacheAction = undefined;
|
|
581
|
+
var glyph_atlas_entries: [8]GlyphAtlasEntry = undefined;
|
|
582
|
+
var glyph_cache_entries: [8]GlyphAtlasCacheEntry = undefined;
|
|
583
|
+
var glyph_cache_actions: [16]GlyphAtlasCacheAction = undefined;
|
|
584
|
+
var text_layout_plans: [4]TextLayoutPlan = undefined;
|
|
585
|
+
var text_layout_lines: [8]TextLine = undefined;
|
|
586
|
+
var text_layout_cache_entries: [4]TextLayoutCacheEntry = undefined;
|
|
587
|
+
var text_layout_cache_actions: [8]TextLayoutCacheAction = undefined;
|
|
588
|
+
var changes: [commands.len]DiffChange = undefined;
|
|
589
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
590
|
+
.surface_size = geometry.SizeF.init(32, 24),
|
|
591
|
+
.full_repaint = true,
|
|
592
|
+
}, .{
|
|
593
|
+
.render_commands = &render_commands,
|
|
594
|
+
.render_batches = &render_batches,
|
|
595
|
+
.pipeline_cache_entries = &pipeline_cache_entries,
|
|
596
|
+
.pipeline_cache_actions = &pipeline_cache_actions,
|
|
597
|
+
.layers = &layers,
|
|
598
|
+
.layer_cache_entries = &layer_cache_entries,
|
|
599
|
+
.layer_cache_actions = &layer_cache_actions,
|
|
600
|
+
.resources = &resources,
|
|
601
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
602
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
603
|
+
.visual_effects = &visual_effects,
|
|
604
|
+
.visual_effect_cache_entries = &visual_effect_cache_entries,
|
|
605
|
+
.visual_effect_cache_actions = &visual_effect_cache_actions,
|
|
606
|
+
.glyph_atlas_entries = &glyph_atlas_entries,
|
|
607
|
+
.glyph_atlas_cache_entries = &glyph_cache_entries,
|
|
608
|
+
.glyph_atlas_cache_actions = &glyph_cache_actions,
|
|
609
|
+
.text_layout_plans = &text_layout_plans,
|
|
610
|
+
.text_layout_lines = &text_layout_lines,
|
|
611
|
+
.text_layout_cache_entries = &text_layout_cache_entries,
|
|
612
|
+
.text_layout_cache_actions = &text_layout_cache_actions,
|
|
613
|
+
.changes = &changes,
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
try std.testing.expect(frame.requiresRender());
|
|
617
|
+
try std.testing.expect(frame.batch_plan.batchCount() >= 5);
|
|
618
|
+
try std.testing.expectEqual(@as(usize, 1), frame.layer_plan.opacityLayerCount());
|
|
619
|
+
try std.testing.expectEqual(@as(usize, 1), frame.layer_plan.clipLayerCount());
|
|
620
|
+
try std.testing.expectEqual(@as(usize, 2), frame.layer_plan.transformLayerCount());
|
|
621
|
+
try std.testing.expect(frame.resource_plan.resourceCount() >= 3);
|
|
622
|
+
try std.testing.expect(frame.visual_effect_plan.shadowCount() >= 1);
|
|
623
|
+
try std.testing.expect(frame.visual_effect_plan.blurCount() >= 1);
|
|
624
|
+
try std.testing.expectEqual(@as(usize, 2), frame.glyph_atlas_plan.entryCount());
|
|
625
|
+
|
|
626
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
627
|
+
var scratch: [32 * 24 * 4]u8 = undefined;
|
|
628
|
+
const surface = (try ReferenceRenderSurface.initWithScratch(32, 24, &pixels, &scratch)).withImages(&images);
|
|
629
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
630
|
+
|
|
631
|
+
try std.testing.expectEqual(@as(u64, 12197497484215834747), referenceSurfaceSignature(&pixels));
|
|
632
|
+
try expectVisiblePixel(surface.pixelRgba8(6, 6));
|
|
633
|
+
try expectVisiblePixel(surface.pixelRgba8(20, 8));
|
|
634
|
+
try expectVisiblePixel(surface.pixelRgba8(6, 16));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
test "reference renderer applies clip transform and opacity" {
|
|
638
|
+
const commands = [_]CanvasCommand{
|
|
639
|
+
.{ .push_clip = .{ .rect = geometry.RectF.init(1, 1, 2, 2) } },
|
|
640
|
+
.{ .push_opacity = 0.5 },
|
|
641
|
+
.{ .transform = Affine.translate(1, 0) },
|
|
642
|
+
.{ .fill_rect = .{
|
|
643
|
+
.id = 1,
|
|
644
|
+
.rect = geometry.RectF.init(0, 0, 3, 3),
|
|
645
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
646
|
+
} },
|
|
647
|
+
.pop_opacity,
|
|
648
|
+
.pop_clip,
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
652
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
653
|
+
var resources: [0]RenderResource = .{};
|
|
654
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
655
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
656
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
657
|
+
var changes: [0]DiffChange = .{};
|
|
658
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
659
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
660
|
+
}, .{
|
|
661
|
+
.render_commands = &render_commands,
|
|
662
|
+
.render_batches = &render_batches,
|
|
663
|
+
.resources = &resources,
|
|
664
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
665
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
666
|
+
.glyph_atlas_entries = &glyphs,
|
|
667
|
+
.changes = &changes,
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
671
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
672
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
673
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 0);
|
|
674
|
+
try expectPixelRgba8(.{ 128, 0, 0, 255 }, surface, 1, 1);
|
|
675
|
+
try expectPixelRgba8(.{ 128, 0, 0, 255 }, surface, 2, 2);
|
|
676
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 3);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
test "reference renderer samples transformed clipped linear gradients" {
|
|
680
|
+
const stops = [_]GradientStop{
|
|
681
|
+
.{ .offset = 0, .color = Color.rgb8(255, 0, 0) },
|
|
682
|
+
.{ .offset = 1, .color = Color.rgb8(0, 0, 255) },
|
|
683
|
+
};
|
|
684
|
+
const commands = [_]CanvasCommand{
|
|
685
|
+
.{ .push_clip = .{ .rect = geometry.RectF.init(2, 0, 1, 1) } },
|
|
686
|
+
.{ .transform = Affine.translate(1, 0) },
|
|
687
|
+
.{ .fill_rect = .{
|
|
688
|
+
.id = 1,
|
|
689
|
+
.rect = geometry.RectF.init(0, 0, 2, 1),
|
|
690
|
+
.fill = .{ .linear_gradient = .{
|
|
691
|
+
.start = geometry.PointF.init(0, 0),
|
|
692
|
+
.end = geometry.PointF.init(2, 0),
|
|
693
|
+
.stops = &stops,
|
|
694
|
+
} },
|
|
695
|
+
} },
|
|
696
|
+
.pop_clip,
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
700
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
701
|
+
var resources: [1]RenderResource = undefined;
|
|
702
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
703
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
704
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
705
|
+
var changes: [0]DiffChange = .{};
|
|
706
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
707
|
+
.surface_size = geometry.SizeF.init(4, 1),
|
|
708
|
+
}, .{
|
|
709
|
+
.render_commands = &render_commands,
|
|
710
|
+
.render_batches = &render_batches,
|
|
711
|
+
.resources = &resources,
|
|
712
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
713
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
714
|
+
.glyph_atlas_entries = &glyphs,
|
|
715
|
+
.changes = &changes,
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
var pixels: [4 * 1 * 4]u8 = undefined;
|
|
719
|
+
const surface = try ReferenceRenderSurface.init(4, 1, &pixels);
|
|
720
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
721
|
+
|
|
722
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 0, 0);
|
|
723
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 0);
|
|
724
|
+
try expectPixelRgba8(.{ 137, 0, 225, 255 }, surface, 2, 0);
|
|
725
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 0);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
test "reference renderer draws stroked lines" {
|
|
729
|
+
const commands = [_]CanvasCommand{.{ .draw_line = .{
|
|
730
|
+
.id = 1,
|
|
731
|
+
.from = geometry.PointF.init(0.5, 1.5),
|
|
732
|
+
.to = geometry.PointF.init(2.5, 1.5),
|
|
733
|
+
.stroke = .{ .fill = .{ .color = Color.rgb8(255, 0, 0) }, .width = 1 },
|
|
734
|
+
} }};
|
|
735
|
+
|
|
736
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
737
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
738
|
+
var resources: [0]RenderResource = .{};
|
|
739
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
740
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
741
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
742
|
+
var changes: [0]DiffChange = .{};
|
|
743
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
744
|
+
.surface_size = geometry.SizeF.init(4, 3),
|
|
745
|
+
}, .{
|
|
746
|
+
.render_commands = &render_commands,
|
|
747
|
+
.render_batches = &render_batches,
|
|
748
|
+
.resources = &resources,
|
|
749
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
750
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
751
|
+
.glyph_atlas_entries = &glyphs,
|
|
752
|
+
.changes = &changes,
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
var pixels: [4 * 3 * 4]u8 = undefined;
|
|
756
|
+
const surface = try ReferenceRenderSurface.init(4, 3, &pixels);
|
|
757
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
758
|
+
|
|
759
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 0);
|
|
760
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 0, 1);
|
|
761
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
762
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 2, 1);
|
|
763
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 1);
|
|
764
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 2);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
test "reference renderer fills closed paths" {
|
|
768
|
+
const elements = [_]PathElement{
|
|
769
|
+
.{ .verb = .move_to, .points = .{ geometry.PointF.init(1, 1), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
770
|
+
.{ .verb = .line_to, .points = .{ geometry.PointF.init(3, 1), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
771
|
+
.{ .verb = .line_to, .points = .{ geometry.PointF.init(3, 3), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
772
|
+
.{ .verb = .line_to, .points = .{ geometry.PointF.init(1, 3), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
773
|
+
.{ .verb = .close },
|
|
774
|
+
};
|
|
775
|
+
const commands = [_]CanvasCommand{.{ .fill_path = .{
|
|
776
|
+
.id = 1,
|
|
777
|
+
.elements = &elements,
|
|
778
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
779
|
+
} }};
|
|
780
|
+
|
|
781
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
782
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
783
|
+
var resources: [0]RenderResource = .{};
|
|
784
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
785
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
786
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
787
|
+
var changes: [0]DiffChange = .{};
|
|
788
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
789
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
790
|
+
}, .{
|
|
791
|
+
.render_commands = &render_commands,
|
|
792
|
+
.render_batches = &render_batches,
|
|
793
|
+
.resources = &resources,
|
|
794
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
795
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
796
|
+
.glyph_atlas_entries = &glyphs,
|
|
797
|
+
.changes = &changes,
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
801
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
802
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
803
|
+
|
|
804
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 0, 0);
|
|
805
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
806
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 2, 2);
|
|
807
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 3);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
test "reference renderer strokes paths: butt caps end at the segment, round caps extend it" {
|
|
811
|
+
// One horizontal unit-width segment, rendered once per cap shape.
|
|
812
|
+
// The end pixels (0,1) and (2,1) are where the caps live: the butt
|
|
813
|
+
// cap stops at the endpoint (the segment covers exactly half of each
|
|
814
|
+
// end pixel — 128 after coverage rounding), while the round cap
|
|
815
|
+
// bulges a half-width semicircle past it (75% coverage per the
|
|
816
|
+
// anti-aliased vector core). Interior and off-stroke pixels are
|
|
817
|
+
// cap-independent.
|
|
818
|
+
const cases = [_]struct { cap: canvas.LineCap, end_coverage: u8 }{
|
|
819
|
+
.{ .cap = .butt, .end_coverage = 128 },
|
|
820
|
+
.{ .cap = .round, .end_coverage = 191 },
|
|
821
|
+
};
|
|
822
|
+
for (cases) |case| {
|
|
823
|
+
const elements = [_]PathElement{
|
|
824
|
+
.{ .verb = .move_to, .points = .{ geometry.PointF.init(0.5, 1.5), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
825
|
+
.{ .verb = .line_to, .points = .{ geometry.PointF.init(2.5, 1.5), geometry.PointF.zero(), geometry.PointF.zero() } },
|
|
826
|
+
};
|
|
827
|
+
const commands = [_]CanvasCommand{.{ .stroke_path = .{
|
|
828
|
+
.id = 1,
|
|
829
|
+
.elements = &elements,
|
|
830
|
+
.stroke = .{ .fill = .{ .color = Color.rgb8(255, 0, 0) }, .width = 1 },
|
|
831
|
+
.cap = case.cap,
|
|
832
|
+
} }};
|
|
833
|
+
|
|
834
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
835
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
836
|
+
var resources: [0]RenderResource = .{};
|
|
837
|
+
var resource_cache_entries: [0]RenderResourceCacheEntry = .{};
|
|
838
|
+
var resource_cache_actions: [0]RenderResourceCacheAction = .{};
|
|
839
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
840
|
+
var changes: [0]DiffChange = .{};
|
|
841
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
842
|
+
.surface_size = geometry.SizeF.init(4, 3),
|
|
843
|
+
}, .{
|
|
844
|
+
.render_commands = &render_commands,
|
|
845
|
+
.render_batches = &render_batches,
|
|
846
|
+
.resources = &resources,
|
|
847
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
848
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
849
|
+
.glyph_atlas_entries = &glyphs,
|
|
850
|
+
.changes = &changes,
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
var pixels: [4 * 3 * 4]u8 = undefined;
|
|
854
|
+
const surface = try ReferenceRenderSurface.init(4, 3, &pixels);
|
|
855
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
856
|
+
|
|
857
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 0);
|
|
858
|
+
try expectPixelRgba8(.{ case.end_coverage, 0, 0, 255 }, surface, 0, 1);
|
|
859
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
860
|
+
try expectPixelRgba8(.{ case.end_coverage, 0, 0, 255 }, surface, 2, 1);
|
|
861
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 1);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
test "reference renderer draws soft shadows" {
|
|
866
|
+
const commands = [_]CanvasCommand{.{ .shadow = .{
|
|
867
|
+
.id = 1,
|
|
868
|
+
.rect = geometry.RectF.init(1, 1, 2, 2),
|
|
869
|
+
.blur = 1,
|
|
870
|
+
.color = Color.rgba8(0, 0, 0, 128),
|
|
871
|
+
} }};
|
|
872
|
+
|
|
873
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
874
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
875
|
+
var resources: [1]RenderResource = undefined;
|
|
876
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
877
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
878
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
879
|
+
var changes: [0]DiffChange = .{};
|
|
880
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
881
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
882
|
+
}, .{
|
|
883
|
+
.render_commands = &render_commands,
|
|
884
|
+
.render_batches = &render_batches,
|
|
885
|
+
.resources = &resources,
|
|
886
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
887
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
888
|
+
.glyph_atlas_entries = &glyphs,
|
|
889
|
+
.changes = &changes,
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
893
|
+
const surface = try ReferenceRenderSurface.init(4, 4, &pixels);
|
|
894
|
+
try surface.renderPass(frame.renderPass(), Color.rgba8(0, 0, 0, 0));
|
|
895
|
+
|
|
896
|
+
try expectPixelRgba8(.{ 0, 0, 0, 27 }, surface, 0, 0);
|
|
897
|
+
try expectPixelRgba8(.{ 0, 0, 0, 64 }, surface, 0, 1);
|
|
898
|
+
try expectPixelRgba8(.{ 0, 0, 0, 128 }, surface, 1, 1);
|
|
899
|
+
try expectPixelRgba8(.{ 0, 0, 0, 64 }, surface, 3, 2);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
test "reference renderer blurs with caller scratch storage" {
|
|
903
|
+
const commands = [_]CanvasCommand{
|
|
904
|
+
.{ .fill_rect = .{
|
|
905
|
+
.id = 1,
|
|
906
|
+
.rect = geometry.RectF.init(0, 0, 1, 1),
|
|
907
|
+
.fill = .{ .color = Color.rgb8(255, 0, 0) },
|
|
908
|
+
} },
|
|
909
|
+
.{ .fill_rect = .{
|
|
910
|
+
.id = 2,
|
|
911
|
+
.rect = geometry.RectF.init(2, 0, 1, 1),
|
|
912
|
+
.fill = .{ .color = Color.rgb8(0, 0, 255) },
|
|
913
|
+
} },
|
|
914
|
+
.{ .blur = .{
|
|
915
|
+
.id = 3,
|
|
916
|
+
.rect = geometry.RectF.init(0, 0, 3, 1),
|
|
917
|
+
.radius = 1,
|
|
918
|
+
} },
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
var render_commands: [3]RenderCommand = undefined;
|
|
922
|
+
var render_batches: [3]RenderBatch = undefined;
|
|
923
|
+
var resources: [1]RenderResource = undefined;
|
|
924
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
925
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
926
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
927
|
+
var changes: [0]DiffChange = .{};
|
|
928
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
929
|
+
.surface_size = geometry.SizeF.init(3, 1),
|
|
930
|
+
}, .{
|
|
931
|
+
.render_commands = &render_commands,
|
|
932
|
+
.render_batches = &render_batches,
|
|
933
|
+
.resources = &resources,
|
|
934
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
935
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
936
|
+
.glyph_atlas_entries = &glyphs,
|
|
937
|
+
.changes = &changes,
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
var pixels: [3 * 1 * 4]u8 = undefined;
|
|
941
|
+
var scratch: [3 * 1 * 4]u8 = undefined;
|
|
942
|
+
const surface = try ReferenceRenderSurface.initWithScratch(3, 1, &pixels, &scratch);
|
|
943
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
944
|
+
|
|
945
|
+
try expectPixelRgba8(.{ 159, 0, 0, 255 }, surface, 0, 0);
|
|
946
|
+
try expectPixelRgba8(.{ 70, 0, 70, 255 }, surface, 1, 0);
|
|
947
|
+
try expectPixelRgba8(.{ 0, 0, 159, 255 }, surface, 2, 0);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
test "reference renderer render memo replays byte-identical pixels" {
|
|
951
|
+
// The render memo is pure memoization: a render with a cold memo, a
|
|
952
|
+
// render that HITS the memo, and a render with no memo at all must
|
|
953
|
+
// produce the same bytes — determinism is the law, the memo only
|
|
954
|
+
// moves time. A content change under the memoized layers must miss
|
|
955
|
+
// and land on the unmemoized bytes for the NEW content. The scene
|
|
956
|
+
// carries every memoized command kind: a base fill, a backdrop blur,
|
|
957
|
+
// a translucent wash fill, a drop shadow, and a rounded surface fill
|
|
958
|
+
// (the modal-dialog stack in miniature).
|
|
959
|
+
const Frame = struct {
|
|
960
|
+
commands: [5]CanvasCommand,
|
|
961
|
+
render_commands: [5]RenderCommand,
|
|
962
|
+
render_batches: [5]RenderBatch,
|
|
963
|
+
resources: [8]RenderResource,
|
|
964
|
+
resource_cache_entries: [8]RenderResourceCacheEntry,
|
|
965
|
+
resource_cache_actions: [8]RenderResourceCacheAction,
|
|
966
|
+
glyphs: [0]GlyphAtlasEntry,
|
|
967
|
+
changes: [0]DiffChange,
|
|
968
|
+
|
|
969
|
+
fn render(self: *@This(), base: Color, pixels: []u8, scratch: []u8, memo: ?*canvas.ReferenceRenderMemo) !void {
|
|
970
|
+
self.commands = .{
|
|
971
|
+
.{ .fill_rect = .{
|
|
972
|
+
.id = 1,
|
|
973
|
+
.rect = geometry.RectF.init(0, 0, 8, 8),
|
|
974
|
+
.fill = .{ .color = base },
|
|
975
|
+
} },
|
|
976
|
+
.{ .blur = .{
|
|
977
|
+
.id = 2,
|
|
978
|
+
.rect = geometry.RectF.init(0, 0, 8, 8),
|
|
979
|
+
.radius = 1,
|
|
980
|
+
} },
|
|
981
|
+
.{ .fill_rect = .{
|
|
982
|
+
.id = 3,
|
|
983
|
+
.rect = geometry.RectF.init(0, 0, 8, 8),
|
|
984
|
+
.fill = .{ .color = Color.rgba8(0, 0, 0, 26) },
|
|
985
|
+
} },
|
|
986
|
+
.{ .shadow = .{
|
|
987
|
+
.id = 4,
|
|
988
|
+
.rect = geometry.RectF.init(2, 2, 4, 4),
|
|
989
|
+
.blur = 2,
|
|
990
|
+
.color = Color.rgba8(0, 0, 0, 128),
|
|
991
|
+
} },
|
|
992
|
+
.{ .fill_rounded_rect = .{
|
|
993
|
+
.id = 5,
|
|
994
|
+
.rect = geometry.RectF.init(2, 2, 4, 4),
|
|
995
|
+
.radius = Radius.all(1),
|
|
996
|
+
.fill = .{ .color = Color.rgb8(240, 240, 240) },
|
|
997
|
+
} },
|
|
998
|
+
};
|
|
999
|
+
const frame = try (DisplayList{ .commands = &self.commands }).framePlan(null, .{
|
|
1000
|
+
.surface_size = geometry.SizeF.init(8, 8),
|
|
1001
|
+
}, .{
|
|
1002
|
+
.render_commands = &self.render_commands,
|
|
1003
|
+
.render_batches = &self.render_batches,
|
|
1004
|
+
.resources = &self.resources,
|
|
1005
|
+
.resource_cache_entries = &self.resource_cache_entries,
|
|
1006
|
+
.resource_cache_actions = &self.resource_cache_actions,
|
|
1007
|
+
.glyph_atlas_entries = &self.glyphs,
|
|
1008
|
+
.changes = &self.changes,
|
|
1009
|
+
});
|
|
1010
|
+
const surface = (try ReferenceRenderSurface.initWithScratch(8, 8, pixels, scratch)).withRenderMemo(memo);
|
|
1011
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
var frame: Frame = undefined;
|
|
1015
|
+
|
|
1016
|
+
var memo = canvas.ReferenceRenderMemo.init(std.testing.allocator);
|
|
1017
|
+
defer memo.deinit();
|
|
1018
|
+
// The production threshold skips small rects; the test surface is
|
|
1019
|
+
// tiny, so memoize everything to exercise all four command kinds.
|
|
1020
|
+
memo.min_pixels = 0;
|
|
1021
|
+
|
|
1022
|
+
var baseline: [8 * 8 * 4]u8 = undefined;
|
|
1023
|
+
var pixels: [8 * 8 * 4]u8 = undefined;
|
|
1024
|
+
var scratch: [8 * 8 * 4]u8 = undefined;
|
|
1025
|
+
|
|
1026
|
+
const red = Color.rgb8(255, 0, 0);
|
|
1027
|
+
try frame.render(red, &baseline, &scratch, null);
|
|
1028
|
+
|
|
1029
|
+
// Cold memo: all five commands miss and compute — same bytes as
|
|
1030
|
+
// unmemoized.
|
|
1031
|
+
try frame.render(red, &pixels, &scratch, &memo);
|
|
1032
|
+
try std.testing.expectEqual(@as(u64, 0), memo.hits);
|
|
1033
|
+
try std.testing.expectEqual(@as(u64, 5), memo.misses);
|
|
1034
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1035
|
+
|
|
1036
|
+
// Warm memo: every command hits — replayed bytes must be identical
|
|
1037
|
+
// too.
|
|
1038
|
+
try frame.render(red, &pixels, &scratch, &memo);
|
|
1039
|
+
try std.testing.expectEqual(@as(u64, 5), memo.hits);
|
|
1040
|
+
try std.testing.expectEqual(@as(u64, 5), memo.misses);
|
|
1041
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1042
|
+
|
|
1043
|
+
// Changed content at the bottom of the stack: every layer above it
|
|
1044
|
+
// reads different source bytes, so all five must MISS (stale pixels
|
|
1045
|
+
// would be wrong) and match the unmemoized render of the new
|
|
1046
|
+
// content.
|
|
1047
|
+
const green = Color.rgb8(0, 255, 0);
|
|
1048
|
+
var changed_baseline: [8 * 8 * 4]u8 = undefined;
|
|
1049
|
+
try frame.render(green, &changed_baseline, &scratch, null);
|
|
1050
|
+
try frame.render(green, &pixels, &scratch, &memo);
|
|
1051
|
+
try std.testing.expectEqual(@as(u64, 5), memo.hits);
|
|
1052
|
+
try std.testing.expectEqual(@as(u64, 10), memo.misses);
|
|
1053
|
+
try std.testing.expectEqualSlices(u8, &changed_baseline, &pixels);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
test "reference renderer blurs transparent colors without dark fringes" {
|
|
1057
|
+
const commands = [_]CanvasCommand{
|
|
1058
|
+
.{ .fill_rect = .{
|
|
1059
|
+
.id = 1,
|
|
1060
|
+
.rect = geometry.RectF.init(0, 0, 1, 1),
|
|
1061
|
+
.fill = .{ .color = Color.rgba8(255, 0, 0, 128) },
|
|
1062
|
+
} },
|
|
1063
|
+
.{ .blur = .{
|
|
1064
|
+
.id = 2,
|
|
1065
|
+
.rect = geometry.RectF.init(0, 0, 3, 1),
|
|
1066
|
+
.radius = 1,
|
|
1067
|
+
} },
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
var render_commands: [2]RenderCommand = undefined;
|
|
1071
|
+
var render_batches: [2]RenderBatch = undefined;
|
|
1072
|
+
var resources: [1]RenderResource = undefined;
|
|
1073
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1074
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1075
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1076
|
+
var changes: [0]DiffChange = .{};
|
|
1077
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1078
|
+
.surface_size = geometry.SizeF.init(3, 1),
|
|
1079
|
+
}, .{
|
|
1080
|
+
.render_commands = &render_commands,
|
|
1081
|
+
.render_batches = &render_batches,
|
|
1082
|
+
.resources = &resources,
|
|
1083
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1084
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1085
|
+
.glyph_atlas_entries = &glyphs,
|
|
1086
|
+
.changes = &changes,
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
var pixels: [3 * 1 * 4]u8 = undefined;
|
|
1090
|
+
var scratch: [3 * 1 * 4]u8 = undefined;
|
|
1091
|
+
const surface = try ReferenceRenderSurface.initWithScratch(3, 1, &pixels, &scratch);
|
|
1092
|
+
try surface.renderPass(frame.renderPass(), Color.rgba8(0, 0, 0, 0));
|
|
1093
|
+
|
|
1094
|
+
try expectPixelRgba8(.{ 255, 0, 0, 80 }, surface, 0, 0);
|
|
1095
|
+
try expectPixelRgba8(.{ 255, 0, 0, 35 }, surface, 1, 0);
|
|
1096
|
+
try expectPixelRgba8(.{ 0, 0, 0, 0 }, surface, 2, 0);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
test "reference renderer draws proxy text runs" {
|
|
1100
|
+
const commands = [_]CanvasCommand{.{ .draw_text = .{
|
|
1101
|
+
.id = 1,
|
|
1102
|
+
.size = 2,
|
|
1103
|
+
.origin = geometry.PointF.init(1, 3),
|
|
1104
|
+
.color = Color.rgb8(255, 0, 0),
|
|
1105
|
+
.text = "A B",
|
|
1106
|
+
} }};
|
|
1107
|
+
|
|
1108
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1109
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1110
|
+
var resources: [1]RenderResource = undefined;
|
|
1111
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1112
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1113
|
+
var glyphs: [3]GlyphAtlasEntry = undefined;
|
|
1114
|
+
var glyph_cache_entries: [3]GlyphAtlasCacheEntry = undefined;
|
|
1115
|
+
var glyph_cache_actions: [3]GlyphAtlasCacheAction = undefined;
|
|
1116
|
+
var changes: [0]DiffChange = .{};
|
|
1117
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1118
|
+
.surface_size = geometry.SizeF.init(5, 4),
|
|
1119
|
+
}, .{
|
|
1120
|
+
.render_commands = &render_commands,
|
|
1121
|
+
.render_batches = &render_batches,
|
|
1122
|
+
.resources = &resources,
|
|
1123
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1124
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1125
|
+
.glyph_atlas_entries = &glyphs,
|
|
1126
|
+
.glyph_atlas_cache_entries = &glyph_cache_entries,
|
|
1127
|
+
.glyph_atlas_cache_actions = &glyph_cache_actions,
|
|
1128
|
+
.changes = &changes,
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
var pixels: [5 * 4 * 4]u8 = undefined;
|
|
1132
|
+
const surface = try ReferenceRenderSurface.init(5, 4, &pixels);
|
|
1133
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1134
|
+
|
|
1135
|
+
// Real Geist outlines walk estimator advances: 'A' inks column 1,
|
|
1136
|
+
// the space keeps column 2 empty, 'B' inks column 3 and ends inside
|
|
1137
|
+
// its estimator box (column 4 stays background). Values are exact
|
|
1138
|
+
// 2px-em anti-aliased coverage.
|
|
1139
|
+
try expectPixelRgba8(.{ 39, 0, 0, 255 }, surface, 1, 1);
|
|
1140
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 2, 1);
|
|
1141
|
+
try expectPixelRgba8(.{ 72, 0, 0, 255 }, surface, 3, 1);
|
|
1142
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 4, 1);
|
|
1143
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 3);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
test "reference renderer advances proxy text by utf8 scalars" {
|
|
1147
|
+
const commands = [_]CanvasCommand{.{ .draw_text = .{
|
|
1148
|
+
.id = 1,
|
|
1149
|
+
.size = 2,
|
|
1150
|
+
.origin = geometry.PointF.init(1, 3),
|
|
1151
|
+
.color = Color.rgb8(255, 0, 0),
|
|
1152
|
+
.text = "é B",
|
|
1153
|
+
} }};
|
|
1154
|
+
|
|
1155
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1156
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1157
|
+
var resources: [1]RenderResource = undefined;
|
|
1158
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1159
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1160
|
+
var glyphs: [4]GlyphAtlasEntry = undefined;
|
|
1161
|
+
var glyph_cache_entries: [4]GlyphAtlasCacheEntry = undefined;
|
|
1162
|
+
var glyph_cache_actions: [4]GlyphAtlasCacheAction = undefined;
|
|
1163
|
+
var changes: [0]DiffChange = .{};
|
|
1164
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1165
|
+
.surface_size = geometry.SizeF.init(5, 4),
|
|
1166
|
+
}, .{
|
|
1167
|
+
.render_commands = &render_commands,
|
|
1168
|
+
.render_batches = &render_batches,
|
|
1169
|
+
.resources = &resources,
|
|
1170
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1171
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1172
|
+
.glyph_atlas_entries = &glyphs,
|
|
1173
|
+
.glyph_atlas_cache_entries = &glyph_cache_entries,
|
|
1174
|
+
.glyph_atlas_cache_actions = &glyph_cache_actions,
|
|
1175
|
+
.changes = &changes,
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
var pixels: [5 * 4 * 4]u8 = undefined;
|
|
1179
|
+
const surface = try ReferenceRenderSurface.init(5, 4, &pixels);
|
|
1180
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1181
|
+
|
|
1182
|
+
// Real outlines walking the face's real advances: the composite
|
|
1183
|
+
// 'e-acute' inks column 1 (11 at this row; its accent shows stronger
|
|
1184
|
+
// one row down) and 'B' lands one scalar advance later — é now
|
|
1185
|
+
// measures its true 0.567 em, so 'B' starts a third of a pixel
|
|
1186
|
+
// earlier than under the old flat multibyte estimate but still
|
|
1187
|
+
// proves multi-byte input advances once per scalar, not per byte.
|
|
1188
|
+
try expectPixelRgba8(.{ 11, 0, 0, 255 }, surface, 1, 1);
|
|
1189
|
+
try expectPixelRgba8(.{ 23, 0, 0, 255 }, surface, 2, 1);
|
|
1190
|
+
try expectPixelRgba8(.{ 49, 0, 0, 255 }, surface, 3, 1);
|
|
1191
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 4, 1);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
test "reference renderer inks mono runs with the bundled mono face" {
|
|
1195
|
+
// Mono runs ink the bundled Geist Mono outlines at the 0.6 em pitch
|
|
1196
|
+
// layout charges. Before the mono face landed, mono ids borrowed the
|
|
1197
|
+
// proportional sans outlines centered in the cell: narrow 'i' floated
|
|
1198
|
+
// in gulfs while wide 'M' (~0.83 em) overflowed its cell into the
|
|
1199
|
+
// next glyph. At size 20 the cell is 12 px; the mono 'i' is designed
|
|
1200
|
+
// for the cell (serif base, ~9.6 px of ink) and 'M' stays inside its
|
|
1201
|
+
// own 12 px column.
|
|
1202
|
+
const size: f32 = 20;
|
|
1203
|
+
const cell: usize = 12; // 0.6 em at size 20
|
|
1204
|
+
const commands = [_]CanvasCommand{.{ .draw_text = .{
|
|
1205
|
+
.id = 1,
|
|
1206
|
+
.font_id = default_mono_font_id,
|
|
1207
|
+
.size = size,
|
|
1208
|
+
.origin = geometry.PointF.init(0, 20),
|
|
1209
|
+
.color = Color.rgb8(255, 0, 0),
|
|
1210
|
+
.text = "iM",
|
|
1211
|
+
} }};
|
|
1212
|
+
|
|
1213
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1214
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1215
|
+
var resources: [1]RenderResource = undefined;
|
|
1216
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1217
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1218
|
+
var glyphs: [2]GlyphAtlasEntry = undefined;
|
|
1219
|
+
var glyph_cache_entries: [2]GlyphAtlasCacheEntry = undefined;
|
|
1220
|
+
var glyph_cache_actions: [2]GlyphAtlasCacheAction = undefined;
|
|
1221
|
+
var changes: [0]DiffChange = .{};
|
|
1222
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1223
|
+
.surface_size = geometry.SizeF.init(26, 24),
|
|
1224
|
+
}, .{
|
|
1225
|
+
.render_commands = &render_commands,
|
|
1226
|
+
.render_batches = &render_batches,
|
|
1227
|
+
.resources = &resources,
|
|
1228
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1229
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1230
|
+
.glyph_atlas_entries = &glyphs,
|
|
1231
|
+
.glyph_atlas_cache_entries = &glyph_cache_entries,
|
|
1232
|
+
.glyph_atlas_cache_actions = &glyph_cache_actions,
|
|
1233
|
+
.changes = &changes,
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
var pixels: [26 * 24 * 4]u8 = undefined;
|
|
1237
|
+
const surface = try ReferenceRenderSurface.init(26, 24, &pixels);
|
|
1238
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1239
|
+
|
|
1240
|
+
// Per-cell ink extents: any red coverage in a column marks it inked.
|
|
1241
|
+
var ink_width: [2]usize = .{ 0, 0 };
|
|
1242
|
+
for (0..2) |cell_index| {
|
|
1243
|
+
const cell_start = cell_index * cell;
|
|
1244
|
+
var first_ink: ?usize = null;
|
|
1245
|
+
var last_ink: usize = 0;
|
|
1246
|
+
for (cell_start..cell_start + cell) |x| {
|
|
1247
|
+
var inked = false;
|
|
1248
|
+
for (0..24) |y| {
|
|
1249
|
+
if (pixels[(y * 26 + x) * 4] != 0) {
|
|
1250
|
+
inked = true;
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
if (inked) {
|
|
1255
|
+
if (first_ink == null) first_ink = x - cell_start;
|
|
1256
|
+
last_ink = x - cell_start;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
const first = first_ink orelse return error.TestUnexpectedResult;
|
|
1260
|
+
ink_width[cell_index] = last_ink + 1 - first;
|
|
1261
|
+
}
|
|
1262
|
+
// The mono 'i' fills most of its fixed cell (the centered sans 'i'
|
|
1263
|
+
// inked ~4.5 px; the mono design carries a serif base of ~9.6 px).
|
|
1264
|
+
try std.testing.expect(ink_width[0] >= 8);
|
|
1265
|
+
// 'M' inks wide but INSIDE its own cell: with the sans outlines it
|
|
1266
|
+
// overflowed 0.83 em of ink into the pixels past both cells.
|
|
1267
|
+
try std.testing.expect(ink_width[1] >= 8);
|
|
1268
|
+
for (2 * cell..26) |x| {
|
|
1269
|
+
for (0..24) |y| {
|
|
1270
|
+
try std.testing.expectEqual(@as(u8, 0), pixels[(y * 26 + x) * 4]);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
test "reference renderer applies shaped glyph y offsets" {
|
|
1276
|
+
const shaped_glyphs = [_]Glyph{.{ .id = 1, .x = 0, .y = 1, .advance = 1 }};
|
|
1277
|
+
const commands = [_]CanvasCommand{.{ .draw_text = .{
|
|
1278
|
+
.id = 1,
|
|
1279
|
+
.font_id = 2,
|
|
1280
|
+
.size = 2,
|
|
1281
|
+
.origin = geometry.PointF.init(1, 3),
|
|
1282
|
+
.color = Color.rgb8(255, 0, 0),
|
|
1283
|
+
.glyphs = &shaped_glyphs,
|
|
1284
|
+
} }};
|
|
1285
|
+
|
|
1286
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1287
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1288
|
+
var resources: [1]RenderResource = undefined;
|
|
1289
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1290
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1291
|
+
var glyphs: [1]GlyphAtlasEntry = undefined;
|
|
1292
|
+
var glyph_cache_entries: [1]GlyphAtlasCacheEntry = undefined;
|
|
1293
|
+
var glyph_cache_actions: [1]GlyphAtlasCacheAction = undefined;
|
|
1294
|
+
var changes: [0]DiffChange = .{};
|
|
1295
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1296
|
+
.surface_size = geometry.SizeF.init(4, 5),
|
|
1297
|
+
}, .{
|
|
1298
|
+
.render_commands = &render_commands,
|
|
1299
|
+
.render_batches = &render_batches,
|
|
1300
|
+
.resources = &resources,
|
|
1301
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1302
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1303
|
+
.glyph_atlas_entries = &glyphs,
|
|
1304
|
+
.glyph_atlas_cache_entries = &glyph_cache_entries,
|
|
1305
|
+
.glyph_atlas_cache_actions = &glyph_cache_actions,
|
|
1306
|
+
.changes = &changes,
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
var pixels: [4 * 5 * 4]u8 = undefined;
|
|
1310
|
+
const surface = try ReferenceRenderSurface.init(4, 5, &pixels);
|
|
1311
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1312
|
+
|
|
1313
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 1, 1);
|
|
1314
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 2);
|
|
1315
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 3);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
test "reference renderer draws image resources" {
|
|
1319
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1320
|
+
.id = 1,
|
|
1321
|
+
.image_id = 42,
|
|
1322
|
+
.dst = geometry.RectF.init(0, 0, 4, 4),
|
|
1323
|
+
.fit = .contain,
|
|
1324
|
+
} }};
|
|
1325
|
+
const image_pixels = [_]u8{
|
|
1326
|
+
255, 0, 0, 255,
|
|
1327
|
+
0, 0, 255, 255,
|
|
1328
|
+
};
|
|
1329
|
+
const images = [_]ReferenceImage{.{
|
|
1330
|
+
.id = 42,
|
|
1331
|
+
.width = 2,
|
|
1332
|
+
.height = 1,
|
|
1333
|
+
.pixels = &image_pixels,
|
|
1334
|
+
}};
|
|
1335
|
+
|
|
1336
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1337
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1338
|
+
var resources: [1]RenderResource = undefined;
|
|
1339
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1340
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1341
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1342
|
+
var changes: [0]DiffChange = .{};
|
|
1343
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1344
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
1345
|
+
}, .{
|
|
1346
|
+
.render_commands = &render_commands,
|
|
1347
|
+
.render_batches = &render_batches,
|
|
1348
|
+
.resources = &resources,
|
|
1349
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1350
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1351
|
+
.glyph_atlas_entries = &glyphs,
|
|
1352
|
+
.changes = &changes,
|
|
1353
|
+
});
|
|
1354
|
+
|
|
1355
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
1356
|
+
const surface = (try ReferenceRenderSurface.init(4, 4, &pixels)).withImages(&images);
|
|
1357
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1358
|
+
|
|
1359
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 0, 0);
|
|
1360
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 0, 1);
|
|
1361
|
+
try expectPixelRgba8(.{ 225, 0, 137, 255 }, surface, 1, 1);
|
|
1362
|
+
try expectPixelRgba8(.{ 137, 0, 225, 255 }, surface, 2, 1);
|
|
1363
|
+
try expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 3, 2);
|
|
1364
|
+
try expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 0, 3);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
test "reference renderer bilinear-filters scaled images" {
|
|
1368
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1369
|
+
.id = 1,
|
|
1370
|
+
.image_id = 42,
|
|
1371
|
+
.dst = geometry.RectF.init(0, 0, 4, 4),
|
|
1372
|
+
} }};
|
|
1373
|
+
const image_pixels = [_]u8{
|
|
1374
|
+
255, 0, 0, 255,
|
|
1375
|
+
0, 255, 0, 255,
|
|
1376
|
+
0, 0, 255, 255,
|
|
1377
|
+
255, 255, 255, 255,
|
|
1378
|
+
};
|
|
1379
|
+
const images = [_]ReferenceImage{.{
|
|
1380
|
+
.id = 42,
|
|
1381
|
+
.width = 2,
|
|
1382
|
+
.height = 2,
|
|
1383
|
+
.pixels = &image_pixels,
|
|
1384
|
+
}};
|
|
1385
|
+
|
|
1386
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1387
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1388
|
+
var resources: [1]RenderResource = undefined;
|
|
1389
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1390
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1391
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1392
|
+
var changes: [0]DiffChange = .{};
|
|
1393
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1394
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
1395
|
+
}, .{
|
|
1396
|
+
.render_commands = &render_commands,
|
|
1397
|
+
.render_batches = &render_batches,
|
|
1398
|
+
.resources = &resources,
|
|
1399
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1400
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1401
|
+
.glyph_atlas_entries = &glyphs,
|
|
1402
|
+
.changes = &changes,
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
1406
|
+
const surface = (try ReferenceRenderSurface.init(4, 4, &pixels)).withImages(&images);
|
|
1407
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1408
|
+
|
|
1409
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 0, 0);
|
|
1410
|
+
try expectPixelRgba8(.{ 207, 137, 137, 255 }, surface, 1, 1);
|
|
1411
|
+
try expectPixelRgba8(.{ 207, 225, 225, 255 }, surface, 2, 2);
|
|
1412
|
+
try expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 3, 3);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
test "reference renderer nearest-filters scaled images" {
|
|
1416
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1417
|
+
.id = 1,
|
|
1418
|
+
.image_id = 42,
|
|
1419
|
+
.dst = geometry.RectF.init(0, 0, 4, 4),
|
|
1420
|
+
.sampling = .nearest,
|
|
1421
|
+
} }};
|
|
1422
|
+
const image_pixels = [_]u8{
|
|
1423
|
+
255, 0, 0, 255,
|
|
1424
|
+
0, 255, 0, 255,
|
|
1425
|
+
0, 0, 255, 255,
|
|
1426
|
+
255, 255, 255, 255,
|
|
1427
|
+
};
|
|
1428
|
+
const images = [_]ReferenceImage{.{
|
|
1429
|
+
.id = 42,
|
|
1430
|
+
.width = 2,
|
|
1431
|
+
.height = 2,
|
|
1432
|
+
.pixels = &image_pixels,
|
|
1433
|
+
}};
|
|
1434
|
+
|
|
1435
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1436
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1437
|
+
var resources: [1]RenderResource = undefined;
|
|
1438
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1439
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1440
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1441
|
+
var changes: [0]DiffChange = .{};
|
|
1442
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1443
|
+
.surface_size = geometry.SizeF.init(4, 4),
|
|
1444
|
+
}, .{
|
|
1445
|
+
.render_commands = &render_commands,
|
|
1446
|
+
.render_batches = &render_batches,
|
|
1447
|
+
.resources = &resources,
|
|
1448
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1449
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1450
|
+
.glyph_atlas_entries = &glyphs,
|
|
1451
|
+
.changes = &changes,
|
|
1452
|
+
});
|
|
1453
|
+
|
|
1454
|
+
var pixels: [4 * 4 * 4]u8 = undefined;
|
|
1455
|
+
const surface = (try ReferenceRenderSurface.init(4, 4, &pixels)).withImages(&images);
|
|
1456
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0));
|
|
1457
|
+
|
|
1458
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 0, 0);
|
|
1459
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 1, 1);
|
|
1460
|
+
try expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 2, 2);
|
|
1461
|
+
try expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 3, 3);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
test "reference renderer filters scaled image alpha premultiplied" {
|
|
1465
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1466
|
+
.id = 1,
|
|
1467
|
+
.image_id = 42,
|
|
1468
|
+
.dst = geometry.RectF.init(0, 0, 4, 1),
|
|
1469
|
+
} }};
|
|
1470
|
+
const image_pixels = [_]u8{
|
|
1471
|
+
255, 0, 0, 255,
|
|
1472
|
+
0, 0, 255, 0,
|
|
1473
|
+
};
|
|
1474
|
+
const images = [_]ReferenceImage{.{
|
|
1475
|
+
.id = 42,
|
|
1476
|
+
.width = 2,
|
|
1477
|
+
.height = 1,
|
|
1478
|
+
.pixels = &image_pixels,
|
|
1479
|
+
}};
|
|
1480
|
+
|
|
1481
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1482
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1483
|
+
var resources: [1]RenderResource = undefined;
|
|
1484
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1485
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1486
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1487
|
+
var changes: [0]DiffChange = .{};
|
|
1488
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1489
|
+
.surface_size = geometry.SizeF.init(4, 1),
|
|
1490
|
+
}, .{
|
|
1491
|
+
.render_commands = &render_commands,
|
|
1492
|
+
.render_batches = &render_batches,
|
|
1493
|
+
.resources = &resources,
|
|
1494
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1495
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1496
|
+
.glyph_atlas_entries = &glyphs,
|
|
1497
|
+
.changes = &changes,
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
var pixels: [4 * 1 * 4]u8 = undefined;
|
|
1501
|
+
const surface = (try ReferenceRenderSurface.init(4, 1, &pixels)).withImages(&images);
|
|
1502
|
+
try surface.renderPass(frame.renderPass(), Color.rgba8(0, 0, 0, 0));
|
|
1503
|
+
|
|
1504
|
+
try expectPixelRgba8(.{ 255, 0, 0, 255 }, surface, 0, 0);
|
|
1505
|
+
try expectPixelRgba8(.{ 255, 0, 0, 191 }, surface, 1, 0);
|
|
1506
|
+
try expectPixelRgba8(.{ 255, 0, 0, 64 }, surface, 2, 0);
|
|
1507
|
+
try expectPixelRgba8(.{ 0, 0, 0, 0 }, surface, 3, 0);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
test "reference renderer skips absent images and rejects corrupt ones" {
|
|
1511
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1512
|
+
.id = 1,
|
|
1513
|
+
.image_id = 42,
|
|
1514
|
+
.dst = geometry.RectF.init(0, 0, 2, 2),
|
|
1515
|
+
} }};
|
|
1516
|
+
|
|
1517
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1518
|
+
var render_batches: [1]RenderBatch = undefined;
|
|
1519
|
+
var resources: [1]RenderResource = undefined;
|
|
1520
|
+
var resource_cache_entries: [1]RenderResourceCacheEntry = undefined;
|
|
1521
|
+
var resource_cache_actions: [1]RenderResourceCacheAction = undefined;
|
|
1522
|
+
var glyphs: [0]GlyphAtlasEntry = .{};
|
|
1523
|
+
var changes: [0]DiffChange = .{};
|
|
1524
|
+
const frame = try (DisplayList{ .commands = &commands }).framePlan(null, .{
|
|
1525
|
+
.surface_size = geometry.SizeF.init(2, 2),
|
|
1526
|
+
}, .{
|
|
1527
|
+
.render_commands = &render_commands,
|
|
1528
|
+
.render_batches = &render_batches,
|
|
1529
|
+
.resources = &resources,
|
|
1530
|
+
.resource_cache_entries = &resource_cache_entries,
|
|
1531
|
+
.resource_cache_actions = &resource_cache_actions,
|
|
1532
|
+
.glyph_atlas_entries = &glyphs,
|
|
1533
|
+
.changes = &changes,
|
|
1534
|
+
});
|
|
1535
|
+
|
|
1536
|
+
// An id with no matching resource is a legitimate transient state
|
|
1537
|
+
// (runtime-registered image mid-fetch or just unregistered): the draw
|
|
1538
|
+
// skips, presentation succeeds, the clear color shows through.
|
|
1539
|
+
var pixels: [2 * 2 * 4]u8 = undefined;
|
|
1540
|
+
const surface = try ReferenceRenderSurface.init(2, 2, &pixels);
|
|
1541
|
+
try surface.renderPass(frame.renderPass(), Color.rgb8(7, 8, 9));
|
|
1542
|
+
try expectPixelRgba8(.{ 7, 8, 9, 255 }, surface, 0, 0);
|
|
1543
|
+
try expectPixelRgba8(.{ 7, 8, 9, 255 }, surface, 1, 1);
|
|
1544
|
+
|
|
1545
|
+
// A PRESENT resource with an undersized pixel buffer is corrupt, not
|
|
1546
|
+
// transient: still a loud error.
|
|
1547
|
+
const corrupt_pixels = [_]u8{ 255, 0, 0, 255 };
|
|
1548
|
+
const corrupt = [_]ReferenceImage{.{ .id = 42, .width = 2, .height = 2, .pixels = &corrupt_pixels }};
|
|
1549
|
+
const corrupt_surface = (try ReferenceRenderSurface.init(2, 2, &pixels)).withImages(&corrupt);
|
|
1550
|
+
try std.testing.expectError(error.ReferenceRenderUnsupportedCommand, corrupt_surface.renderPass(frame.renderPass(), Color.rgb8(0, 0, 0)));
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
test "reference renderer scale-once image panels replay byte-identical samples at any position with the same phase" {
|
|
1554
|
+
// The scaled-image panel is pure memoization: at integer device
|
|
1555
|
+
// alignment a destination pixel's sample depends only on its offset
|
|
1556
|
+
// inside the destination rect, so the panel must produce the same
|
|
1557
|
+
// bytes as direct sampling — cold, warm, AND after the draw moves to
|
|
1558
|
+
// a different integer position (the position-independence that makes
|
|
1559
|
+
// scrolling grids cheap). Fractional alignment must bypass the panel
|
|
1560
|
+
// entirely, and changed image content must miss.
|
|
1561
|
+
const Scene = struct {
|
|
1562
|
+
fn render(dst: geometry.RectF, images: []const ReferenceImage, pixels: []u8, memo: ?*canvas.ReferenceRenderMemo) !void {
|
|
1563
|
+
const commands = [_]CanvasCommand{.{ .draw_image = .{
|
|
1564
|
+
.id = 1,
|
|
1565
|
+
.image_id = 7,
|
|
1566
|
+
.dst = dst,
|
|
1567
|
+
.fit = .cover,
|
|
1568
|
+
.sampling = .linear,
|
|
1569
|
+
.radius = Radius.all(2),
|
|
1570
|
+
} }};
|
|
1571
|
+
var render_commands: [1]RenderCommand = undefined;
|
|
1572
|
+
const plan = try (DisplayList{ .commands = &commands }).renderPlan(&render_commands);
|
|
1573
|
+
const surface = (try ReferenceRenderSurface.init(32, 32, pixels)).withImages(images).withRenderMemo(memo);
|
|
1574
|
+
try surface.renderPass(.{
|
|
1575
|
+
.surface_size = geometry.SizeF.init(32, 32),
|
|
1576
|
+
.scale = 1,
|
|
1577
|
+
.full_repaint = true,
|
|
1578
|
+
.commands = plan.commands,
|
|
1579
|
+
}, Color.rgb8(9, 12, 20));
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
var image_pixels: [8 * 8 * 4]u8 = undefined;
|
|
1584
|
+
for (&image_pixels, 0..) |*byte, index| byte.* = @intCast((index * 37 + 11) % 256);
|
|
1585
|
+
for (0..8 * 8) |pixel| image_pixels[pixel * 4 + 3] = 255;
|
|
1586
|
+
const images = [_]ReferenceImage{.{ .id = 7, .width = 8, .height = 8, .pixels = &image_pixels }};
|
|
1587
|
+
|
|
1588
|
+
var memo = canvas.ReferenceRenderMemo.init(std.testing.allocator);
|
|
1589
|
+
defer memo.deinit();
|
|
1590
|
+
// The production threshold skips small draws; the test panel is
|
|
1591
|
+
// tiny, so cache everything.
|
|
1592
|
+
memo.min_pixels = 0;
|
|
1593
|
+
|
|
1594
|
+
var baseline: [32 * 32 * 4]u8 = undefined;
|
|
1595
|
+
var pixels: [32 * 32 * 4]u8 = undefined;
|
|
1596
|
+
|
|
1597
|
+
// Cold panel: one miss, bytes equal the unmemoized render.
|
|
1598
|
+
const first_rect = geometry.RectF.init(2, 3, 16, 16);
|
|
1599
|
+
try Scene.render(first_rect, &images, &baseline, null);
|
|
1600
|
+
try Scene.render(first_rect, &images, &pixels, &memo);
|
|
1601
|
+
try std.testing.expectEqual(@as(u64, 0), memo.image_scale_hits);
|
|
1602
|
+
try std.testing.expectEqual(@as(u64, 1), memo.image_scale_misses);
|
|
1603
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1604
|
+
|
|
1605
|
+
// Warm panel at the same position.
|
|
1606
|
+
try Scene.render(first_rect, &images, &pixels, &memo);
|
|
1607
|
+
try std.testing.expectEqual(@as(u64, 1), memo.image_scale_hits);
|
|
1608
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1609
|
+
|
|
1610
|
+
// Moved to a different INTEGER position: still a hit (the panel is
|
|
1611
|
+
// position-independent), and still byte-identical to the direct
|
|
1612
|
+
// render at the new position.
|
|
1613
|
+
const moved_rect = geometry.RectF.init(11, 9, 16, 16);
|
|
1614
|
+
try Scene.render(moved_rect, &images, &baseline, null);
|
|
1615
|
+
try Scene.render(moved_rect, &images, &pixels, &memo);
|
|
1616
|
+
try std.testing.expectEqual(@as(u64, 2), memo.image_scale_hits);
|
|
1617
|
+
try std.testing.expectEqual(@as(u64, 1), memo.image_scale_misses);
|
|
1618
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1619
|
+
|
|
1620
|
+
// A FRACTIONAL position keys a different subpixel phase: a fresh
|
|
1621
|
+
// panel fills (miss) and its bytes still equal direct sampling.
|
|
1622
|
+
const fractional_rect = geometry.RectF.init(2.5, 3.25, 16, 16);
|
|
1623
|
+
try Scene.render(fractional_rect, &images, &baseline, null);
|
|
1624
|
+
try Scene.render(fractional_rect, &images, &pixels, &memo);
|
|
1625
|
+
try std.testing.expectEqual(@as(u64, 2), memo.image_scale_hits);
|
|
1626
|
+
try std.testing.expectEqual(@as(u64, 2), memo.image_scale_misses);
|
|
1627
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1628
|
+
|
|
1629
|
+
// Moved by WHOLE pixels from the fractional position (same phase):
|
|
1630
|
+
// a hit, byte-identical at the new position.
|
|
1631
|
+
const fractional_moved = geometry.RectF.init(6.5, 8.25, 16, 16);
|
|
1632
|
+
try Scene.render(fractional_moved, &images, &baseline, null);
|
|
1633
|
+
try Scene.render(fractional_moved, &images, &pixels, &memo);
|
|
1634
|
+
try std.testing.expectEqual(@as(u64, 3), memo.image_scale_hits);
|
|
1635
|
+
try std.testing.expectEqual(@as(u64, 2), memo.image_scale_misses);
|
|
1636
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1637
|
+
|
|
1638
|
+
// Changed image content under the same id: the content hash moves,
|
|
1639
|
+
// so the draw misses and matches the direct render of the new
|
|
1640
|
+
// pixels.
|
|
1641
|
+
var changed_pixels: [8 * 8 * 4]u8 = undefined;
|
|
1642
|
+
for (&changed_pixels, 0..) |*byte, index| byte.* = @intCast((index * 53 + 5) % 256);
|
|
1643
|
+
for (0..8 * 8) |pixel| changed_pixels[pixel * 4 + 3] = 255;
|
|
1644
|
+
const changed_images = [_]ReferenceImage{.{ .id = 7, .width = 8, .height = 8, .pixels = &changed_pixels }};
|
|
1645
|
+
try Scene.render(first_rect, &changed_images, &baseline, null);
|
|
1646
|
+
try Scene.render(first_rect, &changed_images, &pixels, &memo);
|
|
1647
|
+
try std.testing.expectEqual(@as(u64, 3), memo.image_scale_hits);
|
|
1648
|
+
try std.testing.expectEqual(@as(u64, 3), memo.image_scale_misses);
|
|
1649
|
+
try std.testing.expectEqualSlices(u8, &baseline, &pixels);
|
|
1650
|
+
}
|