You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/WebGPUExternalSurfaceDemo/README.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
-
# WebGPU Hosted Surface Demo
1
+
# WebGPU External Surface Demo
2
2
3
-
`WebGPUHostedSurfaceDemo` shows how to render ImageSharp.Drawing content into a UI object owned by an application framework. The sample uses a WinForms `Control`, but the API shape is intended for any externally-owned native drawable host.
3
+
`WebGPUExternalSurfaceDemo` shows how to render ImageSharp.Drawing content into a UI object owned by an application framework. The sample uses a WinForms `Control`, but the API shape is intended for any externally-owned native drawable host.
4
4
5
5
It exists to demonstrate:
6
6
7
-
- creating a `WebGPUHostedSurface<Bgra32>` from a `WebGPUSurfaceHost`
8
-
- keeping the hosted surface synchronized with the host control's drawable framebuffer size
7
+
- creating a `WebGPUExternalSurface<Bgra32>` from a `WebGPUSurfaceHost`
8
+
- keeping the external surface synchronized with the host control's drawable framebuffer size
- drawing with the normal `DrawingCanvas<TPixel>` API
11
11
- presenting by disposing the acquired frame
12
12
13
13
## Running
14
14
15
15
```bash
16
-
dotnet run --project samples/WebGPUHostedSurfaceDemo -c Debug
16
+
dotnet run --project samples/WebGPUExternalSurfaceDemo -c Debug
17
17
```
18
18
19
19
Requirements:
@@ -27,11 +27,11 @@ When the sample starts you should see a WinForms window with three tabs:
27
27
28
28
-`Clock`: a continuously-rendered animated clock scene
29
29
-`Tiger`: an interactive SVG tiger viewer with pan and zoom
30
-
-`Apply`: a reactive hosted-surface readback scene using `DrawingCanvas.Apply(...)`; move the mouse to move the edge-detect and blur regions, and use the mouse wheel to resize them
30
+
-`Apply`: a reactive external-surface readback scene using `DrawingCanvas.Apply(...)`; move the mouse to move the edge-detect and blur regions, and use the mouse wheel to resize them
31
31
32
32
## Why This Sample Matters
33
33
34
-
`WebGPUWindow<TPixel>` owns a top-level native window. `WebGPUHostedSurface<TPixel>` is different: it attaches WebGPU rendering to something the application already owns, such as a control, view, widget, or native surface.
34
+
`WebGPUWindow<TPixel>` owns a top-level native window. `WebGPUExternalSurface<TPixel>` is different: it attaches WebGPU rendering to something the application already owns, such as a control, view, widget, or native surface.
35
35
36
36
That makes it the integration path for UI frameworks. The host owns:
37
37
@@ -40,7 +40,7 @@ That makes it the integration path for UI frameworks. The host owns:
40
40
- layout and resize events
41
41
- input events
42
42
43
-
The hosted surface owns:
43
+
The external surface owns:
44
44
45
45
- the WebGPU surface created for that host
46
46
- swapchain configuration
@@ -50,25 +50,25 @@ The hosted surface owns:
50
50
51
51
## Code Tour
52
52
53
-
The reusable integration point is [WebGPURenderControl.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Controls/WebGPURenderControl.cs).
53
+
The reusable integration point is [WebGPURenderControl.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Controls/WebGPURenderControl.cs).
54
54
55
55
### Surface Creation
56
56
57
-
`WebGPURenderControl.OnHandleCreated(...)` creates the hosted surface from the WinForms control handle:
57
+
`WebGPURenderControl.OnHandleCreated(...)` creates the external surface from the WinForms control handle:
`WebGPUSurfaceHost` is a small public descriptor for externally-owned native handles. The host keeps ownership of those handles; `WebGPUHostedSurface<TPixel>` only uses them to create and manage the WebGPU rendering surface.
67
+
`WebGPUSurfaceHost` is a small public descriptor for externally-owned native handles. The host keeps ownership of those handles; `WebGPUExternalSurface<TPixel>` only uses them to create and manage the WebGPU rendering surface.
68
68
69
69
### Resize
70
70
71
-
`WebGPUHostedSurface<TPixel>.Resize(...)` expects the drawable framebuffer size in pixels:
71
+
`WebGPUExternalSurface<TPixel>.Resize(...)` expects the drawable framebuffer size in pixels:
72
72
73
73
```csharp
74
74
this.framebufferSize=this.ClientSize;
@@ -103,13 +103,13 @@ Frame pacing is delegated to the present mode. With the default `WebGPUPresentMo
103
103
104
104
## Scene Code
105
105
106
-
[MainForm.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/MainForm.cs) creates independent `WebGPURenderControl` instances, one per tab. Each control owns its own hosted surface.
106
+
[MainForm.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/MainForm.cs) creates independent `WebGPURenderControl` instances, one per tab. Each control owns its own external surface.
-[TigerViewerScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/TigerViewerScene.cs): pan and zoom SVG tiger viewer
112
-
-[ApplyReadbackScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/ApplyReadbackScene.cs): `Apply(...)` scene that reads the hosted surface back into CPU processing
-[TigerViewerScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/TigerViewerScene.cs): pan and zoom SVG tiger viewer
112
+
-[ApplyReadbackScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/ApplyReadbackScene.cs): `Apply(...)` scene that reads the external surface back into CPU processing
113
113
114
114
Each scene receives:
115
115
@@ -119,9 +119,9 @@ Each scene receives:
119
119
120
120
## Files
121
121
122
-
-[WebGPURenderControl.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Controls/WebGPURenderControl.cs): reusable WinForms hosted-surface control
123
-
-[MainForm.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/MainForm.cs): tabs and scene wiring
124
-
-[ClockScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/ClockScene.cs): clock scene
125
-
-[TigerViewerScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/TigerViewerScene.cs): tiger viewer scene
126
-
-[ApplyReadbackScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/ApplyReadbackScene.cs): apply readback scene
-[WebGPURenderControl.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Controls/WebGPURenderControl.cs): reusable WinForms external-surface control
123
+
-[MainForm.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/MainForm.cs): tabs and scene wiring
124
+
-[ClockScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/ClockScene.cs): clock scene
125
+
-[TigerViewerScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/TigerViewerScene.cs): tiger viewer scene
126
+
-[ApplyReadbackScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/ApplyReadbackScene.cs): apply readback scene
0 commit comments