Skip to content

Commit 66b9e71

Browse files
Rename HostedSurface to ExternalSurface
1 parent 654b96b commit 66b9e71

17 files changed

Lines changed: 69 additions & 69 deletions

WinFormsSamples.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Drawing.WebGPU.S
1515
EndProject
1616
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawingBackendBenchmark", "samples\DrawingBackendBenchmark\DrawingBackendBenchmark.csproj", "{0AF23A97-CD73-409A-AA29-D214AA400AB0}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebGPUHostedSurfaceDemo", "samples\WebGPUHostedSurfaceDemo\WebGPUHostedSurfaceDemo.csproj", "{478855A1-ECEA-4DF6-9D7B-0342EA26726E}"
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebGPUExternalSurfaceDemo", "samples\WebGPUExternalSurfaceDemo\WebGPUExternalSurfaceDemo.csproj", "{478855A1-ECEA-4DF6-9D7B-0342EA26726E}"
1919
EndProject
2020
Global
2121
GlobalSection(SolutionConfigurationPlatforms) = preSolution

samples/WebGPUHostedSurfaceDemo/Controls/WebGPURenderControl.cs renamed to samples/WebGPUExternalSurfaceDemo/Controls/WebGPURenderControl.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
using SixLabors.ImageSharp.PixelFormats;
99
using ImageSharpSize = SixLabors.ImageSharp.Size;
1010

11-
namespace WebGPUHostedSurfaceDemo.Controls;
11+
namespace WebGPUExternalSurfaceDemo.Controls;
1212

1313
/// <summary>
14-
/// A reusable WinForms control that embeds a <see cref="WebGPUHostedSurface{TPixel}"/> and drives a continuous
14+
/// A reusable WinForms control that embeds a <see cref="WebGPUExternalSurface{TPixel}"/> and drives a continuous
1515
/// render loop via <see cref="Application.Idle"/>. Callers hook <see cref="PaintFrame"/> with their scene logic;
1616
/// the control handles construction, resize, acquire/present, and teardown.
1717
/// </summary>
@@ -20,7 +20,7 @@ public sealed partial class WebGPURenderControl : Control
2020
private const int WM_MOVING = 0x0216;
2121
private const int WM_EXITSIZEMOVE = 0x0232;
2222

23-
private WebGPUHostedSurface<Bgra32>? surface;
23+
private WebGPUExternalSurface<Bgra32>? surface;
2424
private Size framebufferSize;
2525
private bool idleHooked;
2626
private long lastTicks;
@@ -44,7 +44,7 @@ public WebGPURenderControl()
4444
}
4545

4646
/// <summary>
47-
/// Raised each frame once the hosted surface has acquired a drawable frame. The canvas dimensions match
47+
/// Raised each frame once the external surface has acquired a drawable frame. The canvas dimensions match
4848
/// <see cref="FramebufferSize"/>.
4949
/// </summary>
5050
public event Action<DrawingCanvas<Bgra32>, TimeSpan>? PaintFrame;
@@ -59,7 +59,7 @@ protected override void OnHandleCreated(EventArgs e)
5959
{
6060
base.OnHandleCreated(e);
6161

62-
// A hosted surface can only be created once the native HWND exists. The surface borrows the HWND;
62+
// An external surface can only be created once the native HWND exists. The surface borrows the HWND;
6363
// WinForms still owns the control, handle lifetime, and layout.
6464
// WinForms ClientSize is the HWND client rectangle size; pass it through as the drawable framebuffer size.
6565
this.framebufferSize = this.ClientSize;
@@ -69,7 +69,7 @@ protected override void OnHandleCreated(EventArgs e)
6969

7070
// The module handle is required by the Win32 surface descriptor. It identifies the process module
7171
// that owns the window class backing this control.
72-
this.surface = new WebGPUHostedSurface<Bgra32>(
72+
this.surface = new WebGPUExternalSurface<Bgra32>(
7373
WebGPUSurfaceHost.Win32(
7474
this.Handle,
7575
Marshal.GetHINSTANCE(typeof(WebGPURenderControl).Module)),

samples/WebGPUHostedSurfaceDemo/MainForm.cs renamed to samples/WebGPUExternalSurfaceDemo/MainForm.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
using SixLabors.ImageSharp.Drawing.Processing;
55
using SixLabors.ImageSharp.PixelFormats;
6-
using WebGPUHostedSurfaceDemo.Controls;
7-
using WebGPUHostedSurfaceDemo.Scenes;
6+
using WebGPUExternalSurfaceDemo.Controls;
7+
using WebGPUExternalSurfaceDemo.Scenes;
88

9-
namespace WebGPUHostedSurfaceDemo;
9+
namespace WebGPUExternalSurfaceDemo;
1010

1111
/// <summary>
12-
/// Main window for the sample. A tab control switches between demo scenes, each hosted by its own
13-
/// <see cref="WebGPURenderControl"/> instance. This demonstrates that multiple independent hosted surfaces
12+
/// Main window for the sample. A tab control switches between demo scenes, each displayed in its own
13+
/// <see cref="WebGPURenderControl"/> instance. This demonstrates that multiple independent external surfaces
1414
/// can coexist in the same WinForms process without managing surfaces or swapchains in user code.
1515
/// </summary>
1616
internal sealed class MainForm : Form
@@ -25,7 +25,7 @@ internal sealed class MainForm : Form
2525

2626
public MainForm()
2727
{
28-
this.Text = "ImageSharp.Drawing WebGPU - Hosted Surface Demo";
28+
this.Text = "ImageSharp.Drawing WebGPU - External Surface Demo";
2929
this.ClientSize = new Size(1280, 800);
3030
this.StartPosition = FormStartPosition.CenterScreen;
3131
this.BackColor = Color.FromArgb(11, 18, 32);
@@ -34,7 +34,7 @@ public MainForm()
3434
this.tigerScene = new TigerViewerScene();
3535
this.applyScene = new ApplyReadbackScene();
3636

37-
// Each tab gets its own render control and hosted surface. This mirrors real UI applications where
37+
// Each tab gets its own render control and external surface. This mirrors real UI applications where
3838
// separate controls or panels own their own native drawable areas.
3939
this.clockControl = new WebGPURenderControl { Dock = DockStyle.Fill };
4040
this.clockControl.PaintFrame += this.OnPaintClock;
File renamed without changes.

samples/WebGPUHostedSurfaceDemo/Program.cs renamed to samples/WebGPUExternalSurfaceDemo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
namespace WebGPUHostedSurfaceDemo;
4+
namespace WebGPUExternalSurfaceDemo;
55

66
/// <summary>
7-
/// Entry point for the hosted WebGPU surface sample.
7+
/// Entry point for the external WebGPU surface sample.
88
/// </summary>
99
internal static class Program
1010
{

samples/WebGPUHostedSurfaceDemo/Properties/AssemblyInfo.cs renamed to samples/WebGPUExternalSurfaceDemo/Properties/AssemblyInfo.cs

File renamed without changes.

samples/WebGPUHostedSurfaceDemo/README.md renamed to samples/WebGPUExternalSurfaceDemo/README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# WebGPU Hosted Surface Demo
1+
# WebGPU External Surface Demo
22

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.
44

55
It exists to demonstrate:
66

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
99
- acquiring `WebGPUSurfaceFrame<TPixel>` instances manually
1010
- drawing with the normal `DrawingCanvas<TPixel>` API
1111
- presenting by disposing the acquired frame
1212

1313
## Running
1414

1515
```bash
16-
dotnet run --project samples/WebGPUHostedSurfaceDemo -c Debug
16+
dotnet run --project samples/WebGPUExternalSurfaceDemo -c Debug
1717
```
1818

1919
Requirements:
@@ -27,11 +27,11 @@ When the sample starts you should see a WinForms window with three tabs:
2727

2828
- `Clock`: a continuously-rendered animated clock scene
2929
- `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
3131

3232
## Why This Sample Matters
3333

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.
3535

3636
That makes it the integration path for UI frameworks. The host owns:
3737

@@ -40,7 +40,7 @@ That makes it the integration path for UI frameworks. The host owns:
4040
- layout and resize events
4141
- input events
4242

43-
The hosted surface owns:
43+
The external surface owns:
4444

4545
- the WebGPU surface created for that host
4646
- swapchain configuration
@@ -50,25 +50,25 @@ The hosted surface owns:
5050

5151
## Code Tour
5252

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).
5454

5555
### Surface Creation
5656

57-
`WebGPURenderControl.OnHandleCreated(...)` creates the hosted surface from the WinForms control handle:
57+
`WebGPURenderControl.OnHandleCreated(...)` creates the external surface from the WinForms control handle:
5858

5959
```csharp
60-
this.surface = new WebGPUHostedSurface<Bgra32>(
60+
this.surface = new WebGPUExternalSurface<Bgra32>(
6161
WebGPUSurfaceHost.Win32(
6262
this.Handle,
6363
Marshal.GetHINSTANCE(typeof(WebGPURenderControl).Module)),
6464
initialFramebufferSize);
6565
```
6666

67-
`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.
6868

6969
### Resize
7070

71-
`WebGPUHostedSurface<TPixel>.Resize(...)` expects the drawable framebuffer size in pixels:
71+
`WebGPUExternalSurface<TPixel>.Resize(...)` expects the drawable framebuffer size in pixels:
7272

7373
```csharp
7474
this.framebufferSize = this.ClientSize;
@@ -103,13 +103,13 @@ Frame pacing is delegated to the present mode. With the default `WebGPUPresentMo
103103

104104
## Scene Code
105105

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.
107107

108108
The scenes are deliberately ordinary canvas code:
109109

110-
- [ClockScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/Scenes/ClockScene.cs): animated vector clock
111-
- [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
110+
- [ClockScene.cs](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/Scenes/ClockScene.cs): animated vector clock
111+
- [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
113113

114114
Each scene receives:
115115

@@ -119,9 +119,9 @@ Each scene receives:
119119

120120
## Files
121121

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
127-
- [WebGPUHostedSurfaceDemo.csproj](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUHostedSurfaceDemo/WebGPUHostedSurfaceDemo.csproj): sample project file
122+
- [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
127+
- [WebGPUExternalSurfaceDemo.csproj](d:/GitHub/SixLabors/ImageSharp.Drawing/samples/WebGPUExternalSurfaceDemo/WebGPUExternalSurfaceDemo.csproj): sample project file

samples/WebGPUHostedSurfaceDemo/Scenes/ApplyReadbackScene.cs renamed to samples/WebGPUExternalSurfaceDemo/Scenes/ApplyReadbackScene.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
using Size = SixLabors.ImageSharp.Size;
1515
using SizeF = SixLabors.ImageSharp.SizeF;
1616

17-
namespace WebGPUHostedSurfaceDemo.Scenes;
17+
namespace WebGPUExternalSurfaceDemo.Scenes;
1818

1919
/// <summary>
20-
/// Hosted-surface scene that exercises canvas readback by applying CPU image processors to regions of the current frame.
20+
/// External surface scene that exercises canvas readback by applying CPU image processors to regions of the current frame.
2121
/// Pointer movement changes the processed regions so readback cost can be assessed interactively.
2222
/// </summary>
2323
internal sealed class ApplyReadbackScene : RenderScene

samples/WebGPUHostedSurfaceDemo/Scenes/ClockScene.cs renamed to samples/WebGPUExternalSurfaceDemo/Scenes/ClockScene.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using SystemFonts = SixLabors.Fonts.SystemFonts;
2121
using VerticalAlignment = SixLabors.Fonts.VerticalAlignment;
2222

23-
namespace WebGPUHostedSurfaceDemo.Scenes;
23+
namespace WebGPUExternalSurfaceDemo.Scenes;
2424

2525
/// <summary>
2626
/// Animated analog clock. Validates continuous render, curves, thin-stroke antialiasing, text rendering,

samples/WebGPUHostedSurfaceDemo/Scenes/RenderScene.cs renamed to samples/WebGPUExternalSurfaceDemo/Scenes/RenderScene.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using SixLabors.ImageSharp.PixelFormats;
66
using Size = SixLabors.ImageSharp.Size;
77

8-
namespace WebGPUHostedSurfaceDemo.Scenes;
8+
namespace WebGPUExternalSurfaceDemo.Scenes;
99

1010
/// <summary>
1111
/// Base class for a demo scene rendered into a <see cref="WebGPURenderControl"/>.
@@ -21,7 +21,7 @@ internal abstract class RenderScene
2121
/// <summary>
2222
/// Draws the scene into <paramref name="canvas"/> for the current frame.
2323
/// </summary>
24-
/// <param name="canvas">The per-frame drawing canvas bound to the hosted surface's swap-chain texture.</param>
24+
/// <param name="canvas">The per-frame drawing canvas bound to the external surface's swap-chain texture.</param>
2525
/// <param name="viewportSize">The framebuffer size in pixels.</param>
2626
/// <param name="deltaTime">Elapsed time since the previous frame. Scenes that render from absolute state can ignore it.</param>
2727
public abstract void Paint(DrawingCanvas<Bgra32> canvas, Size viewportSize, TimeSpan deltaTime);

0 commit comments

Comments
 (0)