Skip to content

Feature: Add MauiZenithView for iOS and MacCatalyst#17

Merged
qian-o merged 15 commits intomasterfrom
feature/maui-apple-platform-views
Jan 31, 2026
Merged

Feature: Add MauiZenithView for iOS and MacCatalyst#17
qian-o merged 15 commits intomasterfrom
feature/maui-apple-platform-views

Conversation

@qian-o
Copy link
Owner

@qian-o qian-o commented Jan 31, 2026

This pull request refactors the handling of color and depth-stencil formats throughout the Zenith.NET view implementations for Avalonia, MAUI (Android, iOS, MacCatalyst, Windows), WPF, WinForms, and WinUI. The main change is to centralize format selection using the new ZenithViewHelper.ColorFormat and ZenithViewHelper.DepthStencilFormat properties, replacing hardcoded pixel formats. This enables easier support for multiple formats and improves maintainability and platform consistency. Additionally, helper methods are added to map internal formats to platform-specific representations, and several platform view classes are streamlined by removing redundant static Output properties.

Centralized Format Selection

  • Replaced hardcoded color and depth-stencil formats in texture and swap chain creation with ZenithViewHelper.ColorFormat and ZenithViewHelper.DepthStencilFormat across all supported platforms (Surface.cs, MauiZenithView.cs, D3DTexture.cs, ZenithView.Uno.cs, etc.). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Platform-Specific Format Mapping

  • Added helper methods (e.g., ColorFormat()) in platform-specific files to convert ZenithViewHelper.ColorFormat to the appropriate pixel format for Avalonia, Direct3D, DXGI, etc., with error handling for unsupported formats. [1] [2] [3]

Removal of Redundant Static Output Properties

  • Removed static Output properties from view classes for all platforms (Avalonia, MAUI, WPF, WinForms), as format selection is now handled dynamically through ZenithViewHelper. [1] [2] [3] [4] [5] [6]

Platform View Refactoring and Improvements

  • Refactored MAUI and iOS/MacCatalyst view classes to properly manage swap chain lifecycle, handle resource resizing, and implement Metal layer support for Apple platforms. [1] [2]
  • Updated WinUI pixel buffer writing logic to handle both supported formats and throw an exception for unsupported ones.

Version Bump

  • Updated the NuGet package version from 0.0.4 to 0.0.5 in NuGet.Packaging.props.

qian-o added 15 commits January 31, 2026 13:07
Added a new .NET MAUI project, Sandbox.Maui, targeting Android, iOS, MacCatalyst, and Windows. The project demonstrates integration of Zenith.NET graphics rendering within a MAUI UI, including a sample page with a counter and a ZenithView. Platform-specific startup/configuration files, app icons, splash screens, images, and fonts were included. Added resource dictionaries for colors and styles, and documentation for asset management. Project references to Zenith.NET graphics backends and Zenith.NET.Views.Maui were established.
Changed render pass options to clear all buffers by setting
Depth to 1.0, Stencil to 0, and Flags to ClearFlags.All,
ensuring color, depth, and stencil buffers are cleared at
the start of each render pass.
Implement CAMetalLayer and swapchain management for MauiZenithView on both iOS and MacCatalyst. This includes dynamic swapchain creation, resizing, and presentation, as well as updated pixel formats for color and depth-stencil attachments. Rendering is now performed only when the graphics context and view size are valid, improving resource management and enabling efficient Metal-based rendering.
Added using directives for Foundation and ObjCRuntime in MauiZenithView.cs to enable access to Apple platform-specific types and functionality. This prepares the file for features or integrations that rely on these namespaces.
Removed OS-specific graphics context selection in App.xaml.cs to always use Vulkan. Added animated HSV color gradient background in MainPage.xaml.cs by incrementing hue on each render and converting HSV to Vector4. Added System.Numerics import for Vector4 support.
Deleted the entire Sandbox.Maui experimental MAUI application, including its project file, source code, platform-specific files, resources, and configuration. Also removed its reference from the solution file. This cleans up the repository by eliminating the MAUI sample app and all associated assets.
The XML declaration at the top of Zenith.NET.slnx was removed or replaced. No changes were made to the solution structure or project references.
Centralize color and depth/stencil pixel format selection in a new ZenithViewHelper class, replacing hardcoded formats throughout the codebase. Update all platform backends to use these helper properties, add conversion utilities as needed, and adjust Uno backend stream writing for correct byte order. This improves consistency, maintainability, and cross-platform support.
Replace static Convert methods with ColorFormat(), which uses ZenithViewHelper.ColorTargetFormat directly. This centralizes and simplifies color/pixel format handling for surfaces and textures, and updates error messages to reference the global format.
Moved property initialization for ColorTargetFormat and DepthStencilTargetFormat from the static constructor to inline expression-bodied properties. This removes the need for a static constructor and improves code clarity and conciseness.
Updated the package version from 0.0.4 to 0.0.5 in NuGet.Packaging.props. No other metadata or configuration changes were made.
Renamed `ColorTargetFormat` to `ColorFormat` and
`DepthStencilTargetFormat` to `DepthStencilFormat` in
`ZenithViewHelper`. Updated all usages across the codebase,
including texture creation, swap chain setup, pixel format
switching, and output configuration. This improves naming
consistency and makes the property names more descriptive.
Updated EnsureResources to validate both width and height are non-zero before proceeding, correcting a previous logic error. Also added a missing closing brace to properly terminate the MauiZenithView class.
Simplified the loop structure for handling PixelFormat.R8G8B8A8UNorm by removing a redundant outer loop. Now, pixel data is written per row with a single loop over x inside the y loop, improving clarity without changing the pixel writing logic.
Refactored the LayerClass method to use C# target-typed new
for creating the Class object, improving code conciseness and
readability. No functional changes were made.
Copy link
Owner Author

@qian-o qian-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

@qian-o qian-o merged commit bbf6c5b into master Jan 31, 2026
2 checks passed
@qian-o qian-o deleted the feature/maui-apple-platform-views branch January 31, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant