Add Windows platform adapters, a pinned MinGW desktop renderer artifact, and private Wine pixel/service/audio tests. Share raster and window code while selecting native process and library-loading modules per OS. Pin the public WebP native function-table export for dynamic decoding. Local tests: windows-desktop-host-test, desktop-windows-test, desktop-audio-test, native-text-test, native-accessibility-test, image-pixels-test, pay-per-import-test and push-check passed. Strict dynamic image source/saved IR passed ASan, UBSan and leak detection. The stock frame-entry C pruning and Windows ZX external-host gaps remain upstream in step 6. Full make test separately stops at ZX packed media. This checkpoint does not include consumer ports or macOS builds. Signed-off-by: Waozi <[email protected]>
40 lines
2.0 KiB
Ziran
40 lines
2.0 KiB
Ziran
Decode :: #import "image_decode_desktop";
|
|
c :: #system_library "libc";
|
|
Allocate :: (size: usize) -> *void #foreign c "malloc";
|
|
Free :: (memory: *void) #foreign c "free";
|
|
#import "std/byte_text_linux"
|
|
#import "text_tools"
|
|
|
|
// The WebP fixture's ARGB32 pixel at index, or 0 when it does not decode.
|
|
WebPPixel :: (directory: string, name: string, index: s32, width: s32, height: s32) -> u32 {
|
|
parts: [4]string = .[directory, "/", name, ".webp"]
|
|
image := Decode.OpenWebP(TextJoin(parts[:], ""))
|
|
if image.pixels == null { return 0 }; defer { Decode.CloseWebP(image) }
|
|
if image.width != width || image.height != height { return 1 }
|
|
pixels: [256]u32
|
|
if !Decode.CopyWebP(image, cast(*u8)*pixels[0], width * 4) { return 2 }
|
|
return pixels[index]
|
|
}
|
|
|
|
main :: (argc: s32, argv: **u8) -> s32 {
|
|
if argc != 3 { return 2 }
|
|
webp := TextFromCString(argv[2])
|
|
// Straight RGBA becomes premultiplied ARGB32; animations keep frame one.
|
|
if WebPPixel(webp, "lossless", 0, 3, 2) != cast(u32)0xff0a141e ||
|
|
WebPPixel(webp, "lossless", 3, 3, 2) != cast(u32)0x8032373c ||
|
|
WebPPixel(webp, "animated", 9, 8, 8) != cast(u32)0xfffac800 ||
|
|
WebPPixel(webp, "lossy-alpha", 8 * 16 + 13, 16, 16) >> 24 != cast(u32)64 ||
|
|
WebPPixel(webp, "lossy", 8 * 16 + 2, 16, 16) >> 24 != cast(u32)255 {
|
|
print("WebP through the system libwebp failed\n"); return 8
|
|
}
|
|
image := Decode.OpenImage(argv[1])
|
|
if image == null { return 3 }; defer { Decode.CloseImage(image) }
|
|
if Decode.Width(image) != 5000 || Decode.Height(image) != 1000 { print("Large original was reduced\n"); return 4 }
|
|
data := Allocate(20000000); if data == null { return 5 }; defer { Free(data) }
|
|
if !Decode.CopyPixels(image, cast(*u8)data, 20000) { return 6 }
|
|
pixels := cast(*u32)data
|
|
if pixels[0] != cast(u32)0xff00c800 || pixels[300 * 5000 + 4500] != cast(u32)0x80640000 { print("Original pixels or alpha changed\n"); return 7 }
|
|
print("Full-resolution 5000-pixel original, premultiplied alpha and WebP passed without a display\n")
|
|
return 0
|
|
}
|