LibWeb: Return ImmutableBitmap from PaintingSurface::create_snapshot()

This is a preparation for upcoming changes where ImmutableBitmap will
own SkImage allowing Skia to cache GPU textures across repaints.
This commit is contained in:
Aliaksandr Kalenik
2024-11-09 02:36:31 +01:00
committed by Alexander Kalenik
parent 31bf40b659
commit a2c33ea4e1
13 changed files with 33 additions and 20 deletions

View File

@@ -268,7 +268,8 @@ String HTMLCanvasElement::to_data_url(StringView type, Optional<double> quality)
return "data:,"_string;
// 3. Let file be a serialization of this canvas element's bitmap as a file, passing type and quality if given.
auto file = serialize_bitmap(*m_surface->create_snapshot(), type, move(quality));
auto snapshot = m_surface->create_snapshot();
auto file = serialize_bitmap(snapshot->bitmap(), type, move(quality));
// 4. If file is null then return "data:,".
if (file.is_error()) {
@@ -300,7 +301,8 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(JS::NonnullGCPtr<WebIDL::Ca
// 3. If this canvas element's bitmap has pixels (i.e., neither its horizontal dimension nor its vertical dimension is zero),
// then set result to a copy of this canvas element's bitmap.
if (m_surface) {
bitmap_result = m_surface->create_snapshot();
auto snapshot = m_surface->create_snapshot();
bitmap_result = snapshot->bitmap();
}
// 4. Run these steps in parallel: