mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb/WebGL: Don't attempt to do texture transforms on an empty texture
Skia will not give us a surface if the width or height is zero.
This commit is contained in:
parent
b0e02af040
commit
3ca4ff6037
|
|
@ -165,13 +165,14 @@ Optional<WebGLRenderingContextBase::ConvertedTexture> WebGLRenderingContextBase:
|
|||
|
||||
auto buffer = MUST(ByteBuffer::create_zeroed(buffer_pitch.value() * height));
|
||||
|
||||
auto skia_format = opengl_format_and_type_to_skia_color_type(format, type);
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
// FIXME: Respect UNPACK_PREMULTIPLY_ALPHA_WEBGL
|
||||
// FIXME: Respect unpackColorSpace
|
||||
auto skia_format = opengl_format_and_type_to_skia_color_type(format, type);
|
||||
auto color_space = SkColorSpace::MakeSRGB();
|
||||
auto image_info = SkImageInfo::Make(width, height, skia_format, SkAlphaType::kPremul_SkAlphaType, color_space);
|
||||
auto surface = SkSurfaces::WrapPixels(image_info, buffer.data(), buffer_pitch.value());
|
||||
VERIFY(surface);
|
||||
auto surface_canvas = surface->getCanvas();
|
||||
auto dst_rect = Gfx::to_skia_rect(Gfx::Rect { 0, 0, width, height });
|
||||
|
||||
|
|
@ -184,6 +185,9 @@ Optional<WebGLRenderingContextBase::ConvertedTexture> WebGLRenderingContextBase:
|
|||
}
|
||||
|
||||
surface_canvas->drawImageRect(bitmap->sk_image(), dst_rect, Gfx::to_skia_sampling_options(Gfx::ScalingMode::NearestNeighbor));
|
||||
} else {
|
||||
VERIFY(buffer.is_empty());
|
||||
}
|
||||
|
||||
return ConvertedTexture {
|
||||
.buffer = move(buffer),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user