@native-sdk/cli 0.7.1 → 0.7.2
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/build/app.zig +8 -0
- package/build.zig +49 -12
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/skill-data/native-ui/SKILL.md +4 -2
- package/src/platform/macos/appkit_host.m +51 -3
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +50 -0
- package/src/primitives/canvas/code_tests.zig +174 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +2 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +52 -7
- package/src/primitives/canvas/ui_markup.zig +38 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
- package/src/primitives/canvas/ui_schema.zig +5 -0
- package/src/primitives/canvas/ui_schema_tests.zig +4 -3
- package/src/primitives/canvas/ui_tests.zig +14 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +11 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +45 -9
- package/src/primitives/canvas/widget_render.zig +220 -70
- package/src/primitives/canvas/widget_render_controls.zig +79 -21
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_text_input.zig +2 -0
- package/src/primitives/canvas/widgets.zig +53 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
- package/src/runtime/canvas_widget_runtime.zig +11 -8
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +38 -7
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +6 -0
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_text.zig +6 -4
- package/src/runtime/window_view_runtime.zig +1 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -86,19 +86,25 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
86
86
|
// republish when the runtime is invalidated, and a frame
|
|
87
87
|
// completion carrying a NEW discrete fact may have no
|
|
88
88
|
// other invalidation source, leaving the published
|
|
89
|
-
// snapshot stale forever.
|
|
90
|
-
// (a
|
|
89
|
+
// snapshot stale forever. Three such facts invalidate here
|
|
90
|
+
// (a fourth — a resolved input latency — is checked after
|
|
91
91
|
// the app dispatch below, where the responding present
|
|
92
92
|
// stamps it):
|
|
93
93
|
// - the host-reported nonblank verdict changed (the
|
|
94
94
|
// first nonblank presentation on an idle boot has no
|
|
95
95
|
// resize and no input to piggyback on);
|
|
96
|
+
// - the concrete presenter changed (for example a
|
|
97
|
+
// Direct2D packet refusal fell back to software, or a
|
|
98
|
+
// later packet recovered Direct2D);
|
|
96
99
|
// - this frame recorded the first-frame latency.
|
|
97
100
|
// Steady-state frames carry no new fact and stay quiet —
|
|
98
101
|
// a timer-mode surface must not republish observable
|
|
99
102
|
// state 60 times a second.
|
|
100
103
|
const first_frame_latency_recorded = !first_frame_latency_was_recorded and self.views[index].gpu_first_frame_latency_recorded;
|
|
101
|
-
if (self.views[index].gpu_frame_nonblank != frame_event.nonblank or
|
|
104
|
+
if (self.views[index].gpu_frame_nonblank != frame_event.nonblank or
|
|
105
|
+
self.views[index].gpu_backend != frame_event.backend or
|
|
106
|
+
first_frame_latency_recorded)
|
|
107
|
+
{
|
|
102
108
|
self.invalidateFor(.state, self.views[index].frame);
|
|
103
109
|
}
|
|
104
110
|
self.views[index].gpu_frame_nonblank = frame_event.nonblank;
|
|
@@ -113,11 +119,11 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
113
119
|
try enrichGpuSurfaceFrameDiagnostics(self, index, &enriched_frame_event);
|
|
114
120
|
} else if (self.views[index].info().gpuFrame()) |gpu_frame| {
|
|
115
121
|
enriched_frame_event = gpuSurfaceFrameEventFromGpuFrame(gpu_frame);
|
|
116
|
-
// GpuFrame is persistent surface state; the occluded
|
|
117
|
-
// fact is per-completion metadata and must survive
|
|
118
|
-
// the rebuild so the app sees it honestly.
|
|
119
|
-
enriched_frame_event.occluded = frame_event.occluded;
|
|
120
122
|
}
|
|
123
|
+
// Diagnostic enrichment and the low-cost persistent-frame
|
|
124
|
+
// rebuild can both replace fields. Reapply facts owned by
|
|
125
|
+
// this host completion, including device-loss recovery.
|
|
126
|
+
preserveGpuSurfaceCompletionFacts(frame_event, &enriched_frame_event);
|
|
121
127
|
// Alpha mode is immutable surface configuration, not a
|
|
122
128
|
// completion-time measurement. The desktop ABIs predate
|
|
123
129
|
// premultiplied surfaces and stamp their legacy opaque
|
|
@@ -1037,6 +1043,7 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
1037
1043
|
.timestamp_ns = enriched_frame_event.timestamp_ns,
|
|
1038
1044
|
.surface_size = enriched_frame_event.size,
|
|
1039
1045
|
.scale = enriched_frame_event.scale_factor,
|
|
1046
|
+
.full_repaint = enriched_frame_event.canvas_frame_full_repaint,
|
|
1040
1047
|
}, CanvasFrameMethods().canvasFrameScratchStorage(self), false);
|
|
1041
1048
|
const preview_render_pass = preview_frame.renderPass();
|
|
1042
1049
|
const preview_gpu_packet_summary = preview_frame.gpuPacketSummary();
|
|
@@ -1142,6 +1149,30 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
1142
1149
|
};
|
|
1143
1150
|
}
|
|
1144
1151
|
|
|
1152
|
+
fn preserveGpuSurfaceCompletionFacts(source: platform.GpuSurfaceFrameEvent, target: *platform.GpuSurfaceFrameEvent) void {
|
|
1153
|
+
target.occluded = source.occluded;
|
|
1154
|
+
if (source.canvas_frame_full_repaint) {
|
|
1155
|
+
target.canvas_frame_requires_render = true;
|
|
1156
|
+
target.canvas_frame_full_repaint = true;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
test "GPU completion preserves host-forced full repaint" {
|
|
1161
|
+
var enriched: platform.GpuSurfaceFrameEvent = .{
|
|
1162
|
+
.label = "canvas",
|
|
1163
|
+
.size = geometry.SizeF.init(640, 360),
|
|
1164
|
+
};
|
|
1165
|
+
preserveGpuSurfaceCompletionFacts(.{
|
|
1166
|
+
.label = "canvas",
|
|
1167
|
+
.size = geometry.SizeF.init(640, 360),
|
|
1168
|
+
.occluded = true,
|
|
1169
|
+
.canvas_frame_full_repaint = true,
|
|
1170
|
+
}, &enriched);
|
|
1171
|
+
try std.testing.expect(enriched.occluded);
|
|
1172
|
+
try std.testing.expect(enriched.canvas_frame_requires_render);
|
|
1173
|
+
try std.testing.expect(enriched.canvas_frame_full_repaint);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1145
1176
|
fn setFocusedView(self: anytype, window_id: platform.WindowId, label: []const u8) !void {
|
|
1146
1177
|
if (runtimeFindWindowIndexById(self, window_id)) |window_index| {
|
|
1147
1178
|
self.windows[window_index].main_focused = std.mem.eql(u8, label, "main");
|
|
@@ -877,7 +877,7 @@ test "a session recorded with a live producer replays fingerprint-identical with
|
|
|
877
877
|
const media = @import("../root.zig");
|
|
878
878
|
|
|
879
879
|
test "docs example: the typed producer callback is writable against the public exports" {
|
|
880
|
-
// docs/src/app/media-producers/page.mdx, "The mpv shape": the docs
|
|
880
|
+
// docs/src/app/docs/media-producers/page.mdx, "The mpv shape": the docs
|
|
881
881
|
// machinery checks prose patterns, not Zig fences (the
|
|
882
882
|
// test-docs-media-producer-contracts step pins the signature in the
|
|
883
883
|
// page AND in this file), so this test is the compile-shaped mirror
|
|
@@ -936,6 +936,80 @@ test "gpu surface nonblank transition invalidates the runtime" {
|
|
|
936
936
|
try std.testing.expect(!harness.runtime.invalidated);
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
+
test "gpu surface backend transition invalidates the runtime" {
|
|
940
|
+
const TestApp = struct {
|
|
941
|
+
fn app(self: *@This()) App {
|
|
942
|
+
return .{ .context = self, .name = "gpu-backend-transition", .source = platform.WebViewSource.html("<h1>GPU</h1>"), .event_fn = event };
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
fn event(context: *anyopaque, runtime: *Runtime, event_value: Event) anyerror!void {
|
|
946
|
+
_ = context;
|
|
947
|
+
_ = runtime;
|
|
948
|
+
_ = event_value;
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
953
|
+
defer harness.destroy(std.testing.allocator);
|
|
954
|
+
harness.null_platform.gpu_surfaces = true;
|
|
955
|
+
var app_state: TestApp = .{};
|
|
956
|
+
const app = app_state.app();
|
|
957
|
+
try harness.start(app);
|
|
958
|
+
|
|
959
|
+
_ = try harness.runtime.createView(.{
|
|
960
|
+
.window_id = 1,
|
|
961
|
+
.label = "canvas",
|
|
962
|
+
.kind = .gpu_surface,
|
|
963
|
+
.frame = geometry.RectF.init(0, 0, 640, 360),
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
// A fallback completion changes an observable snapshot fact even when
|
|
967
|
+
// nonblank and latency state stay unchanged.
|
|
968
|
+
harness.runtime.invalidated = false;
|
|
969
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
970
|
+
.window_id = 1,
|
|
971
|
+
.label = "canvas",
|
|
972
|
+
.size = geometry.SizeF.init(640, 360),
|
|
973
|
+
.scale_factor = 1,
|
|
974
|
+
.frame_index = 1,
|
|
975
|
+
.timestamp_ns = 16,
|
|
976
|
+
.nonblank = false,
|
|
977
|
+
.backend = .software,
|
|
978
|
+
} });
|
|
979
|
+
try std.testing.expect(harness.runtime.invalidated);
|
|
980
|
+
try std.testing.expectEqual(platform.GpuSurfaceBackend.software, (try harness.runtime.gpuSurfaceFrame(1, "canvas")).backend);
|
|
981
|
+
|
|
982
|
+
// The same presenter on the next timer completion is steady state and
|
|
983
|
+
// must not turn snapshot publication into a per-frame loop.
|
|
984
|
+
harness.runtime.invalidated = false;
|
|
985
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
986
|
+
.window_id = 1,
|
|
987
|
+
.label = "canvas",
|
|
988
|
+
.size = geometry.SizeF.init(640, 360),
|
|
989
|
+
.scale_factor = 1,
|
|
990
|
+
.frame_index = 2,
|
|
991
|
+
.timestamp_ns = 32,
|
|
992
|
+
.nonblank = false,
|
|
993
|
+
.backend = .software,
|
|
994
|
+
} });
|
|
995
|
+
try std.testing.expect(!harness.runtime.invalidated);
|
|
996
|
+
|
|
997
|
+
// Recovery to the packet presenter is the same observable transition
|
|
998
|
+
// in the opposite direction.
|
|
999
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1000
|
+
.window_id = 1,
|
|
1001
|
+
.label = "canvas",
|
|
1002
|
+
.size = geometry.SizeF.init(640, 360),
|
|
1003
|
+
.scale_factor = 1,
|
|
1004
|
+
.frame_index = 3,
|
|
1005
|
+
.timestamp_ns = 48,
|
|
1006
|
+
.nonblank = false,
|
|
1007
|
+
.backend = .direct2d,
|
|
1008
|
+
} });
|
|
1009
|
+
try std.testing.expect(harness.runtime.invalidated);
|
|
1010
|
+
try std.testing.expectEqual(platform.GpuSurfaceBackend.direct2d, (try harness.runtime.gpuSurfaceFrame(1, "canvas")).backend);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
939
1013
|
test "a handler error degrades: dispatch continues, the error ring records it, snapshots publish it" {
|
|
940
1014
|
// One erroring update arm used to exit the whole app
|
|
941
1015
|
// (the platform callback saw the error, set `failed`, and stopped
|
package/src/runtime/ui_app.zig
CHANGED
|
@@ -4327,13 +4327,14 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
4327
4327
|
self.fonts_built_count = runtime.registeredCanvasFontCount();
|
|
4328
4328
|
}
|
|
4329
4329
|
|
|
4330
|
-
/// Present the planned canvas frame: GPU packet when the
|
|
4331
|
-
///
|
|
4332
|
-
///
|
|
4333
|
-
/// e.g.
|
|
4334
|
-
///
|
|
4335
|
-
///
|
|
4336
|
-
///
|
|
4330
|
+
/// Present the planned canvas frame: GPU packet when the view did
|
|
4331
|
+
/// not explicitly request software and the platform has a packet
|
|
4332
|
+
/// presenter (macOS/Metal — unchanged), otherwise the CPU
|
|
4333
|
+
/// reference-rendered pixel path (`presentGpuSurfacePixels`, e.g.
|
|
4334
|
+
/// Linux/GTK). A platform whose packet presenter exists but reports
|
|
4335
|
+
/// `UnsupportedService` at present time also falls back to pixels;
|
|
4336
|
+
/// that attempt forces a full repaint because the failed packet plan
|
|
4337
|
+
/// already recorded the frame's presented summary.
|
|
4337
4338
|
fn presentFrame(self: *Self, runtime: *Runtime, frame_event: platform.GpuSurfaceFrameEvent, canvas_label: []const u8, force_full_repaint: bool, clear_color: canvas.Color) anyerror!void {
|
|
4338
4339
|
// A forced frame must paint unconditionally: the installing
|
|
4339
4340
|
// frame has no earlier glass to retain. Software-buffer
|
|
@@ -4341,7 +4342,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
4341
4342
|
// a surface handoff.
|
|
4342
4343
|
const services = runtime.options.platform.services;
|
|
4343
4344
|
var packet_attempted = false;
|
|
4344
|
-
|
|
4345
|
+
const packet_requested = canvas_frame.canvasGpuPacketPresentationRequested(runtime, frame_event.window_id, canvas_label);
|
|
4346
|
+
if (packet_requested and (services.present_gpu_surface_packet_fn != null or services.present_gpu_surface_packet_binary_fn != null)) {
|
|
4345
4347
|
packet_attempted = true;
|
|
4346
4348
|
const packet_presented = blk: {
|
|
4347
4349
|
_ = runtime.presentNextCanvasGpuPacketWithScale(
|
|
@@ -66,6 +66,25 @@ fn counterOptions() CounterApp.Options {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
const software_counter_views = [_]app_manifest.ShellView{
|
|
70
|
+
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .software },
|
|
71
|
+
};
|
|
72
|
+
const software_counter_windows = [_]app_manifest.ShellWindow{.{
|
|
73
|
+
.label = "main",
|
|
74
|
+
.title = "Software Counter",
|
|
75
|
+
.width = 400,
|
|
76
|
+
.height = 300,
|
|
77
|
+
.views = &software_counter_views,
|
|
78
|
+
}};
|
|
79
|
+
const software_counter_scene: app_manifest.ShellConfig = .{ .windows = &software_counter_windows };
|
|
80
|
+
|
|
81
|
+
fn softwareCounterOptions() CounterApp.Options {
|
|
82
|
+
var options = counterOptions();
|
|
83
|
+
options.name = "ui-app-software-counter";
|
|
84
|
+
options.scene = software_counter_scene;
|
|
85
|
+
return options;
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
fn findWidgetIdByText(tree: anytype, kind: canvas.WidgetKind, text: []const u8) ?canvas.ObjectId {
|
|
70
89
|
return findIn(tree.root, kind, text);
|
|
71
90
|
}
|
|
@@ -480,6 +499,54 @@ test "ui app presents pixels when the packet service is unsupported" {
|
|
|
480
499
|
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
481
500
|
}
|
|
482
501
|
|
|
502
|
+
test "ui app explicit software canvas bypasses the production packet path" {
|
|
503
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
504
|
+
defer harness.destroy(std.testing.allocator);
|
|
505
|
+
harness.null_platform.gpu_surfaces = true;
|
|
506
|
+
harness.runtime.options.pixel_present_retained_baseline = true;
|
|
507
|
+
|
|
508
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
509
|
+
defer std.testing.allocator.destroy(app_state);
|
|
510
|
+
app_state.* = CounterApp.init(std.testing.allocator, .{}, softwareCounterOptions());
|
|
511
|
+
defer app_state.deinit();
|
|
512
|
+
const app = app_state.app();
|
|
513
|
+
try harness.start(app);
|
|
514
|
+
|
|
515
|
+
// Packet services are available and would accept this frame. The
|
|
516
|
+
// immutable software request must still send it directly to the
|
|
517
|
+
// reference renderer without recording a packet fallback.
|
|
518
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
519
|
+
.label = canvas_label,
|
|
520
|
+
.size = geometry.SizeF.init(400, 300),
|
|
521
|
+
.scale_factor = 2,
|
|
522
|
+
.frame_index = 1,
|
|
523
|
+
.timestamp_ns = 1_000_000,
|
|
524
|
+
} });
|
|
525
|
+
|
|
526
|
+
try std.testing.expect(app_state.installed);
|
|
527
|
+
try std.testing.expectEqual(zero_platform.GpuSurfaceBackend.software, harness.runtime.views[0].gpu_requested_backend);
|
|
528
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.gpu_surface_packet_present_count);
|
|
529
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.gpu_surface_image_upload_count);
|
|
530
|
+
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.gpu_surface_present_count);
|
|
531
|
+
try std.testing.expectEqual(zero_platform.GpuPresentPath.pixels, harness.runtime.views[0].gpu_present_path);
|
|
532
|
+
try std.testing.expectEqual(zero_platform.GpuPresentFallbackReason.none, harness.runtime.views[0].info().gpu_present_fallback_reason);
|
|
533
|
+
|
|
534
|
+
// A changed follow-up frame remains incremental. Treating the central
|
|
535
|
+
// software-policy rejection as a failed packet attempt would force this
|
|
536
|
+
// pixel present back to the full surface.
|
|
537
|
+
try app_state.dispatch(&harness.runtime, 1, .increment);
|
|
538
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
539
|
+
.label = canvas_label,
|
|
540
|
+
.size = geometry.SizeF.init(400, 300),
|
|
541
|
+
.scale_factor = 2,
|
|
542
|
+
.frame_index = 2,
|
|
543
|
+
.timestamp_ns = 17_000_000,
|
|
544
|
+
} });
|
|
545
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.gpu_surface_present_count);
|
|
546
|
+
const dirty = harness.null_platform.gpu_surface_present_dirty_bounds orelse return error.TestUnexpectedResult;
|
|
547
|
+
try std.testing.expect(dirty.width < 400 or dirty.height < 300);
|
|
548
|
+
}
|
|
549
|
+
|
|
483
550
|
// ---------------------------------- reflow stale-pixel oracle fixture
|
|
484
551
|
|
|
485
552
|
const ReflowRow = struct {
|
package/src/runtime/view.zig
CHANGED
|
@@ -219,6 +219,11 @@ pub const RuntimeView = struct {
|
|
|
219
219
|
gpu_first_frame_latency_recorded: bool = false,
|
|
220
220
|
gpu_frame_nonblank: bool = false,
|
|
221
221
|
gpu_sample_color: u32 = 0,
|
|
222
|
+
/// Immutable creation-time backend request. `gpu_backend` below is
|
|
223
|
+
/// completion state and changes to the concrete presenter reported by
|
|
224
|
+
/// the host, so it cannot answer whether packet work was explicitly
|
|
225
|
+
/// opted out before a present.
|
|
226
|
+
gpu_requested_backend: platform.GpuSurfaceBackend = .none,
|
|
222
227
|
gpu_backend: platform.GpuSurfaceBackend = .none,
|
|
223
228
|
gpu_pixel_format: platform.GpuSurfacePixelFormat = .none,
|
|
224
229
|
gpu_present_mode: platform.GpuSurfacePresentMode = .none,
|
|
@@ -860,6 +865,7 @@ pub const RuntimeView = struct {
|
|
|
860
865
|
pub const copyCanvasFrameResourceCache = CanvasFrameMethods.copyCanvasFrameResourceCache;
|
|
861
866
|
pub const copyCanvasFramePathGeometryCache = CanvasFrameMethods.copyCanvasFramePathGeometryCache;
|
|
862
867
|
pub const copyCanvasFrameImageCache = CanvasFrameMethods.copyCanvasFrameImageCache;
|
|
868
|
+
pub const removeCanvasFrameImageCacheId = CanvasFrameMethods.removeCanvasFrameImageCacheId;
|
|
863
869
|
pub const copyCanvasFrameLayerCache = CanvasFrameMethods.copyCanvasFrameLayerCache;
|
|
864
870
|
pub const copyCanvasFrameVisualEffectCache = CanvasFrameMethods.copyCanvasFrameVisualEffectCache;
|
|
865
871
|
pub const copyCanvasRenderAnimations = CanvasFrameMethods.copyCanvasRenderAnimations;
|
|
@@ -313,6 +313,21 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
313
313
|
self.canvas_frame_image_cache_count = entries.len;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
/// Forget every retained cache key for one platform image. The
|
|
317
|
+
/// platform removal seam destroys the resource independently of
|
|
318
|
+
/// this per-view planner mirror; leaving an identical key here
|
|
319
|
+
/// would turn a same-content re-registration into `.retain` and
|
|
320
|
+
/// skip the upload needed to recreate that resource.
|
|
321
|
+
pub fn removeCanvasFrameImageCacheId(self: *RuntimeView, image_id: canvas.ImageId) void {
|
|
322
|
+
var kept: usize = 0;
|
|
323
|
+
for (self.canvas_frame_image_cache[0..self.canvas_frame_image_cache_count]) |entry| {
|
|
324
|
+
if (entry.key.image_id == image_id) continue;
|
|
325
|
+
self.canvas_frame_image_cache[kept] = entry;
|
|
326
|
+
kept += 1;
|
|
327
|
+
}
|
|
328
|
+
self.canvas_frame_image_cache_count = kept;
|
|
329
|
+
}
|
|
330
|
+
|
|
316
331
|
pub fn copyCanvasFrameLayerCache(self: *RuntimeView, entries: []const canvas.RenderLayerCacheEntry) anyerror!void {
|
|
317
332
|
if (entries.len > self.canvas_frame_layer_cache.len) return error.LayerListFull;
|
|
318
333
|
@memcpy(self.canvas_frame_layer_cache[0..entries.len], entries);
|
|
@@ -1176,7 +1176,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
const selected_index = point_index orelse return null;
|
|
1178
1178
|
const selected_widget = self.widget_layout_nodes[selected_index].widget;
|
|
1179
|
-
const focus = selected_widget.static_text_group_offset + point_offset;
|
|
1179
|
+
const focus = @as(usize, @intCast(selected_widget.static_text_group_offset)) + point_offset;
|
|
1180
1180
|
const anchor = if (extend)
|
|
1181
1181
|
self.canvas_widget_selected_text_group_anchor
|
|
1182
1182
|
else
|
|
@@ -1191,7 +1191,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1191
1191
|
if (candidate.static_text_group_id != group_id) {
|
|
1192
1192
|
continue;
|
|
1193
1193
|
}
|
|
1194
|
-
const source_start = candidate.static_text_group_offset;
|
|
1194
|
+
const source_start: usize = @intCast(candidate.static_text_group_offset);
|
|
1195
1195
|
const source_end = source_start +| candidate.text.len;
|
|
1196
1196
|
const next_selection: ?canvas.TextSelection = if (selection_start == selection_end)
|
|
1197
1197
|
if (candidate_index == selected_index)
|
|
@@ -1321,7 +1321,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1321
1321
|
if (widget.static_text_group_id != group_id) {
|
|
1322
1322
|
continue;
|
|
1323
1323
|
}
|
|
1324
|
-
const source_start = widget.static_text_group_offset;
|
|
1324
|
+
const source_start: usize = @intCast(widget.static_text_group_offset);
|
|
1325
1325
|
const source_end = source_start +| widget.text.len;
|
|
1326
1326
|
const copy_start = @max(start, source_start);
|
|
1327
1327
|
const copy_end = @min(end, source_end);
|
|
@@ -1378,7 +1378,9 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1378
1378
|
self.widget_layout_nodes[edited_index].widget.text_selection = next_state.selection;
|
|
1379
1379
|
self.widget_layout_nodes[edited_index].widget.text_composition = next_state.composition;
|
|
1380
1380
|
if (text_changed) {
|
|
1381
|
-
self.widget_layout_nodes[edited_index].widget.
|
|
1381
|
+
if (!self.widget_layout_nodes[edited_index].widget.hasCodeDiff()) {
|
|
1382
|
+
self.widget_layout_nodes[edited_index].widget.code_content_width_generation = 0;
|
|
1383
|
+
}
|
|
1382
1384
|
canvas.cacheTextInputContentWidthForWidget(
|
|
1383
1385
|
&self.widget_layout_nodes[edited_index].widget,
|
|
1384
1386
|
self.widget_tokens,
|
|
@@ -484,6 +484,7 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
|
|
|
484
484
|
.transparent = options.transparent,
|
|
485
485
|
.bridge_enabled = options.bridge_enabled,
|
|
486
486
|
.gpu_size = if (options.kind == .gpu_surface) options.frame.size() else geometry.SizeF.init(0, 0),
|
|
487
|
+
.gpu_requested_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
487
488
|
.gpu_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
488
489
|
.gpu_pixel_format = if (options.kind == .gpu_surface) options.gpu_surface.pixel_format else .none,
|
|
489
490
|
.gpu_present_mode = if (options.kind == .gpu_surface) options.gpu_surface.present_mode else .none,
|
|
@@ -1199,7 +1199,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1199
1199
|
\\ runs-on: ubuntu-latest
|
|
1200
1200
|
\\ steps:
|
|
1201
1201
|
\\ - uses: actions/checkout@v4
|
|
1202
|
-
\\ - uses:
|
|
1202
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1203
1203
|
\\ with:
|
|
1204
1204
|
\\ version: 0.16.0
|
|
1205
1205
|
\\
|
|
@@ -1222,7 +1222,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1222
1222
|
\\ runs-on: ubuntu-latest
|
|
1223
1223
|
\\ steps:
|
|
1224
1224
|
\\ - uses: actions/checkout@v4
|
|
1225
|
-
\\ - uses:
|
|
1225
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1226
1226
|
\\ with:
|
|
1227
1227
|
\\ version: 0.16.0
|
|
1228
1228
|
\\
|
|
@@ -1298,7 +1298,7 @@ fn frontendCiYaml(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
|
|
|
1298
1298
|
\\ runs-on: ubuntu-latest
|
|
1299
1299
|
\\ steps:
|
|
1300
1300
|
\\ - uses: actions/checkout@v4
|
|
1301
|
-
\\ - uses:
|
|
1301
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1302
1302
|
\\ with:
|
|
1303
1303
|
\\ version: 0.16.0
|
|
1304
1304
|
\\ - name: Fetch native-sdk
|
|
@@ -1829,10 +1829,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1829
1829
|
\\ app_mod.addLibraryPath(b.path(b.fmt("{s}/Release", .{cef_dir})));
|
|
1830
1830
|
\\ },
|
|
1831
1831
|
\\ }
|
|
1832
|
+
\\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/windows/gpu_surface_renderer.cpp"), .flags = &.{ "-std=c++17" } });
|
|
1832
1833
|
\\ app_mod.linkSystemLibrary("c", .{});
|
|
1833
1834
|
\\ app_mod.linkSystemLibrary("c++", .{});
|
|
1834
1835
|
\\ app_mod.linkSystemLibrary("user32", .{});
|
|
1835
1836
|
\\ app_mod.linkSystemLibrary("gdi32", .{});
|
|
1837
|
+
\\ app_mod.linkSystemLibrary("d2d1", .{});
|
|
1838
|
+
\\ app_mod.linkSystemLibrary("dwrite", .{});
|
|
1836
1839
|
\\ app_mod.linkSystemLibrary("imm32", .{});
|
|
1837
1840
|
\\ app_mod.linkSystemLibrary("comctl32", .{});
|
|
1838
1841
|
\\ app_mod.linkSystemLibrary("ole32", .{});
|
|
@@ -3924,7 +3927,7 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3924
3927
|
defer std.testing.allocator.free(ci_yaml_text);
|
|
3925
3928
|
try expectBasicYaml(ci_yaml_text);
|
|
3926
3929
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null -Dnative-sdk-path=\"$NATIVE_SDK_PATH\"") != null);
|
|
3927
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
3930
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
3928
3931
|
// Web-frontend workflows stop at logic tests: the automation smoke
|
|
3929
3932
|
// recipe is native-app specific.
|
|
3930
3933
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "smoke:") == null);
|
|
@@ -4163,7 +4166,7 @@ test "writeDefaultApp --full ts-core emits a CI workflow with the node tier" {
|
|
|
4163
4166
|
// automation smoke, no WebKitGTK for a native-rendered app.
|
|
4164
4167
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " test:") != null);
|
|
4165
4168
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " smoke:") != null);
|
|
4166
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
4169
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
4167
4170
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
|
|
4168
4171
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libgtk-4-dev xvfb") != null);
|
|
4169
4172
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libwebkitgtk-6.0-dev") == null);
|
|
@@ -4190,7 +4193,7 @@ test "writeDefaultApp emits a CI workflow for native apps" {
|
|
|
4190
4193
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "jobs:") != null);
|
|
4191
4194
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " test:") != null);
|
|
4192
4195
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " smoke:") != null);
|
|
4193
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
4196
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
4194
4197
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "version: 0.16.0") != null);
|
|
4195
4198
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
|
|
4196
4199
|
// The smoke job builds with automation, launches under Xvfb, and drives
|