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,26 +165,30 @@ 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 });
|
||||
|
||||
// FIXME: Respect UNPACK_PREMULTIPLY_ALPHA_WEBGL
|
||||
// FIXME: Respect unpackColorSpace
|
||||
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());
|
||||
auto surface_canvas = surface->getCanvas();
|
||||
auto dst_rect = Gfx::to_skia_rect(Gfx::Rect { 0, 0, width, height });
|
||||
// The first pixel transferred from the source to the WebGL implementation corresponds to the upper left corner of
|
||||
// the source. This behavior is modified by the UNPACK_FLIP_Y_WEBGL pixel storage parameter, except for ImageBitmap
|
||||
// arguments, as described in the abovementioned section.
|
||||
if (m_unpack_flip_y && !source.has<GC::Root<HTML::ImageBitmap>>()) {
|
||||
surface_canvas->translate(0, dst_rect.height());
|
||||
surface_canvas->scale(1, -1);
|
||||
}
|
||||
|
||||
// The first pixel transferred from the source to the WebGL implementation corresponds to the upper left corner of
|
||||
// the source. This behavior is modified by the UNPACK_FLIP_Y_WEBGL pixel storage parameter, except for ImageBitmap
|
||||
// arguments, as described in the abovementioned section.
|
||||
if (m_unpack_flip_y && !source.has<GC::Root<HTML::ImageBitmap>>()) {
|
||||
surface_canvas->translate(0, dst_rect.height());
|
||||
surface_canvas->scale(1, -1);
|
||||
surface_canvas->drawImageRect(bitmap->sk_image(), dst_rect, Gfx::to_skia_sampling_options(Gfx::ScalingMode::NearestNeighbor));
|
||||
} else {
|
||||
VERIFY(buffer.is_empty());
|
||||
}
|
||||
|
||||
surface_canvas->drawImageRect(bitmap->sk_image(), dst_rect, Gfx::to_skia_sampling_options(Gfx::ScalingMode::NearestNeighbor));
|
||||
|
||||
return ConvertedTexture {
|
||||
.buffer = move(buffer),
|
||||
.width = width,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user