LibGfx: Ensure sk_image is available in ::export_to_byte_buffer()

When an ImmutableBitmap is constructed from video data, there's a
probability that we're dealing with YUV data and we do not yet have an
sk_image to work with.

No regression test since we require a GPU to end up in this situation.

Fixes the background scenery on https://screen.toys/roadtrip/.
This commit is contained in:
Jelle Raaijmakers
2026-04-15 09:47:56 +02:00
committed by Gregory Bertilson
parent 7669854ddc
commit b2e0a2515a
Notes: github-actions[bot] 2026-04-15 22:09:11 +00:00

View File

@@ -125,6 +125,9 @@ static SkColorType export_format_to_skia_color_type(ExportFormat format)
ErrorOr<BitmapExportResult> ImmutableBitmap::export_to_byte_buffer(ExportFormat format, int flags, Optional<int> target_width, Optional<int> target_height) const
{
if (SkiaBackendContext::the() && !ensure_sk_image(*SkiaBackendContext::the()))
return Error::from_string_literal("Failed to create a Skia image for this ImmutableBitmap");
int width = target_width.value_or(this->width());
int height = target_height.value_or(this->height());