← All issues

[HDR] Introduce GainMap and ShareableGainMap

ff6f5a8

Source/WebCore/platform/graphics/cocoa/ShareableGainMap.cpp

+RetainPtr<CGImageRef> ShareableGainMap::applyGainMapToBaseImage(CGImageRef baseImage) const
+{
+ auto basePixelBuffer = createMetalCompatibleCVPixelBufferFromImage(baseImage);
+ if (!basePixelBuffer) return nullptr;
+ auto outputPixelBuffer = createScratchMetalCompatibleCVPixelBuffer(*basePixelBuffer);
+ if (!outputPixelBuffer) return nullptr;
+ OSStatus status = CGImageApplyHDRGainMap(basePixelBuffer.get(), m_gainMapPixelBuffer.get(), outputPixelBuffer.get(), nullptr);
+ if (status) return nullptr;
+ return createCGImageFromCVPixelBuffer(outputPixelBuffer.get());
+}

WebKit's GPU process model isolates rendering from web content; ShareableBitmap is the shared-memory primitive used to pass rasterized image data across the boundary. CVPixelBuffer is a CoreVideo reference-counted pixel buffer type. ISO gain maps (standardized in HEIF/JPEG-XL) encode per-pixel HDR headroom as auxiliary image layers; Apple's private CGImageApplyHDRGainMap SPI composites them onto a base image via Metal. This commit threads GainMap (CVPixelBuffer + metadata + colorSpace) through NativeImage and ShareableBitmapConfiguration, with ShareableBitmap::createPlatformImage() conditionally invoking the SPI in the GPU process.

This lays cross-process plumbing for HDR rendering, introducing new IPC-serialized CVPixelBuffer data flowing from WebProcess into the GPU process — a new attack surface with pixel-buffer lifetime management and private SPI invocation passing a null options dict.

🔒

New cross-process pixel-buffer and metadata paths feed private SPI — edge cases in dimension validation and lifetime handling are worth auditing.

Subscribe to read more